UNPKG

laudantiumculpa

Version:
2 lines (1 loc) 22.3 kB
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-744bbd74.cjs"),n=require("./lib/__bundle-30ff8fb3.cjs"),t=require("./lib/__bundle-123524f2.cjs"),a=require("./lib/__bundle-b9e7e115.cjs"),s=require("./lib/__bundle-c931ed88.cjs");require("./lib/__bundle-dae7bdf2.cjs");class r extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const i={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class o extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class h extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class d extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends t.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const p={};class _ 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 r(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 T(this._iid,T.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(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);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageUpdated&&e.onMessageUpdated(a,n),t>0&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:r}=a.as(n.DeleteMessageEventCommand);if(s===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:s,event:r}=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,r)}))))}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,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(t,a)&&s.push(r)}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:r,channelType:i}=a.as(t.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const t=yield this.getChannel(r,!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:r}=a.as(n.PollVoteEventCommand);if(s&&r===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:r}=a.as(c),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(s.channelUrl,!0),{participantCount:t,user:r}=a.as(C),i=n._updateParticipantCount(t,s.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case t.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(s.channelUrl,!0),{operators:r}=a.as(t.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_MUTE:case t.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=a.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case t.ChannelEventCategory.USER_CHANNEL_BAN:case t.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(s.channelUrl,!0),i=s.category===t.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=a.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_FREEZE:case t.ChannelEventCategory.CHANNEL_UNFREEZE:{const t=yield this.getChannel(s.channelUrl,!0),{freeze:r}=a.as(n.FreezeEventCommand);t.isFrozen=r,this.upsertChannelsToCache([t]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?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:r,updated:i,deleted:o}=a.as(n.UpdateMetaDataEventCommand);r&&t._upsertCachedMetaData(r,s.ts),i&&t._upsertCachedMetaData(i,s.ts),o&&t._removeFromCachedMetaData(o,s.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(t,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(t,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(t,o)}))}))));break}case t.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const t=yield this.getChannel(s.channelUrl,!0),{created:r,updated:i,deleted:o}=a.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(t,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(t,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(t,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new o({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new h(t),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return this.upsertChannelsToCache([r]),r}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class m extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class E extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:s}=n;this.token=t,this.participants=s.map((n=>new a.Participant(e,n)))}}class f extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new m(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(E);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class g extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class y extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class U extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class T extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new f(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=_.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new d({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(c);this._updateParticipantCount(s,r);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield t.send(a),{participantCount:r,ts:i}=s.as(C);this._updateParticipantCount(r,i);_.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 g(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(y);this._update(i);const o=_.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},v),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new U({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class b 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}}class P extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class O extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new T(e,n)))),this.ts="number"==typeof s?s:null}}class A extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new P(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(O);this._token=r,this._hasNext=!!r;const i=_.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class w extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:r,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,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},i);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=r,this._manager.createChannel(e)}))}}exports.OpenChannel=T,exports.OpenChannelHandler=class extends b{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=A,exports.OpenChannelModule=w,exports.ParticipantListQuery=f;