let e=2,t=4,s=10,o=11,r=12,i=14,n=17,a=20,u=23,p=26,l=27,c=29,h=30,g=34;class m{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let d={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},_={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},f="CHINA",M={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=f){this.CURRENT=d.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic"}},I={SEARCH_GRP_SNS:new m(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new m(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new m(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new m(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new m(0,Math.pow(2,6)).toString(),USER_STATUS:new m(0,Math.pow(2,7)).toString(),CONV_MARK:new m(0,Math.pow(2,9)).toString(),CONV_GROUP:new m(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new m(0,Math.pow(2,11)).toString(),MSG_EXT:new m(0,Math.pow(2,13)).toString(),GRP_COUNTER:new m(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new m(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new m(Math.pow(2,7)).toString(),PLUGIN_CS:new m(Math.pow(2,8)).toString(),PLUGIN_PUSH:new m(Math.pow(2,9)).toString(),PLUGIN_BOT:new m(Math.pow(2,10)).toString(),MSG_REACTION:new m(Math.pow(2,16)).toString(),FOLLOW:new m(Math.pow(2,20)).toString()},y="group_profile",D="group_member_profile",L=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption"],C=["Role","JoinTime","MsgSeq","MsgFlag"],G=(M.HOST.setCurrent(f),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)&&void 0===wx.getSystemInfoSync().uniPlatform),b="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||G,A=(b&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),v="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),T="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),S="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,R="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,$=b&&"object"==typeof wx.miniapp,w=b||A||v||T||S||R||P,E="undefined"==typeof window&&!w&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,U="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),q="undefined"!=typeof uni?!w:"undefined"!=typeof window&&!w&&!U,N=(A?qq:v?tt:T?swan:S?my:b?wx:R?uni:P&&jd,q&&window&&window.navigator&&window.navigator.userAgent||""),k=/(micromessenger|webbrowser)/i.test(N),O=function(){let e="WEB";return k?e="WEB":A?e="QQ_MP":v?e="TT_MP":T?e="BAIDU_MP":S?e="ALI_MP":b?e=$?"DONUT_NATIVE_APP":"WX_MP":R?e="UNI_NATIVE_APP":E?e="NS_NATIVE_APP":U&&(e="RN_NATIVE_APP"),_[e]}(),F=(!function(){var e=N.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){var e,t,s=N.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);s&&(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e)&&t&&parseFloat(s[1]+"."+s[2])}(),/MSIE/.test(N)||-1{var s=o.find(e=>e.key===t);s?s.value!==e&&(s.value=e,r=!0):(o.push({key:t,value:e}),r=!0)}),r}function et(e){return ke(e)?[]:e.filter(e=>!0===e.isModified)}function st(e){var t;if(Ke(e)&&Ke(e.webhookInfo))return t=[],e.webhookInfo.disableCloudMessagePreHook&&t.push("ForbidBeforeSendMsgCallback"),e.webhookInfo.disableCloudMessagePostHook&&t.push("ForbidAfterSendMsgCallback"),0!==t.length?t:void 0}function ot(e){return ke(e)?[]:e.filter(e=>!1===e.isModified)}let rt=e=>e===de,it=({type:e,groupID:t})=>e===_e||(""+t).startsWith(Ue)&&!(""+t).includes(qe),nt=e=>(""+e).startsWith(Ue)&&(""+e).includes(qe);function at(e){return e.split(qe)[0]}function ut(){return!F&&!w}function pt(e,t=!0,s=!0){var o=Date.now();return t?s?o-e+" ms":Math.round((o-e)/1e3)+" s":s?o-e:Math.round((o-e)/1e3)}let lt=0;function ct(){return ut()?"%c Chat %c":"Chat"}function ht(){(e=new Date).setTime(Pe());var e;return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}let gt={arguments2String(s){let o="";if(1===s.length)o=s[0];else for(let e=0,t=s.length;e{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(t){if(t instanceof Error){if(!this._sentFlag){let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{let e=wt;this.setCode(e)}this.setLevel("error")}}else gt.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(e){return je(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Ve(e)?this.code=e:gt.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return je(e)||this._sentFlag||(Ve(e)&&(this.message=e.toString()),He(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return je(e)||this._sentFlag||(this.level=es[e]),this}setMoreMessage(e){return ke(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return je(e)?gt.w(this._n+".setNetworkType value is undefined, please check!"):(e=ts[e.toLowerCase()],je(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}let rs="send_group_msg",is="get_joined_group_list",ns="get_group_self_member_info",as="create_group",us="destroy_group",ps="modify_group_base_info",ls="apply_join_group",cs="apply_join_group_noauth",hs="quit_group",gs="get_group_public_info",ms="change_group_owner",ds="handle_apply_join_group",_s="handle_invite_join_permission_group",fs="handle_invite_join_group",Ms="group_msg_recall",Is="msg_read_report",ys="group_msg_get",Ds="get_group_msg_receipt",Ls="group_msg_receipt",Cs="get_group_msg_receipt_detail",Gs="get_group_msg_receipts_by_users",bs="get_pendency",As="deletemsg",vs="get_msg",Ts="get_msg_noauth",Ss="get_online_member_num",Ps="delete_group_ramble_msg_by_seq",Rs="modify_group_msg",$s="set_group_attr",ws="modify_group_attr",Es="delete_group_attr",Us="clear_group_attr",qs="get_group_attr",Ns="group_set_key_values",ks="group_get_key_values",Os="batch_get_group_notify",Fs="update_group_counter",xs="get_group_counter",Vs="pin_message",Hs="unpin_message",Ks="get_pinned_messages",Bs="get_huge_group_msg",js="get_group_member_info",Js="get_members",Ws="get_specified_group_member_info",zs="add_group_member",Xs="delete_group_member",Ys="ban_group_member",Qs="modify_group_member_info",Zs="modify_user_info",eo="unSend",to="success",so="notStart",oo="resolved",ro="rejected";class io{constructor(e){this.type=J,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}function no(t,s,e,o=[]){if(!t)return t;let r=t,i=!1;if(!ke(s)){let e=/^(https?:\/\/[^/]+)/;e.test(t)&&(r=t.replace(e,s),i=!0)}t=function(e,t){let s=!1;if(e){var e=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),o=e&&e[2]||"";if(o.includes("rich-dev"))return!0;for(let e=0;e{e.imageUrl=uo(e.imageUrl)});else if(e===Q)t.remoteSnapshotUrl=uo(t.remoteSnapshotUrl),t.remoteThumbUrl=uo(t.remoteThumbUrl),t.remoteVideoUrl=uo(t.remoteVideoUrl);else if(e===z)t.remoteAudioUrl=uo(t.remoteAudioUrl);else if(e===X)t.remoteFileUrl=uo(t.remoteFileUrl);else if(e===oe){let{downloadKey:e="",messageList:t=[]}=s[0].content||s[0].payload;ke(e)&&t.forEach(e=>{ao(e.messageBody[0].type,e.messageBody,o)})}return s}function uo(e){if(!e)return e;if(-1===e.indexOf("authKey="))return e;var e=e.split("?"),t=e[1].split("&");let s=0;for(let e=0;e{switch(e){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;case"operatorInfo":this.content.operatorInfo={},this._initOperatorInfo(t[e]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[e]=t[e],this.content.memberCount=t[e];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(t[e]);break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(t){var s=Object.keys(t);for(let e=0;e{switch(e){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;default:this.content[e]=t[e]}})}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e{!e.imageUrl&&e.url&&(e.imageUrl=e.url,e.sizeType=e.type,1===e.type?e.type=0:3===e.type&&(e.type=1))}):e===Q?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===z?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===X&&!t.fileUrl&&t.url&&(t.remoteFileUrl=t.url,t.fileUrl=t.url,t.url=void 0)}_updateRichMediaDownloadUrl(e,t,s,o,r){(s||o)&&(e===W?t.imageInfoArray.forEach(e=>{e.imageUrl=no(e.imageUrl,void 0,o,r),e.url=no(e.url,s,o,r)}):e===Q?(t.remoteVideoUrl=no(t.remoteVideoUrl,void 0,o,r),t.videoUrl=no(t.videoUrl,s,o,r),t.remoteThumbUrl=no(t.thumbUrl,void 0,o,r),t.remoteSnapshotUrl=no(t.thumbUrl,void 0,o,r),t.thumbUrl=no(t.thumbUrl,s,o,r),t.snapshotUrl=no(t.thumbUrl,s,o,r),t.snapshotHeight=t.thumbHeight,t.snapshotWidth=t.thumbWidth):e===z?(t.remoteAudioUrl=no(t.remoteAudioUrl,void 0,o,r),t.url=no(t.url,s,o,r)):e===X&&(t.remoteFileUrl=no(t.fileUrl,void 0,o,r),t.fileUrl=no(t.fileUrl,s,o,r)))}}var Lo=class{constructor(n,a,u,p){if(this.type=oe,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},n.downloadKey){let{downloadKey:e,pbDownloadKey:t,title:s,abstractList:o,compatibleText:r,version:i}=n;this.content.downloadKey=e,this.content.pbDownloadKey=t,this.content.title=s,this.content.abstractList=o,this.content.compatibleText=r,this.content.version=i||0}else if(ke(n.messageList))1===n.layersOverLimit&&(this.content.layersOverLimit=!0);else{let{messageList:e,title:t,abstractList:s,compatibleText:o,version:r}=n,i=[];e.forEach(e=>{ke(e)||(e=new Do(e,a,u,p),i.push(e))}),this.content.messageList=i,this.content.title=t,this.content.abstractList=s,this.content.compatibleText=o,this.content.version=r||0}}sendable(){return!ke(this.content.messageList)||!ke(this.content.downloadKey)}};let Co={1:re,2:ie,3:ne,4:ae};class Go{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||ue,this.conversationSubType=e.conversationSubType,this.time=e.time||Math.ceil(Date.now()/1e3),this.sequence=e.sequence||0,this.clientSequence=e.clientSequence||e.sequence||0,this.random=e.random||0===e.random?e.random:Xe(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=function(e){let t=e&&1{e!==Se?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(Se))}),Be(e.groupAtInfo)&&e.groupAtInfo.forEach(e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(Se)})}getGroupAtInfoList(){return this._groupAtInfoList}_initProxy(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}reInitialize(e){e&&(this.status=this.from?to:eo,!this.from)&&(this.from=e),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===pe&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(o){if(!o)return!1;if(void 0===Ye[o]){var r=new Date;let e=("3"+r.getHours()).slice(-2),t=("0"+r.getMinutes()).slice(-2),s=("0"+r.getSeconds()).slice(-2);Ye[o]=parseInt([e,t,s,"0001"].join("")),e=null,t=null,s=null,gt.l("autoIncrementIndex start index:"+Ye[o])}return Ye[o]++}(e)),0===this.sequence&&this.conversationType===ue&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===ce&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}_initFlow(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}_concatConversationID(e){var t=this["to"],s=this.conversationType;s!==ce?(e=s===ue?e===this.from?t:this.from:this.to,this.conversationID=e?""+s+e:null):this.conversationID=ce}isElement(e){return e instanceof io||e instanceof po||e instanceof lo||e instanceof co||e instanceof fo||e instanceof Io||e instanceof go||e instanceof _o||e instanceof Mo||e instanceof yo||e instanceof Lo}setElement(t,s,o,r){if(this.isElement(t))this._elements=[t];else{var i=e=>{if(e.type&&e.content)switch(e.type){case J:this.setTextElement(e.content);break;case W:this.setImageElement(e.content,s,o,r);break;case z:this.setAudioElement(e.content,s,o,r);break;case X:this.setFileElement(e.content,s,o,r);break;case Q:this.setVideoElement(e.content,s,o,r);break;case se:this.setCustomElement(e.content);break;case Z:this.setLocationElement(e.content);break;case ee:this.setGroupTipElement(e.content);break;case te:this.setGroupSystemNoticeElement(e.content);break;case Y:this.setFaceElement(e.content);break;case oe:this.setMergerElement(e.content,s,o,r)}};if(Be(t))for(let e=0;e{e.reason=t})}var{nick:s,avatar:o}=t,s=(He(s)&&(this.nick=s),He(o)&&(this.avatar=o),new go(e));this._elements.push(s)}setGroupSystemNoticeElement(e){e=new _o(e);this._elements.push(e)}setFaceElement(e){e=new lo(e);this._elements.push(e)}setMergerElement(e,t,s,o){e=new Lo(e,t,s,o);this._elements.push(e)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(e){if(!je(e)){if(He(e)&&-1!==Object.values(Co).indexOf(e))return e;if(Ve(e)){e=""+e;if(-1!==Object.keys(Co).indexOf(e))return Co[e]}}return ie}setNickAndAvatar(e){var{nick:e,avatar:t}=e;He(e)&&(this.nick=e),He(t)&&(this.avatar=t)}setNameCard(e){He(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===ue&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}}class bo{constructor(e){this._grpM=e,this._n="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4}onCheckTimer(e){e%1==0&&0{var s=this._checkCountMap.get(t),o=this._grpM.hasLocalGroup(t);gt.l(this._n+`._check groupID:${t} hasLocalGroup:${o} checkCount:`+s),o?(this._notifyCachedGroupTips(t),this._checkCountMap.delete(t),this._grpM.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupTips(t),this._checkCountMap.delete(t)):this._checkCountMap.set(t,++s)})}onNewGroupTips(e){gt.l(this._n+".onNewGroupTips options:"+JSON.stringify(e.dataList));var{eventDataList:e,result:t,AVChatRoomMessageList:s}=this._assembly(e);0{switch(e.payload.operationType){case 1:this._onNewMemberComeIn(e);break;case 2:this._onMemberQuit(e);break;case 3:this._onMemberKickedOut(e);break;case 4:this._onMemberSetAdmin(e);break;case 5:this._onMemberCancelledAdmin(e);break;case 6:this._onGroupProfileModified(e);break;case 7:this._onMemberInfoModified(e);break;case 8:this._onTopicProfileUpdated(e);break;default:gt.w(this._n+"._handleTips unknown operationType:"+e.payload.operationType)}})}_onNewMemberComeIn(e){var{memberNum:e,groupProfile:{groupID:t}}=e.payload,t=this._grpM.getLocalGroupProfile(t);t&&Ve(e)&&t.memberCount!==e&&(t.memberCount=e,this._updateConvGroupProfile(t))}_onMemberQuit(e){var{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._grpM.getLocalGroupProfile(s);o&&Ve(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConvGroupProfile(o)),this._grpM.getGroupMemberHandler().deleteLocalGroupMembers(s,e.payload.userIDList)}_onMemberKickedOut(e){var{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._grpM.getLocalGroupProfile(s);o&&Ve(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConvGroupProfile(o)),this._grpM.getGroupMemberHandler().deleteLocalGroupMembers(s,e.payload.userIDList)}_updateConvGroupProfile(e){this._grpM.get(o).updateConvGroupProfile([e])}_onMemberSetAdmin(e){let t=e.payload.groupProfile.groupID,s=e.payload.userIDList,o=this._grpM.getGroupMemberHandler();s.forEach(e=>{e=o.getLocalGroupMemberInfo(t,e);e&&e.updateRole(ye)})}_onMemberCancelledAdmin(e){let t=e.payload.groupProfile.groupID,s=e.payload.userIDList,o=this._grpM.getGroupMemberHandler();s.forEach(e=>{e=o.getLocalGroupMemberInfo(t,e);e&&e.updateRole(De)})}_onGroupProfileModified(e){let{newGroupProfile:t,groupProfile:s,operatorInfo:o}=e.payload,r=s["groupID"],i=this._grpM.getLocalGroupProfile(r);Object.keys(t).forEach(e=>{switch(e){case"ownerID":this._ownerChanged(i,t);break;case"groupName":i.name=t[e];break;default:i[e]=t[e]}}),je(o)||i.selfInfo.userID!==o.userID||Object.keys(o).forEach(t=>{if("nameCard"===t)i.updateSelfInfo({nameCard:o[t]});else if("role"===t){let e="";400===o[t]?e=Ie:300===o[t]?e=ye:200===o[t]&&(e=De),i.updateSelfInfo({role:e})}});e=!i.isSupportTopic;this._grpM.emitGroupListUpdate(!0,e)}_ownerChanged({groupID:r},e){var i=this._grpM.getLocalGroupProfile(r),n=this._grpM.getMyUserID(),a=e["ownerID"];if(n===a){let e=this._grpM.getGroupMemberHandler(),t=e.getLocalGroupMemberInfo(r,n),s=this._grpM.getLocalGroupProfile(r).ownerID,o=e.getLocalGroupMemberInfo(r,s);i.updateGroup({ownerID:a,selfInfo:{role:Ie}}),t&&t.updateRole(Ie),o&&o.updateRole(De)}}_onMemberInfoModified(e){let{to:t,payload:{groupProfile:s,memberList:o}}=e,r=s.groupID,i=(nt(t)&&this._updateTopicMuteTime(e),this._grpM.getGroupMemberHandler());o.forEach(e=>{var t=i.getLocalGroupMemberInfo(r,e.userID);t&&Ve(e.muteTime)&&t.updateMuteUntil(e.muteTime)})}_updateTopicMuteTime(e){var{to:e,payload:{groupProfile:t,memberList:o=[]}}=e,t=t["groupID"],r=this._grpM.get(s).getLocalTopic(t,e);if(r){let s=!1;for(let t=0;t{this.onNewGroupTips(e)}),this._deleteCachedGroupTips(e)}_cacheAndCompare(e){var{groupID:e,event:t,item:s,groupType:o}=e,t=(gt.l(this._n+`._cacheAndCompare groupID:${e} groupType:`+o),this._cacheGroupTips(e,{event:t,dataList:[s]}),{groupID:e,type:o});o===de?this._grpM.hasLocalGroup(e)?this._notifyCachedGroupTips(e,o):this._grpM.setUnjoinedAVChatRoom(e):(this._grpM.updateGroupMap([t]),this._notifyCachedGroupTips(e,o)),this._checkCountMap.has(e)||this._checkCountMap.set(e,0)}reset(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear()}}class Ao{constructor(e){this._grpM=e,this._n="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this.PAGING_GRP_COUNT_LIMIT=200,this._pagingStatus=so,this._pagingGetCostList=[],e.getIEmitInst().on(Xt.A2KEY_AND_TINYID_UPDATED,this.syncGroupList,this)}onCheckTimer(e){e%1==0&&0{var s=this._checkCountMap.get(t),o=this._grpM.hasLocalGroup(t);gt.l(this._n+`._check groupID:${t} hasLocalGroup:${o} checkCount:`+s),o?(this._notifyCachedGroupMessage(t),this._checkCountMap.delete(t),this._grpM.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupMessage(t),this._checkCountMap.delete(t)):this._checkCountMap.set(t,++s)})}updateLastMsg(i){var e=this._n+".updateLastMsg";if(0===this._grpM.getGroupMap().size)this.tempConversationList=i;else{let t,s,o,r=!1;var n,a,u=i.length;for(let e=0;ee.sequence-t.sequence);var I=this._grpM.get(o),y=this._grpM.get(t);for(let a=0;a{let t=e.elements["revokedInfos"],{revokerInfo:n,groupProfile:a}=e,u=!1;a&&(u=it({groupID:a.groupID})||!ke(a.topicID)),je(t)||t.forEach(t=>{var s=ke(t.topicID)?"GROUP"+t.groupID:"GROUP"+t.topicID,e=p.getLocalConversation(s),o=t.revokerInfo&&t.revokerInfo.revoker||n&&n.revoker,r=n&&n.reason||"";let i;if(e&&rt(e.type))i={conversationID:s,sequence:t.sequence,ID:`${t.tinyID}-${t.clientTime}-`+t.random};else{let e=p.revoke(s,t.sequence,t.random);e?i=e:(i={conversationID:s,sequence:t.sequence},t.tinyID&&t.clientTime&&t.random&&(i.ID=`${t.tinyID}-${t.clientTime}-`+t.random),t.time&&(i.time=t.time))}i&&(i.revoker=o,i.revokeReason=r,i.revokerInfo={userID:o,nick:"",avatar:""},(u?(i.revokerInfo.nick=a.nick,i.revokerInfo.avatar=a.avatar,l):g).push(i))})}),0===g.length&&0===l.length||(p.onMessageRevoked([...l,...g],t),0{this._grpM.emitOEvt(Ft,e)}))}_groupListTreeShaking(s){let o=new Map([...this._grpM.getGroupMap()]);for(let e=0,t=s.length;e{o.delete(e)}),this._grpM.getGroupMap().forEach((e,t)=>{e.isSupportTopic&&o.delete(t)});var r=[...o.keys()];for(let e=0,t=r.length;e{var e=function(e){if(Be(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}}(this._pagingGetCostList),t=function(e){if(Be(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}}(this._pagingGetCostList),t=(this._pagingGetCostList.length=0,this._pagingStatus=oo,this._groupListTreeShaking(o),this._grpM.updateGroupMap(o),`count:${this._grpM.getLocalGroupList().length} sum:${t} avg:`+e);return gt.l(r+" ok. "+t),i.setMessage(t).end(),this.tempConversationList&&(this.updateLastMsg(this.tempConversationList),this.tempConversationList=null),this._grpM.emitGroupListUpdate(!0,!0),mt({groupList:this._grpM.getLocalGroupList()})}).catch(e=>(this._pagingStatus=ro,i.setError(e).end(),gt.e(r+" failed. error:",e),zt(e)))}getGroupList(){let t=this._n+".getGroupList";var e;return gt.l(t+" pagingStatus:"+this._pagingStatus),this._pagingStatus===ro||this._pagingStatus===so?this.syncGroupList().then(()=>{var e=this._grpM.getLocalGroupList();return mt({groupList:e,isSyncCompleted:this.isPagingGetCompleted()})}).catch(e=>(gt.e(t+" failed. error:",e),zt(e))):(e=this._grpM.getLocalGroupList(),gt.l(t+". returned group count:"+e.length),Wt({groupList:e,isSyncCompleted:this.isPagingGetCompleted()}))}isPagingGetCompleted(){return this._pagingStatus===oo}_pagingGetGroupList(e){let o=this._n+"._pagingGetGroupList",{isCommunityRelay:r=!1,limit:i,offset:n,groupBaseInfoFilter:a,groupList:u}=e,t=void 0,p=(r&&(t=_e,a.push("AtInfoList")),Date.now());return this._grpM.req({P:is,data:{type:t,memberAccount:this._grpM.getMyUserID(),limit:i,offset:n,responseFilter:{groupBaseInfoFilter:a,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]}}}).then(e=>{var{groups:e=[],totalCount:t}=e.data,e=(u.push(...e),this._handleGroupAtInfoWithoutTopic(r,e),n+i),s=!(e10018===e.code?(gt.w(this.logPrefix+" response size exceeds the limit, request count:"+i),i=50,this._pagingGetGroupList({limit:i,offset:n,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:r})):r?(11e3===e.code&>.l(o+" ok. community unavailable"),Wt({groupList:u})):zt(e))}_pagingGetGroupListWithTopic(e){let o=this._n+"._pagingGetGroupListWithTopic",{limit:r,offset:i,groupBaseInfoFilter:n,groupList:a}=e,u=Date.now();return this._grpM.req({P:is,data:{type:_e,memberAccount:this._grpM.getMyUserID(),limit:r,offset:i,responseFilter:{groupBaseInfoFilter:n,selfInfoFilter:[...C]},isSupportTopic:1,needAppDefineData:1}}).then(e=>{var{groups:e=[],totalCount:t}=e.data,e=(a.push(...e),i+r),s=!(e!0===e.isSupportTopic);return mt({groupList:t})}).catch(e=>10018===e.code?(gt.w(this.logPrefix+" response size exceeds the limit, request count:"+r),r=50,this._pagingGetGroupListWithTopic({limit:r,offset:i,groupBaseInfoFilter:n,groupList:a})):zt(e))}_cacheGroupMessage(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}_deleteCachedGroupMessage(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}_notifyCachedGroupMessage(e,t){var s=this._cachedGroupMessageMap.get(e)||[];gt.l(this._n+`._notifyCachedGroupMessage groupID:${e} groupType:${t} count:`+s.length),s.forEach(e=>{this.onNewMessage(e)}),this._deleteCachedGroupMessage(e)}_cacheAndCompare(e){var{groupID:e,event:t,item:s,groupType:o}=e,t=(gt.l(this._n+`._cacheAndCompare groupID:${e} groupType:`+o),this._cacheGroupMessage(e,{event:t,dataList:[s]}),{groupID:e,type:o});o===de?this._grpM.hasLocalGroup(e)?this._notifyCachedGroupMessage(e,o):this._grpM.setUnjoinedAVChatRoom(e):(this._grpM.updateGroupMap([t]),this._notifyCachedGroupMessage(e,o)),this._checkCountMap.has(e)||this._checkCountMap.set(e,0)}_handleGroupAtInfoWithoutTopic(e,t){e&&0!==t.length&&t.forEach(e=>{let{groupID:t,groupAtInfoList:s}=e,r=[];je(s)||(s.forEach(e=>{r.push({...e,groupID:t})}),this._grpM.get(o).onNewGroupAtTips({dataList:r}))})}setPagingGroupCount(e){je(e)||(this.PAGING_GRP_COUNT_LIMIT=parseInt(e,10))}reset(){this.PAGING_GRP_COUNT_LIMIT=200,this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._pagingStatus=so,this._pagingGetCostList=[]}}let vo=1,To=2,So=3,Po=4,Ro=5;class $o{constructor(e){this._grpM=e,this._n="GroupAttributesHandler",this._groupAttributesMap=new Map,this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4,this._grpM.getIEmitInst().on(Xt.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._grpM.getCloudConfig("grp_attr_cache_time");je(e)||(this.CACHE_EXPIRE_TIME=Number(e))}updateLocalMainSequenceOnReconnected(){this._groupAttributesMap.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdatedNotice(e){var{to:e,elements:{newGroupProfile:t}}=e,s=!je(t)&&!ke(t.groupAttributeOption);return s&&this._onGroupAttributesUpdated({groupID:e,groupAttributeOption:t.groupAttributeOption}),s}_onGroupAttributesUpdated(e){let{groupID:t,groupAttributeOption:s}=e,{mainSequence:o,isWithChangedAttributeInfo:r,groupAttributeList:i=[],operationType:n}=s;if(gt.l(this._n+".onGroupAttributesUpdated. "+`groupID:${t} isWithChangedAttributeInfo:${r} operationType:`+n),!je(n)){this._groupAttributesCopy=this._getCachedAttributes({groupID:t});e=this._getLocalGroupAttributes(t)["localMainSequence"],e=o-e;if(0!=e)if(1===r&&1==e)this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:i,operationType:n}),this._emitGroupAttributesUpdated(t);else if(this._hasLocalGroupAttributes(t)){let e=this._getLocalGroupAttributes(t)["avChatRoomKey"];this._getGroupAttributes({groupID:t,avChatRoomKey:e}).then(()=>{this._emitGroupAttributesUpdated(t)})}}}initGroupAttributesCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupAttributesMap.set(e,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:t}),gt.l(this._n+`.initGroupAttributesCache groupID:${e} avChatRoomKey:`+t)}initGroupAttributes(e){let{groupID:s,groupAttributes:o}=e,{remoteMainSequence:t,avChatRoomKey:r}=this._getLocalGroupAttributes(s),i=new os("initGroupAttributes");return i.setMessage(`groupID:${s} avChatRoomKey:${r} mainSequence:`+t),this._grpM.req({P:$s,data:{groupID:s,avChatRoomKey:r,mainSequence:t,groupAttributeList:this._transformGroupAttributes(o)}}).then(e=>{gt.l(this._n+".initGroupAttributes ok. groupID:"+s);var{mainSequence:e,groupAttributeList:t}=e.data,t=[...t];return t.forEach(e=>{e.value=o[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:s}),this._refreshCachedGroupAttributes({groupID:s,remoteMainSequence:e,groupAttributeList:t,operationType:vo}),this._emitGroupAttributesUpdated(s),i.end(),mt({groupAttributes:o})}).catch(e=>(i.setError(e).end(),zt(e)))}setGroupAttributes(e){let s=this._n+".setGroupAttributes",{groupID:o,groupAttributes:r}=e,{remoteMainSequence:t,avChatRoomKey:i,attributes:n}=this._getLocalGroupAttributes(o),a=this._transformGroupAttributes(r),u=(a.forEach(e=>{var t=e["key"];e.sequence=0,n.has(t)&&(e.sequence=n.get(t).sequence)}),new os("setGroupAttributes"));return u.setMessage(`groupID:${o} groupAttributes:`+JSON.stringify(r)),gt.l(s+`. groupID:${o} mainSequence:`+t),this._grpM.req({P:ws,data:{groupID:o,avChatRoomKey:i,mainSequence:t,groupAttributeList:a}}).then(e=>{gt.l(s+" ok.");var{mainSequence:e,groupAttributeList:t}=e.data,t=[...t];return t.forEach(e=>{e.value=r[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:o}),this._refreshCachedGroupAttributes({groupID:o,remoteMainSequence:e,groupAttributeList:t,operationType:To}),this._emitGroupAttributesUpdated(o),u.end(),mt({groupAttributes:r})}).catch(e=>(u.setError(e).end(),zt(e)))}deleteGroupAttributes(e){let{groupID:t,keyList:s=[]}=e,{remoteMainSequence:o,avChatRoomKey:r,attributes:i}=this._getLocalGroupAttributes(t),n=[...i.keys()],a=Us,u=So,p={groupID:t,avChatRoomKey:r,mainSequence:o},l=[],g=(0{let t=0;i.has(e)&&(t=i.get(e).sequence,n.push(e)),l.push({key:e,sequence:t})}),p.groupAttributeList=l),new os("deleteGroupAttributes"));return g.setMessage(`groupID:${t} mainSequence:${o} keyList:${s} proto:`+a),this._grpM.req({P:a,data:p}).then(e=>{gt.l(this._n+".deleteGroupAttributes ok. groupID:"+t);e=e.data.mainSequence;return this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:e,groupAttributeList:l,operationType:u}),this._emitGroupAttributesUpdated(t),g.end(),mt({keyList:n})}).catch(e=>(g.setError(e).end(),zt(e)))}getGroupAttributes(t){let s=this._n+".getGroupAttributes",o=t["groupID"],{avChatRoomKey:e,lastUpdateTime:r,localMainSequence:i,remoteMainSequence:n}=this._getLocalGroupAttributes(o),a=new os("getGroupAttributes");if(a.setMessage(`groupID:${o} localMainSequence:${i} remoteMainSequence:${n} keyList:`+t.keyList),Date.now()-r>=this.CACHE_EXPIRE_TIME||i{a.setMoreMessage("from remote. count:"+e.length).end(),gt.l(s+" from remote. groupID:"+o);e=this._getCachedAttributes(t);return mt({groupAttributes:e})}).catch(e=>(a.setError(e).end(),zt(e)));a.setMoreMessage(`from cache localMainSequence:${i} remoteMainSequence:`+n).end(),gt.l(s+" from cache. groupID:"+o);var u=this._getCachedAttributes(t);return Wt({groupAttributes:u})}_getGroupAttributes(o){let e=0;return je(o.avChatRoomKey)||(e=1),this._grpM.req({P:qs,data:{...o,groupType:e}}).then(e=>{gt.l(this._n+"._getGroupAttributes ok. groupID:"+o.groupID);var{mainSequence:e=0,groupAttributeList:t}=e.data,s=[...t];return this._refreshCachedGroupAttributes({groupID:o.groupID,remoteMainSequence:e,groupAttributeList:s,operationType:Ro}),t}).catch(e=>zt(e))}_refreshCachedGroupAttributes(e){var{groupID:s,remoteMainSequence:o,groupAttributeList:r,operationType:i}=e;if(this._hasLocalGroupAttributes(s)){let e=this._getLocalGroupAttributes(s),t=e["localMainSequence"];if(i===Ro||o-t==1)e.remoteMainSequence=o,e.localMainSequence=o,e.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:e,groupAttributeList:r,operationType:i});else{if(t===o)return;e.remoteMainSequence=o}this._groupAttributesMap.set(s,e);r=`operationType:${i} localMainSequence:${t} remoteMainSequence:`+o;gt.l(this._n+"._refreshCachedGroupAttributes. "+r)}}_getCachedAttributes(e){let{groupID:s,keyList:o=[]}=e,r={};if(this._hasLocalGroupAttributes(s)){let t=this._getLocalGroupAttributes(s)["attributes"];if(0{t.has(e)&&(r[e]=t.get(e).value)});else for(let e of t.keys())r[e]=t.get(e).value}return r}_updateCachedAttributes(e){let{groupAttributes:o,groupAttributeList:t,operationType:s}=e;s!==So?s!==Po?(s===vo&&o.attributes.clear(),t.forEach(e=>{var{key:e,value:t,sequence:s}=e;o.attributes.set(e,{value:t,sequence:s})})):t.forEach(e=>{o.attributes.delete(e.key)}):o.attributes.clear()}_hasLocalGroupAttributes(e){return this._groupAttributesMap.has(e)}_getLocalGroupAttributes(e){return this._hasLocalGroupAttributes(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesMap.get(e)}_transformGroupAttributes(t){let s=[];return Object.keys(t).forEach(e=>{s.push({key:e,value:t[e]})}),s}_emitGroupAttributesUpdated(e){var t=this._getCachedAttributes({groupID:e}),{updatedKeyList:s,deletedKeyList:o}=this._computeAttrChangedInfo(t);gt.l(`${this._n}._emitGroupAttributesUpdated update:${s.length}, delete:`+o.length),0===s.length&&0===o.length||this._grpM.emitOEvt(Vt,{groupID:e,groupAttributes:t,updatedKeyList:s,deletedKeyList:o})}_computeAttrChangedInfo(t){let s=[],o=[];return Object.keys(t).forEach(e=>{t[e]!==this._groupAttributesCopy[e]&&s.push(e)}),Object.keys(this._groupAttributesCopy).forEach(e=>{je(t[e])&&o.push(e)}),this._groupAttributesCopy={},{updatedKeyList:s,deletedKeyList:o}}deleteLocalGroupAttributes(e){this._hasLocalGroupAttributes(e)&&this._groupAttributesMap.delete(e)}reset(){this._groupAttributesMap.clear(),this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4}}let wo="Set",Eo="Increase",Uo="Decrease";class qo{constructor(e){this._grpM=e,this._n="GroupCountersHandler",this._groupCountersMap=new Map,this.EXPIRE_TIME=3e4,this._grpM.getIEmitInst().on(Xt.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._grpM.getCloudConfig("grp_counter_expire_time");je(e)||(this.EXPIRE_TIME=Number(e))}isGroupCountersNotice(e){var{to:e,elements:{groupCounterInfo:t}}=e;let s=!1;return ke(t)||(this._onGroupCountersUpdated({groupID:e,groupCounterInfo:t}),s=!0),s}_onGroupCountersUpdated(e){let{groupID:o,groupCounterInfo:t}=e;t.forEach(e=>{var{type:e,groupCounterSeq:t,counterList:s=[]}=e;0!==e&&2!==e||(this._updateLocalGroupCounters({groupID:o,groupCounterSeq:t,counterList:s}),s.forEach(e=>{this._grpM.emitOEvt(Ht,{groupID:o,key:e.key,value:e.value})})),1===e&&this._deleteLocalGroupCounters({groupID:o,groupCounterSeq:t,counterList:s})}),gt.l(this._n+"._onGroupCountersUpdated groupID:"+o)}initGroupCountersCache(e){var{groupID:e,avChatRoomKey:t}=e;this._groupCountersMap.set(e,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:t}),gt.l(this._n+`.initGroupCountersCache groupID:${e} avChatRoomKey:`+t)}setGroupCounters(e){if(!this._grpM.canIUse(I.GRP_COUNTER))return this._grpM.noUse("setGroupCounters");let t=this._n+".setGroupCounters",{groupID:s,counters:o}=e,r=this._convertObjectToList(o),i=this._getLocalGroupCounters(s)["avChatRoomKey"],n=`groupID:${s} count:`+r.length,a=new os("setGroupCounters");return a.setMessage(n),gt.l(t+". "+n),this._updateGroupCounters({groupID:s,counterList:r,avChatRoomKey:i,mode:wo}).then(e=>(a.end(),gt.l(t+" ok."),mt({counters:e}))).catch(e=>(a.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}increaseGroupCounter(e){var t="increaseGroupCounter";if(!this._grpM.canIUse(I.GRP_COUNTER))return this._grpM.noUse(t);let s=this._n+"."+t,{groupID:o,key:r,value:i}=e,n=this._getLocalGroupCounters(o)["avChatRoomKey"],a=`groupID:${o} key:${r} value:`+i,u=new os(t);return u.setMessage(a),gt.l(s+". "+a),this._updateGroupCounters({groupID:o,counterList:[{key:r,value:i}],avChatRoomKey:n,mode:Eo}).then(e=>(u.end(),gt.l(s+" ok."),mt({counters:e}))).catch(e=>(u.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}decreaseGroupCounter(e){var t="decreaseGroupCounter";if(!this._grpM.canIUse(I.GRP_COUNTER))return this._grpM.noUse(t);let s=this._n+"."+t,{groupID:o,key:r,value:i}=e,n=this._getLocalGroupCounters(o)["avChatRoomKey"],a=`groupID:${o} key:${r} value:`+i,u=new os(t);return u.setMessage(a),gt.l(s+". "+a),this._updateGroupCounters({groupID:o,counterList:[{key:r,value:i}],avChatRoomKey:n,mode:Uo}).then(e=>(u.end(),gt.l(s+" ok."),mt({counters:e}))).catch(e=>(u.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}getGroupCounters(e){if(!this._grpM.canIUse(I.GRP_COUNTER))return this._grpM.noUse("getGroupCounters");let t=this._n+".getGroupCounters",{groupID:s,keyList:o=[]}=e,{avChatRoomKey:r,lastUpdateTime:i}=this._getLocalGroupCounters(s),n=new os("getGroupCounters");if(n.setMessage("groupID:"+s),Date.now()-i>=this.EXPIRE_TIME)return this._getRemoteGroupCounters({groupID:s,avChatRoomKey:r}).then(e=>{n.setMoreMessage("from remote. count:"+e.length).end(),gt.l(t+" from remote. groupID:"+s);e=this._getLocalCounters(s,o);return mt({counters:e})}).catch(e=>(n.setError(e).end(),zt(e)));n.setMoreMessage("from cache").end(),gt.l(t+" from cache. groupID:"+s);e=this._getLocalCounters(s,o);return Wt({counters:e})}_getRemoteGroupCounters(s){return this._grpM.req({P:xs,data:{...s}}).then(e=>{var{counterList:e=[],groupCounterSeq:t}=e.data;return this._updateLocalGroupCounters({groupID:s.groupID,counterList:e,groupCounterSeq:t}),gt.l(this._n+"._getRemoteGroupCounters ok. groupID:"+s.groupID),e}).catch(e=>zt(e))}_convertObjectToList(t){let s=[];return Object.keys(t).forEach(e=>{s.push({key:e,value:t[e]})}),s}_updateGroupCounters(e){let o=this._n+"._updateGroupCounters",{groupID:t,avChatRoomKey:s,mode:r}=e;return gt.l(o+`. groupID:${t} avChatRoomKey:${s} mode:`+r),this._grpM.req({P:Fs,data:{...e}}).then(e=>{gt.l(o+" ok.");let{counterList:t=[]}=e.data,s={};return t.forEach(e=>{var{key:e,value:t}=e;s[e]=t}),s}).catch(e=>zt(e))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}_getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}_updateLocalGroupCounters(e){var{groupID:o,counterList:r=[],groupCounterSeq:i}=e;if(this._hasLocalGroupCounters(o)){let{counters:s,avChatRoomKey:e,groupCounterSeq:t}=this._getLocalGroupCounters(o);0{var{key:e,value:t}=e;s.set(e,t)}),this._groupCountersMap.set(o,{lastUpdateTime:Date.now(),groupCounterSeq:i,counters:s,avChatRoomKey:e}))}}_deleteLocalGroupCounters(e){var{groupID:s,counterList:o=[],groupCounterSeq:r}=e;if(this._hasLocalGroupCounters(s)){let{counters:t,avChatRoomKey:e}=this._getLocalGroupCounters(s);o.forEach(e=>{t.delete(e.key)}),this._groupCountersMap.set(s,{lastUpdateTime:Date.now(),groupCounterSeq:r,counters:t,avChatRoomKey:e})}}_getLocalCounters(e,s){let o={};if(this._hasLocalGroupCounters(e)){let t=this._getLocalGroupCounters(e)["counters"];if(0{t.has(e)&&(o[e]=t.get(e))});else for(var r of t.keys())o[r]=t.get(r)}return o}reset(){this._groupCountersMap.clear(),this.EXPIRE_TIME=3e4}}class No{constructor(e){var{manager:e,groupID:t,onInit:s,onSuccess:o,onFail:r}=e;this._n="Polling",this._manager=e,this._grpM=e._grpM,this._onInit=s,this._onSuccess=o,this._onFail=r,this._groupID=t,this._timeoutID=-1,this._isRunning=!1,this._proto=vs}start(){var e=this._grpM.isLoggedIn();e||(this._proto=Ts),gt.l(`${this._n}.start pollingInterval:${this._manager.getPollingInterval(this._groupID)} isLoggedIn:`+e),this._isRunning=!0,this._request()}isRunning(){return this._isRunning}_request(){var e=this._onInit(this._groupID);this._grpM.req({P:this._proto,data:e}).then(e=>{this._onSuccess(this._groupID,e),this.isRunning()&&(-1{this._onFail(this._groupID,e),this.isRunning()&&(-1=this.MAX_LENGTH){let e=this.map.entries().next().value[0];this.map.delete(e)}this.map.set(e,1)}has(e){return this.map.has(e)}delete(e){this.has(e)&&this.map.delete(e)}reset(){this.map.clear()}}let Oo=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class Fo{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime="",this.infoSequence="",this.lastInfoTime="",this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:"",lastSequence:"",fromAccount:"",messageForShow:""},this.nextMessageSeq="",this.memberNum="",this.memberCount="",this.maxMemberNum="",this.maxMemberCount="",this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}set memberNum(e){}set maxMemberNum(e){}get memberNum(){return this.memberCount}get maxMemberNum(){return this.maxMemberCount}_initGroup(e){for(var t in e)Oo.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?"muteAllMembers"===t&&He(e[t])?this.muteAllMembers="On"===e[t]:this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}updateGroup(e){e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);e=JSON.parse(JSON.stringify(e));e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),je(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField&&Ze(this.groupCustomField,e.groupCustomField),je(e.memberNum)||(this.memberCount=e.memberNum),je(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),je(e.isSupportTopic)||(this.isSupportTopic=Ve(e.isSupportTopic)?1===e.isSupportTopic:e.isSupportTopic),ze(this,e,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),Be(e.members)&&0{e.userID===this.selfInfo.userID&&ze(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i}){e={nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:r,excludedUnreadSequenceList:i};ze(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}let xo={3:!0,4:!0,5:!0,6:!0,17:!0,20:!0,21:!0,100:!0};class Vo{constructor(e){this._grpM=e,this._n="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._seqSll=new ko(200),this._IDSll=new ko(100),this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60,this.DEFAULT_POLLING_INTERVAL=300,this.MAX_POLLING_INTERVAL=2e3,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._startBroadcastSeq=1,this._broadcastMessageIDMap=new Map,this.DEFAULT_POLLING_SIMPLIFIED_MSG=0,this._pollingIntervalMap=new Map,this._pollingNoMessageCountMap=new Map}hasJoinedAVChatRoom(){let e=[];return 0<(e=0e.type===de):e).length}getJoinedLiveList(){let e=[];return e=0e.type===Me):e}checkJoinedAVChatRoomByID(e){return this._joinedGroupMap.has(e)}getJoinedAVChatRoom(){return 0this._startBroadcastSeq&&(this._startBroadcastSeq=n),Be(s)&&0{e.to=e.groupID}),this.onMessage(s,o);else{r=this._getPollingNoMessageCount(o);if(this._updatePollingNoMessageCount(o,r+=1),r===this.DEFAULT_POLLING_NO_MESSAGE_COUNT){let e=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS;this._pollingIntervalMap.set(o,e)}}this._onBroadcastMessage(a)}}_handleFailure(e,t){}onMessage(t,e){if(Be(t)&&0!==t.length){let i=this._n+".onMessage";e&&(i+=" groupID:"+e),0!==this._getPollingNoMessageCount(e)&&(this._updatePollingNoMessageCount(e,0),this._pollingIntervalMap.set(e,this.DEFAULT_POLLING_INTERVAL));var a=null,u=[],l=this._get(o),h=this._get(p),s=t.length,c=(1e.sequence-t.sequence),this._get(r).isUnlimitedAVChatRoom());let n=!1;if(gt.getLevel()<=0){let e=t.map(e=>e.sequence);gt.l(`${i} count:${e.length} sequenceList:`+e),e.length=0}for(let e=0;e{var{tinyID:e,clientTime:t,random:s,sequence:o}=e,e={conversationID:""+pe+r,ID:e+`-${t}-`+s,revoker:i.revoker,revokeReason:i.reason||"",revokerInfo:{userID:i.revoker,nick:"",avatar:""},sequence:o};n.push(e)}),0!==n.length&&this._get(o).updateRevokerInfo(n).then(e=>{this._grpM.emitOEvt(Ft,e)})}isBroadcastOrNormal(e){return 3===e||17===e}isGroupTip(e){return 4===e||6===e}isGroupSystemNotice(e){return 5===e}restoreGroupTipElements(e={}){var{operatorInfo:t={},operatorID:s,userIDList:o=[],operationType:r}=e,{userID:r=s,avatar:t="",nick:s=""}=(Ve(e.groupJoinType)||1!==r&&2!==r||(e.groupJoinType=2===r?0:1),t),r=(e.operatorInfo={userID:r,avatar:t,nick:s},o.map(e=>({userID:e})));return e.memberInfoList=e.memberInfoList||r,e}restoreMessageFromSimplified(o){let e=o["event"];if(this.isBroadcastOrNormal(e)&&(o.cloudCustomData=o.cloudCustomData||"",o.elements=o.elements.map(e=>{var t;return e.type===se&&({content:t={}}=e,e.content={data:"",description:"",extension:"",...t}),e})),(this.isGroupTip(e)||this.isGroupSystemNotice(e))&&(o.from=o.from||"@TIM#SYSTEM"),this.isGroupTip(e)){o.elements=this.restoreGroupTipElements(o.elements);let{elements:t={}}=o,{operationType:e,operatorInfo:s={}}=t;if(1===e){let e=[{userID:s.userID}];t.memberInfoList=t.memberInfoList||e}}if(this.isGroupSystemNotice(e)){let{memberInfoList:e,operatorInfo:t={}}=o.elements;e=e||t,o.elements.memberInfoList={userID:o.elements.operatorID,avatar:"",nick:"",...e},o.elements={authentication:"",remarkInfo:"",messageKey:1e3*o.time,...o.elements};var s=Object.keys(o.elements).filter(e=>"operatorInfo"!==e).reduce((e,t)=>({...e,[t]:o.elements[t]}),{});o.elements=s}return o}_onGroupDismissed(e){gt.l(this._n+"._onGroupDismissed groupID:"+e),this._grpM.deleteLocalGroupAndConversation(e),this.reset(e)}_checkMessageStacked(e){var t="MessageStacked",e=e.length;100<=e&&(this._grpM.warn(t,e),this._reportMessageStackedCount<5)&&(new os(t).setMessage(`count:${e} groupID:`+[...this._joinedGroupMap.keys()]).setLevel("warning").end(),this._reportMessageStackedCount+=1)}_isMessageSentByCurrentInstance(e){return!!this._get(o).isMessageSentByCurrentInstance(e)}packMessage(e,t){e.currentUser=this._grpM.getMyUserID(),e.conversationType=5===t?ce:pe,e.isSystemMessage=!!e.isSystemMessage;var s=new Go(e),e=this.packElements(e,t),t=this._grpM.getFileDownloadProxy(),o=this._grpM.getDownloadFileAuthKey(),r=this._get(n).getFileDNList();return s.setElement(e,t,o,r),s}packElements(e,t){return 4===t||6===t?(this._updateMemberCountByGroupTips(e),{type:ee,content:{...e.elements,groupProfile:e.groupProfile}}):5===t?{type:te,content:{...e.elements,groupProfile:{...e.groupProfile,groupID:e.groupID}}}:e.elements}packConversationOption(t){var s=new Map;for(let e=0;e{var{longPollingKey:e,group:t}=o,s=t.groupID;return this._joinedGroupMap.set(s,t),this._grpM.updateGroupMap([t]),this._grpM.deleteUnjoinedAVChatRoom(s),this._grpM.emitGroupListUpdate(!0,!1),je(e)?Wt({status:we,group:t}):Promise.resolve()})}startRunLoop(r){return this.handleJoinResult(r).then(()=>{var{longPollingKey:e,group:t,startSeq:s=0}=r,o=t.groupID;return this._pollingRequestInfoMap.set(o,{key:e,startSeq:s}),this.start(o),this._reportLongPollingCount(),this._grpM.isLoggedIn()?Wt({status:we,group:t}):Wt({status:we})})}_preCheck(e){if(!this._get(r).isUnlimitedAVChatRoom()&&this.hasJoinedAVChatRoom()){let[t,e]=this._joinedGroupMap.entries().next().value;if(this._grpM.isLoggedIn()&&e.selfInfo.role!==Ie&&e.ownerID!==this._grpM.getMyUserID())return this._grpM.quitGroup(t,"av").catch(e=>(this.reset(t),Promise.resolve()));this._grpM.deleteLocalGroupAndConversation(t),this.reset(t)}return Promise.resolve()}joinWithoutAuth(e){let s=e["groupID"],r=this._n+".joinWithoutAuth",n=new os("joinWithoutAuth");return this._grpM.req({P:cs,data:e}).then(({data:{longPollingKey:e}})=>{if(n.setMessage(`groupID:${s} longPollingKey:`+e).end(!0),je(e))return zt({code:At});gt.l(r+" ok. groupID:"+s),this._get(o).setCompleted(""+pe+s);var t=new Fo({groupID:s});return this.startRunLoop({group:t,longPollingKey:e}),mt({status:we})}).catch(e=>(gt.e(r+` failed. groupID:${s} error:`,e),n.setError(e).setMessage("groupID:"+s).end(!0),zt(e))).finally(()=>{this._grpM.get(i).reportAtOnce()})}getGroupOnlineMemberCount(e){var t=this._onlineMemberCountMap.get(e)||{},s=Date.now();return ke(t)||s-t.lastSyncTime>1e3*t.expireTime&&1e4mt({memberCount:e.memberCount})).catch(e=>zt(e))):Wt({memberCount:t.memberCount})}_getGroupOnlineMemberCount(r){let i=this._n+"._getGroupOnlineMemberCount",t=new os("_getGroupOnlineMemberCount");return this._grpM.requestOnlineCount(r).then(e=>{var t=this._onlineMemberCountMap.get(r)||{},{memberCount:e=0,expireTime:s=this.DEFAULT_EXPIRE_TIME}=e.data,o=(gt.l(i+` ok. groupID:${r} memberCount:${e} expireTime:`+s),Date.now());return ke(t)&&(t.lastReqTime=o),this._onlineMemberCountMap.set(r,Object.assign(t,{lastSyncTime:o,latestUpdateTime:o,memberCount:e,expireTime:s})),{memberCount:e}}).catch(e=>(gt.w(i+" failed. error:",e),t.setCode(e.code).setMessage(`groupID:${r} error:`+JSON.stringify(e)).end(),Promise.reject(e)))}_get(e){return this._grpM.get(e)}setPollingInterval(e){je(e)||(Ve(e)?this.DEFAULT_POLLING_INTERVAL=e:this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}setPollingIntervalPlus(e){je(e)||(Ve(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}setPollingNoMessageCount(e){je(e)||(Ve(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}setPollingSimplifiedMessage(e){je(e)||"0"!==e&&"1"!==e||(this.DEFAULT_POLLING_SIMPLIFIED_MSG=parseInt(e,10))}getPollingInterval(e){return this._pollingIntervalMap.get(e)||this.DEFAULT_POLLING_INTERVAL}onAVChatRoomMemberBanned(e){e=e.payload.groupProfile.groupID;gt.l(this._n+".onAVChatRoomMemberBanned groupID:"+e),this._grpM.deleteLocalGroupAndConversation(e),this.reset(e)}restartPolling(){gt.l(this._n+".restartPolling count:"+this._pollingInstanceMap.size);for(var e of this._pollingInstanceMap.values())e.stop(),e.start()}getPollingTimerID(e){var t;return this._pollingInstanceMap.has(e)?(t=this._pollingInstanceMap.get(e).getPollingTimerID(),gt.l(this._n+`.getPollingTimerID groupID:${e} timerID:`+t),t):-1}hasPollingInstance(e){return this._pollingInstanceMap.has(e)}onRoomCustomData(e){var{groupID:e,sequence:t,time:s,elements:o}=e,o=o&&o.content;this._get(h).onRoomCustomDataReceived(o),gt.l(this._n+`.onRoomCustomData groupID:${e} sequence:${t} time:${s} data:`+o)}startLiveLongPolling(e){var{group:e,longPollingKey:t,startSeq:s}=e,o=e["groupID"];return this._joinedGroupMap.set(o,e),this._grpM.updateGroupMap([e]),this._pollingRequestInfoMap.set(o,{key:t,startSeq:s}),this.start(o),this._reportLongPollingCount(),Wt({status:we,group:e})}stopLiveLongPolling(e){var t=this._pollingInstanceMap.get(e);t&&t.stop(),this._seqSll.reset(),this._IDSll.reset(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._pollingIntervalMap.delete(e),this._pollingNoMessageCountMap.delete(e),this._reportMessageStackedCount=0}_updatePollingNoMessageCount(e,t){this._pollingNoMessageCountMap.set(e,t)}_getPollingNoMessageCount(e){return this._pollingNoMessageCountMap.get(e)||0}_reportLongPollingCount(){var t=this._joinedGroupMap.size;if(1{(t===Me?o:s).push(e)}),new os("longPollingCount").setMessage(""+t).setMoreMessage(`av:${s.join(",")} live:`+o.join(",")).setEventType(29).setCode(e).end()}}reset(e){if(e){gt.l(this._n+".reset groupID:"+e);var t=this._pollingInstanceMap.get(e);t&&t.stop(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e),this._pollingIntervalMap.delete(e),this._pollingNoMessageCountMap.delete(e)}else{gt.l(this._n+".reset all");for(let e of this._pollingInstanceMap.values())e.stop();this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear(),this._broadcastMessageIDMap.clear(),this._pollingIntervalMap.clear(),this._pollingNoMessageCountMap.clear(),this.DEFAULT_POLLING_INTERVAL=300,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3}this._seqSll.reset(),this._IDSll.reset(),this._reportMessageStackedCount=0}}class Ho{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(e){je(e.onlineStatus)||(this.isOnline="Online"===e.onlineStatus);var t=[null,void 0,"",0,NaN];e.memberCustomField&&Ze(this.memberCustomField,e.memberCustomField),ze(this,e,["memberCustomField","marks","onlineStatus"],t)}updateRole(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}updateMuteUntil(e){je(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}updateNameCard(e){je(e)||(this.nameCard=e)}updateMemberCustomField(e){e&&Ze(this.memberCustomField,e)}}class Ko{constructor(e){this._grpM=e,this._n="GroupMemberHandler",this.groupMemberListMap=new Map,this.avChatRoomMembersReqInfoMap=new Map,this.avChatRoomMembersFreqCount=4,this.avChatRoomMembersFreqInterval=30,this.DEFAULT_MEMBER_INFO_FILTER=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],this._grpM.getIEmitInst().on(Xt.PROFILE_UPDATED,this._onProfileUpdated,this)}setAVChatRoomMembersFrequencyLimit(e){var t;je(e)||({interval:e,count:t}=JSON.parse(e),e&&t&&(this.avChatRoomMembersFreqCount=t,this.avChatRoomMembersFreqInterval=e))}_onProfileUpdated({data:s}){for(let e=0;e{e.has(t.userID)&&e.get(t.userID).updateMember({nick:t.nick,avatar:t.avatar})})}}deleteGroupMemberList(e){this.groupMemberListMap.delete(e)}getGroupMemberList({groupID:r,role:e,offset:s=0,count:o=15,filter:i}){let n=this._n+".getGroupMemberList",a=this._grpM.hasLocalGroup(r);if(gt.l(n+` groupID:${r} role:${e} offset:${s} count:${o} hasLocalGroup:`+a),!a)return Wt({memberList:[],offset:0});if(this._grpM.getLocalGroupProfile(r).type===de){if(this._grpM.canIUse(I.AV_MBR_LIST))return this._isFrequencyOverLimit(r)?zt({code:Ut,message:this._grpM.getErrMsg(Ut,Js+"-"+r)}):this._getAVChatRoomMemberList({groupID:r,offset:s,filter:i});this._grpM.warn("LiveOnlineMember")}let u,p=(e!==ye&&e!==Ie&&e!==De||(u=e),new os("getGroupMemberList")),l=0;i={groupID:r,limit:100(je(o)||(l=ke(o)?0:o),Be(e)&&0!==e.length?(this._grpM.hasLocalGroup(r)&&(this._grpM.getLocalGroupProfile(r).memberNum=s),g=this._updateLocalGroupMemberMap(r,e),this._grpM.get(t).getUserProfile({userIDList:e.map(e=>e.userID),tagList:[$e.NICK,$e.AVATAR]})):(l=0,Promise.resolve([])))).then(e=>{var e=e["data"];return Be(e)&&0!==e.length?(e=e.map(e=>({userID:e.userID,nick:e.nick,avatar:e.avatar})),this._updateLocalGroupMemberMap(r,e),g.length(p.setError(e).end(),gt.e(n+" failed. error:",e),zt(e)))}_getAVChatRoomMemberList({groupID:s,offset:e,filter:t}){let o=this._n+"._getAVChatRoomMemberList",r=new os("_getAVChatRoomMemberList");return r.setMessage(`groupID:${s} offset:${e} filter:`+t),this._grpM.req({P:Js,data:{groupID:s,offset:e,filter:t}}).then(e=>{var{memberList:e=[],offset:t=0}=e.data,e=(r.end(),gt.l(o+` ok. member count:${e.length}, next request timestamp:`+t),e.map(e=>({...e,onlineStatus:"Online"}))),e=this._updateLocalGroupMemberMap(s,e);return mt({memberList:e,offset:t})}).catch(e=>(r.setError(e).end(),gt.e(o+" failed. error:",e),zt(e)))}_isFrequencyOverLimit(e){var t,s;return!this.avChatRoomMembersReqInfoMap.has(e)||({startTime:t,requestCount:s}=this.avChatRoomMembersReqInfoMap.get(e),Date.now()-t>1e3*this.avChatRoomMembersFreqInterval)?(this.avChatRoomMembersReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1):(this.avChatRoomMembersReqInfoMap.set(e,{startTime:t,requestCount:s+=1}),s>this.avChatRoomMembersFreqCount)}getGroupMemberProfile(e){var s="getGroupMemberProfile",o=this._n+"."+s;let r="groupID:"+e.groupID,{groupID:i,userIDList:n}=(5{e=e.data.members;return Be(e)&&0!==e.length?(this._updateLocalGroupMemberMap(i,e),this._grpM.get(t).getUserProfile({userIDList:e.map(({userID:e})=>e),tagList:[$e.NICK,$e.AVATAR]})):Wt([])}).then(e=>{e=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s})),this._updateLocalGroupMemberMap(i,e),e=n.filter(e=>this.hasLocalGroupMember(i,e)).map(e=>this.getLocalGroupMemberInfo(i,e));return u.end(),mt({memberList:e})})}addGroupMember(i){let n=this._n+".addGroupMember",e=i["groupID"],a=this._grpM.getLocalGroupProfile(e),t=a["type"],u=new os("addGroupMember");if(u.setMessage(`groupID:${e} groupType:`+t),rt(t)){let e=new dt({code:bt});return u.setError(e).end(),zt(e)}return i.userIDList=i.userIDList.map(e=>({userID:e})),gt.l(n+" groupID:"+e),this._grpM.req({P:zs,data:i}).then(({data:{members:e}})=>{gt.l(n+" ok");var t=e.filter(e=>1===e.result).map(e=>e.userID),s=e.filter(e=>0===e.result).map(e=>e.userID),o=e.filter(e=>2===e.result).map(e=>e.userID),e=e.filter(e=>4===e.result).map(e=>e.userID),r=`groupID:${i.groupID}, successUserIDList:${t}, failureUserIDList:${s}, existedUserIDList:${o}, overLimitUserIDList:`+e;return u.setMoreMessage(r).end(),0===t.length?mt({successUserIDList:t,failureUserIDList:s,existedUserIDList:o,overLimitUserIDList:e}):(this._updateConvGroupProfile(a),mt({successUserIDList:t,failureUserIDList:s,existedUserIDList:o,overLimitUserIDList:e,group:a}))}).catch(e=>(u.setError(e).end(),gt.e(n+" failed. error:",e),zt(e)))}deleteGroupMember(e){let t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,r=this._grpM.getLocalGroupProfile(s);if(je(r))return zt({code:yt});if(rt(r.type))return this._grpM.canIUse(I.AV_BAN_MBR)?this._banAVChatRoomMember(e):this._grpM.noUse("deleteGroupMember");var i=`groupID:${s} `+(5(n.end(),gt.l(t+" ok"),this._updateConvGroupProfile(r),this.deleteLocalGroupMembers(s,o),mt({group:r,userIDList:o}))).catch(e=>(n.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}_updateConvGroupProfile(e){this._grpM.get(o).updateConvGroupProfile([e])}_banAVChatRoomMember(e){let t=this._n+"._banAVChatRoomMember",{groupID:s,userIDList:o}=e,r=`groupID:${s} `+(5(i.end(),gt.l(t+" ok"),this.deleteLocalGroupMembers(s,o),mt({group:n,userIDList:o}))).catch(e=>(i.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}setGroupMemberMuteTime(e){let{groupID:s,userID:t,muteTime:o}=e,r=this._n+".setGroupMemberMuteTime";if(t===this._grpM.getMyUserID())return zt({code:Pt});e=`groupID:${s} userID:${t} muteTime:`+o;gt.l(r+" "+e);let i=new os("setGroupMemberMuteTime");return i.setMessage(e),this.modifyGroupMemberInfo({groupID:s,userID:t,muteTime:o}).then(e=>{i.end(),gt.l(r+" ok");var t=this._grpM.getLocalGroupProfile(s);return mt({group:t,member:e})}).catch(e=>(i.setError(e).end(),gt.e(r+" failed. error:",e),zt(e)))}setGroupMemberRole(e){let t=this._n+".setGroupMemberRole",{groupID:s,userID:o,role:r}=e,i=`groupID:${s} userID:${o} role:`+r,n=this._grpM.getLocalGroupProfile(s);if(n&&n.selfInfo.role!==Ie)return zt({code:vt});e=[ye,De];if(it({groupID:s})&&e.push(Le),e.indexOf(r)<0)return zt({code:Tt});if(o===this._grpM.getMyUserID())return zt({code:St});let a=new os("setGroupMemberRole");return a.setMessage(i),gt.l(t+" "+i),this.modifyGroupMemberInfo({groupID:s,userID:o,role:r}).then(e=>(a.end(),gt.l(t+" ok"),mt({group:n,member:e}))).catch(e=>(a.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}_filterProfanity(e,t){var s,o=this._grpM.get(c);return!o||({isAllowedToSend:o,modifiedText:s}=o.filterText(t[e],D),!0===o&&(t[e]=s,!0))}setGroupMemberNameCard(e){let t="setGroupMemberNameCard",s=this._n+"."+t;if(e.nameCard&&!1===this._filterProfanity("nameCard",e))return zt({code:Nt});let{groupID:o,userID:r=this._grpM.getMyUserID(),nameCard:i}=e,n=`groupID:${o} userID:${r} nameCard:`+i;gt.l(s+" "+n);e=this._grpM.getLocalGroupProfile(o);if(e&&rt(e.type)){let e=$t;return zt({code:e,message:this._grpM.getErrMsg(e,t)})}let a=new os(t);return a.setMessage(n),this.modifyGroupMemberInfo({groupID:o,userID:r,nameCard:i}).then(e=>{gt.l(s+" ok"),a.end();var t=this._grpM.getLocalGroupProfile(o);return r===this._grpM.getMyUserID()&&t&&t.setSelfNameCard(i),mt({group:t,member:e})}).catch(e=>(a.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}setGroupMemberCustomField(e){let t="setGroupMemberCustomField",s=this._n+"."+t,{groupID:o,userID:r=this._grpM.getMyUserID(),memberCustomField:i}=e,n=`groupID:${o} userID:${r} memberCustomField:`+JSON.stringify(i);gt.l(s+" "+n);e=this._grpM.getLocalGroupProfile(o);if(e&&rt(e.type)){let e=$t;return zt({code:e,message:this._grpM.getErrMsg(e,t)})}let a=new os(t);return a.setMessage(n),this.modifyGroupMemberInfo({groupID:o,userID:r,memberCustomField:i}).then(e=>{a.end(),gt.l(s+" ok");var t=this._grpM.getLocalGroupProfile(o);return mt({group:t,member:e})}).catch(e=>(a.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}modifyGroupMemberInfo(t){let{groupID:s,userID:o}=t,e=void 0;return nt(s)&&(s=at(e=s)),this._grpM.req({P:Qs,data:{...t,groupID:s,topicID:e}}).then(()=>{if(this.hasLocalGroupMember(s,o)){let e=this.getLocalGroupMemberInfo(s,o);return je(t.muteTime)||e.updateMuteUntil(t.muteTime),je(t.role)||e.updateRole(t.role),je(t.nameCard)||e.updateNameCard(t.nameCard),je(t.memberCustomField)||e.updateMemberCustomField(t.memberCustomField),e}let e=this._grpM.getLocalGroupProfile(s);if(e&&!rt(e.type))return this.getGroupMemberProfile({groupID:s,userIDList:[o]}).then(({data:{memberList:[e]}})=>e)})}markGroupMemberList(e){let r=this._n+".markGroupMemberList",{groupID:t,markType:s,enableMark:o,userIDList:i=[]}=e,n=`groupID:${t} markType:${s} enableMark:${o} userIDList count:`+i.length,a=(gt.l(r+" "+n),2),u=[],p=(!0===o&&(a=1),[...i]),l=(500{u.push({userID:e,markType:[s]})}),p=null,new os("markGroupMemberList"));return l.setMessage(n),this._grpM.req({P:Zs,data:{groupID:t,operationType:a,memberList:u}}).then(e=>{let{memberList:t=[]}=e.data,s=[],o=[];t.length===i.length?s.push(...i):(t.forEach(e=>{s.push(e.userID)}),i.forEach(e=>{s.includes(e)||o.push(e)}));e=`success count:${s.length} fail count:`+o.length;return l.setMessage(e).end(),gt.l(r+" ok. "+e),mt({successUserIDList:s,failureUserIDList:o})}).catch(e=>(l.setError(e).end(),gt.e(r+" failed. error:",e),zt(e)))}_getGroupMemberProfileAdvance(e){return this._grpM.req({P:Ws,data:{...e,memberInfoFilter:e.memberInfoFilter||this.DEFAULT_MEMBER_INFO_FILTER}})}_updateLocalGroupMemberMap(t,e){return Be(e)&&0!==e.length?e.map(e=>(this.hasLocalGroupMember(t,e.userID)?this.getLocalGroupMemberInfo(t,e.userID).updateMember(e):this.setLocalGroupMember(t,new Ho(e)),this.getLocalGroupMemberInfo(t,e.userID))):[]}deleteLocalGroupMembers(e,t){let s=this.groupMemberListMap.get(e);s&&t.forEach(e=>{s.delete(e)})}getLocalGroupMemberInfo(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}setLocalGroupMember(e,t){this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).set(t.userID,t):(t=(new Map).set(t.userID,t),this.groupMemberListMap.set(e,t))}getLocalGroupMemberList(e){return this.groupMemberListMap.get(e)}hasLocalGroupMember(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}hasLocalGroupMemberMap(e){return this.groupMemberListMap.has(e)}deleteAVChatRoomMembersReqInfo(e){this.avChatRoomMembersReqInfoMap.delete(e)}reset(){this.groupMemberListMap.clear(),this.avChatRoomMembersReqInfoMap.clear(),this.avChatRoomMembersFreqCount=4,this.avChatRoomMembersFreqInterval=30}}class Bo{constructor(e){this._grpM=e,this._n="GroupPinMessageHandler"}onPinnedMessageNotify(e){let{to:t,elements:{pinnedMessage:s,unPinnedMessageInfo:i,operationType:o,operatorInfo:{userID:r,nick:n="",avatar:a=""}}}=e,u=null,p=!1;if(16===o)p=!0,s.conversationType=pe,(u=new Go(s)).setElement(s.elements[0]),u.pinnerInfo={userID:r,nick:n,avatar:a};else{let{clientTime:e,random:t,senderTinyId:s,serverTime:o,sequence:r}=i;u={ID:`${s}-${e}-`+t,sequence:r,random:t,time:o,clientTime:e}}this._grpM.emitOEvt(jt,{groupID:t,message:u,isPinned:p,operatorInfo:{userID:r,nick:n,avatar:a}})}pinGroupMessage(e){let t=this._n+".pinGroupMessage",{groupID:s,message:o,isPinned:r}=e,i=o["sequence"],n=`groupID:${s} sequence:`+i,a=new os("pinGroupMessage"),u=(a.setMessage(n),gt.l(t+" "+n),s),p=void 0;return nt(s)&&(p=s,u=at(s)),this._grpM.req({P:r?Vs:Hs,data:{groupID:u,topicID:p,sequence:i,operator:this._grpM.getMyUserID()}}).then(e=>(a.end(),gt.l(t+" ok."),mt())).catch(e=>(a.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}getPinnedGroupMessageList(t){let s=this._n+".getPinnedGroupMessageList",o=new os("getPinnedGroupMessageList"),e=(o.setMessage(t),t),r=void 0;return nt(t)&&(r=t,e=at(t)),this._grpM.req({P:Ks,data:{groupID:e,topicID:r}}).then(e=>{var{pinnedMessageList:e=[]}=e.data;return o.setMoreMessage("count:"+e.length).end(),gt.l(s+` ok, groupID:${t} count:`+e.length),this._updatePinnerInfo(t,e).then(e=>mt({messageList:e}))}).catch(e=>(o.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}_updatePinnerInfo(e,r){if(ke(r))return Promise.resolve([]);let i=new Set,n={},a={},u=[],p=[],l=this._grpM.get(o),s=this._grpM.get(t),g=""+pe+e;for(let o=0;o{var[e,{data:t=[]}]=e;return t.forEach(e=>{var{userID:e,nick:t="",avatar:s=""}=e;a[e]={userID:e,nick:t,avatar:s}}),u.push(...e),u.forEach(e=>{var t=e["sequence"],t=n[t],t=a[t]||{userID:t,nick:"",avatar:""};e.pinnerInfo=t}),u.sort((e,t)=>e.sequence-t.sequence),i.clear(),u})}_getMessagesBySequences(s,r){if(ke(r))return Promise.resolve([]);let e=s,t=void 0;return nt(s)&&(t=s,e=at(s)),this._grpM.req({P:ys,data:{groupID:e,topicID:t,reqMsgSeqList:r,getType:3}}).then(e=>{var{messageList:e=[]}=e.data,t=(gt.l(this._n+`.getMessagesBySequences ok, groupID:${s} sequenceList:${r} result:`+e.length),""+pe+s);return this._grpM.get(o).onRoamingMessage(e,t,!1)})}}let jo={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Jo={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Wo(e,t){for(var s in t){var o,r;Object.prototype.hasOwnProperty.call(t,s)&&({range:o,defaultValue:r}=t[s],e[s]=o.includes(e[s])?e[s]:r)}return e}function zo(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Xo(e){let{androidInfo:t={},androidOPPOChannelID:s=""}=e,o=t.OPPOChannelID||s,{sound:r="",FCMChannelID:i="",...n}=Wo(t,jo);return{...n,Sound:zo(r),OPPOChannelID:o,GoogleChannelID:i}}function Yo(e){let{apnsInfo:t={},ignoreIOSBadge:s=!1,disableVoipPush:o}=e,{ignoreIOSBadge:r,disableVoipPush:i,enableIOSBackgroundNotification:n,...a}=Wo(t,Jo),u=!0===r||!0===s?1:0,p=void 0;return je(o)||(p=!1===o?1:0),je(i)||(p=!1===i?1:0),{...a,badgeMode:u,isVoipPush:p,contentAvailable:n?1:0}}function Qo(e){if(Ke(e))return{pushFlag:!0===e.disablePush?1:0,title:e.title||"",desc:e.description||"",ext:e.extension||"",apnsInfo:Yo(e),androidInfo:Xo(e)}}let Zo=1,er=15,tr=[17,18,20];class sr{constructor(e){this._grpM=e,this._n="GroupSystemNoticeHandler",this.pendencyMap=new Map}onNewGroupSystemNotice(e){var{dataList:e,isSyncingEnded:t,isInstantMessage:s}=e,{eventDataList:e,result:r}=(gt.d(this._n+".onReceiveSystemNotice count:"+e.length),this._assembly({notifiesList:e,isInstantMessage:s}));0{e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_`+e.to,e)});let t=this._grpM.get(o).getLocalMessageList(ce),i=[];t.forEach(s=>{let{operatorID:o,operationType:e,groupProfile:r}=s.payload;if(e===Zo){let e=`${o}_${r.groupID}_`+r.to,t=this.pendencyMap.get(e);t&&Ve(t.handled)&&0!==t.handled&&i.push(s)}}),this.deleteGroupSystemNotice({messageList:i})})}deleteGroupSystemNotice(e){let s=this._n+".deleteGroupSystemNotice";return Be(e.messageList)&&0!==e.messageList.length?(gt.l(s+" "+e.messageList.map(e=>e.ID)),this._grpM.req({P:As,data:{messageListToDelete:e.messageList.map(e=>({from:ce,messageSeq:e.clientSequence,messageRandom:e.random}))}}).then(()=>{gt.l(s+" ok");let t=this._grpM.get(o);return e.messageList.forEach(e=>{t.deleteLocalMessage(e)}),mt()}).catch(e=>(gt.e(s+" error:",e),zt(e)))):Wt()}_getPendencyList(e={}){var{type:e,startTime:t=0,limit:s=20}=e;return this._grpM.req({P:bs,data:{type:e,startTime:t,limit:s,handleAccount:this._grpM.getMyUserID()}}).then(e=>{let t=e.data.pendencyList;return 0!==e.data.nextStartTime?this._getPendencyList({startTime:e.data.nextStartTime}).then(e=>[...t,...e]):t})}getGroupApplicationList(){return this._getPendencyList().then(t=>this._getPendencyList({type:_e}).then(e=>(t.push(...e),this._handlePendencyResult(t))).catch(e=>this._handlePendencyResult(t)))}_handlePendencyResult(e){let t=[];return e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_`+e.to,e),0===e.handled&&t.push({applicant:e.from,applicantNick:e.fromUserNickName,groupName:e.groupName,groupID:e.groupID,authentication:e.authentication,messageKey:e.time,applicationType:e.applicationType,userID:e.userID,note:e.note})}),Wt({applicationList:t})}_onReceivedGroupSystemNotice({result:e,isInstantMessage:t}){t&&e.forEach(e=>{switch(e.payload.operationType){case 1:break;case 2:this._onApplyJoinGroup(e);break;case 3:break;case 4:this._onMemberKicked(e);break;case 5:this._onGroupDismissed(e);break;case 6:break;case 7:this._onInviteGroup(e);break;case 8:this._onQuitGroup(e);break;case 9:this._onSetManager(e);break;case 10:this._onDeleteManager(e);break;case 11:case 12:case 15:break;case 20:this._onMessageRemindTypeSynced(e);break;case 21:this._grpM.onAVChatRoomMemberBanned(e)}})}_onApplyJoinGroup(e){var{groupID:e,groupType:t}=e.payload.groupProfile,s=this._grpM.hasLocalGroup(e);gt.l(this._n+`._onApplyJoinGroup groupID:${e} groupType:${t} hasGroup:`+s),s||rt(t)||this._grpM.getGroupProfile({groupID:e}).then(({data:{group:e}})=>{e&&(this._grpM.updateGroupMap([e]),e=!e.isSupportTopic,this._grpM.emitGroupListUpdate(!0,e))})}_onMemberKicked(e){e=e.payload.groupProfile.groupID;this._grpM.hasLocalGroup(e)&&this._grpM.deleteLocalGroupAndConversation(e)}_onGroupDismissed(e){var e=e.payload.groupProfile.groupID,t=(this._grpM.hasLocalGroup(e)&&this._grpM.deleteLocalGroupAndConversation(e),this._grpM)["_AVChatRoomHandler"];t&&t.checkJoinedAVChatRoomByID(e)&&t.reset(e)}_onInviteGroup(e){let t=e.payload.groupProfile.groupID,s=this._grpM.hasLocalGroup(t);gt.l(`${this._n}._onInviteGroup groupID:${t} hasGroup:`+s),this._grpM.getGroupProfile({groupID:t}).then(()=>{this._grpM.emitGroupListUpdate(),this._grpM.get(o).pullMsgOnInvite(""+pe+t)})}_onQuitGroup(e){var{groupID:e,groupType:t}=e.payload.groupProfile,s=this._grpM.hasLocalGroup(e);gt.l(this._n+`._onQuitGroup groupID:${e} groupType:${t} hasGroup:`+s),s&&this._grpM.deleteLocalGroupAndConversation(e)}_onSetManager(e){var{to:e,groupID:t}=e.payload.groupProfile,t=this._grpM.getGroupMemberHandler().getLocalGroupMemberInfo(t,e);t&&t.updateRole(ye)}_onDeleteManager(e){var{to:e,groupID:t}=e.payload.groupProfile,t=this._grpM.getGroupMemberHandler().getLocalGroupMemberInfo(t,e);t&&t.updateRole(De)}_onMessageRemindTypeSynced(e){var t=e.payload.groupProfile["groupID"],e=e.payload.messageRemindType;this._grpM.get(o).onGroupMsgRemindTypeUpdated({groupID:t,messageRemindType:e})}_handleTopicSystemNotice(e){var{groupProfile:{groupID:e,topicID:t},elements:{operationType:o,topicIDList:r,messageRemindType:i}}=e,n=this._grpM.get(s);17===o?n.onTopicCreated({groupID:e,topicID:t}):18===o?n.onTopicDeleted({groupID:e,topicIDList:r}):20===o&&n.onMessageRemindTypeUpdated({groupID:e,topicID:t,messageRemindType:i})}reset(){this.pendencyMap.clear()}}class or extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(r).isLoggedIn()}isOversea(){return this._m.get(r).isOversea()}isPrivateNetWork(){var e=this._m.get(r);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(r).getFileDownloadProxy()}getDownloadFileAuthKey(){return this._m.get(r).getDownloadFileAuthKey()}getMyUserID(){return this._m.get(r).getUserID()}getMyTinyID(){return this._m.get(r).getTinyID()}getSDKAppID(){return this._m.get(r).getSDKAppID()}isIntl(){return this._m.get(r).isIntl()}isUsingChatCore(){return this._m.get(r).isUsingChatCore()}isDevMode(){return this._m.get(r).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return O}getCloudConfig(e){return this._m.get(u).getCloudConfig(e)}emitOEvt(e,t){this._m.getOEmitInst().emit(e,t)}emitIEvt(e,t){this._m.getIEmitInst().emit(e,t)}getIEmitInst(){return this._m.getIEmitInst()}req(e){return this._m.get(a).req(e)}canIUse(e){return this._m.get(l).canIUse(e)}getErrMsg(e,t,s){return this._m.getErrMsg(e,t,s)}warn(e,t,s){e=this.getErrMsg(e,t,s);e&>.w(e)}noUse(e){var t=qt;return zt({code:t,message:this.getErrMsg(t,e)})}}{constructor(e){super(e),this._n="GroupModule",this._commonGroupHandler=new Ao(this),this._groupAttributesHandler=new $o(this),this._groupCountersHandler=new qo(this),this._AVChatRoomHandler=new Vo(this),this._groupTipsHandler=new bo(this),this._groupSystemNoticeHandler=new sr(this),this._groupMemberHandler=new Ko(this),this._groupPinMessageHandler=new Bo(this),this.groupMap=new Map,this._unjoinedAVChatRoomList=new Map,this._receiptDetailCompleteMap=new Map,this._onlineMemberCountMap=new Map,this._timeoutIDs=[],this.getIEmitInst().on(Xt.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),s=this.getCloudConfig("polling_no_msg_count"),o=this.getCloudConfig("polling_simplified_msg"),r=this.getCloudConfig("paging_grp_count"),i=this.getCloudConfig("av_members_freq_limit");gt.l(this._n+`._onCloudConfig pollingInterval:${e} pollingIntervalPlus:${t} pollingNoMessageCount:${s} pollingSimplifiedMessage:${o} pagingGroupCount:${r} avChatRoomMembersFrequencyLimit:`+i),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(s),this._AVChatRoomHandler.setPollingSimplifiedMessage(o),this._commonGroupHandler.setPagingGroupCount(r),this._groupMemberHandler.setAVChatRoomMembersFrequencyLimit(i)}onCheckTimer(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}guardForAVChatRoom(s){if(s.conversationType!==pe)return Wt();{let t=nt(s.to)?at(s.to):s.to;return this.hasLocalGroup(t)?Wt():this.getGroupProfile({groupID:t}).then(e=>{e=e.data.group.type;if(gt.l(`${this._n}.guardForAVChatRoom. groupID:${t} type:`+e),e!==de)return Wt();{let e=_t;return zt(new dt({code:e,message:this.getErrMsg(e,s.from,t),data:{message:s}}))}})}}checkJoinedAVChatRoomByID(e){return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}onNewMessage(e){this._commonGroupHandler.onNewMessage(e)}updateNextMessageSeq(e){if(Be(e)){let o=this.get(s);e.forEach(e=>{var t=e.conversationID.replace(pe,"");nt(t)&&o.updateUnreadCountAndLastMsg(t,e.lastMessage),this.groupMap.has(t)&&(this.groupMap.get(t).nextMessageSeq=e.lastMessage.sequence+1)})}}onNewGroupTips(e){this._groupTipsHandler.onNewGroupTips(e)}onMsgRevoked(e,t=!0){this._commonGroupHandler.onMsgRevoked(e,t)}onNewGroupSystemNotice(e){this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}onMsgReadNotice(e){e.dataList.forEach(e=>{var t=e.elements["groupMessageReadNotice"];if(!je(t)){let i=this.get(o);t.forEach(e=>{var{groupID:e,topicID:t,lastMessageSeq:s}=e;gt.l(this._n+`.onMsgReadNotice groupID:${e} lastMessageSeq:`+s);let o=""+pe+e,r=!0;ke(t)||(o=""+pe+t,r=!1),i.updateIsReadAfterReadReport({conversationID:o,lastMessageSeq:s}),i.updateUnreadCount(o,r),i.clearGroupAtInfoList(o,r)})}})}onReadReceiptList(e){gt.l(this._n+".onReadReceiptList options:",e),e.dataList.forEach(e=>{var{groupProfile:e,elements:t}=e,e=e["groupID"],t=t["readReceiptList"];this.get(o).updateReadReceiptInfo({groupID:e,readReceiptList:t})})}onMsgModified(e){gt.l(this._n+".onMsgModified options:",e);let t=this.get(o);e.dataList.forEach(e=>{t.onMessageModified({...e,conversationType:pe,to:e.topicID||e.groupID})})}deleteGroupSystemNotice(e){this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}initGroupMap(e){this.groupMap.set(e.groupID,new Fo(e))}clearGroupMap(){this.groupMap.clear()}deleteGroup(e){this.groupMap.delete(e)}updateGroupMap(e){let t=this.get(o),s;e.forEach(e=>{s=e.groupID,this.groupMap.has(s)?this.groupMap.get(s).updateGroup(e):(this.groupMap.set(s,new Fo(e)),t.deleteGroupRoamingInfo(s))});var r=this.getMyUserID();for(let[,e]of this.groupMap)e.selfInfo.userID=r,"Owner"===e.selfInfo.role&&(e.ownerID=r)}getGroupMap(){return this.groupMap}getLocalGroupList(){return[...this.groupMap.values()].filter(e=>e.type!==fe&&e.type!==Me)}getLocalGroupProfile(e){return this.groupMap.get(e)}sortLocalGroupList(){var e=[...this.groupMap].filter(([,e])=>!ke(e.lastMessage));e.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime),this.groupMap=new Map([...e])}updateGroupLastMessage(e){this._commonGroupHandler.updateLastMsg(e)}emitGroupListUpdate(e=!0,t=!0){var s=this.getLocalGroupList();if(e&&this.emitOEvt(xt),t){let e=JSON.parse(JSON.stringify(s));this.get(o).updateConvGroupProfile(e)}}getMyNameCardByGroupID(e){e=this.getLocalGroupProfile(e);return e?e.selfInfo.nameCard:""}isPagingGetCompleted(){return this._commonGroupHandler.isPagingGetCompleted()}getMsgRemindType(e){return!Be(e)||0===e.length||0===(e=e.filter(e=>{var{type:e=""}=this.getLocalGroupProfile(e)||{};return!rt(e)})).length?Promise.resolve():(gt.l(this._n+".getMsgRemindType groupIDList:"+e),this.getGroupProfileAdvance({groupIDList:e,responseFilter:{memberInfoFilter:["MsgFlag"]}}).then(e=>{let t=e.data["successGroupList"],s=this.get(o);t.forEach(e=>{s.onGroupMsgRemindTypeUpdated({groupID:e.groupID,messageRemindType:Be(e.members)?e.members[0].messageRemindType:""})})}))}getGroupList(){return this._commonGroupHandler.getGroupList()}syncCommunityWithTopic(){return this._commonGroupHandler.syncGroupList(!0)}getGroupProfile(t){let r=this._n+".getGroupProfile",i=new os("getGroupProfile"),{groupID:n,groupCustomFieldFilter:e}=t;gt.l(r+" groupID:"+n);var s={groupIDList:[n],responseFilter:{groupBaseInfoFilter:[...L],groupCustomFieldFilter:e,memberInfoFilter:[...C,"NameCard"]}};return this.getGroupProfileAdvance(s).then(({data:{successGroupList:e,failureGroupList:t}})=>{if(gt.l(r+" ok"),0(i.setError(e).setMessage("groupID:"+t.groupID).end(),gt.e(r+" failed. error:",e),zt(e)))}getGroupProfileAdvance(t){let s=this._n+".getGroupProfileAdvance",e=t["groupIDList"],o=(Be(e)&&50{(it({groupID:e})?r:o).push(e)});var i=[];if(0{let t=[],s=[];return e.forEach(e=>{t.push(...e.successGroupList),s.push(...e.failureGroupList)}),mt({successGroupList:t,failureGroupList:s})}).catch(e=>(gt.e(s+" failed. error:",e),zt(e)))}_getGroupProfileAdvance(t){let{relayFlag:s=!1,...o}=t;return this.req({P:ns,data:o}).then(e=>{gt.l(this._n+"._getGroupProfileAdvance ok. options:",o);e=e.data.groups;return{successGroupList:e.filter(e=>je(e.errorCode)||0===e.errorCode),failureGroupList:e.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>new dt({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}))}}).catch(e=>s&&it({groupID:t.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:zt(e))}createGroup(u){let s=[ge,he,me,de,_e],o=this._n+".createGroup",{type:r,groupID:i}=u;if(u.name&&!1===this._filterProfanity("name",u))return zt({code:Nt});if(u.introduction&&!1===this._filterProfanity("introduction",u))return zt({code:Nt});if(u.notification&&!1===this._filterProfanity("notification",u))return zt({code:Nt});if(!s.includes(r))return zt({code:Mt});if(!it({type:r})){if(!ke(i)&&it({groupID:i}))return zt({code:It});u.isSupportTopic=void 0}if(rt(r)&&!je(u.memberList)&&0{let{groupID:i,overLimitUserIDList:n=[]}=r.data;l=i,g=n;r=`groupType:${u.type} groupID:${i} overLimitUserIDList:`+n;if(p.setMessage(r).end(),gt.l(o+" ok. "+r),u.type!==de&&(u.type!==_e||1!==u.isSupportTopic)){ke(u.memberList)||ke(n)||(u.memberList=u.memberList.filter(e=>-1===n.indexOf(e.userID))),this.updateGroupMap([{...u,groupID:i}]);r=this.get(e);let s="",o=0;u.type===_e?(s=this.isIntl()?"Create Community":"创建社群",o=1):s=this.isIntl()?"Create Group":"创建群组";var a=this.get(t).getMyNick(),a=r.createCustomMessage({to:i,conversationType:pe,payload:{data:JSON.stringify({businessID:"group_create",content:s,cmd:o,opUser:a||this.getMyUserID(),version:4})}});r.sendMessageInstance(a),this.emitGroupListUpdate()}return this.getGroupProfile({groupID:i})}).then(e=>{var e=e.data["group"],{nameCard:t,joinTime:s}=e.selfInfo;return e.updateSelfInfo({nameCard:t,joinTime:s,messageRemindType:ve,role:Ie}),mt({group:e,overLimitUserIDList:g})}).catch(e=>{var t;return p.setMessage("groupType:"+u.type).setError(e).end(),10010===e.code||10007===e.code?(this._silentlyGetGroupProfile(e.code,l),this.updateGroupMap([{...u,groupID:l}]),(t=this.getLocalGroupProfile(l)).selfInfo.role=Ie,mt({group:t,overLimitUserIDList:g})):(gt.e(o+" failed. error:",e),zt(e))})}dismissGroup(e){let t=this._n+".dismissGroup",s="groupID:"+e,o=new os("dismissGroup");return o.setMessage(s),gt.l(t+" "+s),this.req({P:us,data:{groupID:e}}).then(()=>(o.end(),gt.l(t+" ok"),this.deleteLocalGroupAndConversation(e),this.checkJoinedAVChatRoomByID(e)&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),mt({groupID:e}))).catch(e=>(o.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}updateGroupProfile(t){let s=this._n+".updateGroupProfile";if(this.hasLocalGroup(t.groupID)){let e=this.getLocalGroupProfile(t.groupID).type;this._canIUseJoinOption(e)||je(t.joinOption)||(gt.w(s+" joinOption is unavailable for Work/Meeting/AVChatRoom"),t.joinOption=void 0)}if(je(t.muteAllMembers)||(t.muteAllMembers?t.muteAllMembers="On":t.muteAllMembers="Off"),t.name&&!1===this._filterProfanity("name",t))return zt({code:Nt});if(t.introduction&&!1===this._filterProfanity("introduction",t))return zt({code:Nt});if(t.notification&&!1===this._filterProfanity("notification",t))return zt({code:Nt});let o=new os("updateGroupProfile");return o.setMessage(JSON.stringify(t)),gt.l(s+" groupID:"+t.groupID),this.req({P:ps,data:t}).then(()=>(o.end(),gt.l(s+" ok"),this.hasLocalGroup(t.groupID)&&this.groupMap.get(t.groupID).updateGroup(t),mt({group:this.groupMap.get(t.groupID)}))).catch(e=>(o.setError(e).end(),gt.l(s+" failed. error:",e),zt(e)))}_filterProfanity(e,t){var s,o=this.get(c);return!o||({isAllowedToSend:o,modifiedText:s}=o.filterText(t[e],y),!0===o&&(t[e]=s,!0))}joinGroup(s){let o=s["groupID"],r=this._n+".joinGroup";if(this.deleteUnjoinedAVChatRoom(o),this.hasLocalGroup(o)){if(!this.isLoggedIn())return Wt({status:Te});let t=new os("applyJoinGroup");return this.getGroupProfile({groupID:o}).then(()=>(t.setMessage(`groupID:${o} joinedStatus:`+Te).end(),Wt({status:Te}))).catch(e=>(t.setMessage(`groupID:${o} unjoined`).end(),gt.w(r+` ${o} was unjoined, now join!`),this.groupMap.delete(o),this.applyJoinGroup(s)))}return gt.l(r+" groupID:"+o),this.isLoggedIn()?this.applyJoinGroup(s):this._AVChatRoomHandler.joinWithoutAuth(s)}applyJoinGroup(e){let a=this._n+".applyJoinGroup",{groupID:u,applyMessage:t}=e;if(!ke(t)&&!1===this._filterProfanity("applyMessage",e))return zt({code:Nt});let p=new os("applyJoinGroup"),s={...e},l=this.canIUse(I.AV_HISTORY_MSG);return l&&(s.historyMessageFlag=1),this.get(o).deleteTopicRoamingInfo(u),this.req({P:ls,data:s}).then(({data:{joinedStatus:e,longPollingKey:s,startSeq:o,avChatRoomFlag:r,avChatRoomKey:i,messageList:n}})=>{var t=`groupID:${u} joinedStatus:${e} longPollingKey:${s} startSeq:${o} avChatRoomFlag:${r} canGetAVChatRoomHistoryMsg:${l}, historyMsgCount:`+(ke(n)?0:n.length);switch(p.setMessage(t).end(),gt.l(a+" ok. "+t),e){case Ee:return mt({status:Ee});case we:return this.getGroupProfile({groupID:u}).then(({data:{group:e}})=>this._handleJoinResult({group:e,avChatRoomFlag:r,longPollingKey:s,startSeq:o,avChatRoomKey:i,messageList:n})).catch(t=>{if(10010!==t.code&&10007!==t.code)return gt.e(a+" failed. error:",t),zt(t);{this._silentlyGetGroupProfile(t.code,u);let e=new Fo({groupID:u});return this.updateGroupMap([e]),this._handleJoinResult({group:e,avChatRoomFlag:r,longPollingKey:s,startSeq:o,avChatRoomKey:i,messageList:n})}});default:{let e=new dt({code:Gt});return gt.e(a+" failed. error:",e),zt(e)}}}).catch(e=>(p.setMessage("groupID:"+u).setError(e).end(),gt.e(a+" failed. error:",e),zt(e)))}_handleJoinResult(e){let{group:t,avChatRoomFlag:s,longPollingKey:r,startSeq:i,avChatRoomKey:n,messageList:a}=e,u=t["groupID"];return 1===s?(this.get(o).setCompleted(""+pe+u),this._groupAttributesHandler.initGroupAttributesCache({groupID:u,avChatRoomKey:n}),this._groupCountersHandler.initGroupCountersCache({groupID:u,avChatRoomKey:n}),(e=je(r)?this._AVChatRoomHandler.handleJoinResult({group:t}):this._AVChatRoomHandler.startRunLoop({group:t,longPollingKey:r,startSeq:i})).then(()=>{this._onAVChatRoomHistoryMessage(a,u)}),e):(this.emitGroupListUpdate(!0,!1),mt({status:we,group:t}))}quitGroup(e,t="outer"){let s=this._n+".quitGroup",o=`groupID:${e} from:`+t,r=(gt.l(s+" "+o),this.checkJoinedAVChatRoomByID(e));if(!r&&!this.hasLocalGroup(e))return zt({code:Ct});if(r&&!this.isLoggedIn())return gt.l(s+" anonymously ok. "+o),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Wt({groupID:e});let i=new os("quitGroup");return i.setMessage(o),this.req({P:hs,data:{groupID:e}}).then(()=>(i.end(),gt.l(s+" ok"),this.deleteLocalGroupAndConversation(e),r&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),mt({groupID:e}))).catch(e=>(i.setError(e).end(),gt.e(s+" failed. error:",e),zt(e)))}searchGroupByID(e){let t=this._n+".searchGroupByID",s={groupIDList:[e]},o=new os("searchGroupByID");return o.setMessage("groupID:"+e),gt.l(t+" groupID:"+e),this.req({P:gs,data:s}).then(({data:{groupProfile:e}})=>{if(0!==e[0].errorCode)throw new dt({code:e[0].errorCode,message:e[0].errorInfo});return o.end(),gt.l(t+" ok"),mt({group:new Fo(e[0])})}).catch(e=>(o.setError(e).end(),gt.w(t+" failed. error:",e),zt(e)))}changeGroupOwner(e){let t=this._n+".changeGroupOwner";if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===de)return zt({code:Dt});if(e.newOwnerID===this.getMyUserID())return zt({code:Lt});let i=new os("changeGroupOwner");return i.setMessage(`groupID:${e.groupID} newOwnerID:`+e.newOwnerID),gt.l(t+" groupID:"+e.groupID),this.req({P:ms,data:e}).then(()=>{i.end(),gt.l(t+" ok");var{groupID:s,newOwnerID:o}=e,r=(this.groupMap.get(s).ownerID=o,this._groupMemberHandler.getLocalGroupMemberList(s));if(r instanceof Map){let e=r.get(this.getMyUserID()),t=(je(e)||(e.updateRole("Member"),this.groupMap.get(s).selfInfo.role="Member"),r.get(o));je(t)||t.updateRole("Owner")}return this.emitGroupListUpdate(!0,!1),mt({group:this.groupMap.get(s)})}).catch(e=>(i.setError(e).end(),gt.e(t+" failed. error:",e),zt(e)))}getGroupApplicationList(){return this._groupSystemNoticeHandler.getGroupApplicationList()}handleGroupApplication(e){let t=this._n+".handleGroupApplication",{handleAction:s,handleMessage:o,message:r,application:i}=e,n,a,u,p,l,g=(r?(n=r.payload.operatorID,a=r.payload.groupProfile.groupID,u=r.payload.authentication,p=r.payload.messageKey):i&&(n=i.applicant,a=i.groupID,u=i.authentication,p=i.messageKey),ds),h=(i&&2===i.applicationType&&(g=_s,l=i.userID),new os("handleGroupApplication"));return h.setMessage("groupID:"+a),gt.l(t+" groupID:"+a),this.req({P:g,data:{handleAction:s,handleMessage:o,applicant:n,invitee:l,groupID:a,authentication:u,messageKey:p}}).then(()=>(h.end(),gt.l(t+" ok"),r&&this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),mt({group:this.getLocalGroupProfile(a)}))).catch(e=>(h.setError(e).end(),gt.e(t+" failed. error",e),zt(e)))}handleGroupInvitation(e){let t=this._n+".handleGroupInvitation",{groupProfile:{groupID:s},authentication:o,messageKey:r,operatorID:i}=e.message.payload,n=e["handleAction"],a=new os("handleGroupInvitation");return a.setMessage(`groupID:${s} inviter:${i} handleAction:`+n),gt.l(t+` groupID:${s} inviter:${i} handleAction:`+n),this.req({P:fs,data:{...e,inviter:i,groupID:s,authentication:o,messageKey:r}}).then(()=>(a.end(),gt.l(t+" ok"),this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),mt({group:this.getLocalGroupProfile(s)}))).catch(e=>(a.setError(e).end(),gt.e(t+" failed. error",e),zt(e)))}getGroupOnlineMemberCount(t){let s=this._n+".getGroupOnlineMemberCount",e=this._AVChatRoomHandler.checkJoinedAVChatRoomByID(t),o=this.hasLocalGroup(t);if(gt.l(s+` groupID:${t} isAVChatRoom:${e} has:`+o),e)return this._AVChatRoomHandler.getGroupOnlineMemberCount(t);if(!o)return Wt({memberCount:0});var r=Date.now();if(this._onlineMemberCountMap.has(t)){let e=this._onlineMemberCountMap.get(t);if(r-e.lastReqTime<=6e4)return Wt({memberCount:e.memberCount});e.lastReqTime=r}return this.requestOnlineCount(t).then(e=>{var{memberCount:e=0}=e.data;return this._onlineMemberCountMap.set(t,{lastReqTime:Date.now(),memberCount:e}),gt.l(s+` ok. groupID:${t} memberCount:`+e),Wt({memberCount:e})}).catch(e=>(gt.w(s+" failed. error:",e),Promise.reject(e)))}requestOnlineCount(e){return this.req({P:Ss,data:{groupID:e}})}hasLocalGroup(e){return this.groupMap.has(e)}deleteLocalGroupAndConversation(t){let e=this.checkJoinedAVChatRoomByID(t);gt.l(this._n+`.deleteLocalGroupAndConversation groupID:${t} isJoinedAVChatRoom:`+e);var r=this.get(o),i=""+pe+t;if(e&&(this._AVChatRoomHandler.reset(t),this._deleteLocalGroup(t),r.deleteLocalConv(i),this._groupMemberHandler.deleteAVChatRoomMembersReqInfo(t)),it({groupID:t})){let e=this.getLocalGroupProfile(t);e&&!0===e.isSupportTopic&&this.get(s).deleteTopicListInCommunity(t)}r.clearUnreadCount(i),r.setCompleted(i),this._deleteLocalGroup(t),this._onlineMemberCountMap.delete(t),this.emitGroupListUpdate(!0,!1)}_deleteLocalGroup(e){this.groupMap.delete(e),this._groupMemberHandler.deleteGroupMemberList(e)}sendMessage(e,t){return Be(e._receiverList)&&0(h=e,gt.l(u+` groupID:${l} startSequence:`+h),this.req({P:ys,data:{groupID:l,count:21,sequence:h,topicID:c}}))).then(e=>{var{messageList:t,complete:s,invisibleSequenceList:r=[]}=e.data;let{nextSequence:i=0}=e.data;je(t)?gt.l(u+` ok. complete:${s} nextSequence:${i} but messageList is undefined!`):gt.l(u+` ok. complete:${s} nextSequence:${i} count:`+t.length),g.setMessage(`groupID:${l} topicID:${c} startSequence:${h} complete:${s} nextSequence:`+i).end();e=this.get(o);let n=[];var a=[],t=(ke(t)||(n=e.onRoamingMessage(t,p,!0,a),e.updateIsRead(p),e.patchConvLastMessage(p)),2===s||i<1);return t&&(e.setCompleted(p),i=""),gt.l(u+` isPullingCompleted:${t} nextReqID:${i} storedMsgCount:${n.length} invisibleSeqCount:`+r.length),{nextReqID:i+"",storedMessageList:n,assembledMessageList:a,isPullingCompleted:t}}).catch(e=>(g.setError(e).setMessage(`groupID:${l} topicID:${c} startSequence:`+h).end(),gt.w(u+" failed. error:",e),zt(e)))}_getGroupIDOfMessage(e){return e.conversationID.replace(pe,"")}getReadReceiptList(s){let t=this._n+".getReadReceiptList",e=this._getGroupIDOfMessage(s[0]),o=this.getMyUserID(),r=s.filter(e=>e.from===o&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));if(gt.l(t+` groupID:${e} sequenceList:`+JSON.stringify(r)),0===r.length)return Wt({messageList:s});let i=new os("getReadReceiptList");return i.setMessage("groupID:"+e),this.req({P:Ds,data:{groupID:e,sequenceList:r}}).then(e=>{i.end(),gt.l(t+" ok");e=e.data.readReceiptList;return Be(e)&&e.forEach(t=>{s.forEach(e=>{0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)})}),mt({messageList:s})}).catch(e=>(i.setError(e).end(),gt.w(t+" failed. error:",e),zt(e)))}sendReadReceipt(e){let t=this._n+".sendReadReceipt",s=this._getGroupIDOfMessage(e[0]),o=new os("sendReadReceipt"),r=(o.setMessage("groupID:"+s),this.getMyUserID()),i=e.filter(e=>e.from!==r&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));return 0===i.length?zt({code:ft}):(gt.l(t+". sequenceList:"+JSON.stringify(i)),this.req({P:Ls,data:{groupID:s,sequenceList:i}}).then(e=>(o.end(),gt.l(t+" ok"),mt())).catch(e=>(o.setError(e).end(),gt.w(t+" failed. error:",e),zt(e))))}getReadReceiptDetail(e){let{message:t,filter:s,cursor:o,count:r}=e,i=this._getGroupIDOfMessage(t),n=t.ID,a=t.sequence,u=this._n+".getReadReceiptDetail",p=this._receiptDetailCompleteMap.get(n)||!1,l=0!==s&&1!==s?0:s,g=He(o)?o:"",h=!Ve(r)||r<=0||100<=r?100:r,c=`groupID:${i} sequence:${a} cursor:${g} filter:${l} completeFlag:`+p,m=(gt.l(u+" "+c),{cursor:"",isCompleted:!1,messageID:n,unreadUserIDList:[],readUserIDList:[]}),d=new os("getReadReceiptDetail");return d.setMessage(c),this.req({P:Cs,data:{groupID:i,sequence:a,flag:l,cursor:g,count:h}}).then(e=>{d.end();var{cursor:e,isCompleted:t,unreadUserIDList:s,readUserIDList:o}=e.data;return m.cursor=e,1===t&&(m.isCompleted=!0,this._receiptDetailCompleteMap.set(n,!0)),0===l?m.readUserIDList=o.map(e=>e.userID):1===l&&(m.unreadUserIDList=s.map(e=>e.userID)),gt.l(u+" ok"),mt(m)}).catch(e=>(d.setError(e).end(),gt.w(u+" failed. error:",e),zt(e)))}getGroupReceiptsByUsers(e){let t=this._n+".getGroupReceiptsByUsers",{groupID:s,dataList:o=[]}=e,r=`groupID:${s} dataList length:`+o.length;return gt.l(t+" "+r),0===o.length&>.w(t+" dataList is empty."),this.req({P:Gs,data:{groupID:s,dataList:o}}).then(e=>{var{dataList:e=[]}=e.data;return gt.l(t+" ok."),mt({dataList:e})}).catch(e=>(gt.w(t+" failed. error:",e),zt(e)))}getRoamingMessagesHopping(p){let l=this._n+".getRoamingMessagesHopping",{groupID:t,count:s,sequence:g,direction:h}=p,r=void 0;return je(g)&&1===h?Wt({messageList:[],isCompleted:!0,nextMessageSeq:""}):(nt(t)&&(t=at(r=t)),this._computeReqSeqHopping({groupID:t,topicID:r,sequence:g}).then(e=>{je(g)||1!==h||(e=g+s-1);let a=`${r?"topicID:"+r:"groupID:"+t} sequence:${g} reqSeq:${e} direction:`+h,u=(gt.l(l+" "+a),new os("getRoamingMessagesHopping"));return this.req({P:ys,data:{groupID:t,topicID:r,count:s,sequence:e}}).then(e=>{var{messageList:e=[],complete:t,nextSequence:s=0,invisibleSequenceList:r=[]}=e.data,i=`complete:${t} nextSequence:${s} remoteMsgCount:${e.length} invisibleSequenceList:`+r,i=(u.setMessage(a+" "+i).end(),gt.l(l+" ok. "+i),""+pe+p.groupID),n=this.get(o),i=n.onRoamingMessage(e,i,!1),e=this._computeResult({groupID:p.groupID,direction:h,sequence:g,remoteMessageList:e,processedMessageList:i,complete:t,nextSequence:s,invisibleSequenceList:r});return n.storeHoppingMessageList(e.messageList),mt(e)}).catch(e=>(u.setError(e).setMessage(`groupID:${t} sequence:${g} count:`+s).end(),gt.w(l+" failed. error:",e),zt(e)))}))}_computeReqSeqHopping(e){let{groupID:s,topicID:t,sequence:o}=e;return 0{let t=0;return ke(e)||(t=e[0].nextMessageSeq-1),gt.l(`${this._n}._computeReqSeqHopping groupID:${s} lastSequence:${t} from remote`),t}).catch(e=>zt(e)):Promise.resolve(0)}_computeResult(e){let s={messageList:[],isCompleted:!1,nextMessageSeq:""},{groupID:t,direction:o,sequence:r,remoteMessageList:i=[],processedMessageList:n=[],complete:a,nextSequence:u,invisibleSequenceList:p}=e;if(0===o)return s.nextMessageSeq=u,(2===a||u<1)&&(s.isCompleted=!0,s.nextMessageSeq=""),s.messageList=n,s;if(1===o){if(ke(i)){if(ke(p))return s.isCompleted=!0,s.nextMessageSeq="",s;s.nextMessageSeq=p[0]+1}else{let e=i[0].sequence,t=p[0]||0;s.nextMessageSeq=e>t?e+1:t+1}return n.forEach(e=>{e.sequence>=r&&s.messageList.push(e)}),(it({groupID:t})||nt(t))&&0===s.messageList.length&&i[0].sequence{a.end(),gt.l(n+" ok");var e=this.get(o);e.updateIsReadAfterReadReport({conversationID:r,lastMessageSeq:i});let t=!0;if(!je(p)){t=!1;let e=this.get(s).getLocalTopic(u,p);e&&e.updateSelfInfo({readedSequence:i})}return e.updateUnreadCount(r,t),mt()}).catch(e=>(a.setError(e).end(),gt.l(n+" failed. error:",e),zt(e)))}_computeLastSequence(e){var{groupID:e,topicID:t,sequence:s}=e;return 0(ke(e)?gt.w(r+` ${u}, empty successGroupList`):(n=e[0].nextMessageSeq-1,a=u+`, ${n} from remote`,gt.l(r+" "+a)),i.setMessage(a).end(),n)).catch(e=>(i.setError(e).setMessage(u).end(),gt.w(r+" failed. error:",e),zt(e)))}isMessageFromOrToAVChatroom(e){return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}hasJoinedAVChatRoom(){return this._AVChatRoomHandler.hasJoinedAVChatRoom()}getJoinedAVChatRoom(){return this._AVChatRoomHandler.getJoinedAVChatRoom()}getGroupRemoteLastSeq(e){e=this.getLocalGroupProfile(e);return e?e.nextMessageSeq-1:1}isOnlineMessage(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}_canIUseOnlineOnlyFlag(e){var t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==pe}_onAVChatRoomHistoryMessage(e,s){if(!ke(e)){gt.l(this._n+`._onAVChatRoomHistoryMessage groupID:${s} count:`+e.length);let t=[];e.forEach(e=>{t.push({...e,isHistoryMessage:1})}),this.onAVChatRoomMessage(t,s)}}onAVChatRoomMessage(e,t=""){this._AVChatRoomHandler.onMessage(e,t)}onAVChatRoomMemberBanned(e){this._AVChatRoomHandler.onAVChatRoomMemberBanned(e)}setUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.set(e,1)}deleteUnjoinedAVChatRoom(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}isUnjoinedAVChatRoom(e){return this._unjoinedAVChatRoomList.has(e)}isGroupAttributesUpdatedNotice(e){return this._groupAttributesHandler.isGroupAttributesUpdatedNotice(e)}updateLocalMainSequenceOnReconnected(){this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}initGroupAttributes(e){return this._groupAttributesHandler.initGroupAttributes(e)}setGroupAttributes(e){return this._groupAttributesHandler.setGroupAttributes(e)}deleteGroupAttributes(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}getGroupAttributes(e){return this._groupAttributesHandler.getGroupAttributes(e)}isMessageFromTopic(e,t){return 2===e&&!ke(t)}isMessageFromCommunityOfTopic(e,t){return 2===e&&ke(t)}getMessageExtensions(e,t){return gt.l(this._n+".getMessageExtensions startSequence:"+t),this.req({P:ks,data:{groupID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMsgExts(e,t,s=1){return gt.l(this._n+".modifyMsgExts operateType:"+s),this.req({P:Ns,data:{groupID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}_genNotifyReqList(s){var o,r,i,n,a=[];for(let e=0,t=s.length;e{var t;return!!this.hasLocalGroup(e)&&({type:e,isSupportTopic:t}=this.getLocalGroupProfile(e),!rt(e))&&!t});0!==t.length&&(gt.l(s+" list:"+t),this.req({P:Os,data:{notifyReqList:this._genNotifyReqList(t)}}).then(e=>{let t=e.data["notifyRspList"],n=[];if(Be(t)){let r={dataList:[]},i=s+" ok.";t.forEach(e=>{var{nextRevokedTime:t,groupID:s,notifyList:o}=e;i+=` groupID:${s} nextRevokedTime:${t} count:${o.length} `,r.dataList.push({elements:{revokedInfos:this._genRevokedInfos(e)}}),0!==t?(this._setGroupLastRevokedTime(s,t),n.push(s)):this._setGroupLastRevokedTime(s,1e3*Pe())}),gt.l(i),this.onMsgRevoked(r,!1)}0{gt.e(s+" failed. error:",e)}))}_genRevokedInfos(e){let{notifyList:t,groupID:s}=e,o=[];return Be(t)&&t.forEach(e=>{o.push({groupID:s,sequence:e.sequence,random:e.random,revokerInfo:{...e.revokerInfo}})}),o}_getGroupLastRevokedTime(e){return this.hasLocalGroup(e)?this.getLocalGroupProfile(e)._lastRevokedTime:0}_setGroupLastRevokedTime(e,t){this.hasLocalGroup(e)&&(this.getLocalGroupProfile(e)._lastRevokedTime=t)}isGroupCountersNotice(e){return this._groupCountersHandler.isGroupCountersNotice(e)}setGroupCounters(e){return this._groupCountersHandler.setGroupCounters(e)}increaseGroupCounter(e){return this._groupCountersHandler.increaseGroupCounter(e)}decreaseGroupCounter(e){return this._groupCountersHandler.decreaseGroupCounter(e)}getGroupCounters(e){return this._groupCountersHandler.getGroupCounters(e)}getGroupMemberHandler(){return this._groupMemberHandler}getGroupMemberList(e){return this._groupMemberHandler.getGroupMemberList(e)}getGroupMemberProfile(e){return this._groupMemberHandler.getGroupMemberProfile(e)}addGroupMember(e){return this._groupMemberHandler.addGroupMember(e)}deleteGroupMember(e){return this._groupMemberHandler.deleteGroupMember(e)}setGroupMemberMuteTime(e){return this._groupMemberHandler.setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this._groupMemberHandler.setGroupMemberRole(e)}setGroupMemberNameCard(e){return this._groupMemberHandler.setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this._groupMemberHandler.setGroupMemberCustomField(e)}markGroupMemberList(e){return this._groupMemberHandler.markGroupMemberList(e)}modifyGroupMemberInfo(e){return this._groupMemberHandler.modifyGroupMemberInfo(e)}restartPolling(){this._AVChatRoomHandler.restartPolling()}getPollingTimerID(e){var t;return e&&(t=this.getLocalGroupProfile(e))&&rt(t.type)?this._AVChatRoomHandler.getPollingTimerID(e):-1}_canIUseJoinOption(e){return e===ge||it({type:e})}_silentlyGetGroupProfile(e,t){var s=setTimeout(this.getGroupProfile.bind(this,{groupID:t}),3e3);this._timeoutIDs.push(s),gt.l(this._n+`._silentlyGetGroupProfile errorCode:${e} groupID:${t} timeoutIDs:`+this._timeoutIDs)}_clearTimeoutIDs(){this._timeoutIDs.forEach(e=>{e&&clearTimeout(e)}),this._timeoutIDs=[]}startMessageLongPolling(e){var t,{groupID:e,longPollingKey:s,longPollingSequence:o=1}=e,i=this.get(r).isUnlimitedAVChatRoom();if(!ke(s))return this._AVChatRoomHandler.hasPollingInstance(e)&&this.stopMessageLongPolling({groupID:e}),t=this._AVChatRoomHandler.getJoinedLiveList(),!i&&0{var{messageList:e=[]}=e.data;gt.log(`${this._n}._getLiveHistoryMessages ok, groupID:${t} count:`+e.length),0{gt.log(`${this._n}._getLiveHistoryMessages failed, groupID:${t} info:`,e)})}onPinnedMessageNotify(e){this._groupPinMessageHandler.onPinnedMessageNotify(e)}pinGroupMessage(e){return this._groupPinMessageHandler.pinGroupMessage(e)}getPinnedGroupMessageList(e){return this._groupPinMessageHandler.getPinnedGroupMessageList(e)}reset(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._onlineMemberCountMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._groupAttributesHandler.reset(),this._groupCountersHandler.reset(),this._AVChatRoomHandler.reset(),this._groupMemberHandler.reset(),this._clearTimeoutIDs()}}export{or as default};