-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgroupChannel.js
1 lines (1 loc) · 30.1 KB
/
groupChannel.js
1
import{_ as s,V as h,b as d,G as f,H as _,bf as v,bg as g,t as y,q as E,r as A,a6 as L,N as T,E as F,w as N,I as x,o as I,u as R,j as z,bh as B,ad as J,F as Z,c as $,A as ee,aE as te,e as ne,f as ae,g as re,a as ie,Y as se,a0 as oe,aT as le,aF as ue,bi as ce,aw as he,y as de,b4 as pe}from"./lib/__bundle-b6cf2704.js";export{bj as MessageEventSource,bk as MutedState}from"./lib/__bundle-b6cf2704.js";import{T as fe,G as _e,H as ve,s as me,a as ge,P as ye,b as Ce,S as be,c as Se,d as Me,v as Ee,e as Ae,f as Le,g as we,h as Te}from"./lib/__bundle-7541a242.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,i as GroupChannelEventSource,a as GroupChannelFilter,c as GroupChannelListQuery,j as GroupChannelSearchField,H as HiddenChannelFilter,k as HiddenState,M as Member,l as MemberListOrder,m as MemberListQuery,n as MemberState,o as MemberStateFilter,q as MessageCollection,r as MessageCollectionInitHandler,t as MessageCollectionInitPolicy,u as MutedMemberFilter,p as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,S as SuperChannelFilter,U as UnreadChannelFilter,w as UnreadItemKey}from"./lib/__bundle-7541a242.js";import{Q as Fe,T as ke,V as Ne}from"./lib/__bundle-7c21b511.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-7c21b511.js";import{c as xe,G as Ge,P as Ue,e as Ie}from"./lib/__bundle-31635626.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,e as ScheduledMessageListOrder}from"./lib/__bundle-31635626.js";import{B as Oe}from"./lib/__bundle-2356a701.js";import"./lib/__bundle-29410a44.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function e(e){var t=e._iid,n=e.limit,a=void 0===n?100:n,r=this;this.ref=0,this._iid=t,this._limit=a;var i,o=h.of(this._iid),l=o.sdkState,u=o.dispatcher,c=o.logger,p=o.cacheContext,m=o.statManager;this._metadataKey=(i=l.userId,"sendbird:".concat(i,"@groupchannel/sync.meta"));var C=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(l.userId);this._sync=new xe(C,(function(){return s(r,void 0,void 0,(function(){var e,t,n,a,r,i,s,o,u,h,f,_,C,b,S,M;return d(this,(function(d){switch(d.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(d.sent(),c.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,hiddenChannelFilter:ve.ALL,order:Ge.CHRONOLOGICAL},d.label=2;case 2:if(d.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];d.label=3;case 3:return d.trys.push([3,5,,6]),[4,p.preference.get(T(l.appId))];case 4:return n=d.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return d.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,_e.of(this._iid).getMyGroupChannels(null!==(_=null===(f=this._metadata)||void 0===f?void 0:f.token)&&void 0!==_?_:"",t,this._limit,L.SYNC_CHANNEL_BACKGROUND)];case 7:return a=d.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(o=this._metadata.range).extends.apply(o,E([],A(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),c.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return d.sent(),[3,13];case 9:return s=d.sent(),c.debug("channel background sync error",s),s instanceof y&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:d.sent(),d.label=11;case 11:throw s;case 12:return m.put(new v({type:g.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(b=null===(C=p.localCacheConfig)||void 0===C?void 0:C.maxSize)&&void 0!==b?b:0,use_local_cache:p.localCacheEnabled,starting_point:0,message_init_policy:null!==(M=null===(S=t.order)||void 0===S?void 0:S.toString())&&void 0!==M?M:"",collection_id:l.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",d.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof f)if(e.stateType===_.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t){return Pe[t]||(Pe[t]=new e({_iid:t})),Pe[t].ref++,Pe[t]},e.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[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 fe({})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return s(this,void 0,void 0,(function(){var e;return d(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,h.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new fe(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return s(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,h.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 s(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,h.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.resume=function(){var e,t,n=h.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:""))},e.prototype.pause=function(){h.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},e}(),Re={},Ve=function(){function e(e){var t=e._iid,n=this;this.ref=0,this._iid=t;var a,r=h.of(this._iid),i=r.logger,o=r.sdkState,l=r.dispatcher,u=r.cacheContext,c=r.statManager;this._metadataKey=(a=o.userId,"sendbird:".concat(a,"@groupchannel/changelogs.meta")),this._subscribers=new F;var p=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(o.userId);this._sync=new xe(p,(function(){return s(n,void 0,void 0,(function(){var e,t,n,a,r,s,l,h,p,f,_,m;return d(this,(function(d){switch(d.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:d.sent(),i.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),d.label=2;case 2:d.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},d.label=3;case 3:return d.trys.push([3,5,,6]),[4,u.preference.get(T(o.appId))];case 4:return n=d.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return d.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,_e.of(this._iid).getMyGroupChannelChangeLogs(null!==(m=null===(_=this._metadata)||void 0===_?void 0:_.token)&&void 0!==m?m:"",t,L.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=d.sent(),r=a.updatedChannels,s=a.deletedChannelUrls,l=a.hasMore,h=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:s,hasMore:l,token:h}),e.hasNext=l,e.nextToken=h,this._metadata&&(this._metadata.token=h),i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return d.sent(),u.localCacheEnabled&&c.put(new v({type:g.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||s.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:u.localCacheEnabled,starting_point:0,message_init_policy:s.length.toString(),collection_id:o.userId}})),[3,12];case 9:return p=d.sent(),i.debug("channel changelog sync error",p),p instanceof y&&p.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:d.sent(),d.label=11;case 11:throw p;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){n._subscribers.dispatch("pause")})),this._connectionEventContext=l.on((function(e){if(e instanceof f)if(e.stateType===_.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return Re[t]||(Re[t]=new e({_iid:t})),Re[t].ref++,Re[t]},e.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(e.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),e.prototype.loadMetadata=function(){return s(this,void 0,void 0,(function(){var e,t,n,a;return d(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=h.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]}}))}))},e.prototype.saveMetadata=function(){return s(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._metadata?[4,h.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 s(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,h.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},e.prototype.on=function(e,t){return this._subscribers.on(e,t)},e.prototype.resume=function(){h.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},e.prototype.pause=function(){this._sync.stop()},e.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},e}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},je=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);r<i;){var o=ze(e[s],t,n);if(o>0)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:ze(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},ze=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}},Qe=function(){function e(e,t){var n=t.filter,a=void 0===n?new ge:n,r=t.order,i=void 0===r?Ge.LATEST_LAST_MESSAGE:r,o=t.limit,l=void 0===o?Fe:o,u=t.includeChangesOnInitialLoad,c=void 0!==u&&u,p=this;this.channels=[],this._isInitialized=!1,this._iid=e,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=c,this.filter=a,this.order=i,this._hasMore=!0,this._token="",this._limit=l;var v=h.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(e),this._backgroundSync.resume()),this._changelogSync=Ve.of(e),this._changelogSync.resume(),_e.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return p.filter.match(e,m.userId)})),r=e.filter((function(e){return!p.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&p._addChannelsToView(a,t),r.length>0&&p._removeChannelsFromView(r,t)}},onRemove:function(e,t){p._removeChannelsFromView(e,t)}}),y.on((function(e){e instanceof f&&(e.stateType===_.CONNECTED?p._isGetRemoteChannelsSucceeded||s(p,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===_.LOGOUT&&p.dispose())}))}return Object.defineProperty(e.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),e.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},e.prototype._addChannelsToView=function(e,t,n){var a,r,i,o,l=this;void 0===n&&(n=!1);var u=[],c=[],h=[];try{for(var p=N(e),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=je(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!n&&this._hasMore||(u.push(_),this.channels.push(_)):(u.push(_),this.channels.splice(m,0,_));else switch(t.source){case L.EVENT_CHANNEL_UPDATED:case L.EVENT_MESSAGE_RECEIVED:case L.SYNC_CHANNEL_CHANGELOGS:case L.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?h.push(_):(this.channels.splice(m,0,_),c.push(_));break;default:this.channels.splice(m,0,_),c.push(_)}}}catch(e){a={error:e}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(a)throw a.error}}if(h.length>0)try{for(var g=N(h),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}me(t.source)&&x((function(){return s(l,void 0,void 0,(function(){var e,n,a;return d(this,(function(r){return u.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(t,u),c.length>0&&(null===(n=this._handler)||void 0===n?void 0:n.onChannelsUpdated)&&this._handler.onChannelsUpdated(t,c),h.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,h.map((function(e){return e.url}))),[2]}))}))}))},e.prototype._removeChannelsFromView=function(e,t){var n,a,r=this,i=[],o=function(e){var t=l.channels.findIndex((function(t){return t.url===e}));t>=0&&(i.push(l.channels[t].url),l.channels.splice(t,1))},l=this;try{for(var u=N(e),c=u.next();!c.done;c=u.next()){o(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}return me(t.source)&&i.length>0&&x((function(){return s(r,void 0,void 0,(function(){var e;return d(this,(function(n){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(t,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return s(this,void 0,void 0,(function(){var e,t;return d(this,(function(n){switch(n.label){case 0:return e=_e.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()]}}))}))},e.prototype._getRemoteChannels=function(){return s(this,void 0,void 0,(function(){var e,t,n;return d(this,(function(a){switch(a.label){case 0:return[4,_e.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]}}))}))},e.prototype._revokeLoadMore=function(){return s(this,void 0,void 0,(function(){var e;return d(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:L.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){var e;return s(this,void 0,void 0,(function(){var t,n,a,r,i,o,l,u,c,p,f,_,v,m,C,b,S,M,E,A=this;return d(this,(function(w){switch(w.label){case 0:if(this._isDisposed)throw new y({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return t=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){A._changelogSyncSubscriberContext=A._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:t=w.sent(),null===(e=this._changelogSyncSubscriberContext)||void 0===e||e.close(),w.label=2;case 2:return n=h.of(this._iid),a=n.cacheContext,r=n.connectionManager,i=n.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,a.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:w.sent(),w.label=4;case 4:i.put(new B({type:g.FEATURE_LOCALCACHE,data:{use_local_cache:a.localCacheEnabled,collection_interface:{group_channel:!0}}})),w.label=5;case 5:return o=[],this._hasMore?!a.localCacheEnabled||r.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return s(A,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return o=e.sent(),[2]}}))}))}))]:[3,11];case 6:return w.sent(),this._hasMore=o.length>=this._limit,[3,10];case 7:return w.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return o=w.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return w.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(o,{source:L.REQUEST_CHANNEL},!0),w.label=11;case 11:if(t){try{for(l=N(t.updatedChannels),u=l.next();!u.done;u=l.next())c=u.value,(C=Ke(o,c))>=0?o[C]=c:(p=je(o,c,this.order).place,o.splice(p,0,c))}catch(e){b={error:e}}finally{try{u&&!u.done&&(S=l.return)&&S.call(l)}finally{if(b)throw b.error}}f=o.map((function(e){return e.url}));try{for(_=N(t.deletedChannelUrls),v=_.next();!v.done;v=_.next())m=v.value,(C=f.indexOf(m))>=0&&(o.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{v&&!v.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,o]}}))}))},e.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(),_e.of(this._iid).unsubscribeChannelEvent(this._key))},e}(),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(e){function t(t,n){var a,r,i,s,o,l,u,c,h,d,p,f,_,v,m=this;return(m=e.call(this,t,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=be.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:be.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 $(t,e),t.prototype._validate=function(){return e.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(be,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)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,a,r,i,s;return d(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=h.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=o.sent(),r=a.as(Be),i=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,e];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},t}(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}(Oe)),Je=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),Xe=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 ke(t,e)})),a}return $(t,e),t}(re),Ze=function(e){function t(t,n){var a,r,i,s,o,l=this;return(l=e.call(this,t,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 $(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Ie,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(Ne,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},t.prototype.next=function(){return s(this,void 0,void 0,(function(){var e,t,n,a,r,i;return d(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=h.of(this._iid).requestQueue,t=new Je(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Xe),r=a.scheduledMessages,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},t}(le),$e=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="groupChannel",t}return $(t,e),t.prototype.init=function(t,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;e.prototype.init.call(this,t,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new _e(t,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},t.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new Qe(this._iid,e)},t.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Se(this._iid,e)},t.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},t.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},t.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(y.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(y.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},t.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},t.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},t.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},t.prototype.getChannel=function(e){return s(this,void 0,void 0,(function(){return d(this,(function(t){return de(ie("string",e)).throw(y.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getChannelWithoutCache=function(e){return s(this,void 0,void 0,(function(){return d(this,(function(t){return de(ie("string",e)).throw(y.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},t.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),s(this,void 0,void 0,(function(){var n;return d(this,(function(a){switch(a.label){case 0:return n=z(z({},Me),t),de(ie("string",e)&&Ee(n)).throw(y.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),s(this,void 0,void 0,(function(){var n;return d(this,(function(a){switch(a.label){case 0:return n=z(z({},Me),t),de(ie("number",e)&&Ee(n)).throw(y.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,a.sent()]}}))}))},t.prototype.getGroupChannelCount=function(e){return s(this,void 0,void 0,(function(){var t;return d(this,(function(n){return t=z(z({},Ae),e),de(Le(t)).throw(y.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},t.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._manager.getUnreadItemCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalUnreadChannelCount=function(){return s(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},t.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},t.prototype.createChannel=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var t;return d(this,(function(n){return t=z(z({},we),e),de(Te(t)).throw(y.invalidParameters),[2,this._manager.createChannel(t)]}))}))},t.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var t;return d(this,(function(n){return t=z(z({},we),e),de(Te(t)).throw(y.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},t.prototype.createChannelWithUserIds=function(e,t,n,a,r,i){return void 0===t&&(t=!1),void 0===r&&(r=""),void 0===i&&(i=""),s(this,void 0,void 0,(function(){var s;return d(this,(function(o){return s=z(z({},we),{invitedUserIds:e,isDistinct:t,name:n,data:r,customType:i}),"string"==typeof a?s.coverUrl=a:s.coverImage=a,[2,this.createChannel(s)]}))}))},t.prototype.markAsReadAll=function(){return s(this,void 0,void 0,(function(){return d(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},t.prototype.markAsReadWithChannelUrls=function(e){return s(this,void 0,void 0,(function(){return d(this,(function(t){return de(se("string",e)).throw(y.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},t.prototype.markAsDelivered=function(e){return s(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return de(ie("string",e)).throw(y.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},t}(pe);export{Qe as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery};