@tencentcloud/lite-chat 1.5.2 → 1.6.0
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/CHANGELOG.md +11 -0
- package/basic.es.js +1 -3
- package/basic.js +1 -3
- package/package.json +1 -1
- 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 -3
- package/plugins/message-enhancer.js +1 -3
- 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.es.js +1 -5
- package/professional.js +1 -5
- package/standard.es.js +1 -5
- package/standard.js +1 -5
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",n="Set",i="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",I=10018,v=11e3,b=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,$=6,k=400,U=300,q={from:!0,groupID:!0,groupName:!0,to:!0},F={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,ne=2683,ie=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 Ie=new class{constructor(){this._name="GroupDataHandler"}init(e){var e=(this._core=e)["appStore"]["groupStore"];this._groupMap=e.getGroupMap(),console.log(this._name+".init")}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 ve(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 be(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 Ce(s,u){return be(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){return{code:0,data:e||{}}};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 be(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}),Ie.updateLocalGroup(e),Ie.getLocalGroupList()}return console.log(this._name+".getGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===G||this._pagingStatus===_?this._syncGroupList().then(()=>{var e=Ie.getLocalGroupList();return ye({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw console.error(this._name+".getGroupList fail:",e),e}):(e=Ie.getLocalGroupList(),console.log(this._name+".getGroupList return group count:"+e.length),ye({groupList:e,isSyncCompleted:this._isSyncCompleted()}))})}_syncGroupList(){return be(this,void 0,void 0,function*(){this._pagingStatus===_&&Ie.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),Ie.updateLocalGroup(t);var r=Ie.getLocalGroupList();return console.log(this._name+"._syncGroupList ok, count:"+r.length),Ie.emitGroupListUpdate(),r}catch(e){throw this._pagingStatus=G,console.error(this._name+"._syncGroupList fail:",e),e}})}_pagingGetGroupList(e){return be(this,void 0,void 0,function*(){var{isCommunityRelay:u=!1,groupList:a}=e;let l,{limit:c,offset:h}=e;var d=[...p];u&&(l=this._core.OuterConstant.GRP_COMMUNITY,d.push("AtInfoList"));try{let e=yield Ce({type:l,limit:c,offset:h,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:d,SelfInfoFilter:[...m]}},this._core),{GroupIdList:t=[],TotalCount:r=0}=e||{},o=this._convertGroupKey(t),i=(a.push(...o),h+c),n=!(r>i),s=`offset:${h} limit:${c} total:${r} isCompleted:${n} current:${a.length} isCommunityRelay:`+u;return console.log(this._name+"._pagingGetGroupList ok. "+s),u?n?a:(h=i,this._pagingGetGroupList({isCommunityRelay:!0,limit:c,offset:h,groupList:a})):n?(console.log(this._name+"._pagingGetGroupList start to get community list"),h=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:c,offset:h,groupList:a})):(h=i,this._pagingGetGroupList({limit:c,offset:h,groupList:a}))}catch(e){if(e.ErrorCode===I)return console.warn(this._name+"._pagingGetGroupList response size exceeds the limit, request count:"+c),this._pagingGetGroupList({isCommunityRelay:u,limit:50,offset:h,groupList:a});if(u)return e.code===v&&console.log(this._name+"._pagingGetGroupList ok. community unavailable"),a;throw e}})}_pagingGetJoinedCommunityList(e){return be(this,void 0,void 0,function*(){var{common:{getCurrentUserID:i},OuterConstant:n}=this._core,s=e["groupList"];let{limit:u,offset:a}=e;try{let e=yield Ce({limit:u,offset:a,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);s.push(...o);var l=a+u,c=!(l<r),h=`offset:${a} limit:${u} total:${r} isCompleted:${c} current:`+s.length;return console.log(this._name+"._pagingGetJoinedCommunityList ok. "+h),c?s:(a=l,this._pagingGetJoinedCommunityList({limit:u,offset:a,groupList:s}))}catch(e){if(e.code===ce)return console.warn(this._name+"._pagingGetJoinedCommunityList response size exceeds the limit, request count:"+u),this._pagingGetJoinedCommunityList({limit:50,offset:a,groupList:s});throw e}})}_groupListTreeShaking(r){var o=new Map([...Ie.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++)Ie.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:l,LastInfoTime:c,LastMsgTime:m,MemberNum:h,MaxMemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:v,Owner_Account:I,Type:G,LastRecallTime:b,SelfInfo:C,AtInfoList:y=[],SupportTopic:A}=r[e],i=he(i),C=this._convertSelfInfo(C),y=this._convertAtInfoList(a,y);o.push({groupCustomField:i,joinOption:n,createTime:s,avatar:u,groupID:a,introduction:p,inviteOption:l,lastInfoTime:c,lastMsgTime:m,memberCount:h,maxMemberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:v,ownerID:I,type:G,selfInfo:C,_lastRevokedTime:b,_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 be(this,void 0,void 0,function*(){var n;this._preCheckParams(a);let{ssoLog:e,helper:{ChatError:o}}=this._core,s=e.createSSOLogData({method:"createGroup"});try{let{utils:{isEmpty:e},common:{getCurrentUserID:t}}=this._core,r=yield function(h,d){return be(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:l,isSupportTopic:c}=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:l,SupportTopic:c,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||{};s.setLogInfo({message:"groupID:"+o}).end(),console.log(`${this._name}.createGroup ok, type:${a.type} groupID:${o} overLimitUserIDList:`+i),e(a.memberList)||e(i)||(a.memberList=null==(n=a.memberList)?void 0:n.filter(e=>i.includes(e.userID))),Ie.updateLocalGroup([Object.assign(Object.assign({},a),{groupID:o})]);var u=Ie.getLocalGroup(o);return this._notNeedSendCustomMessage(a)||(this._sendCustomMessage(o,a.type),Ie.emitGroupListUpdate()),ye({group:u})}catch(n){let{errorCode:e,errorInfo:t}=n,r=new o({functionName:"createGroup",code:e,message:t});throw s.setLogInfo({message:"groupID:"+(a.groupID||"")}).setError(r).end(),console.error(this._name+".createGroup fail:",r),r}})}_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=(console.log(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}),console.log(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),console.log(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);console.log(`${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(t){return be(this,void 0,void 0,function*(){console.log(this._name+".dismissGroup groupID:"+t);let{ssoLog:e,helper:{ChatError:i}}=this._core,n=e.createSSOLogData({method:"dismissGroup"});n.setLogInfo({message:"groupID:"+t});try{yield function(e,t){return be(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:{GroupId:e}})})}(t,this._core),n.end(),console.log(this._name+".dismissGroup ok.");let e=Ie.getLocalGroup(t)["type"];return Ie.deleteLocalGroup(t),Ie.emitGroupListUpdate(),Le.deleteGroupAttributesCache(t),ye({groupID:t,type:e})}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"dismissGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".dismissGroup fail:",o),o}})}},Se=new class{constructor(){this._name="GetGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(r){return be(this,void 0,void 0,function*(){let{groupID:i,groupCustomFieldFilter:e}=r,n={groupIDList:[i],responseFilter:{GroupBaseInfoFilter:[...p],AppDefinedDataFilter_Group:e,MemberInfoFilter:[...h]}},{ssoLog:t,helper:{ChatError:s}}=this._core,u=t.createSSOLogData({method:"getGroupProfile"});u.setLogInfo({message:"groupID:"+i});try{let e=yield this.getGroupProfileAdvance(n),{successGroupList:t,failureGroupList:r}=e;if(0<r.length)throw r[0];let o;return(o=!Ie.hasLocalGroup(i)&&le(t[0].type)?new Ge(t[0]):(Ie.updateLocalGroup(t),Ie.getLocalGroup(i))).isSupportTopic||Ie.updateConversationGroupProfile(i),u.end(),console.log(this._name+".getGroupProfile ok."),ye({group:o})}catch(e){let{code:t,message:r}=e,o=new s({functionName:"getGroupProfile",code:t,message:r});throw u.setError(o).end(),console.error(this._name+".getGroupProfile fail:",o),e}})}getGroupProfileAdvance(u){return be(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 be(this,void 0,void 0,function*(){let{isCommunityProfile:t=!1}=e,s=ve(e,["isCommunityProfile"]);if(0===s.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{let e=yield function(r,o){return be(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}})})}(s,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),{isUndefined:o}=this._core["utils"],i=r.filter(e=>o(e.errorCode)||0===e.errorCode),n=r.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return console.log(this._name+"._getGroupProfileAdvance ok, groupID:"+s.groupIDList.join(",")),{successGroupList:i,failureGroupList:n}}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:l,InviteJoinOption:c,LastInfoTime:m,LastMsgTime:h,MaxMemberNum:d,MemberNum:g,MuteAllMember:_,Name:f,NextMsgSeq:v,Notification:I,Owner_Account:G,ShutUpAllMember:b,ShutUpUntil:C,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:l,inviteOption:c,lastInfoTime:m,lastMsgTime:h,maxMemberCount:d,memberCount:g,muteAllMembers:_,name:f,nextMessageSeq:v,notification:I,ownerID:G,shutUpAllMember:b,muteUntil:C,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:l}=r[e],i=he(i);o.push({memberCustomField:i,joinTime:n,userID:s,messageRemindType:u,sequence:a,nameCard:p,role:l})}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(s){return be(this,void 0,void 0,function*(){let t=s["groupID"],{ssoLog:r,helper:{ChatError:i},OuterConstant:o}=this._core,n=r.createSSOLogData({method:"joinGroup"});try{if(Ie.hasLocalGroup(t))try{return yield Se.getGroupProfile({groupID:t}),n.setLogInfo({message:`groupID:${t} joinedStatus:`+o.JOIN_STATUS_ALREADY_IN_GROUP}).end(),ye({status:o.JOIN_STATUS_ALREADY_IN_GROUP,group:Ie.getLocalGroup(t)})}catch(r){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),Ie.deleteLocalGroup(t);let e=yield this._applyJoinGroup(s);return n.setLogInfo({message:"groupID:"+t}).end(),e}let e=yield this._applyJoinGroup(s);return n.setLogInfo({message:"groupID:"+t}).end(),e}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"joinGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".joinGroup fail:",o),o}})}_applyJoinGroup(m){return be(this,void 0,void 0,function*(){var{OuterConstant:e,helper:t}=this._core,r=m["groupID"],i=Object.assign({},m),t=t.checkBusinessCapabilityBits(o),i=(t&&(i.historyMessageFlag=1),yield function(o,i){return be(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}})})}(i,this._core)),{Type:i,JoinedStatus:n,LongPollingKey:s,StartSeq:u,HugeGroupFlag:a,AVChatRoomKey:p,RspMsgList:l=[]}=i||{},t=`groupID:${r} joinedStatus:${n} longPollingKey:${s} startSeq:${u} avChatRoomFlag:${a} canGetAVChatRoomHistoryMsg:${t}, historyMessageCount:`+l.length;console.log(this._name+"._applyJoinGroup ok, "+t);let c=new Ge({groupID:r,type:i});if(n===e.JOIN_STATUS_WAIT_APPROVAL)return ye({status:e.JOIN_STATUS_WAIT_APPROVAL,group:c});if(n!==e.JOIN_STATUS_SUCCESS)throw new this._core.helper.ChatError({code:te});try{c=(yield Se.getGroupProfile({groupID:r})).data.group}catch(e){console.warn(this._name+`._applyJoinGroup getGroupProfile failed, groupID: ${r}, errorCode:`,null==e?void 0:e.code)}return this._handleJoinResult({group:c,avChatRoomFlag:a,longPollingKey:s,startSequence:u,avChatRoomKey:p,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)):(Ie.updateLocalGroup([t]),Ie.emitGroupListUpdate(),ye({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}},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(t){return be(this,void 0,void 0,function*(){if(!Ie.hasLocalGroup(t))throw new this._core.helper.ChatError({code:ee});let{ssoLog:e,helper:{ChatError:i}}=this._core,n=e.createSSOLogData({method:"quitGroup"});n.setLogInfo({message:"groupID:"+t});try{yield function(e,t){return be(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:{GroupId:e}})})}(t,this._core),n.end(),console.log(this._name+".quitGroup ok, groupID:"+t);let e=Ie.getLocalGroup(t)["type"];return Ie.deleteLocalGroup(t),Ie.emitGroupListUpdate(),Le.deleteGroupAttributesCache(t),ye({groupID:t,type:e})}catch(e){let{errorCode:t,errorInfo:r}=e,o=new i({functionName:"quitGroup",code:t,message:r});throw n.setError(o).end(),console.error(this._name+".quitGroup fail:",o),o}})}},Ee=new class{constructor(){this._name="SearchGroup"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(v){return be(this,void 0,void 0,function*(){console.log(this._name+".searchGroupByID groupID:"+v);try{var e=yield function(t,r){return be(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})})}(v,this._core),{GroupInfo:t=[]}=e||{},{AppDefinedData:r=[],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}=t[0];if(0!==d)throw new this._core.helper.ChatError({code:d,message:g});console.log(this._name+".searchGroupByID ok.");var _=he(r),f=new Ge({groupID:v,name:c,avatar:n,introduction:s,joinOption:o,inviteOption:u,maxMemberCount:a,memberCount:p,type:h,ownerID:m,createTime:i,groupCustomField:_});return ye({group:f})}catch(e){throw console.error(this._name+".searchGroupByID fail:",e),e}})}},Ne=new class{constructor(){this._name="UpdateGroupProfile"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(i){return be(this,void 0,void 0,function*(){let t=i["groupID"],{isUndefined:r}=this._core["utils"],o=Ie.getLocalGroup(t);if(o){let e=o["type"];this._canIUseJoinOption(e)||r(i.joinOption)||(console.warn(this._name+".updateGroupProfile joinOption is unavailable for Work/Meeting/AVChatRoom"),i.joinOption=void 0)}r(i.muteAllMembers)||(i.muteAllMembers=!0===i.muteAllMembers?"On":"Off");try{return yield function(p,l){return be(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 l.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:e})})}(i,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),o?(o.updateGroup(i),Ie.emitGroupListUpdate()):o=new Ge(i),ye({group:o})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}})}_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(u){return be(this,void 0,void 0,function*(){let r="changeGroupOwner",{groupID:e,newOwnerID:t}=u,o=Ie.getLocalGroup(e),{helper:i,OuterConstant:n,common:{getCurrentUserID:s}}=this._core;if((null==o?void 0:o.type)===n.GRP_AVCHATROOM)throw new i.ChatError({functionName:r,code:X});if(t===s())throw new i.ChatError({functionName:r,code:Z});console.log(`${this._name}.${r} groupID:${e} newOwnerID:`+t);try{return yield function(r,o){return be(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}})})}(u,this._core),console.log(this._name+`.${r} ok.`),o.ownerID=t,Ie.emitGroupListUpdate(),ye({group:o})}catch(e){let t=new i.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}},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(i){return be(this,void 0,void 0,function*(){let r="getGroupOnlineMemberCount",e=Ie.hasLocalGroup(i);if(console.log(`${this._name}.${r} groupID:${i} hasLocalGroup:`+e),!e)return ye({memberCount:0});let o=Date.now();if(this._onlineMemberCountMap.has(i)){let e=this._onlineMemberCountMap.get(i),{lastReqTime:t=0,memberCount:r=0}=e||{};if(o-t<=6e4)return ye({memberCount:r})}try{let e=yield function(e,t){return be(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:{GroupId:e}})})}(i,this._core),{OnlineMemberNum:t=0}=e||{};return this._onlineMemberCountMap.set(i,{lastReqTime:Date.now(),memberCount:t}),console.log(`${this._name}.${r} ok. groupID:${i} memberCount:`+t),ye({memberCount:t})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${r} fail:`,t),t}})}},$e=new class{init(e,t){console.log("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 be(this,void 0,void 0,function*(){var t="getGroupApplicationList";try{var r=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]),e=(console.log(this._name+`.${t} ok.`),this._handleGroupApplicationResult([...r[0],...r[1]]));return ye({applicationList:e})}catch(e){r=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${t} fail:`,r),r}})}_getGroupApplicationList(n){return be(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 be(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=ve(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}}},Ue=new class{constructor(){this._name="HandleGroupApplication"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return be(this,void 0,void 0,function*(){let r="handleGroupApplication",t=e["application"],o=this._handleParams(e);try{(null==t?void 0:t.applicationType)===b?yield function(s,u){return be(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}})})}(o,this._core):yield function(s,u){return be(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}})})}(o,this._core),console.log(this._name+`.${r} ok.`);let e=Ie.getLocalGroup(o.groupID);return ye({group:e})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_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)===b&&(a=o.userID),{handleAction:e,handleMessage:t,applicant:i,invitee:a,groupID:n,authentication:s,messageKey:u}}},qe=new class{init(e){console.log("GroupApplication.init"),ke.init(e),Ue.init(e)}};let Fe=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 be(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 be(this,void 0,void 0,function*(){let n="getGroupMemberList",{groupID:s,offset:u=0,count:e=100,role:t="",filter:r=""}=o;console.log(`${this._name}.${n} groupID:${s} offset:${u} count:${e} role:${t} filter:`+r);var a=Ie.getLocalGroup(s),p=100<e?100:e,l={groupID:s,offset:u,limit:p,memberRoleFilter:C.includes(t)?[t]:void 0,memberInfoFilter:y};try{let e=yield function(n,s){return be(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}})})}(l,this._core),{MemberList:t,MemberNum:r,Next:o}=e||{};console.log(`${this._name}.${n} ok, totalMemberCount:${r} next:`+o);var{utils:{isArray:c,isEmpty:m},common:{isCommunity:h}}=this._core;if(a&&(a.memberCount=r),!c(t)||0===t.length)return ye({memberList:[],offset:0});let i=u+p;h({groupID:s})&&(i=m(o)?0:o),t.length<p&&(i=0);var d=this._convertMemberInfo(t),d=yield this._patchAvatarAndNick(d),g=this._generateGroupMember(d);return ye({memberList:g,offset:i})}catch(e){let t=new this._core.helper.ChatError({functionName:n,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${n} fail:`,t),t}})}_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}=r[e],i=he(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_patchAvatarAndNick(n){return be(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 Fe(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(t){return be(this,void 0,void 0,function*(){let r="getGroupMemberProfile",{groupID:o,userIDList:i,memberCustomFieldFilter:n}=t,e=Ie.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(e&&le(e.type))throw new s.ChatError({functionName:r,replacement1:r,code:ue});50<i.length&&(console.warn(`${this._name}.${r} userIDList length:${i.length} exceeds limit 50`),i.splice(50));try{let e=yield function(i,n){return be(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=(console.log(this._name+`.${r} ok.`),e||{})["MemberList"];var a,p;return u(t)&&0!==t.length?(a=this._convertMemberInfo(t),a=yield this._getMemberAvatarAndNick(a),p=this._generateGroupMember(a),ye({memberList:p})):ye({memberList:[]})}catch(e){let t=new s.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_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}=r[e],i=he(i);o.push({userID:s,joinTime:n,onlineStatus:u,role:a,muteUntil:p,memberCustomField:i})}return o}_getMemberAvatarAndNick(n){return be(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 Fe(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(t){return be(this,void 0,void 0,function*(){let s="addGroupMember",{groupID:u,userIDList:e}=t,a=Ie.getLocalGroup(u),r=this._core["helper"];if(a&&le(a.type))throw new r.ChatError({functionName:s,code:oe});var p=e.map(e=>({Member_Account:e}));try{let e=yield function(r,o){return be(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:u,userIDList:p},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n}=this._handleResult(t);return console.log(`${this._name}.${s} groupID:${u} ok, successUserIDList:${o} failureUserIDList:${r} existedUserIDList:${i} overLimitUserIDList:`+n),ye({failureUserIDList:r,successUserIDList:o,existedUserIDList:i,overLimitUserIDList:n,group:a})}catch(e){let t=new r.ChatError({functionName:s,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${s} fail:`,t),t}})}_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(s){return be(this,void 0,void 0,function*(){let r="deleteGroupMember",{groupID:e,userIDList:t}=s,o=Ie.getLocalGroup(e),{helper:i,utils:{isUndefined:n}}=this._core;if(n(o))throw new i.ChatError({functionName:r,code:z});20<t.length&&(console.warn(`${this._name}.${r} userIDList length:${t.length} exceeds limit 20`),t.splice(20));try{return yield function(o,i){return be(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:t},this._core),console.log(`${this._name}.${r} ok, groupID:${e} userIDList length:`+t.length),ye({group:o,userIDList:t})}catch(e){let t=new i.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}},Be=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(s){return be(this,void 0,void 0,function*(){let o="setGroupMemberMuteTime",t=this._core["helper"];this._preCheckSettingMuteParams(s);try{yield je(s,this._core);let{groupID:e,userID:t,muteTime:r}=s;console.log(`${this._name}.${o} ok, groupID:${e} userID:${t} muteTime:`+r);var i=Ie.getLocalGroup(e),n=new Fe({userID:t,muteTime:r});return ye({group:i,member:n})}catch(e){i=new t.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,i),i}})}_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(s){return be(this,void 0,void 0,function*(){let o="setGroupMemberRole",t=this._core["helper"];this._preCheckSettingRoleParams(s);try{yield je(s,this._core);let{groupID:e,userID:t,role:r}=s;console.log(`${this._name}.${o} ok, groupID:${e} userID:${t} role:`+r);var i=Ie.getLocalGroup(e),n=new Fe({userID:t,role:r});return ye({group:i,member:n})}catch(e){i=new t.ChatError({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${o} fail:`,i),i}})}_preCheckSettingRoleParams(e){var{groupID:e,userID:t,role:r}=e,{store:o,helper:i,OuterConstant:n,common:{isCommunity:s}}=this._core,u=Ie.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:ie});u=[...C];if(s({groupID:e})&&u.push(n.GRP_MBR_ROLE_CUSTOM),!u.includes(r))throw new i.ChatError({functionName:"setGroupMemberRole",code:ne})}},We=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(a){return be(this,void 0,void 0,function*(){let i="setGroupMemberNameCard",{helper:r,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingNameCardParams(a);try{let{groupID:e,userID:t=n(),nameCard:r}=a,o={groupID:e,userID:t,nameCard:r};yield je(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} nameCard:`+r);var s=Ie.getLocalGroup(e),u=new Fe({userID:t,nameCard:r});return ye({group:s,member:u})}catch(e){let t=new r.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${i} fail:`,t),t}})}_preCheckSettingNameCardParams(e){var e=e["groupID"],t=this._core["helper"],e=Ie.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(a){return be(this,void 0,void 0,function*(){let i="setGroupMemberCustomField",{helper:r,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingCustomFiledParams(a);try{let{groupID:e,userID:t=n(),memberCustomField:r}=a,o={groupID:e,userID:t,memberCustomField:r};yield je(o,this._core),console.log(`${this._name}.${i} ok, groupID:${e} userID:${t} memberCustomField:`+JSON.stringify(r));var s=Ie.getLocalGroup(e),u=new Fe({userID:t,memberCustomField:r});return ye({group:s,member:u})}catch(e){let t=new r.ChatError({functionName:i,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${i} fail:`,t),t}})}_preCheckSettingCustomFiledParams(e){var e=e["groupID"],t=this._core["helper"],e=Ie.getLocalGroup(e);if(le(null==e?void 0:e.type))throw new t.ChatError({functionName:"setGroupMemberCustomField",code:ue})}},Qe=new class{init(e,t){console.log("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(l){return be(this,void 0,void 0,function*(){var t="getGroupCounters";try{ge(t,r);var o,i,n,{groupID:s,keyList:u=[]}=l,{avChatRoomKey:a,lastUpdateTime:p}=Oe.getLocalGroupCounters(s);return Date.now()-p>=this._getExpireTime()&&(o=yield function(n){return be(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 be(this,void 0,void 0,function*(){return this._handleCounterOperation(n,e)})}increaseGroupCounter(e){return be(this,void 0,void 0,function*(){return this._handleCounterOperation(i,e)})}decreaseGroupCounter(e){return be(this,void 0,void 0,function*(){return this._handleCounterOperation(s,e)})}_handleCounterOperation(p,l){return be(this,void 0,void 0,function*(){var t=p+"GroupCounter";try{ge(t,r);var{groupID:e,key:o,value:i=0}=l,s=Oe.getLocalGroupCounters(e)["avChatRoomKey"],u=p===n?this._convertObjectToList(l.counters):[{Key:o,Value:i}],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 be(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 be(this,void 0,void 0,function*(){let o="initGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u}=Le.getGroupAttributesCache(i),a=Le.convertKeyValueMapToList(n);try{let e=yield function(i,n){return be(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||{};console.log(`${this._name}.${o} ok. groupID:${i} serverMainSequence:`+t);var p=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:p,operation:S}),Le.emitGroupAttributesUpdated(i),ye({groupAttributes:n})}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(this._name+`.${o} fail:`,t),t}})}},tt=new class{constructor(){this._name="SetGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return be(this,void 0,void 0,function*(){let o="setGroupAttributes",{groupID:i,groupAttributes:n}=e,{serverMainSequence:s,avChatRoomKey:u,values:a}=Le.getGroupAttributesCache(i),p=Le.convertKeyValueMapToList(n).map(e=>{var{key:t,value:r}=e;return{key:t,value:r,seq:(null==(t=a.get(e.key))?void 0:t.sequence)||0}});try{let e=yield function(i,n){return be(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:p,mainSequence:s},this._core),{AttrMainSeq:t,GroupAttr:r}=e||{};console.log(`${this._name}.${o} ok. groupID:${i} serverMainSequence:`+t);var l=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:l,operation:O}),Le.emitGroupAttributesUpdated(i),ye({groupAttributes:n})}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(this._name+`.${o} fail:`,t),t}})}},ot=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){e=(this._core=e).helper;e.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(u){return be(this,void 0,void 0,function*(){let r="deleteGroupAttributes",{groupID:e,keyList:t=[]}=u;try{var{resultList:o,serverMainSequence:i,operation:n,groupAttributeList:s}=(0===t.length?yield this._clearGroupAttributes(e):yield this._deleteGroupAttributes(e,t))||{};return console.log(`${this._name}.${r} ok. groupID:${e} operation: `+n),Le.saveGroupAttributesCacheValuesCopy(e),Le.refreshGroupAttributesCache({groupID:e,serverMainSequence:i,groupAttributeList:s,operation:n}),Le.emitGroupAttributesUpdated(e),ye({keyList:o})}catch(e){let t=new this._core.helper.ChatError({functionName:r,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(this._name+`.${r} fail:`,t),t}})}_deleteGroupAttributes(s,u){return be(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 be(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 be(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 be(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(l){return be(this,void 0,void 0,function*(){let o="getGroupAttributes",i=l["groupID"],{avChatRoomKey:n,lastUpdateTime:e,localMainSequence:t,serverMainSequence:r}=Le.getGroupAttributesCache(i),{ssoLog:s,helper:{ChatError:u}}=this._core,a=s.createSSOLogData({method:"getGroupAttributes"});if(a.setLogInfo({message:`groupID:${i} localMainSequence:${t} serverMainSequence:${r} keyList:`+l.keyList}),3e4<=Date.now()-e||t<r)try{let e=yield this.getGroupAttributesFromServer({groupID:i,avChatRoomKey:n}),t=Le.getGroupAttributesCacheValues(l),{serverGroupAttributeList:r=[]}=e||{};return a.setLogInfo({moreMessage:"from server, count:"+r.length}).end(),console.log(this._name+`.${o} from server. groupID:`+i),ye({groupAttributes:t})}catch(e){let t=new u({functionName:o,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw a.setError(t).end(),console.error(this._name+`.${o} fail:`,t),t}var p=Le.getGroupAttributesCacheValues(l);return a.setLogInfo({moreMessage:"from cache."}).end(),console.log(this._name+`.${o} from cache. groupID:`+i),ye({groupAttributes:p})})}getGroupAttributesFromServer(i){return be(this,void 0,void 0,function*(){var e=this._core["utils"]["isUndefined"],{groupID:t,avChatRoomKey:r}=i,{AttrMainSeq:e=0,GroupAttrAry:r}=(yield function(o,i){return be(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:t,avChatRoomKey:r,groupType:e(r)?P:N},this._core))||{},o=(console.log(this._name+`._getGroupAttributesFromServer ok. groupID:${t} serverMainSequence:`+e),r.map(e=>{var{key:e,value:t,seq:r}=e;return{key:e,value:t,sequence:r}}));return Le.refreshGroupAttributesCache({groupID:t,serverMainSequence:e,groupAttributeList:o,operation:E}),{serverGroupAttributeList:r}})}},nt=new class{init(e){console.log("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 it(e,t="tips"){let{ClientSeq:r,From_Account:o,MsgClientTime:i,MsgPriority:n,MsgRandom:s,MsgSeq:u,MsgTimeStamp:a,TinyId:p,ToGroupId:l,GroupInfo:c,MsgBody:m}=e,h=function(){var{GroupCode:e,GroupId:t,GroupName:r,GroupType:o,MsgFrom_AccountExtraInfo:i,From_Account:n,To_Account:s}=c;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:l,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];q[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=it(i[t],"tips");if(o===$){if(nt.isGroupAttributesUpdated(e)){nt.handleGroupAttributesUpdated(e);continue}if(Ze.isGroupCounterUpdated(e)){Ze.handleGroupCounterUpdated(e);continue}}var u=e["groupProfile"]["groupID"];if(Ie.hasLocalGroup(u)){u=this._assembleMessage(e);if(o===$&&(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=Ie.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])}),Ie.emitGroupListUpdate(),Ie.updateConversationGroupProfile(n)}_handleGroupOwnerChanged(e,t){var{common:r,OuterConstant:o}=this._core,e=Ie.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===U&&(o=r.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:o})}_handleGroupMemberCountUpdated(e){var{memberCount:e,groupProfile:{groupID:t}}=e.payload,r=Ie.getLocalGroup(t),o=this._core["utils"]["isNumber"];r&&o(e)&&r.memberCount!==e&&(r.memberCount=e,Ie.emitGroupListUpdate(),Ie.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];F[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}=(console.log(`${this._name}.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=it(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=Ie.hasLocalGroup(t);console.log(this._name+`._handleGroupJoinResult groupID:${t} type:${r} hasLocalGroup:`+o),o||le(r)||(Ie.updateLocalGroup([Object.assign({},e)]),Ie.emitGroupListUpdate())}_handleMemberKicked(e){var{groupID:e,type:t}=e.payload["groupProfile"];Ie.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupDismissed(e){var{groupID:e,type:t}=e.payload["groupProfile"];Ie.hasLocalGroup(e)&&this._deleteLocalGroup(e,t),this._updateConversationProfile(e,{unreadCount:0})}_handleGroupInvitedResult(e){var e=e.payload["groupProfile"],e=e["groupID"],t=Ie.hasLocalGroup(e);console.log(this._name+`._handleGroupInvitedResult groupID:${e} hasLocalGroup:`+t),t||Se.getGroupProfile({groupID:e}).then(e=>{var e=e["data"]["group"];Ie.updateLocalGroup([Object.assign({},e)]),Ie.emitGroupListUpdate()})}_handleGroupQuitResult(e){var{groupID:e,type:t}=e.payload["groupProfile"],r=Ie.hasLocalGroup(e);console.log(this._name+`._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)}Ie.deleteLocalGroup(r),Ie.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,console.log("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}},It={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 vt=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=Ie,this.groupAction=$e,this.groupAttribute=nt,this.groupMember=Qe,this.name="Group"}install(t,r=[]){this._core=t,e.init(t),Ie.init(t),$e.init(t,this),Qe.init(t,this),qe.init(t),Ze.init(t),nt.init(t),ht.init(t),t.helper.registerValidateConfig({auth:It,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(){Ie.reset(),nt.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{vt as default};
|
|
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};
|