Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-f1778f50.cjs"),t=require("./message.cjs"),s=require("./poll.cjs"),n=require("./lib/__bundle-5857816a.cjs"),i=require("./lib/__bundle-e4acc296.cjs"),r=require("./lib/__bundle-8d3a0d9d.cjs"),o=require("./lib/__bundle-08e5d80c.cjs");require("./lib/__bundle-53308fa6.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;