@tencentcloud/lite-chat 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/basic.d.ts +30 -2
- package/basic.es.js +1 -1
- package/basic.js +1 -1
- package/index.d.ts +30 -2
- package/package.json +11 -11
- package/plugins/avchatroom.es.js +1 -1
- package/plugins/avchatroom.js +1 -1
- package/plugins/cloud-search.es.js +1 -1
- package/plugins/cloud-search.js +1 -1
- package/plugins/conversation-group.es.js +1 -1
- package/plugins/conversation-group.js +1 -1
- package/plugins/conversation.es.js +1 -1
- package/plugins/conversation.js +1 -1
- package/plugins/follow.es.js +1 -1
- package/plugins/follow.js +1 -1
- package/plugins/friend.es.js +1 -1
- package/plugins/friend.js +1 -1
- package/plugins/group.es.js +1 -1
- package/plugins/group.js +1 -1
- package/plugins/message-enhancer.es.js +1 -1
- package/plugins/message-enhancer.js +1 -1
- package/plugins/offline-message-synchronizer.es.js +1 -1
- package/plugins/offline-message-synchronizer.js +1 -1
- package/plugins/rich-media-message.es.js +1 -1
- package/plugins/rich-media-message.js +1 -1
- package/plugins/signaling.es.js +1 -1
- package/plugins/signaling.js +1 -1
- package/plugins/topic.es.js +1 -1
- package/plugins/topic.js +1 -1
- package/professional.d.ts +30 -2
- package/professional.es.js +1 -1
- package/professional.js +1 -1
- package/standard.es.js +1 -1
- package/standard.js +1 -1
- package/CHANGELOG.md +0 -395
package/plugins/friend.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatFriend=t()}(this,function(){function _(e,n,a,d){return new(a=a||Promise)(function(r,t){function i(e){try{s(d.next(e))}catch(e){t(e)}}function o(e){try{s(d.throw(e))}catch(e){t(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}s((d=d.apply(e,n||[])).next())})}let f="friend",h=100,e="Tag_SNS_IM_",u={GROUP:e+"Group",REMARK:e+"Remark",ADDSOURCE:e+"AddSource",ADDWORDING:e+"Wording",ADDTIME:e+"AddTime"},a="Update_Type_Add",d="Update_Type_Delete",c="remove",l="rename",m=e=>void 0===e;function v(e,t="ResultItem",r=e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})){var{[t]:e=[],ActionStatus:t,ErrorCode:i,ErrorInfo:o,ErrorDisplay:s}=e;return{resultList:e.map(r),actionStatus:t,errorCode:i,errorInfo:o,errorDisplay:s}}let o={[u.REMARK]:(e,t)=>{e.remark=t},[u.GROUP]:(e,t)=>{e.groupList=t?JSON.parse(JSON.stringify(t)):[]},[u.ADDSOURCE]:(e,t)=>{e.source=t},[u.ADDWORDING]:(e,t)=>{e.wording=t},[u.ADDTIME]:(e,t)=>{e.addTime=t}},p=class{constructor(e){this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];var{userID:e,tagValueList:t=[],core:r}=e,r=null==(r=r.user.userProfile)?void 0:r.createProfile(e,t);this.userID=e,this.profile=r,t.forEach(e=>{var{tag:e,value:t}=e,e=(-1<e.indexOf("Tag_Profile_Custom")&&this.friendCustomField.push({key:e,value:t}),o[e]);null!=e&&e(this,t)})}update(e){let i=[];this.friendCustomField.forEach(e=>{i.push(e.key)}),e.forEach(e=>{let{tag:t,value:r}=e;-1<t.indexOf("Tag_Profile_Custom")&&(-1<i.indexOf(t)?this.friendCustomField.forEach(e=>{e.key===t&&(e.value=r)}):this.friendCustomField.push({key:t,value:r}));e=o[t];null!=e&&e(this,r)})}};var F=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(e){var{helper:e,constants:t}=this._core=e;e.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),e.registerApi({apiName:"getFriendProfile",context:this}),e.registerApi({apiName:"addFriend",context:this}),e.registerApi({apiName:"deleteFriend",context:this}),e.registerApi({apiName:"updateFriend",context:this}),e.registerApi({apiName:"checkFriend",context:this}),e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return _(this,void 0,void 0,function*(){var{appStore:{userStore:e},ssoLog:t,utils:{safeStringify:r}}=this._core,e=[...e.getFriendMap().values()];return t.debug("getFriendListFromCache",f+" getFriendListFromCache, data:"+r(e)),{code:0,data:e}})}syncFriendListFromServer(){return _(this,void 0,void 0,function*(){let a,{ssoLog:d,helper:r}=this._core;try{d.debug("syncFriendListFromServer",f+" syncFriendListFromServer");let e={From_Account:null==(a=this._core.store.get("login"))?void 0:a.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},t=yield function(c,l){return _(this,void 0,void 0,function*(){var{UserDataItem:e=[],StandardSequence:t,CustomSequence:r,FriendNum:i,CompleteFlag:o,NextStartIndex:s,ActionStatus:n,ErrorCode:a,ErrorInfo:d,ErrorDisplay:u}=e=yield l.common.buildAndSendPacket({servcmd:"sns.friend_get",data:c});return{friendList:e.map(e=>{return{userID:e.To_Account,tagValueList:null==(e=e.ValueItem)?void 0:e.map(e=>({tag:e.Tag,value:e.Value}))}}),standardSequence:t,customSequence:r,friendNumber:i,completeFlag:o,nextStartIndex:s,actionStatus:n,errorCode:a,errorInfo:d,errorDisplay:u}})}(e,this._core),{friendList:r,nextStartIndex:i,standardSequence:o,customSequence:s,completeFlag:n}=t;this._startIndex=i,this._standardSequence=o,this._customSequence=s,this._processFriendList(r),0===n?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),d.debug("syncFriendListFromServer",f+" syncFriendListFromServer ok")}catch(e){let t=(e||{})["errorCode"];throw new r.ChatError({code:t})}})}getFriendProfile(d){return _(this,void 0,void 0,function*(){var t;try{let e=d["userIDList"];e.length>h&&(e=e.slice(0,h));var r,i,o,{friendUserIdList:s,unFriendUserIdList:n}=this.partitionByIsFriend(e),a=this._createNonFriendErrorList(n);return 0===s.length?{code:0,data:{friendList:[],failureUserIDList:a}}:(r=(yield function(s,n){return _(this,void 0,void 0,function*(){var{InfoItem:e=[],ActionStatus:t,ErrorCode:r,ErrorInfo:i,ErrorDisplay:o}=e=yield n.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:s});return{friendProfileList:e.map(e=>{return{userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,relation:e.Relation,standardSequence:e.StandardSequence,customSequence:e.CustomSequence,profileItem:(null==(e=e.SnsProfileItem)?void 0:e.map(e=>({tag:e.Tag,value:e.Value})))||[]}}),actionStatus:t,errorCode:r,errorInfo:i,errorDisplay:o}})}({From_Account:null==(t=this._core.store.get("login"))?void 0:t.userId,To_Account:s},this._core))||{},{successProfiles:i,failedProfiles:o}=this._processFriendProfileResponse(r),{code:0,data:{friendList:i,failureUserIDList:[...o,...a]}})}catch(e){let t=(e||{})["errorCode"];throw new this._core.helper.ChatError({code:t})}})}addFriend(m){return _(this,void 0,void 0,function*(){var e,{helper:r,store:t,ssoLog:i}=this._core;try{var{to:o,source:s,type:n,wording:a,remark:d,groupName:u}=m,c=yield function(e,t){return _(this,void 0,void 0,function*(){return v(yield t.common.buildAndSendPacket({servcmd:"sns.friend_add",data:e}))})}({From_Account:null==(e=t.get("login"))?void 0:e.userId,AddFriendItem:[{To_Account:o,AddSource:s,AddWording:a,GroupName:u,Remark:d}],AddType:n},this._core),{resultList:l=[]}=c,{userID:p,resultCode:h}=l[0];if(0===h)return i.debug("addFriend",f+" addFriend ok"),{code:0,data:{userID:p}};if(30539===h)return i.debug("addFriend",f+" addFriend wait for the other party to agree"),{code:0,data:{userID:p,code:h,message:"wait for the other party to agree"}};throw new r.ChatError({functionName:"addFriend",code:h})}catch(e){let t=(e||{})["errorCode"];throw new r.ChatError({code:t})}})}deleteFriend(p){return _(this,void 0,void 0,function*(){var r,{store:i,ssoLog:o,helper:s}=this._core;try{let{userIDList:e,type:t}=p;var n,a,d,u=null==(r=i.get("login"))?void 0:r.userId,{friendUserIdList:c,unFriendUserIdList:l}=(1e3<e.length&&(o.info("deleteFriend",f+" deleteFriend the length of userIDList cannot exceed:1000"),e=e.slice(0,h)),this.partitionByIsFriend(e));return 0===c.length?{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(l)}}:(n=yield function(e,t){return _(this,void 0,void 0,function*(){return v(yield t.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:e}))})}({From_Account:u,To_Account:c,DeleteType:t},this._core),{successUserIDList:a,failureUserIDList:d}=this._processOperationResult({resultList:n.resultList,includeRelation:!1}),{code:0,data:{successUserIDList:a,failureUserIDList:d}})}catch(e){let t=(e||{})["errorCode"];throw new s.ChatError({code:t})}})}updateFriend(p){return _(this,void 0,void 0,function*(){var t,{helper:r,store:e,appStore:{userStore:i}}=this._core;try{var{userID:o,remark:s,friendCustomField:n}=p,a=null==(t=e.get("login"))?void 0:t.userId;if(!i.getFriendMap().has(o))throw new r.ChatError({functionName:"updateFriend",code:2700});var d=(yield function(e,t){return _(this,void 0,void 0,function*(){return v(yield t.common.buildAndSendPacket({servcmd:"sns.friend_update",data:e}),"ResultItem",e=>({to:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}({From_Account:a,UpdateItem:[{To_Account:o,SnsItem:this._buildSnsItemList(s,n)}]},this._core))["resultList"],{to:u,resultCode:c,resultInfo:l}=d[0];if(m(c)||0===c)return{code:0,data:this._updateLocalFriend({userID:u,remark:s,friendCustomField:n})};throw new r.ChatError({functionName:"updateFriend",code:c,message:l})}catch(t){let e=(t||{})["errorCode"];throw new r.ChatError({code:e})}})}checkFriend(c){return _(this,void 0,void 0,function*(){let a,{OuterConstant:d,store:u,helper:t}=this._core;try{let{userIDList:e,type:t}=c,r=null==(a=u.get("login"))?void 0:a.userId,i={From_Account:r,To_Account:e,CheckType:t===d.SNS_CHECK_TYPE_SINGLE?t:d.SNS_CHECK_TYPE_BOTH},o=yield function(e,t){return _(this,void 0,void 0,function*(){return v(yield t.common.buildAndSendPacket({servcmd:"sns.friend_check",data:e}),"InfoItem",e=>({userID:e.To_Account,relation:e.Relation,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}(i,this._core),{successUserIDList:s=[],failureUserIDList:n=[]}=this._processOperationResult({resultList:o.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:s,failureUserIDList:n}}}catch(a){let e=(a||{})["errorCode"];throw new t.ChatError({code:e})}})}dispose(){this.reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this)}reset(){var e=this._core.appStore["userStore"];e.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(s){return _(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core;e.debug("updateFriendList",f+" updateFriendList data:"+t(s));let r=this._core.appStore["userStore"],{addedFriendList:i=[],removedFriendList:o=[]}=s;0<i.length&&(i.forEach(e=>{var t=new p({userID:e,core:this._core});r.getFriendMap().set(e,t)}),yield this.getFriendProfile({userIDList:i}),this._emitFriendListUpdated()),0<o.length&&(o.forEach(e=>{r.getFriendMap().delete(e)}),this._emitFriendListUpdated())})}updateFriendInfo(e){var{ssoLog:t,utils:{safeStringify:r}}=this._core;t.debug("updateFriendList",f+" updateFriendInfo data:"+r(e));let{appStore:{userStore:i,conversationStore:o},utils:{isEmpty:s}}=this._core,{userID:n,tagValueList:a}=e[0]||{},d=i.getFriend(n);if(!s(a)&&d){let i=a.map(e=>({tag:e.BytesTag,value:e.BytesValue}));i.forEach(e=>{var{tag:e,value:t}=e,r=null==(r=o.getConversation("C2C"+n))?void 0:r.remark;e===u.REMARK&&t!==r&&o.updateConversation("C2C"+n,{remark:t}),d.update(i)}),this._emitFriendListUpdated()}}_processFriendList(e){let{utils:{isEmpty:t},appStore:{userStore:r}}=this._core;t(e)||e.forEach(e=>{var{userID:e,tagValueList:t}=e;this._isInvalidFriend(e)||(t=new p({userID:e,tagValueList:t,core:this._core}),r.getFriendMap().set(e,t))})}_isInvalidFriend(e){return"@TLS#NOT_FOUND"===e||""===e}_fetchFriendProfile(){return _(this,void 0,void 0,function*(){let{appStore:{userStore:s},user:{userProfile:n},ssoLog:e}=this._core,a=(e.debug("_fetchFriendProfile",f+" _fetchFriendProfile"),[...s.getFriendMap().keys()]),t=Math.ceil(a.length/100);for(let o=0;o<t;o++){let e=100*o,t=Math.min(100+e,a.length),r=a.slice(e,t),i=yield null==n?void 0:n.getUserProfile({userIDList:r});i&&i.data&&i.data.forEach(e=>{var t=s.getFriend(e.userID);t&&(t.profile=e)}),this._emitFriendListUpdated()}})}_emitFriendListUpdated(){var{notificationCenter:e,OuterEvent:t,appStore:{userStore:r}}=this._core,r=Array.from(r.getFriendMap().values());e.emitOuterEvent(t.FRIEND_LIST_UPDATED,{name:t.FRIEND_LIST_UPDATED,data:r})}_updateCustomField(i,e){if(!Array.isArray(i)||!Array.isArray(e))return!1;let o=!1;return e.forEach(({key:t,value:e})=>{var r=i.find(e=>e.key===t);r?r.value!==e&&(r.value=e,o=!0):(i.push({key:t,value:e}),o=!0)}),o}_updateLocalFriend(e){var t=this._core.appStore["userStore"],{userID:e,remark:r,friendCustomField:i}=e,t=t.getFriend(e);if(t)return m(r)||(t.remark=r),Array.isArray(i)&&0<i.length&&this._updateCustomField(t.friendCustomField,i),this._emitFriendListUpdated(),t}_processOperationResult(e){let{resultList:t,includeRelation:o=!1}=e,r=this._core.utils["isEmpty"],s=[],n=[];return Array.isArray(t)&&!r(t)&&t.forEach(e=>{var{userID:t,relation:r,resultCode:e,resultInfo:i}=e;if(m(e)||0===e){let e={userID:t};o&&(e.code=0,e.relation=r),s.push(e)}else n.push({userID:t,code:e,message:i})}),{successUserIDList:s,failureUserIDList:n}}_createNonFriendErrorList(e){return e.map(e=>({userID:e,code:2700,message:"The specified userID is not my friend"}))}_buildSnsItemList(e,t){let r=[];return m(e)||r.push({Tag:u.REMARK,Value:e}),Array.isArray(t)&&0<t.length&&t.forEach(e=>{r.push({tag:e.key,value:e.value})}),r}_processFriendProfileResponse(e){let{friendProfileList:t=[]}=e,o=this._core.appStore["userStore"],s=[],n=[];return t.forEach(e=>{var{userID:t,resultCode:e,resultInfo:r,profileItem:i}=e;if(0===e){let e=new p({userID:t,tagValueList:i,core:this._core});s.push(e),o.getFriendMap().set(t,e)}else n.push({userID:t,code:e,message:r})}),{successProfiles:s,failedProfiles:n}}partitionByIsFriend(e){let r=[],i=[];return e.forEach(e=>{var t=this._core.appStore["userStore"];(t.getFriendMap().has(e)?r:i).push(e)}),{friendUserIdList:r,unFriendUserIdList:i}}isMyFriend(e){var t=this._core.appStore["userStore"];return t.getFriendMap().has(e)}},I=new class{init(e){this.core=e}};function i(r){return _(this,void 0,void 0,function*(){var{store:e,common:t}=I.core,e={From_Account:null==(e=e.get("login"))?void 0:e.userId,ResponseFriendItem:[{To_Account:r.userID,ResponseAction:r.type,Remark:r.remark}]};return n(yield t.buildAndSendPacket({servcmd:"sns.friend_response",data:e}))})}function t(r){return _(this,void 0,void 0,function*(){var{store:e,common:t}=I.core,e={From_Account:null==(e=e.get("login"))?void 0:e.userId,ResponseFriendItem:[{To_Account:r.userID,ResponseAction:"Response_Action_Reject"}]};return n(yield t.buildAndSendPacket({servcmd:"sns.friend_response",data:e}))})}function s(r){return _(this,void 0,void 0,function*(){var{store:e,common:t}=I.core,e={From_Account:null==(e=e.get("login"))?void 0:e.userId,To_Account:[r.userID],PendencyType:r.type};return n(yield t.buildAndSendPacket({servcmd:"sns.pendency_delete",data:e}))})}function n(e){var{ResultItem:e=[],ActionStatus:t,ErrorCode:r,ErrorInfo:i,ErrorDisplay:o}=e;return{resultList:e.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:t,errorCode:r,errorInfo:i,errorDisplay:o}}var L=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),e.registerApi({apiName:"acceptFriendApplication",context:this}),e.registerApi({apiName:"refuseFriendApplication",context:this}),e.registerApi({apiName:"deleteFriendApplication",context:this}),e.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return _(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core,r=[...this._friendApplicationMap.values()];return e.debug("getFriendApplicationListFromCache",f+" getFriendApplicationListFromCache friendApplicationList:"+t(r)),{code:0,data:{friendApplicationList:r,unreadCount:this._unreadCount}}})}syncFriendApplicationListFromServer(){return _(this,void 0,void 0,function*(){let{ssoLog:r,utils:{safeStringify:e}}=this._core,i="syncFriendApplicationListFromServer";try{let e=yield function(d){return _(this,void 0,void 0,function*(){var{store:e,OuterConstant:t,common:r}=I.core,e={From_Account:null==(e=e.get("login"))?void 0:e.userId,PendencyType:t.SNS_APPLICATION_TYPE_BOTH,MaxLimited:h,StartTime:d.startTime,LastSequence:d.currentSequence},{PendencyItem:t=[],StartTime:r,UnreadPendencyCount:e,CurrentSequence:i,ActionStatus:o,ErrorCode:s,ErrorInfo:n,ErrorDisplay:a}=t=yield r.buildAndSendPacket({servcmd:"sns.pendency_get",data:e});return{resultList:t.map(e=>({userID:e.To_Account,time:e.AddTime,source:e.AddSource,wording:e.AddWording,nick:e.Nick,type:e.PendencyType,image:e.Image})),startTime:r,unreadCount:e,currentSequence:i,actionStatus:o,errorCode:s,errorInfo:n,errorDisplay:a}})}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:t,unreadCount:r,startTime:i,currentSequence:o}=e;this._startTime=i,this._currentSequence=o,this._unreadCount=r,this._friendApplicationMap.clear(),Array.isArray(t)&&t.forEach(e=>{var{userID:t,type:r}=e,e=this._createFriendApplication(e);this._friendApplicationMap.set(t+"_"+r,e)}),this._emitApplicationListUpdated()}catch(e){let t=new this._core.helper.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw r.error("syncFriendApplicationListFromServer",`${f} ${i} error:`,{error:t}),t}})}acceptFriendApplication(r){return _(this,void 0,void 0,function*(){var{SNS_APPLICATION_AGREE:e,SNS_APPLICATION_AGREE_AND_ADD:t}=this._core["OuterConstant"];return[e,t].includes(r.type)||(r.type=t),this._operationApplication({functionName:"acceptFriendApplication",options:r,protocolFunction:i})})}refuseFriendApplication(e){return _(this,void 0,void 0,function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:e,protocolFunction:t})})}deleteFriendApplication(r){return _(this,void 0,void 0,function*(){var{userID:e,type:t}=r;return this._checkApplicationExists(e,t,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:r,protocolFunction:s})})}_checkApplicationExists(e,t,r){if(!this._friendApplicationMap.has(e+"_"+t))throw new this._core.helper.ChatError({functionName:r,code:2716})}_operationApplication(e){return _(this,void 0,void 0,function*(){let{functionName:o,options:s,protocolFunction:n}=e;console.log(f+` ${o} options:`,s);try{let e=yield n(s),{resultList:t=[]}=e,{resultCode:r,resultInfo:i}=t[0];if(0===r)return console.log(f+` ${o} ok`),{code:0,data:{}};throw{errorCode:r,errorInfo:i}}catch(e){let t=new this._core.helper.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(f+` ${o} error:`,t),t}})}setFriendApplicationRead(){return _(this,void 0,void 0,function*(){try{return yield function(){return _(this,void 0,void 0,function*(){var{store:e,common:t}=I.core,e={From_Account:null==(e=e.get("login"))?void 0:e.userId,LatestPendencyTimeStamp:(e=Math.floor(Date.now()/1e3),Math.round(Number(e)*Math.pow(10,0))/Math.pow(10,0))},{ActionStatus:t,ErrorCode:e,ErrorInfo:r,ErrorDisplay:i}=t=yield t.buildAndSendPacket({servcmd:"sns.pendency_report",data:e});return{actionStatus:t,errorCode:e,errorInfo:r,errorDisplay:i}})}(),this._unreadCount=0,this._emitApplicationListUpdated(),{code:0,data:{}}}catch(e){throw new this._core.helper.ChatError({functionName:"setFriendApplicationRead",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}updateFriendApplicationList(e){var{from:e,addedApplicationList:t=[],removedApplicationList:r=[]}=e,i=this._core.utils["isEmpty"];i(t)||this.onApplicationAdded(t,e),i(r)||this.onApplicationDeleted()}onApplicationAdded(e,t){let r,{store:i,OuterConstant:o}=this._core,s=t===(null==(r=i.get("login"))?void 0:r.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;e.forEach(e=>{var t=e.userID+"_"+s;s!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,this._createFriendApplication(Object.assign(Object.assign({},e),{type:s})))}),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(e){return{userID:e.userID||"",nick:e.nick||"",avatar:e.avatar||"",time:e.time||0,source:e.source||"",wording:e.wording||"",type:e.type||""}}_emitApplicationListUpdated(){var{notificationCenter:e,OuterEvent:t}=this._core;e.emitOuterEvent(t.FRIEND_APPLICATION_LIST_UPDATED,{name:t.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function r(i){return _(this,void 0,void 0,function*(){var e=I.core["common"],{name:t,userIDList:r}=i,r=g(r,a),t={From_Account:e.getCurrentUserID(),GroupOldName:t,UpdateGroupItem:r};return y(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:t}),e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function A(i){return _(this,void 0,void 0,function*(){var e=I.core["common"],{name:t,userIDList:r}=i,r=g(r,d),t={From_Account:e.getCurrentUserID(),GroupOldName:t,UpdateGroupItem:r};return y(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:t}),e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function g(e,t){return e.filter(e=>F.isMyFriend(e)).map(e=>({To_Account:e,UpdateType:t}))}function y(e,t){var{CurrentSequence:e,ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:s,ResultItem:n=[]}=e,e={currentSequence:e,actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:s};return t&&0<n.length?Object.assign(Object.assign({},e),{resultList:n.map(t)}):e}class S{constructor(e){var{name:e="",userIDList:t=[]}=e;this.name=e,this.userIDList=t,this.count=t.length}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){e=this.userIDList.indexOf(e);-1<e&&(this.userIDList.splice(e,1),this.count=this.userIDList.length)}}var E=new class{constructor(){this._friendGroupMap=new Map}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),e.registerApi({apiName:"createFriendGroup",context:this}),e.registerApi({apiName:"deleteFriendGroup",context:this}),e.registerApi({apiName:"addToFriendGroup",context:this}),e.registerApi({apiName:"removeFromFriendGroup",context:this}),e.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return _(this,void 0,void 0,function*(){var{ssoLog:e,utils:{safeStringify:t}}=this._core,r=[...this._friendGroupMap.values()];return e.debug(f+" getFriendGroupListFromCache, data:"+t(r)),{code:0,data:r}})}syncFriendGroupListFromServer(){return _(this,void 0,void 0,function*(){var e=this._core["ssoLog"],t="syncFriendGroupListFromServer";try{var r=yield function(){return _(this,void 0,void 0,function*(){var e=I.core["common"],t={From_Account:e.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return y(yield e.buildAndSendPacket({servcmd:"sns.group_get",data:t}),e=>({name:e.GroupName,userIDList:e.To_Account||[],count:e.FriendNumber}))})}(),{resultList:i=[]}=r;this._core.helper.isEmpty(i)&&e.debug("syncFriendGroupListFromServer",f+` ${t} ok. count: 0`),i.forEach(e=>{var t=new S(e);this._friendGroupMap.set(e.name,t)}),this._emitGroupListUpdated()}catch(e){this._handleError(t,e)}})}createFriendGroup(n){return _(this,void 0,void 0,function*(){var t="createFriendGroup";try{var e=n["name"],r=(this._checkGroupExist(t,e),yield function(i){return _(this,void 0,void 0,function*(){var{name:e,userIDList:t}=i,r=I.core["common"],e={From_Account:r.getCurrentUserID(),GroupName:[e],To_Account:t};return y(yield r.buildAndSendPacket({servcmd:"sns.group_add",data:e}),e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}(n)),{successUserIDList:i,failureUserIDList:o}=this._parseCreateGroupResponse(r),s=new S({name:e,userIDList:i});return this._friendGroupMap.set(e,s),this._emitGroupListUpdated(),{code:0,data:{friendGroup:s,failureUserIDList:o}}}catch(e){this._handleError(t,e)}})}deleteFriendGroup(i){return _(this,void 0,void 0,function*(){var t="deleteFriendGroup";try{var e=i["name"],r=(this._checkGroupNotExist(t,e),yield function(r){return _(this,void 0,void 0,function*(){var e=I.core["common"],t={From_Account:e.getCurrentUserID(),GroupName:[r.name]};return y(yield e.buildAndSendPacket({servcmd:"sns.group_delete",data:t}))})}(i),this._friendGroupMap.get(e));return r&&(this._updateFriendGroup({name:e,userIDList:r.userIDList,action:c}),this._friendGroupMap.delete(e)),this._emitGroupListUpdated(),{code:0,data:r}}catch(e){this._handleError(t,e)}})}addToFriendGroup(e){return _(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:e,protocolFunction:r})})}removeFromFriendGroup(e){return _(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:e,protocolFunction:A})})}renameFriendGroup(o){return _(this,void 0,void 0,function*(){var t="renameFriendGroup";try{var{oldName:e,newName:r}=o,i=(this._checkGroupNotExist(t,e),this._checkGroupExist(t,r),yield function(i){return _(this,void 0,void 0,function*(){var e=I.core["common"],{oldName:t,newName:r}=i,t={From_Account:e.getCurrentUserID(),GroupOldName:t,GroupNewName:r};return y(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:t}))})}(o),this._updateGroupNameInCache(e,r));return i&&this._updateFriendGroup({name:e,userIDList:i.userIDList,action:l,newName:r}),this._emitGroupListUpdated(),{code:0,data:i}}catch(e){this._handleError(t,e)}})}_updateFriendGroupMember(e){return _(this,void 0,void 0,function*(){var{functionName:t,params:r,protocolFunction:i}=e;try{let e=r["name"];this._checkGroupNotExist(t,e);var o=yield i(r),{friendGroup:s,failureUserIDList:n}=this._parseUpdateFriendGroupResponse(e,o);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:s,failureUserIDList:n}}}catch(e){this._handleError(t,e)}})}_updateGroupNameInCache(e,t){var r=this._friendGroupMap.get(e);return r&&(r.name=t,this._friendGroupMap.delete(e),this._friendGroupMap.set(t,r)),r}_parseCreateGroupResponse(e){let{resultList:t=[]}=e,i=[],o=[];return t.forEach(({userID:e,resultCode:t,resultInfo:r})=>{m(t)||0===t?i.push(e):o.push({userID:e,code:t,message:r})}),{successUserIDList:i,failureUserIDList:o}}_parseUpdateFriendGroupResponse(t,e){let{resultList:r=[]}=e,i=this._friendGroupMap.get(t),o=[],s=[],n=[];return r.forEach(e=>{0===e.resultCode?i&&(e.updateType===a?this._addFriendToGroup(t,e.userID,i,s):e.updateType===d&&this._removeFriendFromGroup(t,e.userID,i,n)):o.push({userID:e.userID,code:e.resultCode,message:e.resultInfo})}),{friendGroup:i,failureUserIDList:o}}_addFriendToGroup(e,t,r,i){r.addToUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:"add"})}_removeFriendFromGroup(e,t,r,i){r.removeFromUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:c})}_emitGroupListUpdated(){var{notificationCenter:e,OuterEvent:t}=this._core,r=[...this._friendGroupMap.values()];e.emitOuterEvent(t.FRIEND_GROUP_LIST_UPDATED,{name:t.FRIEND_GROUP_LIST_UPDATED,data:r})}_checkGroupNotExist(e,t){if(!this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:2711})}_checkGroupExist(e,t){if(this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:2710})}_updateFriendGroup(e){let{name:i,userIDList:t,action:o,newName:s}=e,n=this._core.appStore["userStore"];i&&!this._core.utils.isEmpty(t)&&t.forEach(e=>{var t=n.getFriend(e);if(t){var r=t["groupList"];switch(o){case"add":-1===r.indexOf(i)&&(r.push(i),t.count=r.length);break;case c:{let e=r.indexOf(i);-1<e&&(r.splice(e,1),t.count=r.length);break}case l:if(s){let e=r.indexOf(i);-1!==e&&(r[e]=s)}}}})}_handleError(e,t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function D(e){return e&&0!==e.length?e.map(e=>({userID:e.To_Account,addBlackTimeStamp:e.AddBlackTimeStamp})):[]}var C=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(e){var{helper:e,constants:t}=this._core=e;e.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),e.registerApi({apiName:"addToBlacklist",context:this}),e.registerApi({apiName:"removeFromBlacklist",context:this}),e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return _(this,void 0,void 0,function*(){return{code:0,data:Array.from(this._blacklistMap.keys())}})}syncBlacklistFromServer(){return _(this,void 0,void 0,function*(){try{this._core.ssoLog.debug(f+" syncBlacklistFromServer");var e=yield function(i,o){return _(this,void 0,void 0,function*(){var{helper:e,channel:t}=o,r="sns.black_list_get",e=e.generateProtocolData({servcmd:r,data:i}),r=e.head.seq+r,{BlackListItem:t=[],StartIndex:e=0}=yield t.sendPacket(e,{requestId:r});return{blackList:D(t),startIndex:e}})}({From_Account:this._core.common.getCurrentUserID(),MaxLimited:h,StartIndex:this._startIndex},this._core),{blackList:t=[],startIndex:r=0}=e;return this._startIndex=r,this._addBlacklistMap(t),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw this._retryCount=0,e}})}addToBlacklist(o){return _(this,void 0,void 0,function*(){let r=this._core["helper"];try{let e=this._preprocessBlacklist(o),t={From_Account:this._core.common.getCurrentUserID(),To_Account:e},r=yield function(i,o){return _(this,void 0,void 0,function*(){var{helper:e,channel:t}=o,r="sns.black_list_add",e=e.generateProtocolData({servcmd:r,data:i}),r=e.head.seq+r,{ResultItem:t=[]}=yield t.sendPacket(e,{requestId:r});return{blackList:D(t)}})}(t,this._core),{blackList:i=[]}=r;return this._addBlacklistMap(i),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){let t=(e||{})["errorCode"];throw new r.ChatError({code:t})}})}removeFromBlacklist(i){return _(this,void 0,void 0,function*(){let r=this._core["helper"];try{let e={From_Account:this._core.common.getCurrentUserID(),To_Account:i.userIDList},t=yield function(i,o){return _(this,void 0,void 0,function*(){var{helper:e,channel:t}=o,r="sns.black_list_delete",e=e.generateProtocolData({servcmd:r,data:i}),r=e.head.seq+r,{ResultItem:t=[]}=yield t.sendPacket(e,{requestId:r});return{blackList:D(t)}})}(e,this._core),{blackList:r=[]}=t;return this._deleteBlacklistMap(r),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){let t=(e||{})["errorCode"];throw new r.ChatError({code:t})}})}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(e){var{ssoLog:t,utils:{safeStringify:r}}=this._core,{addedBlacklist:t=[],removedBlacklist:r=[]}=(t.debug("updateBlacklist",f+" updateBlacklist data: "+r(e)),e);let i=!1;0<t.length&&t.some(e=>!this._blacklistMap.has(e))&&(i=!0,this._addBlacklistMap(t.map(e=>({userID:e})))),0<r.length&&r.some(e=>this._blacklistMap.has(e))&&(i=!0,this._deleteBlacklistMap(r.map(e=>({userID:e})))),i&&this._emitBlackListUpdated()}_addBlacklistMap(e){var{ssoLog:t,utils:{safeStringify:r}}=this._core;t.debug("_addBlacklistMap",f+" _addBlacklistMap blackList: "+r(e)),e.forEach(e=>{var{userID:e,addBlackTimeStamp:t=Date.now()}=e;e&&!this._blacklistMap.has(e)&&this._blacklistMap.set(e,{userID:e,addBlackTimeStamp:t})})}_deleteBlacklistMap(e){var{ssoLog:t,utils:{safeStringify:r}}=this._core;t.debug("_deleteBlacklistMap",f+" _deleteBlacklistMap blackList: "+r(e)),e.forEach(e=>{e=e.userID;e&&this._blacklistMap.has(e)&&this._blacklistMap.delete(e)})}_preprocessBlacklist(e){let t=e["userIDList"],r=this._core.common.getCurrentUserID();if(1===t.length&&t[0]===r)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:2742});return t=t.includes(r)?e.userIDList.filter(e=>e!==r):t}_emitBlackListUpdated(){var{notificationCenter:e,OuterEvent:t,ssoLog:r,utils:{safeStringify:i}}=this._core,o=Array.from(this._blacklistMap.keys());r.debug(f+" _emitBlackListUpdated blackList:"+i(o)),e.emitOuterEvent(t.BLACKLIST_UPDATED,{name:t.BLACKLIST_UPDATED,data:o})}};let T={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{var t=I.core["OuterConstant"];return e===t.SNS_ADD_TYPE_SINGLE||e===t.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{var t=I.core["OuterConstant"];return e===t.SNS_DELETE_TYPE_SINGLE||e===t.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{var t=I.core["OuterConstant"];return e===t.SNS_APPLICATION_SENT_TO_ME||e===t.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},k={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};return new class{constructor(){this.name="Friend"}install(e){e.ssoLog.debug(f+" install");var{helper:t,notificationCenter:r,InnerEvent:i,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:s}}=this._core=e;I.init(e),F.init(e),L.init(e),E.init(e),C.init(e),t.registerValidateConfig({auth:k,params:T}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,s.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),r.subscribeInnerEvent(i.LOGOUT,this.reset,this),r.subscribeInnerEvent(i.MESSAGE_PUSH,r.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){C.syncBlacklistFromServer(),F.syncFriendListFromServer(),L.syncFriendApplicationListFromServer(),E.syncFriendGroupListFromServer()}onFriendModified(e){var{from:e,addedBlacklist:t,removedBlacklist:r,addedFriendList:i,removedFriendList:o,addedApplicationList:s,removedApplicationList:n,friendUpdateInfo:a,reportTime:d}=this._parseFriendListModification(null==e?void 0:e.FriendListMod[0]),u=this._core.utils["isEmpty"];u(t)&&u(r)||C.updateBlacklist({addedBlacklist:t,removedBlacklist:r}),u(i)&&u(o)||(F.updateFriendList({addedFriendList:i,removedFriendList:o}),L.updateFriendApplicationList({from:e,removedApplicationList:i})),u(a)||F.updateFriendInfo(a),u(s)&&u(n)||L.updateFriendApplicationList({from:e,addedApplicationList:s,removedApplicationList:n}),d&&L.onApplicationRead()}_parseFriendListModification(e){var{PushType:e,From_Account:t,To_Account:r,ReportTime:i,BlackListAdd_Account:o=[],BlackListDel_Account:s=[],FriendAdd_Account:n=[],FriendDel_Account:a=[],PendencyAdd:d=[],FrienPencydDel_Account:u=[],FriendUpInfo:c=[]}=e,c=c.map(e=>({userID:e.Friend_Account,tagValueList:[...e.SNS]}));return{pushType:e,from:t,to:r,reportTime:i,addedBlacklist:o,removedBlacklist:s,addedFriendList:n,removedFriendList:a,addedApplicationList:d.map(e=>({userID:e.PendencyAdd_Account,source:e.AddSource,time:e.AddTime,wording:e.AddWording,nick:e.ProfileImNick})),friendUpdateInfo:c,removedApplicationList:u}}reset(){C.reset(),F.reset(),L.reset(),E.reset()}dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,e.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),C.dispose(),F.dispose(),L.dispose(),E.dispose()}}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatFriend=t()}(this,function(){"use strict";function e(e,t,r,i){return new(r||(r=Promise))(function(o,n){function s(e){try{a(i.next(e))}catch(e){n(e)}}function d(e){try{a(i.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,d)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const t="friend",r=100,i=2700,o=2710,n=2711,s=2716,d=2742,a=30539,c="Tag_SNS_IM_",u={GROUP:`${c}Group`,REMARK:`${c}Remark`,ADDSOURCE:`${c}AddSource`,ADDWORDING:`${c}Wording`,ADDTIME:`${c}AddTime`},l="Update_Type_Add",p="Update_Type_Delete",h="add",m="remove",_="rename",f=e=>void 0===e;function F(t,r){return e(this,void 0,void 0,function*(){return function(e){return L(e,"ResultItem",e=>({to:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_update",data:t}))})}function I(t,r){return e(this,void 0,void 0,function*(){return function(e){return L(e,"InfoItem",e=>({userID:e.To_Account,relation:e.Relation,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_check",data:t}))})}function L(e,t="ResultItem",r=e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})){const{[t]:i=[],ActionStatus:o,ErrorCode:n,ErrorInfo:s,ErrorDisplay:d}=e;return{resultList:i.map(r),actionStatus:o,errorCode:n,errorInfo:s,errorDisplay:d}}const v={[u.REMARK]:(e,t)=>{e.remark=t},[u.GROUP]:(e,t)=>{e.groupList=t?JSON.parse(JSON.stringify(t)):[]},[u.ADDSOURCE]:(e,t)=>{e.source=t},[u.ADDWORDING]:(e,t)=>{e.wording=t},[u.ADDTIME]:(e,t)=>{e.addTime=t}};let A=class{constructor(e){var t;this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];const{userID:r,tagValueList:i=[],core:o}=e,n=null===(t=o.user.userProfile)||void 0===t?void 0:t.createProfile(r,i);this.userID=r,this.profile=n,i.forEach(e=>{const{tag:t,value:r}=e;t.indexOf("Tag_Profile_Custom")>-1&&this.friendCustomField.push({key:t,value:r});const i=v[t];null==i||i(this,r)})}update(e){const t=[];this.friendCustomField.forEach(e=>{t.push(e.key)}),e.forEach(e=>{const{tag:r,value:i}=e;r.indexOf("Tag_Profile_Custom")>-1&&(t.indexOf(r)>-1?this.friendCustomField.forEach(e=>{e.key===r&&(e.value=i)}):this.friendCustomField.push({key:r,value:i}));const o=v[r];null==o||o(this,i)})}};var g=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),t.registerApi({apiName:"getFriendProfile",context:this}),t.registerApi({apiName:"addFriend",context:this}),t.registerApi({apiName:"deleteFriend",context:this}),t.registerApi({apiName:"updateFriend",context:this}),t.registerApi({apiName:"checkFriend",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return e(this,void 0,void 0,function*(){const{appStore:{userStore:e},ssoLog:r,utils:{safeStringify:i}}=this._core,o=[...e.getFriendMap().values()];return r.debug("getFriendListFromCache",`${t} getFriendListFromCache, data:${i(o)}`),{code:0,data:o}})}syncFriendListFromServer(){return e(this,void 0,void 0,function*(){var r;const{ssoLog:i,helper:o}=this._core;try{i.debug("syncFriendListFromServer",`${t} syncFriendListFromServer`);const o={From_Account:null===(r=this._core.store.get("login"))||void 0===r?void 0:r.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},n=yield function(t,r){return e(this,void 0,void 0,function*(){return function(e){const{UserDataItem:t=[],StandardSequence:r,CustomSequence:i,FriendNum:o,CompleteFlag:n,NextStartIndex:s,ActionStatus:d,ErrorCode:a,ErrorInfo:c,ErrorDisplay:u}=e;return{friendList:t.map(e=>{var t;return{userID:e.To_Account,tagValueList:null===(t=e.ValueItem)||void 0===t?void 0:t.map(e=>({tag:e.Tag,value:e.Value}))}}),standardSequence:r,customSequence:i,friendNumber:o,completeFlag:n,nextStartIndex:s,actionStatus:d,errorCode:a,errorInfo:c,errorDisplay:u}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get",data:t}))})}(o,this._core),{friendList:s,nextStartIndex:d,standardSequence:a,customSequence:c,completeFlag:u}=n;this._startIndex=d,this._standardSequence=a,this._customSequence=c,this._processFriendList(s),0===u?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),i.debug("syncFriendListFromServer",`${t} syncFriendListFromServer ok`)}catch(e){const{errorCode:t}=e||{};throw new o.ChatError({code:t})}})}getFriendProfile(t){return e(this,void 0,void 0,function*(){var i;try{let{userIDList:o}=t;o.length>r&&(o=o.slice(0,r));const{friendUserIdList:n,unFriendUserIdList:s}=this.partitionByIsFriend(o),d=this._createNonFriendErrorList(s);if(0===n.length)return{code:0,data:{friendList:[],failureUserIDList:d}};const a={From_Account:null===(i=this._core.store.get("login"))||void 0===i?void 0:i.userId,To_Account:n},c=(yield function(t,r){return e(this,void 0,void 0,function*(){return function(e){const{InfoItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{friendProfileList:t.map(e=>{var t;return{userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,relation:e.Relation,standardSequence:e.StandardSequence,customSequence:e.CustomSequence,profileItem:(null===(t=e.SnsProfileItem)||void 0===t?void 0:t.map(e=>({tag:e.Tag,value:e.Value})))||[]}}),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}(yield r.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:t}))})}(a,this._core))||{},{successProfiles:u,failedProfiles:l}=this._processFriendProfileResponse(c);return{code:0,data:{friendList:u,failureUserIDList:[...l,...d]}}}catch(e){const{errorCode:t}=e||{};throw new this._core.helper.ChatError({code:t})}})}addFriend(r){return e(this,void 0,void 0,function*(){var i;const{helper:o,store:n,ssoLog:s}=this._core;try{const{to:d,source:c,type:u,wording:l,remark:p,groupName:h}=r,m={From_Account:null===(i=n.get("login"))||void 0===i?void 0:i.userId,AddFriendItem:[{To_Account:d,AddSource:c,AddWording:l,GroupName:h,Remark:p}],AddType:u},_=yield function(t,r){return e(this,void 0,void 0,function*(){return L(yield r.common.buildAndSendPacket({servcmd:"sns.friend_add",data:t}))})}(m,this._core),{resultList:f=[]}=_,{userID:F,resultCode:I}=f[0];if(0===I)return s.debug("addFriend",`${t} addFriend ok`),{code:0,data:{userID:F}};if(I===a)return s.debug("addFriend",`${t} addFriend wait for the other party to agree`),{code:0,data:{userID:F,code:I,message:"wait for the other party to agree"}};throw new o.ChatError({functionName:"addFriend",code:I})}catch(e){const{errorCode:t}=e||{};throw new o.ChatError({code:t})}})}deleteFriend(i){return e(this,void 0,void 0,function*(){var o;const{store:n,ssoLog:s,helper:d}=this._core;try{let{userIDList:d,type:a}=i;const c=null===(o=n.get("login"))||void 0===o?void 0:o.userId;d.length>1e3&&(s.info("deleteFriend",`${t} deleteFriend the length of userIDList cannot exceed:1000`),d=d.slice(0,r));const{friendUserIdList:u,unFriendUserIdList:l}=this.partitionByIsFriend(d);if(0===u.length)return{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(l)}};const p={From_Account:c,To_Account:u,DeleteType:a},h=yield function(t,r){return e(this,void 0,void 0,function*(){return L(yield r.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:t}))})}(p,this._core),{successUserIDList:m,failureUserIDList:_}=this._processOperationResult({resultList:h.resultList,includeRelation:!1});return{code:0,data:{successUserIDList:m,failureUserIDList:_}}}catch(e){const{errorCode:t}=e||{};throw new d.ChatError({code:t})}})}updateFriend(t){return e(this,void 0,void 0,function*(){var e;const{helper:r,store:o,appStore:{userStore:n}}=this._core;try{const{userID:s,remark:d,friendCustomField:a}=t,c=null===(e=o.get("login"))||void 0===e?void 0:e.userId;if(!n.getFriendMap().has(s))throw new r.ChatError({functionName:"updateFriend",code:i});const u={From_Account:c,UpdateItem:[{To_Account:s,SnsItem:this._buildSnsItemList(d,a)}]},l=yield F(u,this._core),{resultList:p}=l,{to:h,resultCode:m,resultInfo:_}=p[0];if(f(m)||0===m){return{code:0,data:this._updateLocalFriend({userID:h,remark:d,friendCustomField:a})}}throw new r.ChatError({functionName:"updateFriend",code:m,message:_})}catch(e){const{errorCode:t}=e||{};throw new r.ChatError({code:t})}})}checkFriend(t){return e(this,void 0,void 0,function*(){var e;const{OuterConstant:r,store:i,helper:o}=this._core;try{const{userIDList:o,type:n}=t,s=null===(e=i.get("login"))||void 0===e?void 0:e.userId,d={From_Account:s,To_Account:o,CheckType:n===r.SNS_CHECK_TYPE_SINGLE?n:r.SNS_CHECK_TYPE_BOTH},a=yield I(d,this._core),{successUserIDList:c=[],failureUserIDList:u=[]}=this._processOperationResult({resultList:a.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:c,failureUserIDList:u}}}catch(e){const{errorCode:t}=e||{};throw new o.ChatError({code:t})}})}dispose(){this.reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this)}reset(){const{userStore:e}=this._core.appStore;e.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(r){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:i}}=this._core;e.debug("updateFriendList",`${t} updateFriendList data:${i(r)}`);const{userStore:o}=this._core.appStore,{addedFriendList:n=[],removedFriendList:s=[]}=r;n.length>0&&(n.forEach(e=>{const t=new A({userID:e,core:this._core});o.getFriendMap().set(e,t)}),yield this.getFriendProfile({userIDList:n}),this._emitFriendListUpdated()),s.length>0&&(s.forEach(e=>{o.getFriendMap().delete(e)}),this._emitFriendListUpdated())})}updateFriendInfo(e){const{ssoLog:r,utils:{safeStringify:i}}=this._core;r.debug("updateFriendList",`${t} updateFriendInfo data:${i(e)}`);const{appStore:{userStore:o,conversationStore:n},utils:{isEmpty:s}}=this._core,{userID:d,tagValueList:a}=e[0]||{},c=o.getFriend(d);if(s(a)||!c)return;const l=a.map(e=>({tag:e.BytesTag,value:e.BytesValue}));l.forEach(e=>{var t;const{tag:r,value:i}=e,o=null===(t=n.getConversation(`C2C${d}`))||void 0===t?void 0:t.remark;r===u.REMARK&&i!==o&&n.updateConversation(`C2C${d}`,{remark:i}),c.update(l)}),this._emitFriendListUpdated()}_processFriendList(e){const{utils:{isEmpty:t},appStore:{userStore:r}}=this._core;t(e)||e.forEach(e=>{const{userID:t,tagValueList:i}=e;if(this._isInvalidFriend(t))return;const o=new A({userID:t,tagValueList:i,core:this._core});r.getFriendMap().set(t,o)})}_isInvalidFriend(e){return"@TLS#NOT_FOUND"===e||""===e}_fetchFriendProfile(){return e(this,void 0,void 0,function*(){const{appStore:{userStore:e},user:{userProfile:r},ssoLog:i}=this._core;i.debug("_fetchFriendProfile",`${t} _fetchFriendProfile`);const o=[...e.getFriendMap().keys()],n=Math.ceil(o.length/100);for(let t=0;t<n;t++){const i=100*t,n=Math.min(i+100,o.length),s=o.slice(i,n),d=yield null==r?void 0:r.getUserProfile({userIDList:s});if(d&&d.data){d.data.forEach(t=>{const r=e.getFriend(t.userID);r&&(r.profile=t)})}this._emitFriendListUpdated()}})}_emitFriendListUpdated(){const{notificationCenter:e,OuterEvent:t,appStore:{userStore:r}}=this._core,i=Array.from(r.getFriendMap().values());e.emitOuterEvent(t.FRIEND_LIST_UPDATED,{name:t.FRIEND_LIST_UPDATED,data:i})}_updateCustomField(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let r=!1;return t.forEach(({key:t,value:i})=>{const o=e.find(e=>e.key===t);o?o.value!==i&&(o.value=i,r=!0):(e.push({key:t,value:i}),r=!0)}),r}_updateLocalFriend(e){const{userStore:t}=this._core.appStore,{userID:r,remark:i,friendCustomField:o}=e,n=t.getFriend(r);if(n)return f(i)||(n.remark=i),Array.isArray(o)&&o.length>0&&this._updateCustomField(n.friendCustomField,o),this._emitFriendListUpdated(),n}_processOperationResult(e){const{resultList:t,includeRelation:r=!1}=e,{isEmpty:i}=this._core.utils,o=[],n=[];return Array.isArray(t)&&!i(t)&&t.forEach(e=>{const{userID:t,relation:i,resultCode:s,resultInfo:d}=e;if(f(s)||0===s){const e={userID:t};r&&(e.code=0,e.relation=i),o.push(e)}else n.push({userID:t,code:s,message:d})}),{successUserIDList:o,failureUserIDList:n}}_createNonFriendErrorList(e){return e.map(e=>({userID:e,code:i,message:"The specified userID is not my friend"}))}_buildSnsItemList(e,t){const r=[];return f(e)||r.push({Tag:u.REMARK,Value:e}),Array.isArray(t)&&t.length>0&&t.forEach(e=>{r.push({tag:e.key,value:e.value})}),r}_processFriendProfileResponse(e){const{friendProfileList:t=[]}=e,{userStore:r}=this._core.appStore,i=[],o=[];return t.forEach(e=>{const{userID:t,resultCode:n,resultInfo:s,profileItem:d}=e;if(0===n){const e=new A({userID:t,tagValueList:d,core:this._core});i.push(e),r.getFriendMap().set(t,e)}else o.push({userID:t,code:n,message:s})}),{successProfiles:i,failedProfiles:o}}partitionByIsFriend(e){const t=[],r=[];return e.forEach(e=>{const{userStore:i}=this._core.appStore;i.getFriendMap().has(e)?t.push(e):r.push(e)}),{friendUserIdList:t,unFriendUserIdList:r}}isMyFriend(e){const{userStore:t}=this._core.appStore;return t.getFriendMap().has(e)}};var y=new class{init(e){this.core=e}};function S(t){return e(this,void 0,void 0,function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:t.type,Remark:t.remark}]};return C(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function E(t){return e(this,void 0,void 0,function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,ResponseFriendItem:[{To_Account:t.userID,ResponseAction:"Response_Action_Reject"}]};return C(yield i.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function D(t){return e(this,void 0,void 0,function*(){var e;const{store:r,common:i}=y.core,o={From_Account:null===(e=r.get("login"))||void 0===e?void 0:e.userId,To_Account:[t.userID],PendencyType:t.type};return C(yield i.buildAndSendPacket({servcmd:"sns.pendency_delete",data:o}))})}function C(e){const{ResultItem:t=[],ActionStatus:r,ErrorCode:i,ErrorInfo:o,ErrorDisplay:n}=e;return{resultList:t.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:r,errorCode:i,errorInfo:o,errorDisplay:n}}var T=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),t.registerApi({apiName:"acceptFriendApplication",context:this}),t.registerApi({apiName:"refuseFriendApplication",context:this}),t.registerApi({apiName:"deleteFriendApplication",context:this}),t.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:r}}=this._core,i=[...this._friendApplicationMap.values()];return e.debug("getFriendApplicationListFromCache",`${t} getFriendApplicationListFromCache friendApplicationList:${r(i)}`),{code:0,data:{friendApplicationList:i,unreadCount:this._unreadCount}}})}syncFriendApplicationListFromServer(){return e(this,void 0,void 0,function*(){const{ssoLog:i,utils:{safeStringify:o}}=this._core,n="syncFriendApplicationListFromServer";try{const t=yield function(t){return e(this,void 0,void 0,function*(){var e;const{store:i,OuterConstant:o,common:n}=y.core,s={From_Account:null===(e=i.get("login"))||void 0===e?void 0:e.userId,PendencyType:o.SNS_APPLICATION_TYPE_BOTH,MaxLimited:r,StartTime:t.startTime,LastSequence:t.currentSequence};return function(e){const{PendencyItem:t=[],StartTime:r,UnreadPendencyCount:i,CurrentSequence:o,ActionStatus:n,ErrorCode:s,ErrorInfo:d,ErrorDisplay:a}=e;return{resultList:t.map(e=>({userID:e.To_Account,time:e.AddTime,source:e.AddSource,wording:e.AddWording,nick:e.Nick,type:e.PendencyType,avatar:e.Image})),startTime:r,unreadCount:i,currentSequence:o,actionStatus:n,errorCode:s,errorInfo:d,errorDisplay:a}}(yield n.buildAndSendPacket({servcmd:"sns.pendency_get",data:s}))})}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:i,unreadCount:o,startTime:n,currentSequence:s}=t;this._startTime=n,this._currentSequence=s,this._unreadCount=o,this._friendApplicationMap.clear(),Array.isArray(i)&&i.forEach(e=>{const{userID:t,type:r}=e,i=this._createFriendApplication(e);this._friendApplicationMap.set(`${t}_${r}`,i)}),this._emitApplicationListUpdated()}catch(e){const r=new this._core.helper.ChatError({functionName:n,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw i.error("syncFriendApplicationListFromServer",`${t} ${n} error:`,{error:r}),r}})}acceptFriendApplication(t){return e(this,void 0,void 0,function*(){const{OuterConstant:{SNS_APPLICATION_AGREE:e,SNS_APPLICATION_AGREE_AND_ADD:r}}=this._core;return[e,r].includes(t.type)||(t.type=r),this._operationApplication({functionName:"acceptFriendApplication",options:t,protocolFunction:S})})}refuseFriendApplication(t){return e(this,void 0,void 0,function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:t,protocolFunction:E})})}deleteFriendApplication(t){return e(this,void 0,void 0,function*(){const{userID:e,type:r}=t;return this._checkApplicationExists(e,r,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:t,protocolFunction:D})})}_checkApplicationExists(e,t,r){if(!this._friendApplicationMap.has(`${e}_${t}`))throw new this._core.helper.ChatError({functionName:r,code:s})}_operationApplication(r){return e(this,void 0,void 0,function*(){const{functionName:e,options:i,protocolFunction:o}=r;console.log(`${t} ${e} options:`,i);try{const r=yield o(i),{resultList:n=[]}=r,{resultCode:s,resultInfo:d}=n[0];if(0===s)return console.log(`${t} ${e} ok`),{code:0,data:{}};throw{errorCode:s,errorInfo:d}}catch(r){const i=new this._core.helper.ChatError({functionName:e,code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo});throw console.error(`${t} ${e} error:`,i),i}})}setFriendApplicationRead(){return e(this,void 0,void 0,function*(){try{return yield function(){return e(this,void 0,void 0,function*(){var e;const{store:t,common:r}=y.core,i={From_Account:null===(e=t.get("login"))||void 0===e?void 0:e.userId,LatestPendencyTimeStamp:(o=Math.floor(Date.now()/1e3),n=0,Math.round(Number(o)*Math.pow(10,n))/Math.pow(10,n))};var o,n;return function(e){const{ActionStatus:t,ErrorCode:r,ErrorInfo:i,ErrorDisplay:o}=e;return{actionStatus:t,errorCode:r,errorInfo:i,errorDisplay:o}}(yield r.buildAndSendPacket({servcmd:"sns.pendency_report",data:i}))})}(),this._unreadCount=0,this._emitApplicationListUpdated(),{code:0,data:{}}}catch(e){throw new this._core.helper.ChatError({functionName:"setFriendApplicationRead",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}updateFriendApplicationList(e){const{from:t,addedApplicationList:r=[],removedApplicationList:i=[]}=e,{isEmpty:o}=this._core.utils;o(r)||this.onApplicationAdded(r,t),o(i)||this.onApplicationDeleted()}onApplicationAdded(e,t){var r;const{store:i,OuterConstant:o}=this._core,n=t===(null===(r=i.get("login"))||void 0===r?void 0:r.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;e.forEach(e=>{const t=`${e.userID}_${n}`;n!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,this._createFriendApplication(Object.assign(Object.assign({},e),{type:n})))}),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(e){return{userID:e.userID||"",nick:e.nick||"",avatar:e.avatar||"",time:e.time||0,source:e.source||"",wording:e.wording||"",type:e.type||""}}_emitApplicationListUpdated(){const{notificationCenter:e,OuterEvent:t}=this._core;e.emitOuterEvent(t.FRIEND_APPLICATION_LIST_UPDATED,{name:t.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function k(){return e(this,void 0,void 0,function*(){const{common:e}=y.core,t={From_Account:e.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return function(e){return U(e,e=>({name:e.GroupName,userIDList:e.To_Account||[],count:e.FriendNumber}))}(yield e.buildAndSendPacket({servcmd:"sns.group_get",data:t}))})}function N(t){return e(this,void 0,void 0,function*(){const{name:e,userIDList:r}=t,{common:i}=y.core,o={From_Account:i.getCurrentUserID(),GroupName:[e],To_Account:r};return function(e){return U(e,e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))}(yield i.buildAndSendPacket({servcmd:"sns.group_add",data:o}))})}function G(t){return e(this,void 0,void 0,function*(){const{common:e}=y.core,r={From_Account:e.getCurrentUserID(),GroupName:[t.name]};return function(e){return U(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_delete",data:r}))})}function w(t){return e(this,void 0,void 0,function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,l),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return U(e,e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))})}function P(t){return e(this,void 0,void 0,function*(){const{common:e}=y.core,{name:r,userIDList:i}=t,o=R(i,p),n={From_Account:e.getCurrentUserID(),GroupOldName:r,UpdateGroupItem:o};return function(e){return U(e,e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:n}))})}function M(t){return e(this,void 0,void 0,function*(){const{common:e}=y.core,{oldName:r,newName:i}=t,o={From_Account:e.getCurrentUserID(),GroupOldName:r,GroupNewName:i};return function(e){return U(e)}(yield e.buildAndSendPacket({servcmd:"sns.group_update",data:o}))})}function R(e,t){return e.filter(e=>g.isMyFriend(e)).map(e=>({To_Account:e,UpdateType:t}))}function U(e,t){const{CurrentSequence:r,ActionStatus:i,ErrorCode:o,ErrorInfo:n,ErrorDisplay:s,ResultItem:d=[]}=e,a={currentSequence:r,actionStatus:i,errorCode:o,errorInfo:n,errorDisplay:s};return t&&d.length>0?Object.assign(Object.assign({},a),{resultList:d.map(t)}):a}class O{constructor(e){const{name:t="",userIDList:r=[]}=e;this.name=t,this.userIDList=r,this.count=r.length}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}var b=new class{constructor(){this._friendGroupMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),t.registerApi({apiName:"createFriendGroup",context:this}),t.registerApi({apiName:"deleteFriendGroup",context:this}),t.registerApi({apiName:"addToFriendGroup",context:this}),t.registerApi({apiName:"removeFromFriendGroup",context:this}),t.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return e(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:r}}=this._core,i=[...this._friendGroupMap.values()];return e.debug(`${t} getFriendGroupListFromCache, data:${r(i)}`),{code:0,data:i}})}syncFriendGroupListFromServer(){return e(this,void 0,void 0,function*(){const{ssoLog:e}=this._core,r="syncFriendGroupListFromServer";try{const i=yield k(),{resultList:o=[]}=i;this._core.helper.isEmpty(o)&&e.debug("syncFriendGroupListFromServer",`${t} ${r} ok. count: 0`),o.forEach(e=>{const t=new O(e);this._friendGroupMap.set(e.name,t)}),this._emitGroupListUpdated()}catch(e){this._handleError(r,e)}})}createFriendGroup(t){return e(this,void 0,void 0,function*(){const e="createFriendGroup";try{const{name:r}=t;this._checkGroupExist(e,r);const i=yield N(t),{successUserIDList:o,failureUserIDList:n}=this._parseCreateGroupResponse(i),s=new O({name:r,userIDList:o});return this._friendGroupMap.set(r,s),this._emitGroupListUpdated(),{code:0,data:{friendGroup:s,failureUserIDList:n}}}catch(t){this._handleError(e,t)}})}deleteFriendGroup(t){return e(this,void 0,void 0,function*(){const e="deleteFriendGroup";try{const{name:r}=t;this._checkGroupNotExist(e,r),yield G(t);const i=this._friendGroupMap.get(r);return i&&(this._updateFriendGroup({name:r,userIDList:i.userIDList,action:m}),this._friendGroupMap.delete(r)),this._emitGroupListUpdated(),{code:0,data:i}}catch(t){this._handleError(e,t)}})}addToFriendGroup(t){return e(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:t,protocolFunction:w})})}removeFromFriendGroup(t){return e(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:t,protocolFunction:P})})}renameFriendGroup(t){return e(this,void 0,void 0,function*(){const e="renameFriendGroup";try{const{oldName:r,newName:i}=t;this._checkGroupNotExist(e,r),this._checkGroupExist(e,i),yield M(t);const o=this._updateGroupNameInCache(r,i);return o&&this._updateFriendGroup({name:r,userIDList:o.userIDList,action:_,newName:i}),this._emitGroupListUpdated(),{code:0,data:o}}catch(t){this._handleError(e,t)}})}_updateFriendGroupMember(t){return e(this,void 0,void 0,function*(){const{functionName:e,params:r,protocolFunction:i}=t;try{const{name:t}=r;this._checkGroupNotExist(e,t);const o=yield i(r),{friendGroup:n,failureUserIDList:s}=this._parseUpdateFriendGroupResponse(t,o);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:n,failureUserIDList:s}}}catch(t){this._handleError(e,t)}})}_updateGroupNameInCache(e,t){const r=this._friendGroupMap.get(e);return r&&(r.name=t,this._friendGroupMap.delete(e),this._friendGroupMap.set(t,r)),r}_parseCreateGroupResponse(e){const{resultList:t=[]}=e,r=[],i=[];return t.forEach(({userID:e,resultCode:t,resultInfo:o})=>{f(t)||0===t?r.push(e):i.push({userID:e,code:t,message:o})}),{successUserIDList:r,failureUserIDList:i}}_parseUpdateFriendGroupResponse(e,t){const{resultList:r=[]}=t,i=this._friendGroupMap.get(e),o=[],n=[],s=[];return r.forEach(t=>{0===t.resultCode?i&&(t.updateType===l?this._addFriendToGroup(e,t.userID,i,n):t.updateType===p&&this._removeFriendFromGroup(e,t.userID,i,s)):o.push({userID:t.userID,code:t.resultCode,message:t.resultInfo})}),{friendGroup:i,failureUserIDList:o}}_addFriendToGroup(e,t,r,i){r.addToUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:h})}_removeFriendFromGroup(e,t,r,i){r.removeFromUserIDList(t),i.push(t),this._updateFriendGroup({name:e,userIDList:i,action:m})}_emitGroupListUpdated(){const{notificationCenter:e,OuterEvent:t}=this._core,r=[...this._friendGroupMap.values()];e.emitOuterEvent(t.FRIEND_GROUP_LIST_UPDATED,{name:t.FRIEND_GROUP_LIST_UPDATED,data:r})}_checkGroupNotExist(e,t){if(!this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:n})}_checkGroupExist(e,t){if(this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:o})}_updateFriendGroup(e){const{name:t,userIDList:r,action:i,newName:o}=e,{userStore:n}=this._core.appStore;t&&!this._core.utils.isEmpty(r)&&r.forEach(e=>{const r=n.getFriend(e);if(!r)return;const{groupList:s}=r;switch(i){case h:-1===s.indexOf(t)&&(s.push(t),r.count=s.length);break;case m:{const e=s.indexOf(t);e>-1&&(s.splice(e,1),r.count=s.length);break}case _:{if(!o)return;const e=s.indexOf(t);-1!==e&&(s[e]=o);break}}})}_handleError(e,t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function B(e){return e&&0!==e.length?e.map(e=>({userID:e.To_Account,addBlackTimeStamp:e.AddBlackTimeStamp})):[]}var q=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(e){this._core=e;const{helper:t,constants:r}=e;t.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),t.registerApi({apiName:"addToBlacklist",context:this}),t.registerApi({apiName:"removeFromBlacklist",context:this}),t.registerWorkflowStep(r.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return e(this,void 0,void 0,function*(){return{code:0,data:Array.from(this._blacklistMap.keys())}})}syncBlacklistFromServer(){return e(this,void 0,void 0,function*(){try{this._core.ssoLog.debug(`${t} syncBlacklistFromServer`);const i={From_Account:this._core.common.getCurrentUserID(),MaxLimited:r,StartIndex:this._startIndex},o=yield function(t,r){return e(this,void 0,void 0,function*(){const{helper:e,channel:i}=r,o="sns.black_list_get",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{BlackListItem:a=[],StartIndex:c=0}=d;return{blackList:B(a),startIndex:c}})}(i,this._core),{blackList:n=[],startIndex:s=0}=o;return this._startIndex=s,this._addBlacklistMap(n),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){throw this._retryCount=0,e}})}addToBlacklist(t){return e(this,void 0,void 0,function*(){const{helper:r}=this._core;try{const r=this._preprocessBlacklist(t),i={From_Account:this._core.common.getCurrentUserID(),To_Account:r},o=yield function(t,r){return e(this,void 0,void 0,function*(){const{helper:e,channel:i}=r,o="sns.black_list_add",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}})}(i,this._core),{blackList:n=[]}=o;return this._addBlacklistMap(n),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){const{errorCode:t}=e||{};throw new r.ChatError({code:t})}})}removeFromBlacklist(t){return e(this,void 0,void 0,function*(){const{helper:r}=this._core;try{const r={From_Account:this._core.common.getCurrentUserID(),To_Account:t.userIDList},i=yield function(t,r){return e(this,void 0,void 0,function*(){const{helper:e,channel:i}=r,o="sns.black_list_delete",n=e.generateProtocolData({servcmd:o,data:t}),s=`${n.head.seq}${o}`,d=yield i.sendPacket(n,{requestId:s}),{ResultItem:a=[]}=d;return{blackList:B(a)}})}(r,this._core),{blackList:o=[]}=i;return this._deleteBlacklistMap(o),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(e){const{errorCode:t}=e||{};throw new r.ChatError({code:t})}})}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(e){const{ssoLog:r,utils:{safeStringify:i}}=this._core;r.debug("updateBlacklist",`${t} updateBlacklist data: ${i(e)}`);const{addedBlacklist:o=[],removedBlacklist:n=[]}=e;let s=!1;if(o.length>0){o.some(e=>!this._blacklistMap.has(e))&&(s=!0,this._addBlacklistMap(o.map(e=>({userID:e}))))}if(n.length>0){n.some(e=>this._blacklistMap.has(e))&&(s=!0,this._deleteBlacklistMap(n.map(e=>({userID:e}))))}s&&this._emitBlackListUpdated()}_addBlacklistMap(e){const{ssoLog:r,utils:{safeStringify:i}}=this._core;r.debug("_addBlacklistMap",`${t} _addBlacklistMap blackList: ${i(e)}`),e.forEach(e=>{const{userID:t,addBlackTimeStamp:r=Date.now()}=e;t&&!this._blacklistMap.has(t)&&this._blacklistMap.set(t,{userID:t,addBlackTimeStamp:r})})}_deleteBlacklistMap(e){const{ssoLog:r,utils:{safeStringify:i}}=this._core;r.debug("_deleteBlacklistMap",`${t} _deleteBlacklistMap blackList: ${i(e)}`),e.forEach(e=>{const{userID:t}=e;t&&this._blacklistMap.has(t)&&this._blacklistMap.delete(t)})}_preprocessBlacklist(e){let{userIDList:t}=e;const r=this._core.common.getCurrentUserID();if(1===t.length&&t[0]===r)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:d});return t.includes(r)&&(t=e.userIDList.filter(e=>e!==r)),t}_emitBlackListUpdated(){const{notificationCenter:e,OuterEvent:r,ssoLog:i,utils:{safeStringify:o}}=this._core,n=Array.from(this._blacklistMap.keys());i.debug(`${t} _emitBlackListUpdated blackList:${o(n)}`),e.emitOuterEvent(r.BLACKLIST_UPDATED,{name:r.BLACKLIST_UPDATED,data:n})}};const x={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_ADD_TYPE_SINGLE||e===t.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_DELETE_TYPE_SINGLE||e===t.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=y.core;return e===t.SNS_APPLICATION_SENT_TO_ME||e===t.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},$={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};return new class{constructor(){this.name="Friend"}install(e){e.ssoLog.debug(`${t} install`),this._core=e;const{helper:r,notificationCenter:i,InnerEvent:o,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:s}}=e;y.init(e),g.init(e),T.init(e),b.init(e),q.init(e),r.registerValidateConfig({auth:$,params:x}),r.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,s.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),i.subscribeInnerEvent(o.LOGOUT,this.reset,this),i.subscribeInnerEvent(o.MESSAGE_PUSH,i.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){q.syncBlacklistFromServer(),g.syncFriendListFromServer(),T.syncFriendApplicationListFromServer(),b.syncFriendGroupListFromServer()}onFriendModified(e){const{from:t,addedBlacklist:r,removedBlacklist:i,addedFriendList:o,removedFriendList:n,addedApplicationList:s,removedApplicationList:d,friendUpdateInfo:a,reportTime:c}=this._parseFriendListModification(null==e?void 0:e.FriendListMod[0]),{isEmpty:u}=this._core.utils;u(r)&&u(i)||q.updateBlacklist({addedBlacklist:r,removedBlacklist:i}),u(o)&&u(n)||(g.updateFriendList({addedFriendList:o,removedFriendList:n}),T.updateFriendApplicationList({from:t,removedApplicationList:o})),u(a)||g.updateFriendInfo(a),u(s)&&u(d)||T.updateFriendApplicationList({from:t,addedApplicationList:s,removedApplicationList:d}),c&&T.onApplicationRead()}_parseFriendListModification(e){const{PushType:t,From_Account:r,To_Account:i,ReportTime:o,BlackListAdd_Account:n=[],BlackListDel_Account:s=[],FriendAdd_Account:d=[],FriendDel_Account:a=[],PendencyAdd:c=[],FrienPencydDel_Account:u=[],FriendUpInfo:l=[]}=e,p=l.map(e=>({userID:e.Friend_Account,tagValueList:[...e.SNS]}));return{pushType:t,from:r,to:i,reportTime:o,addedBlacklist:n,removedBlacklist:s,addedFriendList:d,removedFriendList:a,addedApplicationList:c.map(e=>({userID:e.PendencyAdd_Account,source:e.AddSource,time:e.AddTime,wording:e.AddWording,nick:e.ProfileImNick})),friendUpdateInfo:p,removedApplicationList:u}}reset(){q.reset(),g.reset(),T.reset(),b.reset()}dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,e.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),q.dispose(),g.dispose(),T.dispose(),b.dispose()}}});
|
package/plugins/group.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r="GRP_COUNTER",i="Set",n="Increase",s="Decrease",u=0,a=1,c=2,p=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],l=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],m=["Role","JoinTime","MsgFlag","MsgSeq"],h=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],d=0,g=1,_="notStart",f="resolved",G="rejected",b=10018,I=11e3,C=2,v=["Owner","Admin","Member"],y=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],A=0,M=1,L=2,D=4,S=1,O=2,T=3,w=4,E=5,N=1,P=0,R=4,U=6,k=400,$=300,F={from:!0,groupID:!0,groupName:!0,to:!0},q={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},j=2,K=4,x=5,V=7,J=8,B=15,H=20,W=21,Y=2600,Q=2602,z=2603,X=2620,Z=2621,ee=2623,te=2660,oe=2661,re=2681,ie=2683,ne=2684,se=2685,ue=2687,ae=3122,ce=10018,pe=t=>t===e.core.OuterConstant.GRP_PUBLIC,le=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,me=(o,t)=>{var r=e.core.utils["isArray"];if(!r(o)||!r(t))return!1;let i=!1;return t.forEach(({key:t,value:e})=>{var r=o.find(e=>e.key===t);r?r.value!==e&&(r.value=e,i=!0):(o.push({key:t,value:e}),i=!0)}),i},he=r=>{var o=[];if(r)for(let e=0,t=r.length;e<t;e++){var{Key:i,Value:n}=r[e];o.push({key:i,value:n})}return o},de=r=>{var o=[];for(let e=0,t=r.length;e<t;e++){var{key:i,value:n}=r[e];o.push({Key:i,Value:n})}return o};function ge(t,r){var o=e.core["helper"];if(!o.checkBusinessCapabilityBits(r))throw new o.ChatError({functionName:t,code:ae,replacement1:t})}function _e(t,r){var o=e.core["helper"],o=new o.ChatError({functionName:t,code:(null==r?void 0:r.errorCode)||(null==r?void 0:r.code),message:(null==r?void 0:r.errorInfo)||(null==r?void 0:r.message)});throw console.error(t+" fail:",o),o}let fe=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class Ge{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._groupAtInfoList=[],this._initGroup(e)}_initGroup(t){var{isString:r}=e.core["utils"];for(let e in t)fe.indexOf(e)<0||("selfInfo"!==e?"isSupportTopic"!==e?"muteAllMembers"===e&&r(t[e])?this.muteAllMembers="On"===t[e]:this[e]=t[e]:this.isSupportTopic=1===t[e]:this.updateSelfInfo(t[e]))}updateGroup(t){let{utils:{isArray:r,isUndefined:o,isNumber:i,isString:n},common:{deepMerge:s}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);t=JSON.parse(JSON.stringify(t));t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),n(t.muteAllMembers)&&(t.muteAllMembers="On"===t.muteAllMembers),t.groupCustomField&&me(this.groupCustomField,t.groupCustomField),o(t.isSupportTopic)||(this.isSupportTopic=i(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),s(this,t,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),r(t.members)&&0<t.members.length&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&s(this.selfInfo,e,["sequence"])})}updateSelfInfo(t){var{nameCard:t,joinTime:r,role:o,messageRemindType:i,readedSequence:n,excludedUnreadSequenceList:s}=t,u=e.core["common"]["deepMerge"];u(this.selfInfo,{nameCard:t,joinTime:r,role:o,messageRemindType:i,readedSequence:n,excludedUnreadSequenceList:s},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var be=new class{constructor(){this._name="GroupDataHandler"}init(e){var e=(this._core=e)["appStore"]["groupStore"];this._groupMap=e.getGroupMap()}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){var{getCurrentUserID:t}=this._core["common"];let r;e.forEach(e=>{var t;r=e.groupID,this.hasLocalGroup(r)?null!=(t=this.getLocalGroup(r))&&t.updateGroup(e):this._groupMap.set(r,new Ge(e))});var o=t();for(let[,e]of this._groupMap)e.selfInfo.userID=o,"Owner"===e.selfInfo.role&&(e.ownerID=o)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){let{GRP_ROOM:t,GRP_LIVE:r}=this._core["OuterConstant"];return[...this._groupMap.values()].filter(e=>{e=e.type;return e!==t&&e!==r})}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){var e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:r}=this._core;r.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(t){let{appStore:{conversationStore:r},OuterConstant:{CONV_GROUP:e}}=this._core,o=""+e+t;if(r.getConversation(o)){let e=this.getLocalGroup(t);r.updateConversation(o,{groupProfile:e})}}reset(){this.clearLocalGroup()}};function Ie(e,t){var r={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(r[i[o]]=e[i[o]]);return r}function Ce(e,s,u,a){return new(u=u||Promise)(function(r,t){function o(e){try{n(a.next(e))}catch(e){t(e)}}function i(e){try{n(a.throw(e))}catch(e){t(e)}}function n(e){var t;e.done?r(e.value):((t=e.value)instanceof u?t:new u(function(e){e(t)})).then(o,i)}n((a=a.apply(e,s||[])).next())})}function ve(s,u){return Ce(this,void 0,void 0,function*(){var{type:e,limit:t,offset:r,supportTopic:o=0,memberAccount:i,responseFilter:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:{Type:e,Limit:t,Offset:r,Member_Account:i,ResponseFilter:n,SupportTopic:o,NeedAppDefineData:1}})})}let ye=function(e,t){return{code:0,data:e||{},successLog:t}};var Ae=new class{constructor(){this._name="GetGroupList",this._pagingStatus=_,this.PAGING_GRP_COUNT_LIMIT=200}init(e){var{helper:e,constants:{WORKFLOW_NAME:t,WORKFLOW_STEP:r}}=this._core=e;e.registerApi({apiName:"getGroupList",context:this}),e.registerWorkflowStep(t.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return Ce(this,arguments,void 0,function*(e=!1){if(e){let e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),be.updateLocalGroup(e),be.getLocalGroupList()}return this._core.ssoLog.debug("getGroupList",this._name+".getGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===G||this._pagingStatus===_?this._syncGroupList().then(()=>{var e=be.getLocalGroupList();return ye({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw e}):(e=be.getLocalGroupList(),ye({groupList:e,isSyncCompleted:this._isSyncCompleted()},{message:"return group count:"+e.length}))})}_syncGroupList(){return Ce(this,void 0,void 0,function*(){this._pagingStatus===_&&be.clearLocalGroup();var e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=f,this._groupListTreeShaking(t),be.updateLocalGroup(t);var r=be.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",this._name+"._syncGroupList ok, count:"+r.length),be.emitGroupListUpdate(),r}catch(e){throw this._pagingStatus=G,e}})}_pagingGetGroupList(e){return Ce(this,void 0,void 0,function*(){var i=this._core["ssoLog"],{isCommunityRelay:n=!1,groupList:s}=e;let u,{limit:a,offset:c}=e;var l=[...p];n&&(u=this._core.OuterConstant.GRP_COMMUNITY,l.push("AtInfoList"));try{let e=yield ve({type:u,limit:a,offset:c,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:l,SelfInfoFilter:[...m]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t);s.push(...o);var h=c+a,d=!(h<r),g=`offset:${c} limit:${a} total:${r} isCompleted:${d} current:${s.length} isCommunityRelay:`+n;return i.debug("_pagingGetGroupList",this._name+"._pagingGetGroupList ok. "+g),n?d?s:(c=h,this._pagingGetGroupList({isCommunityRelay:!0,limit:a,offset:c,groupList:s})):d?(i.debug("_pagingGetGroupList",this._name+"._pagingGetGroupList start to get community list"),c=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:a,offset:c,groupList:s})):(c=h,this._pagingGetGroupList({limit:a,offset:c,groupList:s}))}catch(e){if(e.ErrorCode===b)return i.warn("_pagingGetGroupList",this._name+"._pagingGetGroupList response size exceeds the limit, request count:"+a),this._pagingGetGroupList({isCommunityRelay:n,limit:50,offset:c,groupList:s});if(n)return e.code===I&&i.debug("_pagingGetGroupList",this._name+"._pagingGetGroupList ok. community unavailable"),s;throw e}})}_pagingGetJoinedCommunityList(e){return Ce(this,void 0,void 0,function*(){var{common:{getCurrentUserID:i},OuterConstant:n,ssoLog:s}=this._core,u=e["groupList"];let{limit:a,offset:c}=e;try{let e=yield ve({limit:a,offset:c,type:n.GRP_COMMUNITY,memberAccount:i(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...p],SelfInfoFilter:[...m]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t);u.push(...o);var l=c+a,h=!(l<r),d=`offset:${c} limit:${a} total:${r} isCompleted:${h} current:`+u.length;return s.debug("_pagingGetJoinedCommunityList",this._name+"._pagingGetJoinedCommunityList ok. "+d),h?u:(c=l,this._pagingGetJoinedCommunityList({limit:a,offset:c,groupList:u}))}catch(e){if(e.code===ce)return s.warn("_pagingGetJoinedCommunityList",this._name+"._pagingGetJoinedCommunityList response size exceeds the limit, request count:"+a),this._pagingGetJoinedCommunityList({limit:50,offset:c,groupList:u});throw e}})}_groupListTreeShaking(r){var o=new Map([...be.getLocalGroupList()]);for(let e=0,t=r.length;e<t;e++)o.delete(r[e].groupID);var i=[...o.keys()];for(let e=0,t=i.length;e<t;e++)be.deleteLocalGroup(i[e])}_isSyncCompleted(){return this._pagingStatus===f}_convertGroupKey(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppDefinedData:i,ApplyJoinOption:n,CreateTime:s,FaceUrl:u,GroupId:a,Introduction:p,InviteJoinOption:c,LastInfoTime:l,LastMsgTime:m,MemberNum:h,MaxMemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:v,Notification:f,Owner_Account:b,Type:G,LastRecallTime:C,SelfInfo:I,AtInfoList:y=[],SupportTopic:A}=r[e],i=he(i),I=this._convertSelfInfo(I),y=this._convertAtInfoList(a,y);o.push({groupCustomField:i,joinOption:n,createTime:s,avatar:u,groupID:a,introduction:p,inviteOption:c,lastInfoTime:l,lastMsgTime:m,memberCount:h,maxMemberCount:d,muteAllMembers:g,name:_,nextMessageSeq:v,notification:f,ownerID:b,type:G,selfInfo:I,_lastRevokedTime:C,_groupAtInfoList:y,isSupportTopic:A})}return o}_convertSelfInfo(e){var{JoinTime:e,MsgFlag:t,MsgSeq:r,NoUnreadSeqList:o,Role:i}=e;return{joinTime:e,messageRemindType:t,readedSequence:r,excludedUnreadSequenceList:o,role:i}}_convertAtInfoList(o,e){if(0===e.length)return[];let i=[];return e.forEach(e=>{var{AtFlagList:e,AtMsgSeq:t,From_Account:r}=e;i.push({groupID:o,groupAtType:e,sequence:t,from:r})}),i}},Me=new class{constructor(){this._name="CreateGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"createGroup",context:this})}createGroup(a){return Ce(this,void 0,void 0,function*(){var s;this._preCheckParams(a);let e=this._core["helper"]["ChatError"];try{let{utils:{isEmpty:e},common:{getCurrentUserID:t}}=this._core,r=yield function(h,d){return Ce(this,void 0,void 0,function*(){var{name:e,type:t,groupID:r,introduction:o,notification:i,avatar:n,maxMemberNum:s,joinOption:u,inviteOption:a,memberList:p,groupCustomField:c,isSupportTopic:l}=h;let m;e={Name:e,Type:t,GroupId:r,Introduction:o,Notification:i,FaceUrl:n,MaxMemberCount:s,ApplyJoinOption:u,InviteJoinOption:a,MemberList:m=p?p.map(e=>{var{userID:e,memberCustomField:t}=e;return{Member_Account:e,AppMemberDefinedData:t?de(t):void 0}}):m,AppDefinedData:c,SupportTopic:l,webPushFlag:1};return d.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:e})})}(Object.assign(Object.assign({},a),{ownerID:t()}),this._core),{GroupId:o,OverJoinedGroupLimit_Account:i=[]}=r||{},n=`${this._name}.createGroup ok, type:${a.type} groupID:${o} overLimitUserIDList:`+i;e(a.memberList)||e(i)||(a.memberList=null==(s=a.memberList)?void 0:s.filter(e=>i.includes(e.userID))),be.updateLocalGroup([Object.assign(Object.assign({},a),{groupID:o})]);var u=be.getLocalGroup(o);return this._notNeedSendCustomMessage(a)||(this._sendCustomMessage(o,a.type),be.emitGroupListUpdate()),ye({group:u},{message:n})}catch(s){var{errorCode:u,errorInfo:t}=s;throw new e({functionName:"createGroup",code:u,message:t,moreMessage:" groupID:"+a.groupID})}})}_preCheckParams(t){var{type:r,groupID:o}=t,{utils:{isEmpty:i,isUndefined:n},common:{isCommunity:s}}=this._core,i=!i(o);if(!(()=>{var{GRP_PUBLIC:t,GRP_WORK:r,GRP_MEETING:o,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,r,o,i,n]})().includes(r))throw new this._core.helper.ChatError({code:Y});if(!s({type:r})){if(i&&s({groupID:o}))throw new this._core.helper.ChatError({code:Q});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(r)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(r)||n(t.joinOption)||(t.joinOption=void 0),s({type:r})){if(i&&!s({groupID:o}))throw new this._core.helper.ChatError({code:Q});t.isSupportTopic=this._canIUseTopic(t)?1:0}}_canIUseMemberList(e){return!le(e)}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){e=e.isSupportTopic;return!0===e}_notNeedSendCustomMessage(e){var{type:e,isSupportTopic:t}=e,{GRP_AVCHATROOM:r,GRP_COMMUNITY:o}=this._core["OuterConstant"];return e===r||e===o&&1===t}_sendCustomMessage(e,t){var r=this._core["OuterConstant"];let o="Create Group",i=d;t===r.GRP_COMMUNITY&&(o="Create Community",i=g);var t={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:o,cmd:i,opUser:this._core.store.get("login").userId,version:4})}},e=null==(r=null==(e=null==(r=this._core)?void 0:r.message)?void 0:e.messageFactory)?void 0:r.createCustomMessage(t);null!=(r=null==(t=null==(r=this._core)?void 0:r.message)?void 0:t.messageSender)&&r.sendMessage(e,{})}},Le=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){var{helper:e,constants:t}=this._core=e;e.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdated(e){var e=e["elements"]["newGroupProfile"],{isEmpty:t,isUndefined:r}=this._core["utils"];return!r(e)&&!t(e.groupAttributeOption)}handleGroupAttributesUpdated(e){var{groupID:e,groupAttributeOption:t}=e,{serverMainSequence:t,groupAttributeList:r=[],operation:o}=t,i=(this._core.ssoLog.debug("handleGroupAttributesUpdated",this._name+`.handleGroupAttributesUpdated groupID:${e} operation:`+o),this._core)["utils"]["isUndefined"];i(o)||(this.refreshGroupAttributesCache({groupID:e,serverMainSequence:t,groupAttributeList:r,operation:o}),this.emitGroupAttributesUpdated(e))}initGroupAttributesCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupAttributesCache.set(e,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:t,values:new Map}),this._core.ssoLog.debug("initGroupAttributesCache",this._name+`.initGroupAttributesCache. groupID:${e} avChatRoomKey:`+t)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){var{groupID:r,serverMainSequence:o,groupAttributeList:i,operation:n}=e;if(this.hasGroupAttributesCache(r)){let e=this.getGroupAttributesCache(r),t=e["localMainSequence"];n!==E&&o-t!=1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:i,operation:n})),1<o-t&&(e.serverMainSequence=o),this._groupAttributesCache.set(r,e),this._core.ssoLog.debug("refreshGroupAttributesCache",this._name+`.refreshGroupAttributesCache. operation:${n} localMainSequence:${t} serverMainSequence:`+o)}}_updateGroupAttributesCacheValues(e){let{groupAttributes:o,groupAttributeList:t=[],operation:r}=e;r!==T?r!==w?(r===S&&o.values.clear(),t.forEach(e=>{var{key:e,value:t,sequence:r}=e;o.values.set(e,{value:t,sequence:r})})):t.forEach(e=>{o.values.delete(e.key)}):o.values.clear()}getGroupAttributesCacheValues(e){let r,{groupID:o,keyList:i=[]}=e,n={};if(this.hasGroupAttributesCache(o)){let t=this.getGroupAttributesCache(o)["values"];if(0===i.length)for(let e of t.keys())n[e]=(null==(r=t.get(e))?void 0:r.value)||"";else i.forEach(e=>{t.has(e)&&(n[e]=(null==(e=t.get(e))?void 0:e.value)||"")})}return n}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t,r=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:o,deletedKeyList:i}=this._computeValuesChangedData(r);this._core.ssoLog.debug("emitGroupAttributesUpdated",`${this._name}.emitGroupAttributesUpdated update count:${o.length}, delete count:`+i.length),0===o.length&&0===i.length||this._emitEvent({name:null==(t=this._core)?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:r,updatedKeyList:o,deletedKeyList:i}})}_computeValuesChangedData(t){let{isUndefined:r}=this._core["utils"],o=[],i=[];return Object.keys(t).forEach(e=>{t[e]!==this._groupAttributesCacheValuesCopy[e]&&o.push(e)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(e=>{r(t[e])&&i.push(e)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:i}}_emitEvent(e){var t;null!=(t=this._core)&&t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(t){let r=[];return Object.keys(t).forEach(e=>{r.push({key:e,value:t[e]})}),r}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}},De=new class{constructor(){this._name="DismissGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}dismissGroup(i){return Ce(this,void 0,void 0,function*(){let{ChatError:t}=this._core["helper"];try{yield function(e,t){return Ce(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:{GroupId:e}})})}(i,this._core);let e=be.getLocalGroup(i)["type"];return be.deleteLocalGroup(i),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(i),ye({groupID:i,type:e},{message:i})}catch(e){var{errorCode:r,errorInfo:o}=e;throw new t({functionName:"dismissGroup",code:r,message:o})}})}},Se=new class{constructor(){this._name="GetGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(t){return Ce(this,void 0,void 0,function*(){let{groupID:i,groupCustomFieldFilter:e}=t,n={groupIDList:[i],responseFilter:{GroupBaseInfoFilter:[...p],AppDefinedDataFilter_Group:e,MemberInfoFilter:[...h]}},{ChatError:o}=this._core["helper"];try{let e=yield this.getGroupProfileAdvance(n),{successGroupList:t,failureGroupList:r}=e;if(0<r.length)throw r[0];let o;return(o=!be.hasLocalGroup(i)&&le(t[0].type)?new Ge(t[0]):(be.updateLocalGroup(t),be.getLocalGroup(i))).isSupportTopic||be.updateConversationGroupProfile(i),ye({group:o},{message:"groupID:"+i})}catch(e){let{code:t,message:r}=e;throw new o({functionName:"getGroupProfile",code:t,message:r})}})}getGroupProfileAdvance(u){return Ce(this,void 0,void 0,function*(){let e=u["groupIDList"],{isCommunity:t}=this._core["common"],r=e.filter(e=>!t({groupID:e})),o=e.filter(e=>t({groupID:e})),i=(50<r.length&&(r.length=50),50<o.length&&(o.length=50),yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},u),{groupIDList:r})),this._getGroupProfileAdvance(Object.assign(Object.assign({},u),{groupIDList:o,isCommunityProfile:!0}))])),n=[],s=[];return i.forEach(e=>{n.push(...e.successGroupList),s.push(...e.failureGroupList)}),{successGroupList:n,failureGroupList:s}})}_getGroupProfileAdvance(e){return Ce(this,void 0,void 0,function*(){let{ssoLog:n,utils:{isUndefined:s}}=this._core,{isCommunityProfile:t=!1}=e,u=Ie(e,["isCommunityProfile"]);if(0===u.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{let e=yield function(r,o){return Ce(this,void 0,void 0,function*(){var{groupIDList:e,responseFilter:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:{GroupIdList:e,ResponseFilter:t}})})}(u,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),o=r.filter(e=>s(e.errorCode)||0===e.errorCode),i=r.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return n.debug("_getGroupProfileAdvance",this._name+"._getGroupProfileAdvance ok, groupID:"+u.groupIDList.join(",")),{successGroupList:o,failureGroupList:i}}catch(e){if(t)return{successGroupList:[],failureGroupList:[]};throw e}})}_convertGroupProfileKey(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppDefinedData:i,ApplyJoinOption:n,CreateTime:s,FaceUrl:u,GroupId:a,InfoSeq:p,Introduction:c,InviteJoinOption:l,LastInfoTime:m,LastMsgTime:h,MaxMemberNum:d,MemberNum:g,MuteAllMember:_,Name:v,NextMsgSeq:f,Notification:b,Owner_Account:G,ShutUpAllMember:C,ShutUpUntil:I,Type:y,MemberList:A,ErrorCode:L,ErrorInfo:M}=r[e],i=he(i),A=this._convertMembers(A);o.push({groupCustomField:i,joinOption:n,createTime:s,avatar:u,groupID:a,infoSequence:p,introduction:c,inviteOption:l,lastInfoTime:m,lastMsgTime:h,maxMemberCount:d,memberCount:g,muteAllMembers:_,name:v,nextMessageSeq:f,notification:b,ownerID:G,shutUpAllMember:C,muteUntil:I,type:y,members:A,errorCode:L,errorInfo:M})}return o}_convertMembers(r){if(!r)return[];var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,MsgFlag:u,MsgSeq:a,NameCard:p,Role:c}=r[e],i=he(i);o.push({memberCustomField:i,joinTime:n,userID:s,messageRemindType:u,sequence:a,nameCard:p,role:c})}return o}},Oe=new class{constructor(){this._groupCountersMap=new Map}init(e){this._core=e}getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}updateLocalGroupCounters(e){var{groupID:o,counterList:i=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(o)){let{counters:r,avChatRoomKey:e,groupCounterSeq:t}=this.getLocalGroupCounters(o);0<n&&n<t||(i.forEach(e=>{var{Key:e,Value:t=0}=e;r.set(e,t)}),this._groupCountersMap.set(o,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:r,avChatRoomKey:e}))}}initGroupCountersCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupCountersMap.set(e,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:t})}getLocalCounters(e,r){let o={};if(this._hasLocalGroupCounters(e)){let t=this.getLocalGroupCounters(e)["counters"];if(0<r.length)r.forEach(e=>{t.has(e)&&(o[e]=t.get(e))});else for(let e of t.keys())o[e]=t.get(e)}return o}deleteLocalGroupCounters(e){var{groupID:r,counterList:o=[],groupCounterSeq:i}=e;if(this._hasLocalGroupCounters(r)){let{counters:t,avChatRoomKey:e}=this.getLocalGroupCounters(r);o.forEach(e=>{t.delete(e.key)}),this._groupCountersMap.set(r,{lastUpdateTime:Date.now(),groupCounterSeq:i,counters:t,avChatRoomKey:e})}}setGroupCounters(t,i){if(this._hasLocalGroupCounters(t)){let e=this.getLocalGroupCounters(t),r=e["counters"],o=!1;Object.entries(i).forEach(([e,t])=>{r.has(e)&&r.get(e)!==t&&(r.set(e,t),o=!0)}),o&&this._groupCountersMap.set(t,Object.assign(Object.assign({},e),{lastUpdateTime:Date.now(),counters:r}))}}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}reset(){this._groupCountersMap.clear()}},Te=new class{constructor(){this._name="JoinGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"joinGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}joinGroup(r){return Ce(this,void 0,void 0,function*(){let o=r["groupID"],{helper:{ChatError:i},OuterConstant:e,ssoLog:t}=this._core;try{if(be.hasLocalGroup(o))try{return yield Se.getGroupProfile({groupID:o}),ye({status:e.JOIN_STATUS_ALREADY_IN_GROUP,group:be.getLocalGroup(o)},{message:`groupID:${o} joinedStatus:`+e.JOIN_STATUS_ALREADY_IN_GROUP})}catch(i){t.warn("joinGroup",this._name+`.joinGroup ${o} was unjoined, start to join!`),be.deleteLocalGroup(o)}return yield this._applyJoinGroup(r)}catch(e){let{errorCode:t,errorInfo:r}=e;throw new i({functionName:"joinGroup",code:t,message:r,moreMessage:"groupID:"+o})}})}_applyJoinGroup(h){return Ce(this,void 0,void 0,function*(){var{OuterConstant:e,helper:t,ssoLog:r}=this._core,i=h["groupID"],n=Object.assign({},h),t=t.checkBusinessCapabilityBits(o),n=(t&&(n.historyMessageFlag=1),yield function(o,i){return Ce(this,void 0,void 0,function*(){var{groupID:e,applyMessage:t,historyMessageFlag:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:{GroupId:e,ApplyMsg:t,HugeGroupHistoryMsgFlag:r}})})}(n,this._core)),{Type:n,JoinedStatus:s,LongPollingKey:u,StartSeq:a,HugeGroupFlag:p,AVChatRoomKey:c,RspMsgList:l=[]}=n||{},t=`groupID:${i} joinedStatus:${s} longPollingKey:${u} startSeq:${a} avChatRoomFlag:${p} canGetAVChatRoomHistoryMsg:${t}, historyMessageCount:`+l.length;r.debug("_applyJoinGroup",this._name+"._applyJoinGroup ok, "+t);let m=new Ge({groupID:i,type:n});if(s===e.JOIN_STATUS_WAIT_APPROVAL)return ye({status:e.JOIN_STATUS_WAIT_APPROVAL,group:m});if(s!==e.JOIN_STATUS_SUCCESS)throw new this._core.helper.ChatError({code:te});try{m=(yield Se.getGroupProfile({groupID:i})).data.group}catch(e){r.warn("_applyJoinGroup",this._name+`._applyJoinGroup getGroupProfile failed, groupID: ${i}, errorCode:`+(null==e?void 0:e.code))}return this._handleJoinResult({group:m,avChatRoomFlag:p,longPollingKey:u,startSequence:a,avChatRoomKey:c,historyMessageList:l})})}_handleJoinResult(e){var{group:t,avChatRoomFlag:r,avChatRoomKey:o}=e;return 1===r?(Le.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:o}),Oe.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:o}),ye(e)):(be.updateLocalGroup([t]),be.emitGroupListUpdate(),ye({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t},{message:"groupID:"+t.groupID}))}},we=new class{constructor(){this._name="QuitGroup"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"quitGroup",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}quitGroup(i){return Ce(this,void 0,void 0,function*(){if(!be.hasLocalGroup(i))throw new this._core.helper.ChatError({code:ee});let{ChatError:t}=this._core["helper"];try{yield function(e,t){return Ce(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:{GroupId:e}})})}(i,this._core);let e=be.getLocalGroup(i)["type"];return be.deleteLocalGroup(i),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(i),ye({groupID:i,type:e},{message:"groupID:"+i})}catch(e){var{errorCode:r,errorInfo:o}=e;throw new t({functionName:"quitGroup",code:r,message:o,moreMessage:"groupID:"+i})}})}},Ee=new class{constructor(){this._name="SearchGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(f){return Ce(this,void 0,void 0,function*(){try{var t=yield function(t,r){return Ce(this,void 0,void 0,function*(){var e={GroupIdList:[t],GroupBasePublicInfoFilter:[...l]};return r.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:e})})}(f,this._core),{GroupInfo:r=[]}=t||{},{AppDefinedData:e=[],ApplyJoinOption:o,CreateTime:i,FaceUrl:n,Introduction:s,InviteJoinOption:u,MaxMemberNum:a,MemberNum:p,Name:c,Owner_Account:m,Type:h,ErrorCode:d,ErrorInfo:g}=r[0];if(0!==d)throw new this._core.helper.ChatError({code:d,message:g});var _=he(e),v=new Ge({groupID:f,name:c,avatar:n,introduction:s,joinOption:o,inviteOption:u,maxMemberCount:a,memberCount:p,type:h,ownerID:m,createTime:i,groupCustomField:_});return ye({group:v})}catch(e){var{errorCode:t,errorInfo:r}=e;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:t,message:r})}})}},Ne=new class{constructor(){this._name="UpdateGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(s){return Ce(this,void 0,void 0,function*(){let o=s["groupID"],{utils:{isUndefined:t},ssoLog:r,helper:i}=this._core,n=be.getLocalGroup(o);if(n){let e=n["type"];this._canIUseJoinOption(e)||t(s.joinOption)||(r.warn("updateGroupProfile",this._name+`.updateGroupProfile groupID:${o} joinOption is unavailable for Work/Meeting/AVChatRoom`),s.joinOption=void 0)}t(s.muteAllMembers)||(s.muteAllMembers=!0===s.muteAllMembers?"On":"Off");try{return yield function(p,c){return Ce(this,void 0,void 0,function*(){var{groupID:e,name:t,avatar:r,introduction:o,notification:i,muteAllMembers:n,joinOption:s,inviteOption:u,groupCustomField:a}=p,e={GroupId:e,Name:t,FaceUrl:r,Introduction:o,Notification:i,ShutUpAllMember:n,ApplyJoinOption:s,InviteJoinOption:u,AppDefinedData:a?de(a):void 0};return c.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:e})})}(s,this._core),n?(n.updateGroup(s),be.emitGroupListUpdate()):n=new Ge(s),ye({group:n},{message:"groupID:"+o})}catch(e){let{errorCode:t,errorInfo:r}=e;throw new i.ChatError({code:t,message:r,moreMessage:"groupID:"+o})}})}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}},Pe=new class{constructor(){this._name="ChangeGroupOwner"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(s){return Ce(this,void 0,void 0,function*(){var t="changeGroupOwner",{groupID:e,newOwnerID:r}=s,e=be.getLocalGroup(e),{helper:o,OuterConstant:i,common:{getCurrentUserID:n}}=this._core;if((null==e?void 0:e.type)===i.GRP_AVCHATROOM)throw new o.ChatError({functionName:t,code:X});if(r===n())throw new o.ChatError({functionName:t,code:Z});try{return yield function(r,o){return Ce(this,void 0,void 0,function*(){var{groupID:e,newOwnerID:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:{GroupId:e,NewOwner_Account:t}})})}(s,this._core),e.ownerID=r,be.emitGroupListUpdate(),ye({group:e})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},Re=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}getGroupOnlineMemberCount(n){return Ce(this,void 0,void 0,function*(){let r="getGroupOnlineMemberCount";if(!be.hasLocalGroup(n))return ye({memberCount:0});let o=Date.now();if(this._onlineMemberCountMap.has(n)){let e=this._onlineMemberCountMap.get(n),{lastReqTime:t=0,memberCount:r=0}=e||{};if(o-t<=6e4)return ye({memberCount:r})}try{let e=yield function(e,t){return Ce(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:{GroupId:e}})})}(n,this._core),{OnlineMemberNum:t=0}=e||{};this._onlineMemberCountMap.set(n,{lastReqTime:Date.now(),memberCount:t});var i=`${this._name}.${r} ok. groupID:${n} memberCount:`+t;return ye({memberCount:t},{message:i})}catch(e){throw new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},Ue=new class{init(e,t){e.ssoLog.debug("GroupAction.init"),Ae.init(e),Me.init(e),De.init(e,t),Te.init(e,t),we.init(e,t),Ee.init(e),Se.init(e),Ne.init(e),Pe.init(e),Re.init(e,t)}dismissGroup(e){return De.dismissGroup(e)}joinGroup(e){return Te.joinGroup(e)}quitGroup(e){return we.quitGroup(e)}getGroupOnlineMemberCount(e){return Re.getGroupOnlineMemberCount(e)}},ke=new class{constructor(){this._name="GetGroupApplicationList"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return Ce(this,void 0,void 0,function*(){var t="getGroupApplicationList";try{var e=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]),r=(this._core.ssoLog.debug("getGroupApplicationList",this._name+`.${t} ok.`),this._handleGroupApplicationResult([...e[0],...e[1]]));return ye({applicationList:r})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_getGroupApplicationList(n){return Ce(this,void 0,void 0,function*(){var{type:e,startTime:t=0,limit:r=20}=n||{},o=this._core["common"];let i;try{i=yield function(i,n){return Ce(this,void 0,void 0,function*(){var{type:e,startTime:t,limit:r,handleAccount:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:{Type:e,StartTime:t,Limit:r,Handle_Account:o}})})}({type:e,startTime:t,limit:r,handleAccount:o.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;i={}}var{NextStartTime:e=0,PendencyList:t=[]}=i||{};return 0===e?t:(r=yield this._getGroupApplicationList(Object.assign(Object.assign({},n),{startTime:e})),[...t,...r])})}_handleGroupApplicationResult(e){let r=[];return e.forEach(e=>{var e=this._convertApplicationData(e),t=e["handled"],e=Ie(e,["handled"]);0===t&&r.push(e)}),r}_convertApplicationData(e){var{Handled:e,AddTime:t,ApplyInviteMsg:r,Authentication:o,FromUserNickName:i,From_Account:n,GroupId:s,GroupName:u,PendencyType:a,To_Account:p}=e;return{handled:e,messageKey:t,applicant:n,applicantNick:i,groupID:s,groupName:u,authentication:o,applicationType:a,userID:p,note:r}}},$e=new class{constructor(){this._name="HandleGroupApplication"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return Ce(this,void 0,void 0,function*(){var t=e["application"],r=this._handleParams(e);try{(null==t?void 0:t.applicationType)===C?yield function(s,u){return Ce(this,void 0,void 0,function*(){var{groupID:e,handleAction:t,handleMessage:r,applicant:o,authentication:i,invitee:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:{GroupId:e,HandleMsg:t,ApprovalMsg:r,Applicant_Account:o,Authentication:i,Invited_Account:n}})})}(r,this._core):yield function(s,u){return Ce(this,void 0,void 0,function*(){var{groupID:e,handleAction:t,handleMessage:r,applicant:o,authentication:i,messageKey:n}=s;return u.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:{GroupId:e,HandleMsg:t,ApprovalMsg:r,Applicant_Account:o,Authentication:i,MsgKey:n}})})}(r,this._core);let e=be.getLocalGroup(r.groupID);return ye({group:e})}catch(e){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_handleParams(e){var{handleAction:e,handleMessage:t,message:r,application:o}=e;let i,n,s,u,a;if(r){let e=(r||{})["payload"];i=e.operatorID,n=null==(r=e.groupProfile)?void 0:r.groupID,s=e.authentication,u=e.messageKey}else i=(null==o?void 0:o.applicant)||"",n=(null==o?void 0:o.groupID)||"",s=(null==o?void 0:o.authentication)||"",u=(null==o?void 0:o.messageKey)||0;return(null==o?void 0:o.applicationType)===C&&(a=o.userID),{handleAction:e,handleMessage:t,applicant:i,invitee:a,groupID:n,authentication:s,messageKey:u}}},Fe=new class{init(e){e.ssoLog.debug("GroupApplication.init"),ke.init(e),$e.init(e)}};let qe=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(t){var{utils:{isUndefined:r},common:{deepMerge:o}}=e["core"],r=(r(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),r(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus),[null,void 0,"",0,NaN]);t.memberCustomField&&me(this.memberCustomField,t.memberCustomField),o(this,t,["memberCustomField","marks","onlineStatus","muteTime"],r)}};function je(u,a){return Ce(this,void 0,void 0,function*(){var{groupID:e,userID:t,muteTime:r,role:o,nameCard:i,memberCustomField:n}=u;let s;e={GroupId:e,Member_Account:t,ShutUpTime:r,Role:o,NameCard:i,AppMemberDefinedData:s=n?de(n):s};return a.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:e})})}var Ke=new class{constructor(){this._name="GetGroupMemberList"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}getGroupMemberList(o){return Ce(this,void 0,void 0,function*(){let p="getGroupMemberList",{groupID:c,offset:l=0,count:e=100,role:t="",filter:r=""}=o,m=be.getLocalGroup(c),h=100<e?100:e,d={groupID:c,offset:l,limit:h,memberRoleFilter:v.includes(t)?[t]:void 0,memberInfoFilter:y};try{let e=yield function(n,s){return Ce(this,void 0,void 0,function*(){var{groupID:e,offset:t,limit:r,memberRoleFilter:o,memberInfoFilter:i}=n;return s.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:{GroupId:e,Offset:t,Limit:r,MemberRoleFilter:o,MemberInfoFilter:i}})})}(d,this._core),{MemberList:t,MemberNum:r,Next:o}=e||{},i=`${this._name}.${p} ok, totalMemberCount:${r} next:`+o,{utils:{isArray:n,isEmpty:s},common:{isCommunity:u}}=this._core;if(m&&(m.memberCount=r),!n(t)||0===t.length)return ye({memberList:[],offset:0},{message:i});let a=l+h;u({groupID:c})&&(a=s(o)?0:o),t.length<h&&(a=0);var g=this._convertMemberInfo(t),g=yield this._patchAvatarAndNick(g),_=this._generateGroupMember(g);return ye({memberList:_,offset:a},{message:i})}catch(e){throw new this._core.helper.ChatError({functionName:p,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_convertMemberInfo(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,OnlineStatus:u,Role:a,ShutUpUntil:p,NameCard:c}=r[e],i=he(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i,nameCard:c})}return o}_patchAvatarAndNick(n){return Ce(this,void 0,void 0,function*(){let e,t=n.map(e=>e.userID),r=yield null==(e=this._core.user.userProfile)?void 0:e.getUserProfile({userIDList:t}),o=(null==r?void 0:r.data)||[],i=new Map(o.map(e=>[e.userID,e]));return n.forEach(e=>{var t,r;i.has(e.userID)&&({nick:t="",avatar:r=""}=i.get(e.userID),e.nick=t,e.avatar=r)}),n})}_generateGroupMember(r){var o=[];for(let e=0,t=r.length;e<t;e++){var i=new qe(r[e]);o.push(i)}return o}},xe=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(c){return Ce(this,void 0,void 0,function*(){let t="getGroupMemberProfile",{groupID:o,userIDList:i,memberCustomFieldFilter:n}=c,e=be.getLocalGroup(o),{helper:r,utils:{isArray:s},ssoLog:u}=this._core;if(e&&le(e.type))throw new r.ChatError({functionName:t,replacement1:t,code:ue});50<i.length&&(u.warn("getGroupMemberProfile",`${this._name}.${t} userIDList length:${i.length} exceeds limit 50`),i.splice(50));var a=`userIDList length:${i.length} groupID:`+o;try{let e=yield function(i,n){return Ce(this,void 0,void 0,function*(){var{groupID:e,userIDList:t,memberInfoFilter:r,memberCustomFieldFilter:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:{GroupId:e,Member_List_Account:t,MemberInfoFilter:r,AppDefinedDataFilter_GroupMember:o}})})}({groupID:o,userIDList:i,memberCustomFieldFilter:n,memberInfoFilter:[...y]},this._core),t=(e||{})["MemberList"];if(!s(t)||0===t.length)return ye({memberList:[]});var p=this._convertMemberInfo(t),p=yield this._getMemberAvatarAndNick(p);let r=this._generateGroupMember(p);return ye({memberList:r},{message:a})}catch(e){throw new r.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:a})}})}_convertMemberInfo(r){var o=[];for(let e=0,t=r.length;e<t;e++){var{AppMemberDefinedData:i,JoinTime:n,Member_Account:s,OnlineStatus:u,Role:a,ShutUpUntil:p,NameCard:c}=r[e],i=he(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i,nameCard:c})}return o}_getMemberAvatarAndNick(n){return Ce(this,void 0,void 0,function*(){let e,t=n.map(e=>e.userID),r=yield null==(e=this._core.user.userProfile)?void 0:e.getUserProfile({userIDList:t}),o=(null==r?void 0:r.data)||[],i=new Map(o.map(e=>[e.userID,e]));return n.forEach(e=>{var t,r;i.has(e.userID)&&({nick:t="",avatar:r=""}=i.get(e.userID),e.nick=t,e.avatar=r)}),n})}_generateGroupMember(r){var o=[];for(let e=0,t=r.length;e<t;e++){var i=new qe(r[e]);o.push(i)}return o}},Ve=new class{constructor(){this._name="AddGroupMember"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(o){return Ce(this,void 0,void 0,function*(){let t="addGroupMember",{groupID:s,userIDList:e}=o,u=be.getLocalGroup(s),r=this._core["helper"];if(u&&le(u.type))throw new r.ChatError({functionName:t,code:oe});var a=e.map(e=>({Member_Account:e}));try{let e=yield function(r,o){return Ce(this,void 0,void 0,function*(){var{groupID:e,userIDList:t}=r;return o.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:{GroupId:e,MemberList:t}})})}({groupID:s,userIDList:a},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}=this._handleResult(t);return ye({failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n,group:u},{message:` groupID:${s} successUserIDList:${o} failureUserIDList:${r} existedUserIDList:${i} overLimitUserIDList:`+n})}catch(e){throw new r.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_handleResult(e){let r=[],o=[],i=[],n=[];return e.forEach(e=>{var{Result:e,Member_Account:t}=e;e===A?r.push(t):e===M?o.push(t):e===L?i.push(t):e===D&&n.push(t)}),{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}}},Je=new class{constructor(){this._name="DeleteGroupMember"}init(e,r){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!r.getInstalledSubPlugins().includes(t)})}deleteGroupMember(u){return Ce(this,void 0,void 0,function*(){var t="deleteGroupMember",{groupID:e,userIDList:r}=u,o=be.getLocalGroup(e),{helper:i,utils:{isUndefined:n},ssoLog:s}=this._core;if(n(o))throw new i.ChatError({functionName:t,code:z});20<r.length&&(s.warn("deleteGroupMember",`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(o,i){return Ce(this,void 0,void 0,function*(){var{groupID:e,userIDList:t,reason:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:{GroupId:e,MemberToDel_Account:t,Reason:r}})})}({groupID:e,userIDList:r},this._core),ye({group:o,userIDList:r},{message:`groupID:${e} userIDList length:`+r.length})}catch(e){throw new i.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},Be=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(s){return Ce(this,void 0,void 0,function*(){let t=this._core["helper"],{groupID:r,userID:o,muteTime:i}=s,n=` groupID:${r} userID:${o} muteTime:`+i;this._preCheckSettingMuteParams(s);try{yield je(s,this._core);let e=be.getLocalGroup(r),t=new qe({userID:o,muteTime:i});return ye({group:e,member:t},{message:n})}catch(e){throw new t.ChatError({functionName:"setGroupMemberMuteTime",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:n})}})}_preCheckSettingMuteParams(e){var e=e["userID"],{store:t,helper:r}=this._core;if(e===t.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:se})}},He=new class{constructor(){this._name="SetGroupMemberRole"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(u){return Ce(this,void 0,void 0,function*(){let t="setGroupMemberRole",r=this._core["helper"],{groupID:o,userID:i,role:n}=u,s=`${this._name}.${t} ok, groupID:${o} userID:${i} role:`+n;this._preCheckSettingRoleParams(u);try{yield je(u,this._core);let e=be.getLocalGroup(o),t=new qe({userID:i,role:n});return ye({group:e,member:t},{message:s})}catch(e){throw new r.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:s})}})}_preCheckSettingRoleParams(e){var{groupID:e,userID:t,role:r}=e,{store:o,helper:i,OuterConstant:n,common:{isCommunity:s}}=this._core,u=be.getLocalGroup(e);if((null==(u=null==u?void 0:u.selfInfo)?void 0:u.role)!==n.GRP_MBR_ROLE_OWNER)throw new i.ChatError({functionName:"setGroupMemberRole",code:re});if(t===o.get("login").userId)throw new i.ChatError({functionName:"setGroupMemberRole",code:ne});u=[...v];if(s({groupID:e})&&u.push(n.GRP_MBR_ROLE_CUSTOM),!u.includes(r))throw new i.ChatError({functionName:"setGroupMemberRole",code:ie})}},We=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(p){return Ce(this,void 0,void 0,function*(){let i="setGroupMemberNameCard",{helper:t,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingNameCardParams(p);try{let{groupID:e,userID:t=n(),nameCard:r}=p,o={groupID:e,userID:t,nameCard:r};yield je(o,this._core);var s=`${this._name}.${i} ok, groupID:${e} userID:${t} nameCard:`+r,u=be.getLocalGroup(e),a=new qe({userID:t,nameCard:r});return ye({group:u,member:a},{message:s})}catch(e){throw new t.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:logText})}})}_preCheckSettingNameCardParams(e){var e=e["groupID"],t=this._core["helper"],e=be.getLocalGroup(e);if(le(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberNameCard",code:ue})}},Ye=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(u){return Ce(this,void 0,void 0,function*(){let t="setGroupMemberCustomField",{helper:r,common:{getCurrentUserID:e}}=this._core;this._preCheckSettingCustomFiledParams(u);var{groupID:o,userID:i=e(),memberCustomField:n}=u,s=`${this._name}.${t} ok, groupID:${o}userID:${i} memberCustomField:`+JSON.stringify(n);try{let e={groupID:o,userID:i,memberCustomField:n},t=(yield je(e,this._core),be.getLocalGroup(o)),r=new qe({userID:i,memberCustomField:n});return ye({group:t,member:r},{message:s})}catch(e){throw new r.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:s})}})}_preCheckSettingCustomFiledParams(e){var e=e["groupID"],t=this._core["helper"],e=be.getLocalGroup(e);if(le(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberCustomField",code:ue})}},Qe=new class{init(e,t){e.ssoLog.debug("GroupMember.init"),Ke.init(e,t),xe.init(e),Ve.init(e),Je.init(e,t),Be.init(e),He.init(e),We.init(e),Ye.init(e)}getGroupMemberList(e){return Ke.getGroupMemberList(e)}deleteGroupMember(e){return Je.deleteGroupMember(e)}},ze=new class{init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(c){return Ce(this,void 0,void 0,function*(){var t="getGroupCounters";try{ge(t,r);var o,i,n,{groupID:s,keyList:u=[]}=c,{avChatRoomKey:a,lastUpdateTime:p}=Oe.getLocalGroupCounters(s);return Date.now()-p>=this._getExpireTime()&&(o=yield function(n){return Ce(this,void 0,void 0,function*(){var{groupID:t,GroupCounterKeys:r,avChatRoomKey:o}=n,i=e.core["common"];return i.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:{GroupId:t,keyList:r,BytesKey:o}})})}({groupID:s,keyList:u,avChatRoomKey:a}),{GroupCounter:i=[],GroupCounterSeq:n}=o,Oe.updateLocalGroupCounters({groupID:s,counterList:i,groupCounterSeq:n})),{code:0,data:{counters:Oe.getLocalCounters(s,u)}}}catch(e){_e(t,e)}})}_getExpireTime(){var{store:e,utils:{isUndefined:t}}=this._core,e=(e.get("cloudConfig")||{})["grp_counter_expire_time"];return t(e)?3e4:Number(e)}},Xe=new class{init(e){e=e.helper;e.registerApi({apiName:"setGroupCounters",context:this}),e.registerApi({apiName:"increaseGroupCounter",context:this}),e.registerApi({apiName:"decreaseGroupCounter",context:this})}setGroupCounters(e){return Ce(this,void 0,void 0,function*(){return this._handleCounterOperation(i,e)})}increaseGroupCounter(e){return Ce(this,void 0,void 0,function*(){return this._handleCounterOperation(n,e)})}decreaseGroupCounter(e){return Ce(this,void 0,void 0,function*(){return this._handleCounterOperation(s,e)})}_handleCounterOperation(p,c){return Ce(this,void 0,void 0,function*(){var t=p+"GroupCounter";try{ge(t,r);var{groupID:e,key:o,value:n=0}=c,s=Oe.getLocalGroupCounters(e)["avChatRoomKey"],u=p===i?this._convertObjectToList(c.counters):[{Key:o,Value:n}],a=yield this._updateGroupCounters({groupID:e,counterList:u,avChatRoomKey:s,mode:p});return Oe.setGroupCounters(e,a),{code:0,data:{counters:a}}}catch(e){_e(t,e)}})}_updateGroupCounters(s){return Ce(this,void 0,void 0,function*(){let t=yield function(){var{groupID:t,counterList:r,mode:o,avChatRoomKey:i}=s,n=e.core["common"];return n.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:{GroupId:t,GroupCounter:r,Mode:o,BytesKey:i}})}(),{GroupCounter:r=[]}=t,o={};return r.forEach(e=>{var{Key:e,Value:t=0}=e;o[e]=t}),o})}_convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}},Ze=new class{init(e){this._core=e,ze.init(e),Xe.init(e)}isGroupCounterUpdated(e){var e=e["elements"]["groupCounterInfo"],t=this._core["utils"]["isEmpty"];return!t(e)}handleGroupCounterUpdated(e){let{to:o,elements:{groupCounterInfo:t}}=e;t.forEach(e=>{var{type:e,groupCounterSeq:t,counterList:r=[]}=e;e!==u&&e!==c||this._processAndNotifyCounterUpdate(o,t,r),e===a&&Oe.deleteLocalGroupCounters({groupID:o,groupCounterSeq:t,counterList:r})})}_processAndNotifyCounterUpdate(r,e,t){let{OuterEvent:o,notificationCenter:i}=this._core;Oe.updateLocalGroupCounters({groupID:r,groupCounterSeq:e,counterList:t}),t.forEach(({Key:e,Value:t=0})=>{i.emitOuterEvent(o.GROUP_COUNTER_UPDATED,{name:o.GROUP_COUNTER_UPDATED,data:{groupID:r,key:e,value:t}})})}reset(){Oe.reset()}},et=new class{constructor(){this._name="InitGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return Ce(this,void 0,void 0,function*(){let{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u}=Le.getGroupAttributesCache(i),a=Le.convertKeyValueMapToList(n);try{let e=yield function(i,n){return Ce(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:i,avChatRoomKey:u,groupAttributeList:a,mainSequence:s},this._core),{AttrMainSeq:t,GroupAttr:r}=e||{},o=r.map(e=>{var{Key:e,seq:t}=e;return{key:e,value:n[e],sequence:t}});return Le.saveGroupAttributesCacheValuesCopy(i),Le.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:o,operation:S}),Le.emitGroupAttributesUpdated(i),ye({groupAttributes:n},{message:` groupID:${i} serverMainSequence:`+t})}catch(e){throw new this._core.helper.ChatError({functionName:"initGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},tt=new class{constructor(){this._name="SetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return Ce(this,void 0,void 0,function*(){let{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u,values:o}=Le.getGroupAttributesCache(i),a=Le.convertKeyValueMapToList(n).map(e=>{var{key:t,value:r}=e;return{key:t,value:r,seq:(null==(t=o.get(e.key))?void 0:t.sequence)||0}});try{let e=yield function(i,n){return Ce(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:i,avChatRoomKey:u,groupAttributeList:a,mainSequence:s},this._core),{AttrMainSeq:t,GroupAttr:r}=e||{},o=r.map(e=>{var{Key:e,seq:t}=e;return{key:e,value:n[e],sequence:t}});return Le.saveGroupAttributesCacheValuesCopy(i),Le.refreshGroupAttributesCache({groupID:i,serverMainSequence:t,groupAttributeList:o,operation:O}),Le.emitGroupAttributesUpdated(i),ye({groupAttributes:n},{message:` groupID:${i} serverMainSequence:`+t})}catch(e){throw new this._core.helper.ChatError({functionName:"setGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},ot=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(a){return Ce(this,void 0,void 0,function*(){var t="deleteGroupAttributes",{groupID:e,keyList:r=[]}=a;try{var{resultList:o,serverMainSequence:i,operation:n,groupAttributeList:s}=(0===r.length?yield this._clearGroupAttributes(e):yield this._deleteGroupAttributes(e,r))||{},u=this._name+`.${t} ok. groupID:${e} operation: `+n;return Le.saveGroupAttributesCacheValuesCopy(e),Le.refreshGroupAttributesCache({groupID:e,serverMainSequence:i,groupAttributeList:s,operation:n}),Le.emitGroupAttributesUpdated(e),ye({keyList:o},{message:u})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_deleteGroupAttributes(s,u){return Ce(this,void 0,void 0,function*(){let{serverMainSequence:e,avChatRoomKey:t,values:r}=Le.getGroupAttributesCache(s),o=[],i=[];u.forEach(e=>{var t;r.has(e)&&({sequence:t=0}=r.get(e)||{},i.push({key:e,seq:t}),o.push(e))});var n=((yield function(i,n){return Ce(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,groupAttributeList:r,avChatRoomKey:o}=i;return n.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:{GroupId:e,AttrMainSeq:t,GroupAttr:r,BytesKey:o,AttrControl:["RaceConflict"]}})})}({groupID:s,avChatRoomKey:t,groupAttributeList:i,mainSequence:e},this._core))||{})["AttrMainSeq"];return{resultList:o,serverMainSequence:n,groupAttributeList:i,operation:w}})}_clearGroupAttributes(o){return Ce(this,void 0,void 0,function*(){var{serverMainSequence:e,avChatRoomKey:t,values:r}=Le.getGroupAttributesCache(o),r=[...r.keys()],t=((yield function(o,i){return Ce(this,void 0,void 0,function*(){var{groupID:e,mainSequence:t,avChatRoomKey:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:{GroupId:e,AttrMainSeq:t,BytesKey:r,AttrControl:["RaceConflict"]}})})}({groupID:o,avChatRoomKey:t,mainSequence:e},this._core))||{})["AttrMainSeq"];return{resultList:r,serverMainSequence:t,operation:T}})}},rt=new class{constructor(){this._name="GetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(a){return Ce(this,void 0,void 0,function*(){let o=a["groupID"],{avChatRoomKey:i,lastUpdateTime:e,localMainSequence:t,serverMainSequence:r}=Le.getGroupAttributesCache(o),{ChatError:n}=this._core["helper"],s=`groupID:${o} localMainSequence:${t} serverMainSequence:${r} keyList:`+a.keyList;if(3e4<=Date.now()-e||t<r)try{let e=yield this.getGroupAttributesFromServer({groupID:o,avChatRoomKey:i}),t=Le.getGroupAttributesCacheValues(a),{serverGroupAttributeList:r=[]}=e||{};return ye({groupAttributes:t},{message:s,moreMessage:"from server, count:"+r.length})}catch(e){throw new n({functionName:"getGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}var u=Le.getGroupAttributesCacheValues(a);return ye({groupAttributes:u},{message:s,moreMessage:"from cache"})})}getGroupAttributesFromServer(i){return Ce(this,void 0,void 0,function*(){var{utils:{isUndefined:e},ssoLog:t}=this._core,{groupID:r,avChatRoomKey:o}=i,{AttrMainSeq:e=0,GroupAttrAry:o}=(yield function(o,i){return Ce(this,void 0,void 0,function*(){var{groupID:e,groupType:t,avChatRoomKey:r}=o;return i.common.buildAndSendPacket({servcmd:"group_open_attr_http_svc.get_group_attr",data:{GroupId:e,GroupType:t,Key:r}})})}({groupID:r,avChatRoomKey:o,groupType:e(o)?P:N},this._core))||{},t=(t.debug("getGroupAttributesFromServer",this._name+`._getGroupAttributesFromServer ok. groupID:${r} serverMainSequence:`+e),o.map(e=>{var{key:e,value:t,seq:r}=e;return{key:e,value:t,sequence:r}}));return Le.refreshGroupAttributesCache({groupID:r,serverMainSequence:e,groupAttributeList:t,operation:E}),{serverGroupAttributeList:o}})}},it=new class{init(e){e.ssoLog.debug("GroupAttribute.init"),et.init(e),tt.init(e),ot.init(e),rt.init(e),Le.init(e)}isGroupAttributesUpdated(e){return Le.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){let{to:t,elements:{newGroupProfile:r}}=e,o=r["groupAttributeOption"],{serverMainSequence:i,withChangedAttributeInfo:n}=o,s=Le.getGroupAttributesCache(t)["localMainSequence"],u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:`+u),0!=u)if(Le.saveGroupAttributesCacheValuesCopy(t),1!==n||1!=u){if(Le.hasGroupAttributesCache(t)){let e=Le.getGroupAttributesCache(t)["avChatRoomKey"];rt.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{Le.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else Le.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:o})}reset(){Le.reset()}};function nt(e,t="tips"){let{ClientSeq:r,From_Account:o,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:p,ToGroupId:c,GroupInfo:l,MsgBody:m}=e,h=function(){var{GroupCode:e,GroupId:t,GroupName:r,GroupType:o,MsgFrom_AccountExtraInfo:i,From_Account:n,To_Account:s}=l;return{groupCode:e,groupID:t,groupName:r,type:o,messageFromAccountExtraInformation:i,from:n,to:s}}();return{clientSequence:r,from:o,clientTime:i,priority:n,random:s,sequence:u,time:a,tinyID:p,to:c,groupProfile:h,elements:("tips"===t?st:at)(m)}}function st(o){let e={};return Object.keys(o).forEach(r=>{switch(r){case"MemberNum":e.memberCount=o[r];break;case"OpType":e.operationType=o[r];break;case"Operator_Account":e.operatorID=o[r];break;case"List_Account":e.userIDList=o[r];break;case"MsgMemberExtraInfo":e.memberInfoList=o[r].map(e=>ut(e));break;case"MsgOperatorMemberExtraInfo":e.operatorInfo=ut(o[r]);break;case"MsgGroupNewInfo":e.newGroupProfile=function(s){let e={};return Object.keys(s).forEach(n=>{switch(n){case"GroupIntroduction":e.introduction=s[n];break;case"GroupName":e.groupName=s[n];break;case"GroupFaceUrl":e.avatar=s[n];break;case"GroupNotification":e.notification=s[n];break;case"ApplyJoinOption":e.joinOption=s[n];break;case"InviteJoinOption":e.inviteOption=s[n];break;case"ShutupAll":e.muteAllMembers=s[n];break;case"Owner_Account":e.ownerID=s[n];break;case"GroupAttrOption":e.groupAttributeOption=function(){var{BytesChangedKeys:e,GroupAttrSeq:t,OpType:r,PushChangedAttrValFlag:o,GroupAttrInfo:i}=s[n];return{changedKeyList:e,groupAttributeList:i.map(e=>{var{Key:e,Val:t,SubKeySeq:r}=e;return{key:e,value:t,sequence:r}}),serverMainSequence:t,operation:r,withChangedAttributeInfo:o}}()}}),e}(o[r]);break;case"MsgMemberInfo":e.msgMemberInfo=o[r].map(e=>{var{ShutupTime:e,User_Account:t}=e;return{muteTime:e,userID:t}});break;case"OnlineMemberInfo":e.onlineMemberInfo=function(){var{ExpireTime:e,OnlineMemberNum:t}=o[r];return{expireTime:e,onlineMemberNum:t}}();break;case"GroupCounterInfo":e.groupCounterInfo=o[r].map(e=>{var{GroupCounterSeq:e,GroupCounter:t,Type:r}=e;return{type:r,groupCounterSeq:e,counterList:t}})}}),e}function ut(e){var{ImageUrl:e,NickName:t,Role:r,UserId:o}=e;return{avatar:e,nick:t,role:r,userID:o}}function at(t){let r={};return Object.keys(t).forEach(e=>{switch(e){case"MsgKey":r.messageKey=t[e];break;case"Operator_Account":r.operatorID=t[e];break;case"ReportType":r.operationType=t[e];break;case"Authentication":r.authentication=t[e];break;case"MsgFlag":r.messageRemindType=t[e];break;case"UserDefinedField":r.userDefinedField=t[e];break;case"RemarkInfo":r.remarkInfo=t[e];break;case"BanDuration":r.duration=t[e];break;case"MuteTime":r.muteTime=t[e]}}),r}class ct{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){e=st(e);return new ct(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"groupProfile":this._initGroupProfile(t[e]);break;case"operatorInfo":this._initOperatorInfo(t[e]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"newGroupProfile":this._initNewGroupProfile(t[e]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){this.content.groupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];F[o]&&(this.content.groupProfile[o]=t[o])}}_initOperatorInfo(t){this.content.operatorInfo={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];this.content.operatorInfo[o]=t[o]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})}):this.content.memberList=e}_initNewGroupProfile(t){this.content.newGroupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];"muteAllMembers"!==o?this.content.newGroupProfile[o]=t[o]:this.content.newGroupProfile.muteAllMembers=1===t.muteAllMembers}}}var pt=new class{constructor(){this._name="GroupTipsNotification"}init(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:r,WORKFLOW_STEP:o}}=this._core=e,{message:{messageFactory:e},OuterConstant:i}=e;null!=e&&e.registerElementClass(i.MSG_GRP_TIP,ct),t.registerWorkflowStep(r.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.GROUP_TIPS_RECOVER,this._handleGroupTipsRecover,this),t.registerWorkflowStep(r.RECEIVE_GROUP_TIPS_NOTIFICATION,o.HANDLE_GROUP_TIPS_NOTIFICATION,this.onNewGroupTips,this)}onNewGroupTips(e){let t=(e||{})["data"],{messageList:r,conversationUpdateFieldList:o}=this._handleGroupTips(t),{notificationCenter:i,OuterEvent:n,appStore:{conversationStore:s}}=this._core;return null!=o&&o.forEach(e=>{var{conversationID:e,lastMessage:t,unreadCount:r}=e,{unreadCount:o=0}=s.getConversation(e)||{};s.updateConversation(e,{lastMessage:t,unreadCount:r+o})}),0<r.length&&(i.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:r}),this._handleGroupTipMessage(r)),{conversationUpdateFieldList:o}}_handleGroupTips(e,r=!0){let{Event:o,GroupTips:i}=e,n=new Map,t=[],s=[];for(let t=0,e=i.length;t<e;t++){let e=nt(i[t],"tips");if(o===U){if(it.isGroupAttributesUpdated(e)){it.handleGroupAttributesUpdated(e);continue}if(Ze.isGroupCounterUpdated(e)){Ze.handleGroupCounterUpdated(e);continue}}var u=e["groupProfile"]["groupID"];if(be.hasLocalGroup(u)){u=this._assembleMessage(e);if(o===U&&(u._onlineOnlyFlag=!0,s.push(u)),o===R){if(!this._core.message.messageDataHandler.storeConversationMessage(u)&&r)continue;s.push(u)}this._handleConversationOptions(n,u)}}return t.push(...n.values()),{conversationUpdateFieldList:t,messageList:s}}_assembleMessage(e){var{OuterConstant:t,message:{messageFactory:r}}=this._core,t=(e.flow="in",e.conversationType=t.CONV_GROUP,r.createMessage(e)),r=(this._patchNickAndAvatar(e.elements,t),new ct(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)})));return t.setElement(r),t.isSystemMessage=!1,t}_patchNickAndAvatar(e,r){let{utils:{isEmpty:t},OuterConstant:{GROUP_TIPS_OPERATION_TYPE:o}}=this._core,{operationType:i,memberInfoList:n,operatorInfo:s}=e,u={};if(t(n)?t(s)||(u=s):i!==o.JOINED&&i!==o.KICKED&&i!==o.ADMIN_SET&&i!==o.ADMIN_CANCELED||(u=Object.assign({},n[0])),!t(u)){let{nick:e="",avatar:t=""}=u;r.nick=e,r.avatar=t}}_handleConversationOptions(e,t){var{common:{getMessagePreviewText:r},utils:{isObject:o}}=this._core,{conversationID:i,conversationType:n}=t;let s;if(e.has(i))s=e.get(i),"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||s.unreadCount++,s.type=n,s.lastMessage=t._isExcludedFromLastMessage?"":Object.assign({},t);else{let e=0;"in"!==t.flow||t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1),s={conversationID:i,unreadCount:e,type:n,lastMessage:t._isExcludedFromLastMessage?"":Object.assign({},t)}}o(s.lastMessage)&&(s.lastMessage.messageForShow=r(s.lastMessage.type,s.lastMessage.payload)),e.set(i,s)}_handleGroupTipMessage(e){let{GROUP_TIPS_OPERATION_TYPE:r}=this._core["OuterConstant"];e.forEach(e=>{var t=e.payload["operationType"];switch(t){case r.JOINED:this._handleNewMemberJoined(e);break;case r.QUITTED:this._handleMemberQuitted(e);break;case r.KICKED:this._handleMemberKicked(e);break;case r.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(e)}})}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){let t,{newGroupProfile:r,groupProfile:o,operatorInfo:i}=e.payload,n=o.groupID,s=be.getLocalGroup(n);Object.keys(r).forEach(e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(n,r);break;case"groupName":s.name=r[e];break;default:s[e]=r[e]}});var e=this._core["utils"]["isUndefined"];e(i)||(null==(t=null==s?void 0:s.selfInfo)?void 0:t.userID)!==i.userID||Object.keys(i).forEach(e=>{"nameCard"===e&&s.updateSelfInfo({nameCard:i[e]}),"role"===e&&this._updateSelfRole(s,i[e])}),be.emitGroupListUpdate(),be.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){var{common:r,OuterConstant:o}=this._core,e=be.getLocalGroup(e),t=t["ownerID"];r.getCurrentUserID()===t&&e.updateGroup({ownerID:t,selfInfo:{role:o.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){var r=this._core["OuterConstant"];let o=r.GRP_MBR_ROLE_MEMBER;t===k?o=r.GRP_MBR_ROLE_OWNER:t===$&&(o=r.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:o})}_handleGroupMemberCountUpdated(e){var{memberCount:e,groupProfile:{groupID:t}}=e.payload,r=be.getLocalGroup(t),o=this._core["utils"]["isNumber"];r&&o(e)&&r.memberCount!==e&&(r.memberCount=e,be.emitGroupListUpdate(),be.updateConversationGroupProfile(t))}_handleGroupTipsRecover(e){var t=this._core["utils"]["isArray"],e=((null==e?void 0:e.result)||{})["groupTipList"];t(e)&&e.forEach(e=>{e=this._handleGroupTips({Event:e.Event,GroupTips:[e]},!1).messageList;this._handleGroupTipMessage(e)})}};class lt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}static parseServerPushElement(e){e=at(e);return new lt(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this._initGroupProfile(t[e]);break;case"memberInfoList":break;default:this.content[e]=t[e]}})}_initGroupProfile(t){this.content.groupProfile={};var r=Object.keys(t);for(let e=0;e<r.length;e++){var o=r[e];q[o]&&(this.content.groupProfile[o]=t[o])}}}var mt=new class{constructor(){this._name="GroupSystemNotification"}init(e){var{message:{messageFactory:e},OuterConstant:{MSG_GRP_SYS_NOTICE:t}}=this._core=e;null!=e&&e.registerElementClass(t,lt)}onNewGroupSystemNotification(e){var{GroupTips:e=[],isInstantMessage:t=!0}=e,{conversationUpdateFieldList:e,messageList:r}=(this._core.ssoLog.debug("onNewGroupSystemNotification",` count:${e.length} isInstantMessage:`+t),this._handleGroupSystemNotification(e,t)),{notificationCenter:o,OuterEvent:i}=this._core;0<e.length&&this._handleGroupSysTemMessage(t,r),!0===t&&0<r.length&&o.emitOuterEvent(i.MESSAGE_RECEIVED,{name:i.MESSAGE_RECEIVED,data:r})}_handleGroupSystemNotification(t,r){var o=[];let i={};for(let e=0;e<t.length;e++){var n=nt(t[e],"system"),s=n["elements"]["operationType"];s!==B&&(s=this._assembleMessage(n),this._core.message.messageDataHandler.storeConversationMessage(s))&&(o.push(s),i=this._handleConversationOptions(s,r))}return i.lastMessage=o[o.length-1],{conversationUpdateFieldList:0<o.length?[i]:[],messageList:o}}_assembleMessage(e){var{message:{messageFactory:t},OuterConstant:r,utils:{randomInt:o}}=this._core,r=(e.flow="in",e.conversationType=r.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=r.CONV_SYSTEM,t.createMessage(e)),t=new lt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)})),e=(r.setElement(t),r.isSystemMessage=!0,1===r.sequence&&1===r.random),t=2===r.sequence&&2===r.random;return(e||t)&&(r.sequence=o(),r.random=o(),r.generateMessageID()),r}_handleConversationOptions(e,t){var r=this._core["OuterConstant"],r={conversationID:r.CONV_SYSTEM,unreadCount:0,type:r.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&r.unreadCount++,r}_handleGroupSysTemMessage(e,t){e&&t.forEach(e=>{var t=e.payload["operationType"];switch(t){case j:this._handleGroupJoinResult(e);break;case K:this._handleMemberKicked(e);break;case x:this._handleGroupDismissed(e);break;case V:this._handleGroupInvitedResult(e);break;case J:this._handleGroupQuitResult(e);break;case H:this._handleMessageRemindTypeSynced(e);break;case W:this._handleAVChatRoomMemberBanned(e)}})}_handleGroupJoinResult(e){var e=e.payload["groupProfile"],{groupID:t,type:r}=e,o=be.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupJoinResult",` groupID:${t} type:${r} hasLocalGroup:`+o),o||le(r)||(be.updateLocalGroup([Object.assign({},e)]),be.emitGroupListUpdate())}_handleMemberKicked(e){var{groupID:e,type:t}=e.payload["groupProfile"];be.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupDismissed(e){var{groupID:e,type:t}=e.payload["groupProfile"];be.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupInvitedResult(e){var e=e.payload["groupProfile"],e=e["groupID"],t=be.hasLocalGroup(e);this._core.ssoLog.debug("_handleGroupInvitedResult",` groupID:${e} hasLocalGroup:`+t),t||Se.getGroupProfile({groupID:e}).then(e=>{var e=e["data"]["group"];be.updateLocalGroup([Object.assign({},e)]),be.emitGroupListUpdate()})}_handleGroupQuitResult(e){var{groupID:e,type:t}=e.payload["groupProfile"],r=be.hasLocalGroup(e);this._core.ssoLog.debug("_handleGroupQuitResult",` groupID:${e} type:${t} hasLocalGroup:`+r),r&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleMessageRemindTypeSynced(e){var{groupProfile:{groupID:e},messageRemindType:t}=e.payload;this._updateConversationProfile(e,{messageRemindType:t})}_handleAVChatRoomMemberBanned(e){var{groupID:e,type:t}=e.payload["groupProfile"];this._deleteLocalGroup(e,t)}_deleteLocalGroup(r,e){if(le(e)){let{appStore:{conversationStore:e},OuterConstant:{CONV_GROUP:t}}=this._core;e.deleteConversation(""+t+r)}be.deleteLocalGroup(r),be.emitGroupListUpdate()}_updateConversationProfile(e,t){var{appStore:{conversationStore:r},OuterConstant:{CONV_GROUP:o}}=this._core,o=""+o+e;r.getConversation(o)&&r.updateConversation(o,t)}},ht=new class{init(e){(this._core=e).ssoLog.debug("GroupNotificationHandler.init"),pt.init(e),mt.init(e);var{notificationCenter:e,InnerEvent:t}=e,r=e["InnerEventSubType"];e.subscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.subscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:r}}=this._core;t.executeWorkflow(r.RECEIVE_GROUP_TIPS_NOTIFICATION,e)}_onNewGroupSystemNotification(e){mt.onNewGroupSystemNotification(e)}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core,r=e["InnerEventSubType"];e.unSubscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};let dt={required:!0,rules:["string"],allowEmpty:!1},gt={required:!0,rules:["number"],allowEmpty:!1},_t={required:!0,rules:["array"],allowEmpty:!1},ft={required:!0,rules:["object"],allowEmpty:!1},Gt={createGroup:{name:dt,type:dt},dismissGroup:[Object.assign({key:"groupID"},dt)],joinGroup:{groupID:dt,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},dt)],searchGroupByID:[Object.assign({key:"groupID"},dt)],getGroupProfile:{groupID:dt,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:dt,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:dt,newOwnerID:dt},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},dt)],handleGroupApplication:{handleAction:dt},getGroupMemberList:{groupID:dt},getGroupMemberProfile:{groupID:dt,userIDList:_t,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:dt,userIDList:_t},deleteGroupMember:{groupID:dt,userIDList:_t},setGroupMemberMuteTime:{groupID:dt,userID:dt,muteTime:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:dt,userID:dt,role:dt},setGroupMemberNameCard:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:dt},setGroupMemberCustomField:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:_t},markGroupMemberList:{groupID:dt,markType:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:_t},initGroupAttributes:{groupID:dt,groupAttributes:ft},setGroupAttributes:{groupID:dt,groupAttributes:ft},deleteGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupCounters:{groupID:dt,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:dt,counters:ft},increaseGroupCounter:{groupID:dt,key:dt,value:gt},decreaseGroupCounter:{groupID:dt,key:dt,value:gt}},bt={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};var It=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=be,this.groupAction=Ue,this.groupAttribute=it,this.groupMember=Qe,this.name="Group"}install(t,r=[]){this._core=t,e.init(t),be.init(t),Ue.init(t,this),Qe.init(t,this),Fe.init(t),Ze.init(t),it.init(t),ht.init(t),t.helper.registerValidateConfig({auth:bt,params:Gt}),this._installSubPlugins(r);var{notificationCenter:r,InnerEvent:t}=t;r.subscribeInnerEvent(t.LOGOUT,this._reset,this),r.subscribeInnerEvent(t.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){var{isArray:t}=this._core["utils"];e&&t(e)&&e.forEach(e=>{var t;this._installedSubPlugins.includes(e.name)||(null!=(t=e.install)&&t.call(e,this._core,this),this._installedSubPlugins.push(e.name))})}_reset(){be.reset(),it.reset(),Ze.reset()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};export{It as default};
|
|
1
|
+
const e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r="GRP_COUNTER",i="Set",n="Increase",s="Decrease",u=0,a=1,c=2,p=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],l=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],m=["Role","JoinTime","MsgFlag","MsgSeq"],h=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],d=0,g=1,_="notStart",f="resolved",G="rejected",b=10018,I=11e3,v=2,C=["Owner","Admin","Member"],y=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],A=0,M=1,L=2,D=4,S=1,O=2,T=3,w=4,E=5,N=1,P=0,R=4,U=6,k=400,$=300,F={from:!0,groupID:!0,groupName:!0,to:!0},q={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},j=2,K=4,x=5,V=7,J=8,B=15,H=20,W=21,Y=2600,Q=2602,z=2603,X=2620,Z=2621,ee=2623,te=2660,oe=2661,re=2681,ie=2683,ne=2684,se=2685,ue=2687,ae=3122,ce=10018,pe=t=>t===e.core.OuterConstant.GRP_PUBLIC,le=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,me=(t,o)=>{const{isArray:r}=e.core.utils;if(!r(t)||!r(o))return!1;let i=!1;return o.forEach(({key:e,value:o})=>{const r=t.find(t=>t.key===e);r?r.value!==o&&(r.value=o,i=!0):(t.push({key:e,value:o}),i=!0)}),i},he=e=>{const t=[];if(!e)return t;for(let o=0,r=e.length;o<r;o++){const{Key:r,Value:i}=e[o];t.push({key:r,value:i})}return t},de=e=>{const t=[];for(let o=0,r=e.length;o<r;o++){const{key:r,value:i}=e[o];t.push({Key:r,Value:i})}return t};function ge(t,o){const{helper:r}=e.core;if(!r.checkBusinessCapabilityBits(o))throw new r.ChatError({functionName:t,code:ae,replacement1:t})}function _e(t,o){const{helper:r}=e.core,i=new r.ChatError({functionName:t,code:(null==o?void 0:o.errorCode)||(null==o?void 0:o.code),message:(null==o?void 0:o.errorInfo)||(null==o?void 0:o.message)});throw console.error(`${t} fail:`,i),i}const fe=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class Ge{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._groupAtInfoList=[],this._initGroup(e)}_initGroup(t){const{utils:{isString:o}}=e.core;for(const e in t)fe.indexOf(e)<0||("selfInfo"!==e?"isSupportTopic"!==e?"muteAllMembers"===e&&o(t[e])?this.muteAllMembers="On"===t[e]:this[e]=t[e]:this.isSupportTopic=1===t[e]:this.updateSelfInfo(t[e]))}updateGroup(t){const{utils:{isArray:o,isUndefined:r,isNumber:i,isString:n},common:{deepMerge:s}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);const u=JSON.parse(JSON.stringify(t));u.lastMsgTime&&(this.lastMessage.lastTime=u.lastMsgTime),n(u.muteAllMembers)&&(u.muteAllMembers="On"===u.muteAllMembers),u.groupCustomField&&me(this.groupCustomField,u.groupCustomField),r(u.isSupportTopic)||(this.isSupportTopic=i(u.isSupportTopic)?1===u.isSupportTopic:u.isSupportTopic),s(this,u,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),o(u.members)&&u.members.length>0&&u.members.forEach(e=>{e.userID===this.selfInfo.userID&&s(this.selfInfo,e,["sequence"])})}updateSelfInfo(t){const{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u}=t,{common:{deepMerge:a}}=e.core;a(this.selfInfo,{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var be=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap()}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let o;e.forEach(e=>{var t;o=e.groupID,this.hasLocalGroup(o)?null===(t=this.getLocalGroup(o))||void 0===t||t.updateGroup(e):this._groupMap.set(o,new Ge(e))});const r=t();for(const[,e]of this._groupMap)e.selfInfo.userID=r,"Owner"===e.selfInfo.role&&(e.ownerID=r)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){const{OuterConstant:{GRP_ROOM:e,GRP_LIVE:t}}=this._core;return[...this._groupMap.values()].filter(o=>{const{type:r}=o;return r!==e&&r!==t})}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:o}=this._core;o.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core,r=`${o}${e}`;if(t.getConversation(r)){const o=this.getLocalGroup(e);t.updateConversation(r,{groupProfile:o})}}reset(){this.clearLocalGroup()}};function Ie(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(o[r[i]]=e[r[i]])}return o}function ve(e,t,o,r){return new(o||(o=Promise))(function(i,n){function s(e){try{a(r.next(e))}catch(e){n(e)}}function u(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,u)}a((r=r.apply(e,t||[])).next())})}function Ce(e,t){return ve(this,void 0,void 0,function*(){const{type:o,limit:r,offset:i,supportTopic:n=0,memberAccount:s,responseFilter:u}=e,a={Type:o,Limit:r,Offset:i,Member_Account:s,ResponseFilter:u,SupportTopic:n,NeedAppDefineData:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:a})})}"function"==typeof SuppressedError&&SuppressedError;const ye=function(e,t){return{code:0,data:e||{},successLog:t}};var Ae=new class{constructor(){this._name="GetGroupList",this._pagingStatus=_,this.PAGING_GRP_COUNT_LIMIT=200}init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:r}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return ve(this,arguments,void 0,function*(e=!1){if(e){const e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),be.updateLocalGroup(e),be.getLocalGroupList()}if(this._core.ssoLog.debug("getGroupList",`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===G||this._pagingStatus===_)return this._syncGroupList().then(()=>{const e=be.getLocalGroupList();return ye({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw e});const t=be.getLocalGroupList();return ye({groupList:t,isSyncCompleted:this._isSyncCompleted()},{message:`return group count:${t.length}`})})}_syncGroupList(){return ve(this,void 0,void 0,function*(){this._pagingStatus===_&&be.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=f,this._groupListTreeShaking(t),be.updateLocalGroup(t);const o=be.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",`${this._name}._syncGroupList ok, count:${o.length}`),be.emitGroupListUpdate(),o}catch(e){throw this._pagingStatus=G,e}})}_pagingGetGroupList(e){return ve(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{isCommunityRelay:o=!1,groupList:r}=e;let i,{limit:n,offset:s}=e;const u=[...p];o&&(i=this._core.OuterConstant.GRP_COMMUNITY,u.push("AtInfoList"));try{const e=yield Ce({type:i,limit:n,offset:s,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:u,SelfInfoFilter:[...m]}},this._core),{GroupIdList:a=[],TotalCount:c=0}=e||{},p=this._convertGroupKey(a);r.push(...p);const l=s+n,h=!(c>l),d=`offset:${s} limit:${n} total:${c} isCompleted:${h} current:${r.length} isCommunityRelay:${o}`;return t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. ${d}`),o?h?r:(s=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:s,groupList:r})):h?(t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList start to get community list`),s=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:n,offset:s,groupList:r})):(s=l,this._pagingGetGroupList({limit:n,offset:s,groupList:r}))}catch(e){if(e.ErrorCode===b)return t.warn("_pagingGetGroupList",`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetGroupList({isCommunityRelay:o,limit:n,offset:s,groupList:r});if(o)return e.code===I&&t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. community unavailable`),r;throw e}})}_pagingGetJoinedCommunityList(e){return ve(this,void 0,void 0,function*(){const{common:{getCurrentUserID:t},OuterConstant:o,ssoLog:r}=this._core,{groupList:i}=e;let{limit:n,offset:s}=e;try{const e=yield Ce({limit:n,offset:s,type:o.GRP_COMMUNITY,memberAccount:t(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...p],SelfInfoFilter:[...m]}},this._core),{GroupIdList:u=[],TotalCount:a=0}=e||{},c=this._convertGroupKey(u);i.push(...c);const l=s+n,h=!(a>l),d=`offset:${s} limit:${n} total:${a} isCompleted:${h} current:${i.length}`;return r.debug("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList ok. ${d}`),h?i:(s=l,this._pagingGetJoinedCommunityList({limit:n,offset:s,groupList:i}))}catch(e){if(e.code===ce)return r.warn("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList response size exceeds the limit, request count:${n}`),n=50,this._pagingGetJoinedCommunityList({limit:n,offset:s,groupList:i});throw e}})}_groupListTreeShaking(e){const t=new Map([...be.getLocalGroupList()]);for(let o=0,r=e.length;o<r;o++)t.delete(e[o].groupID);const o=[...t.keys()];for(let e=0,t=o.length;e<t;e++)be.deleteLocalGroup(o[e])}_isSyncCompleted(){return this._pagingStatus===f}_convertGroupKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,Introduction:a,InviteJoinOption:c,LastInfoTime:p,LastMsgTime:l,MemberNum:m,MaxMemberNum:h,MuteAllMember:d,Name:g,NextMsgSeq:_,Notification:f,Owner_Account:G,Type:b,LastRecallTime:I,SelfInfo:v,AtInfoList:C=[],SupportTopic:y}=e[o],A=he(r),M=this._convertSelfInfo(v),L=this._convertAtInfoList(u,C);t.push({groupCustomField:A,joinOption:i,createTime:n,avatar:s,groupID:u,introduction:a,inviteOption:c,lastInfoTime:p,lastMsgTime:l,memberCount:m,maxMemberCount:h,muteAllMembers:d,name:g,nextMessageSeq:_,notification:f,ownerID:G,type:b,selfInfo:M,_lastRevokedTime:I,_groupAtInfoList:L,isSupportTopic:y})}return t}_convertSelfInfo(e){const{JoinTime:t,MsgFlag:o,MsgSeq:r,NoUnreadSeqList:i,Role:n}=e;return{joinTime:t,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i,role:n}}_convertAtInfoList(e,t){if(0===t.length)return[];const o=[];return t.forEach(t=>{const{AtFlagList:r,AtMsgSeq:i,From_Account:n}=t;o.push({groupID:e,groupAtType:r,sequence:i,from:n})}),o}};var Me=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return ve(this,void 0,void 0,function*(){var t;this._preCheckParams(e);const{helper:{ChatError:o}}=this._core;try{const{utils:{isEmpty:o},common:{getCurrentUserID:r}}=this._core,i=yield function(e,t){return ve(this,void 0,void 0,function*(){const{name:o,type:r,groupID:i,introduction:n,notification:s,avatar:u,maxMemberNum:a,joinOption:c,inviteOption:p,memberList:l,groupCustomField:m,isSupportTopic:h}=e;let d;l&&(d=l.map(e=>{const{userID:t,memberCustomField:o}=e;return{Member_Account:t,AppMemberDefinedData:o?de(o):void 0}}));const g={Name:o,Type:r,GroupId:i,Introduction:n,Notification:s,FaceUrl:u,MaxMemberCount:a,ApplyJoinOption:c,InviteJoinOption:p,MemberList:d,AppDefinedData:m,SupportTopic:h,webPushFlag:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:g})})}(Object.assign(Object.assign({},e),{ownerID:r()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:s=[]}=i||{},u=`${this._name}.createGroup ok, type:${e.type} groupID:${n} overLimitUserIDList:${s}`;o(e.memberList)||o(s)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter(e=>s.includes(e.userID))),be.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]);const a=be.getLocalGroup(n);return this._notNeedSendCustomMessage(e)||(this._sendCustomMessage(n,e.type),be.emitGroupListUpdate()),ye({group:a},{message:u})}catch(t){const{errorCode:r,errorInfo:i}=t;throw new o({functionName:"createGroup",code:r,message:i,moreMessage:` groupID:${e.groupID}`})}})}_preCheckParams(t){const{type:o,groupID:r}=t,{utils:{isEmpty:i,isUndefined:n},common:{isCommunity:s}}=this._core,u=!i(r);if(!(()=>{const{GRP_PUBLIC:t,GRP_WORK:o,GRP_MEETING:r,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,o,r,i,n]})().includes(o))throw new this._core.helper.ChatError({code:Y});if(!s({type:o})){if(u&&s({groupID:r}))throw new this._core.helper.ChatError({code:Q});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(o)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(o)||n(t.joinOption)||(t.joinOption=void 0),s({type:o})){if(u&&!s({groupID:r}))throw new this._core.helper.ChatError({code:Q});t.isSupportTopic=this._canIUseTopic(t)?1:0}}_canIUseMemberList(e){return!le(e)}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){const{isSupportTopic:t}=e;return!0===t}_notNeedSendCustomMessage(e){const{type:t,isSupportTopic:o}=e,{OuterConstant:{GRP_AVCHATROOM:r,GRP_COMMUNITY:i}}=this._core;return t===r||t===i&&1===o}_sendCustomMessage(e,t){var o,r,i,n,s,u;const{OuterConstant:a}=this._core;let c="Create Group",p=d;t===a.GRP_COMMUNITY&&(c="Create Community",p=g);const l={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:c,cmd:p,opUser:this._core.store.get("login").userId,version:4})}},m=null===(i=null===(r=null===(o=this._core)||void 0===o?void 0:o.message)||void 0===r?void 0:r.messageFactory)||void 0===i?void 0:i.createCustomMessage(l);null===(u=null===(s=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===s?void 0:s.messageSender)||void 0===u||u.sendMessage(m,{})}};var Le=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){this._core=e;const{helper:t,constants:o}=e;t.registerWorkflowStep(o.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:o,isUndefined:r}}=this._core;return!r(t)&&!o(t.groupAttributeOption)}handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:o}=e,{serverMainSequence:r,groupAttributeList:i=[],operation:n}=o;this._core.ssoLog.debug("handleGroupAttributesUpdated",`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${n}`);const{utils:{isUndefined:s}}=this._core;s(n)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:i,operation:n}),this.emitGroupAttributesUpdated(t))}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:o,values:new Map}),this._core.ssoLog.debug("initGroupAttributesCache",`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${o}`)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:o,groupAttributeList:r,operation:i}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:n}=e;i!==E&&o-n!==1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:r,operation:i})),o-n>1&&(e.serverMainSequence=o),this._groupAttributesCache.set(t,e),this._core.ssoLog.debug("refreshGroupAttributesCache",`${this._name}.refreshGroupAttributesCache. operation:${i} localMainSequence:${n} serverMainSequence:${o}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:o=[],operation:r}=e;r!==T?r!==w?(r===S&&t.values.clear(),o.forEach(e=>{const{key:o,value:r,sequence:i}=e;t.values.set(o,{value:r,sequence:i})})):o.forEach(e=>{t.values.delete(e.key)}):t.values.clear()}getGroupAttributesCacheValues(e){var t;const{groupID:o,keyList:r=[]}=e,i={};if(this.hasGroupAttributesCache(o)){const{values:e}=this.getGroupAttributesCache(o);if(0===r.length){for(const o of e.keys())i[o]=(null===(t=e.get(o))||void 0===t?void 0:t.value)||"";return i}return r.forEach(t=>{var o;e.has(t)&&(i[t]=(null===(o=e.get(t))||void 0===o?void 0:o.value)||"")}),i}return i}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t;const o=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:r,deletedKeyList:i}=this._computeValuesChangedData(o);this._core.ssoLog.debug("emitGroupAttributesUpdated",`${this._name}.emitGroupAttributesUpdated update count:${r.length}, delete count:${i.length}`),0===r.length&&0===i.length||this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:o,updatedKeyList:r,deletedKeyList:i}})}_computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,o=[],r=[];return Object.keys(e).forEach(t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&o.push(t)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(o=>{t(e[o])&&r.push(o)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:r}}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach(o=>{t.push({key:o,value:e[o]})}),t}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}};var De=new class{constructor(){this._name="DismissGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}dismissGroup(e){return ve(this,void 0,void 0,function*(){const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:o})})}(e,this._core);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(e),ye({groupID:e,type:t},{message:e})}catch(e){const{errorCode:o,errorInfo:r}=e;throw new t({functionName:"dismissGroup",code:o,message:r})}})}};var Se=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return ve(this,void 0,void 0,function*(){const{groupID:t,groupCustomFieldFilter:o}=e,r={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...p],AppDefinedDataFilter_Group:o,MemberInfoFilter:[...h]}},{helper:{ChatError:i}}=this._core;try{const e=yield this.getGroupProfileAdvance(r),{successGroupList:o,failureGroupList:i}=e;if(i.length>0)throw i[0];let n;return!be.hasLocalGroup(t)&&le(o[0].type)?n=new Ge(o[0]):(be.updateLocalGroup(o),n=be.getLocalGroup(t)),n.isSupportTopic||be.updateConversationGroupProfile(t),ye({group:n},{message:`groupID:${t}`})}catch(e){const{code:t,message:o}=e;throw new i({functionName:"getGroupProfile",code:t,message:o})}})}getGroupProfileAdvance(e){return ve(this,void 0,void 0,function*(){const{groupIDList:t}=e,{common:{isCommunity:o}}=this._core,r=t.filter(e=>!o({groupID:e})),i=t.filter(e=>o({groupID:e}));r.length>50&&(r.length=50),i.length>50&&(i.length=50);const n=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:r})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:i,isCommunityProfile:!0}))]),s=[],u=[];return n.forEach(e=>{s.push(...e.successGroupList),u.push(...e.failureGroupList)}),{successGroupList:s,failureGroupList:u}})}_getGroupProfileAdvance(e){return ve(this,void 0,void 0,function*(){const{ssoLog:t,utils:{isUndefined:o}}=this._core,{isCommunityProfile:r=!1}=e,i=Ie(e,["isCommunityProfile"]);if(0===i.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupIDList:o,responseFilter:r}=e,i={GroupIdList:o,ResponseFilter:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:i})})}(i,this._core),{GroupInfo:r=[]}=e||{},n=this._convertGroupProfileKey(r),s=n.filter(e=>o(e.errorCode)||0===e.errorCode),u=n.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return t.debug("_getGroupProfileAdvance",`${this._name}._getGroupProfileAdvance ok, groupID:${i.groupIDList.join(",")}`),{successGroupList:s,failureGroupList:u}}catch(e){if(r)return{successGroupList:[],failureGroupList:[]};throw e}})}_convertGroupProfileKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,InfoSeq:a,Introduction:c,InviteJoinOption:p,LastInfoTime:l,LastMsgTime:m,MaxMemberNum:h,MemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:I,ShutUpUntil:v,Type:C,MemberList:y,ErrorCode:A,ErrorInfo:M}=e[o],L=he(r),D=this._convertMembers(y);t.push({groupCustomField:L,joinOption:i,createTime:n,avatar:s,groupID:u,infoSequence:a,introduction:c,inviteOption:p,lastInfoTime:l,lastMsgTime:m,maxMemberCount:h,memberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:I,muteUntil:v,type:C,members:D,errorCode:A,errorInfo:M})}return t}_convertMembers(e){if(!e)return[];const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,MsgFlag:s,MsgSeq:u,NameCard:a,Role:c}=e[o],p=he(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Oe=new class{constructor(){this._groupCountersMap=new Map}init(e){this._core=e}getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}updateLocalGroupCounters(e){const{groupID:t,counterList:o=[],groupCounterSeq:r}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i,groupCounterSeq:n}=this.getLocalGroupCounters(t);if(r>0&&r<n)return;o.forEach(t=>{const{Key:o,Value:r=0}=t;e.set(o,r)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:r,counters:e,avChatRoomKey:i})}}initGroupCountersCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:o})}getLocalCounters(e,t){const o={};if(!this._hasLocalGroupCounters(e))return o;const{counters:r}=this.getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{r.has(e)&&(o[e]=r.get(e))});else for(const e of r.keys())o[e]=r.get(e);return o}deleteLocalGroupCounters(e){const{groupID:t,counterList:o=[],groupCounterSeq:r}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i}=this.getLocalGroupCounters(t);o.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:r,counters:e,avChatRoomKey:i})}}setGroupCounters(e,t){if(!this._hasLocalGroupCounters(e))return;const o=this.getLocalGroupCounters(e),{counters:r}=o;let i=!1;Object.entries(t).forEach(([e,t])=>{r.has(e)&&r.get(e)!==t&&(r.set(e,t),i=!0)}),i&&this._groupCountersMap.set(e,Object.assign(Object.assign({},o),{lastUpdateTime:Date.now(),counters:r}))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}reset(){this._groupCountersMap.clear()}};var Te=new class{constructor(){this._name="JoinGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"joinGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}joinGroup(e){return ve(this,void 0,void 0,function*(){const{groupID:t}=e,{helper:{ChatError:o},OuterConstant:r,ssoLog:i}=this._core;try{if(be.hasLocalGroup(t))try{return yield Se.getGroupProfile({groupID:t}),ye({status:r.JOIN_STATUS_ALREADY_IN_GROUP,group:be.getLocalGroup(t)},{message:`groupID:${t} joinedStatus:${r.JOIN_STATUS_ALREADY_IN_GROUP}`})}catch(o){i.warn("joinGroup",`${this._name}.joinGroup ${t} was unjoined, start to join!`),be.deleteLocalGroup(t);return yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){const{errorCode:r,errorInfo:i}=e;throw new o({functionName:"joinGroup",code:r,message:i,moreMessage:`groupID:${t}`})}})}_applyJoinGroup(e){return ve(this,void 0,void 0,function*(){const{OuterConstant:t,helper:r,ssoLog:i}=this._core,{groupID:n}=e,s=Object.assign({},e),u=r.checkBusinessCapabilityBits(o);u&&(s.historyMessageFlag=1);const a=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e,n={GroupId:o,ApplyMsg:r,HugeGroupHistoryMsgFlag:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:n})})}(s,this._core),{Type:c,JoinedStatus:p,LongPollingKey:l,StartSeq:m,HugeGroupFlag:h,AVChatRoomKey:d,RspMsgList:g=[]}=a||{},_=`groupID:${n} joinedStatus:${p} longPollingKey:${l} startSeq:${m} avChatRoomFlag:${h} canGetAVChatRoomHistoryMsg:${u}, historyMessageCount:${g.length}`;i.debug("_applyJoinGroup",`${this._name}._applyJoinGroup ok, ${_}`);let f=new Ge({groupID:n,type:c});if(p===t.JOIN_STATUS_WAIT_APPROVAL)return ye({status:t.JOIN_STATUS_WAIT_APPROVAL,group:f});if(p===t.JOIN_STATUS_SUCCESS){try{f=(yield Se.getGroupProfile({groupID:n})).data.group}catch(e){i.warn("_applyJoinGroup",`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${n}, errorCode:${null==e?void 0:e.code}`)}return this._handleJoinResult({group:f,avChatRoomFlag:h,longPollingKey:l,startSequence:m,avChatRoomKey:d,historyMessageList:g})}throw new this._core.helper.ChatError({code:te})})}_handleJoinResult(e){const{group:t,avChatRoomFlag:o,avChatRoomKey:r}=e;return 1===o?(Le.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:r}),Oe.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:r}),ye(e)):(be.updateLocalGroup([t]),be.emitGroupListUpdate(),ye({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t},{message:`groupID:${t.groupID}`}))}};var we=new class{constructor(){this._name="QuitGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"quitGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}quitGroup(e){return ve(this,void 0,void 0,function*(){if(!be.hasLocalGroup(e))throw new this._core.helper.ChatError({code:ee});const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:o})})}(e,this._core);const{type:t}=be.getLocalGroup(e);return be.deleteLocalGroup(e),be.emitGroupListUpdate(),Le.deleteGroupAttributesCache(e),ye({groupID:e,type:t},{message:`groupID:${e}`})}catch(o){const{errorCode:r,errorInfo:i}=o;throw new t({functionName:"quitGroup",code:r,message:i,moreMessage:`groupID:${e}`})}})}};var Ee=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return ve(this,void 0,void 0,function*(){try{const t=yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupIdList:[e],GroupBasePublicInfoFilter:[...l]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:o})})}(e,this._core),{GroupInfo:o=[]}=t||{},{AppDefinedData:r=[],ApplyJoinOption:i,CreateTime:n,FaceUrl:s,Introduction:u,InviteJoinOption:a,MaxMemberNum:c,MemberNum:p,Name:m,Owner_Account:h,Type:d,ErrorCode:g,ErrorInfo:_}=o[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});const f=he(r),G=new Ge({groupID:e,name:m,avatar:s,introduction:u,joinOption:i,inviteOption:a,maxMemberCount:c,memberCount:p,type:d,ownerID:h,createTime:n,groupCustomField:f});return ye({group:G})}catch(e){const{errorCode:t,errorInfo:o}=e;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:t,message:o})}})}};var Ne=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return ve(this,void 0,void 0,function*(){const{groupID:t}=e,{utils:{isUndefined:o},ssoLog:r,helper:i}=this._core;let n=be.getLocalGroup(t);if(n){const{type:i}=n;this._canIUseJoinOption(i)||o(e.joinOption)||(r.warn("updateGroupProfile",`${this._name}.updateGroupProfile groupID:${t} joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}o(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,name:r,avatar:i,introduction:n,notification:s,muteAllMembers:u,joinOption:a,inviteOption:c,groupCustomField:p}=e,l={GroupId:o,Name:r,FaceUrl:i,Introduction:n,Notification:s,ShutUpAllMember:u,ApplyJoinOption:a,InviteJoinOption:c,AppDefinedData:p?de(p):void 0};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:l})})}(e,this._core),n?(n.updateGroup(e),be.emitGroupListUpdate()):n=new Ge(e),ye({group:n},{message:`groupID:${t}`})}catch(e){const{errorCode:o,errorInfo:r}=e;throw new i.ChatError({code:o,message:r,moreMessage:`groupID:${t}`})}})}_canIUseJoinOption(e){return pe(e)||this._core.common.isCommunity({type:e})}};var Pe=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return ve(this,void 0,void 0,function*(){const t="changeGroupOwner",{groupID:o,newOwnerID:r}=e,i=be.getLocalGroup(o),{helper:n,OuterConstant:s,common:{getCurrentUserID:u}}=this._core;if((null==i?void 0:i.type)===s.GRP_AVCHATROOM)throw new n.ChatError({functionName:t,code:X});if(r===u())throw new n.ChatError({functionName:t,code:Z});try{return yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,newOwnerID:r}=e,i={GroupId:o,NewOwner_Account:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:i})})}(e,this._core),i.ownerID=r,be.emitGroupListUpdate(),ye({group:i})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Re=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupOnlineMemberCount(e){return ve(this,void 0,void 0,function*(){const t="getGroupOnlineMemberCount";if(!be.hasLocalGroup(e))return ye({memberCount:0});const o=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:r=0,memberCount:i=0}=t||{};if(o-r<=6e4)return ye({memberCount:i})}try{const o=yield function(e,t){return ve(this,void 0,void 0,function*(){const o={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:o})})}(e,this._core),{OnlineMemberNum:r=0}=o||{};this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:r});const i=`${this._name}.${t} ok. groupID:${e} memberCount:${r}`;return ye({memberCount:r},{message:i})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Ue=new class{init(e,t){e.ssoLog.debug("GroupAction.init"),Ae.init(e),Me.init(e),De.init(e,t),Te.init(e,t),we.init(e,t),Ee.init(e),Se.init(e),Ne.init(e),Pe.init(e),Re.init(e,t)}dismissGroup(e){return De.dismissGroup(e)}joinGroup(e){return Te.joinGroup(e)}quitGroup(e){return we.quitGroup(e)}getGroupOnlineMemberCount(e){return Re.getGroupOnlineMemberCount(e)}};var ke=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return ve(this,void 0,void 0,function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);this._core.ssoLog.debug("getGroupApplicationList",`${this._name}.${e} ok.`);const o=this._handleGroupApplicationResult([...t[0],...t[1]]);return ye({applicationList:o})}catch(t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}})}_getGroupApplicationList(e){return ve(this,void 0,void 0,function*(){const{type:t,startTime:o=0,limit:r=20}=e||{},{common:i}=this._core;let n;try{n=yield function(e,t){return ve(this,void 0,void 0,function*(){const{type:o,startTime:r,limit:i,handleAccount:n}=e,s={Type:o,StartTime:r,Limit:i,Handle_Account:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:s})})}({type:t,startTime:o,limit:r,handleAccount:i.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;n={}}const{NextStartTime:s=0,PendencyList:u=[]}=n||{};if(0===s)return u;const a=yield this._getGroupApplicationList(Object.assign(Object.assign({},e),{startTime:s}));return[...u,...a]})}_handleGroupApplicationResult(e){const t=[];return e.forEach(e=>{const o=this._convertApplicationData(e),{handled:r}=o,i=Ie(o,["handled"]);0===r&&t.push(i)}),t}_convertApplicationData(e){const{Handled:t,AddTime:o,ApplyInviteMsg:r,Authentication:i,FromUserNickName:n,From_Account:s,GroupId:u,GroupName:a,PendencyType:c,To_Account:p}=e;return{handled:t,messageKey:o,applicant:s,applicantNick:n,groupID:u,groupName:a,authentication:i,applicationType:c,userID:p,note:r}}};var $e=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return ve(this,void 0,void 0,function*(){const{application:t}=e,o=this._handleParams(e);try{(null==t?void 0:t.applicationType)===v?yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,invitee:u}=e,a={GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,Invited_Account:u};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:a})})}(o,this._core):yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,handleAction:r,handleMessage:i,applicant:n,authentication:s,messageKey:u}=e,a={GroupId:o,HandleMsg:r,ApprovalMsg:i,Applicant_Account:n,Authentication:s,MsgKey:u};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:a})})}(o,this._core);const e=be.getLocalGroup(o.groupID);return ye({group:e})}catch(e){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_handleParams(e){var t;const{handleAction:o,handleMessage:r,message:i,application:n}=e;let s,u,a,c,p;if(i){const{payload:e}=i||{};s=e.operatorID,u=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,a=e.authentication,c=e.messageKey}else s=(null==n?void 0:n.applicant)||"",u=(null==n?void 0:n.groupID)||"",a=(null==n?void 0:n.authentication)||"",c=(null==n?void 0:n.messageKey)||0;return(null==n?void 0:n.applicationType)===v&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var Fe=new class{init(e){e.ssoLog.debug("GroupApplication.init"),ke.init(e),$e.init(e)}};let qe=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(t){const{core:{utils:{isUndefined:o},common:{deepMerge:r}}}=e;o(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),o(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus);const i=[null,void 0,"",0,NaN];t.memberCustomField&&me(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function je(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=de(u));const c={GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:c})})}var Ke=new class{constructor(){this._name="GetGroupMemberList"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupMemberList(e){return ve(this,void 0,void 0,function*(){const t="getGroupMemberList",{groupID:o,offset:r=0,count:i=100,role:n="",filter:s=""}=e,u=be.getLocalGroup(o),a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:C.includes(n)?[n]:void 0,memberInfoFilter:y};try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{isCommunity:o}=t.common,{groupID:r,offset:i,limit:n,memberRoleFilter:s,memberInfoFilter:u}=e,a={GroupId:r,Limit:n,MemberRoleFilter:s,MemberInfoFilter:u};return o({groupID:r})?a.Next=String(i):a.Offset=i,t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:a})})}(c,this._core),{MemberList:i,MemberNum:n,Next:s}=e||{},p=`${this._name}.${t} ok, totalMemberCount:${n} next:${s}`,{utils:{isArray:l,isEmpty:m},common:{isCommunity:h}}=this._core;if(u&&(u.memberCount=n),!l(i)||0===i.length)return ye({memberList:[],offset:0},{message:p});let d=r+a;h({groupID:o})&&(d=m(s)?0:s),i.length<a&&(d=0);let g=this._convertMemberInfo(i);g=yield this._patchAvatarAndNick(g);const _=this._generateGroupMember(g);return ye({memberList:_,offset:d},{message:p})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a,NameCard:c}=e[o],p=he(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:p,nameCard:c})}return t}_patchAvatarAndNick(e){return ve(this,void 0,void 0,function*(){var t;const o=e.map(e=>e.userID),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map(e=>[e.userID,e]));return e.forEach(e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}}),e})}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new qe(e[o]);t.push(r)}return t}};var xe=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return ve(this,void 0,void 0,function*(){const t="getGroupMemberProfile",{groupID:o,userIDList:r,memberCustomFieldFilter:i}=e,n=be.getLocalGroup(o),{helper:s,utils:{isArray:u},ssoLog:a}=this._core;if(n&&le(n.type))throw new s.ChatError({functionName:t,replacement1:t,code:ue});r.length>50&&(a.warn("getGroupMemberProfile",`${this._name}.${t} userIDList length:${r.length} exceeds limit 50`),r.splice(50));const c=`userIDList length:${r.length} groupID:${o}`;try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e,s={GroupId:o,Member_List_Account:r,MemberInfoFilter:i,AppDefinedDataFilter_GroupMember:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:s})})}({groupID:o,userIDList:r,memberCustomFieldFilter:i,memberInfoFilter:[...y]},this._core),{MemberList:t}=e||{};if(!u(t)||0===t.length)return ye({memberList:[]});let n=this._convertMemberInfo(t);n=yield this._getMemberAvatarAndNick(n);const s=this._generateGroupMember(n);return ye({memberList:s},{message:c})}catch(e){throw new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:c})}})}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a,NameCard:c}=e[o],p=he(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:p,nameCard:c})}return t}_getMemberAvatarAndNick(e){return ve(this,void 0,void 0,function*(){var t;const o=e.map(e=>e.userID),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map(e=>[e.userID,e]));return e.forEach(e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}}),e})}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new qe(e[o]);t.push(r)}return t}};var Ve=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return ve(this,void 0,void 0,function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n}=this._core;if(i&&le(i.type))throw new n.ChatError({functionName:t,code:oe});const s=r.map(e=>({Member_Account:e}));try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r}=e,i={GroupId:o,MemberList:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:i})})}({groupID:o,userIDList:s},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:r,successUserIDList:n,existedUserIDList:u,overLimitUserIDList:a}=this._handleResult(t);return ye({failureUserIDList:r,successUserIDList:n,existedUserIDList:u,overLimitUserIDList:a,group:i},{message:` groupID:${o} successUserIDList:${n} failureUserIDList:${r} existedUserIDList:${u} overLimitUserIDList:${a}`})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_handleResult(e){const t=[],o=[],r=[],i=[];return e.forEach(e=>{const{Result:n,Member_Account:s}=e;n===A?t.push(s):n===M?o.push(s):n===L?r.push(s):n===D&&i.push(s)}),{failureUserIDList:t,successUserIDList:o,existedUserIDList:r,overLimitUserIDList:i}}};var Je=new class{constructor(){this._name="DeleteGroupMember"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}deleteGroupMember(e){return ve(this,void 0,void 0,function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=be.getLocalGroup(o),{helper:n,utils:{isUndefined:s},ssoLog:u}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:z});r.length>20&&(u.warn("deleteGroupMember",`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,userIDList:r,reason:i}=e,n={GroupId:o,MemberToDel_Account:r,Reason:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:n})})}({groupID:o,userIDList:r},this._core),ye({group:i,userIDList:r},{message:`groupID:${o} userIDList length:${r.length}`})}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var Be=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return ve(this,void 0,void 0,function*(){const{helper:t}=this._core,{groupID:o,userID:r,muteTime:i}=e,n=` groupID:${o} userID:${r} muteTime:${i}`;this._preCheckSettingMuteParams(e);try{yield je(e,this._core);const t=be.getLocalGroup(o),s=new qe({userID:r,muteTime:i});return ye({group:t,member:s},{message:n})}catch(e){throw new t.ChatError({functionName:"setGroupMemberMuteTime",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:n})}})}_preCheckSettingMuteParams(e){const{userID:t}=e,{store:o,helper:r}=this._core;if(t===o.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:se})}};var He=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberRole",{helper:o}=this._core,{groupID:r,userID:i,role:n}=e,s=`${this._name}.${t} ok, groupID:${r} userID:${i} role:${n}`;this._preCheckSettingRoleParams(e);try{yield je(e,this._core);const t=be.getLocalGroup(r),o=new qe({userID:i,role:n});return ye({group:t,member:o},{message:s})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:s})}})}_preCheckSettingRoleParams(e){var t;const{groupID:o,userID:r,role:i}=e,{store:n,helper:s,OuterConstant:u,common:{isCommunity:a}}=this._core,c=be.getLocalGroup(o);if((null===(t=null==c?void 0:c.selfInfo)||void 0===t?void 0:t.role)!==u.GRP_MBR_ROLE_OWNER)throw new s.ChatError({functionName:"setGroupMemberRole",code:re});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ne});const p=[...C];if(a({groupID:o})&&p.push(u.GRP_MBR_ROLE_CUSTOM),!p.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:ie})}};var We=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberNameCard",{helper:o,common:{getCurrentUserID:r}}=this._core;this._preCheckSettingNameCardParams(e);try{const{groupID:o,userID:i=r(),nameCard:n}=e,s={groupID:o,userID:i,nameCard:n};yield je(s,this._core);const u=`${this._name}.${t} ok, groupID:${o} userID:${i} nameCard:${n}`,a=be.getLocalGroup(o),c=new qe({userID:i,nameCard:n});return ye({group:a,member:c},{message:u})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:logText})}})}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(le(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:ue})}};var Ye=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return ve(this,void 0,void 0,function*(){const t="setGroupMemberCustomField",{helper:o,common:{getCurrentUserID:r}}=this._core;this._preCheckSettingCustomFiledParams(e);const{groupID:i,userID:n=r(),memberCustomField:s}=e,u=`${this._name}.${t} ok, groupID:${i}userID:${n} memberCustomField:${JSON.stringify(s)}`;try{const e={groupID:i,userID:n,memberCustomField:s};yield je(e,this._core);const t=be.getLocalGroup(i),o=new qe({userID:n,memberCustomField:s});return ye({group:t,member:o},{message:u})}catch(e){throw new o.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:u})}})}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:o}=this._core,r=be.getLocalGroup(t);if(le(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:ue})}};var Qe=new class{init(e,t){e.ssoLog.debug("GroupMember.init"),Ke.init(e,t),xe.init(e),Ve.init(e),Je.init(e,t),Be.init(e),He.init(e),We.init(e),Ye.init(e)}getGroupMemberList(e){return Ke.getGroupMemberList(e)}deleteGroupMember(e){return Je.deleteGroupMember(e)}};var ze=new class{init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(t){return ve(this,void 0,void 0,function*(){const o="getGroupCounters";try{ge(o,r);const{groupID:i,keyList:n=[]}=t,{avChatRoomKey:s,lastUpdateTime:u}=Oe.getLocalGroupCounters(i);if(!(Date.now()-u>=this._getExpireTime())){return{code:0,data:{counters:Oe.getLocalCounters(i,n)}}}const a=yield function(t){return ve(this,void 0,void 0,function*(){const{groupID:o,GroupCounterKeys:r,avChatRoomKey:i}=t,{common:n}=e.core,s={GroupId:o,keyList:r,BytesKey:i};return n.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:s})})}({groupID:i,keyList:n,avChatRoomKey:s}),{GroupCounter:c=[],GroupCounterSeq:p}=a;Oe.updateLocalGroupCounters({groupID:i,counterList:c,groupCounterSeq:p});return{code:0,data:{counters:Oe.getLocalCounters(i,n)}}}catch(e){_e(o,e)}})}_getExpireTime(){const{store:e,utils:{isUndefined:t}}=this._core,o=e.get("cloudConfig")||{},{grp_counter_expire_time:r}=o;return t(r)?3e4:Number(r)}};var Xe=new class{init(e){const{helper:t}=e;t.registerApi({apiName:"setGroupCounters",context:this}),t.registerApi({apiName:"increaseGroupCounter",context:this}),t.registerApi({apiName:"decreaseGroupCounter",context:this})}setGroupCounters(e){return ve(this,void 0,void 0,function*(){return this._handleCounterOperation(i,e)})}increaseGroupCounter(e){return ve(this,void 0,void 0,function*(){return this._handleCounterOperation(n,e)})}decreaseGroupCounter(e){return ve(this,void 0,void 0,function*(){return this._handleCounterOperation(s,e)})}_handleCounterOperation(e,t){return ve(this,void 0,void 0,function*(){const o=`${e}GroupCounter`;try{ge(o,r);const{groupID:n,key:s,value:u=0}=t,{avChatRoomKey:a}=Oe.getLocalGroupCounters(n),c=e===i?this._convertObjectToList(t.counters):[{Key:s,Value:u}],p=yield this._updateGroupCounters({groupID:n,counterList:c,avChatRoomKey:a,mode:e});return Oe.setGroupCounters(n,p),{code:0,data:{counters:p}}}catch(e){_e(o,e)}})}_updateGroupCounters(t){return ve(this,void 0,void 0,function*(){const o=yield function(t){const{groupID:o,counterList:r,mode:i,avChatRoomKey:n}=t,{common:s}=e.core,u={GroupId:o,GroupCounter:r,Mode:i,BytesKey:n};return s.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:u})}(t),{GroupCounter:r=[]}=o,i={};return r.forEach(e=>{const{Key:t,Value:o=0}=e;i[t]=o}),i})}_convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}};var Ze=new class{init(e){this._core=e,ze.init(e),Xe.init(e)}isGroupCounterUpdated(e){const{elements:{groupCounterInfo:t}}=e,{utils:{isEmpty:o}}=this._core;return!o(t)}handleGroupCounterUpdated(e){const{to:t,elements:{groupCounterInfo:o}}=e;o.forEach(e=>{const{type:o,groupCounterSeq:r,counterList:i=[]}=e;o!==u&&o!==c||this._processAndNotifyCounterUpdate(t,r,i),o===a&&Oe.deleteLocalGroupCounters({groupID:t,groupCounterSeq:r,counterList:i})})}_processAndNotifyCounterUpdate(e,t,o){const{OuterEvent:r,notificationCenter:i}=this._core;Oe.updateLocalGroupCounters({groupID:e,groupCounterSeq:t,counterList:o}),o.forEach(({Key:t,Value:o=0})=>{i.emitOuterEvent(r.GROUP_COUNTER_UPDATED,{name:r.GROUP_COUNTER_UPDATED,data:{groupID:e,key:t,value:o}})})}reset(){Oe.reset()}};var et=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return ve(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:o}=e,{serverMainSequence:r,avChatRoomKey:i}=Le.getGroupAttributesCache(t),n=Le.convertKeyValueMapToList(o);try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e,s={GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:s})})}({groupID:t,avChatRoomKey:i,groupAttributeList:n,mainSequence:r},this._core),{AttrMainSeq:s,GroupAttr:u}=e||{},a=u.map(e=>{const{Key:t,seq:r}=e;return{key:t,value:o[t],sequence:r}});return Le.saveGroupAttributesCacheValuesCopy(t),Le.refreshGroupAttributesCache({groupID:t,serverMainSequence:s,groupAttributeList:a,operation:S}),Le.emitGroupAttributesUpdated(t),ye({groupAttributes:o},{message:` groupID:${t} serverMainSequence:${s}`})}catch(e){throw new this._core.helper.ChatError({functionName:"initGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var tt=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return ve(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:o}=e,{serverMainSequence:r,avChatRoomKey:i,values:n}=Le.getGroupAttributesCache(t),s=Le.convertKeyValueMapToList(o).map(e=>{var t;const{key:o,value:r}=e;return{key:o,value:r,seq:(null===(t=n.get(e.key))||void 0===t?void 0:t.sequence)||0}});try{const e=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e,s={GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:s})})}({groupID:t,avChatRoomKey:i,groupAttributeList:s,mainSequence:r},this._core),{AttrMainSeq:n,GroupAttr:u}=e||{},a=u.map(e=>{const{Key:t,seq:r}=e;return{key:t,value:o[t],sequence:r}});return Le.saveGroupAttributesCacheValuesCopy(t),Le.refreshGroupAttributesCache({groupID:t,serverMainSequence:n,groupAttributeList:a,operation:O}),Le.emitGroupAttributesUpdated(t),ye({groupAttributes:o},{message:` groupID:${t} serverMainSequence:${n}`})}catch(e){throw new this._core.helper.ChatError({functionName:"setGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}};var ot=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return ve(this,void 0,void 0,function*(){const t="deleteGroupAttributes",{groupID:o,keyList:r=[]}=e;try{let e;e=0===r.length?yield this._clearGroupAttributes(o):yield this._deleteGroupAttributes(o,r);const{resultList:i,serverMainSequence:n,operation:s,groupAttributeList:u}=e||{},a=`${this._name}.${t} ok. groupID:${o} operation: ${s}`;return Le.saveGroupAttributesCacheValuesCopy(o),Le.refreshGroupAttributesCache({groupID:o,serverMainSequence:n,groupAttributeList:u,operation:s}),Le.emitGroupAttributesUpdated(o),ye({keyList:i},{message:a})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}_deleteGroupAttributes(e,t){return ve(this,void 0,void 0,function*(){const{serverMainSequence:o,avChatRoomKey:r,values:i}=Le.getGroupAttributesCache(e),n=[],s=[];t.forEach(e=>{if(i.has(e)){const{sequence:t=0}=i.get(e)||{};s.push({key:e,seq:t}),n.push(e)}});const u=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e,s={GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:s})})}({groupID:e,avChatRoomKey:r,groupAttributeList:s,mainSequence:o},this._core),{AttrMainSeq:a}=u||{};return{resultList:n,serverMainSequence:a,groupAttributeList:s,operation:w}})}_clearGroupAttributes(e){return ve(this,void 0,void 0,function*(){const{serverMainSequence:t,avChatRoomKey:o,values:r}=Le.getGroupAttributesCache(e),i=[...r.keys()],n=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,mainSequence:r,avChatRoomKey:i}=e,n={GroupId:o,AttrMainSeq:r,BytesKey:i,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:n})})}({groupID:e,avChatRoomKey:o,mainSequence:t},this._core),{AttrMainSeq:s}=n||{};return{resultList:i,serverMainSequence:s,operation:T}})}};var rt=new class{constructor(){this._name="GetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(e){return ve(this,void 0,void 0,function*(){const{groupID:t}=e,{avChatRoomKey:o,lastUpdateTime:r,localMainSequence:i,serverMainSequence:n}=Le.getGroupAttributesCache(t),{helper:{ChatError:s}}=this._core,u=`groupID:${t} localMainSequence:${i} serverMainSequence:${n} keyList:${e.keyList}`;if(Date.now()-r>=3e4||i<n)try{const r=yield this.getGroupAttributesFromServer({groupID:t,avChatRoomKey:o}),i=Le.getGroupAttributesCacheValues(e),{serverGroupAttributeList:n=[]}=r||{};return ye({groupAttributes:i},{message:u,moreMessage:`from server, count:${n.length}`})}catch(e){throw new s({functionName:"getGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}const a=Le.getGroupAttributesCacheValues(e);return ye({groupAttributes:a},{message:u,moreMessage:"from cache"})})}getGroupAttributesFromServer(e){return ve(this,void 0,void 0,function*(){const{utils:{isUndefined:t},ssoLog:o}=this._core,{groupID:r,avChatRoomKey:i}=e,n=t(i)?P:N,s=yield function(e,t){return ve(this,void 0,void 0,function*(){const{groupID:o,groupType:r,avChatRoomKey:i}=e,n={GroupId:o,GroupType:r,Key:i};return t.common.buildAndSendPacket({servcmd:"group_open_attr_http_svc.get_group_attr",data:n})})}({groupID:r,avChatRoomKey:i,groupType:n},this._core),{AttrMainSeq:u=0,GroupAttrAry:a}=s||{};o.debug("getGroupAttributesFromServer",`${this._name}._getGroupAttributesFromServer ok. groupID:${r} serverMainSequence:${u}`);const c=a.map(e=>{const{key:t,value:o,seq:r}=e;return{key:t,value:o,sequence:r}});return Le.refreshGroupAttributesCache({groupID:r,serverMainSequence:u,groupAttributeList:c,operation:E}),{serverGroupAttributeList:a}})}};var it=new class{init(e){e.ssoLog.debug("GroupAttribute.init"),et.init(e),tt.init(e),ot.init(e),rt.init(e),Le.init(e)}isGroupAttributesUpdated(e){return Le.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:o}}=e,{groupAttributeOption:r}=o,{serverMainSequence:i,withChangedAttributeInfo:n}=r,{localMainSequence:s}=Le.getGroupAttributesCache(t),u=i-s;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${n} diffSequence:${u}`),0!==u)if(Le.saveGroupAttributesCacheValuesCopy(t),1!==n||1!==u){if(Le.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=Le.getGroupAttributesCache(t);rt.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{Le.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else Le.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:r})}reset(){Le.reset()}};function nt(e,t="tips"){const{ClientSeq:o,From_Account:r,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:c,ToGroupId:p,GroupInfo:l,MsgBody:m}=e,h=function(e){const{GroupCode:t,GroupId:o,GroupName:r,GroupType:i,MsgFrom_AccountExtraInfo:n,From_Account:s,To_Account:u}=e;return{groupCode:t,groupID:o,groupName:r,type:i,messageFromAccountExtraInformation:n,from:s,to:u}}(l);return{clientSequence:o,from:r,clientTime:i,priority:n,random:s,sequence:u,time:a,tinyID:c,to:p,groupProfile:h,elements:"tips"===t?st(m):at(m)}}function st(e){const t={};return Object.keys(e).forEach(o=>{var r,i;switch(o){case"MemberNum":t.memberCount=e[o];break;case"OpType":t.operationType=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"List_Account":t.userIDList=e[o];break;case"MsgMemberExtraInfo":t.memberInfoList=null===(r=e[o])||void 0===r?void 0:r.map(e=>ut(e));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=ut(e[o]);break;case"MsgGroupNewInfo":t.newGroupProfile=function(e){const t={};return Object.keys(e).forEach(o=>{switch(o){case"GroupIntroduction":t.introduction=e[o];break;case"GroupName":t.groupName=e[o];break;case"GroupFaceUrl":t.avatar=e[o];break;case"GroupNotification":t.notification=e[o];break;case"ApplyJoinOption":t.joinOption=e[o];break;case"InviteJoinOption":t.inviteOption=e[o];break;case"ShutupAll":t.muteAllMembers=e[o];break;case"Owner_Account":t.ownerID=e[o];break;case"GroupAttrOption":t.groupAttributeOption=function(e){const{BytesChangedKeys:t,GroupAttrSeq:o,OpType:r,PushChangedAttrValFlag:i,GroupAttrInfo:n}=e,s=n.map(e=>{const{Key:t,Val:o,SubKeySeq:r}=e;return{key:t,value:o,sequence:r}});return{changedKeyList:t,groupAttributeList:s,serverMainSequence:o,operation:r,withChangedAttributeInfo:i}}(e[o])}}),t}(e[o]);break;case"MsgMemberInfo":t.msgMemberInfo=null===(i=e[o])||void 0===i?void 0:i.map(e=>function(e){const{ShutupTime:t,User_Account:o}=e;return{muteTime:t,userID:o}}(e));break;case"OnlineMemberInfo":t.onlineMemberInfo=function(e){const{ExpireTime:t,OnlineMemberNum:o}=e;return{expireTime:t,onlineMemberNum:o}}(e[o]);break;case"GroupCounterInfo":t.groupCounterInfo=function(e){return e.map(e=>{const{GroupCounterSeq:t,GroupCounter:o,Type:r}=e;return{type:r,groupCounterSeq:t,counterList:o}})}(e[o])}}),t}function ut(e){const{ImageUrl:t,NickName:o,Role:r,UserId:i}=e;return{avatar:t,nick:o,role:r,userID:i}}function at(e){const t={};return Object.keys(e).forEach(o=>{switch(o){case"MsgKey":t.messageKey=e[o];break;case"Operator_Account":t.operatorID=e[o];break;case"ReportType":t.operationType=e[o];break;case"Authentication":t.authentication=e[o];break;case"MsgFlag":t.messageRemindType=e[o];break;case"UserDefinedField":t.userDefinedField=e[o];break;case"RemarkInfo":t.remarkInfo=e[o];break;case"BanDuration":t.duration=e[o];break;case"MuteTime":t.muteTime=e[o]}}),t}class ct{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(t)}static parseServerPushElement(e){const t=st(e);return new ct(t)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"groupProfile":this._initGroupProfile(e[t]);break;case"operatorInfo":this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"newGroupProfile":this._initNewGroupProfile(e[t]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[t]=e[t]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];F[r]&&(this.content.groupProfile[r]=e[r])}}_initOperatorInfo(e){this.content.operatorInfo={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];this.content.operatorInfo[r]=e[r]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})}):this.content.memberList=e}_initNewGroupProfile(e){this.content.newGroupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];"muteAllMembers"!==r?this.content.newGroupProfile[r]=e[r]:this.content.newGroupProfile.muteAllMembers=1===e.muteAllMembers}}}var pt=new class{constructor(){this._name="GroupTipsNotification"}init(e){this._core=e;const{common:{workflowManager:t},constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:r}}=e,{message:{messageFactory:i},OuterConstant:n}=e;null==i||i.registerElementClass(n.MSG_GRP_TIP,ct),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.GROUP_TIPS_RECOVER,this._handleGroupTipsRecover,this),t.registerWorkflowStep(o.RECEIVE_GROUP_TIPS_NOTIFICATION,r.HANDLE_GROUP_TIPS_NOTIFICATION,this.onNewGroupTips,this)}onNewGroupTips(e){const{data:t}=e||{},{messageList:o,conversationUpdateFieldList:r}=this._handleGroupTips(t),{notificationCenter:i,OuterEvent:n,appStore:{conversationStore:s}}=this._core;return null==r||r.forEach(e=>{const{conversationID:t,lastMessage:o,unreadCount:r}=e,{unreadCount:i=0}=s.getConversation(t)||{};s.updateConversation(t,{lastMessage:o,unreadCount:r+i})}),o.length>0&&(i.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:o}),this._handleGroupTipMessage(o)),{conversationUpdateFieldList:r}}_handleGroupTips(e,t=!0){const{Event:o,GroupTips:r}=e,i=new Map,n=[],s=[];for(let e=0,n=r.length;e<n;e++){const n=nt(r[e],"tips");if(o===U){if(it.isGroupAttributesUpdated(n)){it.handleGroupAttributesUpdated(n);continue}if(Ze.isGroupCounterUpdated(n)){Ze.handleGroupCounterUpdated(n);continue}}const{groupProfile:{groupID:u}}=n;if(!be.hasLocalGroup(u))continue;const a=this._assembleMessage(n);if(o===U&&(a._onlineOnlyFlag=!0,s.push(a)),o===R){if(!this._core.message.messageDataHandler.storeConversationMessage(a)&&t)continue;s.push(a)}this._handleConversationOptions(i,a)}return n.push(...i.values()),{conversationUpdateFieldList:n,messageList:s}}_assembleMessage(e){const{OuterConstant:t,message:{messageFactory:o}}=this._core;e.flow="in",e.conversationType=t.CONV_GROUP;const r=o.createMessage(e);this._patchNickAndAvatar(e.elements,r);const i=new ct(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));return r.setElement(i),r.isSystemMessage=!1,r}_patchNickAndAvatar(e,t){const{utils:{isEmpty:o},OuterConstant:{GROUP_TIPS_OPERATION_TYPE:r}}=this._core,{operationType:i,memberInfoList:n,operatorInfo:s}=e;let u={};if(o(n)?o(s)||(u=s):i!==r.JOINED&&i!==r.KICKED&&i!==r.ADMIN_SET&&i!==r.ADMIN_CANCELED||(u=Object.assign({},n[0])),!o(u)){const{nick:e="",avatar:o=""}=u;t.nick=e,t.avatar=o}}_handleConversationOptions(e,t){const{common:{getMessagePreviewText:o},utils:{isObject:r}}=this._core,{conversationID:i,conversationType:n}=t;let s;if(e.has(i))s=e.get(i),"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||s.unreadCount++),s.type=n,s.lastMessage=t._isExcludedFromLastMessage?"":Object.assign({},t);else{let e=0;"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1)),s={conversationID:i,unreadCount:e,type:n,lastMessage:t._isExcludedFromLastMessage?"":Object.assign({},t)}}r(s.lastMessage)&&(s.lastMessage.messageForShow=o(s.lastMessage.type,s.lastMessage.payload)),e.set(i,s)}_handleGroupTipMessage(e){const{OuterConstant:{GROUP_TIPS_OPERATION_TYPE:t}}=this._core;e.forEach(e=>{const{operationType:o}=e.payload;switch(o){case t.JOINED:this._handleNewMemberJoined(e);break;case t.QUITTED:this._handleMemberQuitted(e);break;case t.KICKED:this._handleMemberKicked(e);break;case t.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(e)}})}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){var t;const{newGroupProfile:o,groupProfile:r,operatorInfo:i}=e.payload,{groupID:n}=r,s=be.getLocalGroup(n);Object.keys(o).forEach(e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(n,o);break;case"groupName":s.name=o[e];break;default:s[e]=o[e]}});const{utils:{isUndefined:u}}=this._core;u(i)||(null===(t=null==s?void 0:s.selfInfo)||void 0===t?void 0:t.userID)!==i.userID||Object.keys(i).forEach(e=>{"nameCard"===e&&s.updateSelfInfo({nameCard:i[e]}),"role"===e&&this._updateSelfRole(s,i[e])}),be.emitGroupListUpdate(),be.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){const{common:o,OuterConstant:r}=this._core,i=be.getLocalGroup(e),n=o.getCurrentUserID(),{ownerID:s}=t;n===s&&i.updateGroup({ownerID:s,selfInfo:{role:r.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){const{OuterConstant:o}=this._core;let r=o.GRP_MBR_ROLE_MEMBER;t===k?r=o.GRP_MBR_ROLE_OWNER:t===$&&(r=o.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:r})}_handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:o}}=e.payload,r=be.getLocalGroup(o),{utils:{isNumber:i}}=this._core;r&&i(t)&&r.memberCount!==t&&(r.memberCount=t,be.emitGroupListUpdate(),be.updateConversationGroupProfile(o))}_handleGroupTipsRecover(e){const{utils:{isArray:t}}=this._core,{groupTipList:o}=(null==e?void 0:e.result)||{};t(o)&&o.forEach(e=>{const{messageList:t}=this._handleGroupTips({Event:e.Event,GroupTips:[e]},!1);this._handleGroupTipMessage(t)})}};class lt{constructor(t){this.type=e.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}static parseServerPushElement(e){const t=at(e);return new lt(t)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this._initGroupProfile(e[t]);break;case"memberInfoList":break;default:this.content[t]=e[t]}})}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let o=0;o<t.length;o++){const r=t[o];q[r]&&(this.content.groupProfile[r]=e[r])}}}var mt=new class{constructor(){this._name="GroupSystemNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:{MSG_GRP_SYS_NOTICE:o}}=e;null==t||t.registerElementClass(o,lt)}onNewGroupSystemNotification(e){const{GroupTips:t=[],isInstantMessage:o=!0}=e;this._core.ssoLog.debug("onNewGroupSystemNotification",` count:${t.length} isInstantMessage:${o}`);const{conversationUpdateFieldList:r,messageList:i}=this._handleGroupSystemNotification(t,o),{notificationCenter:n,OuterEvent:s}=this._core;r.length>0&&this._handleGroupSysTemMessage(o,i),!0===o&&i.length>0&&n.emitOuterEvent(s.MESSAGE_RECEIVED,{name:s.MESSAGE_RECEIVED,data:i})}_handleGroupSystemNotification(e,t){const o=[];let r={};for(let i=0;i<e.length;i++){const n=nt(e[i],"system"),{elements:{operationType:s}}=n;if(s===B)continue;const u=this._assembleMessage(n);this._core.message.messageDataHandler.storeConversationMessage(u)&&(o.push(u),r=this._handleConversationOptions(u,t))}return r.lastMessage=o[o.length-1],{conversationUpdateFieldList:o.length>0?[r]:[],messageList:o}}_assembleMessage(e){const{message:{messageFactory:t},OuterConstant:o,utils:{randomInt:r}}=this._core;e.flow="in",e.conversationType=o.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=o.CONV_SYSTEM;const i=t.createMessage(e),n=new lt(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));i.setElement(n),i.isSystemMessage=!0;const s=1===i.sequence&&1===i.random,u=2===i.sequence&&2===i.random;return(s||u)&&(i.sequence=r(),i.random=r(),i.generateMessageID()),i}_handleConversationOptions(e,t){const{OuterConstant:o}=this._core,r={conversationID:o.CONV_SYSTEM,unreadCount:0,type:o.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&r.unreadCount++,r}_handleGroupSysTemMessage(e,t){e&&t.forEach(e=>{const{operationType:t}=e.payload;switch(t){case j:this._handleGroupJoinResult(e);break;case K:this._handleMemberKicked(e);break;case x:this._handleGroupDismissed(e);break;case V:this._handleGroupInvitedResult(e);break;case J:this._handleGroupQuitResult(e);break;case H:this._handleMessageRemindTypeSynced(e);break;case W:this._handleAVChatRoomMemberBanned(e)}})}_handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:o,type:r}=t,i=be.hasLocalGroup(o);this._core.ssoLog.debug("_handleGroupJoinResult",` groupID:${o} type:${r} hasLocalGroup:${i}`),i||le(r)||(be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate())}_handleMemberKicked(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupDismissed(e){const{groupProfile:{groupID:t,type:o}}=e.payload;be.hasLocalGroup(t)&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:o}=t,r=be.hasLocalGroup(o);this._core.ssoLog.debug("_handleGroupInvitedResult",` groupID:${o} hasLocalGroup:${r}`),r||Se.getGroupProfile({groupID:o}).then(e=>{const{data:{group:t}}=e;be.updateLocalGroup([Object.assign({},t)]),be.emitGroupListUpdate()})}_handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:o}}=e.payload,r=be.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupQuitResult",` groupID:${t} type:${o} hasLocalGroup:${r}`),r&&this._deleteLocalGroup(t,o),this._updateConversationProfile(t,{unreadCount:0})}_handleMessageRemindTypeSynced(e){const{groupProfile:{groupID:t},messageRemindType:o}=e.payload;this._updateConversationProfile(t,{messageRemindType:o})}_handleAVChatRoomMemberBanned(e){const{groupProfile:{groupID:t,type:o}}=e.payload;this._deleteLocalGroup(t,o)}_deleteLocalGroup(e,t){if(le(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core;t.deleteConversation(`${o}${e}`)}be.deleteLocalGroup(e),be.emitGroupListUpdate()}_updateConversationProfile(e,t){const{appStore:{conversationStore:o},OuterConstant:{CONV_GROUP:r}}=this._core,i=`${r}${e}`;o.getConversation(i)&&o.updateConversation(i,t)}};var ht=new class{init(e){this._core=e,e.ssoLog.debug("GroupNotificationHandler.init"),pt.init(e),mt.init(e);const{notificationCenter:t,InnerEvent:o}=e,{InnerEventSubType:r}=t;t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),t.subscribeInnerEvent(o.MESSAGE_PUSH,r.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),t.subscribeInnerEvent(o.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){const{common:{workflowManager:t},constants:{WORKFLOW_NAME:o}}=this._core;t.executeWorkflow(o.RECEIVE_GROUP_TIPS_NOTIFICATION,e)}_onNewGroupSystemNotification(e){mt.onNewGroupSystemNotification(e)}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:o}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,o.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};const dt={required:!0,rules:["string"],allowEmpty:!1},gt={required:!0,rules:["number"],allowEmpty:!1},_t={required:!0,rules:["array"],allowEmpty:!1},ft={required:!0,rules:["object"],allowEmpty:!1},Gt={createGroup:{name:dt,type:dt},dismissGroup:[Object.assign({key:"groupID"},dt)],joinGroup:{groupID:dt,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},dt)],searchGroupByID:[Object.assign({key:"groupID"},dt)],getGroupProfile:{groupID:dt,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:dt,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:dt,newOwnerID:dt},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},dt)],handleGroupApplication:{handleAction:dt},getGroupMemberList:{groupID:dt},getGroupMemberProfile:{groupID:dt,userIDList:_t,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:dt,userIDList:_t},deleteGroupMember:{groupID:dt,userIDList:_t},setGroupMemberMuteTime:{groupID:dt,userID:dt,muteTime:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:dt,userID:dt,role:dt},setGroupMemberNameCard:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:dt},setGroupMemberCustomField:{groupID:dt,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:_t},markGroupMemberList:{groupID:dt,markType:Object.assign(Object.assign({},gt),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:_t},initGroupAttributes:{groupID:dt,groupAttributes:ft},setGroupAttributes:{groupID:dt,groupAttributes:ft},deleteGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupAttributes:{groupID:dt,keyList:Object.assign(Object.assign({},_t),{allowEmpty:!0})},getGroupCounters:{groupID:dt,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:dt,counters:ft},increaseGroupCounter:{groupID:dt,key:dt,value:gt},decreaseGroupCounter:{groupID:dt,key:dt,value:gt}},bt={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};var It=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=be,this.groupAction=Ue,this.groupAttribute=it,this.groupMember=Qe,this.name="Group"}install(t,o=[]){this._core=t,e.init(t),be.init(t),Ue.init(t,this),Qe.init(t,this),Fe.init(t),Ze.init(t),it.init(t),ht.init(t),t.helper.registerValidateConfig({auth:bt,params:Gt}),this._installSubPlugins(o);const{notificationCenter:r,InnerEvent:i}=t;r.subscribeInnerEvent(i.LOGOUT,this._reset,this),r.subscribeInnerEvent(i.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){const{utils:{isArray:t}}=this._core;e&&t(e)&&e.forEach(e=>{var t;this._installedSubPlugins.includes(e.name)||(null===(t=e.install)||void 0===t||t.call(e,this._core,this),this._installedSubPlugins.push(e.name))})}_reset(){be.reset(),it.reset(),Ze.reset()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};export{It as default};
|