@sendbird/chat
Advanced tools
# Changelog | ||
## v4.14.3 (Sep 13, 2024) | ||
### **Improvements** | ||
- Fixed a bug where there was no mentionedUser when sending a message with mentionedUserId as CopyMessage | ||
## v4.14.2 (Aug 29, 2024) | ||
@@ -4,0 +7,0 @@ ### **Improvements** |
@@ -1,1 +0,1 @@ | ||
import{e,u as t,c as n,w as r,s as a,g as i,p as o,q as s,_ as c,b as u,af as l,t as h,b8 as d,B as f,A as p,d as v,f as _,h as g,bg as y,az as m,a as C,bp as b,aQ as w,Q as E,V as M,au as T,W as N,bq as k,z as x,a2 as I,C as S,O as A,a8 as U,G as D,an as F,bk as R,aw as O,ai as P,b9 as H,ba as L,aA as j,aO as G,a_ as V}from"./lib/__bundle-dd1a7eb2.js";import{i as z,aO as B,aj as Q,aP as q,ac as W,aQ as K,aR as J,T as Y,z as X,aS as Z,aT as $}from"./lib/__bundle-01cdb35b.js";export{aj as NotificationMessage,aR as NotificationMessageStatus}from"./lib/__bundle-01cdb35b.js";import{y as ee,z as te,A as ne,B as re,o as ae,E as ie,F as oe,I as se,b as ce}from"./lib/__bundle-cf484113.js";import{g as ue,N as le}from"./lib/__bundle-976bb868.js";import{D as he}from"./lib/__bundle-7fd2f830.js";import{B as de,C as fe,a as pe}from"./lib/__bundle-0cf4fcf7.js";import"./lib/__bundle-acd77193.js";var ve=function(){function n(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return n.payloadify=function(n){return e(t({id:n.id,name:n.name,is_default:n.isDefault}))},Object.defineProperty(n.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),n}(),_e=function(t){function l(e,n){var r=n.sdkState,a=n.cacheContext,i=n.channelManager,o=t.call(this,e)||this;return o._channels=new Map,o._sdkState=r,o._cacheContext=a,o._channelManager=i,o}return n(l,t),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(z)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,t){return void 0===t&&(t=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return o([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return this._channels.set(e,this._deserialize(t)),[2,this._channels.get(e)];n.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?B:n,a=e.backward,i=void 0!==a&&a,o=e.order,s=void 0===o?"latest_last_message":o,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,n,a,o,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=ue(s),n={where:function(e){if(t&&"latest_last_message"===s)if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAt<t)return!1;return!l||l!==e.url},index:e,backward:i},[4,this.collection.query(n)]):[3,3];case 1:return[4,u.sent().fetch({limit:r})];case 2:return a=u.sent(),(o=a.map((function(e){return c._deserialize(e)}))).forEach((function(e){c._channels.has(e.url)||c._channels.set(e.url,e)})),[2,o];case 3:return[2,[]]}}))}))},l.prototype.upsert=function(t){return c(this,void 0,void 0,(function(){var n,r,a,i=this;return u(this,(function(o){switch(o.label){case 0:if(n=[],t.forEach((function(t){if(i._channels.has(t.url)){var r=i._channels.get(t.url),a=e(t);Object.assign(r,a,{_iid:i._iid}),n.push(r)}else i._channels.set(t.url,t),n.push(t)})),!this.localCacheEnabled)return[3,2];for(r=[],a=0;a<n.length;a++)r.push(this._serialize(n[a],a));return[4,this.collection.upsertMany(r)];case 1:o.sent(),o.label=2;case 2:return[2,n]}}))}))},l.prototype.remove=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,7]),t=h(e),n=t.next(),s.label=1;case 1:return n.done?[3,4]:(r=n.value,this._channels.delete(r),this.localCacheEnabled?[4,this.collection.remove(r)]:[3,3]);case 2:s.sent(),s.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return a=s.sent(),i={error:a},[3,7];case 6:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},l.prototype.clear=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return this.clearMemoryCache(),this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},l.prototype.clearMemoryCache=function(){this._channels.clear()},l}(l),ge=function(e){function t(t){var n=t.channels,r=t.context,a=t.isWebSocketEventComing,i=void 0!==a&&a,o=e.call(this)||this;return o.channels=n,o.context=r,o.isWebSocketEventComing=i,o}return n(t,e),t}(d),ye=function(e){function t(t){var n=t.channelUrls,r=t.context,a=t.isWebSocketEventComing,i=void 0!==a&&a,o=e.call(this)||this;return o.channelUrls=n,o.context=r,o.isWebSocketEventComing=i,o}return n(t,e),t}(d),me=function(){function e(e){var t=e.feedChannelCache,n=e.notificationMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return c(a,void 0,void 0,(function(){var r,a,i,o,s,l,d=this;return u(this,(function(p){switch(p.label){case 0:return e instanceof ge?(r=e.channels,s=e.context,l=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof Ge})),[4,t.upsert(a)]):[3,3];case 1:return i=p.sent(),[4,Promise.all(a.map((function(e){return n.markAsReadByTimestamp(e.url,e.myLastRead)})))];case 2:return p.sent(),l||this._broadcastUpdateEvent(i,s),[3,8];case 3:return e instanceof ye?(o=e.channelUrls,s=e.context,l=e.isWebSocketEventComing,[4,t.remove(o)]):[3,6];case 4:return p.sent(),[4,f((function(){return c(d,void 0,void 0,(function(){var e,t,r,a,i,s;return u(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,7]),e=h(o),t=e.next(),c.label=1;case 1:return t.done?[3,4]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:c.sent(),c.label=3;case 3:return t=e.next(),[3,1];case 4:return[3,7];case 5:return a=c.sent(),i={error:a},[3,7];case 6:try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))}))];case 5:return p.sent(),l||this._broadcastRemoveEvent(o,s),[3,8];case 6:return e instanceof he?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,8];case 7:p.sent(),p.label=8;case 8:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var a=h(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onUpdate&&o.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var a=h(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onRemove&&o.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),Ce=!1,be=function(t){function r(n){var r=t.call(this)||this,a=n.userId,i=n.token,o=n.limit,s=n.includeEmpty;return r.method=p.GET,r.path="".concat(v,"/").concat(encodeURIComponent(a),"/my_group_channels"),r.params=e({token:i,limit:o,show_empty:null!=s?s:Ce,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"}),r}return n(r,t),r}(_),we=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.channels=[];var a=n.next,i=n.channels,o=n.ts;return r.token=a,r.ts=null!=o?o:0,r.channels=(null!=i?i:[]).map((function(e){return e.ts=o,new Ge(t,e)})),r}return n(t,e),t}(g),Ee=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,a=e.call(this)||this;return a.method=p.GET,a.path="".concat(r?y:m,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0},a}return n(t,e),t}(_),Me=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Ge(t,n),r}return n(t,e),t}(g),Te={includeEmpty:!0},Ne=function(e){return C("boolean",e.includeEmpty)},ke=function(r){function a(n){var a=n.userId,o=n.ts,s=n.token,c=n.params,u=r.call(this)||this,l=i(i({},Te),c).includeEmpty;return u.method=p.GET,u.path="".concat(v,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),u.params=e(t({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:l,change_ts:o||null,token:s})),u}return n(a,r),a}(_),xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedChannels=n.updated.map((function(e){return new Ge(t,e)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return n(t,e),t}(g),Ie=function(e){function t(){var t=e.call(this)||this;return t.method=p.GET,t.path="".concat(b,"/settings"),t}return n(t,e),t}(_),Se=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.jsonString=JSON.stringify(n),r}return n(t,e),t}(g),Ae=function(t){function r(n){var r=this,a=n.reverse,i=void 0!==a&&a,o=n.keys,s=n.limit,c=void 0===s?20:s,u=n.token;return(r=t.call(this)||this).method=p.GET,r.path="".concat(b,"/templates"),r.params=e({token:u,keys:o,limit:c,reverse:i,order:"updated_at",show_ui_template:!0,show_color_variables:!0}),r}return n(r,t),r}(_),Ue=function(e){function t(t,n){var r=e.call(this,t,n)||this,a=n.next,i=n.has_more,o=void 0!==i&&i,s=w(n,["next","has_more"]);return r.nextToken=a,r.hasMore=o,r.notificationTemplateList={jsonString:JSON.stringify(s)},r}return n(t,e),t}(g),De={reverse:!1,keys:void 0,limit:20},Fe=function(t){function r(n){var r=this,a=n.key;return(r=t.call(this)||this).method=p.GET,r.path="".concat(b,"/templates/").concat(a),r.params=e({key:a}),r}return n(r,t),r}(_),Re=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.jsonString=JSON.stringify(n),r}return n(t,e),t}(g),Oe=function(e){function t(t,n,r){var a,i,o,s=this;(s=e.call(this,t,"ADMM",r)||this).message=new Q(t,r);var c=M.of(t).sdkState;return s.isMentioned=T(s.message.mentionType,null!==(o=null!==(a=s.message.mentionedUserIds)&&void 0!==a?a:null===(i=s.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==o?o:[],c.userId),s}return n(t,e),t}(N),Pe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=p.GET,r.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_message_count"),r}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadFeedCount=n.unread_feed_count,r}n(t,e)}(g);var He={},Le=function(e){function l(t,n){var r=e.call(this,t,i(i({},n),{channelType:S.FEED}))||this;return r._feedChannelHandlers=new Map,r._feedChannelCache=new _e(r._iid,{sdkState:r._sdkState,cacheContext:r._cacheContext,channelManager:r}),r._feedChannelBroadcast=new me({feedChannelCache:r._feedChannelCache,dispatcher:r._dispatcher,notificationMessageCache:q.of(t)}),r._dispatcher.on((function(e){e instanceof N&&r._handleEvent(e).catch((function(e){if(A(e))throw e}))})),He[t]||(He[t]=r),r}return n(l,e),Object.defineProperty(l.prototype,"_notificationMessageCache",{get:function(){return q.of(this._iid)},enumerable:!1,configurable:!0}),l.of=function(e){return He[e]||(He[e]=new l(e,M.of(e))),He[e]},l.clear=function(e){He[e]&&delete He[e]},Object.defineProperty(l.prototype,"handlers",{get:function(){return o([],s(this._feedChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.buildFeedChannelFromSerializedData=function(e){var t=x(e);return new Ge(this._iid,Ge.payloadify(t))},l.prototype.addHandler=function(e,t){this._feedChannelHandlers.set(e,t)},l.prototype.removeHandler=function(e){this._feedChannelHandlers.delete(e)},l.prototype.clearHandler=function(){this._feedChannelHandlers.clear()},l.prototype.getMyFeedChannels=function(e,t,n){return c(this,void 0,void 0,(function(){var r,a,o,s,c;return u(this,(function(u){switch(u.label){case 0:return r=new be(i(i({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(r)];case 1:return a=u.sent(),o=a.as(we),s=o.channels,c=o.token,[2,{channels:s,token:c}]}}))}))},l.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),c(this,void 0,void 0,(function(){var n;return u(this,(function(i){switch(i.label){case 0:r(C("string",e)).throw(a.invalidParameters),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=i.sent())?[2,n]:[3,4];case 3:return i.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,i.sent()]}}))}))},l.prototype.getChannelFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return r(C("string",e)).throw(a.invalidParameters),[4,this._feedChannelCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),c(this,void 0,void 0,(function(){var n,i,o,c;return u(this,(function(u){switch(u.label){case 0:return r(C("string",e)).throw(a.invalidParameters),n=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:return i=u.sent(),o=i.as(Me).channel,[4,this.upsertChannelsToCache([o])];case 2:return c=s.apply(void 0,[u.sent(),1]),[2,c[0]]}}))}))},l.prototype.getMyFeedChannelChangeLogs=function(e,n,o){return void 0===o&&(o=I.REQUEST_CHANNEL_CHANGELOGS),c(this,void 0,void 0,(function(){var s,c,l,h,d,f,p,v;return u(this,(function(u){switch(u.label){case 0:return s=i(i({},Te),n),r((C("string",e)||C("number",e))&&Ne(s)).throw(a.invalidParameters),c=new ke(t({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,params:s})),[4,this._requestQueue.send(c)];case 1:return l=u.sent(),h=l.as(xe),d=h.updatedChannels,f=h.deletedChannelUrls,p=h.hasMore,v=h.token,d.length>0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0<e.length&&e.length<=15&&t.length<=30){try{for(r=h(t),a=r.next();!a.done;a=r.next())(i=a.value)&&i.notificationId&&i.notificationData&&n.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"custom",topic:e,template_key:i.notificationData.templateKey,channel_url:this.url,message_id:i.notificationId,tags:i.notificationData.tags,source:"notification",message_ts:i.createdAt,notification_event_deadline:i.notificationEventDeadline}}))}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new je(this._iid,i({channel:this},e))},t}(X),Ve=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){Object.prototype.hasOwnProperty.call(n,e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onChannelChanged=j,this.onChannelDeleted=j,this.onMessageReceived=j,this.onMentionReceived=j})),ze=function(e){function r(t,n){var r,a=this;return(a=e.call(this,t,n)||this).includeEmpty=Ce,a.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r?r:Ce,a}return n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&C("boolean",this.includeEmpty)},r.prototype.next=function(){return c(this,void 0,void 0,(function(){var e,n,r,o,s;return u(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Le.of(this._iid),n=t(i({},this)),[4,e.getMyFeedChannels(this._token,n,this.limit)]):[3,2]:[3,5];case 1:return r=c.sent(),o=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw a.queryInProgress;case 4:return[3,6];case 5:throw a.invalidParameters;case 6:return[2]}}))}))},r}(G),Be=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="feedChannel",t}return n(t,e),t.prototype.init=function(t,n){e.prototype.init.call(this,t,n),this._manager=new Le(t,n)},t.prototype.buildFeedChannelFromSerializedData=function(e){return this._manager.buildFeedChannelFromSerializedData(e)},t.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new ze(this._iid,e)},t.prototype.addFeedChannelHandler=function(e,t){r(C("string",e)&&t instanceof Ve).throw(a.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeFeedChannelHandler=function(e){r(C("string",e)).throw(a.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},t.prototype.getChannel=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return r(C("string",e)).throw(a.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return u(this,(function(o){switch(o.label){case 0:return n=i(i({},Te),t),r(C("number",e)&&Ne(n)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getMyFeedChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return u(this,(function(o){switch(o.label){case 0:return n=i(i({},Te),t),r(C("string",e)&&Ne(n)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.getTotalUnreadNotificationCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadNotificationCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},t.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.refreshNotificationCollections=function(){this._manager.refreshNotificationCollections()},t}(V);export{Ge as FeedChannel,Ve as FeedChannelHandler,ze as FeedChannelListQuery,Be as FeedChannelModule,ve as NotificationCategory,je as NotificationCollection}; | ||
import{e,u as t,c as n,w as r,s as a,g as i,p as o,q as s,_ as c,b as u,af as l,t as h,b8 as d,B as f,A as p,d as v,f as _,h as g,bg as y,az as m,a as C,bp as b,aQ as w,Q as E,V as M,au as T,W as N,bq as k,z as x,a2 as I,C as S,O as A,a8 as U,G as D,an as F,bk as R,aw as O,ai as P,b9 as H,ba as L,aA as j,aO as G,a_ as V}from"./lib/__bundle-85fbca74.js";import{i as z,aO as B,aj as Q,aP as q,ac as W,aQ as K,aR as J,T as Y,z as X,aS as Z,aT as $}from"./lib/__bundle-3ceb5f92.js";export{aj as NotificationMessage,aR as NotificationMessageStatus}from"./lib/__bundle-3ceb5f92.js";import{y as ee,z as te,A as ne,B as re,o as ae,E as ie,F as oe,I as se,b as ce}from"./lib/__bundle-0e590e6a.js";import{g as ue,N as le}from"./lib/__bundle-80bd1744.js";import{D as he}from"./lib/__bundle-b7a55976.js";import{B as de,C as fe,a as pe}from"./lib/__bundle-ace226dc.js";import"./lib/__bundle-acd77193.js";var ve=function(){function n(e){this.id=e.id,this.name=e.name,this.isDefault=e.is_default}return n.payloadify=function(n){return e(t({id:n.id,name:n.name,is_default:n.isDefault}))},Object.defineProperty(n.prototype,"customType",{get:function(){return this.isDefault?"*":String(this.id)},enumerable:!1,configurable:!0}),n}(),_e=function(t){function l(e,n){var r=n.sdkState,a=n.cacheContext,i=n.channelManager,o=t.call(this,e)||this;return o._channels=new Map,o._sdkState=r,o._cacheContext=a,o._channelManager=i,o}return n(l,t),Object.defineProperty(l.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return r(!!e).throw(a.databaseError),e.collection(z)},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),l.prototype._serialize=function(e,t){return void 0===t&&(t=0),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},l.prototype._deserialize=function(e){return this._channelManager.buildFeedChannelFromSerializedData(e)},Object.defineProperty(l.prototype,"channels",{get:function(){return o([],s(this._channels.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.isCachedInMemory=function(e){return this._channels.has(e)},l.prototype.get=function(e){return c(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return this._channels.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return this._channels.set(e,this._deserialize(t)),[2,this._channels.get(e)];n.label=2;case 2:return[2,void 0];case 3:return[2,this._channels.get(e)]}}))}))},l.prototype.fetch=function(e){var t=e.token,n=e.limit,r=void 0===n?B:n,a=e.backward,i=void 0!==a&&a,o=e.order,s=void 0===o?"latest_last_message":o,l=e.borderlineChannelUrl;return c(this,void 0,void 0,(function(){var e,n,a,o,c=this;return u(this,(function(u){switch(u.label){case 0:return this.localCacheEnabled?(e=ue(s),n={where:function(e){if(t&&"latest_last_message"===s)if(!i&&e.lastMessageUpdatedAt>t||i&&e.lastMessageUpdatedAt<t)return!1;return!l||l!==e.url},index:e,backward:i},[4,this.collection.query(n)]):[3,3];case 1:return[4,u.sent().fetch({limit:r})];case 2:return a=u.sent(),(o=a.map((function(e){return c._deserialize(e)}))).forEach((function(e){c._channels.has(e.url)||c._channels.set(e.url,e)})),[2,o];case 3:return[2,[]]}}))}))},l.prototype.upsert=function(t){return c(this,void 0,void 0,(function(){var n,r,a,i=this;return u(this,(function(o){switch(o.label){case 0:if(n=[],t.forEach((function(t){if(i._channels.has(t.url)){var r=i._channels.get(t.url),a=e(t);Object.assign(r,a,{_iid:i._iid}),n.push(r)}else i._channels.set(t.url,t),n.push(t)})),!this.localCacheEnabled)return[3,2];for(r=[],a=0;a<n.length;a++)r.push(this._serialize(n[a],a));return[4,this.collection.upsertMany(r)];case 1:o.sent(),o.label=2;case 2:return[2,n]}}))}))},l.prototype.remove=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){switch(s.label){case 0:s.trys.push([0,5,6,7]),t=h(e),n=t.next(),s.label=1;case 1:return n.done?[3,4]:(r=n.value,this._channels.delete(r),this.localCacheEnabled?[4,this.collection.remove(r)]:[3,3]);case 2:s.sent(),s.label=3;case 3:return n=t.next(),[3,1];case 4:return[3,7];case 5:return a=s.sent(),i={error:a},[3,7];case 6:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},l.prototype.clear=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return this.clearMemoryCache(),this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},l.prototype.clearMemoryCache=function(){this._channels.clear()},l}(l),ge=function(e){function t(t){var n=t.channels,r=t.context,a=t.isWebSocketEventComing,i=void 0!==a&&a,o=e.call(this)||this;return o.channels=n,o.context=r,o.isWebSocketEventComing=i,o}return n(t,e),t}(d),ye=function(e){function t(t){var n=t.channelUrls,r=t.context,a=t.isWebSocketEventComing,i=void 0!==a&&a,o=e.call(this)||this;return o.channelUrls=n,o.context=r,o.isWebSocketEventComing=i,o}return n(t,e),t}(d),me=function(){function e(e){var t=e.feedChannelCache,n=e.notificationMessageCache,r=e.dispatcher,a=this;this._observers=new Map,r.on((function(e){return c(a,void 0,void 0,(function(){var r,a,i,o,s,l,d=this;return u(this,(function(p){switch(p.label){case 0:return e instanceof ge?(r=e.channels,s=e.context,l=e.isWebSocketEventComing,a=r.filter((function(e){return e instanceof Ge})),[4,t.upsert(a)]):[3,3];case 1:return i=p.sent(),[4,Promise.all(a.map((function(e){return n.markAsReadByTimestamp(e.url,e.myLastRead)})))];case 2:return p.sent(),l||this._broadcastUpdateEvent(i,s),[3,8];case 3:return e instanceof ye?(o=e.channelUrls,s=e.context,l=e.isWebSocketEventComing,[4,t.remove(o)]):[3,6];case 4:return p.sent(),[4,f((function(){return c(d,void 0,void 0,(function(){var e,t,r,a,i,s;return u(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,7]),e=h(o),t=e.next(),c.label=1;case 1:return t.done?[3,4]:(r=t.value,[4,n.removeMessagesOfChannel(r)]);case 2:c.sent(),c.label=3;case 3:return t=e.next(),[3,1];case 4:return[3,7];case 5:return a=c.sent(),i={error:a},[3,7];case 6:try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))}))];case 5:return p.sent(),l||this._broadcastRemoveEvent(o,s),[3,8];case 6:return e instanceof he?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,8];case 7:p.sent(),p.label=8;case 8:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var a=h(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onUpdate&&o.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var a=h(this._observers.values()),i=a.next();!i.done;i=a.next()){var o=i.value;o.onRemove&&o.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),Ce=!1,be=function(t){function r(n){var r=t.call(this)||this,a=n.userId,i=n.token,o=n.limit,s=n.includeEmpty;return r.method=p.GET,r.path="".concat(v,"/").concat(encodeURIComponent(a),"/my_group_channels"),r.params=e({token:i,limit:o,show_empty:null!=s?s:Ce,show_read_receipt:!0,show_delivery_receipt:!0,show_member:!0,is_feed_channel:!0,order:"latest_last_message"}),r}return n(r,t),r}(_),we=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.channels=[];var a=n.next,i=n.channels,o=n.ts;return r.token=a,r.ts=null!=o?o:0,r.channels=(null!=i?i:[]).map((function(e){return e.ts=o,new Ge(t,e)})),r}return n(t,e),t}(g),Ee=function(e){function t(t){var n=t.channelUrl,r=t.isInternalCall,a=e.call(this)||this;return a.method=p.GET,a.path="".concat(r?y:m,"/").concat(encodeURIComponent(n)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,is_feed_channel:!0},a}return n(t,e),t}(_),Me=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.channel=new Ge(t,n),r}return n(t,e),t}(g),Te={includeEmpty:!0},Ne=function(e){return C("boolean",e.includeEmpty)},ke=function(r){function a(n){var a=n.userId,o=n.ts,s=n.token,c=n.params,u=r.call(this)||this,l=i(i({},Te),c).includeEmpty;return u.method=p.GET,u.path="".concat(v,"/").concat(encodeURIComponent(a),"/my_group_channels/changelogs"),u.params=e(t({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,is_feed_channel:!0,show_empty:l,change_ts:o||null,token:s})),u}return n(a,r),a}(_),xe=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedChannels=n.updated.map((function(e){return new Ge(t,e)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return n(t,e),t}(g),Ie=function(e){function t(){var t=e.call(this)||this;return t.method=p.GET,t.path="".concat(b,"/settings"),t}return n(t,e),t}(_),Se=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.jsonString=JSON.stringify(n),r}return n(t,e),t}(g),Ae=function(t){function r(n){var r=this,a=n.reverse,i=void 0!==a&&a,o=n.keys,s=n.limit,c=void 0===s?20:s,u=n.token;return(r=t.call(this)||this).method=p.GET,r.path="".concat(b,"/templates"),r.params=e({token:u,keys:o,limit:c,reverse:i,order:"updated_at",show_ui_template:!0,show_color_variables:!0}),r}return n(r,t),r}(_),Ue=function(e){function t(t,n){var r=e.call(this,t,n)||this,a=n.next,i=n.has_more,o=void 0!==i&&i,s=w(n,["next","has_more"]);return r.nextToken=a,r.hasMore=o,r.notificationTemplateList={jsonString:JSON.stringify(s)},r}return n(t,e),t}(g),De={reverse:!1,keys:void 0,limit:20},Fe=function(t){function r(n){var r=this,a=n.key;return(r=t.call(this)||this).method=p.GET,r.path="".concat(b,"/templates/").concat(a),r.params=e({key:a}),r}return n(r,t),r}(_),Re=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.jsonString=JSON.stringify(n),r}return n(t,e),t}(g),Oe=function(e){function t(t,n,r){var a,i,o,s=this;(s=e.call(this,t,"ADMM",r)||this).message=new Q(t,r);var c=M.of(t).sdkState;return s.isMentioned=T(s.message.mentionType,null!==(o=null!==(a=s.message.mentionedUserIds)&&void 0!==a?a:null===(i=s.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==o?o:[],c.userId),s}return n(t,e),t}(N),Pe=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=p.GET,r.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_message_count"),r}return n(t,e),t}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.unreadFeedCount=n.unread_feed_count,r}n(t,e)}(g);var He={},Le=function(e){function l(t,n){var r=e.call(this,t,i(i({},n),{channelType:S.FEED}))||this;return r._feedChannelHandlers=new Map,r._feedChannelCache=new _e(r._iid,{sdkState:r._sdkState,cacheContext:r._cacheContext,channelManager:r}),r._feedChannelBroadcast=new me({feedChannelCache:r._feedChannelCache,dispatcher:r._dispatcher,notificationMessageCache:q.of(t)}),r._dispatcher.on((function(e){e instanceof N&&r._handleEvent(e).catch((function(e){if(A(e))throw e}))})),He[t]||(He[t]=r),r}return n(l,e),Object.defineProperty(l.prototype,"_notificationMessageCache",{get:function(){return q.of(this._iid)},enumerable:!1,configurable:!0}),l.of=function(e){return He[e]||(He[e]=new l(e,M.of(e))),He[e]},l.clear=function(e){He[e]&&delete He[e]},Object.defineProperty(l.prototype,"handlers",{get:function(){return o([],s(this._feedChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),l.prototype.buildFeedChannelFromSerializedData=function(e){var t=x(e);return new Ge(this._iid,Ge.payloadify(t))},l.prototype.addHandler=function(e,t){this._feedChannelHandlers.set(e,t)},l.prototype.removeHandler=function(e){this._feedChannelHandlers.delete(e)},l.prototype.clearHandler=function(){this._feedChannelHandlers.clear()},l.prototype.getMyFeedChannels=function(e,t,n){return c(this,void 0,void 0,(function(){var r,a,o,s,c;return u(this,(function(u){switch(u.label){case 0:return r=new be(i(i({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(r)];case 1:return a=u.sent(),o=a.as(we),s=o.channels,c=o.token,[2,{channels:s,token:c}]}}))}))},l.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),c(this,void 0,void 0,(function(){var n;return u(this,(function(i){switch(i.label){case 0:r(C("string",e)).throw(a.invalidParameters),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=i.sent())?[2,n]:[3,4];case 3:return i.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,t)];case 5:return[2,i.sent()]}}))}))},l.prototype.getChannelFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return r(C("string",e)).throw(a.invalidParameters),[4,this._feedChannelCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getChannelWithoutCache=function(e,t){return void 0===t&&(t=!1),c(this,void 0,void 0,(function(){var n,i,o,c;return u(this,(function(u){switch(u.label){case 0:return r(C("string",e)).throw(a.invalidParameters),n=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:return i=u.sent(),o=i.as(Me).channel,[4,this.upsertChannelsToCache([o])];case 2:return c=s.apply(void 0,[u.sent(),1]),[2,c[0]]}}))}))},l.prototype.getMyFeedChannelChangeLogs=function(e,n,o){return void 0===o&&(o=I.REQUEST_CHANNEL_CHANGELOGS),c(this,void 0,void 0,(function(){var s,c,l,h,d,f,p,v;return u(this,(function(u){switch(u.label){case 0:return s=i(i({},Te),n),r((C("string",e)||C("number",e))&&Ne(s)).throw(a.invalidParameters),c=new ke(t({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,params:s})),[4,this._requestQueue.send(c)];case 1:return l=u.sent(),h=l.as(xe),d=h.updatedChannels,f=h.deletedChannelUrls,p=h.hasMore,v=h.token,d.length>0&&this._dispatcher.dispatch(new ge({channels:d,context:{source:o}})),f.length>0&&this._dispatcher.dispatch(new ye({channelUrls:f,context:{source:o}})),[2,{updatedChannels:d,deletedChannelUrls:f,hasMore:p,token:v}]}}))}))},l.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){var t,n,o,s,c,l,h;return u(this,(function(u){switch(u.label){case 0:return t=i(i({},te),e),r(ne(t)).throw(a.invalidParameters),n=M.of(this._iid),o=n.sdkState,s=n.requestQueue,c=new re({userId:o.userId,filter:t,includeFeedChannel:!0}),[4,s.send(c)];case 1:return l=u.sent(),h=l.as(ee).unreadFeedCount,[2,void 0===h?0:h]}}))}))},l.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){var e,t,n,r,a,i;return u(this,(function(o){switch(o.label){case 0:return e=M.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pe({userId:t.userId}),[4,n.send(r)];case 1:return a=o.sent(),i=a.as(ee).unreadFeedCount,[2,void 0===i?0:i]}}))}))},l.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){var e,t;return u(this,(function(n){switch(n.label){case 0:return e=new Ie,[4,this._requestQueue.send(e)];case 1:return t=n.sent(),[2,{jsonString:t.as(Se).jsonString}]}}))}))},l.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n,o,s,c,l,h,d;return u(this,(function(u){switch(u.label){case 0:return n=i(i({},De),t),r(C("string",e)&&function(e){return C("boolean",e.reverse,!0)&&E("string",e.keys,!0)&&C("number",e.limit,!0)}(n)).throw(a.invalidParameters),o=new Ae({token:e,keys:n.keys,reverse:n.reverse,limit:n.limit}),[4,this._requestQueue.send(o)];case 1:return s=u.sent(),c=s.as(Ue),l=c.hasMore,h=c.nextToken,d=c.notificationTemplateList,[2,{hasMore:l,token:h,notificationTemplateList:d}]}}))}))},l.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){var t,n;return u(this,(function(i){switch(i.label){case 0:return r(C("string",e)).throw(a.invalidParameters),t=new Fe({key:e}),[4,this._requestQueue.send(t)];case 1:return n=i.sent(),[2,{jsonString:n.as(Re).jsonString}]}}))}))},l.prototype.upsertChannelsToCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.upsert(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.removeChannelsFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._feedChannelCache.remove(e)];case 1:return t.sent(),[2]}}))}))},l.prototype.getNotificationMessageFromCache=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,t.sent()]}}))}))},l.prototype.refreshChannel=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=I.REFRESH_CHANNEL),c(this,void 0,void 0,(function(){var r,a,i,o,s;return u(this,(function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),r=new Ee({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return a=c.sent(),(i=a.as(Me).channel).myMemberState!==ae.NONE?[3,2]:(this._dispatcher.dispatch(new ye({channelUrls:[i.url],context:{source:n}})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:o=c.sent(),this._dispatcher.dispatch(new ge({channels:o,context:{source:n}})),c.label=4;case 4:return[3,6];case 5:return(s=c.sent()).code!==U.NON_AUTHORIZED&&s.code!==U.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new ye({channelUrls:[e],context:{source:n}})),[3,6];case 6:return[2]}}))}))},l.prototype.refreshNotificationCollections=function(){this._dispatcher.dispatch(new le)},l.prototype.subscribeChannelEvent=function(e,t){this._feedChannelBroadcast.subscribe(e,t)},l.prototype.unsubscribeChannelEvent=function(e){this._feedChannelBroadcast.unsubscribe(e)},l.prototype._handleEvent=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,l,d,f,p=this;return u(this,(function(v){switch(v.label){case 0:switch(e.code){case"ADMM":case"BRDM":return[3,1];case"READ":return[3,4];case"SYEV":return[3,7]}return[3,13];case 1:return(s="ADMM"===e.code||"BRDM"===e.code?e.as(Oe):null)&&s.message.channelType===this._channelType?(t=s.message,n=s.isMentioned,[4,this.getChannel(t.channelUrl,!0)]):[3,3];case 2:(r=v.sent())._runIfHandleableWithGroupChannel((function(e){var a;t instanceof Q&&n&&(null===(a=t.mentionedUsers)||void 0===a||a.forEach((function(t){var n,r;try{for(var a=h(e.members),i=a.next();!i.done;i=a.next()){var o=i.value;if(t.userId===o.userId){t.nickname=o.nickname,t.plainProfileUrl=o.plainProfileUrl,t.metaData=o.metaData;break}}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}))),p._dispatcher.dispatch(new ge({channels:[r],context:{source:I.EVENT_MESSAGE_RECEIVED}})),p._dispatcher.dispatch(new F({messages:[t],source:I.EVENT_MESSAGE_RECEIVED})),D((function(){return c(p,void 0,void 0,(function(){var e,a,i,o,s;return u(this,(function(c){try{for(e=h(this._feedChannelHandlers.values()),a=e.next();!a.done;a=e.next())(i=a.value).onMessageReceived&&i.onMessageReceived(r,t),n&&i.onMentionReceived&&i.onMentionReceived(r,t)}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=e.return)&&s.call(e)}finally{if(o)throw o.error}}return[2]}))}))}))})),v.label=3;case 3:return[3,13];case 4:return(s="READ"===e.code?e.as(W):null)&&s.readStatus.channelType===this._channelType?(a=s.readStatus,i=this._feedChannelCache.isCachedInMemory(a.channelUrl),[4,this.getChannel(a.channelUrl,!0)]):[3,6];case 5:(o=v.sent())._runIfHandleableWithGroupChannel((function(e){i&&e._updateUnreadMemberState(a.reader.userId,a.readAt),a.reader.userId===p._sdkState.userId&&(i?(e.unreadMessageCount>0||e.unreadMentionCount>0)&&(e._updateUnreadCount(0,0),p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==e.unreadMessageCount&&0!==e.unreadMentionCount||(p._dispatcher.dispatch(new ge({channels:[o],context:{source:I.EVENT_CHANNEL_READ}})),D((function(){return c(p,void 0,void 0,(function(){var e,t,n,r,a;return u(this,(function(i){try{for(e=h(this._feedChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(o)}catch(e){r={error:e}}finally{try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))))})),v.label=6;case 6:return[3,13];case 7:if(!(s="SYEV"===e.code?e.as(fe):null)||s.event.channelType!==this._channelType)return[3,12];switch(l=s.event,l.category){case pe.CHANNEL_DELETED:return[3,8];case pe.CHANNEL_PROP_CHANGED:return[3,10]}return[3,12];case 8:return[4,this.getChannel(l.channelUrl,!0)];case 9:return d=v.sent(),this._dispatcher.dispatch(new ye({channelUrls:[l.channelUrl],context:{source:I.EVENT_CHANNEL_DELETED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(d.url,d.channelType)})),[2]}))}))})),[3,12];case 10:return[4,this.getChannelWithoutCache(l.channelUrl,!0)];case 11:return f=v.sent(),this._dispatcher.dispatch(new ge({channels:[f],context:{source:I.EVENT_CHANNEL_UPDATED}})),D((function(){return c(p,void 0,void 0,(function(){return u(this,(function(e){return this._feedChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(f)})),[2]}))}))})),[3,12];case 12:return[3,13];case 13:return[2]}}))}))},l.prototype.getMessageFromCache=function(e){var t;return c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._notificationMessageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},l.prototype.getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return c(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},l.prototype.getMessagesFromCache=function(e,t,n,r,a,i){return void 0===a&&(a=K),void 0===i&&(i=!0),c(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,this._notificationMessageCache.fetch({channelUrl:e,token:t,limit:a,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,o.sent()]}}))}))},l}(de),je=function(e){function t(t,n){var r=e.call(this,t,i(i({},n),{channelManager:Le.of(t)}))||this,a=M.of(r._iid),o=a.connectionManager,s=a.dispatcher;return r._notificationCollectionEventContext=s.on((function(e){e instanceof le&&O(10).then((function(){o.isConnected||o.isConnecting||r.refresh()}))})),r}return n(t,e),t.prototype.keyOf=function(e){return e.notificationId},Object.defineProperty(t.prototype,"changelogIncludeParams",{get:function(){return{includeReactions:!1,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0}},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._notificationCollectionEventContext.close()},t.prototype.setMessageCollectionHandler=function(e){this._setBaseMessageCollectionHandler(e)},t.prototype._postprocessChannelUpdateEvent=function(e,t){var n,r,a=this._messages.filter((function(t){return t.messageStatus===J.SENT&&t.createdAt<=e.myLastRead}));if(a.length>0){try{for(var i=h(a),o=i.next();!o.done;o=i.next()){o.value.messageStatus=J.READ}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}this._updateMessagesToView(a,t)}},t.prototype._postprocessMessageUpdateEvent=function(e,t){var n,r;if(t===I.EVENT_CHANNEL_READ){var a=[],i=this._messages.map((function(e){return e.notificationId}));try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var c=s.value.notificationId,u=i.indexOf(c);u>=0&&(this._messages[u].messageStatus=J.READ,a.push(this._messages[u]))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}a.length>0&&this._updateMessagesToView(a,t)}},t.prototype._addMessagesToView=function(e,t){var n,r,a=this,i=this._filterUnderOffsetMessage(e),o=[],s=[];try{for(var l=h(i),d=l.next();!d.done;d=l.next()){var f,p=d.value;if(t===I.SYNC_MESSAGE_FILL){if((f=ie(this._messages,p))<0){var v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}}else if((f=ie(this._messages,p))<0){v=oe(this._messages,p);this._messages.splice(v,0,p),o.push(p)}else this._messages[f]=p,s.push(p)}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r,a,i;return u(this,(function(c){return e={source:t},o.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesAdded)||void 0===r||r.call(n,e,this.channel,o)),s.length>0&&(null===(i=null===(a=this._handler)||void 0===a?void 0:a.onMessagesUpdated)||void 0===i||i.call(a,e,this.channel,s)),[2]}))}))}))},t.prototype._updateMessagesToView=function(e,t){var n,r,a=this,i=[];try{for(var o=h(e),s=o.next();!s.done;s=o.next()){var l=s.value,d=ie(this._messages,l);d>=0&&(i.push(l),this._messages[d]=l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return R(t)&&D((function(){return c(a,void 0,void 0,(function(){var e,n,r;return u(this,(function(a){return e={source:t},i.length>0&&(null===(r=null===(n=this._handler)||void 0===n?void 0:n.onMessagesUpdated)||void 0===r||r.call(n,e,this.channel,i)),[2]}))}))})),i},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._activate()];case 1:return e.sent(),[2]}}))}))},t}(se),Ge=function(e){function t(t,n){var r,a,o=this;return(o=e.call(this,t,n)||this).channelType=S.FEED,o._groupChannel=new ce(t,n),o.isCategoryFilterEnabled=null!==(r=n.is_category_filter_enabled)&&void 0!==r&&r,o.isTemplateLabelEnabled=null===(a=n.is_template_label_enabled)||void 0===a||a,o.notificationCategories=n.categories?n.categories.map((function(e){return new ve(e)})):[],o.lastMessage=n.last_message?Y(o._iid,i({channel_type:o.channelType},n.last_message)):null,o}return n(t,e),t.payloadify=function(e){var t;return i(i({},ce.payloadify(null!==(t=e._groupChannel)&&void 0!==t?t:e)),{is_category_filter_enabled:e.isCategoryFilterEnabled,is_template_label_enabled:e.isTemplateLabelEnabled,categories:e.notificationCategories.map((function(e){return ve.payloadify(e)})),last_message:e.lastMessage?Q.payloadify(e.lastMessage):null})},Object.defineProperty(t.prototype,"groupChannel",{get:function(){return this._groupChannel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._groupChannel.url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._groupChannel.name},set:function(e){this._groupChannel.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._groupChannel.createdAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"members",{get:function(){return this._groupChannel.members},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"memberCount",{get:function(){return this._groupChannel.memberCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myMemberState",{get:function(){return this._groupChannel.myMemberState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"myLastRead",{get:function(){return this._groupChannel.myLastRead},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unreadMessageCount",{get:function(){return this._groupChannel.unreadMessageCount},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){var e,t;return i(i({},this._groupChannel.serialize()),{notificationCategories:this.notificationCategories.map((function(e){return P(e)})),lastMessage:null!==(t=null===(e=this.lastMessage)||void 0===e?void 0:e.serialize())&&void 0!==t?t:null})},t.prototype.refresh=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._groupChannel._refresh(!0)];case 1:return e.sent(),[2,this]}}))}))},t.prototype.markAsRead=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o,s,c,l,h,d=this;return u(this,(function(u){switch(u.label){case 0:return t=M.of(this._iid),n=t.sdkState,r=t.dispatcher,a=t.requestQueue,!(i=null==e?void 0:e.filter((function(e){return!e||e.messageStatus===J.SENT})).map((function(e){return e.notificationId})))||i.length>0?(o=new $({userId:n.userId,channelUrl:this.url,channelType:S.FEED,notificationIds:i}),[4,a.send(o)]):[3,2];case 1:s=u.sent(),c=s.as(Z),l=c.unreadMessageCount,h=c.readAt,e?("number"==typeof l&&(this._groupChannel._updateUnreadCount(l,this._groupChannel.unreadMentionCount),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)}))),e.forEach((function(e){e.messageStatus=J.READ})),r.dispatch(new F({messages:e,source:I.EVENT_CHANNEL_READ}))):(this._groupChannel._updateUnreadMemberState(n.userId,h),this._groupChannel.unreadMessageCount!==l&&(this._groupChannel._updateUnreadCount(l,0),Le.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(d)})))),r.dispatch(new ge({channels:[this],context:{source:I.EVENT_CHANNEL_READ}})),u.label=2;case 2:return[2]}}))}))},t.prototype.markAsClicked=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.logClicked(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.logClicked=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30)try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"clicked",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2]}))}))},t.prototype.logImpression=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return[2,this.logViewed(e)]}))}))},t.prototype.logViewed=function(e){return c(this,void 0,void 0,(function(){var t,n,r,a,i,o;return u(this,(function(s){if(t=M.of(this._iid).statManager,e.length<=30){try{for(n=h(e),r=n.next();!r.done;r=n.next())(a=r.value)&&a.notificationId&&a.notificationData&&t.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"viewed",template_key:a.notificationData.templateKey,channel_url:this.url,message_id:a.notificationId,tags:a.notificationData.tags,source:"notification",message_ts:a.createdAt,notification_event_deadline:a.notificationEventDeadline}}))}catch(e){i={error:e}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.logCustom=function(e,t){return c(this,void 0,void 0,(function(){var n,r,a,i,o,s;return u(this,(function(c){if(n=M.of(this._iid).statManager,0<e.length&&e.length<=15&&t.length<=30){try{for(r=h(t),a=r.next();!a.done;a=r.next())(i=a.value)&&i.notificationId&&i.notificationData&&n.put(new H({type:L.NOTIFICATION,ts:Date.now(),data:{action:"custom",topic:e,template_key:i.notificationData.templateKey,channel_url:this.url,message_id:i.notificationId,tags:i.notificationData.tags,source:"notification",message_ts:i.createdAt,notification_event_deadline:i.notificationEventDeadline}}))}catch(e){o={error:e}}finally{try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(o)throw o.error}}return[2,!0]}return[2,!1]}))}))},t.prototype.createNotificationCollection=function(e){return void 0===e&&(e={}),new je(this._iid,i({channel:this},e))},t}(X),Ve=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){Object.prototype.hasOwnProperty.call(n,e)&&(n[e]=t[e])})),n}return n(t,e),t}((function(){this.onChannelChanged=j,this.onChannelDeleted=j,this.onMessageReceived=j,this.onMentionReceived=j})),ze=function(e){function r(t,n){var r,a=this;return(a=e.call(this,t,n)||this).includeEmpty=Ce,a.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r?r:Ce,a}return n(r,e),r.prototype._validate=function(){return e.prototype._validate.call(this)&&C("boolean",this.includeEmpty)},r.prototype.next=function(){return c(this,void 0,void 0,(function(){var e,n,r,o,s;return u(this,(function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=Le.of(this._iid),n=t(i({},this)),[4,e.getMyFeedChannels(this._token,n,this.limit)]):[3,2]:[3,5];case 1:return r=c.sent(),o=r.channels,s=r.token,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw a.queryInProgress;case 4:return[3,6];case 5:throw a.invalidParameters;case 6:return[2]}}))}))},r}(G),Be=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="feedChannel",t}return n(t,e),t.prototype.init=function(t,n){e.prototype.init.call(this,t,n),this._manager=new Le(t,n)},t.prototype.buildFeedChannelFromSerializedData=function(e){return this._manager.buildFeedChannelFromSerializedData(e)},t.prototype.createMyFeedChannelListQuery=function(e){return void 0===e&&(e={}),new ze(this._iid,e)},t.prototype.addFeedChannelHandler=function(e,t){r(C("string",e)&&t instanceof Ve).throw(a.invalidParameters),this._manager.addHandler(e,t)},t.prototype.removeFeedChannelHandler=function(e){r(C("string",e)).throw(a.invalidParameters),this._manager.removeHandler(e)},t.prototype.removeAllFeedChannelHandlers=function(){this._manager.clearHandler()},t.prototype.getChannel=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return r(C("string",e)).throw(a.invalidParameters),[2,this._manager.getChannel(e)]}))}))},t.prototype.getMyFeedChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return u(this,(function(o){switch(o.label){case 0:return n=i(i({},Te),t),r(C("number",e)&&Ne(n)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getMyFeedChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){var n;return u(this,(function(o){switch(o.label){case 0:return n=i(i({},Te),t),r(C("string",e)&&Ne(n)).throw(a.invalidParameters),[4,this._manager.getMyFeedChannelChangeLogs(e,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getTotalUnreadMessageCount=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.getTotalUnreadNotificationCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getTotalUnreadNotificationCount=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadNotificationCount()];case 1:return[2,e.sent()]}}))}))},t.prototype.getGlobalNotificationChannelSetting=function(){return c(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this._manager.getGlobalNotificationChannelSetting()];case 1:return[2,e.sent()]}}))}))},t.prototype.getNotificationTemplateListByToken=function(e,t){return void 0===t&&(t={}),c(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,this._manager.getNotificationTemplateListByToken(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getNotificationTemplate=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this._manager.getNotificationTemplate(e)];case 1:return[2,t.sent()]}}))}))},t.prototype.refreshNotificationCollections=function(){this._manager.refreshNotificationCollections()},t}(V);export{Ge as FeedChannel,Ve as FeedChannelHandler,ze as FeedChannelListQuery,Be as FeedChannelModule,ve as NotificationCategory,je as NotificationCollection}; |
@@ -1,1 +0,1 @@ | ||
import{_ as e,V as i,b as s,D as h,F as f,b9 as _,ba as v,s as g,p as y,q as E,a2 as A,K as L,E as T,t as F,G as N,n as I,u as R,g as z,bb as B,a8 as J,B as Z,c as $,A as ee,az as te,e as ne,f as ae,h as re,a as ie,Q as se,X as oe,aO as le,aA as ue,bc as ce,aq as he,w as de,a_ as pe}from"./lib/__bundle-dd1a7eb2.js";export{bd as MessageEventSource,be as MutedState}from"./lib/__bundle-dd1a7eb2.js";import{S as fe,T as _e,G as ve,s as me,a as ge,P as ye,b as Ce,c as Se,d as Me,e as Ee,v as Ae,f as we,g as Le,h as Te,i as Fe}from"./lib/__bundle-cf484113.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,j as GroupChannelEventSource,a as GroupChannelFilter,d as GroupChannelListQuery,k as GroupChannelSearchField,H as HiddenChannelFilter,l as HiddenState,M as Member,m as MemberListOrder,n as MemberListQuery,o as MemberState,p as MemberStateFilter,r as MessageCollection,t as MessageCollectionInitHandler,u as MessageCollectionInitPolicy,w as MutedMemberFilter,q as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,c as SuperChannelFilter,U as UnreadChannelFilter,x as UnreadItemKey}from"./lib/__bundle-cf484113.js";import{Q as ke,T as Ne,V as xe}from"./lib/__bundle-01cdb35b.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-01cdb35b.js";import{G as Ge,P as Ue,S as Oe}from"./lib/__bundle-7fd2f830.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-7fd2f830.js";import{B as Ie}from"./lib/__bundle-44075a31.js";import"./lib/__bundle-0cf4fcf7.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function t(t){var n=t._iid,a=t.limit,r=void 0===a?100:a,o=this;this.ref=0,this._iid=n,this._limit=r;var l,u=i.of(this._iid),c=u.sdkState,d=u.dispatcher,p=u.logger,m=u.cacheContext,C=u.statManager;this._metadataKey=(l=c.userId,"sendbird:".concat(l,"@groupchannel/sync.meta"));var b=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new fe(b,(function(){return e(o,void 0,void 0,(function(){var e,t,n,a,r,i,o,l,u,h,d,f,b,S,M,w;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),p.debug("channel background sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),null===(h=this._metadata)||void 0===h?void 0:h.completed)return[3,14];t={includeEmpty:!0,includeMetaData:!0,order:Ge.CHRONOLOGICAL},s.label=2;case 2:if(s.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,m.preference.get(L(c.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannels(null!==(f=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==f?f:"",t,this._limit,A.SYNC_CHANNEL_BACKGROUND)];case 7:return a=s.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r<i;){var o=Qe(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:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,h,d,p,f,_,v,m=this;return(m=t.call(this,e,n)||this).includeEmpty=!1,m.includeFrozen=!0,m.includeMetaData=!0,m.channelUrlsFilter=null,m.customTypesFilter=null,m.customTypeStartsWithFilter=null,m.channelNameContainsFilter=null,m.membershipFilter=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.ALL,m.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,m.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,m.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,m.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,m.order=null!==(v=n.order)&&void 0!==v?v:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; | ||
import{_ as e,V as i,b as s,D as h,F as f,b9 as _,ba as v,s as g,p as y,q as E,a2 as A,K as L,E as T,t as F,G as N,n as I,u as R,g as z,bb as B,a8 as J,B as Z,c as $,A as ee,az as te,e as ne,f as ae,h as re,a as ie,Q as se,X as oe,aO as le,aA as ue,bc as ce,aq as he,w as de,a_ as pe}from"./lib/__bundle-85fbca74.js";export{bd as MessageEventSource,be as MutedState}from"./lib/__bundle-85fbca74.js";import{S as fe,T as _e,G as ve,s as me,a as ge,P as ye,b as Ce,c as Se,d as Me,e as Ee,v as Ae,f as we,g as Le,h as Te,i as Fe}from"./lib/__bundle-0e590e6a.js";export{C as CountPreference,D as DeliveryStatus,b as GroupChannel,j as GroupChannelEventSource,a as GroupChannelFilter,d as GroupChannelListQuery,k as GroupChannelSearchField,H as HiddenChannelFilter,l as HiddenState,M as Member,m as MemberListOrder,n as MemberListQuery,o as MemberState,p as MemberStateFilter,r as MessageCollection,t as MessageCollectionInitHandler,u as MessageCollectionInitPolicy,w as MutedMemberFilter,q as MyMemberStateFilter,O as OperatorFilter,P as PublicChannelFilter,Q as QueryType,c as SuperChannelFilter,U as UnreadChannelFilter,x as UnreadItemKey}from"./lib/__bundle-0e590e6a.js";import{Q as ke,T as Ne,V as xe}from"./lib/__bundle-3ceb5f92.js";export{K as MessageFilter,W as PinnedMessage,X as PinnedMessageListQuery,Y as ReadStatus,V as ScheduledStatus}from"./lib/__bundle-3ceb5f92.js";import{G as Ge,P as Ue,S as Oe}from"./lib/__bundle-b7a55976.js";export{G as GroupChannelListOrder,P as PublicGroupChannelListOrder,S as ScheduledMessageListOrder}from"./lib/__bundle-b7a55976.js";import{B as Ie}from"./lib/__bundle-a7b76e00.js";import"./lib/__bundle-ace226dc.js";import"./lib/__bundle-acd77193.js";var De,Pe={},He=function(){function t(t){var n=t._iid,a=t.limit,r=void 0===a?100:a,o=this;this.ref=0,this._iid=n,this._limit=r;var l,u=i.of(this._iid),c=u.sdkState,d=u.dispatcher,p=u.logger,m=u.cacheContext,C=u.statManager;this._metadataKey=(l=c.userId,"sendbird:".concat(l,"@groupchannel/sync.meta"));var b=function(e){return"sendbird:".concat(e,"@groupchannel/sync")}(c.userId);this._sync=new fe(b,(function(){return e(o,void 0,void 0,(function(){var e,t,n,a,r,i,o,l,u,h,d,f,b,S,M,w;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(s.sent(),p.debug("channel background sync from",null===(u=this._metadata)||void 0===u?void 0:u.token),null===(h=this._metadata)||void 0===h?void 0:h.completed)return[3,14];t={includeEmpty:!0,includeMetaData:!0,order:Ge.CHRONOLOGICAL},s.label=2;case 2:if(s.trys.push([2,9,12,13]),t.order!==Ge.LATEST_LAST_MESSAGE)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,m.preference.get(L(c.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannels(null!==(f=null===(d=this._metadata)||void 0===d?void 0:d.token)&&void 0!==f?f:"",t,this._limit,A.SYNC_CHANNEL_BACKGROUND)];case 7:return a=s.sent(),r=a.channels,i=a.token,e.hasNext=r.length>=this._limit&&!!i,e.nextToken=i,this._metadata&&(this._metadata.token=i,(l=this._metadata.range).extends.apply(l,y([],E(r.map((function(e){return e.createdAt}))),!1)),this._metadata.completed=!e.hasNext),p.debug("channel background sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),[3,13];case 9:return o=s.sent(),p.debug("channel background sync error",o),o instanceof g&&o.isInvalidTokenError?[4,this.clearMetaData()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw o;case 12:return C.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_back_sync",event:"cache_fetch",max_db_size:null!==(S=null===(b=m.localCacheConfig)||void 0===b?void 0:b.maxSize)&&void 0!==S?S:0,use_local_cache:m.localCacheEnabled,starting_point:0,message_init_policy:null!==(w=null===(M=t.order)||void 0===M?void 0:M.toString())&&void 0!==w?w:"",collection_id:c.userId}})),[7];case 13:return[3,15];case 14:e.hasNext=!1,e.nextToken="",s.label=15;case 15:return[2,e]}}))}))})),this._connectionEventContext=d.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)o.resume();else o.pause()}))}return t.of=function(e){return Pe[e]||(Pe[e]=new t({_iid:e})),Pe[e].ref++,Pe[e]},t.clear=function(e){Pe[e]&&(Pe[e].close(),delete Pe[e])},Object.defineProperty(t.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new _e({})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"completed",{get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return this._metadata?[3,2]:[4,i.of(this._iid).cacheContext.preference.get(this._metadataKey)];case 1:e=t.sent(),this._metadata={token:e?e.token:"",range:new _e(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetaData=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.resume=function(){var e,t,n=i.of(this._iid),a=n.logger;n.sessionManager.session.hasSession&&(a.debug("channel background sync resume()"),this._sync.start(null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.token)&&void 0!==t?t:""))},t.prototype.pause=function(){i.of(this._iid).logger.debug("channel background sync stop()"),this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pe[this._iid])},t}(),Re={},Ve=function(){function t(t){var n=t._iid,a=this;this.ref=0,this._iid=n;var r,o=i.of(this._iid),l=o.logger,u=o.sdkState,c=o.dispatcher,d=o.cacheContext,p=o.statManager;this._metadataKey=(r=u.userId,"sendbird:".concat(r,"@groupchannel/changelogs.meta")),this._subscribers=new T;var m=function(e){return"sendbird:".concat(e,"@groupchannel/changelogs")}(u.userId);this._sync=new fe(m,(function(){return e(a,void 0,void 0,(function(){var e,t,n,a,r,i,o,c,h,f,m,y;return s(this,(function(s){switch(s.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:s.sent(),l.debug("channel changelog sync from",null===(f=this._metadata)||void 0===f?void 0:f.token),s.label=2;case 2:s.trys.push([2,9,,12]),t={includeEmpty:!0,includeMetaData:!0},s.label=3;case 3:return s.trys.push([3,5,,6]),[4,d.preference.get(L(u.appId))];case 4:return n=s.sent(),t.includeChatNotification=Boolean(n),[3,6];case 5:return s.sent(),t.includeChatNotification=!1,[3,6];case 6:return[4,ve.of(this._iid).getMyGroupChannelChangeLogs(null!==(y=null===(m=this._metadata)||void 0===m?void 0:m.token)&&void 0!==y?y:"",t,A.SYNC_CHANNEL_CHANGELOGS)];case 7:return a=s.sent(),r=a.updatedChannels,i=a.deletedChannelUrls,o=a.hasMore,c=a.token,this._subscribers.dispatch("progress",{updatedChannels:r,deletedChannelUrls:i,hasMore:o,token:c}),e.hasNext=o,e.nextToken=c,this._metadata&&(this._metadata.token=c),l.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 8:return s.sent(),d.localCacheEnabled&&p.put(new _({type:v.FEATURE_LOCALCACHE_EVENT,ts:Date.now(),data:{channel_url:"",measured_on:"channel_change_log_sync",event:r.length>0||i.length>0?"cache_miss":"cache_hit",max_db_size:r.length,use_local_cache:d.localCacheEnabled,starting_point:0,message_init_policy:i.length.toString(),collection_id:u.userId}})),[3,12];case 9:return h=s.sent(),l.debug("channel changelog sync error",h),h instanceof g&&h.isInvalidTokenError?[4,this.clearMetadata()]:[3,11];case 10:s.sent(),s.label=11;case 11:throw h;case 12:return[2,e]}}))}))})),this._sync.on("stop",(function(){a._subscribers.dispatch("pause")})),this._connectionEventContext=c.on((function(e){if(e instanceof h)if(e.stateType===f.CONNECTED)a.resume();else a.pause()}))}return t.of=function(e){return Re[e]||(Re[e]=new t({_iid:e})),Re[e].ref++,Re[e]},t.clear=function(e){Re[e]&&(Re[e].close(),delete Re[e])},Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._sync.isRunning},enumerable:!1,configurable:!0}),t.prototype.loadMetadata=function(){return e(this,void 0,void 0,(function(){var e,t,n,a;return s(this,(function(r){switch(r.label){case 0:return this._metadata?[3,2]:(e=i.of(this._iid),t=e.cacheContext,n=e.firstConnectedAt,[4,t.preference.get(this._metadataKey)]);case 1:a=r.sent(),this._metadata={token:a?a.token:n},r.label=2;case 2:return[2,this._metadata]}}))}))},t.prototype.saveMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._metadata?[4,i.of(this._iid).cacheContext.preference.set(this._metadataKey,this._metadata)]:[3,2];case 1:return e.sent(),[2,!0];case 2:return[2,!1]}}))}))},t.prototype.clearMetadata=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,i.of(this._iid).cacheContext.preference.remove(this._metadataKey)];case 1:return e.sent(),this._metadata=void 0,[2]}}))}))},t.prototype.on=function(e,t){return this._subscribers.on(e,t)},t.prototype.resume=function(){i.of(this._iid).sessionManager.session.hasSession&&this._sync.start(0)},t.prototype.pause=function(){this._sync.stop()},t.prototype.close=function(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid])},t}(),Ke=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},ze=function(e,t,n){if(e.length>0){for(var a=Ke(e,t),r=0,i=e.length-1,s=Math.floor((r+i)/2);r<i;){var o=Qe(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:Qe(e[s],t,n)>=0?s:s+1,oldPosition:a}}return{place:e.length,oldPosition:-1}},Qe=function(e,t,n){switch(n){case Ge.LATEST_LAST_MESSAGE:return e.lastMessage&&t.lastMessage?0===(a=t.lastMessage.createdAt-e.lastMessage.createdAt)?t.createdAt-e.createdAt:a:e.lastMessage?-1:t.lastMessage?1:t.createdAt-e.createdAt;case Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var a;return 0===(a=e.name.localeCompare(t.name))?e.createdAt-t.createdAt:a;default:return 0}},je=function(){function t(t,n){var a=n.filter,r=void 0===a?new ge:a,o=n.order,l=void 0===o?Ge.LATEST_LAST_MESSAGE:o,u=n.limit,c=void 0===u?ke:u,d=n.includeChangesOnInitialLoad,p=void 0!==d&&d,_=this;this.channels=[],this._isInitialized=!1,this._iid=t,this._key="gcc-".concat(I()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this._includeChangesOnInitialLoad=p,this.filter=r,this.order=l,this._hasMore=!0,this._token="",this._limit=c;var v=i.of(this._iid),m=v.sdkState,g=v.cacheContext,y=v.dispatcher;g.localCacheEnabled&&(this._backgroundSync=He.of(t),this._backgroundSync.resume()),this._changelogSync=Ve.of(t),this._changelogSync.resume(),ve.of(this._iid).subscribeChannelEvent(this._key,{onUpdate:function(e,t){var n=t.source;if(me(n)){var a=e.filter((function(e){return _.filter.match(e,m.userId)})),r=e.filter((function(e){return!_.filter.match(e,m.userId)})).map((function(e){return e.url}));a.length>0&&_._addChannelsToView(a,t),r.length>0&&_._removeChannelsFromView(r,t)}},onRemove:function(e,t){_._removeChannelsFromView(e,t)}}),y.on((function(t){t instanceof h&&(t.stateType===f.CONNECTED?_._isGetRemoteChannelsSucceeded||e(_,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):t.stateType===f.LOGOUT&&_.dispose())}))}return Object.defineProperty(t.prototype,"hasMore",{get:function(){return!this._isDisposed&&this._hasMore},enumerable:!1,configurable:!0}),t.prototype.setGroupChannelCollectionHandler=function(e){this._handler=e},t.prototype._addChannelsToView=function(t,n,a){var r,i,o,l,u=this;void 0===a&&(a=!1);var c=[],h=[],d=[];try{for(var p=F(t),f=p.next();!f.done;f=p.next()){var _=f.value,v=Ke(this.channels,_);v>=0&&this.channels.splice(v,1);var m=ze(this.channels,_,this.order).place;if(v<0)m===this.channels.length?!a&&this._hasMore||(c.push(_),this.channels.push(_)):(c.push(_),this.channels.splice(m,0,_));else switch(n.source){case A.EVENT_CHANNEL_UPDATED:case A.EVENT_MESSAGE_RECEIVED:case A.SYNC_CHANNEL_CHANGELOGS:case A.EVENT_MESSAGE_SENT:this.order===Ge.CHANNEL_NAME_ALPHABETICAL&&this._hasMore&&m===this.channels.length?d.push(_):(this.channels.splice(m,0,_),h.push(_));break;default:this.channels.splice(m,0,_),h.push(_)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}if(d.length>0)try{for(var g=F(d),y=g.next();!y.done;y=g.next()){_=y.value;var C=Ke(this.channels,_);-1!==C&&this.channels.splice(C,1)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(l=g.return)&&l.call(g)}finally{if(o)throw o.error}}me(n.source)&&N((function(){return e(u,void 0,void 0,(function(){var e,t,a;return s(this,(function(r){return c.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(n,c),h.length>0&&(null===(t=this._handler)||void 0===t?void 0:t.onChannelsUpdated)&&this._handler.onChannelsUpdated(n,h),d.length>0&&(null===(a=this._handler)||void 0===a?void 0:a.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,d.map((function(e){return e.url}))),[2]}))}))}))},t.prototype._removeChannelsFromView=function(t,n){var a,r,i=this,o=[],l=function(e){var t=u.channels.findIndex((function(t){return t.url===e}));t>=0&&(o.push(u.channels[t].url),u.channels.splice(t,1))},u=this;try{for(var c=F(t),h=c.next();!h.done;h=c.next()){l(h.value)}}catch(e){a={error:e}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(a)throw a.error}}return me(n.source)&&o.length>0&&N((function(){return e(i,void 0,void 0,(function(){var e;return s(this,(function(t){return(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,o),[2]}))}))})),o},t.prototype._getLocalChannels=function(){return e(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=ve.of(this._iid),t=this.channels.length>0?function(e,t){var n,a,r,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(a=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==a?a:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(r=e.lastMessage)||void 0===r?void 0:r.createdAt)&&void 0!==i?i:e.createdAt}}(this.channels[this.channels.length-1],this.order):null,[4,e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)];case 1:return[2,n.sent()]}}))}))},t.prototype._getRemoteChannels=function(){return e(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(a){switch(a.label){case 0:return[4,ve.of(this._iid).getMyGroupChannels(this._token,R(z(z({},this.filter),{userIdsFilter:this.filter.userIdsFilter,searchFilter:this.filter.searchFilter,order:this.order})),this._limit)];case 1:return e=a.sent(),t=e.channels,n=e.token,this._token=n,this._hasMore=!!n,[2,t]}}))}))},t.prototype._revokeLoadMore=function(){return e(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:if(this._isDisposed)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this._getRemoteChannels()];case 2:return e=t.sent(),this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,{source:A.REQUEST_CHANNEL},!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},t.prototype.loadMore=function(){var t;return e(this,void 0,void 0,(function(){var n,a,r,o,l,u,c,h,d,p,f,_,m,y,C,b,S,M,E,w=this;return s(this,(function(L){switch(L.label){case 0:if(this._isDisposed)throw new g({code:J.COLLECTION_DISPOSED,message:"Collection has been disposed."});return n=null,this._includeChangesOnInitialLoad&&0===this.channels.length&&this._changelogSync.isRunning?[4,new Promise((function(e){w._changelogSyncSubscriberContext=w._changelogSync.on("progress",(function(t){return e(t)})).on("pause",(function(){return e(null)}))}))]:[3,2];case 1:n=L.sent(),null===(t=this._changelogSyncSubscriberContext)||void 0===t||t.close(),L.label=2;case 2:return a=i.of(this._iid),r=a.cacheContext,o=a.connectionManager,l=a.statManager,this._isInitialized?[3,5]:(this._isInitialized=!0,r.localCacheEnabled?[4,this._backgroundSync.loadMetadata()]:[3,4]);case 3:L.sent(),L.label=4;case 4:l.put(new B({type:v.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{group_channel:!0}}})),L.label=5;case 5:return u=[],this._hasMore?!r.localCacheEnabled||o.isConnected&&!this._backgroundSync.completed?[3,7]:[4,Z((function(){return e(w,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._getLocalChannels()];case 1:return u=e.sent(),[2]}}))}))}))]:[3,11];case 6:return L.sent(),this._hasMore=u.length>=this._limit,[3,10];case 7:return L.trys.push([7,9,,10]),[4,this._getRemoteChannels()];case 8:return u=L.sent(),this._isGetRemoteChannelsSucceeded=!0,[3,10];case 9:return L.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,10];case 10:this._addChannelsToView(u,{source:A.REQUEST_CHANNEL},!0),L.label=11;case 11:if(n){try{for(c=F(n.updatedChannels),h=c.next();!h.done;h=c.next())d=h.value,(C=Ke(u,d))>=0?u[C]=d:(p=ze(u,d,this.order).place,u.splice(p,0,d))}catch(e){b={error:e}}finally{try{h&&!h.done&&(S=c.return)&&S.call(c)}finally{if(b)throw b.error}}f=u.map((function(e){return e.url}));try{for(_=F(n.deletedChannelUrls),m=_.next();!m.done;m=_.next())y=m.value,(C=f.indexOf(y))>=0&&(u.splice(C,1),f.splice(C,1))}catch(e){M={error:e}}finally{try{m&&!m.done&&(E=_.return)&&E.call(_)}finally{if(M)throw M.error}}}return[2,u]}}))}))},t.prototype.dispose=function(){var e,t,n;this._isDisposed||(this._isDisposed=!0,this.channels.length>0&&this.channels.splice(0,this.channels.length),null===(e=this._backgroundSync)||void 0===e||e.close(),null===(t=this._changelogSync)||void 0===t||t.close(),null===(n=this._changelogSyncSubscriberContext)||void 0===n||n.close(),ve.of(this._iid).unsubscribeChannelEvent(this._key))},t}(),We=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.includeEmpty,o=t.membershipFilter,l=t.channelNameContainsFilter,u=t.channelUrlsFilter,c=t.customTypesFilter,h=t.customTypeStartsWithFilter,d=t.superChannelFilter,p=t.metadataOrderKeyFilter,f=t.metadataKey,_=t.metadataValues,v=t.metadataValueStartsWith,m=t.includeFrozen,g=t.includeMetaData;return(n=e.call(this)||this).method=ee.GET,n.path=te,n.params=ne(R({token:a,limit:r,order:i,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:s,public_mode:ye.PUBLIC,public_membership_mode:o,name_contains:l,channel_urls:u,custom_types:c,custom_type_startswith:h,super_mode:d,metadata_order_key:p,metadata_key:f,metadata_values:_,metadata_value_startswith:v,show_frozen:m,show_metadata:g})),n}return $(t,e),t}(ae),Be=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.channels=[];var r=n.next,i=n.channels,s=n.ts;return a.token=r,i&&i.length>0&&(a.channels=i.map((function(e){return e.ts=s,new Ce(t,e)}))),a.ts="number"==typeof s?s:0,a}return $(t,e),t}(re);!function(e){e.ALL="all",e.JOINED="joined"}(De||(De={}));var qe=function(t){function n(e,n){var a,r,i,s,o,l,u,c,h,d,p,f,_,v,m=this;return(m=t.call(this,e,n)||this).includeEmpty=!1,m.includeFrozen=!0,m.includeMetaData=!0,m.channelUrlsFilter=null,m.customTypesFilter=null,m.customTypeStartsWithFilter=null,m.channelNameContainsFilter=null,m.membershipFilter=De.ALL,m.superChannelFilter=Se.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=Ue.CHRONOLOGICAL,m.includeEmpty=null!==(a=n.includeEmpty)&&void 0!==a&&a,m.includeFrozen=null===(r=n.includeFrozen)||void 0===r||r,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(s=n.channelUrlsFilter)&&void 0!==s?s:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(l=n.customTypeStartsWithFilter)&&void 0!==l?l:null,m.channelNameContainsFilter=null!==(u=n.channelNameContainsFilter)&&void 0!==u?u:null,m.membershipFilter=null!==(c=n.membershipFilter)&&void 0!==c?c:De.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Se.ALL,m.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,m.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,m.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,m.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,m.order=null!==(v=n.order)&&void 0!==v?v:Ue.CHRONOLOGICAL,m}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("boolean",this.includeEmpty)&&ie("boolean",this.includeFrozen)&&ie("boolean",this.includeMetaData)&&ie("string",this.channelNameContainsFilter,!0)&&se("string",this.channelUrlsFilter,!0)&&se("string",this.customTypesFilter,!0)&&ie("string",this.customTypeStartsWithFilter,!0)&&oe(De,this.membershipFilter)&&oe(Se,this.superChannelFilter)&&oe(Ue,this.order)&&ie("string",this.metadataOrderKeyFilter,!0)&&ie("string",this.metadataKey,!0)&&se("string",this.metadataValues,!0)&&ie("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o,l;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=i.of(this._iid).requestQueue,n=new We(R(z(z({},this),{token:this._token}))),[4,t.send(n)]):[3,2]):[3,5];case 1:return a=s.sent(),r=a.as(Be),o=r.channels,l=r.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,o];case 2:return[2,e];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),Ye=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return Object.keys(t).forEach((function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})),n}return $(t,e),t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onUserJoined=ue,t.onUserLeft=ue,t.onUserReceivedInvitation=ue,t.onUserDeclinedInvitation=ue,t.onChannelHidden=ue,t.onUnreadMemberStatusUpdated=ue,t.onUndeliveredMemberStatusUpdated=ue,t.onTypingStatusUpdated=ue,t.onPollUpdated=ue,t.onPollVoted=ue,t.onPollDeleted=ue,t.onPinnedMessageUpdated=ue,t}return $(t,e),t}(Ie)),Xe=function(e){function t(t){var n=this,a=t.token,r=t.limit,i=t.order,s=t.reverse,o=t.channelUrl,l=t.messageTypeFilter,u=t.scheduledStatus;return(n=e.call(this)||this).method=ee.GET,n.path="".concat(ce),n.params=ne(R({token:a,limit:r,reverse:s,channel_url:o,order:i,message_type:l,status:u})),n}return $(t,e),t}(ae),Je=function(e){function t(t,n){var a=e.call(this,t,n)||this;a.scheduledMessages=[];var r=n.next,i=n.scheduled_messages;return a.token=r,a.scheduledMessages=i.map((function(e){return Ne(t,e)})),a}return $(t,e),t}(re),Ze=function(t){function n(e,n){var a,r,i,s,o,l=this;return(l=t.call(this,e,n)||this).channelUrl=null,l.order=null,l.reverse=!1,l.scheduledStatus=null,l.messageTypeFilter=he.ALL,l.channelUrl=null!==(a=n.channelUrl)&&void 0!==a?a:null,l.order=null!==(r=n.order)&&void 0!==r?r:null,l.reverse=null!==(i=n.reverse)&&void 0!==i&&i,l.scheduledStatus=null!==(s=n.scheduledStatus)&&void 0!==s?s:null,l.messageTypeFilter=null!==(o=n.messageTypeFilter)&&void 0!==o?o:he.ALL,l}return $(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&ie("string",this.channelUrl,!0)&&(oe(Oe,this.order)||null===this.order)&&ie("boolean",this.reverse)&&(se(xe,this.scheduledStatus)||null===this.scheduledStatus)&&oe(he,this.messageTypeFilter)},n.prototype.next=function(){return e(this,void 0,void 0,(function(){var e,t,n,a,r,o;return s(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=i.of(this._iid).requestQueue,t=new Xe(R(z(z({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=s.sent(),a=n.as(Je),r=a.scheduledMessages,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw g.queryInProgress;case 4:return[3,6];case 5:throw g.invalidParameters;case 6:return[2]}}))}))},n}(le),$e=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="groupChannel",e}return $(n,t),n.prototype.init=function(e,n){var a=n.sdkState,r=n.dispatcher,i=n.sessionManager,s=n.requestQueue,o=n.logger,l=n.onlineDetector,u=n.cacheContext;t.prototype.init.call(this,e,{sdkState:a,dispatcher:r,sessionManager:i,requestQueue:s,logger:o,onlineDetector:l,cacheContext:u}),this._manager=new ve(e,{sdkState:a,cacheContext:u,dispatcher:r,sessionManager:i,requestQueue:s,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new je(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new Me(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new qe(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Ze(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){de(ie("string",e)&&t instanceof Ye).throw(g.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){de(ie("string",e)).throw(g.invalidParameters),this._manager.removeHandler(e)},n.prototype.removeAllGroupChannelHandlers=function(){this._manager.clearHandler()},n.prototype.buildGroupChannelFromSerializedData=function(e){return this._manager.buildGroupChannelFromSerializedData(e)},n.prototype.buildGroupChannelListQueryFromSerializedData=function(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)},n.prototype.buildMemberFromSerializedData=function(e){return this._manager.buildMemberFromSerializedData(e)},n.prototype.getChannel=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannel(t)]}))}))},n.prototype.getChannelWithoutCache=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(ie("string",t)).throw(g.invalidParameters),[2,this._manager.getChannelWithoutCache(t)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("string",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(t,n){return void 0===n&&(n={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(a){switch(a.label){case 0:return e=z(z({},Ee),n),de(ie("number",t)&&Ae(e)).throw(g.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(t,e)];case 1:return[2,a.sent()]}}))}))},n.prototype.getGroupChannelCount=function(t){return e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},we),t),de(Le(e)).throw(g.invalidParameters),[2,this._manager.getGroupChannelCount(e)]}))}))},n.prototype.getUnreadItemCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getUnreadItemCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadChannelCount=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadChannelCount()];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalUnreadMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalUnreadMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getTotalScheduledMessageCount=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._manager.getTotalScheduledMessageCount(t)];case 1:return[2,e.sent()]}}))}))},n.prototype.getSubscribedTotalUnreadMessageCount=function(){return this._manager.getSubscribedTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeTotalUnreadMessageCount=function(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()},n.prototype.getSubscribedCustomTypeUnreadMessageCount=function(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)},n.prototype.createChannel=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),[2,this._manager.createChannel(e)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=z(z({},Te),t),de(Fe(e)).throw(g.invalidParameters),e&&(e.isDistinct=!0),[2,this.createChannel(e)]}))}))},n.prototype.createChannelWithUserIds=function(t,n,a,r,i,o){return void 0===n&&(n=!1),void 0===i&&(i=""),void 0===o&&(o=""),e(this,void 0,void 0,(function(){var e;return s(this,(function(s){return e=z(z({},Te),{invitedUserIds:t,isDistinct:n,name:a,data:i,customType:o}),"string"==typeof r?e.coverUrl=r:e.coverImage=r,[2,this.createChannel(e)]}))}))},n.prototype.markAsReadAll=function(){return e(this,void 0,void 0,(function(){return s(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){return de(se("string",t)).throw(g.invalidParameters),this._manager.markAsReadWithChannelUrls(t),[2]}))}))},n.prototype.markAsDelivered=function(t){return e(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return de(ie("string",t)).throw(g.invalidParameters),[4,this.getChannel(t)];case 1:return[4,e.sent().markAsDelivered()];case 2:return e.sent(),[2]}}))}))},n}(pe);export{je as GroupChannelCollection,Ye as GroupChannelHandler,$e as GroupChannelModule,De as MembershipFilter,qe as PublicGroupChannelListQuery,Ze as ScheduledMessageListQuery}; |
@@ -1,1 +0,1 @@ | ||
import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-dd1a7eb2.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-dd1a7eb2.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-01cdb35b.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-01cdb35b.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-7fd2f830.js";import{g as ft,N as pt}from"./lib/__bundle-976bb868.js";import"./lib/__bundle-acd77193.js";var vt=function(e){this.key=e.key,this.url=e.url},gt=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.store.clear()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return c(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(d),kt=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,s=t.profileImage,o=t.preferredLanguages,a=e.call(this)||this;return a.method=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),Lt=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return c(t,e),t}(b),jt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=l.PUT,c.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return c(t,e),t}(v),Ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return c(t,e),t}(b),xt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new wt({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,s=void 0===i?[]:i,o=e.options,a=void 0===o?new N:o,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return q.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=q.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=q.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!q.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return q.of(this._iid).logger.level},set:function(e){q.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return q.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=q.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return q.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=q.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=q.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=q.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._getNestDBVersion=function(){return 7},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.debugModeRequired},n.prototype.addExtension=function(e,t){var n=q.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},n.prototype.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=q.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,11];if(o="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,9];a.label=1;case 1:return a.trys.push([1,6,,8]),r.nestdb&&r.nestdb.state!==rt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new Xe({name:u,version:this._getNestDBVersion(),store:r.store,config:new et({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]);case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 7:throw a.sent(),n.userId=e,Z.databaseError;case 8:return[3,11];case 9:return[4,this._safeInitializeStore(o)];case 10:a.sent(),n.userId=e,a.label=11;case 11:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return i(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=tt.of(this._iid),n=nt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,6,8]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,8];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,8];case 6:return[4,this._setupPreference(e)];case 7:return a.sent(),[7];case 8:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket(!0)];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.invalidParameters),q.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){q.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){q.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){ee(t("string",e)&&n instanceof Ve).throw(Z.invalidParameters),q.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){q.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){q.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Lt({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid).requestQueue,t=new pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; | ||
import{i as e,a as t,_ as i,b as a,C as u,c,E as d,A as l,d as h,e as f,u as p,f as v,U as g,g as m,h as b,P as _,j as w,k,l as I,m as A,S as N,L as M,n as Q,o as j,V as q,p as x,q as K,v as W,r as V,s as Z,t as X,w as ee,x as te,y as ne,z as re,B as ie,D as se,F as oe,W as ae,G as ue,H as ce,I as de,J as le,K as he,M as fe,N as pe,O as ve,Q as ge,R as me,T as be,X as _e,Y as ye,Z as we,$ as ke,a0 as Se}from"./lib/__bundle-85fbca74.js";export{a1 as AppInfo,a3 as CachedChannelInfo,a4 as CachedDataClearOrder,C as ChannelType,a2 as CollectionEventSource,r as ConnectionState,Y as DeviceOsPlatform,a5 as LastMessageThreadingPolicy,L as LocalCacheConfig,a6 as NotificationInfo,a0 as PushTemplate,T as PushTokenRegistrationState,P as PushTokenType,$ as PushTriggerOption,a7 as Role,S as SendbirdChatOptions,s as SendbirdError,a8 as SendbirdErrorCode,ad as SendbirdPlatform,ac as SendbirdProduct,a9 as UIKitConfigInfo,aa as UnreadCountThreadingPolicy,U as User,ab as UserOnlineState}from"./lib/__bundle-85fbca74.js";import{N as Ie,a as Ce,b as Ee,c as Te,g as Pe,M as De,d as Ue,e as Oe,f as Ae,h as Ne,i as Me,j as Le,k as Re,l as ze,m as Qe,L as je,n as Fe,o as qe,p as He,A as xe,I as Ke,q as Ge,U as We,C as Ve,r as Be,B as Je,F as Ye,s as Ze,S as $e,t as Xe,u as et,v as tt,w as nt,x as rt}from"./lib/__bundle-3ceb5f92.js";export{r as ApplicationUserListQuery,y as BannedUserListQuery,z as BaseChannel,B as BlockedUserListQuery,C as ConnectionHandler,F as FriendListQuery,n as LogLevel,o as MemoryStore,D as MutedUserListQuery,O as OperatorListQuery,P as Participant,E as Plugin,R as ReportCategory,G as RestrictedUser,H as RestrictionInfo,J as RestrictionType,S as SessionHandler,U as UserEventHandler}from"./lib/__bundle-3ceb5f92.js";import{PollModule as it}from"./poll.js";import{g as st,G as ot,A as at,U as ut,a as ct,b as dt,D as lt,R as ht}from"./lib/__bundle-b7a55976.js";import{g as ft,N as pt}from"./lib/__bundle-80bd1744.js";import"./lib/__bundle-acd77193.js";var vt=function(e){this.key=e.key,this.url=e.url},gt=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new vt(e)})):[]},mt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new gt(e)})):[]},bt={profileImage:void 0,profileUrl:void 0,nickname:void 0},_t=function(e){return function(t,n){return i(void 0,void 0,void 0,(function(){var r,s,o,c;return a(this,(function(d){switch(d.label){case 0:switch(t){case 1:case 2:case 3:case 4:return[3,1];case 5:return[3,2];case 6:return[3,4]}return[3,11];case 1:return n(),[3,12];case 2:return[4,e.store.clear()];case 3:return d.sent(),n(),[3,12];case 4:return d.trys.push([4,9,,10]),r=function(e){return{v2:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Ce,keyName:Ee,index:[st(ot.LATEST_LAST_MESSAGE),st(ot.CHRONOLOGICAL),st(ot.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:Ie,keyName:Te,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ue,keyName:Oe,index:[Pe(De.CHANNEL_LATEST),Pe(De.NEWEST_CHILD_MESSAGE)]},{collectionName:Ae,keyName:Ne}])];case 1:return[2,t.sent()]}}))}))},v3:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Me,keyName:Le,index:[ft("latest_last_message")]}])];case 1:return[2,t.sent()]}}))}))},v4:function(){return i(void 0,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,e.commitSchema([{collectionName:Re,keyName:ze,index:[Qe()]}])];case 1:return[2,t.sent()]}}))}))}}}(e),s=r.v2,o=r.v3,c=r.v4,[4,s()];case 5:return d.sent(),[4,o()];case 6:return d.sent(),[4,c()];case 7:return d.sent(),[4,e.collection(Ie).removeIf({where:{channelType:u.OPEN}})];case 8:case 9:return d.sent(),[3,10];case 10:return n(),[3,12];case 11:n(),d.label=12;case 12:return[2]}}))}))}},yt=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},wt=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?yt:n,i=t.initialState,s=void 0===i?"visible":i,o=t.isEnabled,a=void 0===o||o,u=t.pauseCheckDelay,c=void 0===u?3e4:u,d=e.call(this)||this;return d._pauseCheckDelay=3e4,d._currentState="visible",d._getVisibilityState=r,d._pauseCheckDelay=c,d._currentState=s,d._isEnabled=a,d._boundToggleState=d._toggleState.bind(d),d}return c(t,e),Object.defineProperty(t.prototype,"currentState",{get:function(){return this._currentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAvailable",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener},enumerable:!1,configurable:!0}),t.prototype._toggleState=function(){var e=this,t=this._getVisibilityState();"hidden"!==t?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,e.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=t},t.prototype.start=function(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))},t.prototype.stop=function(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})},t}(d),kt=function(){function e(e){var t=e.logger,n=e.connectionDelegate,r=void 0===n?null:n,i=this;this._onlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=function(){var e;return null===(e=i.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("online",e),function(){return window.removeEventListener("online",e,!1)}},this._offlineListener=function(e){if(i.isAvailableOnWeb)return window.addEventListener("offline",e),function(){return window.removeEventListener("offline",e,!1)}},this.logger=t,r&&(this.connectionDelegate=r)}return Object.defineProperty(e.prototype,"isAvailableOnWeb",{get:function(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine},enumerable:!1,configurable:!0}),e.prototype.setOnlineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)},e.prototype.setOfflineListener=function(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)},e.prototype.start=function(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]},e.prototype.stop=function(){var e=this;this.unsubscribes.forEach((function(t){try{null==t||t()}catch(t){e.logger.warn(t.message)}})),this.unsubscribes=[]},e.prototype.isOnline=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){return this.isAvailableOnWeb?[2,navigator.onLine]:[2,new Promise((function(e){fetch("https://www.google.com",{method:l.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))}))]}))}))},e}(),St=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,s=t.profileImage,o=t.preferredLanguages,a=e.call(this)||this;return a.method=l.PUT,a.path="".concat(h,"/").concat(encodeURIComponent(n)),a.params=f(p({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return c(t,e),t}(v),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,m({},n)),r}return c(t,e),t}(b),Ct=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),a.params=f({apns_device_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Et=function(e){function t(t){var n=t.userId,r=t.token,i=t.deviceOS,s=t.deviceManufacturer,o=t.systemPushEnabled,a=e.call(this)||this;return a.method=l.POST,a.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),a.params=f({gcm_reg_token:r,always_push:!0,device_os:i,device_manufacturer:s,system_push_enabled:o}),a}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r}c(t,e)}(b);var Tt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Pt=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Dt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/apns"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ut=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.DELETE,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/gcm"),r}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?_[n.type.toLowerCase()]:_.UNKNOWN,r.user=new g(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}c(t,e)}(b);var Ot=function(e){function t(t){var n=t.userId,r=t.type,i=t.token,s=t.ts,o=e.call(this)||this;return o.method=l.GET,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/").concat(encodeURIComponent(r),"/device_tokens"),o.params={created_ts:s,token:i},o}return c(t,e),t}(v),At=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?_[n.type.toLowerCase()]:_.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return c(t,e),t}(b),Nt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),r}return c(t,e),t}(v),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),Lt=function(e){function t(t){var n=t.userId,r=t.willAutoAccept,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/channel_invitation_preference"),i.params={auto_accept:r},i}return c(t,e),t}(v),Rt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.autoAccept=n.auto_accept,r}return c(t,e),t}(b),zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Qt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return c(t,e),t}(b),jt=function(e){function t(t){var n=t.userId,r=t.doNotDisturbOn,i=t.startHour,s=t.startMin,o=t.endHour,a=t.endMin,u=t.timezone,c=e.call(this)||this;return c.method=l.PUT,c.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),c.params={do_not_disturb:r,start_hour:i,start_min:s,end_hour:o,end_min:a,timezone:u},c}return c(t,e),t}(v),Ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.preference={doNotDisturbOn:n.do_not_disturb,startHour:n.start_hour,startMin:n.start_min,endHour:n.end_hour,endMin:n.end_min,timezone:n.timezone},r}return c(t,e),t}(b),qt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Ht=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return c(t,e),t}(b),xt=function(e){function t(t){var n=t.userId,r=t.snoozeOn,i=t.startTs,s=t.endTs,o=e.call(this)||this;return o.method=l.PUT,o.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),o.params={snooze_enabled:r,snooze_start_ts:i,snooze_end_ts:s},o}return c(t,e),t}(v),Kt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.snoozePeriod={isSnoozeOn:n.snooze_enabled},"number"==typeof n.snooze_start_ts&&(r.snoozePeriod.startTs=n.snooze_start_ts),"number"==typeof n.snooze_end_ts&&(r.snoozePeriod.endTs=n.snooze_end_ts),r}return c(t,e),t}(b),Gt=function(e){function t(t){var n=t.userId,r=t.blockedUserId,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block"),i.params={target_id:r},i}return c(t,e),t}(v);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new g(t,n),r}c(t,e)}(b);var Wt=function(e){function t(t){var n=t.userId,r=t.unblockedUserId,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/block/").concat(encodeURIComponent(r)),i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var Vt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),r}return c(t,e),t}(v),Bt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Jt=function(e){function t(t){var n=t.userId,r=t.pushTriggerOption,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push_preference"),i.params={push_trigger_option:r},i}return c(t,e),t}(v),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTriggerOption=n.push_trigger_option,r}return c(t,e),t}(b),Zt=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),r}return c(t,e),t}(v),$t=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),Xt=function(e){function t(t){var n=t.userId,r=t.templateName,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/push/template"),i.params={name:r},i}return c(t,e),t}(v),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.name=n.name,r}return c(t,e),t}(b),tn=function(e){function t(t){var n=t.userId,r=t.token,i=e.call(this)||this;return i.method=l.GET,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends/changelogs"),i.params={token:r},i}return c(t,e),t}(v),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new g(t,e)})),updatedUsers:n.updated.map((function(e){return new g(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return c(t,e),t}(b),rn=function(e){function t(t){var n=t.userId,r=t.discoveries,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discoveries:r.map((function(e){return{friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName}}))},i}return c(t,e),t}(v),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.friendDiscoveryRequestId=n.friend_discovery_request_id,r}return c(t,e),t}(b),on=function(e){function t(t){var n=t.userId,r=t.discoveryKeys,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friend_discoveries"),i.params={friend_discovery_keys:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var an=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.POST,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new g(t,e)})),r}return c(t,e),t}(b),cn=function(e){function t(t){var n=t.userId,r=t.userIds,i=e.call(this)||this;return i.method=l.DELETE,i.path="".concat(h,"/").concat(encodeURIComponent(n),"/friends"),i.params={user_ids:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var dn=function(e){function t(t){var n=t.userId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),r.params={},r}return c(t,e),t}(v),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.allowFriendDiscovery=n.allow_friend_discovery,r}return c(t,e),t}(b),hn=function(e){function t(t){var n=t.userId,r=t.allowFriendDiscovery,i=e.call(this)||this;return i.method=l.PUT,i.path="".concat(h,"/").concat(n,"/allow_friend_discovery"),i.params={allow_friend_discovery:r},i}return c(t,e),t}(v);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}c(t,e)}(b);var fn,pn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path=w,t}return c(t,e),t}(v),vn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new mt(n),r}return c(t,e),t}(b),gn=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(w,"/").concat(n),r}return c(t,e),t}(v),mn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new gt(n),r}return c(t,e),t}(b),bn=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=l.GET,r.path="".concat(k,"/").concat(n),r}return c(t,e),t}(v),_n=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new vt(n),r}return c(t,e),t}(b),yn=function(e){function t(){var t=e.call(this)||this;return t.method=l.GET,t.path="".concat(I),t}return c(t,e),t}(v),wn=function(e){function t(t,n){var r,i=this,s=null!=n?n:{};return(i=e.call(this,t,n)||this).uikitConfiguration={string:JSON.stringify(s),json:s},i.updatedAt=null!==(r=null==n?void 0:n.updated_at)&&void 0!==r?r:0,i}return c(t,e),t}(b);!function(e){e.DELIVERED="DELIVERED",e.CLICKED="CLICKED"}(fn||(fn={}));var kn,Sn=function(e){function t(t){var n=t.deviceToken,r=t.pushTrackingId,i=t.messageId,s=t.allowedPushNotification,o=t.channelKey,a=t.templateKey,u=t.eventType,c=t.notificationEventDeadline,d=e.call(this)||this;return d.method=l.POST,d.path=A,d.params=f({device_token:n,push_tracking_id:r,message_id:i,allowed_push_notification:s,channel_key:o,template_key:a,event_type:u,notification_event_deadline:c}),d}return c(t,e),t}(v);var In=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var s=q.of(e),o=s.sdkState,u=s.cacheContext,c=s.dispatcher,d=s.sessionManager,l=s.requestQueue,h=s.logger,f=s.userEventHandlers,p=s.appStateToggleEnabled;this._onlineDetector=new kt({logger:h,connectionDelegate:{reconnect:function(){return i(r,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(e),n=t.sdkState,r=t.connectionManager,(i=t.sessionManager).session.hasSession)return[3,5];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.connect(i.session.authToken)];case 2:return a.sent(),[3,4];case 3:if(s=a.sent(),ve(s))throw s;return h.debug("connect failed by reconnect event = ",s),[3,4];case 4:return[3,9];case 5:if("foreground"!==n.appState)return[3,9];a.label=6;case 6:return a.trys.push([6,8,,9]),[4,r.resetAndReconnect()];case 7:return a.sent(),[3,9];case 8:if(o=a.sent(),ve(o))throw o;return h.debug("resetAndReconnect failed by reconnect event = ",o),[3,9];case 9:return c.dispatch(new pt),[2]}}))}))},disconnect:function(){ie((function(){return i(r,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,q.of(e).connectionManager.disconnect()];case 1:return t.sent(),[2]}}))}))}))}}});var v=new at(e,{localCacheEnabled:u.localCacheEnabled,enableAutoResend:u.localCacheConfig.enableAutoResend,dispatcher:c,sdkState:o,logger:h});n.forEach((function(t){t.init(e,{sdkState:o,cacheContext:u,dispatcher:c,sessionManager:d,requestQueue:l,logger:h,onlineDetector:r._onlineDetector}),r[t.name]=t})),this._appStateChangeDetector=new wt({isEnabled:p}),this._appStateChangeDetector.on("resume",(function(){h.debug("the page resumes from freeze"),r.setForegroundState()})).on("pause",(function(){h.debug("the page freezes"),r.setBackgroundState()})),c.on((function(t){var n;if(t instanceof se){if(t.stateType===oe.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof ae){if("USEV"===t.code){var s=t.as(ut).event;if(s.category===ct.FRIEND_DISCOVERED){var c=dt.getDataAsFriendDiscoveredEvent(e,s).friendDiscoveries;ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(c)}))]}))}))}))}}}else if(t instanceof ce){var d=q.of(r._iid).subscribedUnreadMessageCount,l=!1,p=t.ts;"number"==typeof p&&p>d.ts&&(d.all!==t.all&&(l=!0),d.all=t.all>=0?t.all:0,t.customTypes&&Object.keys(t.customTypes).forEach((function(e){d.customTypes[e]!==t.customTypes[e]&&(l=!0),d.customTypes[e]=t.customTypes[e]})),l=l&&d.ts>0,d.ts=p),l&&ue((function(){return i(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountChanged&&e.onTotalUnreadMessageCountChanged({groupChannelCount:d.all,feedChannelCount:d.feed,customTypeUnreadCount:d.customTypes}),e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(d.all,d.customTypes)}))]}))}))}))}else t instanceof de?(u.preference.set(r._getUserProfileCacheKey(o.userId),le.payloadify(t.userProfile)),(null===(n=t.userProfile.appInfo.notificationInfo)||void 0===n?void 0:n.isEnabled)&&u.preference.set(he(r.appId),{value:!0})):t instanceof fe&&t.error&&t.error.isSessionInvalidatedError&&(h.debug("session revoked."),r._internalDisconnect(t.error))}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,s=void 0===i?[]:i,o=e.options,a=void 0===o?new N:o,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,g=void 0!==v&&v,m=e.localCacheConfig,b=void 0===m?new M:m,_=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.useMMKVStorageStore,S=void 0===k?null:k,I=e.appStateToggleEnabled,C=void 0===I||I;if(!kn||f){var E="su-".concat(Q()),T=null!=_?_:{encrypt:function(e){return e},decrypt:function(e){return e}},P=new je;P.level=null!=p?p:Fe.WARN;var D=new qe({encryption:T});c||(j()?S?D=new He({MMKV:S,encryption:T}):w&&(D=new xe({AsyncStorage:w,encryption:T}),P.warn("AsyncStorage store is deprecated due to the small size limit. Please use MMKVStorage store instead.")):D=new Ke({encryption:T})),new q(E,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:D,encryption:T,logger:P,localCacheEnabled:g,localCacheConfig:b,debugMode:c,appStateToggleEnabled:C});var U=[new Ge,new it],O=new n(E,a,x(x([],K(s),!1),K(U),!1));return kn||(kn=O),O}return kn},Object.defineProperty(n,"instance",{get:function(){return kn},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return W},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return q.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=q.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=q.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!q.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return q.of(this._iid).logger.level},set:function(e){q.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return q.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=q.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return q.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=q.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=q.of(this._iid).connectionManager;return e.isConnected?V.OPEN:e.isConnecting?V.CONNECTING:V.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=q.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),n.prototype._getNestDBVersion=function(){return 7},n.prototype._getPreferenceCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".pref")},n.prototype._getUserProfileCacheKey=function(e){return"sendbird@".concat(this.appId,"/").concat(e,".profile")},n.prototype._internalDisconnect=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return t=q.of(this._iid),n=t.connectionManager,r=t.sdkState,i=t.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),i.cancelAll(),[4,n.logout(e)];case 1:return s.sent(),[4,this.clearCachedData()];case 2:return s.sent(),r.appState="foreground",[2]}}))}))},n.prototype.getMemoryStoreForDebugging=function(){var e=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof qe?n.store:null;throw Z.debugModeRequired},n.prototype.addExtension=function(e,t){var n=q.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(n.extensions[e]=t)},n.prototype.addSendbirdExtensions=function(e,t,n){var r,i,s=q.of(this._iid),o=s.logger,a=s.sdkState,u=new RegExp(pe);if(0===e.length)return o.debug("sb.addSendbirdExtensions() has failed because the given sendbirdExtensions is empty."),!1;if(e.find((function(e){return!u.test(e.version)})))return o.debug("sb.addSendbirdExtensions() has failed because the given version did not satisfy the SemVer specification."),!1;if(n)try{for(var c=X(Object.entries(n)),d=c.next();!d.done;d=c.next()){var l=K(d.value,2),h=l[0],f=l[1];if(/&|=/.test(h)||/&|=/.test(f))return o.debug("sb.addSendbirdExtensions() has failed because the given customData includes at least one invalid character: = or &."),!1}}catch(e){r={error:e}}finally{try{d&&!d.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return a.sendbirdRuntimeEnvironment={sendbirdExtensions:e,deviceOS:t,customData:n},!0},n.prototype.setOnlineListener=function(e){this._onlineDetector.setOnlineListener(e)},n.prototype.setOfflineListener=function(e){this._onlineDetector.setOfflineListener(e)},n.prototype._safeInitializeStore=function(e){return i(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:t=q.of(this._iid).cacheContext,n.label=1;case 1:return n.trys.push([1,3,,5]),[4,t.store.init(e)];case 2:return n.sent(),this._storeInitialized=!0,[3,5];case 3:return n.sent(),t.replaceStore(new qe),[4,this._safeInitializeStore(e)];case 4:return n.sent(),[3,5];case 5:return[2]}}))}))},n.prototype.setLocaleForChatbot=function(e){var t=q.of(this._iid).sdkState,n=function(e){return e.replace(/[^a-zA-Z-_.]/g,"")}(e.trim());n&&(t.localeForChatbot=n)},n.prototype.initializeCache=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:if(t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.dispatcher,s=t.logger,n.userId&&n.userId===e)return[3,11];if(o="sendbird@".concat(n.appId,"/").concat(e,".db"),!r.localCacheEnabled)return[3,9];a.label=1;case 1:return a.trys.push([1,6,,8]),r.nestdb&&r.nestdb.state!==rt.CLOSED&&r.nestdb.name===o?[3,3]:(u="sendbird@".concat(n.appId,"/").concat(e,".db"),(c=r.nestdb=new Xe({name:u,version:this._getNestDBVersion(),store:r.store,config:new et({dbname:u,itemSizeLimit:61440})})).on("upgrade",_t(c)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",_t(c))})),[4,c.open()]);case 2:return a.sent(),this._storeInitialized=!0,i.dispatch(new lt(this._iid,{userId:e})),[3,5];case 3:return[4,this._safeInitializeStore(o)];case 4:a.sent(),a.label=5;case 5:return n.userId=e,[3,8];case 6:return d=a.sent(),s.warn("Nest DB Open Failed. ",d),r.store instanceof qe||(r.replaceStore(new qe),r.localCacheEnabled=!1),[4,this._safeInitializeStore(o)];case 7:throw a.sent(),n.userId=e,Z.databaseError;case 8:return[3,11];case 9:return[4,this._safeInitializeStore(o)];case 10:a.sent(),n.userId=e,a.label=11;case 11:return[2]}}))}))},n.prototype.getCacheDataSize=function(){return i(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.estimateUsage()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,0]}}))}))},n.prototype.clearCachedData=function(){return i(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return(e=q.of(this._iid).cacheContext).localCacheEnabled&&e.nestdb?[4,e.nestdb.clear()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this._storeInitialized?[4,e.preference.clear()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},n.prototype.clearCachedMessages=function(e){return i(this,void 0,void 0,(function(){var t,n,r=this;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=tt.of(this._iid),n=nt.of(this._iid),t&&n?[4,Promise.all(e.map((function(e){return i(r,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,t.removeMessagesOfChannel(e)];case 1:return r.sent(),[4,n.removeMessagesOfChannel(e)];case 2:return r.sent(),[2]}}))}))})))]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2]}}))}))},n.prototype._setupPreference=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.cacheContext,i=t.statManager,[4,r.preference.init(this._getPreferenceCacheKey(e),this._getNestDBVersion())];case 1:return o.sent(),[4,r.preference.get(this._getUserProfileCacheKey(e))];case 2:return(s=o.sent())&&new le(this._iid,s).apply(),[4,i.init("sendbird@".concat(n.appId,"/").concat(e,".statlog"))];case 3:return o.sent(),[2]}}))}))},n.prototype._ready=function(e,n,r){return void 0===r&&(r={}),i(this,void 0,void 0,(function(){var i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&t("string",n,!0)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.cacheContext,u=i.connectionManager,c=r.errorForOtherUser,s.userId&&s.userId!==e?c?[3,2]:[4,u.logout()]:[3,3];case 1:return a.sent(),[3,3];case 2:throw c;case 3:return a.trys.push([3,5,6,8]),[4,this.initializeCache(e)];case 4:return a.sent(),q.of(this._iid).dispatcher.dispatch(new ht),[3,8];case 5:return a.sent(),d=q.of(this._iid).logger,o.localCacheEnabled=!1,d.warn("Cache initialization failed - cache is not available."),[3,8];case 6:return[4,this._setupPreference(e)];case 7:return a.sent(),[7];case 8:return[2]}}))}))},n.prototype.authenticateFeed=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this.authenticate(e,t)];case 1:return[2,n.sent()]}}))}))},n.prototype.authenticate=function(e,t){var n;return i(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return r=q.of(this._iid),i=r.sessionManager,s=r.connectionManager,[4,this._ready(e,t,{errorForOtherUser:s.isConnected?Z.alreadyConnectedAsAnotherUser:void 0})];case 1:return a.sent(),(null===(n=i.session.services)||void 0===n?void 0:n.includes(me.CHAT))?[3,3]:(t||i.handler||(o=new $e,this.setSessionHandler(o)),[4,i.authenticate(e,t)]);case 2:a.sent(),a.label=3;case 3:return[2,this.currentUser]}}))}))},n.prototype.connect=function(e,t){return i(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._ready(e,t)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,,4,5]),[4,q.of(this._iid).connectionManager.connect(t)];case 3:return n.sent(),[3,5];case 4:return this._onlineDetector.start(),this._appStateChangeDetector.start(),[7];case 5:return[2,this.currentUser]}}))}))},n.prototype.reconnect=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.sessionManager.session.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((function(){n.appState="foreground"})).catch((function(){}))),r},n.prototype.disconnect=function(){return i(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._internalDisconnect()];case 1:return e.sent(),[2]}}))}))},n.prototype.disconnectWebSocket=function(){return i(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid),t=e.connectionManager,n=e.requestQueue,this._appStateChangeDetector.stop(),this._onlineDetector.stop(),n.cancelAll(),[4,t.disconnectWebSocket(!0)];case 1:return r.sent(),[2]}}))}))},n.prototype.setBackgroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.logger;"foreground"===n.appState&&(n.appState="background",r.debug("going background state"),t.background().catch((function(e){r.debug("setBackgroundState error = ",e)})))},n.prototype.setForegroundState=function(){var e=q.of(this._iid),t=e.connectionManager,n=e.sdkState,r=e.dispatcher,i=e.logger;"background"===n.appState&&(n.appState="foreground",i.debug("going foreground state"),t.resetAndReconnect().catch((function(e){i.debug("setForgroundState error = ",e)})),r.dispatch(new pt))},n.prototype.setSessionHandler=function(e){ee(e instanceof $e).throw(Z.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){ee(t("string",e)&&n instanceof We).throw(Z.invalidParameters),q.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){q.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){q.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){ee(t("string",e)&&n instanceof Ve).throw(Z.invalidParameters),q.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){q.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){q.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new Be(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new Je(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new Ye(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new Ze(this._iid,e)},n.prototype.createPollListQuery=function(e){return new te(this._iid,m({},e))},n.prototype.createPollVoterListQuery=function(e){return new ne(this._iid,m({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=re(e);return new g(this._iid,g.payloadify(t))},n.prototype.updateCurrentUserInfo=function(n){return void 0===n&&(n={}),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d;return a(this,(function(a){switch(a.label){case 0:return r=m(m({},bt),n),ee(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(Z.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new St(m({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(It).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw Z.connectionRequired}}))}))},n.prototype.updateCurrentUserInfoWithPreferredLanguages=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new St({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(It).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw Z.connectionRequired}}))}))},n.prototype.registerFCMPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.ANDROID,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.FCM,e)?[2,be.SUCCESS]:(h=new Et({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.FCM,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,s=n.sdkState,o=n.requestQueue,u=new Pt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterFCMPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,s=new Ut({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.FCM),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.registerAPNSPushTokenForCurrentUser=function(e,n){var r,s;return i(this,void 0,void 0,(function(){var o,u,c,d,l,h,f=this;return a(this,(function(p){switch(p.label){case 0:if(ee(t("string",e)&&t("string",null==n?void 0:n.deviceManufacturer,!0)).throw(Z.invalidParameters),(null==n?void 0:n.deviceOS)&&ee(_e(ye,n.deviceOS.platform,!0)&&t("string",n.deviceOS.version,!0)).throw(Z.invalidParameters),!this.currentUser)return[3,6];o={deviceOS:"".concat((null===(r=null==n?void 0:n.deviceOS)||void 0===r?void 0:r.platform)||ye.IOS,"-").concat((null===(s=null==n?void 0:n.deviceOS)||void 0===s?void 0:s.version)||"unknown"),deviceManufacturer:null==n?void 0:n.deviceManufacturer,systemPushEnabled:null==n?void 0:n.systemPushEnabled},p.label=1;case 1:return p.trys.push([1,4,,5]),u=q.of(this._iid),c=u.sessionManager,d=u.sdkState,l=u.requestQueue,c.hasDeviceToken(_.APNS,e)?[2,be.SUCCESS]:(h=new Ct({userId:d.userId,token:e,deviceOS:o.deviceOS,deviceManufacturer:o.deviceManufacturer,systemPushEnabled:o.systemPushEnabled}),[4,l.send(h)]);case 2:return p.sent(),[4,ie((function(){return i(f,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.setDeviceToken(_.APNS,e,o),[4,c.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return p.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return p.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenForCurrentUser=function(e){return i(this,void 0,void 0,(function(){var n,r,s,o,u,c,d=this;return a(this,(function(l){switch(l.label){case 0:if(ee(t("string",e)).throw(Z.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,s=n.sdkState,o=n.requestQueue,u=new Tt({userId:s.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,ie((function(){return i(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(_.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,be.SUCCESS];case 4:return l.sent(),[2,be.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,be.PENDING];case 7:return[2]}}))}))},n.prototype.unregisterAPNSPushTokenAllForCurrentUser=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,s,o,u=this;return a(this,(function(c){switch(c.label){case 0:return this.currentUser?(e=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,s=new Dt({userId:n.userId}),[4,r.send(s)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,ie((function(){return i(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(_.APNS),t.setDeviceTokenDeletedAt(o),[4,t.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))}))];case 2:c.sent(),c.label=3;case 3:return[2]}}))}))},n.prototype.markPushNotificationAsDelivered=function(e,t){var n;return void 0===t&&(t=!0),i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_,y,w,k;return a(this,(function(a){switch(a.label){case 0:if(r=q.of(this._iid),i=r.logger,s=r.sessionManager,o=r.requestQueue,u=r.pushNotificationAckManager,i.debug("markPushNotificationAsDelivered:",e),c=fn.DELIVERED,d=u.parseData(e),l=d.pushTrackingId,h=d.sessionTopics,f=d.sessionKey,p=d.messageId,v=d.channelKey,g=d.templateKey,m=d.notificationEventDeadline,!f)throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!h.includes(we.PUSH_ACKNOWLEDGEMENT))throw i.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(u.isAcked(l,c))return i.info("already delivered push notification:",l),[2];b=Boolean(v),_=t&&b,y=null===(n=s.deviceTokens[0])||void 0===n?void 0:n.token,w=new Sn({deviceToken:null!=y?y:"",pushTrackingId:l,eventType:c,messageId:p,channelKey:v,templateKey:g,notificationEventDeadline:m,allowedPushNotification:_}),f&&(w.headers["Session-Key"]=f),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,o.send(w)];case 2:return a.sent(),u.markAsAcked(l,c),[3,4];case 3:throw k=a.sent(),i.debug("failed to mark push notification as delivered. push tracking id: ".concat(l,". error: ").concat(k)),k;case 4:return[2]}}))}))},n.prototype.markPushNotificationAsClicked=function(e){var t;return i(this,void 0,void 0,(function(){var n,r,i,s,o,u,c,d,l,h,f,p,v,g,m,b,_;return a(this,(function(a){switch(a.label){case 0:if(n=q.of(this._iid),r=n.logger,i=n.sessionManager,s=n.requestQueue,o=n.pushNotificationAckManager,r.debug("markPushNotificationAsClicked:",e),u=fn.CLICKED,c=o.parseData(e),d=c.pushTrackingId,l=c.sessionTopics,h=c.sessionKey,f=c.messageId,p=c.channelKey,v=c.templateKey,g=c.notificationEventDeadline,!h)throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(!l.includes(we.PUSH_ACKNOWLEDGEMENT))throw r.info("Can't use markPushNotificationAsDelivered() feature."),Z.malformedDataError;if(o.isAcked(d,u))return r.info("already clicked push notification:",d),[2];m=null===(t=i.deviceTokens[0])||void 0===t?void 0:t.token,b=new Sn({deviceToken:null!=m?m:"",pushTrackingId:d,eventType:u,messageId:f,channelKey:p,templateKey:v,notificationEventDeadline:g}),h&&(b.headers["Session-Key"]=h),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,s.send(b)];case 2:return a.sent(),o.markAsAcked(d,u),[3,4];case 3:throw _=a.sent(),r.debug("failed to mark push notification as clicked. push tracking id: ".concat(d,". error: ").concat(_)),_;case 4:return[2]}}))}))},n.prototype.getChannelInvitationPreference=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Nt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(Mt).autoAccept}]}}))}))},n.prototype.setChannelInvitationPreference=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Lt({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(Rt).autoAccept}]}}))}))},n.prototype.getDoNotDisturb=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new zt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Qt).preference]}}))}))},n.prototype.setDoNotDisturb=function(e,n,r,s,o,u){return void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===u&&(u=""),i(this,void 0,void 0,(function(){var i,c,d,l,h;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",s)&&t("number",o)&&t("string",u)).throw(Z.invalidParameters),i=q.of(this._iid),c=i.sdkState,d=i.requestQueue,l=new jt({userId:c.userId,doNotDisturbOn:e,startHour:n,startMin:r,endHour:s,endMin:o,timezone:u}),[4,d.send(l)];case 1:return h=a.sent(),[2,h.as(Ft).preference]}}))}))},n.prototype.getSnoozePeriod=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(Ht).snoozePeriod]}}))}))},n.prototype.setSnoozePeriod=function(e,n,r){return void 0===n&&(n=0),void 0===r&&(r=0),i(this,void 0,void 0,(function(){var i,s,o,u,c;return a(this,(function(a){switch(a.label){case 0:return ee(t("boolean",e)&&t("number",n)&&t("number",r)).throw(Z.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new xt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(Kt).snoozePeriod]}}))}))},n.prototype.getMyPushTokensByToken=function(e,n){return i(this,void 0,void 0,(function(){var r,i,s,o,u,c,d,l,h,f,p,v;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)&&_e(_,n)).throw(Z.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new Ot({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(At).pushTokens;try{for(l=X(d.deviceTokens),h=l.next();!h.done;h=l.next())f=h.value,o.setDeviceToken(d.type,f)}catch(e){p={error:e}}finally{try{h&&!h.done&&(v=l.return)&&v.call(l)}finally{if(p)throw p.error}}return[4,o.saveDeviceToken()];case 2:return a.sent(),[2,d]}}))}))},n.prototype.getPushTriggerOption=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Bt).pushTriggerOption]}}))}))},n.prototype.setPushTriggerOption=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(ke,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Jt({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Yt).pushTriggerOption]}}))}))},n.prototype.getPushTemplate=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Zt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as($t).name]}}))}))},n.prototype.setPushTemplate=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(_e(Se,e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Xt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(en).name]}}))}))},n.prototype.blockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Gt({userId:r.userId,blockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.blockUser(e)]}))}))},n.prototype.unblockUser=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(e instanceof g||t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Wt({userId:r.userId,unblockedUserId:e instanceof g?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.unblockUser(e)]}))}))},n.prototype.getFriendChangeLogsByToken=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s,o;return a(this,(function(a){switch(a.label){case 0:return ee(t("string",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new tn({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(nn).changelogs]}}))}))},n.prototype.getAllowFriendDiscovery=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return e=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new dn({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(ln).allowFriendDiscovery]}}))}))},n.prototype.setAllowFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){var n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(t("boolean",e)).throw(Z.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new hn({userId:r.userId,allowFriendDiscovery:e}),[4,i.send(s)];case 1:return o.sent(),[2,e]}}))}))},n.prototype.uploadFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new rn({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(sn).friendDiscoveryRequestId]}}))}))},n.prototype.deleteFriendDiscovery=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriendDiscoveries([e])]}))}))},n.prototype.deleteFriendDiscoveries=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new on({userId:n.userId,discoveryKeys:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.addFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new an({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(un).users]}}))}))},n.prototype.deleteFriend=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){return[2,this.deleteFriends([e])]}))}))},n.prototype.deleteFriends=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i;return a(this,(function(s){switch(s.label){case 0:return ee(ge("string",e)).throw(Z.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new cn({userId:n.userId,userIds:e}),[4,r.send(i)];case 1:return s.sent(),[2]}}))}))},n.prototype.getAllEmoji=function(){return i(this,void 0,void 0,(function(){var e,t,n;return a(this,(function(r){switch(r.label){case 0:return e=q.of(this._iid).requestQueue,t=new pn,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(vn).emojiContainer]}}))}))},n.prototype.getEmojiCategory=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new gn({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(mn).emojiCategory]}}))}))},n.prototype.getEmoji=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return a(this,(function(i){switch(i.label){case 0:return t=q.of(this._iid).requestQueue,n=new bn({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(_n).emoji]}}))}))},n.prototype.getUIKitConfiguration=function(){return i(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return e=q.of(this._iid),ee(e.hasExtension("sb_uikit")).throw(Z.notSupportedError),t=e.requestQueue,n=new yn,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(wn).uikitConfiguration]}}))}))},n}();export{vt as Emoji,gt as EmojiCategory,mt as EmojiContainer,In as default}; |
@@ -1,1 +0,1 @@ | ||
export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-dd1a7eb2.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-01cdb35b.js"; | ||
export{aj as MentionType,a$ as MessageReviewStatus,ah as MessageType,aq as MessageTypeFilter,at as PushNotificationDeliveryOption,ay as ReplyType,ao as SendingStatus}from"./lib/__bundle-85fbca74.js";export{aM as AdminMessage,ar as AppleCriticalAlertOptions,ab as BaseMessage,b2 as Feedback,b3 as FeedbackRating,a0 as FileMessage,b4 as MessageForm,b5 as MessageFormItem,b6 as MessageFormItemLayout,aq as MessageMetaArray,q as MessageModule,aF as MessageRequestHandler,aU as MessageReviewInfo,aV as MessageSearchOrder,s as MessageSearchQuery,aW as MultipleFilesMessage,au as MultipleFilesMessageRequestHandler,aX as OGImage,aY as OGMetaData,aZ as PreviousMessageListQuery,a_ as Reaction,aN as ReactionEvent,a$ as ReactionEventOperation,b0 as Sender,a2 as ThreadInfo,a1 as ThreadInfoUpdateEvent,at as ThreadedParentMessageListQuery,ap as Thumbnail,b1 as UploadedFileInfo,$ as UserMessage}from"./lib/__bundle-3ceb5f92.js"; |
@@ -1,1 +0,1 @@ | ||
import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-dd1a7eb2.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-01cdb35b.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-0cf4fcf7.js";import{B as fe}from"./lib/__bundle-44075a31.js";import"./lib/__bundle-acd77193.js";var Ce=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return!!e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.prototype.getChannelFromCache=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},o.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),e.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt<o.updatedAt&&(l.lastPinnedMessage=o,c=!0),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s,i,h;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(l.url)&&(c&&(null===(i=r.onPinnedMessageUpdated)||void 0===i||i.call(r,l),null===(h=r.onChannelChanged)||void 0===h||h.call(r,l)),r.onMessageUpdated&&r.onMessageUpdated(l,o),u>0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=function(r){function a(e,n,t){return r.call(this,e,n,m.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,a.channelType=m.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; | ||
import{c as e,_ as n,b as t,af as r,Q as a,a as s,i,A as o,bn as u,bo as l,f as c,h,e as d,u as p,ak as f,U as C,z as v,p as _,q as g,g as y,C as m,aA as U,W as E,O as M,D as w,F as P,t as b,G as T,aM as N,a2 as D,aT as H,bi as I,w as O,s as x,bj as A,aB as L,V as R,ai as F,aO as k,a_ as S}from"./lib/__bundle-85fbca74.js";import{a3 as z,a4 as q,a5 as Q,a7 as G,a6 as j,a8 as B,a9 as K,aa as V,ae as W,af as X,ag as Y,ah as Z,P as $,z as J,as as ee,T as ne,ak as te}from"./lib/__bundle-3ceb5f92.js";import{C as re,B as ae,U as se,a as ie,O as oe,P as ue,M as le,T as ce,R as he,b as de,A as pe}from"./lib/__bundle-ace226dc.js";import{B as fe}from"./lib/__bundle-a7b76e00.js";import"./lib/__bundle-acd77193.js";var Ce=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e._channels=new Map,e._enteredChannelUrls=[],e}return e(a,r),Object.defineProperty(a.prototype,"enteredChannels",{get:function(){var e=this;return this._enteredChannelUrls.map((function(n){return e._channels.get(n)})).filter((function(e){return!!e}))},enumerable:!1,configurable:!0}),a.prototype.isEnteredChannel=function(e){return this._enteredChannelUrls.includes(e)},a.prototype.enter=function(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)},a.prototype.exit=function(e){var n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)},a.prototype.exitAll=function(){this._enteredChannelUrls=[]},a.prototype.get=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},a.prototype.upsert=function(e){return n(this,void 0,void 0,(function(){var n,r=this;return t(this,(function(t){return n=[],e.forEach((function(e){if(r._channels.has(e.url)){var t=r._channels.get(e.url);Object.assign(t,e),n.push(t)}else r._channels.set(e.url,e),n.push(e)})),[2,n]}))}))},a.prototype.remove=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return this._channels.delete(e),this.exit(e),[2]}))}))},a.prototype.clear=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){return this._channels.clear(),this._enteredChannelUrls=[],[2]}))}))},a}(r),ve={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},_e=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=o.GET,a.path="".concat(r?u:l,"/").concat(encodeURIComponent(t)),a.params={show_pinned_messages:!0},a}return e(t,n),t}(c),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),ye=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds,C=e.isEphemeral;return(t=n.call(this)||this).method=o.POST,t.path=l,t.params=d(p({channel_url:r,cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f,is_ephemeral:C})),t}return e(t,n),t}(c);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}e(t,n)}(h);var me=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"ENTR",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),Ue=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"SYEV",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),Ee=function(n){function t(e){var t=e.channelUrl;return n.call(this,{code:"EXIT",payload:{channel_url:t},ackRequired:!0})||this}return e(t,n),t}(f),Me=function(n){function t(e,t,r){var a,s,i=this;return i=n.call(this,e,"EXIT",r)||this,r.data&&(i.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,i.user=new C(e,r.data),i.ts=null!==(s=r.data.edge_ts)&&void 0!==s?s:0),i}return e(t,n),t}(re),we={},Pe=function(r){function o(e,a){var s=r.call(this,e,y(y({},a),{channelType:m.OPEN}))||this;return s.subscribeChannelEvent=U,s.unsubscribeChannelEvent=U,s.refreshChannel=function(){return n(s,void 0,void 0,(function(){return t(this,(function(e){return[2,U()]}))}))},s._openChannelCache=new Ce(e),s._openChannelHandlers=new Map,s._dispatcher.on((function(e){var n,t;if(e instanceof E)s._handleEvent(e).catch((function(e){if(M(e)&&"foreground"===s._sdkState.appState)throw e}));else if(e instanceof w&&e.stateType===P.CONNECTED){var r=s._openChannelCache.enteredChannels;try{for(var a=b(r),i=a.next();!i.done;i=a.next()){i.value.enter()}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),we[e]||(we[e]=s),s}return e(o,r),o.of=function(e){return we[e]},o.prototype.buildOpenChannelFromSerializedData=function(e){var n=v(e);return new xe(this._iid,xe.payloadify(n))},o.prototype.getChannelFromCache=function(e){var r;return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.get(e)];case 1:return[2,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},o.prototype.upsertChannelsToCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,this._openChannelCache.upsert(e)];case 1:return[2,n.sent()]}}))}))},o.prototype.removeChannelsFromCache=function(e){return n(this,void 0,void 0,(function(){var n,r,a,s,i,o;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=b(e),r=n.next(),t.label=1;case 1:return r.done?[3,4]:(a=r.value,[4,this._openChannelCache.remove(a)]);case 2:t.sent(),t.label=3;case 3:return r=n.next(),[3,1];case 4:return[3,7];case 5:return s=t.sent(),i={error:s},[3,7];case 6:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}return[7];case 7:return[2]}}))}))},o.prototype.setEnteredToCache=function(e){this._openChannelCache.enter(e.url)},o.prototype.setExitedToCache=function(e){this._openChannelCache.exit(e.url)},Object.defineProperty(o.prototype,"handlers",{get:function(){return _([],g(this._openChannelHandlers.values()),!1)},enumerable:!1,configurable:!0}),o.prototype._handleEvent=function(e){return n(this,void 0,void 0,(function(){var r,a,s,i,o,u,l,c,h,d,p,f,C,v,_,g,y,U,E,w,P,O,x,L,R,F,k,S,$,J,ee,ne,te,ae,fe,Ce,ve,_e,ge,ye,me,Ee,we,Pe,be,Te,Ne,De,He,Ie,Oe,xe,Ae,Le,Re,Fe,ke,Se,ze,qe,Qe,Ge,je,Be,Ke,Ve,We,Xe,Ye,Ze,$e,Je,en,nn,tn=this;return t(this,(function(rn){switch(rn.label){case 0:switch(rn.trys.push([0,59,,60]),e.code){case"MESG":case"FILE":case"ADMM":case"BRDM":return[3,1];case"MEDI":case"FEDI":case"AEDI":return[3,4];case"DELM":return[3,7];case"MRCT":return[3,10];case"MTHD":return[3,13];case"MCNT":return[3,16];case"PEDI":return[3,27];case"VOTE":return[3,30];case"SYEV":return[3,33]}return[3,58];case 1:return i=null,"MESG"===e.code?i=e.as(Y):"FILE"===e.code?i=e.as(Z):"ADMM"!==e.code&&"BRDM"!=e.code||(i=e.as(pe)),i?(r=i.message,a=i.isMentioned,r.channelType!==m.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:s=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,i,o,u;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())i=n.value,this._openChannelCache.isEnteredChannel(s.url)&&(i.onMessageReceived&&i.onMessageReceived(s,r),a&&i.onMentionReceived&&i.onMentionReceived(s,r))}catch(e){o={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(o)throw o.error}}return[2]}))}))})),rn.label=3;case 3:return[3,58];case 4:return i=null,"MEDI"===e.code?i=e.as(W):"FEDI"===e.code?i=e.as(X):"AEDI"===e.code&&(i=e.as(de)),i?(o=i.message,u=i.mentionCountChange,o.channelType!==m.OPEN?[3,6]:[4,this.getChannel(o.channelUrl,!0)]):[3,6];case 5:l=rn.sent(),c=!1,l.lastPinnedMessage&&l.lastPinnedMessage.messageId===o.messageId&&l.lastPinnedMessage.updatedAt<o.updatedAt&&(l.lastPinnedMessage=o,c=!0),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s,i,h;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(l.url)&&(c&&(null===(i=r.onPinnedMessageUpdated)||void 0===i||i.call(r,l),null===(h=r.onChannelChanged)||void 0===h||h.call(r,l)),r.onMessageUpdated&&r.onMessageUpdated(l,o),u>0&&r.onMentionReceived&&r.onMentionReceived(l,o))}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=6;case 6:return[3,58];case 7:return h=e.as(I),ne=h.channelUrl,te=h.channelType,d=h.messageId,te!==m.OPEN?[3,9]:[4,this.getChannel(ne,!0)];case 8:p=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(p.url)&&r.onMessageDeleted&&r.onMessageDeleted(p,d)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=9;case 9:return[3,58];case 10:return f=e.as(he),ne=f.channelUrl,te=f.channelType,C=f.event,te!==m.OPEN?[3,12]:[4,this.getChannel(ne,!0)];case 11:v=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&r.onReactionUpdated(v,C)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=12;case 12:return[3,58];case 13:return(_=e.as(ce).event).channelType!==m.OPEN?[3,15]:[4,this.getChannel(_.channelUrl,!0)];case 14:g=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(g.url)&&r.onThreadInfoUpdated&&r.onThreadInfoUpdated(g,_)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=15;case 15:return[3,58];case 16:y=e.as(le).openChannelMemberCounts,U=[],rn.label=17;case 17:rn.trys.push([17,22,23,24]),E=b(y),w=E.next(),rn.label=18;case 18:return w.done?[3,21]:(P=w.value,ne=P.channelUrl,Ee=P.participantCount,O=P.updatedAt,[4,this.getChannelFromCache(ne)]);case 19:(x=rn.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),rn.label=20;case 20:return w=E.next(),[3,18];case 21:return[3,24];case 22:return L=rn.sent(),en={error:L},[3,24];case 23:try{w&&!w.done&&(nn=E.return)&&nn.call(E)}finally{if(en)throw en.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:R=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(R)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=26;case 26:return[3,58];case 27:return F=e.as(ue),k=F.event,S=F.status,ne=F.channelUrl,te=F.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,29];case 28:$=rn.sent(),this._dispatcher.dispatch(new H({event:k,source:D.EVENT_POLL_UPDATED})),T(S===A?function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted($,k.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated($,k)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),rn.label=29;case 29:return[3,58];case 30:return J=e.as(V),ee=J.event,ne=J.channelUrl,te=J.channelType,ne&&te===m.OPEN?[4,this.getChannel(ne,!0)]:[3,32];case 31:ae=rn.sent(),this._dispatcher.dispatch(new N({event:ee,source:D.EVENT_POLL_VOTED})),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(ae,ee)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),rn.label=32;case 32:return[3,58];case 33:if(!(fe=e.as(re).event).isOpenChannelEvent)return[3,57];switch(fe.category){case ie.CHANNEL_ENTER:return[3,34];case ie.CHANNEL_EXIT:return[3,36];case ie.CHANNEL_OPERATOR_UPDATE:return[3,38];case ie.USER_CHANNEL_MUTE:case ie.USER_CHANNEL_UNMUTE:return[3,40];case ie.USER_CHANNEL_BAN:case ie.USER_CHANNEL_UNBAN:return[3,42];case ie.CHANNEL_FREEZE:case ie.CHANNEL_UNFREEZE:return[3,44];case ie.CHANNEL_DELETED:return[3,46];case ie.CHANNEL_PROP_CHANGED:return[3,49];case ie.CHANNEL_META_DATA_CHANGED:return[3,51];case ie.CHANNEL_META_COUNTERS_CHANGED:return[3,53];case ie.PINNED_MESSAGE_CHANGED:return[3,55]}return[3,57];case 34:return[4,this.getChannel(fe.channelUrl,!0)];case 35:return Ce=rn.sent(),ve=e.as(Ue),Ee=ve.participantCount,_e=ve.user,ge=Ce._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserEntered&&e.onUserEntered(Ce,_e),ge&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(Ce)})),[2]}))}))})),[3,57];case 36:return[4,this.getChannel(fe.channelUrl,!0)];case 37:return ye=rn.sent(),me=e.as(Me),Ee=me.participantCount,we=me.user,Pe=ye._updateParticipantCount(Ee,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onUserExited&&e.onUserExited(ye,we),Pe&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(ye)})),[2]}))}))})),[3,57];case 38:return[4,this.getChannel(fe.channelUrl,!0)];case 39:return be=rn.sent(),Te=e.as(oe).operators,be.operators=Te,this.upsertChannelsToCache([be]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(be,Te)})),[2]}))}))})),[3,57];case 40:return[4,this.getChannel(fe.channelUrl,!0)];case 41:return Ne=rn.sent(),De=fe.category===ie.USER_CHANNEL_MUTE,He=e.as(De?B:K).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){De?e.onUserMuted&&e.onUserMuted(Ne,He):e.onUserUnmuted&&e.onUserUnmuted(Ne,He)})),[2]}))}))})),[3,57];case 42:return[4,this.getChannel(fe.channelUrl,!0)];case 43:return Ie=rn.sent(),Oe=fe.category===ie.USER_CHANNEL_BAN,xe=e.as(Oe?G:j).user,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Oe?e.onUserBanned&&e.onUserBanned(Ie,xe):e.onUserUnbanned&&e.onUserUnbanned(Ie,xe)})),[2]}))}))})),[3,57];case 44:return[4,this.getChannel(fe.channelUrl,!0)];case 45:return Ae=rn.sent(),Le=e.as(Q).freeze,Ae.isFrozen=Le,this.upsertChannelsToCache([Ae]),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Le?e.onChannelFrozen&&e.onChannelFrozen(Ae):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ae)})),[2]}))}))})),[3,57];case 46:return[4,this.getChannel(fe.channelUrl,!0)];case 47:return Re=rn.sent(),[4,this.removeChannelsFromCache([Re.url])];case 48:return rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Re.url,Re.channelType)})),[2]}))}))})),[3,57];case 49:return[4,this.getChannelWithoutCache(fe.channelUrl,!0)];case 50:return Fe=rn.sent(),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Fe)})),[2]}))}))})),[3,57];case 51:return[4,this.getChannel(fe.channelUrl,!0)];case 52:return ke=rn.sent(),Se=e.as(q),ze=Se.created,qe=Se.updated,Qe=Se.deleted,ze&&ke._upsertCachedMetaData(ze,fe.ts),qe&&ke._upsertCachedMetaData(qe,fe.ts),Qe&&ke._removeFromCachedMetaData(Qe,fe.ts),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){ze&&e.onMetaDataCreated&&e.onMetaDataCreated(ke,ze),qe&&e.onMetaDataUpdated&&e.onMetaDataUpdated(ke,qe),Qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(ke,Qe)})),[2]}))}))})),[3,57];case 53:return[4,this.getChannel(fe.channelUrl,!0)];case 54:return Ge=rn.sent(),je=e.as(z),Be=je.created,Ke=je.updated,Ve=je.deleted,T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Be&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Ge,Be),Ke&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ge,Ke),Ve&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Ge,Ve)})),[2]}))}))})),[3,57];case 55:return[4,this.getChannel(fe.channelUrl,!0)];case 56:return We=rn.sent(),Xe=e.as(se),Ye=Xe.pinnedMessageIds,Ze=Xe.latestPinnedMessage,($e=Xe.ts)>We._pinnedMessagesUpdatedAt&&(We.pinnedMessageIds=Ye,We.lastPinnedMessage=Ze,We._pinnedMessagesUpdatedAt=$e,this.upsertChannelsToCache([We]),T((function(){return n(tn,void 0,void 0,(function(){var e,n,r,a,s;return t(this,(function(t){try{for(e=b(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelChanged&&r.onChannelChanged(We)}catch(e){a={error:e}}finally{try{n&&!n.done&&(s=e.return)&&s.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),T((function(){return n(tn,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(We)})),[2]}))}))}))),[3,57];case 57:return[3,58];case 58:return[3,60];case 59:if(Je=rn.sent(),M(Je))throw Je;return[3,60];case 60:return[2]}}))}))},o.prototype.addHandler=function(e,n){this._openChannelHandlers.set(e,n)},o.prototype.removeHandler=function(e){this._openChannelHandlers.delete(e)},o.prototype.clearHandler=function(){this._openChannelHandlers.clear()},o.prototype.getChannel=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n;return t(this,(function(t){switch(t.label){case 0:O(s("string",e)).throw(x.invalidParameters),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.getChannelFromCache(e)];case 2:return(n=t.sent())?[2,n]:[3,4];case 3:return t.sent(),[3,4];case 4:return[4,this.getChannelWithoutCache(e,r)];case 5:return[2,t.sent()]}}))}))},o.prototype.getChannelWithoutCache=function(e,r){return void 0===r&&(r=!1),n(this,void 0,void 0,(function(){var n,a,i;return t(this,(function(t){switch(t.label){case 0:return O(s("string",e)).throw(x.invalidParameters),n=new _e({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),i=a.as(ge).channel,[4,this.upsertChannelsToCache([i])];case 2:return[2,t.sent()[0]]}}))}))},o.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},ve),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)&&(s("string",e.channelUrl)&&/^\w+$/.test(e.channelUrl)||null===e.channelUrl||void 0===e.channelUrl)&&s("boolean",e.isEphemeral,!0)}(n)).throw(x.invalidParameters),r=new ye(n),[4,this._requestQueue.send(r)];case 1:return o=t.sent(),u=o.as(ge).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},o}(ae),be={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.token,s=e.limit;return(t=n.call(this)||this).method=o.GET,t.path="".concat(l,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:s},t}return e(t,n),t}(c),Ne=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,s=t.participants;return r.token=a,r.participants=s.map((function(n){return new $(e,n)})),r}return e(t,n),t}(h),De=function(r){function a(e,n,t){return r.call(this,e,n,m.OPEN,t)||this}return e(a,r),a.prototype._validate=function(){return r.prototype._validate.call(this)},a.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Te(y(y({},this),{token:this._token})),[4,e.send(n)]):[3,2]:[3,5];case 1:return r=t.sent(),a=r.as(Ne),s=a.participants,i=a.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw x.queryInProgress;case 4:return[3,6];case 5:throw x.invalidParameters;case 6:return[2]}}))}))},a}(L),He=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,c=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=o.PUT,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:s("string",a)?a:null,cover_file:i(a)?a:null,name:u,data:c,custom_type:h,operators:f})),t}return e(t,n),t}(c),Ie=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new xe(e,t),r}return e(t,n),t}(h),Oe=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=o.DELETE,t.path="".concat(l,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(c);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var xe=function(r){function o(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.lastPinnedMessage=null,a._pinnedMessagesUpdatedAt=0,a.channelType=m.OPEN,a.participantCount=null!==(t=n.participant_count)&&void 0!==t?t:0,a.operators=Array.isArray(n.operators)?n.operators.map((function(n){return new C(e,n)})):[],a.lastPinnedMessage=n.latest_pinned_message?ne(a._iid,y({channel_type:a.channelType},n.latest_pinned_message)):null,a}return e(o,r),o.payloadify=function(e){return d(p(y(y({},J.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return C.payloadify(e)})),latest_pinned_message:e.lastPinnedMessage?ee(e.lastPinnedMessage):null})))},o.prototype.serialize=function(){return F(this)},o.prototype.isOperator=function(e){return e instanceof C?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},o.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},o.prototype.createParticipantListQuery=function(e){return new De(this._iid,this.url,e)},o.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,Pe.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},o.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new me({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Ue),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setEnteredToCache(this),[2]}}))}))},o.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Ee({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(Me),s=a.participantCount,i=a.ts,this._updateParticipantCount(s,i),Pe.of(this._iid).setExitedToCache(this),te.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},o.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,o,u,l;return t(this,(function(t){switch(t.label){case 0:return n=y(y({},be),e),O(function(e){return a("string",e.operatorUserIds,!0)&&(s("string",e.coverUrlOrImage,!0)||i(e.coverUrlOrImage,!0))&&s("string",e.name,!0)&&s("string",e.data,!0)&&s("string",e.customType,!0)}(n)).throw(x.invalidParameters),r=R.of(this._iid).requestQueue,o=new He(y({channelUrl:this.url},n)),[4,r.send(o)];case 1:return u=t.sent(),l=u.as(Ie).channel,this._update(l),[4,Pe.of(this._iid).upsertChannelsToCache([l])];case 2:return t.sent(),[2,this]}}))}))},o.prototype.updateChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=y(y({},be),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:s,customType:i}),[2,this.updateChannel(n)]}))}))},o.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=R.of(this._iid).requestQueue,n=new Oe({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,Pe.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},o.prototype.updateUserMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateUserMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o.prototype.updateFileMessage=function(e,a){return n(this,void 0,void 0,(function(){var n,s,i,o=this;return t(this,(function(t){switch(t.label){case 0:return[4,r.prototype.updateFileMessage.call(this,e,a)];case 1:return n=t.sent(),s=!1,i=!1,this.lastPinnedMessage&&this.lastPinnedMessage.messageId===n.messageId&&(this.lastPinnedMessage=n,s=!0,i=!0),s&&Pe.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),i&&Pe.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),[2,n]}}))}))},o}(J),Ae=function(n){function t(e){void 0===e&&(e={});var t=n.call(this)||this;return Object.keys(e).forEach((function(n){t.hasOwnProperty(n)&&(t[n]=e[n])})),t}return e(t,n),t}(function(n){function t(){var e=null!==n&&n.apply(this,arguments)||this;return e.onUserEntered=U,e.onUserExited=U,e.onChannelParticipantCountChanged=U,e.onPollUpdated=U,e.onPollVoted=U,e.onPollDeleted=U,e.onPinnedMessageUpdated=U,e}return e(t,n),t}(fe)),Le=function(n){function t(e){var t=this,r=e.token,a=e.limit,s=e.nameKeyword,i=e.urlKeyword,u=e.customTypes,c=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=o.GET,t.path=l,t.params=d({token:r,limit:a,name_contains:s,url_contains:i,custom_types:u,show_frozen:c,show_metadata:h,show_pinned_messages:!0}),t}return e(t,n),t}(c),Re=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,s=t.channels,i=t.ts;return r.token=a,s&&s.length>0&&(r.channels=s.map((function(n){return new xe(e,n)}))),r.ts="number"==typeof i?i:null,r}return e(t,n),t}(h),Fe=function(r){function i(e,n){var t,a,s,i,o,u=this;return(u=r.call(this,e,n)||this).includeFrozen=!0,u.includeMetaData=!0,u.nameKeyword=null,u.urlKeyword=null,u.customTypes=null,u.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,u.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,u.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,u.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,u.customTypes=null!==(o=n.customTypes)&&void 0!==o?o:null,u}return e(i,r),i.prototype._validate=function(){return r.prototype._validate.call(this)&&s("boolean",this.includeFrozen)&&s("boolean",this.includeMetaData)&&s("string",this.nameKeyword,!0)&&s("string",this.urlKeyword,!0)&&a("string",this.customTypes,!0)},i.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,s,i;return t(this,(function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,4]:this._hasNext?(this._isLoading=!0,e=R.of(this._iid).requestQueue,n=new Le(p(y(y({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(Re),s=a.channels,i=a.token,this._token=i,this._hasNext=!!i,[4,Pe.of(this._iid).upsertChannelsToCache(s)];case 2:return t.sent(),this._isLoading=!1,[2,s];case 3:return[2,[]];case 4:throw x.queryInProgress;case 5:return[3,7];case 6:throw x.invalidParameters;case 7:return[2]}}))}))},i}(k),ke=function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name="openChannel",e}return e(a,r),a.prototype.init=function(e,n){var t=n.sdkState,a=n.dispatcher,s=n.sessionManager,i=n.requestQueue,o=n.logger,u=n.onlineDetector,l=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:s,requestQueue:i,logger:o,onlineDetector:u,cacheContext:l}),this._manager=new Pe(e,{sdkState:t,dispatcher:a,requestQueue:i,logger:o,cacheContext:l,sessionManager:s})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Fe(this._iid,e)},a.prototype.addOpenChannelHandler=function(e,n){this._manager.addHandler(e,n)},a.prototype.removeOpenChannelHandler=function(e){this._manager.removeHandler(e)},a.prototype.removeAllOpenChannelHandlers=function(){this._manager.clearHandler()},a.prototype.buildOpenChannelFromSerializedData=function(e){return this._manager.buildOpenChannelFromSerializedData(e)},a.prototype.getChannel=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannel(e)]}))}))},a.prototype.getChannelWithoutCache=function(e){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.getChannelWithoutCache(e)]}))}))},a.prototype.createChannel=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._manager.createChannel(e)]}))}))},a.prototype.createChannelWithOperatorUserIds=function(e,r,a,s,i){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=y({},ve)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=s,n.customType=i,[2,this._manager.createChannel(n)]}))}))},a}(S);export{xe as OpenChannel,Ae as OpenChannelHandler,Fe as OpenChannelListQuery,ke as OpenChannelModule,De as ParticipantListQuery}; |
{ | ||
"version": "4.14.2", | ||
"version": "4.14.3", | ||
"description": "Sendbird SDK for JavaScript", | ||
@@ -4,0 +4,0 @@ "sideEffects": false, |
@@ -1,1 +0,1 @@ | ||
import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as d,b4 as p,b5 as h}from"./lib/__bundle-dd1a7eb2.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-dd1a7eb2.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(d(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},p),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; | ||
import{c as t,aN as e,_ as r,a_ as a,b as n,g as o,b0 as i,w as s,b1 as l,s as u,b2 as c,b3 as p,b4 as d,b5 as h}from"./lib/__bundle-85fbca74.js";export{ar as Poll,x as PollListQuery,b6 as PollOption,b7 as PollStatus,aI as PollVoteEvent,y as PollVoterListQuery}from"./lib/__bundle-85fbca74.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var b=function(a){function b(){var t=null!==a&&a.apply(this,arguments)||this;return t.name="poll",t}return t(b,a),b.prototype.init=function(t,r){var n=r.sdkState,o=r.dispatcher,i=r.sessionManager,s=r.requestQueue,l=r.logger,u=r.onlineDetector,c=r.cacheContext;a.prototype.init.call(this,t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c}),this._manager=new e(t,{sdkState:n,dispatcher:o,sessionManager:i,requestQueue:s,logger:l,onlineDetector:u,cacheContext:c})},b.prototype.create=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},i),t),s(l(e)).throw(u.invalidParameters),[2,this._manager.create(e)]}))}))},b.prototype.get=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},c),t),s(p(e)).throw(u.invalidParameters),[2,this._manager.get(e)]}))}))},b.prototype.getOption=function(t){return r(this,void 0,void 0,(function(){var e;return n(this,(function(r){return e=o(o({},d),t),s(h(e)).throw(u.invalidParameters),[2,this._manager.getOption(e)]}))}))},b.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},b}(a);export{b as PollModule}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
3068651
0.01%