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