=1){if(1===n&&r.type===S.CONV_C2C){var c=this._getConversationLastMessageTime(r);this.updateIsReadAfterReadReport({conversationID:s,lastMessageTime:c})}else if(r.type===S.CONV_GROUP){var u=s.replace(S.CONV_GROUP,\"\");if(this._remoteGroupReadSequenceMap.has(u)){var l=this._remoteGroupReadSequenceMap.get(u),d=this._getConversationLastMessageSequence(r);this.updateIsReadAfterReadReport({conversationID:s,remoteReadSequence:l}),d>=l&&this._remoteGroupReadSequenceMap.delete(u)}}this.updateUnreadCount(s,!1)&&(o+=1)}}}catch(p){a.e(p)}finally{a.f()}return o}},{key:\"isRemoteRead\",value:function(e){var t=e.conversationID,n=e.sequence,o=t.replace(S.CONV_GROUP,\"\"),a=!1;if(this._remoteGroupReadSequenceMap.has(o)){var i=this._remoteGroupReadSequenceMap.get(o);n<=i&&(a=!0,Je.l(\"\".concat(this._n,\".isRemoteRead conversationID:\").concat(t,\" messageSequence:\").concat(n,\" remoteReadSequence:\").concat(i))),n>=i+10&&this._remoteGroupReadSequenceMap.delete(o)}return a}},{key:\"updateIsReadAfterReadReport\",value:function(e){var t=e.conversationID,n=e.lastMessageSeq,o=e.lastMessageTime,a=this._messageListHandler.getLocalMessageList(t);if(0!==a.length)for(var i,s=a.length-1;s>=0;s--)if(i=a[s],!(o&&i.time>o||n&&i.sequence>n)){if(\"in\"===i.flow&&i.isRead)break;i.setIsRead(!0)}}},{key:\"updateUnreadCount\",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!1,o=this.getLocalConversation(e),a=this._messageListHandler.getLocalMessageList(e);if(o){var i=o.unreadCount,s=a.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;if(i!==s&&(o.unreadCount=s,n=!0,Je.l(\"\".concat(this._n,\".updateUnreadCount from \").concat(i,\" to \").concat(s,\", conversationID:\").concat(e)),!0===t&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())),n&&o.type===S.CONV_TOPIC){var r=o.unreadCount,c=this.getModule(oo),u=e.replace(S.CONV_GROUP,\"\");c.onConversationProxy({topicID:u,unreadCount:r})}return n}}},{key:\"clearGroupAtInfoList\",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getLocalConversation(e);if(n&&n.groupAtInfoList.length>0){if(n.clearGroupAtInfoList(),Je.l(\"\".concat(this._n,\".clearGroupAtInfoList conversationID:\").concat(e)),n.type===S.CONV_TOPIC){var o=n.groupAtInfoList,a=this.getModule(oo),i=e.replace(S.CONV_GROUP,\"\");a.onConversationProxy({topicID:i,groupAtInfoList:o})}!0===t&&this.emitConversationUpdate(!0,!1)}}},{key:\"updateReadReceiptInfo\",value:function(e){var t=this,n=e.userID,o=void 0===n?void 0:n,a=e.groupID,i=void 0===a?void 0:a,s=e.readReceiptList;if(!pn(s)){var r=[];if(mt(o)){if(!mt(i)){var c=\"\".concat(S.CONV_GROUP).concat(i);s.forEach((function(e){var n=e.tinyID,o=e.clientTime,a=e.random,s=e.readCount,u=e.unreadCount,l=\"\".concat(n,\"-\").concat(o,\"-\").concat(a),d=t._messageListHandler.getLocalMessage(c,l),p={groupID:i,messageID:l,readCount:0,unreadCount:0};d&&(_t(s)&&(d.readReceiptInfo.readCount=s,p.readCount=s),_t(u)&&(d.readReceiptInfo.unreadCount=u,p.unreadCount=u),r.push(p))}))}}else{var u=\"\".concat(S.CONV_C2C).concat(o);s.forEach((function(e){var n=e.tinyID,a=e.clientTime,i=e.random,s=\"\".concat(n,\"-\").concat(a,\"-\").concat(i),c=t._messageListHandler.getLocalMessage(u,s);if(c){c.readReceiptInfo.isPeerRead=!0;var l={userID:o,messageID:s,isPeerRead:!0};r.push(l)}}))}r.length>0&&this.emitOuterEvent(E.MESSAGE_READ_RECEIPT_RECEIVED,r)}}},{key:\"updateIsRead\",value:function(e){var t=this.getLocalConversation(e),n=this.getLocalMessageList(e);if(t&&0!==n.length&&!Vt(t.type)){for(var o=[],a=0,i=n.length;a0){var n=this._messageListHandler.updateMessageIsPeerReadProperty(e,t);if(n.length>0&&this.emitOuterEvent(E.MESSAGE_READ_BY_PEER,n),this._conversationMap.has(e)){var o=this._conversationMap.get(e).lastMessage;pn(o)||o.fromAccount===this.getMyUserID()&&o.lastTime<=t&&!o.isPeerRead&&(o.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}},{key:\"updateMessageIsModifiedProperty\",value:function(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}},{key:\"setCompleted\",value:function(e){Je.l(\"\".concat(this._n,\".setCompleted. conversationID:\").concat(e)),this._completedMap.set(e,!0)}},{key:\"updateRoamingMessageKeyAndTime\",value:function(e,t,n){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:n})}},{key:\"updateRoamingMessageSequence\",value:function(e,t){this._roamingMessageSequenceMap.set(e,t)}},{key:\"getConversationList\",value:function(e){var t=this,n=\"\".concat(this._n,\".\").concat(\"getConversationList\"),o=\"pagingStatus:\".concat(this._pagingStatus,\", local conversation count:\").concat(this._conversationMap.size,\", options:\").concat(e);if(Je.l(\"\".concat(n,\". \").concat(o)),this._pagingStatus===vn.REJECTED){var a=new Xo(\"getConversationList\");return a.setMessage(o),this.syncConversationList().then((function(){a.setNetworkType(t.getNetworkType()).end();var n=t._getConversationList(e);return No({conversationList:n,isSyncCompleted:t._isSyncCompleted()})})).catch((function(e){return t.probeNetwork().then((function(t){var n=v(t,2),o=n[0],i=n[1];a.setError(e,o,i).end()})),Je.e(\"\".concat(n,\" failed. error:\"),e),Go(e)}))}var i=this._getConversationList(e);return Je.l(\"\".concat(n,\". returned conversation count:\").concat(i.length)),Oo({conversationList:i,isSyncCompleted:this._isSyncCompleted()})}},{key:\"_getConversationList\",value:function(e){if(mt(e))return this.getLocalConversationList();if(vt(e))return 0===e.length?[]:this.getLocalConversationList().filter((function(t){return e.includes(t.conversationID)}));if(ft(e)){var t=e.type,n=e.markType,o=e.groupName;return this.getLocalConversationList().filter((function(e){return(t!==S.CONV_C2C&&t!==S.CONV_GROUP||e.type===t)&&(!gt(o)||e.conversationGroupList.includes(o))&&(!_t(n)||e.markList.includes(n))}))}return[]}},{key:\"_handleC2CPeerReadTime\",value:function(){var e,t=D(this._conversationMap);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2),o=n[0],a=n[1];a.type===S.CONV_C2C&&(Je.d(\"\".concat(this._n,\"._handleC2CPeerReadTime conversationID:\").concat(o,\" peerReadTime:\").concat(a.peerReadTime)),this.recordPeerReadTime(o,a.peerReadTime))}}catch(i){t.e(i)}finally{t.f()}}},{key:\"_isPagingGetGroupListCompleted\",value:function(){var e=this.getModule(to);return!e||e.isPagingGetCompleted()}},{key:\"_getLocalGroupCount\",value:function(){var e=this.getModule(to);return e?e.getLocalGroupList().length:0}},{key:\"_hasLocalGroup\",value:function(e){var t=this.getModule(to);return!!t&&t.hasLocalGroup(e.replace(S.CONV_GROUP,\"\"))}},{key:\"getConversationProfile\",value:function(e){var t,n=this;if((t=this._conversationMap.has(e)?this._conversationMap.get(e):new Aa({conversationID:e,type:e.slice(0,3)===S.CONV_C2C?S.CONV_C2C:S.CONV_GROUP},this.isIntl(),this.isUsingChatCore()))._isInfoCompleted||t.type===S.CONV_SYSTEM)return Oo({conversation:t});if(xt(e)&&!this._hasLocalGroup(e))return Oo({conversation:t});var o=\"\".concat(this._n,\".\").concat(\"getConversationProfile\"),a=new Xo(\"getConversationProfile\");return Je.l(\"\".concat(o,\". conversationID:\").concat(e,\" remark:\").concat(t.remark,\" lastMessage:\"),t.lastMessage),this._updateUserOrGroupProfileCompletely(t).then((function(i){a.setNetworkType(n.getNetworkType()).setMessage(\"conversationID:\".concat(e,\" unreadCount:\").concat(i.data.conversation.unreadCount)).end();var s=n.getModule(no);if(s&&t.type===S.CONV_C2C){var r=e.replace(S.CONV_C2C,\"\");if(s.isMyFriend(r)){var c=s.getFriendRemark(r);t.remark!==c&&(t.remark=c,Je.l(\"\".concat(o,\". conversationID:\").concat(e,\" patch remark:\").concat(t.remark)))}}return Je.l(\"\".concat(o,\" ok. conversationID:\").concat(e)),i})).catch((function(t){return n.probeNetwork().then((function(n){var o=v(n,2),i=o[0],s=o[1];a.setError(t,i,s).setMessage(\"conversationID:\".concat(e)).end()})),Je.e(\"\".concat(o,\" failed. error:\"),t),Go(t)}))}},{key:\"_updateUserOrGroupProfileCompletely\",value:function(e){var t=this;return e.type===S.CONV_C2C?this.getModule($n).getUserProfile({userIDList:[e.toAccount]}).then((function(n){var o=n.data;return 0===o.length?Go(new ko({code:Ao.USER_OR_GRP_NOT_FOUND})):(e.userProfile=o[0],e._isInfoCompleted=!0,t._unshiftConversation(e),Oo({conversation:e}))})):this.getModule(to).getGroupProfile({groupID:e.toAccount}).then((function(n){return e.groupProfile=n.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),Oo({conversation:e})}))}},{key:\"_unshiftConversation\",value:function(e){e instanceof Aa&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e]].concat(m(this._conversationMap))),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}},{key:\"_onProfileUpdated\",value:function(e){var t=this;e.data.forEach((function(e){var n=e.userID;if(n===t.getMyUserID())t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{var o=t._conversationMap.get(\"\".concat(S.CONV_C2C).concat(n));o&&(o.userProfile=e)}}))}},{key:\"_isSyncCompleted\",value:function(){return this._pagingStatus===vn.RESOLVED}},{key:\"_errorLog\",value:function(e,t,n,o){var a=new Error(\"Params validate failed.\"),i=\"\".concat(this.getErrorMessage(\"API_REFER\")).concat(e);throw Je.w(\"[\".concat(e,\"] | \").concat(t,\" | \").concat(this.getErrorMessage(n,o),\", \").concat(i)),Je.e(\"[\".concat(e,\"] Invalid \").concat(t,\": type check failed for \").concat(t,\".\")),a}},{key:\"_isValidConversationID\",value:function(e){return qt(e)||xt(e)||Vt(e)}},{key:\"deleteConversation\",value:function(e){var t=this,n=\"deleteConversation\";return gt(e)||ht(e)||this._errorLog(n,\"options\",\"StringOrObjectRequiredLog\"),gt(e)?(this._isValidConversationID(e)||this._errorLog(n,\"options\",\"InvalidConversationID\",e),Je.l(\"\".concat(this._n,\".\").concat(n,\" conversationID:\").concat(e)),this.deleteConversationList({conversationIDList:[e],flag:1})):(vt(e.conversationIDList)||this._errorLog(n,\"conversationIDList\",\"ArrayRequiredLog\"),0===e.conversationIDList.length&&this._errorLog(n,\"conversationIDList\",\"NonEmptyArrayLog\"),e.conversationIDList.forEach((function(e){t._isValidConversationID(e)||t._errorLog(n,\"conversationIDList\",\"InvalidConversationID\",e)})),\"clearHistoryMessage\"in e&&\"boolean\"!=typeof e.clearHistoryMessage&&this._errorLog(n,\"clearHistoryMessage\",\"BooleanRequiredLog\"),e.conversationIDList.length>100&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConversationList(e))}},{key:\"deleteConversationList\",value:function(e){var t=this,n=e.conversationIDList,o=void 0===n?[]:n,a=e.clearHistoryMessage,i=void 0===a||a,s=e.flag,r=void 0===s?0:s,c=\"\".concat(this._n,\".\").concat(\"deleteConversationList\");Je.l(\"\".concat(c,\" conversationIDList.length:\").concat(o.length,\" clearHistoryMessage:\").concat(i));var u=new Xo(\"deleteConversationList\");return u.setMessage(\"conversationIDList:\".concat(o)),Promise.all([this.rmLocalOnlyConversationList(o),this.rmLocalAndRemoteConversationList(o,i)]).then((function(e){u.setNetworkType(t.getNetworkType()).end();var n=[].concat(m(e[0]),m(e[1]));return 0===n.length?Go(new ko({code:Ao.CONV_NOT_FOUND})):(Je.l(\"\".concat(c,\" ok\")),Oo(1===r?{conversationID:n[0]}:{conversationIDList:n}))})).catch((function(e){return t.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),Je.e(\"\".concat(c,\" failed. error:\"),e),Go(e)}))}},{key:\"rmLocalOnlyConversationList\",value:function(e){var t=this;return e.filter((function(e){if(!t._conversationMap.has(e))return!1;var n=t.getLocalConversation(e).type;return n!==S.CONV_GROUP||t._hasLocalGroup(e)?n===S.CONV_SYSTEM&&(t.getModule(to).deleteGroupSystemNotice({messageList:t._messageListHandler.getLocalMessageList(e)}),t.deleteLocalConversation(e),!0):(t.deleteLocalConversation(e),!0)}))}},{key:\"rmLocalAndRemoteConversationList\",value:function(e,t){var n=this,o={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:t?1:0};return e.forEach((function(e){if(n._conversationMap.has(e)){var t=n.getLocalConversation(e).type;t===S.CONV_C2C?o.conversationList.push({toAccount:e.replace(t,\"\"),type:1}):t===S.CONV_GROUP&&n._hasLocalGroup(e)&&o.conversationList.push({toGroupID:e.replace(t,\"\"),type:2})}})),0===o.conversationList.length?[]:this.request({protocolName:Uo.DELETE_CONVERSATION,requestData:o}).then((function(e){var t=[];return e.data.resultList.length>0&&e.data.resultList.map((function(e){if(0===e.code){var n=1===e.type?\"\".concat(S.CONV_C2C).concat(e.to):\"\".concat(S.CONV_GROUP).concat(e.groupID);t.push(n)}})),n.deleteLocalConversationList(t),t}))}},{key:\"setConversationDraft\",value:function(e){var t=e.conversationID,n=e.draftText,o=\"\".concat(this._n,\".\").concat(\"setConversationDraft\");if(Je.l(\"\".concat(o,\" conversationID:\").concat(t,\" draftText:\").concat(n)),!this._conversationMap.has(t))return Go({code:Ao.CONV_NOT_FOUND});var a=this._conversationMap.get(t);return a.setDraftText(n),Oo({code:0,conversation:a})}},{key:\"clearHistoryMessage\",value:function(e){var t=this,n={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e))return Go({code:Ao.CONV_NOT_FOUND});var o=this._conversationMap.get(e).type;if(o===S.CONV_C2C)n.type=1,n.toAccount=e.replace(S.CONV_C2C,\"\");else{if(o!==S.CONV_GROUP)return o===S.CONV_SYSTEM?(this.getModule(to).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),Oo({conversationID:e})):Go({code:Ao.CONV_UN_RECORDED_TYPE});n.type=2,n.toGroupID=e.replace(S.CONV_GROUP,\"\")}var a=\"\".concat(this._n,\".\").concat(\"clearHistoryMessage\"),i=new Xo(\"clearHistoryMessage\");return i.setMessage(\"conversationID:\".concat(e)),Je.l(\"\".concat(a,\". conversationID:\").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.request({protocolName:Uo.CLEAR_HISTORY_MESSAGE,requestData:n})})).then((function(){i.setNetworkType(t.getNetworkType()).end(),Je.l(\"\".concat(a,\" ok\")),t._messageListHandler.removeByConversationID(e),t.setCompleted(e);var n=t.getLocalConversation(e);return n&&(n.updateLastMessage(),t._sortConversationListAndEmitEvent()),Oo({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];i.setError(e,o,a).end()})),Je.e(\"\".concat(a,\" failed. error:\"),e),Go(e)}))}},{key:\"pinConversation\",value:function(e){var t=this,n=e.conversationID,o=e.isPinned;if(!this._conversationMap.has(n))return Go({code:Ao.CONV_NOT_FOUND});var a=this.getLocalConversation(n);if(a.isPinned===o)return Oo({conversationID:n});var i=\"\".concat(this._n,\".\").concat(\"pinConversation\"),s=new Xo(\"pinConversation\");s.setMessage(\"conversationID:\".concat(n,\" isPinned:\").concat(o)),Je.l(\"\".concat(i,\". conversationID:\").concat(n,\" isPinned:\").concat(o));var r=null;return qt(n)?r={type:1,toAccount:n.replace(S.CONV_C2C,\"\")}:xt(n)&&(r={type:2,groupID:n.replace(S.CONV_GROUP,\"\")}),this.request({protocolName:Uo.PIN_CONVERSATION,requestData:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[r]}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),Je.l(\"\".concat(i,\" ok\")),a.isPinned!==o&&(a.isPinned=o,t._sortConversationListAndEmitEvent()),No({conversationID:n})})).catch((function(e){return t.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),Je.e(\"\".concat(i,\" failed. error:\"),e),Go(e)}))}},{key:\"setMessageRemindType\",value:function(e){return this._messageRemindHandler.set(e)}},{key:\"patchMessageRemindType\",value:function(e){var t=e.ID,n=e.isC2CConversation,o=e.messageRemindType,a=!1,i=this.getLocalConversation(n?\"\".concat(S.CONV_C2C).concat(t):\"\".concat(S.CONV_GROUP).concat(t));return i&&i.messageRemindType!==o&&(i.messageRemindType=o,a=!0),Je.d(\"\".concat(this._n,\".patchMessageRemindType options:\"),e,\"ret:\".concat(a)),a}},{key:\"onC2CMessageRemindTypeFetched\",value:function(e){var t=this;if(vt(e)&&e.length>0){var n=0;e.forEach((function(e){var o=e.userID,a=e.muteFlag,i=t._transMessageRemindType(a);!0===t.patchMessageRemindType({ID:o,isC2CConversation:!0,messageRemindType:i})&&(n+=1)})),Je.l(\"\".concat(this._n,\".onC2CMessageRemindTypeFetched updateCount:\").concat(n)),n>=1&&this.emitConversationUpdate(!0,!1)}}},{key:\"onC2CMessageRemindTypeSynced\",value:function(e){var t=this,n=\"\".concat(this._n,\".onC2CMessageRemindTypeSynced\");Je.d(n,e),e.dataList.forEach((function(e){if(!pn(e.muteNotificationsSync)){var o=e.muteNotificationsSync,a=o.to,i=o.muteFlag,s=t._transMessageRemindType(i),r=0;t.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:s})&&(r+=1),Je.l(\"\".concat(n,\" updateCount:\").concat(r)),r>=1&&t.emitConversationUpdate(!0,!1)}}))}},{key:\"onGroupMessageRemindTypeUpdated\",value:function(e){Je.d(\"\".concat(this._n,\".onGroupMessageRemindTypeUpdated options:\"),e),this._messageRemindHandler.onGroupMessageRemindTypeUpdated(e)}},{key:\"deleteLocalConversation\",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this._conversationMap.has(e);if(Je.d(\"\".concat(this._n,\".deleteLocalConversation conversationID:\").concat(e,\" has:\").concat(n)),n&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.has(e)&&this._roamingMessageKeyAndTimeMap.delete(e),this._roamingMessageSequenceMap.has(e)&&this._roamingMessageSequenceMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),t)){var o=!this._isTopicConversation(e);this.emitConversationUpdate(o,!1)}}},{key:\"deleteLocalConversationList\",value:function(e){var t=this,n=0,o=!1;e.forEach((function(e){t._conversationMap.has(e)&&(n+=t._conversationMap.get(e).unreadCount||0,t.deleteLocalConversation(e,!1),o=!0)})),Je.l(\"\".concat(this._n,\".deleteLocalConversationList conversationIDList.length:\").concat(e.length,\" isConvIDExisted:\").concat(o)),o&&(this.emitConversationUpdate(!0,!1),n>0&&this.emitTotalUnreadMessageCountUpdate())}},{key:\"isMessageSentByCurrentInstance\",value:function(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:\"modifyMessageList\",value:function(e){if(e.startsWith(S.CONV_C2C)&&this._conversationMap.has(e)){var t=this._conversationMap.get(e),n=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var o=this.getModule($n).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:o.nick,latestAvatar:o.avatar}),Je.l(\"\".concat(this._n,\".modifyMessageList conversationID:\").concat(e,\" cost:\").concat(un(n)))}}},{key:\"updateUserProfileSpecifiedKey\",value:function(e){Je.l(\"\".concat(this._n,\".updateUserProfileSpecifiedKey options:\"),e);var t=e.conversationID,n=e.nick,o=e.avatar;if(this._conversationMap.has(t)){var a=this._conversationMap.get(t).userProfile;gt(n)&&a.nick!==n&&(a.nick=n),gt(o)&&a.avatar!==o&&(a.avatar=o),this.emitConversationUpdate(!0,!1)}}},{key:\"_onMyProfileModified\",value:function(e){var n=this,o=this.getLocalConversationList(),a=Date.now();o.forEach((function(o){n.modifyMessageSentByMe(t({conversationID:o.conversationID},e))})),Je.l(\"\".concat(this._n,\"._onMyProfileModified. modify all messages sent by me, cost:\").concat(un(a)))}},{key:\"modifyMessageSentByMe\",value:function(e){this._messageListHandler.modifyMessageSentByMe(e)}},{key:\"getLatestMessageSentByMe\",value:function(e){return this._messageListHandler.getLatestMessageSentByMe(e)}},{key:\"modifyMessageSentByPeer\",value:function(e){this._messageListHandler.modifyMessageSentByPeer(e)}},{key:\"getLatestMessageSentByPeer\",value:function(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}},{key:\"pushIntoNoticeResult\",value:function(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:\"getLocalLastMessage\",value:function(e){return this._messageListHandler.getLocalLastMessage(e)}},{key:\"checkAndPatchRemark\",value:function(){var e=this.getModule(no);if(0!==this._conversationMap.size&&e){var t=m(this._conversationMap.values()).filter((function(e){return e.type===S.CONV_C2C}));if(0!==t.length){var n=0;t.forEach((function(t){var o=t.conversationID.replace(S.CONV_C2C,\"\");if(e.isMyFriend(o)){var a=e.getFriendRemark(o);t.remark!==a&&(t.remark=a,n+=1)}})),Je.l(\"\".concat(this._n,\".checkAndPatchRemark. c2c conversation count:\").concat(t.length,\", patched count:\").concat(n))}}}},{key:\"updateTopicConversation\",value:function(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}},{key:\"sendReadReceipt\",value:function(e){var t=e[0],n=null;return t.conversationType===S.CONV_C2C?n=this._m.getModule(eo):t.conversationType===S.CONV_GROUP&&(n=this._m.getModule(to)),n?n.sendReadReceipt(e):Go({code:Ao.CANNOT_FIND_MODULE})}},{key:\"getReadReceiptList\",value:function(e){var t=e[0],n=null;return t.conversationType===S.CONV_C2C?n=this._m.getModule(eo):t.conversationType===S.CONV_GROUP&&(n=this._m.getModule(to)),n?n.getReadReceiptList(e):Go({code:Ao.CANNOT_FIND_MODULE})}},{key:\"getLastMessageTime\",value:function(e){var t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}},{key:\"getTotalUnreadMessageCount\",value:function(){var e=this.getLocalConversationList(),t=0;return e.forEach((function(e){e.type!==S.CONV_SYSTEM&&(\"\"!==e.messageRemindType&&e.messageRemindType!==S.MSG_REMIND_ACPT_AND_NOTE||(t+=e.unreadCount))})),t}},{key:\"emitTotalUnreadMessageCountUpdate\",value:function(){var e=this.getTotalUnreadMessageCount();this._convTotalUnreadCount!==e&&(Je.l(\"\".concat(this._n,\".emitTotalUnreadMessageCountUpdate from \").concat(this._convTotalUnreadCount,\" to \").concat(e)),this._convTotalUnreadCount=e,this.emitOuterEvent(E.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}},{key:\"reset\",value:function(){Je.l(\"\".concat(this._n,\".reset\")),this._setStorageConversationList(!0),this._pagingStatus=vn.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.clear(),this._roamingMessageSequenceMap.clear(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._conversationMap.clear(),this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._remoteGroupReadSequenceMap.clear(),this._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this.resetReady()}}]),a}(Po),Ga=function(){function e(t){o(this,e),this._groupModule=t,this._n=\"GroupTipsHandler\",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}return i(e,[{key:\"onCheckTimer\",value:function(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}},{key:\"_checkCachedGroupTips\",value:function(){var e=this;this._cachedGroupTipsMap.forEach((function(t,n){var o=e._checkCountMap.get(n),a=e._groupModule.hasLocalGroup(n);Je.l(\"\".concat(e._n,\"._checkCachedGroupTips groupID:\").concat(n,\" hasLocalGroup:\").concat(a,\" checkCount:\").concat(o)),a?(e._notifyCachedGroupTips(n),e._checkCountMap.delete(n),e._groupModule.deleteUnjoinedAVChatRoom(n)):o>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupTips(n),e._checkCountMap.delete(n)):(o++,e._checkCountMap.set(n,o))}))}},{key:\"onNewGroupTips\",value:function(e){Je.d(\"\".concat(this._n,\".onReceiveGroupTips count:\").concat(e.dataList.length));var t=this.newGroupTipsStoredAndSummary(e),n=t.eventDataList,o=t.result,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),n.length>0)&&(this._groupModule.updateNextMessageSeq(n),this._groupModule.getModule(ao).onNewMessage({conversationOptionsList:n,isInstantMessage:!0}));o.length>0&&(this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED,o),this.handleMessageList(o))}},{key:\"newGroupTipsStoredAndSummary\",value:function(e){for(var n=this,o=e.event,a=e.dataList,i=null,s=[],r=[],c={},u=[],l=function(e,l){var d=Pt(a[e]);if(6===o){if(n._groupModule.isGroupAttributesUpdatedNotice(d))return\"continue\";if(n._groupModule.isGroupCountersNotice(d))return\"continue\"}var p=d.groupProfile,_=p.groupID,g=p.communityType,h=void 0===g?0:g,f=p.topicID,v=void 0===f?void 0:f,m=p.invisible,M=void 0,I=n._groupModule.isMessageFromTopic(h,v);if(I){M=S.CONV_TOPIC,d.to=v;var y=n._groupModule.getModule(oo);y.hasLocalTopic(_,v)||n._getTopicPendingMap.has(v)||(n._getTopicPendingMap.set(v,1),y.getTopicList({groupID:_,topicIDList:[v]}).finally((function(){n._getTopicPendingMap.delete(v)})))}var T=n._groupModule.hasLocalGroup(_);if(!T&&n._groupModule.isUnjoinedAVChatRoom(_))return\"continue\";if(!T&&!I)return n._cacheGroupTipsAndProbe({groupID:_,event:o,item:d}),\"continue\";if(n._groupModule.isMessageFromOrToAVChatroom(_))return d.event=o,u.push(d),\"continue\";if(d.currentUser=n._groupModule.getMyUserID(),d.conversationType=S.CONV_GROUP,(i=new pa(d)).setElement({type:S.MSG_GRP_TIP,content:t(t({},d.elements),{},{groupProfile:d.groupProfile})}),i.isSystemMessage=!1,1===m)return n._qualityStat(i),\"continue\";var C=n._groupModule.getModule(ao),D=i,E=D.conversationID,N=D.sequence;if(6===o)i._onlineOnlyFlag=!0,r.push(i);else if(!C.pushIntoNoticeResult(r,i))return\"continue\";if(n._groupModule.isMessageFromCommunityOfTopic(h,v))return\"continue\";if(6===o&&C.getLocalConversation(E))return\"continue\";6!==o&&n._qualityStat(i);var k=C.isRemoteRead({conversationID:E,sequence:N});if(mt(c[E])){var A=0;\"in\"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||k||(A=1)),c[E]=s.push({conversationID:E,unreadCount:A,type:mt(M)?i.conversationType:M,subType:i.conversationSubType,lastMessage:i._isExcludedFromLastMessage?\"\":i})-1}else{var L=c[E];s[L].type=i.conversationType,s[L].subType=i.conversationSubType,s[L].lastMessage=i._isExcludedFromLastMessage?\"\":i,\"in\"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||k||s[L].unreadCount++)}},d=0,p=a.length;d=0){c.updateSelfInfo({muteTime:d.muteTime}),u=!0;break}}u&&this._groupModule.emitOuterEvent(E.TOPIC_UPDATED,{groupID:r,topic:c})}}},{key:\"_onTopicProfileUpdated\",value:function(e){var n=e.payload,o=n.groupProfile.groupID,a=n.newTopicInfo;this._groupModule.getModule(oo).onTopicProfileUpdated(t({groupID:o,topicID:e.to},a))}},{key:\"_cacheGroupTips\",value:function(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}},{key:\"_deleteCachedGroupTips\",value:function(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}},{key:\"_notifyCachedGroupTips\",value:function(e){var t=this,n=this._cachedGroupTipsMap.get(e)||[];n.forEach((function(e){t.onNewGroupTips(e)})),this._deleteCachedGroupTips(e),Je.l(\"\".concat(this._n,\"._notifyCachedGroupTips groupID:\").concat(e,\" count:\").concat(n.length))}},{key:\"_cacheGroupTipsAndProbe\",value:function(e){var t=this,n=e.groupID,o=e.event,a=e.item;this._cacheGroupTips(n,{event:o,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(n).then((function(e){e.type===S.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(n)?t._notifyCachedGroupTips(n):t._groupModule.setUnjoinedAVChatRoom(n):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupTips(n))})),this._checkCountMap.has(n)||this._checkCountMap.set(n,0),Je.l(\"\".concat(this._n,\"._cacheGroupTipsAndProbe groupID:\").concat(n))}},{key:\"reset\",value:function(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}]),e}(),Pa=function(){function e(t){o(this,e),this._groupModule=t,this._n=\"CommonGroupHandler\",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this.PAGING_GRP_COUNT_LIMIT=200,this._getTopicPendingMap=new Map,this._pagingStatus=vn.NOT_START,this._pagingGetCostList=[],t.getInnerEmitterInstance().on(ha.A2KEY_AND_TINYID_UPDATED,this.syncGroupList,this)}return i(e,[{key:\"onCheckTimer\",value:function(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}},{key:\"_checkCachedGroupMessage\",value:function(){var e=this;this._cachedGroupMessageMap.forEach((function(t,n){var o=e._checkCountMap.get(n),a=e._groupModule.hasLocalGroup(n);Je.l(\"\".concat(e._n,\"._checkCachedGroupMessage groupID:\").concat(n,\" hasLocalGroup:\").concat(a,\" checkCount:\").concat(o)),a?(e._notifyCachedGroupMessage(n),e._checkCountMap.delete(n),e._groupModule.deleteUnjoinedAVChatRoom(n)):o>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupMessage(n),e._checkCountMap.delete(n)):(o++,e._checkCountMap.set(n,o))}))}},{key:\"handleUpdateGroupLastMessage\",value:function(e){var n=\"\".concat(this._n,\".handleUpdateGroupLastMessage\");if(0!==this._groupModule.getGroupMap().size){for(var o,a,i,s,r,c=!1,u=0,l=e.length;u0&&this._groupModule.onAVChatRoomMessage(a),this._groupModule.filterModifiedMessage(o),n.length>0)&&(this._groupModule.updateNextMessageSeq(n),this._groupModule.getModule(ao).onNewMessage({conversationOptionsList:n,isInstantMessage:e.isInstantMessage||!0,updateUnreadCount:e.updateUnreadCount||!0}));var i=this._groupModule.filterUnmodifiedMessage(o);i.length>0&&this._groupModule.emitOuterEvent(E.MESSAGE_RECEIVED,i),o.length=0}},{key:\"_newGroupMessageStoredAndSummary\",value:function(e){var t=this,n=e.dataList,o=e.event,a=e.isInstantMessage,i=null,s=[],r=[],c=[],u={},l=this._groupModule.getFileDownloadProxy(),d=n.length;d>1&&n.sort((function(e,t){return e.sequence-t.sequence}));for(var p=this._groupModule.getModule(ao),_=this._groupModule.getModule($n),g=function(e){var d=Pt(n[e]),g=d.groupProfile,h=g.groupID,f=g.communityType,v=void 0===f?0:f,m=g.topicID,M=void 0===m?void 0:m,I=g.invisible,y=void 0,T=t._groupModule.isMessageFromTopic(v,M);if(T){y=S.CONV_TOPIC,d.to=M;var C=t._groupModule.getModule(oo);C.hasLocalTopic(h,M)||t._getTopicPendingMap.has(M)||(t._getTopicPendingMap.set(M,1),C.getTopicList({groupID:h,topicIDList:[M]}).finally((function(){t._getTopicPendingMap.delete(M)})))}var D=t._groupModule.hasLocalGroup(h);if(!D&&t._groupModule.isUnjoinedAVChatRoom(h))return\"continue\";if(!D&&!T)return t._cacheGroupMessageAndProbe({groupID:h,event:o,item:d}),\"continue\";if(t._groupModule.isMessageFromOrToAVChatroom(h))return d.event=o,c.push(d),\"continue\";if(d.currentUser=t._groupModule.getMyUserID(),d.conversationType=S.CONV_GROUP,d.isSystemMessage=!!d.isSystemMessage,(i=new pa(d)).setElement(d.elements,l),1===I)return t._qualityStat(a,i),\"continue\";var E=1===n[e].isModified;if(p.isMessageSentByCurrentInstance(i)?i.isModified=E:E=!1,1===d.onlineOnlyFlag)i._onlineOnlyFlag=!0,p.isMessageSentByCurrentInstance(i)||r.push(i);else{if(t._groupModule.isMessageFromCommunityOfTopic(v,M))return r.push(i),\"continue\";if(i.from===t._groupModule.getMyUserID()){var N=p.getLatestMessageSentByMe(i.conversationID);if(N){var k=N.nick,A=N.avatar;k===i.nick&&A===i.avatar||(p.modifyMessageSentByMe({conversationID:R,latestNick:i.nick,latestAvatar:i.avatar}),_.mockOnNickAvatarModified(i.nick,i.avatar))}}if(!p.pushIntoMessageList(r,i,E))return\"continue\";t._qualityStat(a,i);var L=i,R=L.conversationID,O=L.sequence,G=p.isRemoteRead({conversationID:R,sequence:O});if(mt(u[R])){var P=0;\"in\"===i.flow&&(i._isExcludedFromUnreadCount||G||(P=1)),u[R]=s.push({conversationID:R,unreadCount:P,type:mt(y)?i.conversationType:y,subType:i.conversationSubType,lastMessage:i._isExcludedFromLastMessage?\"\":i})-1}else{var U=u[R];s[U].type=mt(y)?i.conversationType:y,s[U].subType=i.conversationSubType,s[U].lastMessage=i._isExcludedFromLastMessage?\"\":i,\"in\"===i.flow&&(i._isExcludedFromUnreadCount||G||s[U].unreadCount++)}}},h=0;h0&&n.addMessageDelay(t.clientTime)}},{key:\"onGroupMessageRevoked\",value:function(e){var t=this,n=this._groupModule.getModule(ao),o=[];e.dataList.forEach((function(e){var t=e.elements.revokedInfos,a=e.revokerInfo;mt(t)||t.forEach((function(e){var t,i=pn(e.topicID)?\"GROUP\".concat(e.groupID):\"GROUP\".concat(e.topicID),s=n.getLocalConversation(i),r=e.revokerInfo&&e.revokerInfo.revoker||a&&a.revoker,c=a&&a.reason||\"\";if(bt(s.type))t={conversationID:i,sequence:e.sequence,ID:\"\".concat(e.tinyID,\"-\").concat(e.clientTime,\"-\").concat(e.random)};else{var u=n.revoke(i,e.sequence,e.random);u?t=u:(t={conversationID:i,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(t.ID=\"\".concat(e.tinyID,\"-\").concat(e.clientTime,\"-\").concat(e.random)),e.time&&(t.time=e.time))}t&&(t.revoker=r,t.revokeReason=c,t.revokerInfo={userID:r,nick:\"\",avatar:\"\"},o.push(t))}))})),0!==o.length&&(n.onMessageRevoked(o),n.updateRevokerInfo(o).then((function(e){t._groupModule.emitOuterEvent(E.MESSAGE_REVOKED,e)})))}},{key:\"_groupListTreeShaking\",value:function(e){for(var t=new Map(m(this._groupModule.getGroupMap())),n=0,o=e.length;n0&&void 0!==arguments[0]&&arguments[0];this._pagingStatus===vn.NOT_START&&this._groupModule.clearGroupMap();var n=[\"Type\",\"Name\",\"FaceUrl\",\"NextMsgSeq\",\"LastMsgTime\",\"AtInfoList\",\"LastRecallTime\"],o=this.PAGING_GRP_COUNT_LIMIT,a=0,i=[];if(!0===t)return this._pagingGetGroupListWithTopic({limit:o,offset:a,groupBaseInfoFilter:n,groupList:i});var s=\"syncGroupList\",r=\"\".concat(this._n,\".\").concat(s),c=new Xo(s);return this._pagingGetGroupList({limit:o,offset:a,groupBaseInfoFilter:n,groupList:i}).then((function(){var t=cn(e._pagingGetCostList),n=rn(e._pagingGetCostList);e._pagingGetCostList.length=0,e._pagingStatus=vn.RESOLVED,e._groupListTreeShaking(i),e._groupModule.updateGroupMap(i);var o=e._groupModule.getLocalGroupList().length,a=\"count:\".concat(o,\" sum:\").concat(n,\" avg:\").concat(t);return Je.l(\"\".concat(r,\" ok. \").concat(a)),c.setNetworkType(e._groupModule.getNetworkType()).setMessage(a).end(),e.tempConversationList&&(e.handleUpdateGroupLastMessage(e.tempConversationList),e.tempConversationList=null),e._groupModule.emitGroupListUpdate(!0,!0),No({groupList:e._groupModule.getLocalGroupList()})})).catch((function(t){return e._pagingStatus=vn.REJECTED,e._groupModule.probeNetwork().then((function(e){var n=v(e,2),o=n[0],a=n[1];c.setError(t,o,a).end()})),Je.e(\"\".concat(r,\" failed. error:\"),t),Go(t)}))}},{key:\"getGroupList\",value:function(){var e=this,t=\"\".concat(this._n,\".\").concat(\"getGroupList\");if(Je.l(\"\".concat(t,\" pagingStatus:\").concat(this._pagingStatus)),this._pagingStatus===vn.REJECTED||this._pagingStatus===vn.NOT_START)return this.syncGroupList().then((function(){var t=e._groupModule.getLocalGroupList();return No({groupList:t,isSyncCompleted:e.isPagingGetCompleted()})})).catch((function(e){return Je.e(\"\".concat(t,\" failed. error:\"),e),Go(e)}));var n=this._groupModule.getLocalGroupList();return Je.l(\"\".concat(t,\". returned group count:\").concat(n.length)),Oo({groupList:n,isSyncCompleted:this.isPagingGetCompleted()})}},{key:\"isPagingGetCompleted\",value:function(){return this._pagingStatus===vn.RESOLVED}},{key:\"_pagingGetGroupList\",value:function(e){var t=this,n=\"\".concat(this._n,\".\").concat(\"_pagingGetGroupList\"),o=e.isCommunityRelay,a=void 0!==o&&o,i=e.limit,s=e.offset,r=e.groupBaseInfoFilter,c=e.groupList,u=Date.now();return this._groupModule.request({protocolName:Uo.GET_GROUP_LIST,requestData:{type:a?S.GRP_COMMUNITY:void 0,memberAccount:this._groupModule.getMyUserID(),limit:i,offset:s,responseFilter:{groupBaseInfoFilter:r,selfInfoFilter:[\"Role\",\"JoinTime\",\"MsgFlag\",\"MsgSeq\"]}}}).then((function(e){var o=e.data,l=o.groups,d=void 0===l?[]:l,p=o.totalCount;c.push.apply(c,m(d)),t._handleGroupAtInfoWithoutTopic(a,d);var _=s+i,g=!(p>_),h=\"offset:\".concat(s,\" limit:\").concat(i,\" totalCount:\").concat(p,\" isCompleted:\").concat(g,\" \")+\"currentCount:\".concat(c.length,\" isCommunityRelay:\").concat(a);return t._pagingGetCostList.push(un(u,!1)),Je.l(\"\".concat(n,\" ok. \").concat(h,\" cost:\").concat(un(u))),a||g?!a&&g?(Je.l(\"\".concat(n,\" start to get community list\")),s=0,t._pagingGetGroupList({limit:i,offset:s,groupBaseInfoFilter:r,groupList:c,isCommunityRelay:!0})):a&&!g?(s=_,t._pagingGetGroupList({limit:i,offset:s,groupBaseInfoFilter:r,groupList:c,isCommunityRelay:!0})):No({groupList:c}):(s=_,t._pagingGetGroupList({limit:i,offset:s,groupBaseInfoFilter:r,groupList:c}))})).catch((function(e){return 10018===e.code?(Je.w(\"\".concat(t.logPrefix,\" response size exceeds the limit, request count:\").concat(i)),i=50,t._pagingGetGroupList({limit:i,offset:s,groupBaseInfoFilter:r,groupList:c,isCommunityRelay:a})):a?(11e3===e.code&&Je.l(\"\".concat(n,\" ok. community unavailable\")),Oo({groupList:c})):Go(e)}))}},{key:\"_pagingGetGroupListWithTopic\",value:function(e){var t=this,n=\"\".concat(this._n,\"._pagingGetGroupListWithTopic\"),o=e.limit,a=e.offset,i=e.groupBaseInfoFilter,s=e.groupList,r=Date.now();return this._groupModule.request({protocolName:Uo.GET_GROUP_LIST,requestData:{type:S.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:o,offset:a,responseFilter:{groupBaseInfoFilter:i,selfInfoFilter:[\"Role\",\"JoinTime\",\"MsgFlag\",\"MsgSeq\"]},isSupportTopic:1}}).then((function(e){var c=e.data,u=c.groups,l=void 0===u?[]:u,d=c.totalCount;s.push.apply(s,m(l));var p=a+o,_=!(d>p);if(Je.l(\"\".concat(n,\" ok. offset:\").concat(a,\" limit:\").concat(o,\" totalCount:\").concat(d,\" isCompleted:\").concat(_,\" currentCount:\").concat(s.length,\" cost:\").concat(un(r))),!_)return a=p,t._pagingGetGroupListWithTopic({limit:o,offset:a,groupBaseInfoFilter:i,groupList:s});t._groupModule.updateGroupMap(s),t._groupModule.emitGroupListUpdate(!0,!1);var g=t._groupModule.getLocalGroupList().filter((function(e){return!0===e.isSupportTopic}));return No({groupList:g})})).catch((function(e){return 10018===e.code?(Je.w(\"\".concat(t.logPrefix,\" response size exceeds the limit, request count:\").concat(o)),o=50,t._pagingGetGroupListWithTopic({limit:o,offset:a,groupBaseInfoFilter:i,groupList:s})):Go(e)}))}},{key:\"_cacheGroupMessage\",value:function(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}},{key:\"_deleteCachedGroupMessage\",value:function(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}},{key:\"_notifyCachedGroupMessage\",value:function(e){var t=this,n=this._cachedGroupMessageMap.get(e)||[];n.forEach((function(e){t.onNewGroupMessage(e)})),this._deleteCachedGroupMessage(e),Je.l(\"\".concat(this._n,\"._notifyCachedGroupMessage groupID:\").concat(e,\" count:\").concat(n.length))}},{key:\"_cacheGroupMessageAndProbe\",value:function(e){var t=this,n=e.groupID,o=e.event,a=e.item;this._cacheGroupMessage(n,{event:o,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(n).then((function(e){e.type===S.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(n)?t._notifyCachedGroupMessage(n):t._groupModule.setUnjoinedAVChatRoom(n):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupMessage(n))})),this._checkCountMap.has(n)||this._checkCountMap.set(n,0),Je.l(\"\".concat(this._n,\"._cacheGroupMessageAndProbe groupID:\").concat(n))}},{key:\"_handleGroupAtInfoWithoutTopic\",value:function(e,n){var o=this;e&&0!==n.length&&n.forEach((function(e){var n=e.groupID,a=e.groupAtInfoList,i=[];mt(a)||(a.forEach((function(e){i.push(t(t({},e),{},{groupID:n}))})),o._groupModule.getModule(ao).onNewGroupAtTips({dataList:i}))}))}},{key:\"setPagingGroupCount\",value:function(e){mt(e)||(this.PAGING_GRP_COUNT_LIMIT=parseInt(e,10))}},{key:\"reset\",value:function(){this.PAGING_GRP_COUNT_LIMIT=200,this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._pagingStatus=vn.NOT_START,this._pagingGetCostList=[]}}]),e}(),Ua=1,ba=2,wa=3,Fa=4,qa=5,xa=function(){function e(t){o(this,e),this._groupModule=t,this._n=\"GroupAttributesHandler\",this._groupAttributesMap=new Map,this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(ha.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}return i(e,[{key:\"_onCloudConfigUpdated\",value:function(){var e=this._groupModule.getCloudConfig(\"grp_attr_cache_time\");mt(e)||(this.CACHE_EXPIRE_TIME=Number(e))}},{key:\"updateLocalMainSequenceOnReconnected\",value:function(){this._groupAttributesMap.forEach((function(e){e.localMainSequence=0}))}},{key:\"isGroupAttributesUpdatedNotice\",value:function(e){var t=e.to,n=e.elements.newGroupProfile,o=!mt(n)&&!pn(n.groupAttributeOption);return o&&this._onGroupAttributesUpdated({groupID:t,groupAttributeOption:n.groupAttributeOption}),o}},{key:\"_onGroupAttributesUpdated\",value:function(e){var t=this,n=e.groupID,o=e.groupAttributeOption,a=o.mainSequence,i=o.isWithChangedAttributeInfo,s=o.groupAttributeList,r=void 0===s?[]:s,c=o.operationType;if(Je.l(\"\".concat(this._n,\".onGroupAttributesUpdated. \")+\"groupID:\".concat(n,\" isWithChangedAttributeInfo:\").concat(i,\" operationType:\").concat(c)),!mt(c)){this._groupAttributesCopy=this._getCachedAttributes({groupID:n});var u=a-this._getLocalGroupAttributes(n).localMainSequence;if(0!==u){if(1===i&&1===u)return this._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:a,groupAttributeList:r,operationType:c}),void this._emitGroupAttributesUpdated(n);if(this._hasLocalGroupAttributes(n)){var l=this._getLocalGroupAttributes(n).avChatRoomKey;this._getGroupAttributes({groupID:n,avChatRoomKey:l}).then((function(){t._emitGroupAttributesUpdated(n)}))}}}}},{key:\"initGroupAttributesCache\",value:function(e){var t=e.groupID,n=e.avChatRoomKey,o=void 0===n?void 0:n;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:o}),Je.l(\"\".concat(this._n,\".initGroupAttributesCache groupID:\").concat(t,\" avChatRoomKey:\").concat(o))}},{key:\"initGroupAttributes\",value:function(e){var t=this,n=e.groupID,o=e.groupAttributes,a=this._getLocalGroupAttributes(n),i=a.remoteMainSequence,s=a.avChatRoomKey,r=new Xo(\"initGroupAttributes\");return r.setMessage(\"groupID:\".concat(n,\" avChatRoomKey:\").concat(s,\" mainSequence:\").concat(i)),this._groupModule.request({protocolName:Uo.SET_GROUP_ATTRIBUTES,requestData:{groupID:n,avChatRoomKey:s,mainSequence:i,groupAttributeList:this._transformGroupAttributes(o)}}).then((function(e){Je.l(\"\".concat(t._n,\".\").concat(\"initGroupAttributes\",\" ok. groupID:\").concat(n));var a=e.data,i=a.mainSequence,s=m(a.groupAttributeList);return s.forEach((function(e){e.value=o[e.key]})),t._groupAttributesCopy=t._getCachedAttributes({groupID:n}),t._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:i,groupAttributeList:s,operationType:Ua}),t._emitGroupAttributesUpdated(n),r.setNetworkType(t._groupModule.getNetworkType()).end(),No({groupAttributes:o})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];r.setError(e,o,a).end()})),Go(e)}))}},{key:\"setGroupAttributes\",value:function(e){var t=this,n=\"\".concat(this._n,\".\").concat(\"setGroupAttributes\"),o=e.groupID,a=e.groupAttributes,i=this._getLocalGroupAttributes(o),s=i.remoteMainSequence,r=i.avChatRoomKey,c=i.attributes,u=this._transformGroupAttributes(a);u.forEach((function(e){var t=e.key;e.sequence=0,c.has(t)&&(e.sequence=c.get(t).sequence)}));var l=new Xo(\"setGroupAttributes\");return l.setMessage(\"groupID:\".concat(o,\" groupAttributes:\").concat(JSON.stringify(a))),Je.l(\"\".concat(n,\". groupID:\").concat(o,\" mainSequence:\").concat(s)),this._groupModule.request({protocolName:Uo.MODIFY_GROUP_ATTRIBUTES,requestData:{groupID:o,avChatRoomKey:r,mainSequence:s,groupAttributeList:u}}).then((function(e){Je.l(\"\".concat(n,\" ok.\"));var i=e.data,s=i.mainSequence,r=m(i.groupAttributeList);return r.forEach((function(e){e.value=a[e.key]})),t._groupAttributesCopy=t._getCachedAttributes({groupID:o}),t._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:s,groupAttributeList:r,operationType:ba}),t._emitGroupAttributesUpdated(o),l.setNetworkType(t._groupModule.getNetworkType()).end(),No({groupAttributes:a})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];l.setError(e,o,a).end()})),Go(e)}))}},{key:\"deleteGroupAttributes\",value:function(e){var t=this,n=e.groupID,o=e.keyList,a=void 0===o?[]:o,i=this._getLocalGroupAttributes(n),s=i.remoteMainSequence,r=i.avChatRoomKey,c=i.attributes,u=m(c.keys()),l=Uo.CLEAR_GROUP_ATTRIBUTES,d=wa,p={groupID:n,avChatRoomKey:r,mainSequence:s},_=[];a.length>0&&(u=[],l=Uo.DELETE_GROUP_ATTRIBUTES,d=Fa,a.forEach((function(e){var t=0;c.has(e)&&(t=c.get(e).sequence,u.push(e)),_.push({key:e,sequence:t})})),p.groupAttributeList=_);var g=new Xo(\"deleteGroupAttributes\");return g.setMessage(\"groupID:\".concat(n,\" mainSequence:\").concat(s,\" keyList:\").concat(a,\" protocolName:\").concat(l)),this._groupModule.request({protocolName:l,requestData:p}).then((function(e){Je.l(\"\".concat(t._n,\".\").concat(\"deleteGroupAttributes\",\" ok. groupID:\").concat(n));var o=e.data.mainSequence;return t._groupAttributesCopy=t._getCachedAttributes({groupID:n}),t._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:o,groupAttributeList:_,operationType:d}),t._emitGroupAttributesUpdated(n),g.setNetworkType(t._groupModule.getNetworkType()).end(),No({keyList:u})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];g.setError(e,o,a).end()})),Go(e)}))}},{key:\"getGroupAttributes\",value:function(e){var t=this,n=\"\".concat(this._n,\".\").concat(\"getGroupAttributes\"),o=e.groupID,a=this._getLocalGroupAttributes(o),i=a.avChatRoomKey,s=a.lastUpdateTime,r=a.localMainSequence,c=a.remoteMainSequence,u=new Xo(\"getGroupAttributes\");if(u.setMessage(\"groupID:\".concat(o,\" localMainSequence:\").concat(r,\" remoteMainSequence:\").concat(c,\" keyList:\").concat(e.keyList)),Date.now()-s>=this.CACHE_EXPIRE_TIME||r0)o.forEach((function(e){i.has(e)&&(a[e]=i.get(e).value)}));else{var s,r=D(i.keys());try{for(r.s();!(s=r.n()).done;){var c=s.value;a[c]=i.get(c).value}}catch(u){r.e(u)}finally{r.f()}}}return a}},{key:\"_updateCachedAttributes\",value:function(e){var t=e.groupAttributes,n=e.groupAttributeList,o=e.operationType;o!==wa?o!==Fa?(o===Ua&&t.attributes.clear(),n.forEach((function(e){var n=e.key,o=e.value,a=e.sequence;t.attributes.set(n,{value:o,sequence:a})}))):n.forEach((function(e){t.attributes.delete(e.key)})):t.attributes.clear()}},{key:\"_hasLocalGroupAttributes\",value:function(e){return this._groupAttributesMap.has(e)}},{key:\"_getLocalGroupAttributes\",value:function(e){return this._hasLocalGroupAttributes(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesMap.get(e)}},{key:\"_transformGroupAttributes\",value:function(e){var t=[];return Object.keys(e).forEach((function(n){t.push({key:n,value:e[n]})})),t}},{key:\"_emitGroupAttributesUpdated\",value:function(e){var t=this._getCachedAttributes({groupID:e}),n=this._computeAttrChangedInfo(t),o=n.updatedKeyList,a=n.deletedKeyList;Je.l(\"\".concat(this._n,\"._emitGroupAttributesUpdated update:\").concat(o.length,\", delete:\").concat(a.length)),0===o.length&&0===a.length||this._groupModule.emitOuterEvent(E.GROUP_ATTRIBUTES_UPDATED,{groupID:e,groupAttributes:t,updatedKeyList:o,deletedKeyList:a})}},{key:\"_computeAttrChangedInfo\",value:function(e){var t=this,n=[],o=[];return Object.keys(e).forEach((function(o){e[o]!==t._groupAttributesCopy[o]&&n.push(o)})),Object.keys(this._groupAttributesCopy).forEach((function(t){mt(e[t])&&o.push(t)})),this._groupAttributesCopy={},{updatedKeyList:n,deletedKeyList:o}}},{key:\"deleteLocalGroupAttributes\",value:function(e){this._hasLocalGroupAttributes(e)&&this._groupAttributesMap.delete(e)}},{key:\"reset\",value:function(){this._groupAttributesMap.clear(),this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4}}]),e}(),Va=\"Set\",Ha=\"Increase\",Ba=\"Decrease\",Ka=function(){function e(t){o(this,e),this._groupModule=t,this._n=\"GroupCountersHandler\",this._groupCountersMap=new Map,this.EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(ha.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}return i(e,[{key:\"_onCloudConfigUpdated\",value:function(){var e=this._groupModule.getCloudConfig(\"grp_counter_expire_time\");mt(e)||(this.EXPIRE_TIME=Number(e))}},{key:\"isGroupCountersNotice\",value:function(e){var t=e.to,n=e.elements.groupCounterInfo,o=!1;return pn(n)||(this._onGroupCountersUpdated({groupID:t,groupCounterInfo:n}),o=!0),o}},{key:\"_onGroupCountersUpdated\",value:function(e){var t=this,n=e.groupID;e.groupCounterInfo.forEach((function(e){var o=e.type,a=e.groupCounterSeq,i=e.counterList,s=void 0===i?[]:i;0!==o&&2!==o||(t._updateLocalGroupCounters({groupID:n,groupCounterSeq:a,counterList:s}),s.forEach((function(e){t._groupModule.emitOuterEvent(E.GROUP_COUNTER_UPDATED,{groupID:n,key:e.key,value:e.value})}))),1===o&&t._deleteLocalGroupCounters({groupID:n,groupCounterSeq:a,counterList:s})})),Je.l(\"\".concat(this._n,\"._onGroupCountersUpdated groupID:\").concat(n))}},{key:\"initGroupCountersCache\",value:function(e){var t=e.groupID,n=e.avChatRoomKey;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:n}),Je.l(\"\".concat(this._n,\".initGroupCountersCache groupID:\").concat(t,\" avChatRoomKey:\").concat(n))}},{key:\"setGroupCounters\",value:function(e){var t=this;if(!this._groupModule.canIUse(K.GRP_COUNTER))return this._groupModule.cannotUseCommercialAbility(\"setGroupCounters\");var n=\"\".concat(this._n,\".\").concat(\"setGroupCounters\"),o=e.groupID,a=e.counters,i=this._convertObjectToList(a),s=this._getLocalGroupCounters(o).avChatRoomKey,r=\"groupID:\".concat(o,\" count:\").concat(i.length),c=new Xo(\"setGroupCounters\");return c.setMessage(\"\".concat(r)),Je.l(\"\".concat(n,\". \").concat(r)),this._updateGroupCounters({groupID:o,counterList:i,avChatRoomKey:s,mode:Va}).then((function(e){return c.end(),Je.l(\"\".concat(n,\" ok.\")),No({counters:e})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),Je.e(\"\".concat(n,\" failed. error:\"),e),Go(e)}))}},{key:\"increaseGroupCounter\",value:function(e){var t=this,n=\"increaseGroupCounter\";if(!this._groupModule.canIUse(K.GRP_COUNTER))return this._groupModule.cannotUseCommercialAbility(n);var o=\"\".concat(this._n,\".\").concat(n),a=e.groupID,i=e.key,s=e.value,r=this._getLocalGroupCounters(a).avChatRoomKey,c=\"groupID:\".concat(a,\" key:\").concat(i,\" value:\").concat(s),u=new Xo(n);u.setMessage(\"\".concat(c)),Je.l(\"\".concat(o,\". \").concat(c));var l=[{key:i,value:s}];return this._updateGroupCounters({groupID:a,counterList:l,avChatRoomKey:r,mode:Ha}).then((function(e){return u.end(),Je.l(\"\".concat(o,\" ok.\")),No({counters:e})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),Je.e(\"\".concat(o,\" failed. error:\"),e),Go(e)}))}},{key:\"decreaseGroupCounter\",value:function(e){var t=this,n=\"decreaseGroupCounter\";if(!this._groupModule.canIUse(K.GRP_COUNTER))return this._groupModule.cannotUseCommercialAbility(n);var o=\"\".concat(this._n,\".\").concat(n),a=e.groupID,i=e.key,s=e.value,r=this._getLocalGroupCounters(a).avChatRoomKey,c=\"groupID:\".concat(a,\" key:\").concat(i,\" value:\").concat(s),u=new Xo(n);u.setMessage(\"\".concat(c)),Je.l(\"\".concat(o,\". \").concat(c));var l=[{key:i,value:s}];return this._updateGroupCounters({groupID:a,counterList:l,avChatRoomKey:r,mode:Ba}).then((function(e){return u.end(),Je.l(\"\".concat(o,\" ok.\")),No({counters:e})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),Je.e(\"\".concat(o,\" failed. error:\"),e),Go(e)}))}},{key:\"getGroupCounters\",value:function(e){var t=this;if(!this._groupModule.canIUse(K.GRP_COUNTER))return this._groupModule.cannotUseCommercialAbility(\"getGroupCounters\");var n=\"\".concat(this._n,\".\").concat(\"getGroupCounters\"),o=e.groupID,a=e.keyList,i=void 0===a?[]:a,s=this._getLocalGroupCounters(o),r=s.avChatRoomKey,c=s.lastUpdateTime,u=new Xo(\"getGroupCounters\");if(u.setMessage(\"groupID:\".concat(o)),Date.now()-c>=this.EXPIRE_TIME)return this._getRemoteGroupCounters({groupID:o,avChatRoomKey:r}).then((function(e){u.setMoreMessage(\"from remote. count:\".concat(e.length)).end(),Je.l(\"\".concat(n,\" from remote. groupID:\").concat(o));var a=t._getLocalCounters(o,i);return No({counters:a})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=v(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),Go(e)}));u.setMoreMessage(\"from cache\").end(),Je.l(\"\".concat(n,\" from cache. groupID:\").concat(o));var l=this._getLocalCounters(o,i);return Oo({counters:l})}},{key:\"_getRemoteGroupCounters\",value:function(e){var n=this;return this._groupModule.request({protocolName:Uo.GET_GROUP_COUNTER,requestData:t({},e)}).then((function(t){var o=t.data,a=o.counterList,i=void 0===a?[]:a,s=o.groupCounterSeq;return n._updateLocalGroupCounters({groupID:e.groupID,counterList:i,groupCounterSeq:s}),Je.l(\"\".concat(n._n,\"._getRemoteGroupCounters ok. groupID:\").concat(e.groupID)),i})).catch((function(e){return Go(e)}))}},{key:\"_convertObjectToList\",value:function(e){var t=[];return Object.keys(e).forEach((function(n){t.push({key:n,value:e[n]})})),t}},{key:\"_updateGroupCounters\",value:function(e){var n=\"\".concat(this._n,\"._updateGroupCounters\"),o=e.groupID,a=e.avChatRoomKey,i=e.mode;return Je.l(\"\".concat(n,\". groupID:\").concat(o,\" avChatRoomKey:\").concat(a,\" mode:\").concat(i)),this._groupModule.request({protocolName:Uo.UPDATE_GROUP_COUNTER,requestData:t({},e)}).then((function(e){Je.l(\"\".concat(n,\" ok.\"));var t=e.data.counterList,o={};return(void 0===t?[]:t).forEach((function(e){var t=e.key,n=e.value;o[t]=n})),o})).catch((function(e){return Go(e)}))}},{key:\"_hasLocalGroupCounters\",value:function(e){return this._groupCountersMap.has(e)}},{key:\"_getLocalGroupCounters\",value:function(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}},{key:\"_updateLocalGroupCounters\",value:function(e){var t=e.groupID,n=e.counterList,o=void 0===n?[]:n,a=e.groupCounterSeq;if(this._hasLocalGroupCounters(t)){var i=this._getLocalGroupCounters(t),s=i.counters,r=i.avChatRoomKey,c=i.groupCounterSeq;if(a>0&&a