PageSourceSearch

https://www.caringbridge.org/_next/static/chunks/bf1bea8b-aaf74c3f8596ad63.js

js caringbridge.org collected 2026-09-24 08:40:40 UTC 284,963 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5600],{61301:function(e,t,n){n.d(t,{$:function(){return ip},A:function(){return rQ},B:function(){return nH},C:function(){return nq},D:function(){return r1},F:function(){return nJ},G:function(){return nF},I:function(){return rK},K:function(){return eE},L:function(){return r0},M:function(){return r$},N:function(){return nt},P:function(){return ew},S:function(){return nz},U:function(){return nj},V:function(){return r2},W:function(){return t7},X:function(){return N},Y:function(){return C},Z:function(){return ib},_:function(){return es},a:function(){return t8},a0:function(){return O},a1:function(){return B},a2:function(){return W},a3:function(){return iI},a4:function(){return c},a5:function(){return tm},a6:function(){return ti},a7:function(){return tM},a8:function(){return tS},a9:function(){return tw},aA:function(){return r8},aB:function(){return r9},aC:function(){return ie},aD:function(){return eO},aE:function(){return nx},aF:function(){return ej},aG:function(){return eN},aH:function(){return eF},aI:function(){return nd},aJ:function(){return eT},aK:function(){return I},aL:function(){return T},aM:function(){return E},aN:function(){return tG},aO:function(){return nR},aP:function(){return u},aQ:function(){return o},aT:function(){return id},aU:function(){return l},aa:function(){return tg},ab:function(){return tI},ac:function(){return t6},ad:function(){return D},ae:function(){return w},af:function(){return L},ag:function(){return tD},ah:function(){return tF},ai:function(){return z},aj:function(){return tx},ak:function(){return Z},al:function(){return ne},am:function(){return Q},an:function(){return H},ao:function(){return eB},ap:function(){return eK},aq:function(){return eQ},ar:function(){return eG},as:function(){return a},at:function(){return v},au:function(){return m},av:function(){return G},aw:function(){return iC},ax:function(){return b},ay:function(){return nf},az:function(){return r7},b:function(){return t9},c:function(){return nn},d:function(){return it},e:function(){return ir},f:function(){return ns},g:function(){return r5},h:function(){return na},i:function(){return no},j:function(){return nu},k:function(){return nr},l:function(){return ni},m:function(){return r6},n:function(){return nc},o:function(){return nl},p:function(){return rJ},q:function(){return rV},r:function(){return rG},s:function(){return iR},t:function(){return nK},u:function(){return iM},v:function(){return io},w:function(){return is},x:function(){return rY},y:function(){return rX},z:function(){return nZ}});var r,i,s=n(25098),a=function(){function e(e,t,n){var r,i;this.width=0,this.height=0,this.realWidth=0,this.realHeight=0,this._requireAuth=!1,this._iid=e,this.plainUrl=t.url,this.width=t.width,this.height=t.height,this.realWidth=null!==(r=t.real_width)&&void 0!==r?r:t.width,this.realHeight=null!==(i=t.real_height)&&void 0!==i?i:t.height,this._requireAuth=n}return e.payloadify=function(t){return(0,s.f)((0,s.g)(t instanceof e?{url:t.plainUrl,width:t.width,height:t.height,real_width:t.realWidth,real_height:t.realHeight}:{url:"",width:t.maxWidth,height:t.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),e}(),o=function(e){function t(t){var n=e.call(this)||this;if(n.method=s.A.POST,n.path="".concat(s.ao),n.params=(0,s.f)({file:t.file,channel_url:t.channelUrl}),t.thumbnailSizes)for(var r=0;r<t.thumbnailSizes.length;r++){var i=t.thumbnailSizes[r],a=i.maxWidth,o=i.maxHeight;n.params["thumbnail".concat(r+1)]="".concat(a,",").concat(o)}return n.requestId=t.requestId,n}return(0,s.c)(t,e),t}(s.h),u=function(e){function t(t,n){var r,i,s,o,u=this;return(u=e.call(this,t,n)||this).url=n.url,u.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,u.thumbnails=null!==(s=null===(i=n.thumbnails)||void 0===i?void 0:i.map(function(e){return new a(t,e,!1)}))&&void 0!==s?s:[],u.requireAuth=null!==(o=n.require_auth)&&void 0!==o&&o,u}return(0,s.c)(t,e),t}(s.j),c=function(e){function t(t,n){var r,i,a,o,u,c=this;return(c=e.call(this,t)||this).replyCount=0,c.memberCount=0,c.lastRepliedAt=0,c.updatedAt=0,c.replyCount=null!==(r=n.reply_count)&&void 0!==r?r:0,c.memberCount=null!==(i=n.member_count)&&void 0!==i?i:0,c.mostRepliedUsers=n.most_replies&&(0,s.a2)("object",n.most_replies)?n.most_replies.map(function(e){return new s.U(c._iid,e)}):[],c.unreadReplyCount=null!==(a=n.unread_message_count)&&void 0!==a?a:0,c.isPushNotificationEnabled="number"==typeof n.push_enabled?n.push_enabled>0:void 0,c.lastRepliedAt=null!==(o=n.last_replied_at)&&void 0!==o?o:0,c.updatedAt=null!==(u=n.updated_at)&&void 0!==u?u:0,c}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{reply_count:t.replyCount,unread_message_count:t.unreadReplyCount,member_count:t.memberCount,most_replies:Array.isArray(t.mostRepliedUsers
1)?t.mostRepliedUsers.map(function(e){return s.U.payloadify(e)}):[],push_enabled:"boolean"==typeof t.isPushNotificationEnabled?t.isPushNotificationEnabled?1:0:void 0,last_replied_at:t.lastRepliedAt,updated_at:t.updatedAt})))},Object.defineProperty(t.prototype,"_isUpdateRequired",{get:function(){return void 0===this.unreadReplyCount||void 0===this.isPushNotificationEnabled},enumerable:!1,configurable:!0}),t.prototype._updateFrom=function(e){var t,n;this.unreadReplyCount=null!==(t=e.unreadReplyCount)&&void 0!==t?t:this.unreadReplyCount,this.isPushNotificationEnabled=null!==(n=e.isPushNotificationEnabled)&&void 0!==n?n:this.isPushNotificationEnabled},t}(s.ap);(M=i||(i={})).ADD="add",M.DELETE="delete";var l=function(e){this.messageId=0,this.operation=null,this.updatedAt=0;var t,n=(0,s.a)("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,r=e.user_id,a=e.operation?e.operation.toLowerCase():null,o=e.reaction,u=e.updated_at,c=e.count,l=e.sampled_user_ids,d=null!==(t=e.sampled_user_info)&&void 0!==t?t:{};n&&(0,s.a)("string",r)&&(0,s.a)("string",a)&&(0,s.a5)(i,a)&&(0,s.a)("string",o)&&o&&(0,s.a)("number",u)&&(this.messageId=n,this.userId=r,this.key=o,this.operation=a,this.updatedAt=u,this._count=c,this._sampledUserIds=l,this._sampledUserInfoList=d)},d=function(e){function t(t,n,r){var i,s=this;return(s=e.call(this,t)||this).userId=n,s.nickname=r.nickname,s.plainProfileUrl=r.profile_url,s.requireAuth=null!==(i=r.require_auth_for_profile_image)&&void 0!==i&&i,s}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"profileUrl",{get:function(){var e=s.V.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl},enumerable:!1,configurable:!0}),t.payloadify=function(e){return{nickname:e.nickname,profile_url:e.plainProfileUrl,require_auth_for_profile_image:e.requireAuth}},t}(s.ap),h=function(e){function t(t,n){var r,i,a,o,u,c,l,h,f,p=this;(p=e.call(this,t)||this)._sampledUserInfoList=[],p._count=0,p._hasCurrentUserReacted=!1;var m=n.key,_=(0,s.q)([],(0,s.r)(null!==(o=null!==(a=n.sampled_user_ids)&&void 0!==a?a:n.user_ids)&&void 0!==o?o:[]),!1),v=null!==(c=null!==(u=n.last_ts)&&void 0!==u?u:n.updated_at)&&void 0!==c?c:0,y=null!==(l=n.is_self_included)&&void 0!==l?l:_.includes(s.V.of(t).sdkState.userId),g=null!==(h=n.sampled_user_info)&&void 0!==h?h:{};(0,s.a)("string",m)&&m&&(0,s.a2)("string",_)&&_.length>0&&(0,s.a)("number",v)&&(p.key=m,p._sampledUserIds=_,p._updatedAt=v,p._count=null!==(f=n.count)&&void 0!==f?f:_.length,p._hasCurrentUserReacted=y,Object.keys(g).forEach(function(e){p._sampledUserInfoList.push(new d(t,e,g[e]))}));var b={};try{for(var I=(0,s.w)(p.sampledUserIds),E=I.next();!E.done;E=I.next())b[E.value]=p.updatedAt}catch(e){r={error:e}}finally{try{E&&!E.done&&(i=I.return)&&i.call(I)}finally{if(r)throw r.error}}return p._version=b,p}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return 0===this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserIds",{get:function(){return this._sampledUserIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sampledUserInfoList",{get:function(){return this._sampledUserInfoList},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updatedAt",{get:function(){return this._updatedAt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCurrentUserReacted",{get:function(){return this._hasCurrentUserReacted},enumerable:!1,configurable:!0}),t.payloadify=function(e){var t={};return e._sampledUserInfoList.forEach(function(e){t[e.userId]=d.payloadify(e)}),(0,s.f)((0,s.g)({key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:t,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e._updatedAt}))},t.prototype.applyEvent=function(e){var t=this;if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(e._sampledUserIds)this._sampledUserIds=e._sampledUserIds,this._sampledUserInfoList=[],Object.keys(e._sampledUserInfoList).forEach(function(n){t._sampledUserInfoList.push(new d(t._iid,n,e._sampledUserInfoList[n]))}),this._count=e._count,void 0!==e._hasCurrentUserReacted&&(this._hasCurrentUserReacted=e._hasCurrentUserReacted),this._updatedAt=e.updatedAt;else{if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){var n=this._sampledUserIds.indexOf(e.userId);switch(e.operation){case i.ADD:n<0&&this._sampledUserIds.push(e.userId);break;case i.DELETE:n>=0&&this._sampledUserIds.splice(n,1)}this._count=this._sampledUserIds.length,this._version[e.userId]=e.updatedAt}this._updatedAt=Math.max(this.updatedAt,e.updatedAt)}}},t}(s.ap),f=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.t
1ype=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return(0,s.f)((0,s.g)({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(n=e.height)&&void 0!==n?n:0,alt:e.alt}))},e}(),p=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new f(e["og:image"]))}return e.payloadify=function(e){return(0,s.f)((0,s.g)({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?f.payloadify(e.defaultImage):null}))},e}(),m=function(){function e(e){var t,n;this.volume=0,this.name=null!==(t=e.name)&&void 0!==t?t:"default",this.volume=null!==(n=e.volume)&&void 0!==n?n:1}return e.prototype.serialize=function(){return{name:this.name,volume:this.volume}},e.payloadify=function(e){return(0,s.f)((0,s.g)({name:e.name,volume:e.volume}))},e}(),_=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isBlockedByMe=!1,i.role=(0,s.a5)(s.ai,n.role)?n.role:s.ai.NONE,i.isBlockedByMe=null!==(r=n.is_blocked_by_me)&&void 0!==r&&r,i}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{role:t.role,is_blocked_by_me:t.isBlockedByMe})))},t}(s.U),v=function(){function e(e){this.key=e.key,this.value=(0,s.a2)("string",e.value)?(0,s.q)([],(0,s.r)(e.value),!1):[]}return e.payloadify=function(e){var t;return(0,s.f)((0,s.g)({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),y=function(e){switch(e){case s.ar.BASE:return"";case s.ar.USER:return"MESG";case s.ar.FILE:return"FILE";case s.ar.ADMIN:return"ADMM"}},g=function(e){function t(t,n){var r,i,a,o,u,c,l,d,h,f=this;(f=e.call(this,t)||this).channelType=s.C.BASE,f.messageType=s.ar.BASE,f.mentionType=null,f.mentionedUsers=null,f.mentionedUserIds=null,f.metaArrays=[],f.extendedMessage={},f.createdAt=0,f.updatedAt=0,f.channelUrl=n.channel_url,f.channelType=(0,s.a5)(s.C,n.channel_type)?n.channel_type:s.C.GROUP,n.channel&&(n.channel.channel_url&&(f.channelUrl=n.channel.channel_url),n.channel.channel_type&&(f.channelType=n.channel.channel_type)),f.data=null!==(r=n.data)&&void 0!==r?r:"",f.customType=null!==(i=n.custom_type)&&void 0!==i?i:"",f.mentionType=(0,s.a5)(s.at,n.mention_type)?n.mention_type:null,f.mentionedUsers=n.mentioned_users?n.mentioned_users.map(function(e){return new s.U(f._iid,e)}):null,f.mentionedUserIds=null!==(a=n.mentioned_user_ids)&&void 0!==a?a:null,f.mentionedUsers&&!f.mentionedUserIds&&(f.mentionedUserIds=f.mentionedUsers.map(function(e){return e.userId}));var p=null!==(o=n.metaarray)&&void 0!==o?o:{},m=null!==(u=n.metaarray_key_order)&&void 0!==u?u:Object.keys(p).sort(function(e,t){return e.localeCompare(t)});f.metaArrays=[];for(var _=0;_<m.length;_++){var y=m[_];f.metaArrays.push(new v({key:y,value:p[y]||[]}))}return n.sorted_metaarray&&(f.metaArrays=n.sorted_metaarray.map(function(e){return new v(e)})),f.extendedMessage=null!==(c=n.extended_message)&&void 0!==c?c:{},f.extendedMessagePayload=n.extended_message_payload,f.createdAt=null!==(d=null!==(l=n.created_at)&&void 0!==l?l:n.ts)&&void 0!==d?d:0,f.updatedAt=null!==(h=n.updated_at)&&void 0!==h?h:0,f}return(0,s.c)(t,e),t.payloadify=function(t){var n,r;return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{channel_url:t.channelUrl,channel_type:t.channelType,type:y(t.messageType),data:t.data,custom_type:t.customType,mention_type:t.mentionType,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(n=t.mentionedUsers)||void 0===n?void 0:n.map(function(e){return s.U.payloadify(e)}),sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return v.payloadify(e)}),extended_message:t.extendedMessage,extended_message_payload:t.extendedMessagePayload,created_at:t.createdAt,updated_at:t.updatedAt})))},t.prototype.isIdentical=function(e){return!0},t.prototype.isEqual=function(e){return(0,s.aq)(this,e)},t.prototype.isUserMessage=function(){return this.messageType===s.ar.USER},t.prototype.isFileMessage=function(){return this.messageType===s.ar.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isMultipleFilesMessage=function(){return this.messageType===s.ar.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")},t.prototype.isAdminMessage=function(){return this.messageType===s.ar.ADMIN},t.prototype.serialize=function(){return(0,s.as)(this)},t.prototype.getMetaArraysByKeys=function(e){return this.metaArrays.filter(function(t){return e.includes(t.key)})},t}(s.ap),b=function(e){function t(t,n){var r,i,a,o=this;return(o=e.call(this,t)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",o.channelType=null!==(i=n.channel_type)&&void 0!==i?i:s.C.GROUP,o.reader=new s.U(o._iid,n.user),o.readAt=n.ts,o.isExcluded=null!==(a=n.is_excluded)&&void 0!==a&&a,o}return(0,s.c)(t,e),t}(s.ap),I=function(e){function t(t){var n=t.channelUrl;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return(0,s.c)(t,e),t}(s.au),E=function(e){function t(t){var n=e.call(this)||this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.notificationIds,u=t.messageId,c=t.isExcluded,l=t.uniqueId;return n.method=s.A.PUT,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/messages/mark_as_read"),n.params=(0,s.f)((0,s.g)({user_id:a,message_ids:o,message_id:u,is_excluded:c,unique_id:l})),n}return(0,s.c)(t,e),t}(s.h),w=function(e){function t(t,n,r){var i=e.call(this,t,"READ",r)||this;return i.readStatus=new b(t,r),i}return(0,s.c)(t,e),t}(s.W),T=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.readAt=n.ts,r.unreadMessageCount=n.unread_message_count,r.totalUnreadCount=n.total_unread_count,r.channelUrl=n.channel_url,r.userId=n.user_id,r.isExcluded=n.is_excluded,r.uniqueId=n.unique_id,r}return(0,s.c)(t,e),t}(s.j),S=function(e){function t(t){var n=t.channelUrl,r=t.messageId;return e.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n,parent_message_id:r}})||this}return(0,s.c)(t,e),t}(s.au),A=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.pushEnabled,o=e.call(this)||this;return o.method=s.A.PUT,o.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/thread_push"),o.params={push_enabled:a},o}return(0,s.c)(t,e),t}(s.h);U=s.j,(0,s.c)(function(e,t){return U.call(this,e,t)||this},U);var M,U,N,C,k=function(e){function t(t,n){var r,i,o,u,c,l=this;return(l=e.call(this,t)||this).plainUrl="",l.fileName=null,l.mimeType=null,l.fileSize=0,l.thumbnails=[],l._requireAuth=!1,l.plainUrl=null!==(r=n.url)&&void 0!==r?r:"",l.fileName=null!==(i=n.file_name)&&void 0!==i?i:null,l.mimeType=null!==(o=n.file_type)&&void 0!==o?o:null,l.fileSize=null!==(u=n.file_size)&&void 0!==u?u:0,l._requireAuth=null!==(c=n.require_auth)&&void 0!==c&&c,l.thumbnails=n.thumbnails?n.thumbnails.map(function(e){var t;return new a(l._iid,"string"==typeof e?{url:e,width:0,height:0}:(0,s.d)((0,s.d)({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),l._requireAuth)}):[],l}return(0,s.c)(t,e),t.payloadify=function(e){var t;return(0,s.f)((0,s.g)({url:e.plainUrl,file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e.thumbnails)||void 0===t?void 0:t.map(function(e){var t;return{url:(null!==(t=e.plainUrl)&&void 0!==t?t:"").split("auth=")[0],width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}}),require_auth:e._requireAuth}))},Object.defineProperty(t.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this._requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}
1,enumerable:!1,configurable:!0}),t}(s.ap),O=function(e){var t=e.channelUrl,n=e.channelType,r=e.parentMessage;this.channelUrl=t,this.channelType=n,this.parentMessage=r};(P=N||(N={})).PENDING="pending",P.SENT="sent",P.FAILED="failed",P.CANCELED="canceled",(x=C||(C={})).PENDING="pending",x.IN_QUEUE="in_queue",x.SENT="sent",x.FAILED="failed",x.CANCELED="canceled",x.REMOVED="removed";var P,x,R,D=function(e){function t(t,n){var r,i,a,o,u,l,d,f,_,v=this;return(v=e.call(this,t,n)||this).parentMessage=null,v.silent=!1,v.isOperatorMessage=!1,v.threadInfo=null,v.reactions=[],v.appleCriticalAlertOptions=null,v.scheduledInfo=null,v.suggestedReplies=null,v.myFeedback=null,v.myFeedbackStatus="NOT_APPLICABLE",v.messageForm=null,v._isContinuousMessages=!1,v._scheduledStatus=null,v._poll=null,v.messageId=null!==(i=null!==(r=n.msg_id)&&void 0!==r?r:n.message_id)&&void 0!==i?i:0,v.parentMessageId=null!==(a="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==a?a:0,v.threadInfo=n.thread_info?new c(v._iid,n.thread_info):null,n.reactions_summary?v.reactions=n.reactions_summary.map(function(e){return new h(t,e)}):n.reactions?v.reactions=n.reactions.map(function(e){return new h(t,e)}):v.reactions=[],v.ogMetaData=n.og_tag?new p(n.og_tag):null,v.silent=null!==(o=n.silent)&&void 0!==o&&o,v.isOperatorMessage=null!==(u=n.is_op_msg)&&void 0!==u&&u,v.appleCriticalAlertOptions=n.apple_critical_alert_options?new m(n.apple_critical_alert_options):null,"number"==typeof n.scheduled_message_id&&"number"==typeof n.scheduled_at&&n.scheduled_status&&(v.scheduledInfo={scheduledMessageId:n.scheduled_message_id,scheduledAt:n.scheduled_at},v._scheduledStatus=n.scheduled_status),v._isContinuousMessages=null!==(l=n.is_continuous_messages)&&void 0!==l&&l,v.suggestedReplies=null!==(f=null===(d=n.extended_message_payload)||void 0===d?void 0:d.suggested_replies)&&void 0!==f?f:null,v.message=null!==(_=n.message)&&void 0!==_?_:"",v._poll=n.poll?new s.aw(v._iid,n.poll):null,v}return(0,s.c)(t,e),t.payloadify=function(t){var n,r;return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{message_id:t.messageId,parent_message_id:t.parentMessageId,thread_info:t.threadInfo?c.payloadify(t.threadInfo):null,reactions_summary:t.reactions.map(function(e){return h.payloadify(e)}),og_tag:t.ogMetaData?p.payloadify(t.ogMetaData):null,silent:t.silent,is_op_msg:t.isOperatorMessage,apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,scheduled_message_id:null===(n=t.scheduledInfo)||void 0===n?void 0:n.scheduledMessageId,scheduled_at:null===(r=t.scheduledInfo)||void 0===r?void 0:r.scheduledAt,scheduled_status:t._scheduledStatus,message:t.message,poll:t._poll?s.aw.payloadify(t._poll):null})))},t._getParentMessageInfoPayload=function(e){var t={type:y(e.messageType),ts:e.createdAt,user:e.sender?_.payloadify(e.sender):null,message:e.message,data:e.data,custom_type:e.customType};switch(e.messageType){case s.ar.USER:return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},t),{translations:e.translations})));case s.ar.FILE:return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},t),{file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth},files:Array.isArray(e.fileInfoList)?e.fileInfoList.map(function(e){return k.payloadify(e)}):null})));case s.ar.ADMIN:return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},t),{translations:e.translations})));default:return(0,s.f)((0,s.g)((0,s.d)({},t)))}},t.prototype.isIdentical=function(e){return this.messageId===e.messageId},t.prototype.applyThreadInfoUpdateEvent=function(e){return this.messageId===e.targetMessageId&&(e.threadInfo._isUpdateRequired&&this.threadInfo&&e.threadInfo._updateFrom(this.threadInfo),this.threadInfo=e.threadInfo,!0)},t.prototype._findReactionIndex=function(e){for(var t=0;t<this.reactions.length;t++)if(this.reactions[t].key===e)return t;return -1},t.prototype.applyReactionEvent=function(e){var t,n=s.V.of(this._iid).sdkState;if(this.messageId===e.messageId)switch(e.operation){case i.ADD:e.userId===n.userId&&(e._hasCurrentUserReacted=!0),-1!==(t=this._findReactionIndex(e.key))?this.reactions[t].applyEvent(e):e._sampledUserIds?this.reactions.push(new h(this._iid,{key:e.key,sampled_user_ids:e._sampledUserIds,sampled_user_info:e._sampledUserInfoList,count:e._count,is_self_included:e._hasCurrentUserReacted,last_ts:e.updatedAt})):this.reactions.push(new h(this._iid,{key:e.key,user_ids:[e.userId],updated_at:e.updatedAt}));break;case i.DELETE:-1!==(t=this._findReactionIndex(e.key))&&(e._sampledUserIds?0===e._count?this.reactions.splice(t,1):(e.userId===n.userId&&(e._hasCurrentUserReacted=!1),this.reactions[t].applyEvent(e)):(this.reactions[t].applyEvent(e),this.reactions[t].isEmpty&&this.reactions.splice(t,1)
1))}},t.prototype.applyParentMessage=function(e){if(!this.parentMessage)return this.parentMessage=e,!0;if(this.parentMessageId===e.messageId){var t=this.parentMessage.updatedAt;if(e.updatedAt>=t)return this.parentMessage=e,!0}return!1},t.prototype.applyPoll=function(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)},Object.defineProperty(t.prototype,"poll",{get:function(){return this._poll},enumerable:!1,configurable:!0}),t.prototype._triggerThreadInfoUpdatedEvent=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){return(e=s.V.of(this._iid).dispatcher).dispatch(new O({channelType:s.C.GROUP,channelUrl:this.channelUrl,parentMessage:this})),e.dispatch(new s.ax({messages:[this],source:s.ab.EVENT_MESSAGE_THREADINFO_UPDATED})),[2]})})},t.prototype.markThreadAsRead=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new S({channelUrl:this.channelUrl,messageId:this.messageId}),[4,e.send(t)];case 1:return n.sent(),this.threadInfo&&0!==this.threadInfo.unreadReplyCount?(this.threadInfo.unreadReplyCount=0,[4,this._triggerThreadInfoUpdatedEvent()]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},t.prototype.setPushNotificationEnabled=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new A({channelUrl:this.channelUrl,channelType:this.channelType,messageId:this.messageId,pushEnabled:e}),[4,t.send(n)];case 1:return r.sent(),this.threadInfo&&this.threadInfo.isPushNotificationEnabled!==e&&(this.threadInfo.isPushNotificationEnabled=e),[2]}})})},t.prototype.submitMessageForm=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){throw s.t.legacyChatbotFeatureNotSupported})})},t.prototype.submitFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){throw s.t.legacyChatbotFeatureNotSupported})})},t.prototype.updateFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){throw s.t.legacyChatbotFeatureNotSupported})})},t.prototype.deleteFeedback=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){throw s.t.legacyChatbotFeatureNotSupported})})},t}(g),L=function(e){function t(t,n){var r,i,a,o,u=this;if((u=e.call(this,t,n)||this).reqId="",u.replyToChannel=!1,u.errorCode=0,u.sender=n.user?new _(u._iid,n.user):n.sender_id,u.reqId=null!==(i=null!==(r=n.req_id)&&void 0!==r?r:n.request_id)&&void 0!==i?i:"",u.replyToChannel=null!==(a=n.is_reply_to_channel)&&void 0!==a&&a,n.request_state&&(0,s.a5)(s.ay,n.request_state)&&(u.sendingStatus=n.request_state),!u.sendingStatus){if(u.messageId>0)u.sendingStatus=s.ay.SUCCEEDED;else if(u.scheduledInfo)switch(n.scheduled_status&&(u._scheduledStatus=n.scheduled_status),n.scheduled_status){case C.SENT:case C.IN_QUEUE:u.sendingStatus=s.ay.SUCCEEDED;break;case C.PENDING:u.sendingStatus=s.ay.SCHEDULED;break;case C.FAILED:case C.REMOVED:u.sendingStatus=s.ay.FAILED;break;case C.CANCELED:u.sendingStatus=s.ay.CANCELED}else u.sendingStatus=s.ay.PENDING}return u.errorCode=null!==(o=n.error_code)&&void 0!==o?o:0,u._messageToken=n.mesg_token,u}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{user:_.payloadify(t.sender),req_id:t.reqId,is_reply_to_channel:t.replyToChannel,request_state:t.sendingStatus,error_code:t.errorCode,mesg_token:t._messageToken})))},Object.defineProperty(t.prototype,"isResendable",{get:function(){return(this.sendingStatus===s.ay.FAILED||this.sendingStatus===s.ay.CANCELED)&&(0,s.az)(this.errorCode)},enumerable:!1,configurable:!0}),t.prototype.isIdentical=function(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId},t}(D),F={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.aA.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},q=function(e){return(0,s.a)("number",e.prevResultSize)&&(0,s.a)("number",e.nextResultSize)&&(0,s.a)("boolean",e.isInclusive)&&(0,s.a)("boolean",e.reverse)&&(0,s.a)("string",e.messageTypeFilter)&&(0,s.a5)(s.aA,e.messageTypeFilter)&&(0,s.a2)("string",e.customTypesFilter,!0)&&(0,s.a2)("string",e.senderUserIdsFilter,!0)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeParentMessageInfo)},z=function(e){function t(t,n){var r,i,a,o=this;if((o=e.call(this,t,n)||this).translations={},o.messageType=s.ar.ADMIN,o.translations=null!==(r=n.translations)&&void 0!==r?r:{},n.parent_message_info){var u=n.parent_message_info;o.parentMessage=H(t,(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},u),{message_id:o.parentMessageId,channel_url:o.channelUrl,channel_type:o.channelType,file:u.file,url:null===(i=u.file)||void 0===i?void 0:i.url,require_auth:null===(a=u.file)||void 0===a?void 0:a.require_auth}))))}return o}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{translations:t.translations,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},F),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&q(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(D),j=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&(0,s.a)("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return(0,s.f)((0,s.g)({type:e.type,vendor:e.vend
1or,detail:e.detail}))},e}(),V=function(){function e(e){this.status=e.status,e.original_message_info&&(this.originalMessageInfo={createdAt:e.original_message_info.ts,messageId:e.original_message_info.id})}return e.payloadify=function(e){return(0,s.f)({status:e.status,original_message_info:e.originalMessageInfo?{id:e.originalMessageInfo.messageId,ts:e.originalMessageInfo.createdAt}:void 0})},e}(),B=function(e){function t(t,n){var r,i,a,o,u,c,l,d=this;if((d=e.call(this,t,n)||this).messageParams=null,d.mentionedMessageTemplate=void 0,d.translations={},d.translationTargetLanguages=[],d.messageSurvivalSeconds=-1,d.plugins=[],d.messageType=s.ar.USER,d.translations=null!==(a=n.translations)&&void 0!==a?a:{},d.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(d.translations).length&&d.translationTargetLanguages.length>0)try{for(var h=(0,s.w)(d.translationTargetLanguages),f=h.next();!f.done;f=h.next()){var p=f.value;d.translations[p]=""}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}if(d.mentionedMessageTemplate=n.mentioned_message_template,d.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,d.plugins=n.plugins?n.plugins.map(function(e){return new j(e)}):[],n.parent_message_info){var m=n.parent_message_info;d.parentMessage=H(t,(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},m),{created_at:m.ts,message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:m.file,url:null===(c=m.file)||void 0===c?void 0:c.url,require_auth:null===(l=m.file)||void 0===l?void 0:l.require_auth}))))}return n.review_info&&(d.messageReviewInfo=new V(n.review_info)),d}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{translations:t.translations,message_survival_seconds:t.messageSurvivalSeconds,mentioned_message_template:t.mentionedMessageTemplate,plugins:t.plugins.map(function(e){return j.payloadify(e)}),parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null,review_info:t.messageReviewInfo?V.payloadify(t.messageReviewInfo):void 0})))},t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},F),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&q(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(L),K=function(e){function t(t,n){var r,i,a,o,u,c,l,d,h=this;if((h=e.call(this,t,n)||this).messageParams=null,h.fileInfoList=[],h.messageSurvivalSeconds=-1,h.messageType=s.ar.FILE,h.data=null!==(a=null!==(i=null===(r=n.file)||void 0===r?void 0:r.data)&&void 0!==i?i:n.custom)&&void 0!==a?a:"",h.fileInfoList=null!==(u=null===(o=n.files)||void 0===o?void 0:o.map(function(e){return new k(t,e)}))&&void 0!==u?u:[],h.messageSurvivalSeconds=null!==(c=n.message_survival_seconds)&&void 0!==c?c:-1,n.parent_message_info){var f=n.parent_message_info;h.parentMessage=H(t,(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},f),{created_at:f.ts,message_id:h.parentMessageId,channel_url:h.channelUrl,channel_type:h.channelType,file:f.file,url:null===(l=f.file)||void 0===l?void 0:l.url,require_auth:null===(d=f.file)||void 0===d?void 0:d.require_auth}))))}return h}return(0,s.c)(t,e),t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},F),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&q(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t.payloadify=function(t){var n,r,i,a,o,u;return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{file:{name:null!==(r=null===(n=t.fileInfoList[0])||void 0===n?void 0:n.fileName)&&void 0!==r?r:"",size:null!==(a=null===(i=t.fileInfoList[0])||void 0===i?void 0:i.fileSize)&&void 0!==a?a:0,type:null!==(u=null===(o=t.fileInfoList[0])||void 0===o?void 0:o.mimeType)&&void 0!==u?u:"",data:t.data},files:Array.isArray(t.fileInfoList)?t.fileInfoList.map(function(e){return k.payloadify(e)}):null,message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},t._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},t._isMultipleFilesMessageSerializedData=function(e){return Array.isArray(e.fileInfoList)},t}(L);(et=R||(R={})).SENT="SENT",et.READ="READ";var Q=function(e){function t(t,n){var r,i,a=this;if((a=e.call(this,t,n)||this).notificationData=null,a.notificationId=n.notification_message_id,a.messageType=s.ar.ADMIN,a.messageStatus=null!==(r=n.message_status)&&void 0!==r?r:R.SENT,a.priority=null!==(i=n.priority)&&void 0!==i?i:s.aB.NORMAL,a.notificationEventDeadline=n.notification_event_deadline,0===a.extendedMessage.sub_type)try{var o=JSON.parse(a.extendedMessage.sub_data),u=o.label,c=o.tags,l=o.template_key,d=o.template_variables;a.notificationData={label:u,tags:void 0===c?[]:c,templateKey:l,templateVariables:d}}catch(e){}return a}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{notification_message_id:t.notificationId,message_status:t.messageStatus,priority:t.priority,notification_event_deadline:t.notificationEventDeadline})))},t.prototype.isIdentical=function(e){return this.notificationId===e.notificationId},t}(g),G=function(e){if(e.notificationId)return Q.payloadify(e);switch(e.messageType){case s.ar.USER:return B.payloadify(e);case s.ar.FILE:return e.fileInfoList?K.payloadify(e):W.payloadify(e);case s.ar.ADMIN:return z.payloadify(e);default:throw s.t.unknown}},H=function(e,t){if(t.notification_message_id)return new Q(e,t);switch(t.type){case"MESG":return new B(e,t);case"FILE":return K._isMultipleFilesMessagePayload(t)?new K(e,t):new W(e,t);case"ADMM":case"BRDM":return new z(e,t);default:return null}},W=function(e){function t(t,n){var r,i,o,u,c,l,d,h,f,p,m,_,v,y,g,b=this;(b=e.call(this,t,n)||this).messageParams=null,b.plainUrl="",b.requireAuth=!1,b.thumbnails=[],b.messageSurvivalSeconds=-1,b.messageType=s.ar.FILE;var I=n.file;if(b.plainUrl=(null!==(i=null!==(r=null==I?void 0:I.url)&&void 0!==r?r:n.url)&&void 0!==i?i:"").split("?auth=")[0],b.name=null!==(u=null!==(o=null==I?void 0:I.name)&&void 0!==o?o:n.name)&&void 0!==u?u:"File",b.size=null!==(l=null!==(c=null==I?void 0:I.size)&&void 0!==c?c:n.size)&&void 0!==l?l:0,b.data=null!==(f=null!==(h=null!==(d=null==I?void 0:I.data)&&void 0!==d?d:n.custom)&&void 0!==h?h:b.data)&&void 0!==f?f:"",b.type=I?null!==(p=I.type)&&void 0!==p?p:"":null!==(m=n.type)&&void 0!==m?m:"",b.requireAuth=null!==(_=n.require_auth)&&void 0!==_&&_,b.thumbnails=n.thumbnails?n.thumbnails.map(function(e){var t;return new a(b._iid,"string"==typeof e?{url:e,width:0,height:0}:(0,s.d)((0,s.d)({},e),{url:(null!==(t=e.url)&&void 0!==t?t:"").split("auth=")[0]}),b.requireAuth)}):[],b.messageSurvivalSeconds=null!==(v=n.message_survival_seconds)&&void 0!==v?v:-1,n.parent_message_info){var E=n.parent_message_info;b.parentMessage=H(t,(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},E),{created_at:E.ts,message_id:b.parentMessageId,channel_url:b.channelUrl,channel_type:b.channelType,file:E.file,url:null===(y=E.file)||void 0===y?void 0:y.url,require_auth:null===(g=E.file)||void 0===g?void 0:g.require_auth}))))}return b}return(0,s.c)(t,e),t.payloadify=function(t){var n;return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{url:t.plainUrl,require_auth:t.requireAuth,file:{name:t.name,size:t.size,type:t.type,data:t.data},thumbnails:null===(n=t.thumbnails)||void 0===n?void 0:n.map(function(e){return{url:e.plainUrl,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}}),message_survival_seconds:t.messageSurvivalSeconds,parent_message_info:t.parentMessage?e._getParentMessageInfoPayload.call(this,t.parentMessage):null})))},Object.defineProperty(t.prototype,"url",{get:function(){var e=s.V.of(this._iid).sessionManager;return this.requireAuth&&e.ekey?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}
1,enumerable:!1,configurable:!0}),t.prototype.getThreadedMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},F),t),(0,s.F)(this.messageId>0&&(0,s.a)("number",e)&&q(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,r.sent()]}})})},t}(L),Y=function(e){function t(t,n){var r=n.file,i=n.fileUrl,s=n.fileName,a=n.fileSize,o=n.mimeType,u=n.thumbnailSizes,c=n._uploadedMetaData,l=n._thumbnails,d=e.call(this,t)||this;return d._plainUrl=i,d.file=r,d.fileName=s,d.fileSize=a,d.mimeType=o,d.thumbnailSizes=u,d._uploadedMetaData=c,d._thumbnails=l,d}return(0,s.c)(t,e),t.getPlainUrl=function(e){return e instanceof t?e._plainUrl:e.fileUrl},Object.defineProperty(t.prototype,"fileUrl",{get:function(){var e,t=s.V.of(this._iid).sessionManager;return this._plainUrl&&(null===(e=this._uploadedMetaData)||void 0===e?void 0:e.requireAuth)&&t.ekey?"".concat(this._plainUrl,"?auth=").concat(t.ekey):this._plainUrl},set:function(e){this._plainUrl=e},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return{file:this.file,fileUrl:this._plainUrl,fileName:this.fileName,fileSize:this.fileSize,mimeType:this.mimeType,thumbnailSizes:this.thumbnailSizes,_thumbnails:this._thumbnails,_uploadedMetaData:this._uploadedMetaData}},t}(s.ap),J=function(e){function t(t){var n,r,i,o,u=[];return t.mentionType===s.at.USERS&&(t.mentionedUserIds?u=t.mentionedUserIds:t.mentionedUsers&&(u=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"FILE",ackRequired:!0,payload:(0,s.f)((0,s.g)({channel_url:t.channelUrl,files:t.files?ee(t.files):null,url:t.url,name:null!==(n=t.fileName)&&void 0!==n?n:"",type:null!==(r=t.mimeType)&&void 0!==r?r:"",size:null!==(i=t.fileSize)&&void 0!==i?i:0,custom:t.data,custom_type:t.customType,thumbnails:null===(o=t._thumbnails)||void 0===o?void 0:o.map(function(e){return a.payloadify(e)}),require_auth:t.requireAuth,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:u,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==s.aC.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,message:t.message}))})||this}return(0,s.c)(t,e),t}(s.au),X=function(e){function t(t){var n,r,i=this;i=e.call(this)||this;var o=[];return t.mentionType===s.at.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map(function(e){return e.userId}))),i.method=s.A.POST,i.path="".concat((0,s.av)(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),i.params=(0,s.f)((0,s.g)({message_type:s.ar.FILE,user_id:t.userId,files:t.files?ee(t.files):null,url:t.fileUrl,mention_type:t.mentionType,mentioned_user_ids:o,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,data:t.data,custom_type:t.customType,thumbnails:null===(n=t._thumbnails)||void 0===n?void 0:n.map(function(e){return a.payloadify(e)}),require_auth:t.requireAuth,sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return v.payloadify(e)}),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage})),i}return(0,s.c)(t,e),t}(s.h),Z=function(e){function t(t,n,r){var i,a,o,u,c=this;(c=e.call(this,t,"FILE",r)||this).message=r.files&&r.files.length>=2?new K(t,r):new W(t,r);var l=s.V.of(t).sdkState;return c.isMentioned=(0,s.aD)(c.message.mentionType,null!==(o=null!==(i=c.message.mentionedUserIds)&&void 0!==i?i:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}
1))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=r.force_update_last_message)&&void 0!==u&&u,c}return(0,s.c)(t,e),t}(s.W),$=function(e){function t(t,n){var r,i,a,o,u=this;(u=e.call(this,t,n)||this).message=n.files&&n.files.length>=2?new K(t,n):new W(t,n);var c=s.V.of(t).sdkState;return u.isMentioned=(0,s.aD)(u.message.mentionType,null!==(a=null!==(r=u.message.mentionedUserIds)&&void 0!==r?r:null===(i=u.message.mentionedUsers)||void 0===i?void 0:i.map(function(e){return e.userId}))&&void 0!==a?a:[],c.userId),u.forceUpdateLastMessage=null!==(o=n.force_update_last_message)&&void 0!==o&&o,u}return(0,s.c)(t,e),t}(s.j);function ee(e){return e.map(function(e){var t,n;return(0,s.f)((0,s.g)({url:Y.getPlainUrl(e),file_name:e.fileName,file_type:e.mimeType,file_size:e.fileSize,thumbnails:null===(t=e._thumbnails)||void 0===t?void 0:t.map(function(e){return a.payloadify(e)}),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))})}(en=er||(er={}))[en.PENDING=0]="PENDING",en[en.UPLOADING=1]="UPLOADING",en[en.UPLOADED=2]="UPLOADED",en[en.SENDING=3]="SENDING",en[en.FAILED=4]="FAILED";var et,en,er,ei,es,ea=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,a=t.onlineDetector,o=t.cacheContext,u=this;this._queueMap=new Map,this._iid=e,this._sdkState=n,this._requestQueue=i,this._cacheContext=o,this._dispatcher=r,this._dispatcher.on(function(e){e instanceof s.K&&(u._connectionState=e.stateType)}),this._onlineDetector=a}return Object.defineProperty(e.prototype,"_shouldSendThroughWebSocket",{get:function(){return this._connectionState===s.M.CONNECTED||this._connectionState===s.M.CONNECTING||this._connectionState===s.M.RECONNECTING},enumerable:!1,configurable:!0}),e.prototype._sendFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return n=this._createSendFileMessageRequestParam
1s(e,t),this._shouldSendThroughWebSocket?(r=new J(n),[4,this._requestQueue.send(r)]):[3,2];case 1:return[2,i.sent().as(Z).message];case 2:return r=new X((0,s.d)((0,s.d)({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(r)];case 3:return[2,i.sent().as($).message]}})})},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=(0,s.d)((0,s.d)({},t.params),{channelUrl:e.url,channelType:e.channelType,reqId:t.requestId,url:""});if(t.multipleFileUploadInfo){var r=t.params;n.files=r.fileInfoList}else r=t.params,n.url=r.fileUrl,n.requireAuth=r.requireAuth;return n},e.prototype._resolveMessageQueue=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h,f,p;return(0,s.b)(this,function(m){switch(m.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,r=[],i=!0,m.label=1;case 1:m.trys.push([1,15,16,17]),o=(a=(0,s.w)(n.messageQueue)).next(),m.label=2;case 2:if(o.done)return[3,14];switch((u=o.value).state){case er.PENDING:case er.UPLOADING:return[3,3];case er.UPLOADED:return[3,4];case er.FAILED:return[3,12]}return[3,13];case 3:return i=!1,r.push(u),[3,13];case 4:if(!i)return[3,10];m.label=5;case 5:return m.trys.push([5,8,,9]),u.state=er.SENDING,[4,this._sendFileMessage(e,u)];case 6:return c=m.sent(),u.deferred.resolve(c),[4,(0,s.aF)(100)];case 7:return m.sent(),[3,9];case 8:return l=m.sent(),u.deferred.reject(l),[3,9];case 9:return[3,11];case 10:r.push(u),m.label=11;case 11:return[3,13];case 12:return d=null!==(t=u.error)&&void 0!==t?t:s.t.unknown,u.deferred.reject(d.code===s.D.REQUEST_CANCELED?s.t.fileUploadCanceled:d),[3,13];case 13:return o=a.next(),[3,2];case 14:return[3,17];case 15:return f={error:m.sent()},[3,17];case 16:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(f)throw f.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=r,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:m.sent(),m.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,m.label=21;case 21:return[2]}})})},e.prototype._uploadNextPendingItem=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h;return(0,s.b)(this,function(f){switch(f.label){case 0:return(n=this._queueMap.get(e.url))&&(r=n.messageQueue.find(function(e){return e.state===er.PENDING}))?r.multipleFileUploadInfo?(a=(i=r.multipleFileUploadInfo).uploadIndex,o=i.uploadCount,u=i.requestHandler,c=(h=r.params).fileInfoList[a],!(0,s.i)(c.file)||(null===(t=c._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?[3,2]:[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]):[3,4]:[3,9];case 1:return f.sent(),[3,3];case 2:r.state=a<o-1?er.PENDING:er.UPLOADED,f.label=3;case 3:return l=h.fileInfoList[a],d=r.multipleFileUploadInfo.uploadIndex++,r.multipleFileUploadInfo.isCopy||null==u||u._triggerOnFileUploaded(r.requestId,d,l,r.error),[3,7];case 4:return h=r.params,(0,s.i)(h.file)?[4,this._tryUploadNextItemAndUpdateItemState(e,n,r)]:[3,6];case 5:return f.sent(),[3,7];case 6:h.thumbnailSizes=[],r.state=er.UPLOADED,f.label=7;case 7:return this._uploadNextPendingItem(e),[4,this._resolveMessageQueue(e)];case 8:f.sent(),f.label=9;case 9:return[2]}})})},e.prototype._tryUploadNextItemAndUpdateItemState=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return[4,this._onlineDetector.isOnline()];case 1:if(r=l.sent(),!s.V.of(this._iid).sessionManager.currentUser||!r)return n.error=s.t.connectionRequired,n.state=er.FAILED,[2];if(!(t.uploadQueue.length<6))return[3,9];n.state=er.UPLOADING,t.uploadQueue.push(n),l.label=2;case 2:return l.trys.push([2,7,,8]),n.multipleFileUploadInfo?(a=(i=n.multipleFileUploadInfo).uploadIndex,o=i.uploadCount,u=n.params,[4,this._uploadNextFileForMultipleFilesItemAndUpdateParams(e,n,u)]):[3,4];case 3:return l.sent(),n.state=a<o-1?er.PENDING:er.UPLOADED,[3,6];case 4:return u=n.params,[4,this._uploadNextFileForSingleFileItemAndUpdateParams(e,n,u)];case 5:l.sent(),n.state=er.UPLOADED,l.label=6;case 6:return[3,8];case 7:switch((c=l.sent()).code){case s.D.REQUEST_FAILED:n.error=new s.t({code:s.D.NETWORK_E
1RROR,message:"Failed to upload a file."});break;case s.D.REQUEST_CANCELED:n.error=s.t.fileUploadCanceled;break;default:n.error=c}return n.state=er.FAILED,[3,8];case 8:this._dequeueUploadItem(t,n),l.label=9;case 9:return[2]}})})},e.prototype._dequeueUploadItem=function(e,t){var n=e.uploadQueue.findIndex(function(e){return e.requestId===t.requestId});n>=0&&e.uploadQueue.splice(n,1)},e.prototype._uploadNextFileForSingleFileItemAndUpdateParams=function(e,t,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var c,l,d,h,f,p,m,_,v;return(0,s.b)(this,function(s){switch(s.label){case 0:return c=new o({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(c)];case 1:return d=(l=s.sent().as(u)).url,f=void 0===(h=l.fileSize)?n.fileSize:h,m=void 0===(p=l.thumbnails)?[]:p,v=void 0!==(_=l.requireAuth)&&_,n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(i=n.mimeType)&&void 0!==i?i:n.file.type,n.fileSize=null!==(a=n.fileSize)&&void 0!==a?a:n.file.size,n.fileUrl=d,n.fileSize=f,n.requireAuth=v,n._thumbnails=m,[2]}})})},e.prototype._uploadNextFileForMultipleFilesItemAndUpdateParams=function(e,t,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var c,l,d,h,f,p,m,_,v,y;return(0,s.b)(this,function(g){switch(g.label){case 0:return c=t.multipleFileUploadInfo.uploadIndex,d=new o({file:(l=n.fileInfoList[c]).file,channelUrl:e.url,thumbnailSizes:l.thumbnailSizes,requestId:t.requestId}),[4,this._requestQueue.send(d)];case 1:return f=(h=g.sent().as(u)).url,m=void 0===(p=h.fileSize)?l.fileSize:p,_=h.thumbnails,y=void 0!==(v=h.requireAuth)&&v,l.fileName=null!==(r=l.fileName)&&void 0!==r?r:l.file.name,l.mimeType=null!==(i=l.mimeType)&&void 0!==i?i:l.file.type,l.fileSize=null!==(a=l.fileSize)&&void 0!==a?a:l.file.size,l.file=void 0,l.fileUrl=f,l.fileSize=m,l._thumbnails=_,l._uploadedMetaData=(0,s.d)((0,s.d)({},l._uploadedMetaData),{requireAuth:y,isUploaded:!0}),l instanceof Y||(n.fileInfoList[c]=new Y(this._iid,l)),[2]}})})},e.prototype.request=function(e,t,n,r){return void 0===r&&(r={}),(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c;return(0,s.b)(this,function(l){return this._queueMap.has(e.url)||(i={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1},this._queueMap.set(e.url,i)),a=this._queueMap.get(e.url),o=new s.aG,u={requestId:t,params:n,state:er.PENDING,deferred:o},"fileInfoList"in n&&(c=(0,s.d)({uploadIndex:0,uploadCount:n.fileInfoList.length},r),u.multipleFileUploadInfo=c),a.messageQueue.push(u),this._uploadNextPendingItem(e),[2,o.promise]})})},e.prototype.cancel=function(e,t){var n,r,i=this._queueMap.get(e.url);if(i){var a=t?[i.messageQueue.find(function(e){return e.requestId===t})]:(0,s.q)([],(0,s.r)(i.messageQueue),!1);try{for(var o=(0,s.w)(a),u=o.next();!u.done;u=o.next()){var c=u.value;if(c)switch(c.state){case er.PENDING:if(c.state=er.FAILED,c.error=s.t.requestCanceled,c.multipleFileUploadInfo&&!c.multipleFileUploadInfo.isCopy){var l=c.multipleFileUploadInfo,d=l.uploadIndex,h=l.requestHandler,f=c.params.fileInfoList[d];null==h||h._triggerOnFileUploaded(c.requestId,d,f,s.t.fileUploadCanceled)}this._resolveMessageQueue(e);break;case er.UPLOADING:this._requestQueue.cancel(c.requestId),this._dispatcher.dispatch(new s.aE({requestId:c.requestId}))}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else t&&(this._requestQueue.cancel(t),this._dispatcher.dispatch(new s.aE({requestId:t})))},e}(),eo={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.aA.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:s.aH.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},eu=function(e){return(0,s.a)("number",e.prevResultSize)&&(0,s.a)("number",e.nextResultSize)&&(0,s.a)("boolean",e.isInclusive)&&(0,s.a)("boolean",e.reverse)&&(0,s.a)("string",e.messageTypeFilter)&&(0,s.a5)(s.aA,e.messageTypeFilter)&&(0,s.a2)("string",e.customTypesFilter,!0)&&(0,s.a2)("string",e.senderUserIdsFilter,!0)&&(0,s.a5)(s.aH,e.replyType)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeParentMessageInfo)&&(0,s.a)("boolean",e.includeThreadInfo)&&(0,s.a)("boolean",e.showSubchannelMessagesOnly)},ec={replyType:s.aH.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},el=function(e){return(0,s.a5)(s.aH,e.replyType)&&(0,s.a)("boolean",e.includeReactions)&&(0,s.a)("boolean",e.includeMetaArray)&&(0,s.a)("boolean",e.includeParentMessageInfo)&&(0,s.a)("boolean",e.includeThreadInfo)};(ei||(ei={})).MESSAGE="message",(ed=es||(es={})).INTERNAL_BACKSYNC="internal_backsync",ed.INTERNAL_FILL_GAP="internal_fill_gap",ed.EXTERNAL_LEGACY="external_legacy",ed.EXTERNAL_COLLECTION="external_collection";var ed,eh,ef=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.includeMetaArray,o=t.includeReactions,u=t.includeThreadInfo,c=t.includeParentMessageInfo,l=e.call(this)||this;return l.method=s.A.GET,l.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i)),l.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions_summary:null!=o&&o,include_thread_info:u,include_parent_message_info:c,include_poll_details:!0},l}return(0,s.c)(t,e),t}(s.h),ep=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?H(t,(0,s.d)({},n)):null,r}return(0,s.c)(t,e),t}(s.j),em=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,a=t.token,o=t.prevResultSize,u=t.nextResultSize,c=t.isInclusive,l=t.reverse,d=t.messageTypeFilter,h=t.customTypesFilter,f=t.senderUserIdsFilter,p=t.replyType,m=t.includeMetaArray,_=t.includeReactions,v=t.parentMessageId,y=t.includeThreadInfo,g=t.includeParentMessageInfo,b=t.showSubchannelMessagesOnly,I=t.checkingHasNext,E=t.checkingContinuousMessages,w=t.sdkSource,T=e.call(this)||this;return T.method=s.A.GET,T.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages"),T.params=(0,s.f)((0,s.g)({is_sdk:!0,prev_limit:o,next_limit:u,include:c,reverse:l,message_ts:i,message_id:a,message_type:null!=d?d:null,custom_types:h,sender_ids:f,include_reply_type:p,with_sorted_meta_array:m,include_reactions_summary:_,parent_message_id:v,include_thread_info:y,include_parent_message_info:g,show_subchannel_message_only:b,include_poll_details:!0,checking_has_next:I,checking_continuous_messages:E,sdk_source:w})),T}return(0,s.c)(t,e),t}(s.h),e_=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0!==n.is_continuous_messages&&(r.isContinuousMessages=n.is_continuous_messages),void 0!==n.has_next&&(r.hasNext=n.has_next),r.messages=n.messages.map(function(e){return H(t,e)}),r}return(0,s.c)(t,e),t}(s.j),ev=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.timestamp,a=t.token,o=t.replyType,u=t.includeMetaArray,c=t.includeReactions,l=t.includeThreadInfo,d=t.includeParentMessageInfo,h=e.call(this)||this;return h.method=s.A.GET,h.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/changelogs"),h.params={change_ts:i,token:a,with_sorted_meta_array:u,include_reactions_summary:c,include_thread_info:l,include_reply_type:o,include_parent_message_info:d,include_poll_details:!0},h}return(0,s.c)(t,e),t}(s.h),ey=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.updatedMessages=n.updated.map(function(e){return H(t,e)}),r.deletedMessagesInfo=n.deleted.map(function(e){return{messageId:e.message_id,deletedAt:e.deleted_at}}),r.hasMore=n.has_more,r.nextToken=n.next,r.forceUseNextToken=n.force_use_next_token||!1,r}return(0,s.c)(t,e),t}(s.j),eg=function(e){function t(t){var n=t.channelUrl,r=t.scheduledMessageId,i=e.call(this)||this;return i.method=s.A.GET,i.path="".concat(s.aI,"/").concat(encodeURIComponent(n),"/scheduled_messages/").concat(encodeURIComponent(r)),i.params={},i}return(0,s.c)(t,e),t}(s.h),eb=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=n?H(t,(0,s.d)({},n)):null,r}return(0,s.c)(t,e),t}(s.j);(eC=eh||(eh={})).MUTED="muted",eC.BANNED="banned";var eI=function(){function e(e){var t,n,r,i;this.restrictionType=null,(0,s.a5)(eh,e.restriction_type)&&(this.restrictionType=e.restriction_type),this.description=null!==(t=e.description)&&void 0!==t?t:null,this.endAt=null!==(r=null!==(n=e.end_at)&&void 0!==n?n:e.muted_end_at)&&void 0!==r?r:-1,this.remainingDuration=null!==(i=e.remaining_duration)&&void 0!==i?i:-1}return e.payloadify=function(e){return(0,s.f)((0,s.g)({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),eE=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=new eI(n),r}return(0,s.c)(t,e),t.payloadify=function(t){return(0,s.f)((0,s.g)((0,s.d)((0,s.d)({},e.payloadify.call(this,t)),eI.payloadify(t.restrictionInfo))))},t}(s.U),ew=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).isMuted=!1,i.isMuted=null!==(r=n.is_muted)&&void 0!==r&&r,i}return(0,s.c)(t,e),t}(s.U),eT=function(){function e(){this._onPending=s.aJ,this._onFailed=s.aJ,this._onSucceeded=s.aJ}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case s.ay.PENDING:0===e.errorCode&&this._onPending(e);break;case s.ay.SCHEDULED:case s.ay.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case s.ay.FAILED:case s.ay.CANCELED:this._onFailed(e,t.scheduledInfo?null:t)}},e.prototype.onPending=function(e){return this._onPending=e,this},e.prototype.onFailed=function(e){return this._onFailed=e,this},e.prototype.onSucceeded=function(e){return this._onSucceeded=e,this},e}(),eS={data:void 0,customType:void 0,mentionType:s.at.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1,pollId:void 0},eA=function(e){return(0,s.a)("string",e.data,!0)&&(0,s.a)("string",e.customType,!0)&&(0,s.a5)(s.at,e.mentionType)&&(0,s.a2)("string",e.mentionedUserIds,!0)&&(0,s.a2)(s.U,e.mentionedUsers,!0)&&(0,s.a2)(v,e.metaArrays,!0)&&(0,s.a)("number",e.parentMessageId,!0)&&(0,s.a)("boolean",e.isReplyToChannel)&&(0,s.a5)(s.aC,e.pushNotificationDeliveryOption,!0)&&(0,s.a)(m,e.appleCriticalAlertOptions,!0)&&(0,s.a)("boolean",e.isPinnedMessage,!0)&&(0,s.a)("number",e.pollId,!0)},eM=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},eU=(0,s.d)((0,s.d)({},eS),{message:"",mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,extendedMessagePayload:void 0});function eN(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.g)((0,s.d)((0,s.d)({},e),{mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),mentionedMessageTemplate:e.mentionedMessageTemplate,translationTargetLanguages:Object.keys(e.translations),pushNotificationDeliveryOption:s.aC.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}))}var eC,ek,eO=function(e){var t;return(0,s.f)((0,s.g)({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,mentionedMessageTemplate:e.mentionedMessageTemplate,metaArrays:e.metaArrays,pollId:null===(t=e.poll)||void 0===t?void 0:t.id,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,message:e.message,translationTargetLanguages:Object.keys(e.translations),extendedMessagePayload:e.extendedMessagePayload}))},eP=function(e){return eA(e)&&(0,s.a)("string",e.message)&&(0,s.a)("string",e.mentionedMessageTemplate,!0)&&(0,s.a2)("string",e.translationTargetLanguages,!0)&&(0,s.a)("object",e.extendedMessagePayload,!0)};(eq=ek||(ek={})).FILE="file",eq.BLOB="blob",eq.BLOB_LIKE_OBJECT="blobLikeObject",eq.URL="url";var ex=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},eR=function(e){return e===ek.BLOB||e===ek.FILE},eD=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},eL=(0,s.d)((0,s.d)({},eS),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1,message:void 0});function eF(e){var t,n,r,i;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.g)((0,s.d)((0,s.d)({},e),{fileUrl:e.plainUrl,fileName:e.name,fileSize:e.size,mimeType:e.type,mentionType:e.mentionType,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aC.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(i=e.thumbnails)||void 0===i?void 0:i.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),requireAuth:e.requireAuth,isPinnedMessage:!1,_thumbnails:e.thumbnails,message:e.message}))}var eq,ez,ej=function(e,t){var n,r;return e.messageParams?(!e.url&&(0,s.i)(t)&&(e.messageParams.file=t),e.messageParams):(0,s.f)((0,s.g)({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),message:e.message,pollId:null===(r=e.poll)||void 0===r?void 0:r.id}))},eV=function(e){return eA(e)&&((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(0,s.a)("string",e.message,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every(function(e){return(0,s.a)("object",e)&&e.maxWidth>0&&e.maxHeight>0}))},eB={data:void 0,customType:void 0,mentionType:s.at.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},eK=function(e){return(0,s.a)("string",e.data,!0)&&(0,s.a)("string",e.customType,!0)&&(0,s.a5)(s.at,e.mentionType)&&(0,s.a2)("string",e.mentionedUserIds,!0)&&(0,s.a2)(s.U,e.mentionedUsers,!0)&&(0,s.a2)(v,e.metaArrays,!0)&&(0,s.a5)(s.aC,e.pushNotificationDeliveryOption,!0)&&(0,s.a)(m,e.appleCriticalAlertOptions,!0)},eQ=(0,s.d)((0,s.d)({},eB),{message:void 0,mentionedMessageTemplate:void 0,translationTargetLanguages:void 0,pollId:void 0}),eG=function(e){return eK(e)&&(0,s.a)("string",e.mentionedMessageTemplate,!0)&&(0,s.a)("string",e.message,!0)&&(0,s.a2)("string",e.translationTargetLanguages,!0)&&(0,s.a)("number",e.pollId,!0)},eH=(0,s.d)({},eB),eW=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat((0,s.av)(r),"/").concat(encodeURIComponent(n),"/operators"),o.params={token:i,limit:a},o}return(0,s.c)(t,e),t}(s.h),eY=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map(function(e){return new s.U(t,e)}),r.token=n.next,r}return(0,s.c)(t,e),t}(s.j),eJ=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=s.V.of(this._iid).requestQueue,n=new eW((0,s.d)((0,s.d)({},this),{channelUrl:this.channelUrl,token:this._token})),[4,t.send(n)]):[3,2]):[3,5];case 1:return i=(r=o.sent().as(eY)).operators,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,e];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK),eX=function(e){function t(t,n,r,i){var a,o,u,c,l,d,h,f,p,m,_=this;return(_=e.call(this,t,n,r,i)||this).reverse=!1,_.messageTypeFilter=s.aA.ALL,_.customTypesFilter=null,_.senderUserIdsFilter=null,_.replyType=s.aH.NONE,_.includeMetaArray=!1,_.includeReactions=!1,_.includeParentMessageInfo=!1,_.includeThreadInfo=!1,_.showSubchannelMessagesOnly=!1,_._edge=Number.MAX_SAFE_INTEGER,_.reverse=null!==(a=i.reverse)&&void 0!==a&&a,_.messageTypeFilter=null!==(o=i.messageTypeFilter)&&void 0!==o?o:s.aA.ALL,_.customTypesFilter=null!==(u=i.customTypesFilter)&&void 0!==u?u:null,_.senderUserIdsFilter=null!==(c=i.senderUserIdsFilter)&&void 0!==c?c:null,_.replyType=null!==(l=i.replyType)&&void 0!==l?l:s.aH.NONE,_.includeMetaArray=null!==(d=i.includeMetaArray)&&void 0!==d&&d,_.includeReactions=null!==(h=i.includeReactions)&&void 0!==h&&h,_.includeParentMessageInfo=null!==(f=i.includeParentMessageInfo)&&void 0!==f&&f,_.includeThreadInfo=null!==(p=i.includeThreadInfo)&&void 0!==p&&p,_.showSubchannelMessagesOnly=null!==(m=i.showSubchannelMessagesOnly)&&void 0!==m&&m,_}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("boolean",this.reverse)&&(0,s.a5)(s.aA,this.messageTypeFilter)&&(0,s.a5)(s.aH,this.replyType)&&(0,s.a2)("string",this.customTypesFilter,!0)&&(0,s.a2)("string",this.senderUserIdsFilter,!0)&&(0,s.a)("boolean",this.includeMetaArray)&&(0,s.a)("boolean",this.includeReactions)&&(0,s.a)("boolean",this.includeParentMessageInfo)&&(0,s.a)("boolean",this.includeThreadInfo)&&(0,s.a)("boolean",this.showSubchannelMessagesOnly)},t.prototype.load=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,ib.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,(0,s.g)({prevResultSize:this.limit,nextResultSize:0,isInclusive:!1,reverse:this.reverse,messageTypeFilter:this.messageTypeFilter,customTypesFilter:this.customTypesFilter,replyType:this.replyType,senderUserIdsFilter:this.senderUserIdsFilter,includeReactions:this.includeReactions,includeMetaArray:this.includeMetaArray,includeParentMessageInfo:this.includeParentMessageInfo,includeThreadInfo:this.includeThreadInfo,showSubchannelMessagesOnly:this.showSubchannelMessagesOnly}))]):[3,2]:[3,5];case 1:return e=t.sent(),this._edge=Math.min.apply(Math,(0,s.q)([Number.MAX_SAFE_INTEGER],(0,s.r)(e.map(function(e){return e.createdAt})),!1)),this._hasNext=e.length>=this.limit,this._isLoading=!1,[2,e];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK),eZ=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:o},n}return(0,s.c)(t,e),t}(s.h),e$=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.mutedUsers=[];var i=n.next,s=n.muted_list;return r.token=i,s&&s.length>0&&(r.mutedUsers=s.map(function(e){return new eE(t,e)})),r}return(0,s.c)(t,e),t}(s.j),e0=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new eZ((0,s.d)((0,s.d)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=a.sent().as(e$)).mutedUsers,i=n.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK),e1=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,o=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=(0,s.f)({limit:a,token:o}),n}return(0,s.c)(t,e),t}(s.h),e2=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.bannedUsers=[];var i=n.next,s=n.banned_list;return r.token=i,s&&s.length>0&&(r.bannedUsers=s.map(function(e){return new eE(t,e.user)})),r}return(0,s.c)(t,e),t}(s.j),e3=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new e1((0,s.d)((0,s.d)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=a.sent().as(e2)).bannedUsers,i=n.token,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK);(nb=ez||(ez={})).SPAM="spam",nb.HARASSING="harassing",nb.SUSPICIOUS="suspicious",nb.INAPPROPRIATE="inappropriate";var e4=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return(0,s.c)(t,e),t}(s.h);nI=s.j,(0,s.c)(function(){return null!==nI&&nI.apply(this,arguments)||this},nI);var e5=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return(0,s.c)(t,e),t}(s.h);nE=s.j,(0,s.c)(function(e,t){return nE.call(this,e,t)||this},nE);var e6=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return(0,s.c)(t,e),t}(s.h),e7=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,s=n.start_at,a=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=s,r.endAt=a,r.remainingDuration=o,r.description=u,r}return(0,s.c)(t,e),t}(s.j),e8=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return(0,s.c)(t,e),t}(s.h),e9=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return(0,s.c)(t,e),t}(s.j),te=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return(0,s.c)(t,e),t}(s.h),tt=function(e){function t(t,n){var r,i,s=this;return(s=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},s.ts=null!==(i=n.ts)&&void 0!==i?i:null,s}return(0,s.c)(t,e),t}(s.j),tn=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,o=t.upsert;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=o&&o},n}return(0,s.c)(t,e),t}(s.h),tr=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,s=n.ts;return r.metadata=i,r.ts=s,r}return(0,s.c)(t,e),t}(s.j),ti=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return(0,s.c)(t,e),t}(s.W),ts=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return(0,s.c)(t,e),t}(s.h),ta=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return(0,s.c)(t,e),t}(s.j),to=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return(0,s.c)(t,e),t}(s.h),tu=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return(0,s.c)(t,e),t}(s.j),tc=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return(0,s.c)(t,e),t}(s.h),tl=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.j),td=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return(0,s.c)(t,e),t}(s.h),th=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.j),tf=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,o=t.upsert,u=t.mode;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:void 0!==o&&o,mode:void 0===u?"set":u},n}return(0,s.c)(t,e),t}(s.h),tp=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return(0,s.c)(t,e),t}(s.j),tm=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return(0,s.c)(t,e),t}(s.W),t_=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return(0,s.c)(t,e),t}(s.h);nw=s.j,(0,s.c)(function(e,t){return nw.call(this,e,t)||this},nw);var tv=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return(0,s.c)(t,e),t}(s.h);nT=s.j,(0,s.c)(function(){return null!==nT&&nT.apply(this,arguments)||this},nT);var ty=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:o,description:u},n}return(0,s.c)(t,e),t}(s.h);nS=s.j,(0,s.c)(function(e,t){return nS.call(this,e,t)||this},nS);var tg=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new eE(t,r.data),i}return(0,s.c)(t,e),t}(s.W),tb=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return(0,s.c)(t,e),t}(s.h);nA=s.j,(0,s.c)(function(){return null!==nA&&nA.apply(this,arguments)||this},nA);var tI=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new eE(t,r.data),i}return(0,s.c)(t,e),t}(s.W),tE=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,o=t.seconds,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=(0,s.f)({user_id:a,seconds:o,description:u}),n}return(0,s.c)(t,e),t}(s.h);nM=s.j,(0,s.c)(function(){return null!==nM&&nM.apply(this,arguments)||this},nM);var tw=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new eE(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return(0,s.c)(t,e),t}(s.W),tT=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=s.A.DELETE,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return(0,s.c)(t,e),t}(s.h);nU=s.j,(0,s.c)(function(){return null!==nU&&nU.apply(this,arguments)||this},nU);var tS=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new eE(t,r.data),i}return(0,s.c)(t,e),t}(s.W),tA=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=s.A.PUT,n.path="".concat((0,s.av)(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return(0,s.c)(t,e),t}(s.h);nN=s.j,(0,s.c)(function(){return null!==nN&&nN.apply(this,arguments)||this},nN);var tM=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return(0,s.c)(t,e),t}(s.W),tU=function(e){return e instanceof s.ah?e._custom?"custom"
1:e.name:e},tN=function(e){if(e instanceof s.ah&&e._custom)return e.name},tC=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aL)(i),"/").concat(encodeURIComponent(r)),n.params=(0,s.f)({report_category:tU(a),reporting_user_id:o,report_description:u,custom_report_category_name:tN(a)}),n}return(0,s.c)(t,e),t}(s.h),tk=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat(s.aM,"/users/").concat(u),n.params=(0,s.f)({channel_url:r,channel_type:i===s.C.OPEN?"open_channels":"group_channels",report_category:tU(a),reporting_user_id:o,report_description:c,custom_report_category_name:tN(a)}),n}return(0,s.c)(t,e),t}(s.h),tO=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,o=t.userId,u=t.offendingUserId,c=t.messageId,l=t.description;return(n=e.call(this)||this).method=s.A.POST,n.path="".concat((0,s.aL)(i),"/").concat(encodeURIComponent(r),"/messages/").concat(c),n.params=(0,s.f)({report_category:tU(a),reporting_user_id:o,report_description:l,offending_user_id:u,custom_report_category_name:tN(a)}),n}return(0,s.c)(t,e),t}(s.h),tP=function(e){function t(t){var n=[];return t.mentionType===s.at.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"MESG",ackRequired:!0,payload:(0,s.f)((0,s.g)({channel_url:t.channelUrl,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrays,mention_type:t.mentionType,mentioned_user_ids:n,mentioned_message_template:t.mentionedMessageTemplate,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption&&t.pushNotificationDeliveryOption!==s.aC.DEFAULT?t.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:t.appleCriticalAlertOptions,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage,extended_message_payload:t.extendedMessagePayload}))})||this}return(0,s.c)(t,e),t}(s.au),tx=function(e){function t(t,n,r){var i,a,o,u,c=this;(c=e.call(this,t,"MESG",r)||this).message=new B(t,r);var l=s.V.of(t).sdkState;return c.isMentioned=(0,s.aD)(c.message.mentionType,null!==(o=null!==(i=c.message.mentionedUserIds)&&void 0!==i?i:null===(a=c.message.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}))&&void 0!==o?o:[],l.userId),c.forceUpdateLastMessage=null!==(u=r.force_update_last_message)&&void 0!==u&&u,c}return(0,s.c)(t,e),t}(s.W),tR=function(e){function t(t){var n=null;return t.mentionType===s.at.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"MEDI",ackRequired:!0,payload:(0,s.f)((0,s.g)({channel_url:t.channelUrl,msg_id:t.messageId,message:t.message,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:n,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})||this}return(0,s.c)(t,e),t}(s.au),tD=function(e){function t(t,n,r){var i,a,o,u,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new B(t,r);var d=s.V.of(t).sdkState;return l.mentionCountChange=(0,s.aN)({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},(0,s.g)({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map(function(e){return e.userId})}),d.userId),l}return(0,s.c)(t,e),t}(s.W),tL=function(e){function t(t){var n=null;return t.mentionType===s.at.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map(function(e){return e.userId}))),e.call(this,{code:"FEDI",ackRequired:!0,payload:(0,s.f)((0,s.g)({channel_url:t.channelUrl,msg_id:t.messageId,data:t.data,custom_type:t.customType,metaarray:t.metaArrayParams,mention_type:t.mentionType,mentioned_user_ids:n,apple_critical_alert_options:t.appleCriticalAlertOptions}))})||this}return(0,s.c)(t,e),t}(s.au),tF=function(e){function t(t,n,r){var i,a,o,u,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new W(t,r);var d=s.V.of(t).sdkState;return l.mentionCountChange=(0,s.aN)({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==o?o:[]},(0,s.g)({mentionType:l.message.mentionType,mentionedUserIds:null!==(u=l.message.mentionedUserIds)&&void 0!==u?u:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map(function(e){return e.userId})}),d.userId),l}return(0,s.c)(t,e),t}(s.W),tq=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),o.params={reaction:a},o}return(0,s.c)(t,e),t}(s.h),tz=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new l(n),r}return(0,s.c)(t,e),t}(s.j),tj=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,o=e.call(this)||this;return o.method=s.A.DELETE,o.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),o.params={reaction:a},o}return(0,s.c)(t,e),t}(s.h),tV=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new l((0,s.d)({},n)),r}return(0,s.c)(t,e),t}(s.j),tB=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),o.params={target_langs:a},o}return(0,s.c)(t,e),t}(s.h),tK=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new B(t,n),r}return(0,s.c)(t,e),t}(s.j),tQ=function(e){function t(t){var n,r=this;r=e.call(this)||this;var i=[];t.mentionType===s.at.USERS&&(t.mentionedUserIds?i=t.mentionedUserIds:t.mentionedUsers&&(i=t.mentionedUsers.map(function(e){return e.userId})));var a=t.channelType,o=t.channelUrl;return r.method=s.A.POST,r.path="".concat((0,s.av)(a),"/").concat(encodeURIComponent(o),"/scheduled_messages"),r.params=(0,s.f)((0,s.g)({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:s.aO.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:i,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map(function(e){return v.payloadify(e)}),apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),r}return(0,s.c)(t,e),t}(s.h),tG=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new B(t,n),r}return(0,s.c)(t,e),t}(s.j),tH=function(e){function t(t){var n,r,i=this;i=e.call(this)||this;var o=[];t.mentionType===s.at.USERS&&(t.mentionedUserIds?o=t.mentionedUserIds:t.mentionedUsers&&(o=t.mentionedUsers.map(function(e){return e.userId})));var u=t.channelType,c=t.channelUrl;return i.method=s.A.POST,i.path="".concat((0,s.av)(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=(0,s.g)({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:s.aO.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:null===(n=t._thumbnails)||void 0===n?void 0:n.map(function(e){return a.payloadify(e)}),custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:o,sorted_metaarray:null===(r=t.metaArrays)||void 0===r?void 0:r.map(function(e){return v.payloadify(e)}),apple_critical_alert_options:t.appleCriticalAlertOptions?m.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),i}return(0,s.c)(t,e),t}(s.h),tW=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new W(t,n),r}return(0,s.c)(t,e),t}(s.j),tY=function(e){function t(t){var n=t.pollId,r=t.title,i=t.data,a=t.allowUserSuggestion,o=t.allowMultipleVotes,u=t.closeAt,c=e.call(this)||this;return c.method=s.A.PUT,c.path="".concat(s.aQ,"/").concat(encodeURIComponent(n)),c.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:o,close_at:u},c}return(0,s.c)(t,e),t}(s.h),tJ=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new s.aw(t,n),r}return(0,s.c)(t,e),t}(s.j),tX=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=s.A.DELETE,r.path="".concat(s.aQ,"/").concat(encodeURIComponent(n)),r}return(0,s.c)(t,e),t}(s.h);nC=s.j,(0,s.c)(function(){return null!==nC&&nC.apply(this,arguments)||this},nC);var tZ=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=s.A.PUT,r.path="".concat(s.aQ,"/").concat(encodeURIComponent(n),"/close"),r}return(0,s.c)(t,e),t}(s.h),t$=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new s.aw(t,n),r}return(0,s.c)(t,e),t}(s.j),t0=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.pollId,a=t.optionText,o=e.call(this)||this;return o.method=s.A.POST,o.path="".concat(s.aQ,"/").concat(encodeURIComponent(i),"/options"),o.params={channel_url:n,channel_type:r,text:a},o}return(0,s.c)(t,e),t}(s.h),t1=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new s.aw(t,n),r}return(0,s.c)(t,e),t}(s.j),t2=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.o
1ptionText,a=e.call(this)||this;return a.method=s.A.PUT,a.path="".concat(s.aQ,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return(0,s.c)(t,e),t}(s.h),t3=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new s.aw(t,n),r}return(0,s.c)(t,e),t}(s.j),t4=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=s.A.DELETE,i.path="".concat(s.aQ,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return(0,s.c)(t,e),t}(s.h);nk=s.j,(0,s.c)(function(){return null!==nk&&nk.apply(this,arguments)||this},nk);var t5=function(e){function t(t){var n=t.reqId,r=t.channelType,i=t.channelUrl,a=t.pollId,o=t.pollOptionIds;return e.call(this,{code:"VOTE",ackRequired:!0,payload:(0,s.f)({req_id:n,channel_type:r===s.C.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:o})})||this}return(0,s.c)(t,e),t}(s.au),t6=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new s.aR(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return(0,s.c)(t,e),t}(s.W),t7=100,t8="GroupChannel",t9="url",ne=100,nt="Message",nn="messageId",nr="NotificationMessage",ni="notificationId",ns="Poll",na="pollId",no="FeedChannel",nu="url",nc="UserInfo",nl="userId";
1function nd(e){var t,n,r;return null!==(t=e.messageParams)&&void 0!==t?t:(0,s.g)((0,s.d)((0,s.d)({},e),{isReplyToChannel:!1,mentionedUserIds:null!==(n=e.mentionedUserIds)&&void 0!==n?n:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aC.DEFAULT,isPinnedMessage:!1,fileInfoList:e.fileInfoList.map(function(e){var t;return{fileUrl:e.plainUrl,fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:null===(t=e.thumbnails)||void 0===t?void 0:t.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),_thumbnails:e.thumbnails,_uploadedMetaData:{requireAuth:e._requireAuth,isUploaded:!0}}})}))}var nh=(0,s.d)((0,s.d)({},eS),{fileInfoList:[],message:""}),nf=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onFileUploaded=s.aJ,t}return(0,s.c)(t,e),t.prototype._triggerOnFileUploaded=function(e,t,n,r){this._onFileUploaded(e,t,n,r)},t.prototype.onFileUploaded=function(e){return this._onFileUploaded=e,this},t.prototype.onPending=function(t){return e.prototype.onPending.call(this,t),this},t.prototype.onFailed=function(t){return e.prototype.onFailed.call(this,t),this},t.prototype.onSucceeded=function(t){return e.prototype.onSucceeded.call(this,t),this},t}(eT),np=function(e){function t(t,n){var r=e.call(this,t)||this;return r.message=null,r.message=H(t,n.message),r}return(0,s.c)(t,e),t}(s.ap),nm=function(e){function t(t){var n=this,r=t.channelType,i=t.channelUrl,a=t.limit,o=t.token,u=t.includeReactions,c=t.includeMetaArray,l=t.includeParentMessageInfo,d=t.includeThreadInfo,h=t.includePollDetails;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat((0,s.av)(r),"/").concat(encodeURIComponent(i),"/pinned_messages"),n.params=(0,s.f)({limit:a,token:o,include_reactions_summary:u,with_sorted_meta_array:c,include_thread_info:d,include_parent_message_info:l,include_poll_details:h}),n}return(0,s.c)(t,e),t}(s.h),n_=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.pinned_messages,s=n.has_more,a=n.next;return r.pinnedMessages=i.map(function(e){return new np(t,e)}),r.hasMore=s,r.token=a,r}return(0,s.c)(t,e),t}(s.j),nv=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s.includeMetaArray=i.includeMetaArray,s.includeReactions=i.includeReactions,s.includeParentMessageInfo=i.includeParentMessageInfo,s.includeThreadInfo=i.includeThreadInfo,s.includePollDetails=i.includePollDetails,s}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("boolean",this.includeMetaArray,!0)&&(0,s.a)("boolean",this.includeReactions,!0)&&(0,s.a)("boolean",this.includeParentMessageInfo,!0)&&(0,s.a)("boolean",this.includeThreadInfo,!0)&&(0,s.a)("boolean",this.includePollDetails,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new nm((0,s.d)((0,s.d)({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=o.sent().as(n_)).pinnedMessages,i=n.hasMore,a=n.token,this._token=a,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK),ny=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=s.A.POST,a.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/pin"),a}return(0,s.c)(t,e),t}(s.h);nO=s.j,(0,s.c)(function(e,t){return nO.call(this,e,t)||this},nO);var ng=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=e.call(this)||this;return a.method=s.A.DELETE,a.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/pin"),a}return(0,s.c)(t,e),t}(s.h);nP=s.j,(0,s.c)(function(e,t){return nP.call(this,e,t)||this},nP);var nb,nI,nE,nw,nT,nS,nA,nM,nU,nN,nC,nk,nO,nP,nx,nR=2;(nD=nx||(nx={})).SEND="send",nD.RESEND="resend",nD.COPY="copy";var nD,nL,nF=function(e){function t(t,n){var r,i,a,o,u,c,l,d=this;return(d=e.call(this,t)||this)._name="",d._createdAt=0,d.pinnedMessageIds=[],d.channelType=s.C.BASE,d.coverUrl="",d.customType="",d.data="",d.isFrozen=!1,d.isEphemeral=!1,d.creator=null,d._messageCollectionLastAccessedAt=0,d._url=n.channel_url,d._name=null!==(r=n.name)&&void 0!==r?r:"",d._createdAt=1e3*n.created_at,d.coverUrl=null!==(i=n.cover_url)&&void 0!==i?i:"",d.customType=null!==(a=n.custom_type)&&void 0!==a?a:"",d.data=null!==(o=n.data)&&void 0!==o?o:"",d.isFrozen=null!==(u=n.freeze)&&void 0!==u&&u,d.isEphemeral=null!==(c=n.is_ephemeral)&&void 0!==c&&c,d.creator=n.created_by?new s.U(d._iid,n.created_by):null,n.metadata&&Object.keys(n.metadata).length>0&&n.ts?(d._cachedMetaData=new Map,Object.keys(n.metadata).forEac
1h(function(e){d._cachedMetaData.set(e,{value:n.metadata[e],isRemoved:!1,updatedAt:n.ts})})):"string"==typeof n.metadata&&(d._cachedMetaData=new Map(Object.entries(JSON.parse(n.metadata)))),d.pinnedMessageIds=null!==(l=n.pinned_message_ids)&&void 0!==l?l:[],d}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"createdAt",{get:function(){return this._createdAt},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return(0,s.d)((0,s.d)({},this),{url:this._url,name:this._name,createdAt:this._createdAt})},t.payloadify=function(t,n){void 0===n&&(n=!1);var r=(0,s.d)((0,s.d)({},e.payloadify.call(this,t)),{channel_url:t.url,name:t.name,cover_url:t.coverUrl,custom_type:t.customType,data:t.data,freeze:t.isFrozen,is_ephemeral:t.isEphemeral,created_by:t.creator?s.U.payloadify(t.creator):null,created_at:t.createdAt/1e3,metadata:t.cachedMetaData,pinned_message_ids:t.pinnedMessageIds});return n?r:(0,s.f)((0,s.g)(r))},t.prototype.isGroupChannel=function(){return this.channelType===s.C.GROUP},t.prototype.isOpenChannel=function(){return this.channelType===s.C.OPEN},t.prototype.isFeedChannel=function(){return this.channelType===s.C.FEED},Object.defineProperty(t.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData&&this._cachedMetaData.forEach(function(t,n){t.isRemoved||(e[n]=t.value)}),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),t.prototype._serializeCachedMetaData=function(){return this._cachedMetaData?{cachedMetaData:JSON.stringify(Object.fromEntries(this._cachedMetaData))}:{}},t.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},t.prototype._update=function(e){Object.assign(this,e)},t.prototype._upsertCachedMetaData=function(e,t){var n=this;Object.keys(e).forEach(function(r){n._cachedMetaData||(n._cachedMetaData=new Map);var i=n._cachedMetaData.get(r);(!i||i.updatedAt<=t)&&n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})})},t.prototype._updateCachedMetaData=function(e,t){var n=this,r=!1;return this._cachedMetaData?this._cachedMetaData.forEach(function(i,s){var a;i.updatedAt<=t&&(n._cachedMetaData.set(s,{value:null!==(a=e[s])&&void 0!==a?a:i.value,isRemoved:!e[s],updatedAt:t}),r=!0)}):(this._cachedMetaData=new Map,Object.keys(e).forEach(function(r){n._cachedMetaData.set(r,{value:e[r],isRemoved:!1,updatedAt:t})}),r=!0),{isUpdated:r}},t.prototype._removeFromCachedMetaData=function(e,t){var n=this;this._cachedMetaData&&e.forEach(function(e){var r=n._cachedMetaData.get(e);r&&r.updatedAt<t&&(r.isRemoved=!0,r.updatedAt=t)})},t.prototype._clearCachedMetaData=function(){this._cachedMetaData&&this._cachedMetaData.clear()},t.prototype._runIfHandleableWithGroupChannel=function(e){this.isGroupChannel()?e(this):this.isFeedChannel()&&e(this.groupChannel)},t.prototype._generateRequestId=function(){return"rq-".concat((0,s.u)())},t.prototype.isIdentical=function(e){return e&&this.url===e.url},t.prototype.isEqual=function(e){return(0,s.aq)(this,e)},t.prototype.createOperatorListQuery=function(e){return void 0===e&&(e={}),new eJ(this._iid,this.url,this.channelType,e)},t.prototype.createMutedUserListQuery=function(e){return void 0===e&&(e={}),new e0(this._iid,this.url,this.channelType,e)},t.prototype.createBannedUserListQuery=function(e){return void 0===e&&(e={}),new e3(this._iid,this.url,this.channelType,e)},t.prototype.createPreviousMessageListQuery=function(e){return void 0===e&&(e={}),new eX(this._iid,this.url,this.channelType,e)},t.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new nv(this._iid,this.url,this.channelType,e)},t.prototype.addOperators=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a2)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new e4({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.removeOperators=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a2)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new e5({channelUrl:this.url,channelType:this.channelType,operatorUserIds:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.getMyMutedInfo=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return t=(e=s.
1V.of(this._iid)).sdkState,n=e.requestQueue,r=new e6({channelUrl:this.url,channelType:this.channelType,userId:t.userId}),[4,n.send(r)];case 1:return a=(i=u.sent().as(e7)).isMuted,o=i.startAt,[2,{isMuted:a,startAt:o,endAt:i.endAt,remainingDuration:i.remainingDuration,description:i.description}]}})})},t.prototype.getMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return(0,s.F)((0,s.a2)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new e8({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,t.send(n)];case 1:return i=(r=o.sent().as(e9)).metadata,a=r.ts,this._upsertCachedMetaData(i,a),[2,i]}})})},t.prototype.getAllMetaData=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new e8({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(t)];case 1:return r=(n=a.sent().as(e9)).metadata,i=n.ts,this._updateCachedMetaData(r,i),[2,r]}})})},t.prototype.createMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new te({channelUrl:this.url,channelType:this.channelType,metadata:e}),[4,t.send(n)];case 1:return r=i.sent().as(tt).metaData,this._upsertCachedMetaData(r,0),[2,r]}})})},t.prototype.updateMetaData=function(e,t){return void 0===t&&(t=!1),(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return n=s.V.of(this._iid).requestQueue,r=new tn({channelUrl:this.url,channelType:this.channelType,metadata:e,upsert:t}),[4,n.send(r)];case 1:return a=(i=u.sent().as(tr)).metadata,o=i.ts,this._upsertCachedMetaData(a,o),[2,a]}})})},t.prototype.deleteMetaData=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ts({channelUrl:this.url,channelType:this.channelType,key:e}),[4,t.send(n)];case 1:return r=i.sent().as(ta).ts,this._removeFromCachedMetaData([e],r),[2]}})})},t.prototype.deleteAllMetaData=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new to({channelUrl:this.url,channelType:this.channelType}),[4,e.send(t)];case 1:return n=r.sent().as(tu).ts,this._removeFromCachedMetaData((0,s.q)([],(0,s.r)(this._cachedMetaData.keys()),!1),n),[2]}})})},t.prototype.getMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a2)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new tc({channelUrl:this.url,channelType:this.channelType,keys:e}),[4,t.send(n)];case 1:return[2,r.sent().as(tl).metaCounter]}})})},t.prototype.getAllMetaCounters=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new tc({channelUrl:this.url,channelType:this.channelType,keys:[]}),[4,e.send(t)];case 1:return[2,n.sent().as(tl).metaCounter]}})})},t.prototype.createMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new td({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),[4,t.send(n)];case 1:return[2,r.sent().as(th).metaCounter]}})})},t.prototype.updateMetaCounters=function(e,t){return void 0===t&&(t=!1),(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return n=s.V.of(this._iid).requestQueue,r=new tf({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:t}),[4,n.send(r)];case 1:return[2,i.sent().as(tp).metaCounter]}})})},t.prototype.increaseMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new tf({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"increase"}),[4,t.send(n)];case 1:return[2,r.sent().as(tp).metaCounter]}})})},t.prototype.decreaseMetaCounters=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=s.V.of(this._iid).requestQueue,n=new tf({channelUrl:this.url,channelType:this.channelType,metaCounter:e,upsert:!1,mode:"decrease"}),[4,t.send(n)];case 1:return[2,r.sent().as(tp).metaCounter]}})})},t.prototype.deleteMetaCounter=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new t_({channelUrl:this.url,channelType:this.channelType,key:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.deleteAllMetaCounters=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new tv({channelUrl:this.url,channelType:this.channelType}),[4,e.send(t)];case 1:return n.sent(),[2]}})})},t.prototype.muteUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){return[2,this.muteUserWithUserId(e.userId,t,n)]})})},t.prototype.muteUserWithUserId=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return(0,s.F)((0,s.a)("string",e)&&(0,s.a)("number",t,!0)&&(0,s.a)("string",n,!0)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new ty({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.unmuteUser=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this.unmuteUserWithUserId(e.userId)]})})},t.prototype.unmuteUserWithUserId=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new tb({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.banUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){return[2,this.banUserWithUserId(e.userId,t,n)]})})},t.prototype.banUserWithUserId=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return(0,s.F)((0,s.a)("string",e)&&(0,s.a)("number",t,!0)&&(0,s.a)("string",n,!0)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new tE({channelUrl:this.url,channelType:this.channelType,userId:e,seconds:t,description:n}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.unbanUser=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this.unbanUserWithUserId(e.userId)]})})},t.prototype.unbanUserWithUserId=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new tT({channelUrl:this.url,channelType:this.channelType,userId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.freeze=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new tA({channelUrl:this.url,channelType:this.channelType,freezing:!0}),[4,e.send(t)];case 1:return n.sent(),this.isFrozen=!0,[2]}})})},t.prototype.unfreeze=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=s.V.of(this._iid).requestQueue,t=new tA({channelUrl:this.url,channelType:this.channelType,freezing:!1}),[4,e.send(t)];case 1:return n.sent(),this.isFrozen=!1,[2]}})})},t.prototype.getMessagesByMessageId=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},eo),t),(0,s.F)((0,s.a)("number",e)&&eu(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getMessagesByMessageId(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessagesByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},eo),t),(0,s.F)((0,s.a)("number",e)&&eu(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getMessagesByTimestamp(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessageChangeLogsSinceTimestamp=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},ec),t),(0,s.F)((0,s.a)("number",e)&&el(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype.getMessageChangeLogsSinceToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return n=(0,s.d)((0,s.d)({},ec),t),(0,s.F)((0,s.a)("string",e)&&el(n)).throw(s.t.invalidParameters),[4,ib.of(this._iid).getMessageChangelogs(this.url,this.channelType,e,n)];case 1:return[2,r.sent()]}})})},t.prototype._createPendingSendableMessagePayload=function(e,t,n){var r,i=s.V.of(this._iid).sessionManager;return(0,s.f)((0,s.g)({channel_url:this.url,channel_type:this.channelType,msg_id:0,parent_message_id:e.parentMessageId,data:e.data,custom_type:e.customType,mention_type:e.mentionType,sorted_metaarray:e.metaArrays?e.metaArrays.map(function(e){return v.payloadify(e)}):null,apple_critical_alert_options:e.appleCriticalAlertOptions?m.payloadify(e.appleCriticalAlertOptions):null,created_at:n,user:i.currentUser?_.payloadify(i.currentUser):null,req_id:t,request_state:s.ay.PENDING,mentioned_user_ids:e.mentionedUserIds,mentioned_users:null===(r=e.mentionedUsers)||void 0===r?void 0:r.map(function(e){return s.U.payloadify(e)})}))},t.prototype._createPendingUserMessage=function(e,t,n){var r,i,a={};if(e.translationTargetLanguages)try{for(var o=(0,s.w)(e.translationTargetLanguages),u=o.next();!u.done;u=o.next())a[u.value]=""}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}var c=(0,s.f)((0,s.d)((0,s.d)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.ar.USER,message:e.message,translations:a,extended_message_payload:e.extendedMessagePayload})),l=new B(this._iid,c);return l.messageParams=e,l},t.prototype._createPendingScheduledUserMessage=function(e,t,n){var r=this._createPendingUserMessage(e,t,n);
1return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},t.prototype._createPendingFileMessage=function(e,t,n){var r,i,o,u,c,l,d,h=(0,s.f)((0,s.d)((0,s.d)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.ar.FILE,url:e.fileUrl,file:{name:null!==(r=e.fileName)&&void 0!==r?r:null===(i=e.file)||void 0===i?void 0:i.name,size:null!==(o=e.fileSize)&&void 0!==o?o:null===(u=e.file)||void 0===u?void 0:u.size,type:null!==(c=e.mimeType)&&void 0!==c?c:null===(l=e.file)||void 0===l?void 0:l.type,data:e.data},thumbnails:null===(d=e._thumbnails)||void 0===d?void 0:d.map(function(e){return a.payloadify(e)}),message:e.message})),f=new W(this._iid,h);return f.messageParams=e,f},t.prototype._createPendingMultipleFilesMessage=function(e,t,n){var r=(0,s.f)((0,s.d)((0,s.d)({},this._createPendingSendableMessagePayload(e,t,n)),{type:s.ar.FILE,file:e.fileInfoList.length>0?{name:e.fileInfoList[0].fileName,size:e.fileInfoList[0].fileSize,type:e.fileInfoList[0].mimeType,data:e.data}:void 0,message:e.message})),i=new K(this._iid,r);return i.messageParams=e,i},t.prototype._validateFailedFileMessageHasFile=function(e,t){var n;return!!e.url||(0,s.i)(t)||(0,s.i)(null===(n=e.messageParams)||void 0===n?void 0:n.file)},t.prototype._createPendingScheduledFileMessage=function(e,t,n){var r=this._createPendingFileMessage(e,t,n);return r.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},r},t.prototype._markMessageAsFailed=function(e,t,n){void 0===n&&(n=!1),e.errorCode=t.code,t.code===s.D.REQUEST_CANCELED||t.code===s.D.FILE_UPLOAD_CANCEL_FAILED?e.sendingStatus=s.ay.CANCELED:n||(e.sendingStatus=s.ay.FAILED)},t.prototype.sendUserMessage=function(e){var t=(0,s.d)((0,s.d)({},eU),e);return(0,s.F)(eP(t)).throw(s.t.invalidParameters),this._sendUserMessage(t)},t.prototype._sendUserMessage=function(e,t,n){var r=this;void 0===t&&(t=nx.SEND);var i=s.V.of(this._iid),a=i.dispatcher,o=i.requestQueue,u=null!=n?n:this._generateRequestId(),c=Date.now(),l=new eT;return(0,s.aF)(2).then(function(){var n=r._createPendingUserMessage(e,u,c);a.dispatch(new s.ax({messages:[n],source:t===nx.RESEND?s.ab.LOCAL_MESSAGE_RESEND_STARTED:s.ab.EVENT_MESSAGE_SENT_PENDING})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._trigger(n)]})})});var i=new tP((0,s.d)((0,s.d)({},e),{channelUrl:r.url,channelType:r.channelType,reqId:u}));o.send(i).then(function(e){var t=e.as(tx).message;a.dispatch(new s.ax({messages:[t],source:s.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._trigger(t)]})})})}).catch(function(t){if((0,s.a1)(t))throw t;(0,s.aF)(2).then(function(){var n=r._createPendingUserMessage(e,u,c),i=s.V.of(r._iid).cacheContext,o=i.localCacheEnabled&&i.localCacheConfig.enableAutoResend&&
1(0,s.aT)(t.code);r._markMessageAsFailed(n,t,o),a.dispatch(new s.ax({messages:[n],source:n.sendingStatus===s.ay.PENDING?s.ab.REQUEST_RESEND_MESSAGE:s.ab.EVENT_MESSAGE_SENT_FAILED})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,l._triggerFailed(t,n)]})})})})})}),l},t.prototype._autoResendUserMessage=function(e){return(0,s.F)(e instanceof B&&!!e.messageParams).throw(s.t.invalidParameters),this._sendUserMessage(e.messageParams,nx.SEND,e.reqId)},t.prototype.resendUserMessage=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){return(0,s.F)(e instanceof B&&!e.scheduledInfo).throw(s.t.invalidParameters),n=new s.aG,r=null!==(t=e.messageParams)&&void 0!==t?t:eO(e),this._sendUserMessage(r,nx.RESEND,e.reqId).onFailed(function(e){return n.reject(e)}).onSucceeded(function(e){return n.resolve(e)}),[2,n.promise]})})},t.prototype.updateUserMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.d)((0,s.d)({},eQ),t),(0,s.F)((0,s.a)("number",e)&&eG(n)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new tR((0,s.d)({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:n.metaArrays?{array:n.metaArrays,mode:"add",upsert:!0}:void 0},n)),[4,r.send(i)];case 1:return[2,a.sent().as(tD).message]}})})},t.prototype.copyUserMessage=function(e,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,u;return(0,s.b)(this,function(c){return(0,s.F)(e instanceof t&&n instanceof B&&n.sendingStatus===s.ay.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters),(0,s.F)(!n.poll).throw(s.t.notSupportedError),o=new s.aG,u=null!==(r=n.messageParams)&&void 0!==r?r:(0,s.g)((0,s.d)((0,s.d)({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(a=n.mentionedUsers)||void 0===a?void 0:a.map(function(e){return e.userId}),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:s.aC.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1})),e._sendUserMessage(u).onSucceeded(function(e){o.resolve(e)}).onFailed(function(e){return o.reject(e)}),[2,o.promise]})})},t.prototype.translateUserMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof B&&e.messageId>0&&(0,s.a2)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tB({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(r)];case 1:return[2,i.sent().as(tK).message]}})})},t.prototype._createScheduledUserMessage=function(e,t){var n=this,r=s.V.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();(0,s.aF)(2).then(function(){var r=n._createPendingScheduledUserMessage(e,a,i);(0,s.N)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(r)]})})})});var o=new tQ((0,s.d)({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then(function(e){var r=e.as(tG).message;(0,s.N)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(r)]})})})}).catch(function(r){if((0,s.a1)(r))throw r;(0,s.aF)(2).then(function(){var o=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(o,r),(0,s.N)(function(){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._triggerFailed(r,o)]})})})})})},t.prototype.sendFileMessage=function(e){var t=(0,s.d)((0,s.d)({},eL),e);return(0,s.F)(eV(t)).throw(s.t.invalidParameters),this._sendFileMessage(t)},t.prototype.sendMultipleFilesMessage=function(e){var t,n,r=(0,s.d)((0,s.d)({},nh),e),i=s.V.of(this._iid);(0,s.F)((void 0===(t=null===(n=i.appInfo)||void 0===n?void 0:n.multipleFilesMessageFileCountLimit)&&(t=s.aS),eA(r)&&(0,s.a)("string",r.message,!0)&&Array.isArray(r.fileInfoList)&&r.fileInfoList.length>=2&&r.fileInfoList.length<=t&&r.fileInfoList.every(function(e){return((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(void 0===e.thumbnailSizes||Array.isArray(e.thumbnailSizes)&&e.thumbnailSizes.every(function(e){return e.maxWidth>0&&e.maxHeight>0}))}))).throw(s.t.invalidParameters);var a=!!e.fileInfoList.find(function(e){var t=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t});return(0,s.F)(!a).throw(s.t.fileSizeLimitExceededError),this._sendMultipleFilesMessage(r)},t.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===t&&(t=nx.SEND);var i=s.V.of(this._iid).dispatcher,a=ib.of(this._iid).fileMessageQueue,o=null!=n?n:this._generateRequestId(),u=Date.now(),c=new eT;return(0,s.aF)(2).then(function(){var n=r._createPendingFileMessage(e,o,u);i.dispatch(new s.ax({messages:[n],source:t===nx.RESEND?s.ab.LOCAL_MESSAGE_RESEND_STARTED:s.ab.EVENT_MESSAGE_SENT_PENDING})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,c._trigger(n)]})})}),a.request(r,o,e).then(function(e){i.dispatch(new s.ax({messages:[e],source:s.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,c._trigger(e)]})})})}).catch(function(t){if((0,s.a1)(t))throw t;(0,s.aF)(2).then(function(){var n=r._createPendingFileMessage(e,o,u),a=s.V.of(r._iid).cacheContext,l=a.localCacheEnabled&&a.localCacheConfig.enableAutoResend&&
1(0,s.aT)(t.code);r._markMessageAsFailed(n,t,l),i.dispatch(new s.ax({messages:[n],source:n.sendingStatus===s.ay.PENDING?s.ab.REQUEST_RESEND_MESSAGE:t.code===s.D.FILE_UPLOAD_CANCEL_FAILED?s.ab.LOCAL_MESSAGE_CANCELED:s.ab.EVENT_MESSAGE_SENT_FAILED})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,c._triggerFailed(t,n)]})})})})})}),c},t.prototype._autoResendFileMessage=function(e){(0,s.F)(e instanceof W&&!!e.messageParams).throw(s.t.invalidParameters);var t=s.V.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,nx.SEND,e.reqId).onFailed(function(e){t.debug("autoResendFileMessage failed",e)}).onSucceeded(function(e){t.debug("autoResendFileMessage success",e)})},t.prototype._sendMultipleFilesMessage=function(e,t,n){var r=this,i=s.V.of(this._iid).dispatcher,a=ib.of(this._iid).fileMessageQueue,o=null!=n?n:this._generateRequestId(),u=Date.now(),c=new nf;return(0,s.aF)(2).then(function(){var n=r._createPendingMultipleFilesMessage(e,o,u);i.dispatch(new s.ax({messages:[n],source:t===nx.RESEND?s.ab.LOCAL_MESSAGE_RESEND_STARTED:s.ab.EVENT_MESSAGE_SENT_PENDING})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,c._trigger(n)]})})}),a.request(r,o,e,{requestHandler:c,isCopy:t===nx.COPY}).then(function(e){i.dispatch(new s.ax({messages:[e],source:s.ab.EVENT_MESSAGE_SENT_SUCCESS})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,c._trigger(e)]})})})}).catch(function(t){if((0,s.a1)(t))throw t;(0,s.aF)(2).then(function(){var n=r._createPendingMultipleFilesMessage(e,o,u);r._markMessageAsFailed(n,t),i.dispatch(new s.ax({messages:[n],source:s.ab.EVENT_MESSAGE_SENT_FAILED})),(0,s.N)(function(){return(0,s._)(r,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,c._triggerFailed(t,n)]})})})})})}),c},t.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=s.V.of(this._iid).requestQueue,o=new tH((0,s.d)((0,s.d)({reqId:n,channelType:this.channelType,channelUrl:this.url},e),{fileUrl:e.fileUrl,requireAuth:e.requireAuth}));a.send(o).then(function(e){var n=e.as(tW).message;(0,s.N)(function(){return(0,s._)(i,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._trigger(n)]})})})}).catch(function(a){if((0,s.a1)(a))throw a;(0,s.aF)(2).then(function(){var o=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(o,a),(0,s.N)(function(){return(0,s._)(i,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2,t._triggerFailed(a,o)]})})})})})},t.prototype.sendFileMessages=function(e){(0,s.F)(e.every(function(e){return eV((0,s.d)((0,s.d)({},eL),e))})).throw(s.t.invalidParameters);var t,n,r=new eT;try{for(var i=(0,s.w)(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).onPending(function(e){return r._trigger(e)}).onFailed(function(e,t){return r._triggerFailed(e,t)}).onSucceeded(function(e){return r._trigger(e)})}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},t.prototype.resendFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){return n=this._validateFailedFileMessageHasFile(e,t),(0,s.F)(e instanceof W&&n&&!e.scheduledInfo).throw(s.t.invalidParameters),r=new s.aG,i=ej(e,t),this._sendFileMessage(i,nx.RESEND,e.reqId).onFailed(function(e){return r.reject(e)}).onSucceeded(function(e){return r.resolve(e)}),[2,r.promise]})})},t.prototype.resendMessage=function(e,t){var n,r;if((0,s.F)(e instanceof L&&!e.scheduledInfo&&e.isResendable).throw(s.t.invalidParameters),e.isUserMessage()){var i=null!==(n=e.messageParams)&&void 0!==n?n:eO(e);return this._sendUserMessage(i,nx.RESEND,e.reqId)}if(e.isFileMessage()){var a=this._validateFailedFileMessageHasFile(e,t);return(0,s.F)(a).throw(s.t.invalidParameters),i=null!==(r=e.messageParams)&&void 0!==r?r:ej(e,t),this._sendFileMessage(i,nx.RESEND,e.reqId)}if(e.isMultipleFilesMessage())throw s.t.channelTypeNotSupportedError},t.prototype.updateFileMessage=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.d)((0,s.d)({},eH),t),(0,s.F)((0,s.a)("number",e)&&eK(n)).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new tL((0,s.d)({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:n.metaArrays?{array:n.metaArrays,mode:"add",upsert:!0}:void 0},n)),[4,r.send(i)];case 1:return[2,a.sent().as(tF).message]}})})},t.prototype.uploadFile=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return t=s.V.of(this._iid).requestQueue,n=(0,s.u)(),(r=new o({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:n})).uploadProgressHandler=e.progressHandler,e.uploadStartedHandler&&e.uploadStartedHandler(n),[4,t.send(r)];case 1:return a=(i=l.sent().as(u)).url,c=i.thumbnails,[2,{requestId:n,url:a,thumbnails:c}]}})})},t.prototype.cancelUploadingFileMessage=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),ib.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]})})},t.prototype.copyFileMessage=function(e,n){var r,i,a;return(0,s._)(this,void 0,void 0,function(){var o,u;return(0,s.b)(this,function(c){return(0,s.F)(e instanceof t&&n instanceof W&&n.sendingStatus===s.ay.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters),o=new s.aG,u=(0,s.g)((0,s.d)((0,s.d)({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(r=n.mentionedUserIds)&&void 0!==r?r:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map(function(e){return e.userId}),pushNotificationDeliveryOption:s.aC.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(a=n.thumbnails)||void 0===a?void 0:a.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),requireAuth:n.requireAuth,isPinnedMessage:!1})),e._sendFileMessage(u).onSucceeded(function(e){return o.resolve(e)}).onFailed(function(e){return o.reject(e)}),[2,o.promise]})})},t.prototype.copyMessage=function(e,n){if((0,s.F)(e instanceof t&&n instanceof L&&n.sendingStatus===s.ay.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(s.t.invalidParameters),n.isUserMessage()){(0,s.F)(!n.poll).throw(s.t.notSupportedError);var r=eN(n);return e._sendUserMessage(r)}if(n.isFileMessage())return r=eF(n),e._sendFileMessage(r);if(n.isMultipleFilesMessage())throw s.t.channelTypeNotSupportedError},t.prototype.deleteMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)(e instanceof D).throw(s.t.invalidParameters),e.messageId>0?(t=s.V.of(this._iid).requestQueue,n=new s.aU({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,messageToken:e instanceof L?e._messageToken:void 0}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.addReaction=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof D&&e.messageId>0&&(0,s.a)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tq({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return[2,i.sent().as(tz).reactionEvent]}})})},t.prototype.deleteReaction=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)(e instanceof D&&e.messageId>0&&(0,s.a)("string",t)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tj({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:t}),[4,n.send(r)];case 1:return[2,i.sent().as(tV).reactionEvent]}})})},t.prototype._updateUserMessageMetaArray=function(e,t,n,r){return(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return a=(i=s.V.of(this._iid)).dispatcher,o=i.requestQueue,u=new tR({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,o.send(u)];case 1:return c=l.sent().as(tD).message,a.dispatch(new s.ax({messages:[c],source:s.ab.EVENT_MESSAGE_UPDATED})),[2,c]}})})},t.prototype._updateFileMessageMetaArray=function(e,t,n,r){return(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return a=(i=s.V.of(this._iid)).dispatcher,o=i.requestQueue,u=new tL({channelType:this.channelType,channelUrl:this.url,messageId:e,metaArrayParams:{array:t,mode:n,upsert:r}}),[4,o.send(u)];case 1:return c=l.sent().as(tF).message,a.dispatch(new s.ax({messages:[c],source:s.ab.EVENT_MESSAGE_UPDATED})),[2,c]}})})},t.prototype.createMessageMetaArrayKeys=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return(0,s.F)(e instanceof D&&e.messageId>0&&(0,s.a2)("string",t)).throw(s.t.invalidParameters),n=t.map(function(e){return new v({key:e})}),e instanceof W?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]})})},t.prototype.deleteMessageMetaArrayKeys=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return(0,s.F)(e instanceof D&&e.messageId>0&&(0,s.a2)("string",t)).throw(s.t.invalidParameters),n=t.map(function(e){return new v({key:e})}),e instanceof W?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]})})},t.prototype.addMessageMetaArrayValues=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return(0,s.F)(e instanceof D&&e.messageId>0&&t.every(function(e){return e instanceof v})).throw(s.t.invalidParameters),e instanceof W?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]})})},t.prototype.removeMessageMetaArrayValues=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return(0,s.F)(e instanceof D&&e.messageId>0&&t.every(function(e){return e instanceof v})).throw(s.t.invalidParameters),e instanceof W?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]})})},t.prototype.report=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return(0,s.F)(((0,s.a5)(ez,e)||e instanceof s.ah)&&(0,s.a)("string",t)).throw(s.t.invalidParameters),r=(n=s.V.of(this._iid)).sdkState,i=n.requestQueue,a=new tC({channelUrl:this.url,channelType:this.channelType,userId:r.userId,category:e,description:t}),[4,i.send(a)];case 1:return o.sent(),[2]}})})},t.prototype.reportUser=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return(0,s.F)(e instanceof s.U&&((0,s.a5)(ez,t)||t instanceof s.ah)&&(0,s.a)("string",n)).throw(s.t.invalidParameters),i=(r=s.V.of(this._iid)).sdkState,a=r.requestQueue,o=new tk({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.userId,category:t,description:n}),[4,a.send(o)];case 1:return u.sent(),[2]}})})},t.prototype.reportMessage=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return(0,s.F)(e instanceof L&&((0,s.a5)(ez,t)||t instanceof s.ah)&&(0,s.a)("string",n)).throw(s.t.invalidParameters),i=(r=s.V.of(this._iid)).sdkState,a=r.requestQueue,o=new tO({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:t,description:n,messageToken:e._messageToken}),[4,a.send(o)];case 1:return u.sent(),[2]}})})},t.prototype.updatePoll=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return(0,s.F)((0,s.a)("number",e)&&(0,s.a)("string",t.title,!0)&&(0,s.aP)(t.data)&&(0,s.a)("boolean",t.allowUserSuggestion,!0)&&(0,s.a)("boolean",t.allowMultipleVotes,!0)&&(0,s.a)("number",t.closeAt,!0)).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tY((0,s.d)({pollId:e},t)),[4,n.send(r)];case 1:return[2,i.sent().as(tJ).poll]}})})},t.prototype.deletePoll=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t=(0,s.a)("number",e),(0,s.F)(t).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tX({pollId:e}),[4,n.send(r)];case 1:return i.sent(),[2]}})})},t.prototype.closePoll=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t=(0,s.a)("number",e),(0,s.F)(t).throw(s.t.invalidParameters),n=s.V.of(this._iid).requestQueue,r=new tZ({pollId:e}),[4,n.send(r)];case 1:return[2,i.sent().as(t$).poll]}})})},t.prototype.addPollOption=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.a)("number",e)&&(0,s.a)("string",t)&&""!==t.trim(),(0,s.F)(n).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new t0({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:t}),[4,r.send(i)];case 1:return[2,a.sent().as(t1).poll]}})})},t.prototype.updatePollOption=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return r=(0,s.a)("number",e)&&(0,s.a)("number",t)&&(0,s.a)("string",n)&&""!==n.trim(),(0,s.F)(r).throw(s.t.invalidParameters),i=s.V.of(this._iid).requestQueue,a=new t2({pollId:e,pollOptionId:t,optionText:n}),[4,i.send(a)];case 1:return[2,o.sent().as(t3).poll]}})})},t.prototype.deletePollOption=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return n=(0,s.a)("number",e)&&(0,s.a)("number",t),(0,s.F)(n).throw(s.t.invalidParameters),r=s.V.of(this._iid).requestQueue,i=new t4({pollId:e,pollOptionId:t}),[4,r.send(i)];case 1:return a.sent(),[2]}})})},t.prototype.votePoll=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return n=(0,s.a)("number",e)&&(0,s.a2)("number",t),(0,s.F)(n).throw(s.t.invalidParameters),i=(r=s.V.of(this._iid)).requestQueue,a=r.dispatcher,o=new t5({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionIds:t}),[4,i.send(o)];case 1:return u=c.sent().as(t6).event,a.dispatch(new s.aV({event:u,source:s.ab.EVENT_POLL_VOTED})),[2,u]}})})},t.prototype.getPollChangeLogsSinceTimestamp=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return(0,s.F)((0,s.a)("number",e)).throw(s.t.invalidParameters),[4,s.aW.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}})})},t.prototype.getPollChangeLogsSinceToken=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return(0,s.F)((0,s.a)("string",e,!0)),[4,s.aW.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,t.sent()]}})})},t.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new s.G(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},t.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new s.H(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},t.prototype.pinMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("number",e)&&e>0).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ny({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t.prototype.unpinMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return
1(0,s.b)(this,function(r){switch(r.label){case 0:return(0,s.F)((0,s.a)("number",e)&&e>0).throw(s.t.invalidParameters),t=s.V.of(this._iid).requestQueue,n=new ng({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}})})},t}(s.ap),nq=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(0,s.c)(t,e),t}(function(){this.onConnected=s.aJ,this.onReconnectStarted=s.aJ,this.onReconnectSucceeded=s.aJ,this.onReconnectFailed=s.aJ,this.onConnectionLost=s.aJ,this.onDisconnected=s.aJ,this.onConnectionDelayed=s.aJ}),nz=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(0,s.c)(t,e),t}(function(){this.onSessionExpired=s.aJ,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=s.aJ,this.onSessionRefreshed=s.aJ,this.onSessionClosed=s.aJ}),nj=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(0,s.c)(t,e),t}(function(){this.onFriendsDiscovered=s.aJ,this.onTotalUnreadMessageCountChanged=s.aJ,this.onTotalUnreadMessageCountUpdated=s.aJ}),nV=function(e){function t(t){var n=t.limit,r=t.token,i=t.userIdsFilter,a=t.metaDataKeyFilter,o=t.metaDataValuesFilter,u=t.nicknameStartsWithFilter,c=e.call(this)||this;return c.method=s.A.GET,c.path=s.k,c.params=(0,s.f)({limit:n,token:r,user_ids:i,metadatakey:a,metadatavalues_in:o,nickname_startswith:u}),c}return(0,s.c)(t,e),t}(s.h),nB=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.j),nK=function(e){function t(t,n){var r,i,s,a=this;return(a=e.call(this,t,n)||this).userIdsFilter=null,a.metaDataKeyFilter=null,a.metaDataValuesFilter=null,a.nicknameStartsWithFilter=null,a.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,a.metaDataKeyFilter=null!==(i=n.metaDataKeyFilter)&&void 0!==i?i:null,a.metaDataValuesFilter=null!==(s=n.metaDataValuesFilter)&&void 0!==s?s:null,a.nicknameStartsWithFilter=n.nicknameStartsWithFilter||null,a}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a2)("string",this.userIdsFilter,!0)&&(0,s.a)("string",this.metaDataKeyFilter,!0)&&(0,s.a2)("string",this.metaDataValuesFilter,!0)&&(0,s.a)("string",this.nicknameStartsWithFilter,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new nV((0,s.g)((0,s.d)((0,s.d)({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=a.sent().as(nB)).users,i=n.next,this._token=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aX),nQ=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,a=t.userIdsFilter,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat(s.k,"/").concat(encodeURIComponent(n),"/block"),o.params=(0,s.f)({limit:r,token:i,user_ids:a}),o}return(0,s.c)(t,e),t}(s.h),nG=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.j),nH=function(e){function t(t,n){var r,i=this;return(i=e.call(this,t,n)||this).userIdsFilter=null,i.userIdsFilter=null!==(r=n.userIdsFilter)&&void 0!==r?r:null,i}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a2)("string",this.userIdsFilter,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=(e=s.V.of(this._iid)).sdkState,n=e.requestQueue,r=new nQ((0,s.g)((0,s.d)((0,s.d)({},this),{userId:t.userId,token:this._token}
1))),[4,n.send(r)]):[3,2]:[3,5];case 1:return a=(i=u.sent().as(nG)).users,o=i.next,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aX),nW=function(e){function t(t){var n=t.userId,r=t.limit,i=t.token,a=e.call(this)||this;return a.method=s.A.GET,a.path="".concat(s.k,"/").concat(encodeURIComponent(n),"/friends"),a.params={limit:r,token:i},a}return(0,s.c)(t,e),t}(s.h),nY=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map(function(e){return new s.U(t,e)}),r.next=n.next,r}return(0,s.c)(t,e),t}(s.j),nJ=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=(e=s.V.of(this._iid)).sdkState,n=e.requestQueue,r=new nW((0,s.d)((0,s.d)({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return a=(i=c.sent().as(nY)).users,o=i.hasMore,u=i.next,this._token=u,this._hasNext=o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aX),nX={},nZ=function(){function e(e){var t=e.dbname,n=e.itemSizeLimit,r=e.cacheLimit,i=e.blockHashBase,s=e.blockHashMultiplier,a=e.blockHashConstant,o=e.transactionApplyDelay,u=e.disableLogger;return nX[t]||(this.itemSizeLimit=void 0===n?1048576:n,this.cacheLimit=void 0===r?256:r,this.blockHashBase=void 0===i?2:i,this.blockHashMultiplier=void 0===s?10:s,this.blockHashConstant=void 0===a?11:a,this.transactionApplyDelay=void 0===o?200:o,this.disableLogger=void 0!==u&&u,nX[t]=this),nX[t]}return e.get=function(e){return nX[e]},e}();(n$=nL||(nL={}))[n$.UNKNOWN_ERROR=6e7]="UNKNOWN_ERROR",n$[n$.STORE_NOT_DEFINED=61001e3]="STORE_NOT_DEFINED",n$[n$.STORE_NOT_AVAILABLE=61001001]="STORE_NOT_AVAILABLE",n$[n$.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING=61001002]="STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING",n$[n$.STORE_IS_FULL=61001003]="STORE_IS_FULL",n$[n$.STORE_NOT_INITIALIZED=61001004]="STORE_NOT_INITIALIZED",n$[n$.STORE_INVALID_KEY_TYPE=61002e3]="STORE_INVALID_KEY_TYPE",n$[n$.STORE_BROKEN_INTEGRITY=61002001]="STORE_BROKEN_INTEGRITY",n$[n$.STORE_BROKEN_BLOB=61002002]="STORE_BROKEN_BLOB",n$[n$.STORE_ENCRYPTION_INVA
1LID=61002003]="STORE_ENCRYPTION_INVALID",n$[n$.STORE_ITEM_SIZE_LIMIT_EXCEEDED=61017e3]="STORE_ITEM_SIZE_LIMIT_EXCEEDED",n$[n$.STORE_READ_FAILED=61017001]="STORE_READ_FAILED",n$[n$.STORE_WRITE_FAILED=61017002]="STORE_WRITE_FAILED",n$[n$.DATABASE_SCHEMA_NOT_ON_UPGRADE=62002e3]="DATABASE_SCHEMA_NOT_ON_UPGRADE",n$[n$.COLLECTION_NOT_READY=63001e3]="COLLECTION_NOT_READY",n$[n$.COLLECTION_KEY_NOT_MATCH=63002e3]="COLLECTION_KEY_NOT_MATCH",n$[n$.COLLECTION_QUERY_NOT_VALID=63002001]="COLLECTION_QUERY_NOT_VALID",n$[n$.COLLECTION_KEY_NOT_FOUND=63004e3]="COLLECTION_KEY_NOT_FOUND",n$[n$.COLLECTION_KEY_NOT_GIVEN=63004001]="COLLECTION_KEY_NOT_GIVEN",n$[n$.COLLECTION_INSERT_DUPLICATE=63009e3]="COLLECTION_INSERT_DUPLICATE",n$[n$.COLLECTION_WRITE_FAILED=63017e3]="COLLECTION_WRITE_FAILED",n$[n$.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED=63017001]="COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED",n$[n$.INDEX_TABLE_IS_REQUIRED=65001e3]="INDEX_TABLE_IS_REQUIRED",n$[n$.INDEX_TYPE_NOT_MATCH=65002e3]="INDEX_TYPE_NOT_MATCH",n$[n$.COMPARE_TYPE_NOT_MATCH=69002001]="COMPARE_TYPE_NOT_MATCH",n$[n$.CIRCULAR_REFERENCE_FOUND=69002002]="CIRCULAR_REFERENCE_FOUND";var n$,n0,n1=function(e){function t(n){var r=n.code,i=void 0===r?nL.UNKNOWN_ERROR:r,s=n.message,a=e.call(this,void 0===s?"Unknown error occurred.":s)||this;return a.code=i,Object.setPrototypeOf(a,t.prototype),a}return(0,s.c)(t,e),Object.defineProperty(t,"storeNotDefined",{get:function(){return new t({code:nL.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailable",{get:function(){return new t({code:nL.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotAvailableInPrivateBrowsing",{get:function(){return new t({code:nL.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeIsFull",{get:function(){return new t({code:nL.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:nL.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:nL.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenIntegrity",{get:function(){return new t({code:nL.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeBrokenBlob",{get:function(){return new t({code:nL.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeEncryptionInvalid",{get:function(){return new t({code:nL.STORE_ENCRYPTION_INVA
1LID,message:"Encryption algorithm has changed. All the store should reset."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeItemSizeExceeded",{get:function(){return new t({code:nL.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeReadFailed",{get:function(){return new t({code:nL.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:nL.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:nL.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionNotReady",{get:function(){return new t({code:nL.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotMatch",{get:function(){return new t({code:nL.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionQueryNotValid",{get:function(){return new t({code:nL.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionInsertDuplicate",{get:function(){return new t({code:nL.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:nL.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:nL.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionWriteFailed",{get:function(){return new t({code:nL.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:nL.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTableIsRequired",{get:function(){return new t({code:nL.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:nL.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"compareTypesNotMatch",{get:function(){return new t({code:nL.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"circularReferenceFound",{get:function(){return new t({code:nL.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})},enumerable:!1,configurable:!0}),t}(Error);(n2=n0||(n0={})).INIT="init",n2.READY="ready",n2.CLOSED="closed";var n2,n3,n4=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){var n;if(t.has(e))throw n1.circularReferenceFound;return t.set(e,!0),Array.isArray(e)?n=e.map(function(e){return n4(e,t)}):e instanceof RegExp||e instanceof Date?n=e:(n={},Object.keys(e).forEach(function(r){n[r]=n4(e[r],t)})),t.delete(e),n}return e},n5=function(e,t){if(null==t)return 1;if(null==e)return -1;if(typeof e!=typeof t)throw n1.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},n6=function(e,t){for(var n=0,r=0;r<e.length;r++)n=e.charCodeAt(r)+(n<<6)+(n<<16)-n;return(n>>>0)%t},n7=function(e){return new Promise(function(t){setTimeout(function(){return t()},e)})},n8=function(e,t){if(!t)return!1;if("function"!=typeof e){for(var n in e)if(["/and","&&"].includes(n)){if(e[n].some(function(e){return!n8(e,t)}))return!1}else if(["/or","||"].includes(n)){if(e[n].every(function(e){return!n8(e,t)}))return!1}else if("/where"===n){if(!(0,e[n])(t))return!1}else if("object"==typeof e[n]){var r=e[n];for(var i in r)switch(i){case"/eq":case"=":if((s=t[n])!==(a=r[i]))return!1;break;case"/neq":case"!=":if((s=t[n])===(a=r[i]))return!1;break;case"/gt":case">":var s=t[n],a=r[i];if(!(n5(s,a)>0))return!1;break;case"/gte":case">=":if(!(n5(s=t[n],a=r[i])>=0))return!1;break;case"/lt":case"<":if(!(0>n5(s=t[n],a=r[i])))return!1;break;case"/lte":case"<=":if(!(0>=n5(s=t[n],a=r[i])))return!1;break;case"/in":if(s=t[n],!(a=r[i]).includes(s))return!1;break;case"/nin":if(s=t[n],(a=r[i]).includes(s))return!1;break;case"/contain":if(s=t[n],a=r[i],!s.includes(a))return!1;break;case"/regex":if(s=t[n],!(a=r[i]).test(s))return!1;break;case"/where":if(s=t[n],!(0,r[i])(s))return!1}}else if("function"==typeof e[n]){if(!e[n](t[n]))return!1}else if(e[n]!==t[n])return!1;return!0}return e(t)},n9=function(){},re=function(){return Promise.resolve()},rt=function(e){return e},rn=function(e,t){t()};(rr=n3||(n3={}))[rr.FORWARD=0]="FORWARD",rr[rr.BACKWARD=1]="BACKWARD";var rr,ri,rs,ra,ro=function(){function e(e){var t=e.initialPrevValue,n=e.initialNextValue,r=e.iterator,i=e.map,s=e.backward,a=e.forward,o=e.complete;this._prevValue=void 0===t?null:t,this._nextValue=void 0===n?null:n,this._error=null,this._map=void 0===i?rt:i,this._backward=void 0===s?re:s,this._forward=void 0===a?re:a,this._iterator=r,this._complete=void 0===o?n9:o}return Object.defineProperty(e.prototype,"prevValue",{get:function(){return this._map(this._prevValue)}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextValue",{get:function(){return this._map(this._nextValue)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"error",{get:function(){return this._error},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPrevious",{get:function(){return!!this._prevValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNext",{get:function(){return!!this._nextValue},enumerable:!1,configurable:!0}),e.prototype.prev=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:if(!this.hasPrevious)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._prevValue,t=this,[4,this._backward()];case 2:return t._prevValue=r.sent()||null,this._nextValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}})})},e.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:if(!this.hasNext)return[3,6];r.label=1;case 1:return r.trys.push([1,3,,4]),e=this._nextValue,t=this,[4,this._forward()];case 2:return t._nextValue=r.sent()||null,this._prevValue=e,[3,4];case 3:return n=r.sent(),this._error=n,[3,4];case 4:return[4,this._iterator(this)];case 5:return[2,r.sent()];case 6:this._complete(),r.label=7;case 7:return[2]}})})},e.prototype.stop=function(){this._prevValue=null,this._nextValue=null,this._complete()},e}(),ru=function(){function e(e){var t=e.condition,n=e.backward,r=e.blockManager,i=e.indexer;this.condition=void 0===t?{}:t,this.backward=void 0!==n&&n,this._blockManager=r,this._indexer=i}return e.prototype.findOptimizedStartPosition=function(){var e=this,t=["=","/eq",">",">=","/gt","/gte"],n=["=","/eq","<","<=","/lt","/lte"];if(this.backward){var r=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(h=0;h<this._indexer.fields.length;h++){var i=this._indexer.fields[h],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),this.condition[i]){if("object"==typeof this.condition[i]){var a=s>0?n:t;for(var o in this.condition[i])if(a.includes(o)){for(var u=r;u>=0;u--)if(s*n5(this._indexer.origin[u].columnValues[h],this.condition[i][o])<=0){r=u;break}}}else for(u=r;u>=0;u--)if(s*n5(this._indexer.origin[u].columnValues[h],this.condition[i])<=0){r=u;break}}}return Math.min(r+1,this._indexer.origin.length-1)}var c=0;if("function"!=typeof this.condition)for(var l=function(r){var i=d._indexer.fields[r],s=1;if("-"===i[0]&&(i=i.slice(1),s=-1),d.condition[i]){if("object"==typeof d.condition[i])Object.keys(d.condition[i]).forEach(function(a){if((s>0?t:n).includes(a)){for(var o=c;o<e._indexer.origin.length;o++)if(s*n5(e._indexer.origin[o].columnValues[r],e.condition[i][a])>=0){c=o;break}}});else for(var a=c;a<d._indexer.origin.length;a++)if(s*n5(d._indexer.origin[a].columnValues[r],d.condition[i])>=0){c=a;break}}},d=this,h=0;h<this._indexer.fields.length;h++)l(h);return Math.max(c-1,0)},e.prototype.each=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c=this;return(0,s.b)(this,function(l){switch(l.label){case 0:if(t=this.findOptimizedStartPosition(),n=0,this.backward&&this._indexer.origin[t]&&(n=this._indexer.origin[t].keys.length-1),r=function(){if(c._indexer.origin[t]){if(!c._indexer.origin[t].keys[++n]){if(!c._indexer.origin[++t])return!1;n=0}return!0}return!1},i=function(){if(c._indexer.origin[t]){if(!c._indexer.origin[t].keys[--n]){if(!c._indexer.origin[--t])return!1;n=c._indexer.origin[t].keys.length-1}return!0}return!1},a=null,!this._indexer.origin[t])return[3,4];o=this.backward?i:r,l.label=1;case 1:return[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])];case 2:if((u=l.sent())&&n8(this.condition,u))return a=u,[3,4];l.label=3;case 3:if(o())return[3,1];l.label=4;case 4:return[4,new Promise(function(o){var u=new ro({initialNextValue:n4(a),iterator:e,forward:function(){return(0,s._)(c,void 0,void 0,function(){var e,a;return(0,s.b)(this,function(s){switch(s.label){case 0:e=this.backward?
1i:r,s.label=1;case 1:return e()?[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])]:[3,3];case 2:return(a=s.sent())&&n8(this.condition,a)?[2,n4(a)]:[3,1];case 3:return[2,null]}})})},backward:function(){return(0,s._)(c,void 0,void 0,function(){var e,a;return(0,s.b)(this,function(s){switch(s.label){case 0:e=this.backward?r:i,s.label=1;case 1:return e()?[4,this._blockManager.getFromBlock(this._indexer.origin[t].keys[n])]:[3,3];case 2:return(a=s.sent())&&n8(this.condition,a)?[2,n4(a)]:[3,1];case 3:return[2,null]}})})},complete:o});e(u)})];case 5:return[2,l.sent()]}})})},e}(),rc=function(){function e(e){var t=e.condition,n=e.backward,r=e.mutex,i=e.blockManager,s=e.indexer;this._mutex=r,this._iterator=new ru({condition:void 0===t?{}:t,backward:void 0!==n&&n,blockManager:i,indexer:s}),this._indexer=s}return Object.defineProperty(e.prototype,"indexer",{get:function(){return this._indexer},enumerable:!1,configurable:!0}),e.prototype.fetch=function(e){return void 0===e&&(e={}),(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a=this;return(0,s.b)(this,function(o){switch(o.label){case 0:if(t=Math.max(e.offset||0,0),0===(n="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER))return[2,[]];if(n<0)throw n1.collectionQueryNotValid;o.label=1;case 1:return o.trys.push([1,4,,5]),r=[],[4,this._mutex.lock()];case 2:return o.sent(),[4,this._iterator.each(function(e){return(0,s._)(a,void 0,void 0,function(){return(0,s.b)(this,function(i){return e.error?e.stop():e.hasNext?0===t?(r.push(e.nextValue),0<n&&n<=r.length?e.stop():e.next()):(t--,e.next()):e.stop(),[2]})})})];case 3:return o.sent(),this._mutex.unlock(),[2,r];case 4:throw i=o.sent(),this._mutex.unlock(),i;case 5:return[2]}})})},e.prototype.count=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e=0,[4,this._mutex.lock()];case 1:return r.sent(),[4,this._iterator.each(function(t){return(0,s._)(n,void 0,void 0,function(){return(0,s.b)(this,function(n){return t.error?t.stop():t.hasNext?(e++,t.next()):t.stop(),[2]})})})];case 2:return r.sent(),this._mutex.unlock(),[2,e];case 3:throw t=r.sent(),this._mutex.unlock(),t;case 4:return[2]}})})},e}(),rl=function(e){return"".concat("nest","@").concat(e)},rd=function(e,t){return"".concat(rl(e),"/").concat(t)},rh=function(e,t){return"".concat(rd(e,t),".metadata")},rf=function(e,t){return"".concat(rd(e,t),"/block.")},rp=function(e,t){return"".concat(rd(e,t),"/blob.")},rm=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this.dbname=t,this.collectionName=n,this.store=r}return e.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,this.store.get(e)];case 1:return(t=s.sent())?(n=t.data,r=t.type,"undefined"==typeof fetch?[3,4]:[4,fetch(n)]):[3,5];case 2:return[4,s.sent().blob()];case 3:return[2,s.sent()];case 4:for(i=[],a=atob(n.split(",")[1]),o=0;o<a.length;o+=512){for(c=Array((u=a.slice(o,o+512)).length),l=0;l<u.length;l++)c[l]=u.charCodeAt(l);i.push(new Uint8Array(c))}return[2,new Blob(i,{type:r})];case 5:return[2,null]}})})},e.prototype.save=function(e,t){return void 0===t&&(t="".concat(Date.now())),(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,new Promise(function(n){var r,i,s,a,u=(r=o.dbname,i=o.collectionName,s=t,void 0===a&&(a=0),"".concat(rp(r,i)).concat(s,".").concat(a)),c=new FileReader;c.onload=function(){n({blobId:u,data:c.result,type:e.type})},c.readAsDataURL(e)})];case 1:return r=(n=s.sent()).blobId,i=n.data,a=n.type,[4,this.store.set({key:r,value:{data:i,type:a}})];case 2:return s.sent(),[2,r]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this.store.remove(e)
1];case 1:return t.sent(),[2]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e,t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=rp(this.dbname,this.collectionName),[4,this.store.getAllKeys()];case 1:return[4,Promise.all(n.sent().filter(function(t){return t.startsWith(e)}).map(function(e){return(0,s._)(t,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this.store.remove(e)];case 1:return[2,t.sent()]}})})}))];case 2:return n.sent(),[2]}})})},e}();(r_=ri||(ri={}))[r_.COMMIT=0]="COMMIT",r_[r_.WRITE=1]="WRITE",r_[r_.ERROR=2]="ERROR",(rv=rs||(rs={})).PENDING="pending",rv.PERSISTENT="persistent",rv.VOLATILE="volatile",(ry=ra||(ra={}))[ry.NO_CACHE=0]="NO_CACHE",ry[ry.DEFAULT=1]="DEFAULT",ry[ry.PERSISTENT=2]="PERSISTENT";var r_,rv,ry,rg,rb,rI=[rs.PENDING,rs.VOLATILE],rE={},rw=function(){function e(e){var t=e.dbname,n=e.limit;return rE[t]||(this.dbname=t,this._items=[],this._limit=void 0===n?256:n,rE[t]=this),rE[t]}return e.get=function(e){return rE[e]},Object.defineProperty(e.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),e.prototype.find=function(e,t,n){return void 0===n&&(n=ra.DEFAULT),(0,s._)(this,void 0,void 0,function(){var r,i;return(0,s.b)(this,function(s){switch(s.label){case 0:return(r=this.get(t))?[3,2]:[4,e.get(t)];case 1:return(i=s.sent())&&(r={key:t,value:i,state:n===ra.PERSISTENT?rs.PERSISTENT:rs.VOLATILE},this.put(r)),[3,3];case 2:n===ra.PERSISTENT&&(r.state=rs.PERSISTENT),s.label=3;case 3:return[2,r]}})})},e.prototype.get=function(e,t){void 0===t&&(t=ra.DEFAULT);var n=this._items.map(function(e){return e.key}).indexOf(e);if(n>-1){var r=this._items[n];return t===ra.PERSISTENT&&(r.state=rs.PERSISTENT),t!==ra.NO_CACHE&&this.put(r),r}return null},e.prototype.put=function(e){var t,n;if(this._limit>0){var r=this._items.map(function(e){return e.key}).indexOf(e.key);if(r>-1)rI.includes(this._items[r].state)&&rI.includes(e.state)?(this._items.splice(r,1),this._items.push(e)):(this._items[r].state=e.state,this._items[r].value=e.value);else{this._items.push(e);var i=this._items.filter(function(e){return e.state===rs.VOLATILE}).length-this._limit;if(i>0){var a=[];try{for(var o=(0,s.w)(this._items),u=o.next();!u.done;u=o.next()){var c=u.value;c.state===rs.VOLATILE&&i>0?i--:a.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this._items=a}}}},e.prototype.remove=function(e){var t=this._items.map(function(e){return e.key}).indexOf(e);t>-1&&this._items.splice(t,1)},e.prototype.clearByCondition=function(e){this._items=this._items.filter(function(t){return!e(t)})},e.prototype.clearForDatabase=function(e){this.clearByCondition(function(t){return t.key.startsWith(rl(e))})},e.prototype.clear=function(e){void 0===e&&(e=!1),this._items=e?[]:this._items.filter(function(e){return e.state!==rs.VOLATILE})},e}(),rT=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.store;this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=t,this.collectionName=n,this.metadataKey="".concat(rd(t,n),"/trans.metadata"),this.recordsetKey="".concat(rd(t,n),"/trans.recordset"),this._store=r}return Object.defineProperty(e.prototype,"generation",{get:function(){return this._metadata?this._metadata.generation:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"requestCount",{get:function(){return this._requests.length},enumerable:!1,configurable:!0}),e.prototype._getReducedRecordset=function(e){return void 0===e&&(e=[]),(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._store.get(this.recordsetKey)];case 1:return(t=n.sent()||[]).push.apply(t,(0,s.q)([],(0,s.r)(e),!1)),[2,this._reduceRecordSet(t)]}})})},e.prototype._reduceRecordSet=function(e){for(var t=[],n={},r=e.length-1;r>=0;r--){for(var i=e[r],s=[],a=i.requests.length-1;a>=0;a--){var o=i.requests[a],u=o.data;n[u.key]||(s.unshift(o),n[u.key]=!0)}s.length>0&&(i.requests=s,t.unshift(i))}return t},e.prototype._applyRecord=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l;return(0,s.b)(this,function(d){switch(d.label){case 0:n=rw.get(this.dbname),r=t.generation,i=t.requests,a=null,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this._store.setMany(i.map(function(e){return(0,s.d)((0,s.d)({},e.data),{generation:r})}))];case 2:for(o=d.sent(),u=0;u<i.length;u++)o[u]instanceof Error&&(a||(a=o[u]),c=i[u].data,n.put((0,s.d)((0,s.d)({},c),{state:rs.PERSISTENT})));return[3,4];case 3:return a=d.sent(),[3,4];case 4:return a?[3,6]:(l=e.filter(function(e){return e.generation!==r}),[4,this._store.set({key:this.recordsetKey,value:l})]);case 5:return d.sent(),this._onWrite.forEach(function(e){e(i.map(function(e){return e.data}))}),[3,7];case 6:this._onError.forEach(function(e){a&&e(a)}),d.label=7;case 7:return[2]}})})},e.prototype.init=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return e=this,[4,this._store.get(this.metadataKey)];case 1:return e._metadata=u.sent()||{generation:1},[4,this._getReducedRecordset()];case 2:t=u.sent(),u.label=3;case 3:u.trys.push([3,8,9,10]),r=(n=(0,s.w)(t)).next(),u.label=4;case 4:return r.done?[3,7]:(i=r.value,[4,this._applyRecord(t,i)]);case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return a={error:u.sent()},[3,10];case 9:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(a)throw a.error}
1return[7];case 10:return[2]}})})},e.prototype.on=function(e,t,n){switch(e){case ri.COMMIT:this._onCommit.set(t,n);break;case ri.WRITE:this._onWrite.set(t,n);break;case ri.ERROR:this._onError.set(t,n)}},e.prototype.requestWrite=function(e,t){this._requests.push({data:e,options:t}),rw.get(this.dbname).put((0,s.d)({state:rs.PENDING},e))},e.prototype.requestMultipleWrite=function(e,t){var n,r,i=rw.get(this.dbname);try{for(var a=(0,s.w)(e),o=a.next();!o.done;o=a.next()){var u=o.value;this._requests.push({data:u,options:t}),i.put((0,s.d)({state:rs.PENDING},u))}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return rw.get(this.dbname).clearByCondition(function(e){return e.state===rs.PENDING}),this._requests=[],[2]})})},e.prototype.commit=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d,h=this;return(0,s.b)(this,function(f){switch(f.label){case 0:if(!((e=this._requests).length>0))return[3,4];for(t=[],n={},u=e.length-1;u>=0;u--)n[(l=(r=e[u]).data).key]||(n[l.key]=!0,t.unshift(r));return i={generation:this.generation,requests:t},[4,this._getReducedRecordset([i])];case 1:return a=f.sent(),[4,this._store.set({key:this.recordsetKey,value:a})];case 2:return f.sent(),this._metadata.generation++,[4,this._store.set({key:this.metadataKey,value:this._metadata})];case 3:for(f.sent(),o=rw.get(this.dbname),u=0;u<t.length;u++)l=(c=t[u]).data,d=c.options,o.put((0,s.d)((0,s.d)({},l),{state:d&&d.persistent?rs.PERSISTENT:rs.VOLATILE}));this._requests=[],this._onCommit.forEach(function(t){t(e.map(function(e){return e.data}))}),setTimeout(function(){try{h._applyRecord(a,i)}catch(e){h._onError.forEach(function(t){return t(e)})}},nZ.get(this.dbname).transactionApplyDelay),f.label=4;case 4:return[2]}})})},e}(),rS=function(){function e(e){var t=e.blockId,n=e.keyName,r=e.items,i=e.limit;this.blockId=t,this.keyName=n,this.limit=i,this._items=(0,s.q)([],(0,s.r)(void 0===r?[]:r),!1)}return e.createFromCacheItem=function(t){return t?new e(t.value):null},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this._items.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},enumerable:!1,configurable:!0}),e.prototype.serialize=function(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}},e.prototype.getItemByKey=function(e){var t=this,n=this._items.find(function(n){return e===n[t.keyName]});return null!=n?n:null},e.prototype.has=function(e){var t=this;return this._items.map(function(e){return e[t.keyName]}).includes(e)},e.prototype.add=function(e){var t=this,n=this._items.map(function(e){return e[t.keyName]}).indexOf(e[this.keyName]);return n<0?this._items.length<this.limit&&(this._items.push(e),!0):(this._items[n]=e,!0)},e.prototype.remove=function(e){for(var t=0;t<this._items.length;t++)if(this._items[t][this.keyName]===e)return this._items.splice(t,1),!0;return!1},e.prototype.clear=function(){this._items=[]},e}(),rA=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.metadata,i=e.hashFunction,s=void 0===i?n6:i,a=e.transaction,o=e.store;this.dbname=t,this.collectionName=n,this.hashFunction=s,this.metadata=r,this._transaction=a,this._store=o}return Object.defineProperty(e.prototype,"keyName",{get:function(){return this.metadata.keyName},enumerable:!1,configurable:!0}),e.prototype.createBlockId=function(e,t){var n,r,i,s,a,o,u;return void 0===t&&(t=this.metadata.blockLevel),n=this.dbname,r=this.collectionName,i=t,s="".concat((a=t,u=(o={hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant}).base*Math.pow(o.multiplier,a)+o.constant,(o.hashFunction||n6)(e,u))),"".concat(rf(n,r)).concat(i,".").concat(s)},e.prototype._findBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:t=rw.get(this.dbname),n=this.metadata.blockLevel,s.label=1;case 1:return n>0?(r=this.createBlockId(e,n),[4,t.find(this._store,r)]):[3,4];case 2:if((i=s.sent())&&(null==(a=rS.createFromCacheItem(i))?void 0:a.getItemByKey(e)))return[2,a];s.label=3;case 3:return n--,[3,1];case 4:return[2,null]}})})},e.prototype.getFromBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return[2,(t=n.sent())?t.getItemByKey(e):null]}})})},e.prototype.putToBlock=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o;return(0,s.b)(this,function(s){switch(s.label){case 0:return n=nZ.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,rw.get(this.dbname).find(this._store,r)];case 1:return(null==(o=(a=s.sent())?rS.createFromCacheItem(a):new rS({blockId:r,keyName:this.keyName,items:[],limit:i}))?void 0:o.add(t))?(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),[2,!0]):[2,!1]}})})},e.prototype.removeFromBlock=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._findBlock(e)];case 1:return(t=n.sent())&&t.remove(e)?(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),[2,!0]):[2,!1]}})})},e.prototype.clearAllBlocks=function(){return(0,s._)(this,void 0,void 0,function(){var e,t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e=rf(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 1:return t=n.sent().filter(function(t){return t.startsWith(e)}),[4,this._store.removeMany(t)];case 2:return n.sent(),[4,this._transaction.clear()];case 3:return n.sent(),rw.get(this.dbname).clearByCondition(function(t){return t.key.startsWith(e)}),[2]}})})},e}(),rM=function(){function e(e){var t,n=e.dbname,r=e.collectionName,i=e.keyName,s=e.fields,a=e.transaction,o=e.store,u=e.mutex,
1c=this;this._origin=[],this._table=[],this.restoreInterval=1e3;var l=(t=s.join(">"),"".concat(rd(n,r),"/index.").concat(t));this.dbname=n,this.collectionName=r,this.keyName=i,this.fields=s,this.indexerKey=l,this._store=o,this._transaction=a,this._transaction.on(ri.COMMIT,this.indexerKey,function(){return c.commit()}),this._transaction.on(ri.ERROR,this.indexerKey,function(){return c.abort()}),this._lastRestoreIndexerTime=0,this._isRestoringIndexer=!1,this._mutex=u}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=(0,s.r)(this.indexOf(n),2),i=r[0];return r[1]?!this._table[i].keys.includes(t)&&(this._table[i].keys.push(t),!0):(this._table.splice(i,0,{columnValues:n,keys:[t]}),!0)},e.prototype._removeItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=(0,s.r)(this.indexOf(n),2),i=r[0];if(r[1]){var a=this._table[i].keys.indexOf(t);if(a>-1)return this._table[i].keys.splice(a,1),0===this._table[i].keys.length&&this._table.splice(i,1),!0}return!1},Object.defineProperty(e.prototype,"origin",{get:function(){return this._origin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"table",{get:function(){return this._table},enumerable:!1,configurable:!0}),e.prototype.getColumnValues=function(e){var t,n,r,i,a=[];try{for(var o=(0,s.w)(this.fields),u=o.next();!u.done;u=o.next()){var c=u.value;if("-"===c[0]&&(c=c.slice(1)),r=e[c],i=void 0,i=typeof r,null!==r&&"undefined"!==i&&"boolean"!==i&&"number"!==i&&"string"!==i)throw n1.indexTypesNotMatch;a.push(e[c])}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return a},e.prototype.diff=function(e,t){for(var n in this.fields){var r="-"===this.fields[n][0]?-1:1,i=n5(e[n],t[n]);if(0!==i)return r*i}return 0},e.prototype.indexOf=function(e){return this._indexOfInTable(this._table,e)},e.prototype._indexOfInTable=function(e,t){if(e.length>0){for(var n=0,r=e.length-1;n<=r;){var i=Math.floor((n+r)/2),s=this.diff(t,e[i].columnValues);if(s>0)n=i+1;else{if(!(s<0))return[i,!0];r=i-1}}return[n,!1]}return[0,!1]},e.prototype.ensure=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d,h,f,p,m,_;return(0,s.b)(this,function(v){switch(v.label){case 0:return[4,(e=rw.get(this.dbname)).find(this._store,this.indexerKey,ra.PERSISTENT)];case 1:return(t=v.sent())?[3,11]:(n=rf(this.dbname,this.collectionName),[4,this._store.getAllKeys()]);case 2:r=v.sent(),v.label=3;case 3:v.trys.push([3,8,9,10]),a=(i=(0,s.w)(r)).next(),v.label=4;case 4:return a.done?[3,7]:(o=a.value).startsWith(n)?[4,e.find(this._store,o,ra.NO_CACHE)]:[3,6];case 5:if(u=v.sent(),c=rS.createFromCacheItem(u))try{for(m=void 0,d=(l=(0,s.w)(c.items)).next();!d.done;d=l.next())h=d.value,this._addItem(h)}catch(e){m={error:e}}finally{try{d&&!d.done&&(_=l.return)&&_.call(l)}finally{if(m)throw m.error}}v.label=6;case 6:return a=i.next(),[3,4];case 7:return[3,10];case 8:return f={error:v.sent()},[3,10];case 9:try{a&&!a.done&&(p=i.return)&&p.call(i)}finally{if(f)throw f.error}return[7];case 10:return this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[3,12];case 11:this._origin=t.value,this._table=n4(this._origin),v.label=12;case 12:return[2]}})})},e.prototype.restoreIndexer=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u,c,l,d,h,f,p,m,_,v,y,g,b,I,E,w,T,S,A,M,U,N,C,k,O,P,x,R,D,L,F,q,z,j,V;return(0,s.b)(this,function(B){switch(B.label){case 0:if(e=Date.now(),this._isRestoringIndexer||e-this._lastRestoreIndexerTime<this.restoreInterval)return[2];B.label=1;case 1:return B.trys.push([1,,13,14]),this._mutex.lock(),this._isRestoringIndexer=!0,this._lastRestoreIndexerTime=e,[4,this._store.get(this.indexerKey)];case 2:(t=B.sent())?(this._origin=t,this._table=n4(this._origin)):this._table=[],n=new Set;try{for(i=(r=(0,s.w)(this._table)).next();!i.done;i=r.next()){a=i.value;try{for(P=void 0,u=(o=(0,s.w)(a.keys)).next();!u.done;u=o.next())M=u.value,n.add(M)}catch(e){P={error:e}}finally{try{u&&!u.done&&(x=o.return)&&x.call(o)}finally{if(P)throw P.error}}}}catch(e){k={error:e}}finally{try{i&&!i.done&&(O=r.return)&&O.call(r)}finally{if(k)throw k.error}}return c=rf(this.dbname,this.collectionName),[4,this._store.getAllKeys()];case 3:l=B.sent(),d=new Set,h=new Map,B.label=4;case 4:B.trys.push([4,9,10,11]),p=(f=(0,s.w)(l)).next(),B.label=5;case 5:return p.done?[3,8]:(M=p.value).startsWith(c)?[4,this._store.get(M)]:[3,7];case 6:if(_=(m=B.sent())?rS.createFromCacheItem({key:M,value:m,state:rs.VOLATILE}):null)try{for(L=void 0,y=(v=(0,s.w)(_.items)).next();!y.done;y=v.next())g=(A=y.value)[this.keyName],d.add(g),h.set(g,A)}catch(e){L={error:e}}finally{try{y&&!y.done&&(F=v.return)&&F.call(v)}finally{if(L)throw L.error}}B.label=7;case 7:return p=f.next(),[3,5];case 8:return[3,11];case 9:return R={error:B.sent()},[3,11];case 10:try{p&&!p.done&&(D=f.return)&&D.call(f)}finally{if(R)throw R.error}
1return[7];case 11:if(0===d.size)return[2];b=!1,I=[];try{for(w=(E=(0,s.w)(d)).next();!w.done;w=E.next())M=w.value,n.has(M)||(b=!0,console.warn("Indexer restore: missed key detected - ".concat(M)),(A=h.get(M))&&I.push(A))}catch(e){q={error:e}}finally{try{w&&!w.done&&(z=E.return)&&z.call(E)}finally{if(q)throw q.error}}if(!b)return[2];try{for(S=(T=(0,s.w)(I)).next();!S.done;S=T.next())M=(A=S.value)[this.keyName],U=this.getColumnValues(A),C=(N=(0,s.r)(this._indexOfInTable(this._table,U),2))[0],N[1]?this._table[C].keys.includes(M)||this._table[C].keys.push(M):this._table.splice(C,0,{columnValues:U,keys:[M]})}catch(e){j={error:e}}finally{try{S&&!S.done&&(V=T.return)&&V.call(T)}finally{if(j)throw j.error}}return[4,this._store.set({key:this.indexerKey,value:this._table})];case 12:return B.sent(),rw.get(this.dbname).put({key:this.indexerKey,value:this._table,state:rs.PERSISTENT}),this._origin=n4(this._table),[3,14];case 13:return this._isRestoringIndexer=!1,this._mutex.unlock(),[7];case 14:return[2]}})})},e.prototype.drop=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return rw.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),[2]}})})},e.prototype.addItem=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.removeItem=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0}),[2]})})},e.prototype.commit=function(){this._origin=this._table,this._table=n4(this._origin)},e.prototype.abort=function(){this._table=n4(this._origin)},e}(),rU=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},rN=function(){var e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?n:3&n|8).toString(16)})};(rC=rg||(rg={}))[rC.PROCESSING=0]="PROCESSING",rC[rC.DONE=1]="DONE",(rk=rb||(rb={})).NEWNODE="newnode",rk.REMOVENODE="removenode",rk.CLAIM_HOST="claimhost",rk.SYNC_HOST="synchost",rk.REQUEST_LOCK="requestlock",rk.ACQUIRE_LOCK="acquirelock",rk.RELEASE_LOCK="releaselock";var rC,rk,rO,rP={},rx=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=rg.PROCESSING,this._queue=[],this._activationQueue=[],rP[e]&&!t.forceCreate||(this.nodeId=rN(),this.key=e,rU()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",function(){"visible"===document.visibilityState&&n.claimHost()}),window.addEventListener("message",function(e){var t,r,i=e.data;if(null==i?void 0:i.isNestDbMessage){var a=i.nodeId,o=i.requestId,u=i.key,c=i.op,l=i.data;if(a!==n.nodeId&&u===n.key)switch(c){case rb.NEWNODE:n._sendSync();break;case rb.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case rb.SYNC_HOST:if(!n.isInSync){n._activationTimeout&&clearTimeout(n._activationTimeout);var d=l.currentItemRequestId,h=l.queue,f=function(e){0>n._queue.findIndex(function(t){return t.requestId===e.requestId})&&n._requestLock({isNestDbMessage:!0,nodeId:e.nodeId,requestId:e.requestId,key:n.key,op:rb.REQUEST_LOCK,ts:e.ts})};try{for(var p=(0,s.w)(h),m=p.next();!m.done;m=p.next())f(m.value)}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}n._currentItem=n._queue.find(function(e){return e.requestId===d}),n._completeSync()}break;case rb.REMOVENODE:n._queue=n._queue.filter(function(e){return e.nodeId!==i.nodeId}),n._currentItem&&n._currentItem.nodeId===i.nodeId&&(n._currentItem=void 0,n._acquire(n._queue[0]));break;case rb.REQUEST_LOCK:n._requestLock(i);break;case rb.ACQUIRE_LOCK:var _=n._queue.find(function(e){return e.requestId===o});n._acquire(_);break;case rb.RELEASE_LOCK:n._release(o)}}}),window.addEventListener("beforeunload",function(){n._send(rb.REMOVENODE)})),rP[e]=this),rP[e]}return Object.defineProperty(e.prototype,"locked",{get:function(){return!!this._currentItem}
1,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHost",{get:function(){return this._hostId===this.nodeId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInSync",{get:function(){return this._state==rg.DONE},enumerable:!1,configurable:!0}),e.prototype._send=function(e,t){void 0===t&&(t={});var n,r={isNestDbMessage:!0,nodeId:this.nodeId,requestId:null!==(n=null==t?void 0:t.requestId)&&void 0!==n?n:rN(),key:this.key,op:e,data:t.data,ts:Date.now()};return rU()&&window.postMessage(r,"*"),r},e.prototype._acquire=function(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0},e.prototype._release=function(e){if(this._currentItem&&this._currentItem.requestId===e){var t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(rb.RELEASE_LOCK,{requestId:t.requestId});var n=this._queue.findIndex(function(t){return t.requestId===e});n>-1&&this._queue.splice(n,1),t.onReleased&&t.onReleased(e)}},e.prototype._requestLock=function(e){var t=this;return new Promise(function(n){for(var r={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:function(e){t.isHost&&t._send(rb.ACQUIRE_LOCK,{requestId:e}),n()},onReleased:function(){t._acquire(t._queue[0])}},i=!1,s=0;s<t._queue.length;s++)if(t._queue[s].ts>r.ts){t._queue.splice(s,0,r),i=!0;break}i||t._queue.push(r),t._currentItem||t._acquire(t._queue[0])})},e.prototype._sendSync=function(){var e;this.isHost&&this._send(rb.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map(function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}})}})},e.prototype._waitUntilSyncCompleted=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){return this.isHost&&!this.isInSync?[2,new Promise(function(t){e._activationQueue.push(t)})]:[2]})})},e.prototype._waitSync=function(){var e=this;this.isInSync||(this._activationTimeout=setTimeout(function(){e._completeSync()},8))},e.prototype._completeSync=function(){this.isInSync||(this._state=rg.DONE,this._activationQueue.forEach(function(e){return e()}),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(rb.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(rb.CLAIM_HOST),this._waitSync()},e.prototype.lock=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._waitUntilSyncCompleted()];case 1:return t.sent(),e=this._send(rb.REQUEST_LOCK),[4,this._requestLock(e)];case 2:return t.sent(),[2]}})})},e.prototype.unlock=function(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)},e}(),rR=function(){function e(e){var t=e.dbname,n=e.collectionName,r=e.keyName,i=e.keyHash,a=e.indexes,o=e.store,u=this;this._state=n0.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=(0,s.q)([[r]],(0,s.r)(a.filter(function(e){return rM.createKey(e)!==u.keyName})),!1),this._keyHash=i,this._store=o,this._mutex=new rx("".concat(rd(t,n),".lock")),this._blobContainer=new rm({dbname:t,collectionName:n,store:o}),this._transaction=new rT({dbname:t,collectionName:n,store:o})}return e.metadataOf=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r;return(0,s.b)(this,function(i){switch(i.label){case 0:return r=rh(e,t),[4,n.get(r)];case 1:return[2,i.sent()]}})})},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._state===n0.READY},enumerable:!1,configurable:!0}),e.prototype.init=function(){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p,m,_=this;return(0,s.b)(this,function(v){switch(v.label){case 0:return[4,this._mutex.lock()];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,9,,10]),t=nZ.get(this.dbname),[4,e.metadataOf(this.dbname,this.name,this._store)];case 3:return n=v.sent(),this._metadata=n||{keyName:this.keyName,blockLevel:1,blockHashBase:t.blockHashBase,blockHashMultiplier:t.blockHashMultiplier,blockHashConstant:t.blockHashConstant,indexes:this.indexes},[4,this._transaction.init()];case 4:v.sent(),this._blockManager=new rA({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=(0,s.q)([],(0,s.r)(this.indexes),!1),i=[],a=r.map(function(e){return rM.createKey(e)}),o=n?n.indexes.map(function(e){return rM.createKey(e)}):[];try{for(c=(u=(0,s.w)(o)).next();!c.done;c=u.next())l=c.value,a.includes(l)||i.push(rM.parseKey(l))}catch(e){p={error:e}}finally{try{c&&!c.done&&(m=u.return)&&m.call(u)}finally{if(p)throw p.error}}return(d=[]).push.apply(d,(0,s.q)([],(0,s.r)(r.map(function(e){var t=new rM({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store,mutex:_._mutex});return _._indexers.push(t),t.ensure()})),!1)),d.push.apply(d,(0,s.q)([],(0,s.r)(i.map(function(e){return new rM({dbname:_.dbname,collectionName:_.name,keyName:_.keyName,fields:e,transaction:_._transaction,store:_._store,mutex:_._mutex}).drop()})),!1)),[4,Promise.all(d)];case 5:return v.sent(),[4,this._transaction.commit()];case 6:return v.sent(),a.sort().join(",")===o.sort().join(",")?[3,8]:(h=rh(this.dbname,this.name),this._metadata.indexes=r,[4,this._store.set({key:h,value:this._metadata})]);case 7:v.sent(),v.label=8;case 8:return this._state=n0.READY,this._mutex.unlock(),[3,10];
1case 9:throw f=v.sent(),this._mutex.unlock(),f;case 10:return[2]}})})},e.prototype.close=function(){this._state=n0.CLOSED},e.prototype._hasPropertyOfKeyName=function(e){var t=e[this.keyName];return"string"==typeof t&&!!t},e.prototype._getIndexerBy=function(e){void 0===e&&(e=null),e||(e=[this.keyName]);var t,n,r=rM.createKey(e);try{for(var i=(0,s.w)(this._indexers),a=i.next();!a.done;a=i.next()){var o=a.value;if(r===rM.createKey(o.fields))return o}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw n1.indexTableIsRequired},e.prototype._upgradeBlockLevel=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return e=rh(this.dbname,this.name),this._metadata.blockLevel++,[4,this._store.set({key:e,value:this._metadata})];case 1:return t.sent(),[2]}})})},e.prototype._requestInsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return o.sent()?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return o.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return o.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:o.sent(),o.label=5;case 5:o.trys.push([5,10,11,12]),r=(n=(0,s.w)(this._indexers)).next(),o.label=6;case 6:return r.done?[3,9]:[4,r.value.addItem(e)];case 7:o.sent(),o.label=8;case 8:return r=n.next(),[3,6];case 9:return[3,12];case 10:return i={error:o.sent()},[3,12];case 11:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}return[7];case 12:return[3,14];case 13:throw n1.collectionInsertDuplicate;case 14:return[2]}})})},e.prototype._requestUpsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h;return(0,s.b)(this,function(f){switch(f.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=f.sent())?[3,13]:[4,this._blockManager.putToBlock(t,e)];case 2:return f.sent()?[3,5]:[4,this._upgradeBlockLevel()];case 3:return f.sent(),[4,this._blockManager.putToBlock(t,e)];case 4:f.sent(),f.label=5;case 5:f.trys.push([5,10,11,12]),i=(r=(0,s.w)(this._indexers)).next(),f.label=6;case 6:return i.done?[3,9]:[4,(u=i.value).addItem(e)];case 7:f.sent(),f.label=8;case 8:return i=r.next(),[3,6];case 9:return[3,12];case 10:return c={error:f.sent()},[3,12];case 11:try{i&&!i.done&&(l=r.return)&&l.call(r)}finally{if(c)throw c.error}return[7];case 12:return[3,23];case 13:return[4,this._blockManager.putToBlock(t,e)];case 14:f.sent(),f.label=15;case 15:f.trys.push([15,21,22,23]),o=(a=(0,s.w)(this._indexers)).next(),f.label=16;case 16:return o.done?[3,20]:0===(u=o.value).diff(u.getColumnValues(n),u.getColumnValues(e))?[3,19]:[4,u.removeItem(n)];case 17:return f.sent(),[4,u.addItem(e)];case 18:f.sent(),f.label=19;case 19:return o=a.next(),[3,16];case 20:return[3,23];case 21:return d={error:f.sent()},[3,23];case 22:try{o&&!o.done&&(h=a.return)&&h.call(a)}finally{if(d)throw d.error}return[7];case 23:return[2]}})})},e.prototype._requestUpdate=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return t=e[this.keyName],[4,this._blockManager.getFromBlock(t)];case 1:return(n=c.sent())?[4,this._blockManager.putToBlock(t,e)]:[3,11];case 2:c.sent(),c.label=3;case 3:c.trys.push([3,9,10,11]),i=(r=(0,s.w)(this._indexers)).next(),c.label=4;case 4:return i.done?[3,8]:0===(a=i.value).diff(a.getColumnValues(n),a.getColumnValues(e))?[3,7]:[4,a.removeItem(n)];case 5:return c.sent(),[4,a.addItem(e)];case 6:c.sent(),c.label=7;case 7:return i=r.next(),[3,4];case 8:return[3,11];case 9:return o={error:c.sent()},[3,11];case 10:try{i&&!i.done&&(u=r.return)&&u.call(r)}finally{if(o)throw o.error}return[7];case 11:return[2]}})})},e.prototype._requestRemove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return[4,this._blockManager.getFromBlock(e)];case 1:return(t=o.sent())?[4,this._blockManager.removeFromBlock(e)]:[3,10];case 2:o.sent(),o.label=3;case 3:o.trys.push([3,8,9,10]),r=(n=(0,s.w)(this._indexers)).next(),o.label=4;case 4:return r.done?[3,7]:[4,r.value.removeItem(t)];case 5:o.sent(),o.label=6;case 6:return r=n.next(),[3,4];case 7:return[3,10];case 8:return i={error:o.sent()},[3,10];case 9:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(i)throw i.error}
1return[7];case 10:return[2]}})})},e.prototype._requestClear=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return[4,this._blockManager.clearAllBlocks()];case 1:i.sent(),i.label=2;case 2:i.trys.push([2,7,8,9]),t=(e=(0,s.w)(this._indexers)).next(),i.label=3;case 3:return t.done?[3,6]:[4,t.value.clear()];case 4:i.sent(),i.label=5;case 5:return t=e.next(),[3,3];case 6:return[3,9];case 7:return n={error:i.sent()},[3,9];case 8:try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}return[7];case 9:return[2]}})})},e.prototype.getByKey=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,6];case 1:r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._blockManager.getFromBlock(e)];case 3:return t=r.sent(),this._mutex.unlock(),[2,n4(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw n1.collectionNotReady;case 7:return[2]}})})},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new rc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw n1.collectionNotReady},e.prototype.insertOne=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw n1.collectionKeyNotGiven;return[4,this._requestInsert(n4(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw n1.collectionNotReady;case 9:return[2]}})})},e.prototype.insertMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u=this;return(0,s.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some(function(e){return!u._hasPropertyOfKeyName(e)}))throw n1.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),n=(t=(0,s.w)(e)).next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestInsert(n4(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a={error:c.sent()},[3,10];case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return i=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),i;case 14:return[3,16];case 15:throw n1.collectionNotReady;case 16:return[2]}})})},e.prototype.upsertOne=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw n1.collectionKeyNotGiven;return[4,this._requestUpsert(n4(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw n1.collectionNotReady;case 9:return[2]}})})},e.prototype.upsertMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u=this;return(0,s.b)(this,function(c){switch(c.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:c.sent(),c.label=2;case 2:if(c.trys.push([2,12,,14]),e.some(function(e){return!u._hasPropertyOfKeyName(e)}))throw n1.collectionKeyNotGiven;c.label=3;case 3:c.trys.push([3,8,9,10]),n=(t=(0,s.w)(e)).next(),c.label=4;case 4:return n.done?[3,7]:(r=n.value,[4,this._requestUpsert(n4(r))]);case 5:c.sent(),c.label=6;case 6:return n=t.next(),[3,4];case 7:return[3,10];case 8:return a={error:c.sent()},[3,10];
1case 9:try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}return[7];case 10:return[4,this._transaction.commit()];case 11:return c.sent(),this._mutex.unlock(),[2,e];case 12:return i=c.sent(),[4,this._transaction.clear()];case 13:throw c.sent(),this._mutex.unlock(),i;case 14:return[3,16];case 15:throw n1.collectionNotReady;case 16:return[2]}})})},e.prototype.update=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:if(n.trys.push([2,5,,7]),!this._hasPropertyOfKeyName(e))throw n1.collectionKeyNotGiven;return[4,this._requestUpdate(n4(e))];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[2,e];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw n1.collectionNotReady;case 9:return[2]}})})},e.prototype.updateIf=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l,d,h,f,p,m,_=this;return(0,s.b)(this,function(v){switch(v.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:v.sent(),v.label=2;case 2:return v.trys.push([2,13,,15]),r=void 0===(n=e.where)?{}:n,a=void 0===(i=e.index)?null:i,u=void 0!==(o=e.backward)&&o,c=[],[4,new ru({condition:r,blockManager:this._blockManager,backward:u,indexer:this._getIndexerBy(a)}).each(function(e){return(0,s._)(_,void 0,void 0,function(){var n;return(0,s.b)(this,function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n8(r,n=e.nextValue)&&t.set&&("function"!=typeof t.set?Object.keys(t.set).forEach(function(e){var r;n[e]=null===(r=t.set)||void 0===r?void 0:r[e]}):t.set(n),c.push(n)),e.next()):e.stop(),[2]})})})];case 3:v.sent(),v.label=4;case 4:v.trys.push([4,9,10,11]),d=(l=(0,s.w)(c)).next(),v.label=5;case 5:return d.done?[3,8]:(h=d.value,[4,this._requestUpdate(n4(h))]);case 6:v.sent(),v.label=7;case 7:return d=l.next(),[3,5];case 8:return[3,11];case 9:return p={error:v.sent()},[3,11];case 10:try{d&&!d.done&&(m=l.return)&&m.call(l)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return v.sent(),this._mutex.unlock(),[2,c];case 13:return f=v.sent(),[4,this._transaction.clear()];case 14:throw v.sent(),this._mutex.unlock(),f;case 15:return[3,17];case 16:throw this._transaction.clear(),n1.collectionNotReady;case 17:return[2]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,5,,7]),[4,this._requestRemove(e)];case 3:return n.sent(),[4,this._transaction.commit()];case 4:return n.sent(),this._mutex.unlock(),[3,7];case 5:return t=n.sent(),[4,this._transaction.clear()];case 6:throw n.sent(),this._mutex.unlock(),t;case 7:return[3,9];case 8:throw n1.collectionNotReady;case 9:return[2]}})})},e.prototype.removeIf=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p,m=this;return(0,s.b)(this,function(_){switch(_.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:_.sent(),_.label=2;case 2:return _.trys.push([2,13,,14]),n=void 0===(t=e.where)?{}:t,i=void 0===(r=e.index)?null:r,o=void 0!==(a=e.backward)&&a,u=[],[4,new ru({condition:n,blockManager:this._blockManager,backward:o,indexer:this._getIndexerBy(i)}).each(function(e){return(0,s._)(m,void 0,void 0,function(){var t,r;return(0,s.b)(this,function(i){if(e.error)throw e.stop(),e.error;return e.hasNext?(n8(n,t=e.nextValue)&&(r=t[this.keyName],u.push(r)),e.next()):e.stop(),[2]})})})];case 3:_.sent(),_.label=4;case 4:_.trys.push([4,9,10,11]),l=(c=(0,s.w)(u)).next(),_.label=5;case 5:return l.done?[3,8]:(d=l.value,[4,this._requestRemove(d)]);case 6:_.sent(),_.label=7;case 7:return l=c.next(),[3,5];case 8:return[3,11];case 9:return f={error:_.sent()},[3,11];case 10:try{l&&!l.done&&(p=c.return)&&p.call(c)}finally{if(f)throw f.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return _.sent(),this._mutex.unlock(),[2,u];case 13:throw h=_.sent(),this._mutex.unlock(),h;
1case 14:return[3,16];case 15:throw this._transaction.clear(),n1.collectionNotReady;case 16:return[2]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,8];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this._requestClear()];case 3:return t.sent(),[4,this._transaction.commit()];case 4:return t.sent(),this._mutex.unlock(),[3,7];case 5:return e=t.sent(),[4,this._transaction.clear()];case 6:throw t.sent(),this._mutex.unlock(),e;case 7:return[3,9];case 8:throw n1.collectionNotReady;case 9:return[2]}})})},e.prototype.getBlob=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._blobContainer.get(e)];case 1:return[2,t.sent()]}})})},e.prototype.saveBlob=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._blobContainer.save(e,t)];case 1:return[2,n.sent()]}})})},e.prototype.removeBlob=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._blobContainer.remove(e)];case 1:return t.sent(),[2]}})})},e.prototype.removeAllBlobs=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._blobContainer.clear()];case 1:return e.sent(),[2]}})})},e}(),rD="[NESTDB]",rL=!0,rF=function(){function e(){}return e.off=function(){rL=!1},e.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];rL&&console.log.apply(console,(0,s.q)(["".concat(rD,"[LOG]")],(0,s.r)(e),!1))},e.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];rL&&console.warn.apply(console,(0,s.q)(["".concat(rD,"[WARNING]")],(0,s.r)(e),!1))},e.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];rL&&console.error.apply(console,(0,s.q)(["".concat(rD,"[ERROR]")],(0,s.r)(e),!1))},e}(),rq=[{},{a:700400,n:"error"}],rz=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:s.aY,this.itemSizeLimit=null!==(n=e.itemSizeLimit)&&void 0!==n?n:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}return Object.defineProperty(e.prototype,"_encryptionCheckKey",{get:function(){return"".concat(this.dbname,".encrypt")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_reservedKeys",{get:function(){return[this._encryptionCheckKey]},enumerable:!1,configurable:!0}),e.prototype._getRawKey=function(e,t){return void 0===t&&(t=""),"".concat(e).concat(t)},e.prototype._generateShardPostfixArray=function(e){return void 0===e&&(e=1),(0,s.q)([],(0,s.r)(Array(e).keys()),!1)},e.prototype._shardify=function(e){var t=this,n=e.key,r=e.value,i=JSON.stringify(this.encryption.encrypt(r)),s=Math.ceil(i.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(s).map(function(e){var r={key:t._getRawKey(n,".".concat(e)),data:i.substring(e*t.adjustedItemSizeLimit,(e+1)*t.adjustedItemSizeLimit)};return 0===e&&(r.metadata={shards:s}),r})},e.prototype._resetIfEncryptionChanged=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return[4,this.get(this._encryptionCheckKey)];case 1:if(e=s.sent(),t={encrypted:rq.map(function(e){var t;return null===(t=u.encryption)||void 0===t?void 0:t.encrypt(e)})},!e)return[3,8];if(!e.encrypted||!Array.isArray(e.encrypted))return[3,6];for(i in n=e.encrypted,r=[],n)r.push(i);a=0,s.label=2;case 2:return a<r.length?(i=r[a])in n?(o=i,JSON.stringify(e.encrypted[o])===JSON.stringify(t.encrypted[o])?[3,4]:(rF.warning("Encryption algorithm has changed. Stored data would be cleared."),[4,this.clear()])):[3,4]:[3,5];case 3:return s.sent(),[3,5];case 4:return a++,[3,2];case 5:return[3,8];case 6:return[4,this.clear()];case 7:s.sent(),s.label=8;case 8:return[4,this.set({key:this._encryptionCheckKey,value:t})];case 9:return s.sent(),[2]}})})},Object.defineProperty(e.prototype,"adjustedItemSizeLimit",{get:function(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}
1,enumerable:!1,configurable:!0}),e.prototype.usage=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:return e=0,[4,this._getAllRawKeys()];case 1:t=c.sent(),c.label=2;case 2:c.trys.push([2,7,8,9]),r=(n=(0,s.w)(t)).next(),c.label=3;case 3:return r.done?[3,6]:(i=r.value,[4,this._getRaw(i)]);case 4:(a=c.sent())&&(e+=JSON.stringify(a).length),c.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return o={error:c.sent()},[3,9];case 8:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 9:return[2,e]}})})},e.prototype.getAllKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._getAllRawKeys()];case 1:return[2,t.sent().filter(function(e){return e.endsWith(".0")}).map(function(e){return e.replace(/\.0$/,"")}).filter(function(t){return!e._reservedKeys.includes(t)})]}})})},e.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u=this;return(0,s.b)(this,function(c){switch(c.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:if(!(n=c.sent()))return[3,7];c.label=2;case 2:return c.trys.push([2,6,,7]),r=n.data,(null==(i=n.metadata)?void 0:i.shards)&&i.shards>1?[4,Promise.all(this._generateShardPostfixArray(null==i?void 0:i.shards).map(function(t){return(0,s._)(u,void 0,void 0,function(){var n,i;return(0,s.b)(this,function(s){switch(s.label){case 0:return t>0?(n=this._getRawKey(e,".".concat(t)),[4,this._getRaw(n)]):[3,2];case 1:if(!(i=s.sent()))throw n1.storeBrokenIntegrity;return[2,i.data];case 2:return[2,r]}})})}))]:[3,4];case 3:return o=c.sent(),[3,5];case 4:o=[r],c.label=5;case 5:return a=o,[2,this.encryption.decrypt(JSON.parse(a.join("")))];case 6:return c.sent(),[2,null];case 7:return[2,null]}})})},e.prototype.set=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=this._shardify(e),[4,this._setRaw(t)];case 1:return n.sent(),[2,(0,s.d)({},e.value)]}})})},e.prototype.setMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=[],[4,this._setRaw(t.concat.apply(t,(0,s.q)([],(0,s.r)(e.map(function(e){return n._shardify(e)})),!1)))];case 1:return r.sent(),[2,e.map(function(e){return e.value})]}})})},e.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return t=this._getRawKey(e,".0"),[4,this._getRaw(t)];case 1:return(n=s.sent())?(r=n.metadata,i=this._generateShardPostfixArray(null==r?void 0:r.shards).map(function(t){return o._getRawKey(e,".".concat(t))}),[4,this._removeRaw(i)]):[3,3];case 2:return s.sent(),null==(a=rw.get(this.dbname))||a.remove(e),[2,!0];case 3:return[2,!1]}})})},e.prototype.removeMany=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:t=rw.get(this.dbname),n=[],r=function(e){var r,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return r=i._getRawKey(e,".0"),[4,i._getRaw(r)];case 1:return(a=u.sent())&&(o=a.metadata,n.push.apply(n,(0,s.q)([],(0,s.r)(i._generateShardPostfixArray(null==o?void 0:o.shards).map(function(t){return d._getRawKey(e,".".concat(t))})),!1))),null==t||t.remove(e),[2]}})},i=this,h.label=1;case 1:h.trys.push([1,6,7,8]),o=(a=(0,s.w)(e)).next(),h.label=2;case 2:return o.done?[3,5]:(u=o.value,[5,r(u)]);case 3:h.sent(),h.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return c={error:h.sent()},[3,8];case 7:try{o&&!o.done&&(l=a.return)&&l.call(a)}finally{if(c)throw c.error}return[7];case 8:return n.length>0?[4,this._removeRaw(n)]:[3,10];case 9:h.sent(),h.label=10;case 10:return[2,e]}})})},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){return null==(e=rw.get(this.dbname))||e.clearForDatabase(this.dbname),[2]})})},e.prototype.trim=function(){},e}(),rj={},rV=function(e){function t(t){void 0===t&&(t={});var n,r=this;r=e.call(this,(0,s.d)((0,s.d)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:4194304}))||this;var i=t.delay;return r.delay=void 0===i?1:i,r.observer={},r}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"rawData",{get:function(){return rj[this.dbname]}
1,set:function(e){rj[this.dbname]=e},enumerable:!1,configurable:!0}),t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(rj[this.dbname])return[2,Object.keys(rj[this.dbname])];throw n1.storeNotAvailable})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return rj[this.dbname]?[4,n7(this.delay)]:[3,2];case 1:return t.sent(),[2,rj[this.dbname][e]?(0,s.d)({key:e},rj[this.dbname][e]):null];case 2:throw n1.storeNotAvailable}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c;return(0,s.b)(this,function(l){switch(l.label){case 0:return rj[this.dbname]?[4,n7(this.delay)]:[3,2];case 1:l.sent();try{for(n=(t=(0,s.w)(e)).next();!n.done;n=t.next())i=(r=n.value).key,a=r.data,o=r.metadata,rj[this.dbname][i]=Object.freeze({data:a,metadata:o})}catch(e){u={error:e}}finally{try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.error}}return[3,3];case 2:throw n1.storeNotAvailable;case 3:return[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:return rj[this.dbname]?[4,n7(this.delay)]:[3,2];case 1:o.sent();try{for(n=(t=(0,s.w)(e)).next();!n.done;n=t.next())r=n.value,rj[this.dbname][r]&&delete rj[this.dbname][r]}catch(e){i={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}}return[3,3];case 2:throw n1.storeNotAvailable;case 3:return[2]}})})},t.prototype.observe=function(e,t,n){var r=this;this.observer[e]||(this.observer[e]={}),t.forEach(function(t){return r.observer[e][t]=n})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,rj[this.dbname]||(rj[this.dbname]={}),[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.set=function(t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){if((n=this.observer[t.key])&&"function"==typeof n.set&&(r=n.set()))throw r;return[2,e.prototype.set.call(this,t)]})})},t.prototype.setMany=function(t){return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c;return(0,s.b)(this,function(l){try{for(r=(n=(0,s.w)(t)).next();!r.done;r=n.next())if(i=r.value,(a=this.observer[i.key])&&"function"==typeof a.set&&(o=a.set()))throw o}catch(e){u={error:e}}finally{try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}}return[2,e.prototype.setMany.call(this,t)]})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return t.sent(),[4,n7(this.delay)];case 2:return t.sent(),rj[this.dbname]={},[2]}})})},t}(rz),rB="NestDBStore";(rH=rO||(rO={}))[rH.UNINITIALIZED=0]="UNINITIALIZED",rH[rH.OPENING=1]="OPENING",rH[rH.OPEN=2]="OPEN",rH[rH.CLOSED=3]="CLOSED";var rK=function(e){function t(t){void 0===t&&(t={});var n,r=this;return(r=e.call(this,(0,s.d)((0,s.d)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:104857600}))||this)._storeName=rB,r._state=rO.UNINITIALIZED,r._openJobQueue=[],r._window="undefined"!=typeof window?window:void 0,r._indexedDb=r._window?r._window.indexedDB||r._window.mozIndexedDB||r._window.webkitIndexedDB||r._window.msIndexedDB:void 0,r}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.isTransactionInactiveError=function(e){return e instanceof Error&&e.message.includes("The transaction is inactive")},t.prototype._putToObjectStore=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return[2,new Promise(function(n,r){var i=e.put(t);i.addEventListener("success",function(e){n(e.target.result)}),i.addEventListener("error",function(e){r(e.target.error)})})]})})},t.prototype._deleteFromObjectStore=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){return[2,new Promise(function(n,r){var i=e.delete(t);i.addEventListener("success",function(){return n(t)}),i.addEventListener("error",function(e){return r(e.target.error)})})]})})},t.prototype._openDatabase=function(e){var t=this;return new Promise(function(n,r){if(t._indexedDb){t._state=rO.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",function(e){e.target.result.createObjectStore(rB,{keyPath:"key"})}),i.addEventListener("success",function(r){t._state=rO.OPEN,t._database=r.target.result,t._openJobQueue.forEach(function(e){return e()}),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=rO.OPENING,setTimeout(function(){t._openDatabase(e)},5)},n(t._database)}),i.addEventListener("error",function(e){t._state=rO.UNINITIALIZED,r(e.target.error)})}else r(n1.storeNotAvailable)})},t.prototype._getObjectStore=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return this._database?((t=this._database.transaction(this._storeName,e)).addEventListener("abort",function(e){throw e.target.error}),[2,t.objectStore(this._storeName)]):[3,1];case 1:switch(this._state){case rO.UNINITIALIZED:case rO.OPEN:return[3,2];case rO.OPENING:case rO.CLOSED:return[3,3]}return[3,4];case 2:throw n1.storeNotInitialized;case 3:return[2,new Promise(function(t){n._openJobQueue.push(function(){return t(n._getObjectStore(e))})})];case 4:return[4,this._getObjectStore(e)];case 5:return[2,r.sent()]}})})},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,new Promise(function(t,n){return(0,s._)(e,void 0,void 0,function(){var e;return(0,s.b)(this,function(r){switch(r.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return(e=r.sent().getAllKeys()).addEventListener("success",function(e){t(e.target.result)}),e.addEventListener("error",function(e){return n(e.target.error)}),[2]}})})})];case 1:return[2,t.sent()]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n,r){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(i){switch(i.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return(t=i.sent().get(e)).addEventListener("success",function(e){var t;n(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)}),t.addEventListener("error",function(e){return r(e.target.error)}),[2]}})})})];case 1:return[2,n.sent()]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l=this;return(0,s.b)(this,function(d){switch(d.label){case 0:return d.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return t=d.sent(),[4,Promise.all(e.map(function(e){return l._putToObjectStore(t,e)}))];case 2:return d.sent(),[3,15];case 3:return n=d.sent(),this.isTransactionInactiveError(n)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:r=d.sent(),d.label=5;case 5:d.trys.push([5,10,11,12]),a=(i=(0,s.w)(e)).next(),d.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._putToObjectStore(r,o)]);case 7:d.sent(),d.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return u={error:d.sent()},[3,12];case 11:try{a&&!a.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}
1return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l=this;return(0,s.b)(this,function(d){switch(d.label){case 0:return d.trys.push([0,3,,15]),[4,this._getObjectStore("readwrite")];case 1:return t=d.sent(),[4,Promise.all(e.map(function(e){return l._deleteFromObjectStore(t,e)}))];case 2:return d.sent(),[3,15];case 3:return n=d.sent(),this.isTransactionInactiveError(n)?[4,this._getObjectStore("readwrite")]:[3,13];case 4:r=d.sent(),d.label=5;case 5:d.trys.push([5,10,11,12]),a=(i=(0,s.w)(e)).next(),d.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._deleteFromObjectStore(r,o)]);case 7:d.sent(),d.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return u={error:d.sent()},[3,12];case 11:try{a&&!a.done&&(c=i.return)&&c.call(i)}finally{if(u)throw u.error}return[7];case 12:return[3,14];case 13:throw n;case 14:return[3,15];case 15:return[2]}})})},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){var e,t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:if(!((null==(e="undefined"!=typeof window?window:null)?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))return[3,6];if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!rU())return[3,4];if(!(rU()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw n1.storeNotAvailableInPrivateBrowsing;return[3,3];case 1:return[4,new Promise(function(e,n){if(t._indexedDb)try{var r=t._indexedDb.open("_testMozilla");r.onerror=function(){return n(n1.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(r){if(r.target.result.close(),t._indexedDb){var i=t._indexedDb.deleteDatabase("_testMozilla");i.onerror=function(){return e()},i.onsuccess=function(){return e()}}else n(n1.storeNotAvailable)}}catch(e){n(n1.storeNotAvailableInPrivateBrowsing)}else n(n1.storeNotAvailable)})];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:case 6:throw n1.storeNotAvailable;case 5:return[3,7];case 7:return[2]}})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[4,this._resetIfEncryptionChanged()];case 3:return t.sent(),[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,new Promise(function(e,n){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(r){switch(r.label){case 0:return[4,this._getObjectStore("readwrite")];case 1:return(t=r.sent().clear()).addEventListener("success",function(){return e()}),t.addEventListener("error",function(e){return n(e.target.error)}),[2]}})})})];case 2:return[2,n.sent()]}})})},t}(rz),rQ=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,a=(0,s.aZ)(t,["AsyncStorage","itemSizeLimit"]);return(n=e.call(this,(0,s.d)((0,s.d)({},a),{itemSizeLimit:void 0===i?2097152:i}))||this)._asyncStorage=r,n}return(0,s.c)(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._asyncStorage.getAllKeys()];case 1:return[2,t.sent().filter(function(t){return e._isBelonging(t)}).map(function(t){return t.substring("".concat(e.dbname,"/").length)})]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._asyncStorage.getItem(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u;return(0,s.b)(this,function(c){switch(c.label){case 0:t=[];try{for(r=(n=(0,s.w)(e)).next();!r.done;r=n.next())a=(i=r.value).key,i.data.length<=this.adjustedItemSizeLimit&&t.push([this._getActualKey(a),JSON.stringify(i)])}catch(e){o={error:e}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return[4,this._asyncStorage.multiSet(t)];case 1:return c.sent(),[2]}})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._asyncStorage.multiRemove(e.map(function(e){return t._getActualKey(e)}))];case 1:return n.sent(),[2]}})})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(!this._asyncStorage)throw n1.storeNotAvailable;return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return n.sent(),[4,this.getAllKeys()];case 2:return t=n.sent(),[4,this.removeMany(t)];case 3:return n.sent(),[2]}})})},t}(rz),rG=function(e){function t(t){var n,r,i=this;return(i=e.call(this,(0,s.d)((0,s.d)({},t),{itemSizeLimit:null!==(n=t.itemSizeLimit)&&void 0!==n?n:6291456}))||this)._mmkv=(r=t.MMKV,{getString:function(e){return r.getString(e)}
1,set:function(e,t){return r.set(e,t)},delete:function(e){return r.remove?r.remove(e):r.delete(e)},getAllKeys:function(){return r.getAllKeys()},trim:function(){if(r.trim)return r.trim()}}),i}return(0,s.c)(t,e),t.prototype._isBelonging=function(e){return e.startsWith("".concat(this.dbname,"/"))},t.prototype._getActualKey=function(e){return"".concat(this.dbname,"/").concat(e)},t.prototype._getAllRawKeys=function(){return(0,s._)(this,void 0,void 0,function(){var e=this;return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._mmkv.getAllKeys()];case 1:return[2,t.sent().filter(function(t){return e._isBelonging(t)}).map(function(t){return t.substring("".concat(e.dbname,"/").length)})]}})})},t.prototype._getRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this._mmkv.getString(this._getActualKey(e))];case 1:return[2,(t=n.sent())?JSON.parse(t):null]}})})},t.prototype._setRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(u){try{for(n=(t=(0,s.w)(e)).next();!n.done;n=t.next())i=(r=n.value).key,r.data.length<=this.adjustedItemSizeLimit&&this._mmkv.set(this._getActualKey(i),JSON.stringify(r))}catch(e){a={error:e}}finally{try{n&&!n.done&&(o=t.return)&&o.call(t)}finally{if(a)throw a.error}}return[2]})})},t.prototype._removeRaw=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){try{for(n=(t=(0,s.w)(e)).next();!n.done;n=t.next())r=n.value,this._mmkv.delete(this._getActualKey(r))}catch(e){i={error:e}}finally{try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}}return[2]})})},t.prototype.checkAvailability=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){if(!this._mmkv)throw n1.storeNotAvailable;return[2]})})},t.prototype.init=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.dbname=e,[4,this._resetIfEncryptionChanged()];case 1:return t.sent(),[2]}})})},t.prototype.clear=function(){var t;return(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){switch(r.label){case 0:return[4,e.prototype.clear.call(this)];case 1:return r.sent(),[4,this.getAllKeys()];case 2:return n=r.sent(),[4,this.removeMany(n)];case 3:return r.sent(),null===(t=this._mmkv)||void 0===t||t.trim(),[2]}})})},t.prototype.trim=function(){var e;null===(e=this._mmkv)||void 0===e||e.trim()},t}(rz);(rW=rY||(rY={})).INIT="INIT",rW.OPENING="OPENING",rW.OPENED="OPENED",rW.CLOSED="CLOSED";var rH,rW,rY,rJ,rX=function(){function e(e){var t=e.name,n=e.version,r=e.store,i=e.config;this.name=t,this._version=n,this._state=rY.INIT,this._config=i||new nZ({dbname:t}),this._store=r,this._event={success:n9,error:n9,storeReplaced:n9,upgrade:rn},this._collections=new Map,this._globalMutex=new rx("".concat(this.name,".lock")),this._config.disableLogger&&rF.off(),new rw({dbname:t,limit:this._config.cacheLimit})}return Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"store",{get:function(){return this._store},enumerable:!1,configurable:!0}),e.prototype._initializeCollection=function(e,t){var n;return(0,s._)(this,void 0,void 0,function(){var r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:return i=this._collections.get(e),t?(r=new rR({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:null!==(n=t.index)&&void 0!==n?n:[[t.keyName]],store:this._store}),[3,3]):[3,1];case 1:return i&&i.state===n0.READY?[3,3]:[4,rR.metadataOf(this.name,e,this._store)];case 2:(a=s.sent())&&(r=new rR({dbname:this.name,collectionName:e,keyName:a.keyName,indexes:a.indexes,store:this._store})),s.label=3;case 3:return r?(this._collections.set(e,r),[4,r.init()]):[3,5];case 4:s.sent(),s.label=5;case 5:return[2]}})})},e.prototype.estimateUsage=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){var t;switch(e.label){case 0:return[4,(t=this._store,(0,s._)(void 0,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,t.usage()];case 1:return[2,e.sent()]}})}))];case 1:return[2,e.sent()]}})})},e.prototype.commitSchema=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this._state!==rY.OPENING?[3,2]:[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._initializeCollection(e.collectionName,e)];case 1:return t.sent(),[2]}})})}))];case 1:return n.sent(),[3,3];case 2:throw n1.databaseSchemaNotOnUpgrade;case 3:return[2]}})})},e.prototype.open=function(){var e;return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){var f;switch(h.label){case 0:return[4,this._globalMutex.lock()];case 1:if(h.sent(),this._state===rY.OPENED)return[3,20];this._state=rY.OPENING,h.label=2;case 2:return h.trys.push([2,13,,20]),[4,this._store.init(this.name)];case 3:return h.sent(),f=this.name,t="".concat(rl(f),".metadata"),n={version:0,collectionNames:[]},[4,this._store.get(t)];case 4:r=null!==(e=h.sent())&&void 0!==e?e:n,h.label=5;
1case 5:h.trys.push([5,10,11,12]),a=(i=(0,s.w)(r.collectionNames)).next(),h.label=6;case 6:return a.done?[3,9]:(o=a.value,[4,this._initializeCollection(o)]);case 7:h.sent(),h.label=8;case 8:return a=i.next(),[3,6];case 9:return[3,12];case 10:return c={error:h.sent()},[3,12];case 11:try{a&&!a.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}return[7];case 12:return[2,new Promise(function(e,n){var i=function(e){r.version<d._version?d._event.upgrade(r.version,function(n){return(0,s._)(d,void 0,void 0,function(){return(0,s.b)(this,function(i){switch(i.label){case 0:if(n)return[3,5];r.version++,r.collectionNames=Array.from(this._collections.keys()),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._store.set({key:t,value:r})];case 2:return i.sent(),e({continued:!0}),[3,4];case 3:return e({continued:!1,err:i.sent()}),[3,4];case 4:return[3,6];case 5:e({continued:!1,err:n}),i.label=6;case 6:return[2]}})})}):e({continued:!1})},a=function(t){var s=t.continued,o=t.err,u=void 0===o?null:o;void 0!==s&&s?setTimeout(function(){return i(a)},10):u?(rF.error(u.message),d._globalMutex.unlock(),d._event.error(u),n(u)):Promise.all(r.collectionNames.map(function(e){return d._initializeCollection(e)})).then(function(){d._state=rY.OPENED,d._globalMutex.unlock(),d._event.success(),e()}).catch(function(e){rF.error(e.message),d._globalMutex.unlock(),d._event.error(e),n(e)})};i(a)})];case 13:switch((u=h.sent()).code){case nL.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:return[3,14];case nL.STORE_NOT_AVAILABLE:return[3,16]}return[3,18];case 14:return rF.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new rV({}),this._globalMutex.unlock(),this._event.error(u),this._event.storeReplaced(this._store),[4,this.open()];case 15:case 17:return h.sent(),[3,19];case 16:return rF.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new rV({}),this._globalMutex.unlock(),this._event.error(u),this._event.storeReplaced(this._store),[4,this.open()];case 18:throw rF.error(u.message),this._globalMutex.unlock(),this._event.error(u),u;case 19:return[3,20];case 20:return[2]}})})},e.prototype.close=function(){this._collections.forEach(function(e){return e.close()}),this._state=rY.CLOSED},e.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,Promise.all(Array.from(this._collections.values()).map(function(e){return e.clear()}))];case 1:return e.sent(),[2]}})})},e.prototype.reset=function(){return(0,s._)(this,void 0,void 0,function(){var e;return(0,s.b)(this,function(t){switch(t.label){case 0:return(e=rw.get(this.name))&&e.clearForDatabase(this.name),[4,this._store.clear()];case 1:return t.sent(),[2]}})})},e.prototype.on=function(e,t){this._event[e]=t},e.prototype.off=function(e){"function"==typeof this._event[e]&&("upgrade"===e?this._event[e]=rn:this._event[e]=n9)},e.prototype.collection=function(e){var t=this._collections.get(e);if(t)return t;throw n1.collectionNotReady},e.prototype.trim=function(){var e;null===(e=this._store)||void 0===e||e.trim()},e}();(rZ=rJ||(rJ={}))[rZ.VERBOSE=0]="VERBOSE",rZ[rZ.DEBUG=1]="DEBUG",rZ[rZ.INFO=2]="INFO",rZ[rZ.WARN=3]="WARN",rZ[rZ.ERROR=4]="ERROR",rZ[rZ.NONE=5]="NONE";var rZ,r$,r0=function(){function e(){this.level=rJ.WARN}return e.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=rJ.VERBOSE&&console.log.apply(console,(0,s.q)(["[verbose]"],(0,s.r)(e),!1))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=rJ.DEBUG&&console.log.apply(console,(0,s.q)(["[debug]"],(0,s.r)(e),!1))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=rJ.INFO&&console.log.apply(console,(0,s.q)(["[info]"],(0,s.r)(e),!1))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=rJ.WARN&&console.warn.apply(console,(0,s.q)(["[warn]"],(0,s.r)(e),!1))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.level<=rJ.ERROR&&console.error.apply(console,(0,s.q)(["[error]"],(0,s.r)(e),!1))},e}(),r1=function(){function e(e){this._dndSchedules=null!=e?e:{}}return e.prototype.setDayDndSchedule=function(e,t){return this._dndSchedules[e]=t,this._dndSchedules},e.prototype.getDayDndSchedule=function(e){return this._dndSchedules[e]},e.prototype.getDndSchedules=function(){return this._dndSchedules},e.prototype.setDndSchedules=function(e){return this._dndSchedules=e,this._dndSchedules},e.prototype.setWeekdays=function(e){return this._dndSchedules[s.ae.MONDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules[s.ae.TUESDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules[s.ae.WEDNESDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules[s.ae.THURSDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules[s.ae.FRIDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules},e.prototype.setWeekends=function(e){return this._dndSchedules[s.ae.SATURDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules[s.ae.SUNDAY]=(0,s.q)([],(0,s.r)(e),!1),this._dndSchedules},e.prototype.setFullDay=function(e){var t,n;try{for(var r=(0,s.w)(e),i=r.next();!i.done;i=r.next()){var a=i.value;this._dndSchedules[a]=[{startHour:0,startMin:0,endHour:23,endMin:59}]}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return this._dndSchedules},e.prototype.isValid=function(){var e,t,n,r,i=Object.values(this._dndSchedules);if(0===i.length)return!1;try{for(var a=(0,s.w)(i),o=a.next();!o.done;o=a.next()){var u=o.value;if(!Array.isArray(u)||0===u.length)return!1;try{for(var c,l=(n=void 0,(0,s.w)(u)),d=l.next();!d.done;d=l.next())if(c=d.value,!((0,s.a_)(c.startHour)&&(0,s.a$)(c.startMin)&&(0,s.a_)(c.endHour)&&(0,s.a$)(c.endMin))||!(c.startHour<c.endHour)&&(c.startHour!==c.endHour||!(c.startMin<c.endMin)))return!1}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}return!0},e.payloadify=function(e){return Object.entries(e.getDndSchedules()).map(function(e){var t=(0,s.r)(e,2);return{day_of_week:t[0],time_windows:t[1].map(function(e){return{start_hour:e.startHour,start_min:e.startMin,end_hour:e.endHour,end_min:e.endMin}})}})},e.buildDndScheduleFromPayload=function(t){var n,r,i={};try{for(var a=(0,s.w)(t),o=a.next();!o.done;o=a.next()){var u=o.value;i[u.day_of_week]=u.time_windows.map(function(e){return{startHour:e.start_hour,startMin:e.start_min,endHour:e.end_hour,endMin:e.end_min}})}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return new e(i)},e}(),r2=function(){function e(e){var t,n,r,i;this.messageTypeFilter=null!==(t=null==e?void 0:e.messageTypeFilter)&&void 0!==t?t:s.aA.ALL,this.customTypesFilter=null!==(n=null==e?void 0:e.customTypesFilter)&&void 0!==n?n:null,this.senderUserIdsFilter=null!==(r=null==e?void 0:e.senderUserIdsFilter)&&void 0!==r?r:null,this.replyType=null!==(i=null==e?void 0:e.replyType)&&void 0!==i?i:s.aH.NONE}return e.prototype.clone=function(){var t=new e,n=JSON.parse(JSON.stringify(this));
1return Object.keys(n).forEach(function(e){t[e]=n[e]}),t},e.prototype.match=function(e){switch(this.messageTypeFilter){case s.aA.USER:if(e.messageType!==s.ar.USER)return!1;break;case s.aA.FILE:if(e.messageType!==s.ar.FILE)return!1;break;case s.aA.ADMIN:if(e.messageType!==s.ar.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes("*")&&!this.customTypesFilter.includes(e.customType)||this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0&&(!(e instanceof L)||!this.senderUserIdsFilter.includes(e.sender.userId)))return!1;if(e instanceof D)switch(this.replyType){case s.aH.NONE:if(e.parentMessageId>0)return!1;break;case s.aH.ONLY_REPLY_TO_CHANNEL:if(e instanceof L&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0},e}();(r3=r$||(r$={})).CHANNEL_LATEST="channel_latest",r3.NEWEST_CHILD_MESSAGE="newest_child_message";var r3,r4,r5=function(e){switch(e){case r$.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case r$.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},r6=function(){return["channelUrl","-createdAt","-notificationId"]},r7=(0,s.d)((0,s.d)({},eU),{scheduledAt:void 0}),r8=function(e){return eP(e)&&(0,s.a)("number",e.scheduledAt,!0)},r9=(0,s.d)((0,s.d)({},eS),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),ie=function(e){return eA(e)&&(0,s.a)("number",e.scheduledAt)&&((0,s.i)(e.file)||(0,s.a)("string",e.fileUrl))&&(0,s.a)("string",e.fileName,!0)&&(0,s.a)("string",e.mimeType,!0)&&(0,s.a)("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every(function(e){return(0,s.a)("object",e)&&e.maxWidth>0&&e.maxHeight>0}))},it="UnsentMessage",ir="reqId",ii={},is=function(e){function t(t){var n=e.call(this,t)||this;return n._mutex=new rx("unsendmessagecache.lock"),ii[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),ii[e]&&!n||(ii[e]=new t(e)),ii[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(it);if(!t)throw s.t.databaseError;return t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){if(e.messageId>0)throw s.t.invalidParameters;var t,n,r,i=(0,s.d)({},e.serialize());return e instanceof B?(e.messageParams&&(i.messageParams=eM(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(i.scheduledInfo.scheduledMessageParams=(r=e.scheduledInfo.scheduledMessageParams,(0,s.d)((0,s.d)({},eM(r)),{scheduledAt:r.scheduledAt})))):e instanceof W?(e.messageParams&&(i.messageParams=eD(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(i.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,(0,s.d)((0,s.d)({},eD(t)),{scheduledAt:t.scheduledAt})))):e instanceof K&&e.messageParams&&(i.messageParams=(n=e.messageParams,(0,s.f)({fileInfoList:n.fileInfoList.map(function(e){return{file:e.file,fileUrl:Y.getPlainUrl(e),fileName:e.fileName,fileSize:e.fileSize,mimeType:e.mimeType,thumbnailSizes:e.thumbnailSizes,_thumbnails:e._thumbnails,_uploadedMetaData:e._uploadedMetaData}}),isReplyToChannel:n.isReplyToChannel,pushNotificationDeliveryOption:n.pushNotificationDeliveryOption}))),i},t.prototype._deserialize=function(e){return e=(0,s.d)((0,s.d)({},e),{messageId:parseInt(e.messageId)}),ib.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var t,n,r;return(0,s._)(this,void 0,void 0,function(){var i,a,o,u,c,l,d=this;return(0,s.b)(this,function(h){switch(h.label){case 0:return i=ib.of(this._iid),a=this._deserialize(e),e.messageParams?a instanceof B?(u=e.messageParams,a.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,a),[3,6]):[3,1]:[3,6];case 1:return a instanceof W?(u=e.messageParams).fileKey&&"string"==typeof u.fileKey&&eR(null!==(t=u.fileType)&&void 0!==t?t:"")?(o=u,[4,this.collection.getBlob(u.fileKey)]):[3,3]:[3,4];case 2:o.file=null!==(n=h.sent())&&void 0!==n?n:void 0,h.label=3;case 3:return a.messageParams=i.buildFileMessageCreateParamsFromSerializedData(u,a),[3,6];case 4:return a instanceof K&&(u=e.messageParams)&&u.fileInfoList?(a.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(u,a),[4,Promise.all(a.messageParams.fileInfoList.map(function(e){return(0,s._)(d,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(s){switch(s.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&eR(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(a=s.sent())&&void 0!==a?a:void 0,s.label=2;case 2:return[2]}})})}))]):[3,6];case 5:h.sent(),h.label=6;case 6:return a.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?a instanceof B?(c=e.scheduledInfo.scheduledMessageParams,a.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(c,a),[3,10]):[3,7]:[3,10];case 7:return a instanceof W?(c=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof c.fileKey&&"string"==typeof c.fileType&&eR(c.fileType)?(l=c,[4,this.collection.getBlob(c.fileKey)]):[3,9]:[3,10];case 8:l.file=null!==(r=h.sent())&&void 0!==r?r:void 0,h.label=9;case 9:a.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(c,a),h.label=10;case 10:return[2,a]}})})},t.prototype._getFileInfoBlobKey=function(e,t){return"".concat(e,".").concat(t)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserializeWithMessageCreateParams(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,r=void 0===n?new r2:n,i=e.order,a=void 0===i?r$.CHANNEL_LATEST:i,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return(0,s._)(this,void 0,void 0,function(){var e,n,i,u=this;return(0,s.b)(this,function(d){switch(d.label){case 0:return this.localCacheEnabled?(e=r5(a),n={"/where":function(e){return!!(a!==r$.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&r.match(u._deserialize(e))}},t&&(n.channelUrl=t),o&&(n.sendingStatus=o),i={where:n,index:e,backward:c},[4,this.collection.query(i)]):[3,3];case 1:return[4,d.sent().fetch({})];case 2:return[2,Promise.all(d.sent().map(function(e){return(0,s._)(u,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return[4,this._deserializeWithMessageCreateParams(e)];case 1:return[2,t.sent()]}})})}))];case 3:return[2,[]]}})})},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new r2),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:r$.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}})})},t.prototype.upsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return e instanceof W||e instanceof K?[4,this._mutex.lock()]:[3,4];case 1:return n.sent(),[4,this.saveBlob(e)];case 2:return n.sent(),[4,this._mutex.unlock()];case 3:n.sent(),n.label=4;case 4:return t=this._serialize(e),[4,this.collection.upsertOne(t)];case 5:return n.sent(),[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.upsertChildMessages=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach(function(t){return t.applyParentMessage(e)}),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.label=4;case 4:return[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),n=(t=(0,s.w)(e)).next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i={error:o.sent()},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}
1return[7];case 8:return[2]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.saveBlob=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,s.b)(this,function(a){switch(a.label){case 0:return e instanceof W?e.messageParams&&(r=e.messageParams).file&&ex(r.file)?[4,this.collection.saveBlob(r.file,e.reqId)]:[3,2]:[3,5];case 1:n=a.sent(),r.fileKey=n,r.fileType=ek.BLOB,a.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(t=e.scheduledInfo.scheduledMessageParams).file&&ex(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=a.sent(),t.fileKey=n,t.fileType=ek.BLOB,a.label=4;case 4:return[3,7];case 5:return e instanceof K&&(r=e.messageParams)&&r.fileInfoList&&Array.isArray(r.fileInfoList)?[4,Promise.all(r.fileInfoList.map(function(t,n){return(0,s._)(i,void 0,void 0,function(){var r;return(0,s.b)(this,function(i){switch(i.label){case 0:return t.file&&ex(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=ek.BLOB,i.label=2;case 2:return[2]}})})}))]:[3,7];case 6:a.sent(),a.label=7;case 7:return[2]}})})},t}(s.ap),ia={},io=function(e){function t(t){var n=e.call(this,t)||this;return ia[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return s.V.of(this._iid).sdkState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return is.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),ia[e]&&!n||(ia[e]=new t(e)),ia[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(nt)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return(0,s.d)((0,s.d)({},e.serialize()),{messageId:"".concat(e.messageId)})},t.prototype._deserialize=function(e){return e=(0,s.d)((0,s.d)({},e),{messageId:parseInt(e.messageId)}),ib.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey("".concat(e))]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,a=e.filter,o=void 0===a?new r2:a,u=e.order,c=void 0===u?r$.CHANNEL_LATEST:u,l=e.backward,d=void 0!==l&&l,h=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,m=e.exactMatch,_=void 0!==m&&m,v=e.inclusive,y=void 0===v||v,g=e.isRestoreIndexedDB,b=void 0!==g&&g;return(0,s._)(this,void 0,void 0,function(){var e,r,a=this;return(0,s.b)(this,function(u){switch(u.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(null!=n&&""!==n)switch(c){case r$.CHANNEL_LATEST:if(_&&e.createdAt!==n)return!1;if(d){if(y&&e.createdAt<n||!y&&e.createdAt<=n)return!1}else if(y&&e.createdAt>n||!y&&e.createdAt>=n)return!1;break;case r$.NEWEST_CHILD_MESSAGE:if(!h||0===e.parentMessageId||e.parentMessageId!==h)return!1}return!(p&&!e._poll)&&o.match(a._deserialize(e))}},index:r5(c),backward:d},[4,this.collection.query(e)]):[3,5];case 1:return r=u.sent(),this._cacheContext.localCacheConfig.enableRestoreDB&&b?[4,r.indexer.restoreIndexer()]:[3,3];case 2:u.sent(),u.label=3;case 3:return[4,r.fetch({limit:null!=i?i:void 0})];case 4:return[2,Promise.all(u.sent().map(function(e){return(0,s._)(a,void 0,void 0,function(){return(0,s.b)(this,function(t){return[2,this._deserialize(e)]})})}))];case 5:return[2,[]]}})})},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new r2),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:r$.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}})})},t.prototype.upsert=function(e){var t;return(0,s._)(this,void 0,void 0,function(){var n,r,i,a,o,u,c,l=this;return(0,s.b)(this,function(d){switch(d.label){case 0:return this.localCacheEnabled?[4,this.saveBlobs(e)]:[3,13];case 1:d.sent(),d.label=2;case 2:d.trys.push([2,7,8,9]),r=(n=(0,s.w)(e)).next(),d.label=3;case 3:return r.done?[3,6]:(null===(t=(i=r.value).threadInfo)||void 0===t?void 0:t._isUpdateRequired)?[4,this.get(i.messageId)]:[3,5];case 4:(null==(a=d.sent())?void 0:a.threadInfo)&&i.threadInfo._updateFrom(a.threadInfo),d.label=5;case 5:return r=n.next(),[3,3];case 6:return[3,9];case 7:return u={error:d.sent()},[3,9];case 8:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}
1return[7];case 9:return o=e.map(function(e){return l._serialize(e)}),[4,this.collection.upsertMany(o)];case 10:return d.sent(),[4,this.upsertChildMessages(e)];case 11:return d.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 12:d.sent(),d.label=13;case 13:return[2]}})})},t.prototype.upsertChildMessages=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=[],(null===(n=e.threadInfo)||void 0===n?void 0:n.replyCount)&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=r.sent(),r.label=2;case 2:return t.length>0?(t.forEach(function(t){return t.applyParentMessage(e)}),[4,this.upsert(t)]):[3,4];case 3:r.sent(),r.label=4;case 4:return[2]}})})}))]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),n=(t=(0,s.w)(e)).next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove("".concat(r))]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i={error:o.sent()},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}return[7];case 8:return[2]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:r5(r$.CHANNEL_LATEST)})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}})})},t.prototype.removeUnderOffset=function(e,t,n){return void 0===n&&(n=!1),(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(r){switch(r.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:n?{"<=":t}:{"<":t}},index:r5(r$.CHANNEL_LATEST)})]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.countBetween=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=r5(r$.CHANNEL_LATEST),[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}})})},t.prototype.saveBlobs=function(e){return(0,s._)(this,void 0,void 0,function(){var t=this;return(0,s.b)(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(e){return(0,s._)(t,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return e instanceof W&&e.messageParams&&(t=e.messageParams).file&&ex(t.file)?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,2];case 1:n=r.sent(),t.fileKey=n,r.label=2;case 2:return[2]}})})}))];case 1:return n.sent(),[2]}})})},t.prototype._getGroupChannelPreferenceSize=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a,o;return(0,s.b)(this,function(s){switch(s.label){case 0:return t=0,[4,(n=this._cacheContext.preference).get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 1:return r=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 2:return i=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 3:return a=s.sent(),[4,n.get("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 4:return o=s.sent(),r&&(t+=JSON.stringify(r).length),i&&(t+=JSON.stringify(i).length),a&&(t+=JSON.stringify(a).length),o&&(t+=JSON.stringify(o).length),[2,t]}})})},t}(s.ap),iu={},ic=function(e){function t(t){var n=e.call(this,t)||this;return iu[t]=n,n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_sdkState",{get:function(){return s.V.of(this._iid).sdkState}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext},enumerable:!1,configurable:!0}),t.of=function(e,n){return void 0===n&&(n=!1),iu[e]&&!n||(iu[e]=new t(e)),iu[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(nr)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e){return(0,s.d)({},e.serialize())},t.prototype._deserialize=function(e){return ib.of(this._iid).buildMessageFromSerializedData(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=n.sent())return[2,this._deserialize(t)];n.label=2;case 2:return[2,void 0]}})})},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,r=e.limit,i=void 0===r?100:r,a=e.filter,o=void 0===a?new r2:a,u=e.backward,c=void 0!==u&&u,l=e.exactMatch,d=void 0!==l&&l,h=e.inclusive,f=void 0===h||h;return(0,s._)(this,void 0,void 0,function(){var e,r=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(e={where:{channelUrl:t,"/where":function(e){if(n){if(d&&e.createdAt!==n)return!1;if(c){if(f&&e.createdAt<n||!f&&e.createdAt<=n)return!1}else if(f&&e.createdAt>n||!f&&e.createdAt>=n)return!1}return o.match(r._deserialize(e))}},index:["channelUrl","-createdAt","-notificationId"],backward:c},[4,this.collection.query(e)]):[3,3];case 1:return[4,s.sent().fetch({limit:null!=i?i:void 0})];case 2:return[2,s.sent().map(function(e){return r._deserialize(e)})];case 3:return[2,[]]}})})},t.prototype.upsert=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n=this;return(0,s.b)(this,function(r){switch(r.label){case 0:return this.localCacheEnabled?(t=e.map(function(e){return n._serialize(e)}),[4,this.collection.upsertMany(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n,r,i,a;return(0,s.b)(this,function(o){switch(o.label){case 0:if(!this.localCacheEnabled)return[3,8];o.label=1;case 1:o.trys.push([1,6,7,8]),n=(t=(0,s.w)(e)).next(),o.label=2;case 2:return n.done?[3,5]:(r=n.value,[4,this.collection.remove(r)]);case 3:o.sent(),o.label=4;case 4:return n=t.next(),[3,2];case 5:return[3,8];case 6:return i={error:o.sent()},[3,8];case 7:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(i)throw i.error}return[7];case 8:return[2]}})})},t.prototype.markAsReadByTimestamp=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,messageStatus:R.SENT,createdAt:{"<":t}}},{set:{messageStatus:R.READ}})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.markAsReadByMessageIds=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.updateIf({where:{channelUrl:e,notificationId:{"/in":t},messageStatus:R.SENT}},{set:{messageStatus:R.READ}})]:[3,2];case 1:return[2,n.sent().length];case 2:return[2,0]}})})},t.prototype.removeMessagesOfChannel=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e},index:["channelUrl","-createdAt","-notificationId"]})]:[3,6];case 1:return n.sent(),[4,(t=this._cacheContext.preference).remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync"))];case 2:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/sync.meta"))];case 3:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs"))];case 4:return n.sent(),[4,t.remove("sendbird:".concat(this._sdkState.userId,"@groupchannel/").concat(e,"/message/changelogs.meta"))];case 5:n.sent(),n.label=6;case 6:return[2]}})})},t.prototype.removeUnderOffset=function(e,t){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(n){switch(n.label){case 0:return this.localCacheEnabled?[4,this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:r5(r$.CHANNEL_LATEST)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return this.localCacheEnabled?[4,this.collection.clear()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.countBetween=function(e,t,n){return(0,s._)(this,void 0,void 0,function(){var r,i=this;return(0,s.b)(this,function(s){switch(s.label){case 0:return this.localCacheEnabled?(r=["channelUrl","-createdAt","-notificationId"],[4,this.collection.query({where:{channelUrl:e,"/where":function(e){var r=i._deserialize(e);return n.includes(r.createdAt)&&t.match(r)}},index:r}).count()]):[3,2];case 1:return[2,s.sent()];case 2:return[2,0]}})})},t}(s.ap),il={},id=function(e){function t(t){var n=e.call(this,t)||this;return n._observers=new Map,n._dispatcherContext=n._dispatcher.on(function(e){return(0,s._)(n,void 0,void 0,function(){var t,n,r,i,a,o,u,c,l,d,h,f,p,m,_,v,y,g,b,I,E=this;return(0,s.b)(this,function(w){switch(w.label){case 0:return e instanceof s.ax?(t=e.messages,I=e.source,o=e.isWebSocketEventComing,n=t.filter(function(e){return e instanceof D&&e.channelType!==s.C.OPEN&&e.messageId>0}),r=t.filter(function(e){return e instanceof D&&e.channelType!==s.C.OPEN&&0===e.messageId}),i=t.filter(function(e){return e instanceof Q}),n.length>0?[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(n)];case 1:return e.sent(),[4,this._unsentMessageCache.remove(n.map(function(e){return e instanceof L?e.reqId:null}).filter(function(e){return null!==e}))];case 2:return e.sent(),[2]}})})})]:[3,2]):[3,7];case 1:w.sent(),o||this._broadcastUpdateEvent(n,I),w.label=2;case 2:return r.length>0?[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.upsert(r)];case 1:return e.sent(),[2]}})})})]:[3,4];case 3:w.sent(),o||this._broadcastUpdateEvent(r,I),w.label=4;case 4:return i.length>0?[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._notificationCache.upsert(i)];case 1:return e.sent(),[2]}})})})]:[3,6];case 5:w.sent(),o||this._broadcastUpdateEvent(i,I),w.label=6;case 6:return[3,24];case 7:return e instanceof s.b6?(a=e.messageIds,I=e.source,o=e.isWebSocketEventComing,u=a.filter(function(e){return"number"==typeof e}),c=a.filter(function(e){return"string"==typeof e}),[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return u.length>0?[4,this._messageCache.remove(u)]:[3,2];case 1:e.sent(),e.label=2;case 2:return c.length>0?[4,this._notificationCache.remove(c)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2]}})})})]):[3,9];case 8:return w.sent(),o||this._broadcastRemoveEvent(a,I),[3,24];case 9:return e instanceof s.b5?(l=e.reqId,I=e.source,[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._unsentMessageCache.remove([l])];case 1:return e.sent(),[2]}})})})]):[3,11];case 10:return w.sent(),this._broadcastRemoveUnsentEvent(l,I),[3,24];case 11:return e instanceof s.b4?(d=e.polls,I=e.source,this._cacheContext.localCacheEnabled?[4,Promise.all(d.map(function(e){return e.messageId}).map(function(e){return E._messageCache.get(e)}))]:[3,14]):[3,15];case 12:return(h=w.sent().filter(function(e){return e})).length>0&&d.forEach(function(e){var t=h.find(function(t){return t.messageId===e.messageId});t&&t.applyPoll(e)}),[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert(h)];case 1:return[2,e.sent()]}})})})];case 13:w.sent(),w.label=14;case 14:return this._broadcastPollChangeLogEvent(d,I),[3,24];case 15:return e instanceof s.b3?(f=e.event,I=e.source,[4,this._messageCache.get(f.messageId)]):[3,19];case 16:return(p=w.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(f)?[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([p])];case 1:return[2,e.sent()]}})})})]:[3,18];case 17:w.sent(),w.label=18;case 18:return this._broadcastPollUpdateEvent(f,I),[3,24];case 19:return e instanceof s.aV?(m=e.event,I=e.source,[4,this._messageCache.get(m.messageId)]):[3,23];case 20:return(_=w.sent())&&_.isUserMessage()&&_.poll&&_.poll.applyPollVoteEvent(m)?[4,(0,s.J)(function(){return(0,s._)(E,void 0,void 0,function(){return(0,s.b)(this,function(e){switch(e.label){case 0:return[4,this._messageCache.upsert([_])];case 1:return[2,e.sent()]}})})})]:[3,22];case 21:w.sent(),w.label=22;case 22:return this._broadcastPollVoteEvent(m,I),[3,24];case 23:e instanceof s.b0?(v=e.event,I=e.source,v.messageId>0&&this._broadcastReactionUpdateEvent(v,I)):e instanceof s.b1?(y=e.event,I=e.source,this._broadcastThreadUpdateEvent(y,I)):e instanceof s.b2&&(g=e.messageDeletionTimestamp,b=e.channelUrl,I=e.source,this._broadcastMessageRetentionEvent(g,b,I)),w.label=24;case 24:return[2]}})})}),n}return(0,s.c)(t,e),Object.defineProperty(t.prototype,"_cacheContext",{get:function(){return s.V.of(this._iid).cacheContext}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dispatcher",{get:function(){return s.V.of(this._iid).dispatcher},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_messageCache",{get:function(){return io.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_unsentMessageCache",{get:function(){return is.of(this._iid)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notificationCache",{get:function(){return ic.of(this._iid)},enumerable:!1,configurable:!0}),t.of=function(e,n){var r;return void 0===n&&(n=!1),il[e]&&!n||(il[e]&&(null===(r=il[e]._dispatcherContext)||void 0===r||r.close()),il[e]=new t(e)),il[e]},t.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onUpdate&&o.onUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollChangeLogEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollChangeLogUpdate&&o.onPollChangeLogUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollUpdate&&o.onPollUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastPollVoteEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onPollVote&&o.onPollVote(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onRemove&&o.onRemove(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastRemoveUnsentEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onRemoveUnsent&&o.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastReactionUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onReactionUpdate&&o.onReactionUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastThreadUpdateEvent=function(e,t){var n,r;try{for(var i=(0,s.w)(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onThreadInfoUpdate&&o.onThreadInfoUpdate(e,t)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}},t.prototype._broadcastMessageRetentionEvent=function(e,t,n){var r,i;try{for(var a=(0,s.w)(this._observers.values()),o=a.next();!o.done;o=a.next()){var u=o.value;u.onDeletedByRetentionPolicy&&u.onDeletedByRetentionPolicy(e,t,n)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}},t.prototype.subscribe=function(e,t){this._observers.set(e,t)},t.prototype.unsubscribe=function(e){this._observers.delete(e)},t.prototype.unsubscribeAll=function(){this._observers.clear()},t}(s.ap),ih={},ip=function(e){function t(t,n){var r=n.sdkState,i=n.cacheContext,s=e.call(this,t)||this;return s._users=new Map,s._sdkState=r,s._cacheContext=i,ih[t]=s,s}return(0,s.c)(t,e),t.of=function(e){return ih[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return(0,s.F)(!!e).throw(s.t.databaseError),e.collection(nc)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCacheEnabled",{get:function(){return this._cacheContext.localCacheEnabled&&!!this.collection}
1,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return(0,s.q)([],(0,s.r)(this._users.values()),!1)},enumerable:!1,configurable:!0}),t.prototype._serialize=function(e,t){return(0,s.d)((0,s.d)({},e.serialize()),{updatedAt:t})},t.prototype._deserialize=function(e){return s.U._buildUserFromSerializedData(e)},t.prototype.isCachedInMemory=function(e){return this._users.has(e)},t.prototype.getUserInfoFromCache=function(e){if(this._users.has(e))return this._users.get(e)},t.prototype.get=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return this._users.has(e)?[3,3]:this.localCacheEnabled?[4,this.collection.getByKey(e)]:[3,2];case 1:if(t=r.sent())return n=this._deserialize(t),this._users.set(n.userId,n),[2,n];r.label=2;case 2:return[2,void 0];case 3:return[2,this._users.get(e)]}})})},t.prototype.fetch=function(e){var t=e.limit,n=void 0===t?100:t,r=e.backward,i=void 0!==r&&r;return(0,s._)(this,void 0,void 0,function(){var e,t,r=this;return(0,s.b)(this,function(s){switch(s.label){case 0:if(!this.localCacheEnabled)return[2,[]];s.label=1;case 1:return s.trys.push([1,4,,5]),e={index:["-userId","-updatedAt"],backward:i},[4,this.collection.query(e)];case 2:return[4,s.sent().fetch({limit:n})];case 3:return(t=s.sent().map(function(e){return r._deserialize(e)})).forEach(function(e){r._users.has(e.userId)||r._users.set(e.userId,e)}),[2,t];case 4:return s.sent(),[2,[]];case 5:return[2]}})})},t.prototype.upsert=function(e,t){return(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:if(!this.localCacheEnabled)return[3,2];if(n=this._serialize(e,t),(r=this._users.get(e.userId))&&(r._hashValue===e._hashValue||r._updatedAt>t))return[2];return this._users.set(e.userId,s.U._buildUserFromSerializedData(n)),[4,this.collection.upsertOne(n)];case 1:i.sent(),i.label=2;case 2:return[2]}})})},t.prototype.remove=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){switch(t.label){case 0:return this._users.has(e)&&this._users.delete(e),this.localCacheEnabled?[4,this.collection.remove(e)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},t.prototype.clearMemoryCache=function(){this._users.clear()},t.prototype.clear=function(){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(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]}})})},t}(s.ap),im=function(e){function t(t){var n=this,r=t.reverse,i=t.limit,a=t.keys,o=t.token;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat(s.b7),n.params=(0,s.f)({token:o,limit:void 0===i?20:i,reverse:void 0!==r&&r,order:s.b8.UPDATED_AT,show_ui_template:!0,show_color_variables:!0,keys:a}),n}return(0,s.c)(t,e),t}(s.h),i_=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.next,s=n.has_more,a=n.templates;return r.nextToken=i,r.hasMore=void 0!==s&&s,r.templates=a.map(function(e){return{template:JSON.stringify(e)}}),r}return(0,s.c)(t,e),t}(s.j),iv=function(e){function t(t){var n=this,r=t.key;return(n=e.call(this)||this).method=s.A.GET,n.path="".concat(s.b7,"/").concat(r),n}return(0,s.c)(t,e),t}(s.h),iy=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return(0,s.c)(t,e),t}(s.j),ig={},ib=function(){function e(e,t){var n=t.sdkState,r=t.dispatcher,i=t.requestQueue,s=t.onlineDetector,a=t.cacheContext;this._iid=e,this._sdkState=n,this._requestQueue=i,this._dispatcher=r,this._cacheContext=a,io.of(e),is.of(e),id.of(e),this.fileMessageQueue=new ea(e,{sdkState:n,dispatcher:r,requestQueue:i,onlineDetector:s,cacheContext:a}),ig[e]=this}return e.of=function(e){return ig[e]},e.prototype._setSenderInfo=function(e){if(this._cacheContext.localCacheEnabled&&(e.messageType===s.ar.USER||e.messageType===s.ar.FILE)){var t=e.sender;if(t){var n=ip.of(this._iid),r=n.getUserInfoFromCache(t.userId);if(r){var i=(0,s.d)((0,s.d)({},e.sender),{nickname:r.nickname,profileUrl:r.plainProfileUrl,requireAuth:r.requireAuth,metadata:r.metaData}
1);e.sender=i}else n.upsert(new s.U(this._iid,s.U.payloadify(t)),e.createdAt)}}},e.prototype.buildMessageFromSerializedData=function(e){var t=(0,s.I)(e);if(t.notificationId)return new Q(this._iid,Q.payloadify(t));switch(this._setSenderInfo(t),t.messageType){case s.ar.USER:return new B(this._iid,B.payloadify(t));case s.ar.FILE:return K._isMultipleFilesMessageSerializedData(t)?new K(this._iid,K.payloadify(t)):new W(this._iid,W.payloadify(t));case s.ar.ADMIN:return new z(this._iid,z.payloadify(t))}throw s.t.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return(0,s.f)((0,s.g)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,mentionedMessageTemplate:t.mentionedMessageTemplate,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,message:t.message,translationTargetLanguages:Object.keys(t.translations),pollId:e.pollId}))},e.prototype.buildFileMessageCreateParamsFromSerializedData=function(e,t){var n;return(0,s.f)((0,s.g)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,file:e.file,fileKey:e.fileKey,fileUrl:t.plainUrl,fileName:t.name,fileSize:t.size,mimeType:t.type,thumbnailSizes:null===(n=t.thumbnails)||void 0===n?void 0:n.map(function(e){return{maxWidth:e.width,maxHeight:e.height}}),fileType:e.fileType,requireAuth:t.requireAuth}))},e.prototype.buildMultipleFilesMessageCreateParamsFromSerializedData=function(e,t){var n=this;return(0,s.f)({data:t.data,customType:t.customType,mentionType:t.mentionType,mentionedUserIds:t.mentionedUserIds,mentionedUsers:t.mentionedUsers,metaArrays:t.metaArrays,parentMessageId:t.parentMessageId,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,appleCriticalAlertOptions:t.appleCriticalAlertOptions,reqId:t.reqId,fileInfoList:e.fileInfoList.map(function(e){return new Y(n._iid,e)})})},e.prototype.buildScheduledUserMessageCreateParamsFromSerializedData=function(e,t){return(0,s.d)((0,s.d)({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return(0,s.d)((0,s.d)({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=(0,s.I)(e);return new _(this._iid,_.payloadify(t))},e.prototype.getMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new ef(e),[4,this._requestQueue.send(t)];case 1:return[2,n.sent().as(ep).message]}})})},e.prototype.getScheduledMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new eg(e),[4,this._requestQueue.send(t)];case 1:return[2,n.sent().as(eb).message]}})})},e.prototype.getMessagesByMessageId=function(e,t,n,r,i){return void 0===i&&(i=s.ab.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return a=new em((0,s.d)((0,s.d)((0,s.d)({channelType:t,channelUrl:e,token:String(n)},eo),r),{sdkSource:es.EXTERNAL_LEGACY})),[4,this._requestQueue.send(a)];case 1:return o=u.sent().as(e_).messages,this._dispatcher.dispatch(new s.ax({messages:o,source:i})),[2,o]}})})},e.prototype.getMessagesByTimestamp=function(e,t,n,r,i){return void 0===i&&(i=s.ab.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return a=new em((0,s.d)((0,s.d)((0,s.d)({channelType:t,channelUrl:e,timestamp:n},eo),r),{sdkSource:es.EXTERNAL_LEGACY})),[4,this._requestQueue.send(a)];case 1:return o=u.sent().as(e_).messages,this._dispatcher.dispatch(new s.ax({messages:o,source:i})),[2,o]}})})},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,r,i,a,o,u){return void 0===i&&(i=s.ab.REQUEST_MESSAGE),(0,s._)(this,void 0,void 0,function(){var c,l,d,h,f;return(0,s.b)(this,function(p){switch(p.label){case 0:return c=new em((0,s.d)((0,s.d)((0,s.d)({channelType:t,channelUrl:e,timestamp:n},eo),r),{checkingHasNext:a,checkingContinuousMessages:o,sdkSource:u})),[4,this._requestQueue.send(c)];case 1:return d=(l=p.sent().as(e_)).messages,h=l.isContinuousMessages,f=l.hasNext,this._dispatcher.dispatch(new s.ax({messages:d,source:i})),[2,{messages:d,isContinuousMessages:h,hasNext:f}]}})})},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,r){return void 0===r&&(r=s.ab.REQUEST_THREADED_MESSAGE),(0,s._)(this,void 0,void 0,function(){var i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return i=new em((0,s.d)((0,s.d)((0,s.d)({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},F),n),{replyType:s.aH.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(i)];
1case 1:return(o=(a=u.sent().as(e_).messages).slice(1)).forEach(function(t){t.parentMessage=e}),this._dispatcher.dispatch(new s.ax({messages:o,source:r})),[2,{parentMessage:a[0],threadedMessages:o}]}})})},e.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n,r;return(0,s.b)(this,function(i){switch(i.label){case 0:return n=new im((0,s.d)({token:e},t)),[4,this._requestQueue.send(n)];case 1:return[2,{hasMore:(r=i.sent().as(i_)).hasMore,token:r.nextToken,templates:r.templates}]}})})},e.prototype.getMessageTemplate=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){switch(n.label){case 0:return t=new iv({key:e}),[4,this._requestQueue.send(t)];case 1:return[2,{template:n.sent().as(iy).template}]}})})},e.prototype.getMessageChangelogs=function(e,t,n,r,i){return void 0===i&&(i=s.ab.REQUEST_MESSAGE_CHANGELOGS),(0,s._)(this,void 0,void 0,function(){var a,o,u,c,l,d,h,f;return(0,s.b)(this,function(p){switch(p.label){case 0:return a=new ev((0,s.f)((0,s.g)((0,s.d)((0,s.d)({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},ec),r)))),[4,this._requestQueue.send(a)];case 1:return u=(o=p.sent().as(ey)).updatedMessages,c=o.deletedMessagesInfo,l=o.hasMore,d=o.nextToken,h=o.forceUseNextToken,f=c.map(function(e){return e.messageId}),u.length>0&&this._dispatcher.dispatch(new s.ax({messages:u,source:i})),f.length>0&&this._dispatcher.dispatch(new s.b6({messageIds:f,source:i})),[2,{updatedMessages:u,deletedMessageIds:f,hasMore:l,token:d,forceUseNextToken:h}]}})})},e}(),iI=function(e){function t(t,n){var r=e.call(this,t)||this;r.targetMessageId=0;var i=n.thread_info,a=n.parent_message_id,o=n.channel_url,u=n.channel_type;return i&&(0,s.a)("object",i)&&(0,s.a)("number",a)&&(0,s.a)("string",o)&&(0,s.a)("string",u)&&(r.threadInfo=new c(t,i),r.targetMessageId=a,r.channelUrl=o,r.channelType=u),r}return(0,s.c)(t,e),t}(s.ap),iE={channelUrl:"",channelType:s.C.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},iw=function(e){function t(t){var n=t.channelCustomType,r=t.keyword,i=t.limit,a=t.reverse,o=t.exactMatch,u=t.channelUrl,c=t.order,l=t.messageTimestampFrom,d=t.messageTimestampTo,h=t.advancedQuery,f=t.targetFields,p=t.nextToken,m=e.call(this)||this;return m.method=s.A.GET,m.path="".concat(s.b9,"/messages"),m.params=(0,s.f)({custom_type:n,query:r,limit:i,reverse:a,exact_match:o,channel_url:u,message_ts_from:l,message_ts_to:d,sort_field:c,advanced_query:h,target_fields:f,after:p}),m}return(0,s.c)(t,e),t}(s.h),iT=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.messages=n.results.map(function(e){return H(t,e)}),r.hasNext=n.has_next,r.nextToken=n.end_cursor,r.totalCount=n.total_count,r}return(0,s.c)(t,e),t}(s.j);(iS=r4||(r4={})).SCORE="score",iS.TIMESTAMP="ts";var iS,iA,iM=function(e){function t(t,n){var r,i,s,a,o,u,c,l,d,h=this;return(h=e.call(this,t,n)||this).keyword="",h.reverse=!1,h.exactMatch=!1,h.channelUrl=null,h.channelCustomType=null,h.messageTimestampFrom=null,h.messageTimestampTo=null,h.order=r4.SCORE,h.advancedQuery=!1,h.targetFields=null,h._nextToken="",h.totalCount=-1,h.keyword=n.keyword,h.reverse=null!==(r=n.reverse)&&void 0!==r&&r,h.exactMatch=null!==(i=n.exactMatch)&&void 0!==i&&i,h.channelUrl=null!==(s=n.channelUrl)&&void 0!==s?s:null,h.channelCustomType=null!==(a=n.channelCustomType)&&void 0!==a?a:null,h.messageTimestampFrom=null!==(o=n.messageTimestampFrom)&&void 0!==o?o:null,h.messageTimestampTo=null!==(u=n.messageTimestampTo)&&void 0!==u?u:null,h.order=null!==(c=n.order)&&void 0!==c?c:r4.SCORE,h.advancedQuery=null!==(l=n.advancedQuery)&&void 0!==l&&l,h.targetFields=null!==(d=n.targetFields)&&void 0!==d?d:null,h}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)&&(0,s.a)("string",this.keyword)&&this.keyword.length>0&&(0,s.a)("boolean",this.reverse)&&(0,s.a)("boolean",this.exactMatch)&&(0,s.a)("string",this.channelUrl,!0)&&(0,s.a)("string",this.channelCustomType,!0)&&(0,s.a)("number",this.messageTimestampFrom,!0)&&(0,s.a)("number",this.messageTimestampTo,!0)&&(0,s.a5)(r4,this.order)&&(0,s.a)("boolean",this.advancedQuery)&&(0,s.a2)("string",this.targetFields,!0)},t.prototype.next=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i,a,o;return(0,s.b)(this,function(u){switch(u.label){case 0:return this._val
1idate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new iw((0,s.g)((0,s.d)((0,s.d)({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=u.sent().as(iT)).messages,i=n.hasNext,a=n.nextToken,o=n.totalCount,this._nextToken=a,this._hasNext=i,this._isLoading=!1,this.totalCount=o,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aX),iU=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.limit,a=t.token,o=e.call(this)||this;return o.method=s.A.GET,o.path="".concat((0,s.av)(n),"/").concat(encodeURIComponent(r),"/messages/parent_thread_message"),o.params=(0,s.f)((0,s.g)({limit:i,token:a})),o}return(0,s.c)(t,e),t}(s.h),iN=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.next,r.messages=n.messages.map(function(e){return H(t,e)}),r}return(0,s.c)(t,e),t}(s.j),iC=function(e){function t(t,n,r,i){var s=e.call(this,t,n,r,i)||this;return s._edge="",s}return(0,s.c)(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.load=function(){return(0,s._)(this,void 0,void 0,function(){var e,t,n,r,i;return(0,s.b)(this,function(a){switch(a.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=s.V.of(this._iid).requestQueue,t=new iU({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),[4,e.send(t)]):[3,2]:[3,5];case 1:return r=(n=a.sent().as(iN)).messages,i=n.token,this._edge=i,this._hasNext=!!i,this._isLoading=!1,[2,r];case 2:return[2,[]];case 3:throw s.t.queryInProgress;case 4:return[3,6];case 5:throw s.t.invalidParameters;case 6:return[2]}})})},t}(s.aK),ik={channelUrl:"",scheduledMessageId:0};(iO=iA||(iA={})).GOOD="good",iO.BAD="bad";var iO,iP,ix={reverse:!1,limit:20};(r=iP||(iP={})).TEXT="text",r.TEXTAREA="textarea",r.NUMBER="number",r.PHONE="phone",r.EMAIL="email",r.CHIP="chip";var iR=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="message",t}return(0,s.c)(t,e),t.prototype.init=function(t,n){var r=n.sdkState,i=n.dispatcher,s=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:i,sessionManager:s,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new ib(t,{sdkState:r,dispatcher:i,requestQueue:a,onlineDetector:u,cacheContext:c})},t.prototype.buildMessageFromSerializedData=function(e){return this._manager.buildMessageFromSerializedData(e)},t.prototype.buildSenderFromSerializedData=function(e){return this._manager.buildSenderFromSerializedData(e)},t.prototype.getMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t,n;return(0,s.b)(this,function(r){switch(r.label){case 0:return t=(0,s.d)((0,s.d)({},iE),e),(0,s.F)((0,s.a)("string",t.channelUrl)&&(0,s.a5)(s.C,t.channelType)&&(0,s.a)("number",t.messageId)&&(0,s.a)("boolean",t.includeReactions,!0)&&(0,s.a)("boolean",t.includeMetaArray,!0)&&(0,s.a)("boolean",t.includeParentMessageInfo,!0)&&(0,s.a)("boolean",t.includeThreadInfo,!0)).throw(s.t.invalidParameters),[4,this._manager.getMessage(t)];case 1:if((n=r.sent())instanceof D||n instanceof Q||null===n)return[2,n];throw"Unknown message type is given."}})})},t.prototype.getScheduledMessage=function(e){return(0,s._)(this,void 0,void 0,function(){var t;return(0,s.b)(this,function(n){return t=(0,s.d)((0,s.d)({},ik),e),(0,s.F)((0,s.a)("string",t.channelUrl)&&""!==t.channelUrl&&(0,s.a)("number",t.scheduledMessageId)&&t.scheduledMessageId>0).throw(s.t.invalidParameters),[2,this._manager.getScheduledMessage(t)]})})},t.prototype.getMessageTemplatesByToken=function(e,t){return void 0===t&&(t={}),(0,s._)(this,void 0,void 0,function(){var n;return(0,s.b)(this,function(r){return n=(0,s.d)((0,s.d)({},ix),t),(0,s.F)((0,s.a)("string",e,!0)&&(0,s.a)("boolean",n.reverse,!0)&&(0,s.a)("number",n.limit,!0)&&(0,s.a2)("string",n.keys,!0)).throw(s.t.invalidParameters),[2,this._manager.getMessageTemplatesByToken(e,n)]})})},t.prototype.getMessageTemplate=function(e){return(0,s._)(this,void 0,void 0,function(){return(0,s.b)(this,function(t){return(0,s.F)((0,s.a)("string",e)).throw(s.t.invalidParameters),[2,this._manager.getMessageTemplate(e)]})})},t}(s.ba)}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.