UNPKG

@tencentcloud/lite-chat

Version:

Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut

1 lines 70.5 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChatGroup=t()}(this,(function(){"use strict";const e=new class{init(e){this.core=e}},t="AVChatRoom",o="AV_HISTORY_MSG",r=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],i=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],n=["Role","JoinTime","MsgFlag","MsgSeq"],s=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],u=0,a=1,c="notStart",p="resolved",l="rejected",h=10018,m=11e3,d=2,g=["Owner","Admin","Member"],_=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],f=0,G=1,b=2,v=4,I=1,y=2,C=3,M=4,A=5,D=1,L=0,S=4,O=6,w=1,T=2,$=3,N=4,E=5,P=6,R=400,U=300,k={from:!0,groupID:!0,groupName:!0,to:!0},q={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},F=2,j=4,x=5,K=7,V=8,J=15,B=20,H=21,Y=2600,W=2602,Q=2603,z=2620,X=2621,Z=2623,ee=2660,te=2661,oe=2681,re=2683,ie=2684,ne=2685,se=2687,ue=t=>t===e.core.OuterConstant.GRP_PUBLIC,ae=t=>t===e.core.OuterConstant.GRP_AVCHATROOM,ce=(t,o)=>{const{isArray:r}=e.core.utils;if(!r(t)||!r(o))return!1;let i=!1;return o.forEach((({key:e,value:o})=>{const r=t.find((t=>t.key===e));r?r.value!==o&&(r.value=o,i=!0):(t.push({key:e,value:o}),i=!0)})),i},pe=e=>{const t=[];if(!e)return t;for(let o=0,r=e.length;o<r;o++){const{Key:r,Value:i}=e[o];t.push({key:r,value:i})}return t},le=e=>{const t=[];for(let o=0,r=e.length;o<r;o++){const{key:r,value:i}=e[o];t.push({Key:r,Value:i})}return t},he=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class me{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._initGroup(e)}_initGroup(t){const{utils:{isString:o}}=e.core;for(const e in t)he.indexOf(e)<0||("selfInfo"!==e?"isSupportTopic"!==e?"muteAllMembers"===e&&o(t[e])?this.muteAllMembers="On"===t[e]:this[e]=t[e]:this.isSupportTopic=1===t[e]:this.updateSelfInfo(t[e]))}updateGroup(t){const{utils:{isArray:o,isUndefined:r,isNumber:i,isString:n},common:{deepMerge:s}}=e.core;t.appid=void 0,t.grossTopicNextMsgSeq=void 0,t.selfInfo&&(t.selfInfo.grossTopicReadSeq=void 0);const u=JSON.parse(JSON.stringify(t));u.lastMsgTime&&(this.lastMessage.lastTime=u.lastMsgTime),n(u.muteAllMembers)&&(u.muteAllMembers="On"===u.muteAllMembers),u.groupCustomField&&ce(this.groupCustomField,u.groupCustomField),r(u.isSupportTopic)||(this.isSupportTopic=i(u.isSupportTopic)?1===u.isSupportTopic:u.isSupportTopic),s(this,u,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),o(u.members)&&u.members.length>0&&u.members.forEach((e=>{e.userID===this.selfInfo.userID&&s(this.selfInfo,e,["sequence"])}))}updateSelfInfo(t){const{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u}=t,{common:{deepMerge:a}}=e.core;a(this.selfInfo,{nameCard:o,joinTime:r,role:i,messageRemindType:n,readedSequence:s,excludedUnreadSequenceList:u},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var de=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap(),console.log(`${this._name}.init`)}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let o;e.forEach((e=>{var t;o=e.groupID,this.hasLocalGroup(o)?null===(t=this.getLocalGroup(o))||void 0===t||t.updateGroup(e):this._groupMap.set(o,new me(e))}));const r=t();for(const[,e]of this._groupMap)e.selfInfo.userID=r,"Owner"===e.selfInfo.role&&(e.ownerID=r)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){return[...this._groupMap.values()]}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:o}=this._core;o.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:o}}=this._core,r=`${o}${e}`;if(t.getConversation(r)){const o=this.getLocalGroup(e);t.updateConversation(r,{groupProfile:o})}}reset(){this.clearLocalGroup()}};function ge(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(o[r[i]]=e[r[i]])}return o}function _e(e,t,o,r){return new(o||(o=Promise))((function(i,n){function s(e){try{a(r.next(e))}catch(e){n(e)}}function u(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function fe(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}"function"==typeof SuppressedError&&SuppressedError;const Ge=function(e){return{code:0,data:e||{}}};var be=new class{constructor(){this._name="GetGroupList",this._pagingStatus=c,this.PAGING_GRP_COUNT_LIMIT=200}init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:r}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,r.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return _e(this,void 0,void 0,(function*(){if(console.log(`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===l||this._pagingStatus===c)return this._syncGroupList().then((()=>{const e=de.getLocalGroupList();return Ge({groupList:e,isSyncCompleted:this._isSyncCompleted()})})).catch((e=>{throw console.error(`${this._name}.getGroupList fail:`,e),e}));const e=de.getLocalGroupList();return console.log(`${this._name}.getGroupList return group count:${e.length}`),Ge({groupList:e,isSyncCompleted:this._isSyncCompleted()})}))}_syncGroupList(){return _e(this,void 0,void 0,(function*(){this._pagingStatus===c&&de.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=p,this._groupListTreeShaking(t),de.updateLocalGroup(t);const o=de.getLocalGroupList();return console.log(`${this._name}._syncGroupList ok, count:${o.length}`),de.emitGroupListUpdate(),o}catch(e){throw this._pagingStatus=l,console.error(`${this._name}._syncGroupList fail:`,e),e}}))}_pagingGetGroupList(e){return _e(this,void 0,void 0,(function*(){const{isCommunityRelay:t=!1,groupList:o}=e;let i,{limit:s,offset:u}=e;const a=[...r];t&&(i=this._core.OuterConstant.GRP_COMMUNITY,a.push("AtInfoList"));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{type:o,limit:r,offset:i,memberAccount:n,responseFilter:s}=e;return fe(o?"million_group_open_http_svc.get_joined_group_list":"group_open_http_svc.get_joined_group_list",{Limit:r,Offset:i,Member_Account:n,ResponseFilter:s,SupportTopic:0,NeedAppDefineData:1},t)}))}({type:i,limit:s,offset:u,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:a,SelfInfoFilter:[...n]}},this._core),{GroupIdList:r=[],TotalCount:c=0}=e||{},p=this._convertGroupKey(r);o.push(...p);const l=u+s,h=!(c>l),m=`offset:${u} limit:${s} total:${c} isCompleted:${h} current:${o.length} isCommunityRelay:${t}`;return console.log(`${this._name}._pagingGetGroupList ok. ${m}`),t?h?o:(u=l,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):h?(console.log(`${this._name}._pagingGetGroupList start to get community list`),u=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:s,offset:u,groupList:o})):(u=l,this._pagingGetGroupList({limit:s,offset:u,groupList:o}))}catch(e){if(e.ErrorCode===h)return console.warn(`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${s}`),s=50,this._pagingGetGroupList({isCommunityRelay:t,limit:s,offset:u,groupList:o});if(t)return e.code===m&&console.log(`${this._name}._pagingGetGroupList ok. community unavailable`),o;throw e}}))}_groupListTreeShaking(e){const t=new Map([...de.getLocalGroupList()]);for(let o=0,r=e.length;o<r;o++)t.delete(e[o].groupID);const o=[...t.keys()];for(let e=0,t=o.length;e<t;e++)de.deleteLocalGroup(o[e])}_isSyncCompleted(){return this._pagingStatus===p}_convertGroupKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,Introduction:a,InviteJoinOption:c,LastInfoTime:p,LastMsgTime:l,MemberNum:h,MaxMemberNum:m,MuteAllMember:d,Name:g,NextMsgSeq:_,Notification:f,Owner_Account:G,Type:b,LastRecallTime:v,SelfInfo:I}=e[o],y=pe(r),C=this._convertSelfInfo(I);t.push({groupCustomField:y,joinOption:i,createTime:n,avatar:s,groupID:u,introduction:a,inviteOption:c,lastInfoTime:p,lastMsgTime:l,memberCount:h,maxMemberCount:m,muteAllMembers:d,name:g,nextMessageSeq:_,notification:f,ownerID:G,type:b,_lastRevokedTime:v,selfInfo:C})}return t}_convertSelfInfo(e){const{JoinTime:t,MsgFlag:o,MsgSeq:r,NoUnreadSeqList:i,Role:n}=e;return{joinTime:t,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i,role:n}}};var ve=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return _e(this,void 0,void 0,(function*(){var t;this._preCheckParams(e),console.log(`${this._name}.createGroup options:`,e);try{const{utils:{isEmpty:o},common:{getCurrentUserID:r}}=this._core,i=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{name:o,type:r,groupID:i,introduction:n,notification:s,avatar:u,maxMemberNum:a,joinOption:c,inviteOption:p,memberList:l,groupCustomField:h,isSupportTopic:m}=e;let d;return l&&(d=l.map((e=>{const{userID:t,memberCustomField:o}=e;return{Member_Account:t,AppMemberDefinedData:o?le(o):void 0}}))),fe("group_open_http_svc.create_group",{Name:o,Type:r,GroupId:i,Introduction:n,Notification:s,FaceUrl:u,MaxMemberCount:a,ApplyJoinOption:c,InviteJoinOption:p,MemberList:d,AppDefinedData:h,SupportTopic:m,webPushFlag:1},t)}))}(Object.assign(Object.assign({},e),{ownerID:r()}),this._core),{GroupId:n,OverJoinedGroupLimit_Account:s=[]}=i||{};if(console.log(`${this._name}.createGroup ok, groupType:${e.type} groupID:${n} overLimitUserIDList:${s}`),o(e.memberList)||o(s)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter((e=>s.includes(e.userID)))),this._notNeedUpdateLocalGroup(e))return Ge({group:new me(e)});de.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:n})]),this._sendCustomMessage(n,e.type);const u=de.getLocalGroup(n);return de.emitGroupListUpdate(),Ge({group:u})}catch(e){throw console.error(`${this._name}.createGroup fail:`,e),e}}))}_preCheckParams(t){const{type:o,groupID:r}=t,{utils:{isEmpty:i,isUndefined:n},common:{isCommunity:s}}=this._core,u=!i(r);if(!(()=>{const{GRP_PUBLIC:t,GRP_WORK:o,GRP_MEETING:r,GRP_AVCHATROOM:i,GRP_COMMUNITY:n}=e.core.OuterConstant;return[t,o,r,i,n]})().includes(o))throw new this._core.helper.ChatError({code:Y});if(!s({type:o})){if(u&&s({groupID:r}))throw new this._core.helper.ChatError({code:W});n(t.isSupportTopic)||(t.isSupportTopic=void 0)}if(this._canIUseMemberList(o)||n(t.memberList)||(t.memberList=void 0),this._canIUseJoinOption(o)||n(t.joinOption)||(t.joinOption=void 0),this._canIUseTopic(t)&&(t.isSupportTopic=!0===t.isSupportTopic?1:0),s({type:o})&&u&&!s({groupID:r}))throw new this._core.helper.ChatError({code:W})}_canIUseMemberList(e){return!ae(e)}_canIUseJoinOption(e){return ue(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){const{type:t,isSupportTopic:o}=e,{utils:{isUndefined:r},common:{isCommunity:i}}=this._core;return i({type:t})&&r(o)}_notNeedUpdateLocalGroup(e){const{type:t,isSupportTopic:o}=e,{OuterConstant:r}=this._core;return t===r.GRP_AVCHATROOM||t===r.GRP_COMMUNITY&&1===o}_sendCustomMessage(e,t){var o,r,i,n,s,c;const{OuterConstant:p}=this._core;let l="Create Group",h=u;t===p.GRP_COMMUNITY&&(l="Create Community",h=a);const m={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:l,cmd:h,opUser:this._core.store.get("login").userId,version:4})}},d=null===(i=null===(r=null===(o=this._core)||void 0===o?void 0:o.message)||void 0===r?void 0:r.messageFactory)||void 0===i?void 0:i.createCustomMessage(m);null===(c=null===(s=null===(n=this._core)||void 0===n?void 0:n.message)||void 0===s?void 0:s.messageSender)||void 0===c||c.sendMessage(d,{})}};var Ie=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){this._core=e;const{helper:t,constants:o}=e;t.registerWorkflowStep(o.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,o.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach((e=>{e.localMainSequence=0}))}isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:o,isUndefined:r}}=this._core;return!r(t)&&!o(t.groupAttributeOption)}handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:o}=e,{serverMainSequence:r,groupAttributeList:i=[],operation:n}=o;console.log(`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${n}`);const{utils:{isUndefined:s}}=this._core;s(n)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:i,operation:n}),this.emitGroupAttributesUpdated(t))}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:o}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:o,values:new Map}),console.log(`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${o}`)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:o,groupAttributeList:r,operation:i}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:n}=e;i!==A&&o-n!=1||(e.serverMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:r,operation:i})),o-n>1&&(e.serverMainSequence=o),this._groupAttributesCache.set(t,e),console.log(`${this._name}.refreshGroupAttributesCache. operation:${i} localMainSequence:${n} serverMainSequence:${o}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:o=[],operation:r}=e;r!==C?r!==M?(r===I&&t.values.clear(),o.forEach((e=>{const{key:o,value:r,sequence:i}=e;t.values.set(o,{value:r,sequence:i})}))):o.forEach((e=>{t.values.delete(e.key)})):t.values.clear()}getGroupAttributesCacheValues(e){var t;const{groupID:o,keyList:r=[]}=e,i={};if(this.hasGroupAttributesCache(o)){const{values:e}=this.getGroupAttributesCache(o);if(0===r.length){for(const o of e.keys())i[o]=(null===(t=e.get(o))||void 0===t?void 0:t.value)||"";return i}return r.forEach((t=>{var o;e.has(t)&&(i[t]=(null===(o=e.get(t))||void 0===o?void 0:o.value)||"")})),i}return i}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t;const o=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:r,deletedKeyList:i}=this._computeValuesChangedData(o);console.log(`${this._name}.emitGroupAttributesUpdated update count:${r.length}, delete count:${i.length}`),0===r.length&&0===i.length||this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:o,updatedKeyList:r,deletedKeyList:i}})}_computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,o=[],r=[];return Object.keys(e).forEach((t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&o.push(t)})),Object.keys(this._groupAttributesCacheValuesCopy).forEach((o=>{t(e[o])&&r.push(o)})),this._groupAttributesCacheValuesCopy={},{updatedKeyList:o,deletedKeyList:r}}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach((o=>{t.push({key:o,value:e[o]})})),t}};var ye=new class{constructor(){this._name="DismissGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}dismissGroup(e){return _e(this,void 0,void 0,(function*(){console.log(`${this._name}.dismissGroup groupID:${e}`);try{yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.destroy_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.dismissGroup ok.`);const{type:t}=de.getLocalGroup(e);return de.deleteLocalGroup(e),de.emitGroupListUpdate(),Ie.deleteGroupAttributesCache(e),Ge({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.dismissGroup fail:`,e),e}}))}};var Ce=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return _e(this,void 0,void 0,(function*(){const{groupID:t,groupCustomFieldFilter:o}=e,i={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...r],AppDefinedDataFilter_Group:o,MemberInfoFilter:[...s]}};try{const e=yield this.getGroupProfileAdvance(i),{successGroupList:o,failureGroupList:r}=e;if(r.length>0)throw r[0];let n;return!de.hasLocalGroup(t)&&ae(o[0].type)?n=new me(o[0]):(de.updateLocalGroup(o),n=de.getLocalGroup(t)),n.isSupportTopic||de.updateConversationGroupProfile(t),console.log(`${this._name}.getGroupProfile ok.`),Ge({group:n})}catch(e){throw console.error(`${this._name}.getGroupProfile fail:`,e),e}}))}getGroupProfileAdvance(e){return _e(this,void 0,void 0,(function*(){const{groupIDList:t}=e,{common:{isCommunity:o}}=this._core,r=t.filter((e=>!o({groupID:e}))),i=t.filter((e=>o({groupID:e})));r.length>50&&(r.length=50),i.length>50&&(i.length=50);const n=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:r})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:i,isCommunityProfile:!0}))]),s=[],u=[];return n.forEach((e=>{s.push(...e.successGroupList),u.push(...e.failureGroupList)})),{successGroupList:s,failureGroupList:u}}))}_getGroupProfileAdvance(e){return _e(this,void 0,void 0,(function*(){const{isCommunityProfile:t=!1}=e,o=ge(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupIDList:o,responseFilter:r}=e;return fe("group_open_http_svc.get_group_self_member_info",{GroupIdList:o,ResponseFilter:r},t)}))}(o,this._core),{GroupInfo:t=[]}=e||{},r=this._convertGroupProfileKey(t),{utils:{isUndefined:i}}=this._core,n=r.filter((e=>i(e.errorCode)||0===e.errorCode)),s=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:${o.groupIDList.join(",")}`),{successGroupList:n,failureGroupList:s}}catch(e){if(t)return{successGroupList:[],failureGroupList:[]};throw e}}))}_convertGroupProfileKey(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppDefinedData:r,ApplyJoinOption:i,CreateTime:n,FaceUrl:s,GroupId:u,InfoSeq:a,Introduction:c,InviteJoinOption:p,LastInfoTime:l,LastMsgTime:h,MaxMemberNum:m,MemberNum:d,MuteAllMember:g,Name:_,NextMsgSeq:f,Notification:G,Owner_Account:b,ShutUpAllMember:v,ShutUpUntil:I,Type:y,MemberList:C,ErrorCode:M,ErrorInfo:A}=e[o],D=pe(r),L=this._convertMembers(C);t.push({groupCustomField:D,joinOption:i,createTime:n,avatar:s,groupID:u,infoSequence:a,introduction:c,inviteOption:p,lastInfoTime:l,lastMsgTime:h,maxMemberCount:m,memberCount:d,muteAllMembers:g,name:_,nextMessageSeq:f,notification:G,ownerID:b,shutUpAllMember:v,muteUntil:I,type:y,members:L,errorCode:M,errorInfo:A})}return t}_convertMembers(e){if(!e)return[];const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,MsgFlag:s,MsgSeq:u,NameCard:a,Role:c}=e[o],p=pe(r);t.push({memberCustomField:p,joinTime:i,userID:n,messageRemindType:s,sequence:u,nameCard:a,role:c})}return t}};var Me=new class{constructor(){this._name="JoinGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"joinGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}joinGroup(e){return _e(this,void 0,void 0,(function*(){const{groupID:t}=e;try{if(de.hasLocalGroup(t))try{return yield Ce.getGroupProfile({groupID:t}),Ge({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS})}catch(o){console.warn(`${this._name}.joinGroup ${t} was unjoined, start to join!`),de.deleteLocalGroup(t);return yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){throw console.error(`${this._name}.joinGroup fail:`,e),e}}))}_applyJoinGroup(e){return _e(this,void 0,void 0,(function*(){const{OuterConstant:t,helper:r}=this._core,{groupID:i}=e,n=Object.assign({},e),s=r.checkBusinessCapabilityBits(o);s&&(n.historyMessageFlag=1);const u=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,applyMessage:r,historyMessageFlag:i}=e;return fe("group_open_http_svc.apply_join_group",{GroupId:o,ApplyMsg:r,HugeGroupHistoryMsgFlag:i},t)}))}(n,this._core),{JoinedStatus:a,LongPollingKey:c,StartSeq:p,HugeGroupFlag:l,AVChatRoomKey:h,RspMsgList:m=[]}=u||{},d=`groupID:${i} joinedStatus:${a} longPollingKey:${c} startSeq:${p} avChatRoomFlag:${l} canGetAVChatRoomHistoryMsg:${s}, historyMessageCount:${m.length}`;if(console.log(`${this._name}._applyJoinGroup ok, ${d}`),a===t.JOIN_STATUS_WAIT_APPROVAL)return{code:0,data:{status:t.JOIN_STATUS_WAIT_APPROVAL}};if(a===t.JOIN_STATUS_SUCCESS){let e=null;try{e=(yield Ce.getGroupProfile({groupID:i})).data.group}catch(t){e=new me({groupID:i}),console.warn(`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${i}, errorCode:`,null==t?void 0:t.code)}return this._handleJoinResult({group:e,avChatRoomFlag:l,longPollingKey:c,startSequence:p,avChatRoomKey:h,historyMessageList:m})}throw new this._core.helper.ChatError({code:ee})}))}_handleJoinResult(e){const{group:t,avChatRoomFlag:o,avChatRoomKey:r}=e;return 1===o?(Ie.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:r}),Ge(e)):(de.updateLocalGroup([t]),de.emitGroupListUpdate(),Ge({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t}))}};var Ae=new class{constructor(){this._name="QuitGroup"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"quitGroup",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}quitGroup(e){return _e(this,void 0,void 0,(function*(){if(!de.hasLocalGroup(e))throw new this._core.helper.ChatError({code:Z});try{yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.quit_group",{GroupId:e},t)}))}(e,this._core),console.log(`${this._name}.quitGroup ok, groupID:${e}`);const{type:t}=de.getLocalGroup(e);return de.deleteLocalGroup(e),de.emitGroupListUpdate(),Ie.deleteGroupAttributesCache(e),Ge({groupID:e,type:t})}catch(e){throw console.error(`${this._name}.quitGroup fail:`,e),e}}))}};var De=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return _e(this,void 0,void 0,(function*(){console.log(`${this._name}.searchGroupByID groupID:${e}`);try{const t=yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.get_group_public_info",{GroupIdList:[e],GroupBasePublicInfoFilter:[...i]},t)}))}(e,this._core),{GroupInfo:o=[]}=t||{},{AppDefinedData:r=[],ApplyJoinOption:n,CreateTime:s,FaceUrl:u,Introduction:a,InviteJoinOption:c,MaxMemberNum:p,MemberNum:l,Name:h,Owner_Account:m,Type:d,ErrorCode:g,ErrorInfo:_}=o[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});console.log(`${this._name}.searchGroupByID ok.`);const f=pe(r),G=new me({groupID:e,name:h,avatar:u,introduction:a,joinOption:n,inviteOption:c,maxMemberCount:p,memberCount:l,type:d,ownerID:m,createTime:s,groupCustomField:f});return Ge({group:G})}catch(e){throw console.error(`${this._name}.searchGroupByID fail:`,e),e}}))}};var Le=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return _e(this,void 0,void 0,(function*(){const{groupID:t}=e,{utils:{isUndefined:o}}=this._core;let r=de.getLocalGroup(t);if(r){const{type:t}=r;this._canIUseJoinOption(t)||o(e.joinOption)||(console.warn(`${this._name}.updateGroupProfile joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}o(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,name:r,avatar:i,introduction:n,notification:s,muteAllMembers:u,joinOption:a,inviteOption:c,groupCustomField:p}=e;return fe("group_open_http_svc.modify_group_base_info",{GroupId:o,Name:r,FaceUrl:i,Introduction:n,Notification:s,ShutUpAllMember:u,ApplyJoinOption:a,InviteJoinOption:c,AppDefinedData:p?le(p):void 0},t)}))}(e,this._core),console.log(`${this._name}.updateGroupProfile groupID:${t} ok.`),r?(r.updateGroup(e),de.emitGroupListUpdate()):r=new me(e),Ge({group:r})}catch(e){throw console.error(`${this._name}.updateGroupProfile groupID:${t} fail:`,e),e}}))}_canIUseJoinOption(e){return ue(e)||this._core.common.isCommunity({type:e})}};var Se=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return _e(this,void 0,void 0,(function*(){const t="changeGroupOwner",{groupID:o,newOwnerID:r}=e,i=de.getLocalGroup(o),{helper:n,OuterConstant:s,common:{getCurrentUserID:u}}=this._core;if((null==i?void 0:i.type)===s.GRP_AVCHATROOM)throw new n.ChatError({functionName:t,code:z});if(r===u())throw new n.ChatError({functionName:t,code:X});console.log(`${this._name}.${t} groupID:${o} newOwnerID:${r}`);try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,newOwnerID:r}=e;return fe("group_open_http_svc.change_group_owner",{GroupId:o,NewOwner_Account:r},t)}))}(e,this._core),console.log(`${this._name}.${t} ok.`),i.ownerID=r,de.emitGroupListUpdate(),Ge({group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var Oe=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupOnlineMemberCount(e){return _e(this,void 0,void 0,(function*(){const t="getGroupOnlineMemberCount",o=de.hasLocalGroup(e);if(console.log(`${this._name}.${t} groupID:${e} hasLocalGroup:${o}`),!o)return Ge({memberCount:0});const r=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:o=0,memberCount:i=0}=t||{};if(r-o<=6e4)return Ge({memberCount:i})}try{const o=yield function(e,t){return _e(this,void 0,void 0,(function*(){return fe("group_open_http_svc.get_online_member_num",{GroupId:e},t)}))}(e,this._core),{OnlineMemberNum:r=0}=o||{};return this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:r}),console.log(`${this._name}.${t} ok. groupID:${e} memberCount:${r}`),Ge({memberCount:r})}catch(e){const o=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:`,o),o}}))}};var we=new class{init(e,t){console.log("GroupAction.init"),be.init(e),ve.init(e),ye.init(e,t),Me.init(e,t),Ae.init(e,t),De.init(e),Ce.init(e),Le.init(e),Se.init(e),Oe.init(e,t)}dismissGroup(e){return ye.dismissGroup(e)}joinGroup(e){return Me.joinGroup(e)}quitGroup(e){return Ae.quitGroup(e)}getGroupOnlineMemberCount(e){return Oe.getGroupOnlineMemberCount(e)}};function Te(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var $e=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return _e(this,void 0,void 0,(function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);console.log(`${this._name}.${e} ok.`);const o=this._handleGroupApplicationResult([...t[0],...t[1]]);return Ge({applicationList:o})}catch(t){const o=new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo});throw console.error(`${this._name}.${e} fail:`,o),o}}))}_getGroupApplicationList(t){return _e(this,void 0,void 0,(function*(){const{type:o,startTime:r=0,limit:i=20}=t||{},{common:n}=this._core;let s;try{s=yield function(t,o){return _e(this,void 0,void 0,(function*(){const{type:r,startTime:i,limit:n,handleAccount:s}=t;return Te(e.core.common.isCommunity({type:r})?"million_group_open_http_svc.get_pendency":"group_open_http_svc.get_pendency",{StartTime:i,Limit:n,Handle_Account:s},o)}))}({type:o,startTime:r,limit:i,handleAccount:n.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;s={}}const{NextStartTime:u=0,PendencyList:a=[]}=s||{};if(0===u)return a;const c=yield this._getGroupApplicationList(Object.assign(Object.assign({},t),{startTime:u}));return[...a,...c]}))}_handleGroupApplicationResult(e){const t=[];return e.forEach((e=>{const o=this._convertApplicationData(e),{handled:r}=o,i=ge(o,["handled"]);0===r&&t.push(i)})),t}_convertApplicationData(e){const{Handled:t,AddTime:o,ApplyInviteMsg:r,Authentication:i,FromUserNickName:n,From_Account:s,GroupId:u,GroupName:a,PendencyType:c,To_Account:p}=e;return{handled:t,messageKey:o,applicant:s,applicantNick:n,groupID:u,groupName:a,authentication:i,applicationType:c,userID:p,note:r}}};var Ne=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(t){return _e(this,void 0,void 0,(function*(){const o="handleGroupApplication",{application:r}=t,i=this._handleParams(t);try{(null==r?void 0:r.applicationType)===d?yield function(t,o){return _e(this,void 0,void 0,(function*(){const{groupID:r,handleAction:i,handleMessage:n,applicant:s,authentication:u,invitee:a}=t;return Te(e.core.common.isCommunity({groupID:r})?"million_group_open_http_svc.handle_invite_join_permission_group":"group_open_http_svc.handle_invite_join_permission_group",{GroupId:r,HandleMsg:i,ApprovalMsg:n,Applicant_Account:s,Authentication:u,Invited_Account:a},o)}))}(i,this._core):yield function(t,o){return _e(this,void 0,void 0,(function*(){const{groupID:r,handleAction:i,handleMessage:n,applicant:s,authentication:u,messageKey:a}=t;return Te(e.core.common.isCommunity({groupID:r})?"million_group_open_http_svc.handle_apply_join_group":"group_open_http_svc.handle_apply_join_group",{GroupId:r,HandleMsg:i,ApprovalMsg:n,Applicant_Account:s,Authentication:u,MsgKey:a},o)}))}(i,this._core),console.log(`${this._name}.${o} ok.`);const t=de.getLocalGroup(i.groupID);return Ge({group:t})}catch(e){const 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}}))}_handleParams(e){var t;const{handleAction:o,handleMessage:r,message:i,application:n}=e;let s,u,a,c,p;if(i){const{payload:e}=i||{};s=e.operatorID,u=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,a=e.authentication,c=e.messageKey}else s=(null==n?void 0:n.applicant)||"",u=(null==n?void 0:n.groupID)||"",a=(null==n?void 0:n.authentication)||"",c=(null==n?void 0:n.messageKey)||0;return(null==n?void 0:n.applicationType)===d&&(p=n.userID),{handleAction:o,handleMessage:r,applicant:s,invitee:p,groupID:u,authentication:a,messageKey:c}}};var Ee=new class{init(e){console.log("GroupApplication.init"),$e.init(e),Ne.init(e)}};let Pe=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(t){const{core:{utils:{isUndefined:o},common:{deepMerge:r}}}=e;o(t.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*t.muteTime)/1e3)),o(t.onlineStatus)||(this.isOnline="Online"===t.onlineStatus);const i=[null,void 0,"",0,NaN];t.memberCustomField&&ce(this.memberCustomField,t.memberCustomField),r(this,t,["memberCustomField","marks","onlineStatus","muteTime"],i)}};function Re(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}function Ue(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userID:r,muteTime:i,role:n,nameCard:s,memberCustomField:u}=e;let a;u&&(a=le(u));return Re("group_open_http_svc.modify_group_member_info",{GroupId:o,Member_Account:r,ShutUpTime:i,Role:n,NameCard:s,AppMemberDefinedData:a},t)}))}var ke=new class{constructor(){this._name="GetGroupMemberList"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}getGroupMemberList(e){return _e(this,void 0,void 0,(function*(){const t="getGroupMemberList",{groupID:o,offset:r=0,count:i=100,role:n="",filter:s=""}=e;console.log(`${this._name}.${t} groupID:${o} offset:${r} count:${i} role:${n} filter:${s}`);const u=de.getLocalGroup(o),a=i>100?100:i,c={groupID:o,offset:r,limit:a,memberRoleFilter:g.includes(n)?[n]:void 0,memberInfoFilter:_};try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,offset:r,limit:i,memberRoleFilter:n,memberInfoFilter:s}=e;return Re("group_open_http_svc.get_group_member_info",{GroupId:o,Offset:r,Limit:i,MemberRoleFilter:n,MemberInfoFilter:s},t)}))}(c,this._core),{MemberList:i,MemberNum:n,Next:s}=e||{};console.log(`${this._name}.${t} ok, totalMemberCount:${n} next:${s}`);const{utils:{isArray:p,isEmpty:l},common:{isCommunity:h}}=this._core;if(u&&(u.memberCount=n),!p(i)||0===i.length)return Ge({memberList:[],offset:0});let m=r+a;h({groupID:o})&&(m=l(s)?0:s),i.length<a&&(m=0);let d=this._convertMemberInfo(i);d=yield this._patchAvatarAndNick(d);const g=this._generateGroupMember(d);return Ge({memberList:g,offset:m})}catch(e){const o=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:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=pe(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_patchAvatarAndNick(e){return _e(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new Pe(e[o]);t.push(r)}return t}};var qe=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return _e(this,void 0,void 0,(function*(){const t="getGroupMemberProfile",{groupID:o,userIDList:r,memberCustomFieldFilter:i}=e,n=de.getLocalGroup(o),{helper:s,utils:{isArray:u}}=this._core;if(n&&ae(n.type))throw new s.ChatError({functionName:t,replacement1:t,code:se});r.length>50&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 50`),r.splice(50));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,memberInfoFilter:i,memberCustomFieldFilter:n}=e;return Re("group_open_http_svc.get_specified_group_member_info",{GroupId:o,Member_List_Account:r,MemberInfoFilter:i,AppDefinedDataFilter_GroupMember:n},t)}))}({groupID:o,userIDList:r,memberCustomFieldFilter:i,memberInfoFilter:[..._]},this._core);console.log(`${this._name}.${t} ok.`);const{MemberList:n}=e||{};if(!u(n)||0===n.length)return Ge({memberList:[]});let s=this._convertMemberInfo(n);s=yield this._getMemberAvatarAndNick(s);const a=this._generateGroupMember(s);return Ge({memberList:a})}catch(e){const o=new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_convertMemberInfo(e){const t=[];for(let o=0,r=e.length;o<r;o++){const{AppMemberDefinedData:r,JoinTime:i,Member_Account:n,OnlineStatus:s,Role:u,ShutUpUntil:a}=e[o],c=pe(r);t.push({userID:n,joinTime:i,onlineStatus:s,role:u,muteUntil:a,memberCustomField:c})}return t}_getMemberAvatarAndNick(e){return _e(this,void 0,void 0,(function*(){var t;const o=e.map((e=>e.userID)),r=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:o}),i=(null==r?void 0:r.data)||[],n=new Map(i.map((e=>[e.userID,e])));return e.forEach((e=>{if(n.has(e.userID)){const{nick:t="",avatar:o=""}=n.get(e.userID);e.nick=t,e.avatar=o}})),e}))}_generateGroupMember(e){const t=[];for(let o=0,r=e.length;o<r;o++){const r=new Pe(e[o]);t.push(r)}return t}};var Fe=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return _e(this,void 0,void 0,(function*(){const t="addGroupMember",{groupID:o,userIDList:r}=e,i=de.getLocalGroup(o),{helper:n}=this._core;if(i&&ae(i.type))throw new n.ChatError({functionName:t,code:te});const s=r.map((e=>({Member_Account:e})));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r}=e;return Re("group_open_http_svc.add_group_member",{GroupId:o,MemberList:r},t)}))}({groupID:o,userIDList:s},this._core),{MemberList:r=[]}=e||{},{failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c}=this._handleResult(r);return console.log(`${this._name}.${t} groupID:${o} ok, successUserIDList:${u} failureUserIDList:${n} existedUserIDList:${a} overLimitUserIDList:${c}`),Ge({failureUserIDList:n,successUserIDList:u,existedUserIDList:a,overLimitUserIDList:c,group:i})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}_handleResult(e){const t=[],o=[],r=[],i=[];return e.forEach((e=>{const{Result:n,Member_Account:s}=e;n===f?t.push(s):n===G?o.push(s):n===b?r.push(s):n===v&&i.push(s)})),{failureUserIDList:t,successUserIDList:o,existedUserIDList:r,overLimitUserIDList:i}}};var je=new class{constructor(){this._name="DeleteGroupMember"}init(e,o){this._core=e;const{helper:r}=e;r.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!o.getInstalledSubPlugins().includes(t)})}deleteGroupMember(e){return _e(this,void 0,void 0,(function*(){const t="deleteGroupMember",{groupID:o,userIDList:r}=e,i=de.getLocalGroup(o),{helper:n,utils:{isUndefined:s}}=this._core;if(s(i))throw new n.ChatError({functionName:t,code:Q});r.length>20&&(console.warn(`${this._name}.${t} userIDList length:${r.length} exceeds limit 20`),r.splice(20));try{return yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,userIDList:r,reason:i}=e;return Re("group_open_http_svc.delete_group_member",{GroupId:o,MemberToDel_Account:r,Reason:i},t)}))}({groupID:o,userIDList:r},this._core),console.log(`${this._name}.${t} ok, groupID:${o} userIDList length:${r.length}`),Ge({group:i,userIDList:r})}catch(e){const o=new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,o),o}}))}};var xe=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberMuteTime",{helper:o}=this._core;this._preCheckSettingMuteParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,muteTime:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} muteTime:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,muteTime:i});return Ge({group:n,member:s})}catch(e){const r=new o.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}}))}_preCheckSettingMuteParams(e){const{userID:t}=e,{store:o,helper:r}=this._core;if(t===o.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberMuteTime",code:ne})}};var Ke=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberRole",{helper:o}=this._core;this._preCheckSettingRoleParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,role:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} role:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,role:i});return Ge({group:n,member:s})}catch(e){const r=new o.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}}))}_preCheckSettingRoleParams(e){var t;const{groupID:o,userID:r,role:i}=e,{store:n,helper:s,OuterConstant:u,common:{isCommunity:a}}=this._core,c=de.getLocalGroup(o);if((null===(t=null==c?void 0:c.selfInfo)||void 0===t?void 0:t.role)!==u.GRP_MBR_ROLE_OWNER)throw new s.ChatError({functionName:"setGroupMemberRole",code:oe});if(r===n.get("login").userId)throw new s.ChatError({functionName:"setGroupMemberRole",code:ie});const p=[...g];if(a({groupID:o})&&p.push(u.GRP_MBR_ROLE_CUSTOM),!p.includes(i))throw new s.ChatError({functionName:"setGroupMemberRole",code:re})}};var Ve=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberNameCard",{helper:o}=this._core;this._preCheckSettingNameCardParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,nameCard:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} nameCard:${i}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,nameCard:i});return Ge({group:n,member:s})}catch(e){const r=new o.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}}))}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:o}=this._core,r=de.getLocalGroup(t);if(ae(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberNameCard",code:se})}};var Je=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return _e(this,void 0,void 0,(function*(){const t="setGroupMemberCustomField",{helper:o}=this._core;this._preCheckSettingCustomFiledParams(e);try{yield Ue(e,this._core);const{groupID:o,userID:r,memberCustomField:i}=e;console.log(`${this._name}.${t} ok, groupID:${o} userID:${r} memberCustomField:${JSON.stringify(i)}`);const n=de.getLocalGroup(o),s=new Pe({userID:r,memberCustomField:i});return Ge({group:n,member:s})}catch(e){const r=new o.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}}))}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:o}=this._core,r=de.getLocalGroup(t);if(ae(null==r?void 0:r.type))throw new o.ChatError({functionName:"setGroupMemberCustomField",code:se})}};var Be=new class{init(e,t){console.log("GroupMember.init"),ke.init(e,t),qe.init(e),Fe.init(e),je.init(e,t),xe.init(e),Ke.init(e),Ve.init(e),Je.init(e)}getGroupMemberList(e){return ke.getGroupMemberList(e)}deleteGroupMember(e){return je.deleteGroupMember(e)}};var He=new class{init(e){this._core=e}};function Ye(e,t,o){return _e(this,void 0,void 0,(function*(){const{helper:r,channel:i}=o,n=r.generateProtocolData({servcmd:e,data:t}),s=`${n.head.seq}${e}`;return yield i.sendPacket(n,{requestId:s})}))}var We=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="initGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n}=Ie.getGroupAttributesCache(o),s=Ie.convertKeyValueMapToList(r);try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ye("group_open_http_svc.set_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:s,mainSequence:i},this._core),{AttrMainSeq:u,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${u}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:u,groupAttributeList:c,operation:I}),Ie.emitGroupAttributesUpdated(o),Ge({groupAttributes:r})}catch(e){const o=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:`,o),o}}))}};var Qe=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="setGroupAttributes",{groupID:o,groupAttributes:r}=e,{serverMainSequence:i,avChatRoomKey:n,values:s}=Ie.getGroupAttributesCache(o),u=Ie.convertKeyValueMapToList(r).map((e=>{var t;const{key:o,value:r}=e;return{key:o,value:r,seq:(null===(t=s.get(e.key))||void 0===t?void 0:t.sequence)||0}}));try{const e=yield function(e,t){return _e(this,void 0,void 0,(function*(){const{groupID:o,mainSequence:r,groupAttributeList:i,avChatRoomKey:n}=e;return Ye("group_open_http_svc.modify_group_attr",{GroupId:o,AttrMainSeq:r,GroupAttr:i,BytesKey:n,AttrControl:["RaceConflict"]},t)}))}({groupID:o,avChatRoomKey:n,groupAttributeList:u,mainSequence:i},this._core),{AttrMainSeq:s,GroupAttr:a}=e||{};console.log(`${this._name}.${t} ok. groupID:${o} serverMainSequence:${s}`);const c=a.map((e=>{const{Key:t,seq:o}=e;return{key:t,value:r[t],sequence:o}}));return Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:s,groupAttributeList:c,operation:y}),Ie.emitGroupAttributesUpdated(o),Ge({groupAttributes:r})}catch(e){const o=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:`,o),o}}))}};var ze=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return _e(this,void 0,void 0,(function*(){const t="deleteGroupAttributes",{groupID:o,keyList:r=[]}=e;try{let e;e=0===r.length?yield this._clearGroupAttributes(o):yield this._deleteGroupAttributes(o,r);const{resultList:i,serverMainSequence:n,operation:s,groupAttributeList:u}=e||{};return console.log(`${this._name}.${t} ok. groupID:${o} operation: ${s}`),Ie.saveGroupAttributesCacheValuesCopy(o),Ie.refreshGroupAttributesCache({groupID:o,serverMainSequence:n,groupAttributeList:u,op