'use strict';const e={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",TOTAL_UNREAD_MESSAGE_COUNT_UPDATED:"onTotalUnreadMessageCountUpdated",CONVERSATION_GROUP_LIST_UPDATED:"onConversationGroupListUpdated",CONVERSATION_IN_GROUP_UPDATED:"onConversationInGroupUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",GROUP_COUNTER_UPDATED:"onGroupCounterUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",USER_STATUS_UPDATED:"onUserStatusUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},t={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3};class s{constructor(){this.cache=[],this.options=null}use(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}next(e){if(this.middlewares&&this.middlewares.length>0){return this.middlewares.shift().call(this,this.options,this.next.bind(this))}}run(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}class o{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(){const 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}}const i={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com"}}},n={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},r="1.7.3",a=537048168,u="CHINA",c="OVERSEA",l="SINGAPORE",d="KOREA",p="GERMANY",h="IND",g="JPN",_="USA",m={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=u){this.CURRENT=i.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GROUP:"group_open_http_svc",GROUP_AVCHATROOM:"group_open_avchatroom_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_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_MESSAGE:"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"},CMD:{LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_specified",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",MODIFY_C2C_MESSAGE:"modify_c2c_msg",MODIFY_C2C_MESSAGE_EXTENSIONS:"set_key_values",GET_C2C_MESSAGE_EXTENSIONS:"get_key_values",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",MODIFY_GROUP_MESSAGE:"modify_group_msg",MODIFY_GROUP_MESSAGE_EXTENSIONS:"group_set_key_values",GET_GROUP_MESSAGE_EXTENSIONS:"group_get_key_values",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",GET_AVCHATROOM_MEMBER_LIST:"get_members",MARK_AVCHATROOM_MEMBER_INFO:"modify_user_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",BAN_AVCHATROOM_MEMBER:"ban_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_INVITE_JOIN_GROUP:"handle_invite_join_permission_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_GROUP_NOTIFY:"get_group_notify",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"batch_delete",CLEAR_HISTORY_MESSAGE:"clear_msg",PIN_CONVERSATION:"top",SET_CONVERSATION_CUSTOM_DATA:"mark_contact",MARK_CONVERSATION:"mark_contact",CREATE_CONVERSATION_GROUP:"create_contact_group",DELETE_CONVERSATION_GROUP:"del_contact_group",UPDATE_CONVERSATION_GROUP:"update_contact_group",GET_CONVERSATION_GROUP_LIST:"get_contact_group",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg",CREATE_TOPIC:"create_topic",DELETE_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic",SET_SELF_STATUS:"ws_set_custom_status",GET_USER_STATUS:"ws_get_user_status",SUBSCRIBE_USER_STATUS:"ws_status_subscribe",UNSUBSCRIBE_USER_STATUS:"ws_status_unsubscribe",GET_RPOFANITY_LIST:"get_local_words",TRANSLATE_TEXT:"ws_batch_trans_text",UPDATE_GROUP_COUNTER:"update_group_counter",GET_GROUP_COUNTER:"get_group_counter"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}},M={SEARCH_MSG:new o(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new o(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new o(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new o(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new o(0,Math.pow(2,4)).toString(),AVCHATROOM_MBR_LIST:new o(0,Math.pow(2,6)).toString(),USER_STATUS:new o(0,Math.pow(2,7)).toString(),CONV_MARK:new o(0,Math.pow(2,9)).toString(),CONV_GROUP:new o(0,Math.pow(2,10)).toString(),AVCHATROOM_BAN_MBR:new o(0,Math.pow(2,11)).toString(),MSG_EXT:new o(0,Math.pow(2,13)).toString(),GRP_COUNTER:new o(0,Math.pow(2,15)).toString()},f="c2c_text_message",I="c2c_custom_message",C="group_text_message",T="group_custom_message",y="user_profile",D="group_profile",E="group_member_profile";m.HOST.setCurrent(u);const S="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),v=S&&"function"==typeof wx.createGamePortal,L="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),R="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),O="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,G="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,U="undefined"!=typeof uni,P=S||L||A||R||N||G||O,k=("undefined"!=typeof uni||"undefined"!=typeof window)&&!P,b=L?qq:A?tt:R?swan:N?my:S?wx:G?uni:O?jd:{},w=k&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(w),F=/AppleWebKit\/([\d.]+)/i.exec(w);F&&parseFloat(F.pop());const q=function(){let e="WEB";return $?e="WEB":L?e="QQ_MP":A?e="TT_MP":R?e="BAIDU_MP":N?e="ALI_MP":S?e="WX_MP":G&&(e="UNI_NATIVE_APP"),n[e]}(),x=/iPad/i.test(w),V=/iPhone/i.test(w)&&!x,B=/iPod/i.test(w),H=V||x||B,K=function(){const e=w.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),W=/Android/i.test(w),Y=function(){const e=w.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(e[1]+"."+e[2]):t||null}();!function(){const e=w.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}();const j=/MSIE/.test(w)||w.indexOf("Trident")>-1&&w.indexOf("rv:11.0")>-1,z=function(){const e=/MSIE\s(\d+)\.\d/.exec(w);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(w)&&/rv:11.0/.test(w)&&(t=11),t}();!function(){const e=w.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}();const J=/Windows/i.test(w),X=/MAC OS X/i.test(w),Z=k&&"undefined"!=typeof Worker&&!j,Q=W||H,ee=k&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy;let te,se;te="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const oe=function(){},ie=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let ne=ie.length;for(;ne--;)se=ie[ne],console[se]||(te[se]=oe);var re=te;let ae=0;const ue=function(){return(new Date).getTime()+ae},ce=function(){ae=0},le=function(){return Math.floor(ue()/1e3)};let de=0;function pe(){return mt()?"%c TIM %c":"TIM"}function he(){const e=function(){const e=new Date;return e.setTime(ue()),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())}const ge={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let s=0,o=e.length;s=0?t[o]=e[o]:t[o]=We(e[o])):t[o]=void 0:t[o]=null;return t};function Ye(e,t){if(!Ne(e)||!Ne(t))return!1;let s=!1;return t.forEach(({key:t,value:o})=>{const i=e.find(e=>e.key===t);i?i.value!==o&&(i.value=o,s=!0):(e.push({key:t,value:o}),s=!0)}),s}const je=e=>e===t.GRP_AVCHATROOM,ze=({type:e,groupID:s})=>e===t.GRP_COMMUNITY||(""+s).startsWith(ye)&&!(""+s).includes(De),Je=e=>(""+e).startsWith(ye)&&(""+e).includes(De),Xe=e=>Le(e)&&e.slice(0,3)===t.CONV_C2C,Ze=e=>Le(e)&&e.slice(0,5)===t.CONV_GROUP,Qe=e=>Le(e)&&e===t.CONV_SYSTEM;function et(e,t){const s={};return Object.keys(e).forEach(o=>{s[o]=t(e[o],o)}),s}function st(e){return P?new Promise((t,s)=>{b.getImageInfo({src:e,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})}):j&&9===z?Promise.resolve({width:0,height:0}):new Promise((t,s)=>{let o=new Image;o.onload=function(){t({width:this.width,height:this.height}),o=null},o.onerror=function(){t({width:0,height:0}),o=null},o.src=e})}function ot(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}function it(){let e="unknown";if(X&&(e="mac"),J&&(e="windows"),H&&(e="ios"),W&&(e="android"),P)try{const t=b.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(t){}return e}function nt(e,t){e=e.split("."),t=t.split(".");const s=Math.max(e.length,t.length);for(;e.lengthi)return 1;if(s-1?t+"&":t+"?";a.url=198===i?e+"imageView2/3/w/198/h/198":e+"imageView2/3/w/720/h/720"}if(Oe(t)){const{url:e,...t}=a;return t}return a}function at(e){const t=e[2];e[2]=e[1],e[1]=t;for(let s=0;s=0;o--)"1"===e[o]&&t.push(Math.pow(2,s-o-1));return t}function mt(){return!j&&!P}function Mt(e){return"the length of userIDList cannot exceed "+e}function ft(e,t){if(!e)return;let s=e;return t&&(e.startsWith("http://")?s=e.replace(/^http:\/\/[^/]+/,t):e.startsWith("https://")&&(s=e.replace(/^https:\/\/[^/]+/,t))),s}const It=Object.prototype.hasOwnProperty;function Ct(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(Re(e)){for(const t in e)if(It.call(e,t))return!1;return!0}return!(!Ee(e)&&(t=e,"set"!==ke(t))&&!Se(e))&&0===e.size;var t}function Tt(e,t,s){if(void 0===t)return!0;let o=!0;if(Re(t))Object.keys(t).forEach(i=>{const n=1===e.length?e[0][i]:void 0;o=!!yt(n,t[i],s,i)&&o});else if(Ne(t))for(let i=0;i"string"==typeof e&&0!==e.length||(vt({api:"on",param:"eventName",desc:At("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(vt({api:"on",param:"handler",desc:Gt()}),!1):(""===e.name&&vt({api:"on",param:"handler",desc:Ht()}),!0)}],once:[{name:"eventName",type:"String",validator:e=>"string"==typeof e&&0!==e.length||(vt({api:"once",param:"eventName",desc:At("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(vt({api:"once",param:"handler",desc:Gt()}),!1):(""===e.name&&vt({api:"once",param:"handler",desc:Ht()}),!0)}],off:[{name:"eventName",type:"String",validator:e=>"string"==typeof e&&0!==e.length||(vt({api:"off",param:"eventName",desc:At("eventName")}),!1)},{name:"handler",type:"Function",validator:e=>"function"!=typeof e?(vt({api:"off",param:"handler",desc:Gt()}),!1):(""===e.name&&vt({api:"off",param:"handler",desc:Ht()}),!0)}],sendMessage:[{name:"message",...jt}],setMessageExtensions:[{name:"message",...jt,validator:e=>e.status===Dt.SUCCESS&&!0===e.isSupportExtension||(vt({api:"setMessageExtensions",param:"message",desc:Kt()}),!1)},{name:"extensions",...Yt}],getMessageExtensions:[{name:"message",...jt,validator:e=>e.status===Dt.SUCCESS&&!0===e.isSupportExtension||(vt({api:"getMessageExtensions",param:"message",desc:Kt()}),!1)}],deleteMessageExtensions:[{name:"message",...jt,validator:e=>e.status===Dt.SUCCESS&&!0===e.isSupportExtension||(vt({api:"deleteMessageExtensions",param:"message",desc:Kt()}),!1)}],getMessageList:{conversationID:{...Wt,validator:e=>St(e)},nextReqMessageID:{type:"String"},count:{type:"Number",validator:e=>!(!Oe(e)&&!/^[1-9][0-9]*$/.test(e))||(vt({api:"getMessageList",param:"count",desc:bt()}),!1)}},getMessageListHopping:{conversationID:{...Wt,validator:e=>St(e)},sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:e=>!(!Oe(e)&&0!==e&&1!==e)||(vt({api:"getMessageListHopping",param:"direction",desc:Xt("0Or1RequiredLog")}),!1)},count:{type:"Number",validator:e=>!(!Oe(e)&&!/^[1-9][0-9]*$/.test(e))||(vt({api:"getMessageListHopping",param:"count",desc:bt}),!1)}},setMessageRead:{conversationID:{...Wt,validator:e=>St(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:e=>!e||-1!==[t.READ_ALL_C2C_MSG,t.READ_ALL_GROUP_MSG,t.READ_ALL_MSG].indexOf(e)||(vt({api:"setAllMessageRead",param:"scope",desc:"TIM.TYPES.READ_ALL_C2C_MSG or TIM.TYPES.READ_ALL_GROUP_MSG or TIM.TYPES.READ_ALL_MSG required"}),!1)}},getConversationProfile:[{name:"conversationID",...Wt,validator:e=>St(e)}],clearHistoryMessage:[{name:"conversationID",...Wt,validator:e=>St(e)}],pinConversation:{conversationID:{...Wt,validator:e=>St(e)},isPinned:{...zt}},setConversationCustomData:{conversationIDList:{...Yt},customData:{type:"String",validator:e=>Le(e)?!(e.length>256)||(vt({api:"setConversationCustomData",param:"customData",desc:wt("customData",256)}),!1):(vt({api:"setConversationCustomData",param:"customData",desc:Lt()}),!1)}},markConversation:{conversationIDList:{...Yt},markType:{type:"number",validator:e=>{return ve(e)?e<=0?(vt({api:"markConversation",param:"markType",desc:(t="markType",s=0,Xt("NumberGreaterThanLog",t,s))}),!1):!(e>=Math.pow(2,64))||(vt({api:"markConversation",param:"markType",desc:$t("markType","Math.pow(2,64)")}),!1):(vt({api:"markConversation",param:"markType",desc:Rt()}),!1);var t,s}},enableMark:{...zt}},createConversationGroup:{conversationIDList:{...Yt},groupName:{...Wt,validator:e=>!!e&&(!(e.length>32)||(vt({api:"createConversationGroup",param:"groupName",desc:wt("groupName",32)}),!1))}},deleteConversationGroup:[{name:"groupName",...Wt}],renameConversationGroup:{oldName:{...Wt},newName:{...Wt,validator:e=>!!e&&(!(e.length>32)||(vt({api:"renameConversationGroup",param:"newName",desc:wt("newName",32)}),!1))}},addConversationsToGroup:{conversationIDList:{...Yt},groupName:{...Wt}},deleteConversationsFromGroup:{conversationIDList:{...Yt},groupName:{...Wt}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:Wt,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:Yt},createGroup:{name:Wt},joinGroup:{groupID:Wt,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...Wt}],handleApplication:{message:jt,handleAction:Wt,handleMessage:{type:"String"}},changeGroupOwner:{groupID:Wt,newOwnerID:Wt},updateGroupProfile:{groupID:Wt,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...Wt}],searchGroupByID:[{name:"groupID",...Wt}],initGroupAttributes:{groupID:Wt,groupAttributes:{...jt,validator:e=>{let t=!0;return Object.keys(e).forEach(s=>{if(!Le(e[s]))return vt({api:"initGroupAttributes",param:"groupAttributes",desc:Ft("value")}),t=!1,t}),t}}},setGroupAttributes:{groupID:Wt,groupAttributes:{...jt,validator:e=>{let t=!0;return Object.keys(e).forEach(s=>{if(!Le(e[s]))return vt({api:"setGroupAttributes",param:"groupAttributes",desc:Ft("value")}),t=!1,t}),t}}},deleteGroupAttributes:{groupID:Wt,keyList:{type:"Array",validator:e=>{if(Oe(e)||!Ne(e))return vt({api:"deleteGroupAttributes",param:"keyList",desc:Ut()}),!1;if(!Ct(e)){let t=!0;return e.forEach(e=>{if(!Le(e))return vt({api:"deleteGroupAttributes",param:"keyList",desc:Xt("StringArrayRequiredLog")}),t=!1,t}),t}return!0}}},getGroupAttributes:{groupID:Wt,keyList:{type:"Array",validator:e=>{if(Oe(e)||!Ne(e))return vt({api:"getGroupAttributes",param:"keyList",desc:Ut()}),!1;if(!Ct(e)){let t=!0;return e.forEach(e=>{if(!Le(e))return vt({api:"getGroupAttributes",param:"keyList",desc:Ft("key")}),t=!1,t}),t}return!0}}},setGroupCounters:{groupID:Wt,counters:jt},increaseGroupCounter:{groupID:Wt,key:Wt,value:Jt},decreaseGroupCounter:{groupID:Wt,key:Wt,value:Jt},getGroupCounters:{groupID:Wt},getGroupMemberList:{groupID:Wt,count:{type:"Number"}},getGroupMemberProfile:{groupID:Wt,userIDList:Yt,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:Wt,userIDList:Yt},setGroupMemberRole:{groupID:Wt,userID:Wt,role:Wt},setGroupMemberMuteTime:{groupID:Wt,userID:Wt,muteTime:{type:"Number",validator:e=>e>=0}},setGroupMemberNameCard:{groupID:Wt,userID:{type:"String"},nameCard:{type:"String",validator:e=>Le(e)?(e.length,!0):(vt({api:"setGroupMemberNameCard",param:"nameCard",desc:Lt()}),!1)}},setGroupMemberCustomField:{groupID:Wt,userID:{type:"String"},memberCustomField:Yt},deleteGroupMember:{groupID:Wt},markGroupMemberList:{groupID:Wt,markType:{type:"number",validator:e=>{return ve(e)?!(e<1e3)||(vt({api:"markGroupMemberList",param:"markType",desc:(t="markType",s=1e3,Xt("NumberGreaterOrEqualLog",t,s))}),!1):(vt({api:"markGroupMemberList",param:"markType",desc:Rt()}),!1);var t,s}},userIDList:{...Yt},enableMark:{...zt}},createTextMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>Re(e)?Le(e.text)?0!==e.text.length||(vt({api:"createTextMessage",param:"payload.text",desc:xt()}),!1):(vt({api:"createTextMessage",param:"payload.text",desc:Lt()}),!1):(vt({api:"createTextMessage",param:"payload",desc:qt()}),!1)}},createTextAtMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>Re(e)?Le(e.text)?0===e.text.length?(vt({api:"createTextAtMessage",param:"payload.text",desc:xt()}),!1):!(e.atUserList&&!Ne(e.atUserList))||(vt({api:"createTextAtMessage",param:"payload.atUserList",desc:Ut()}),!1):(vt({api:"createTextAtMessage",param:"payload.text",desc:Lt()}),!1):(vt({api:"createTextAtMessage",param:"payload",desc:qt()}),!1)}},createCustomMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>Re(e)?e.data&&!Le(e.data)?(vt({api:"createCustomMessage",param:"payload.data",desc:Lt()}),!1):e.description&&!Le(e.description)?(vt({api:"createCustomMessage",param:"payload.description",desc:Lt()}),!1):!(e.extension&&!Le(e.extension))||(vt({api:"createCustomMessage",param:"payload.extension",desc:Lt()}),!1):(vt({api:"createCustomMessage",param:"payload",desc:qt()}),!1)}},createImageMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>{if(!Re(e))return vt({api:"createImageMessage",param:"payload",desc:qt()}),!1;if(Oe(e.file))return vt({api:"createImageMessage",param:"payload.file",desc:Nt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Se(e.file)))return Re(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(vt({api:"createImageMessage",param:"payload.file",desc:Vt()}),!1):(vt({api:"createImageMessage",param:"payload.file",desc:Ot()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return vt({api:"createImageMessage",param:"payload.file",desc:Vt()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:e=>(Oe(e)&&vt({api:"createImageMessage",param:"onProgress",desc:kt()}),!0)}}},createAudioMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>!!Re(e)||(vt({api:"createAudioMessage",param:"payload",desc:qt()}),!1)},onProgress:{type:"Function",required:!1,validator:e=>(Oe(e)&&vt({api:"createAudioMessage",param:"onProgress",desc:kt()}),!0)}},createVideoMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>{if(!Re(e))return vt({api:"createVideoMessage",param:"payload",desc:qt()}),!1;if(Oe(e.file))return vt({api:"createVideoMessage",param:"payload.file",desc:Nt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Se(e.file)))return Re(e.file)&&"undefined"!=typeof uni?!!Se(e.file.tempFile)||(vt({api:"createVideoMessage",param:"payload.file",desc:Vt()}),!1):(vt({api:"createVideoMessage",param:"payload.file",desc:Ot()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return vt({api:"createVideoMessage",param:"payload.file",desc:Vt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:e=>(Oe(e)&&vt({api:"createVideoMessage",param:"onProgress",desc:kt()}),!0)}},createFaceMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>Re(e)?ve(e.index)?!!Le(e.data)||(vt({api:"createFaceMessage",param:"payload.data",desc:Lt()}),!1):(vt({api:"createFaceMessage",param:"payload.index",desc:Rt()}),!1):(vt({api:"createFaceMessage",param:"payload",desc:qt()}),!1)}},createFileMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>{if(!Re(e))return vt({api:"createFileMessage",param:"payload",desc:qt()}),!1;if(Oe(e.file))return vt({api:"createFileMessage",param:"payload.file",desc:Nt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Se(e.file)))return Re(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(vt({api:"createFileMessage",param:"payload.file",desc:Vt()}),!1):(vt({api:"createFileMessage",param:"payload.file",desc:Ot()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return vt({api:"createFileMessage",param:"payload.file",desc:Vt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:e=>(Oe(e)&&vt({api:"createFileMessage",param:"onProgress",desc:kt()}),!0)}},createLocationMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>Re(e)?Le(e.description)?ve(e.longitude)?!!ve(e.latitude)||(vt({api:"createLocationMessage",param:"payload.latitude",desc:Rt()}),!1):(vt({api:"createLocationMessage",param:"payload.longitude",desc:Rt()}),!1):(vt({api:"createLocationMessage",param:"payload.description",desc:Lt()}),!1):(vt({api:"createLocationMessage",param:"payload",desc:qt()}),!1)}},createMergerMessage:{to:Wt,conversationType:Wt,payload:{...jt,validator:e=>{if(Ct(e.messageList))return vt({api:"createMergerMessage",param:"payload.messageList",desc:Pt()}),!1;if(Ct(e.compatibleText))return vt({api:"createMergerMessage",param:"payload.compatibleText",desc:At("compatibleText")}),!1;let t=!1;return e.messageList.forEach(e=>{e.status===Dt.FAIL&&(t=!0)}),!t||(vt({api:"createMergerMessage",param:"payload.messageList",desc:Xt("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...jt,validator:e=>Ct(e)?(vt({api:"revokeMessage",param:"message",desc:Bt()}),!1):e.conversationType===t.CONV_SYSTEM?(vt({api:"revokeMessage",param:"message",desc:Xt("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(vt({api:"revokeMessage",param:"message",desc:Xt("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",...Yt,validator:e=>!Ct(e)||(vt({api:"deleteMessage",param:"messageList",desc:Pt()}),!1)}],translateText:{sourceTextList:Yt,sourceLanguage:Wt,targetLanguage:Wt},modifyMessage:[{name:"message",...jt,validator:e=>Ct(e)?(vt({api:"modifyMessage",param:"message",desc:Bt()}),!1):e.conversationType===t.CONV_SYSTEM?(vt({api:"modifyMessage",param:"message",desc:Xt("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(vt({api:"modifyMessage",param:"message",desc:Xt("OnlineMessageNotSupportLog")}),!1)}],getUserProfile:{userIDList:{type:"Array",validator:e=>Ne(e)?(0===e.length&&vt({api:"getUserProfile",param:"userIDList",desc:Pt()}),!0):(vt({api:"getUserProfile",param:"userIDList",desc:Ut()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:e=>!!Oe(e)||(!!Ne(e)||(vt({api:"updateMyProfile",param:"profileCustomField",desc:Ut()}),!1))}},setSelfStatus:{customStatus:{type:"String",validator:e=>!!Le(e)||(vt({api:"setSelfStatus",param:"customStatus",desc:Lt()}),!1)}},getUserStatus:{userIDList:{type:"Array",validator:e=>Ne(e)?0!==e.length||(vt({api:"getUserStatus",param:"userIDList",desc:Pt()}),!1):(vt({api:"getUserStatus",param:"userIDList",desc:Ut()}),!1)}},subscribeUserStatus:{userIDList:{type:"Array",validator:e=>Ne(e)?0!==e.length||(vt({api:"subscribeUserStatus",param:"userIDList",desc:Pt()}),!1):(vt({api:"subscribeUserStatus",param:"userIDList",desc:Ut()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:e=>!e||(!!Ne(e)||(vt({api:"subscribeUserStatus",param:"userIDList",desc:Ut()}),!1))}},addFriend:{to:Wt,source:{type:"String",required:!0,validator:e=>{if(!e)return!1;if(!e.startsWith("AddSource_Type_"))return vt({api:"addFriend",param:"source",desc:Xt("SourcePrefixLog")}),!1;return!(e.replace("AddSource_Type_","").length>8)||(vt({api:"addFriend",param:"source",desc:wt("keyword",8)}),!1)}},remark:{type:"String",required:!1,validator:e=>!(Le(e)&&e.length>96)||(vt({api:"addFriend",param:"remark",desc:wt("remark",96)}),!1)}},deleteFriend:{userIDList:Yt},checkFriend:{userIDList:Yt},getFriendProfile:{userIDList:Yt},updateFriend:{userID:Wt,remark:{type:"String",required:!1,validator:e=>!(Le(e)&&e.length>96)||(vt({api:"updateFriend",param:"remark",desc:wt("remark",96)}),!1)},friendCustomField:{type:"Array",required:!1,validator:e=>{if(e){if(!Ne(e))return vt({api:"updateFriend",param:"friendCustomField",desc:Ut()}),!1;let t=!0;return e.forEach(e=>{if(!Le(e.key)||-1===e.key.indexOf("Tag_SNS_Custom"))return vt({api:"updateFriend",param:"friendCustomField",desc:Xt("FriendCustomFieldPrefixLog")}),t=!1,t;if(!Le(e.value))return vt({api:"updateFriend",param:"friendCustomField",desc:Ft("value")}),t=!1,t;return e.key.replace("Tag_SNS_Custom_","").length>8?(vt({api:"updateFriend",param:"friendCustomField",desc:wt("keyword",8)}),t=!1,t):void 0}),t}return!0}}},acceptFriendApplication:{userID:Wt},refuseFriendApplication:{userID:Wt},deleteFriendApplication:{userID:Wt},createFriendGroup:{name:Wt},deleteFriendGroup:{name:Wt},addToFriendGroup:{name:Wt,userIDList:Yt},removeFromFriendGroup:{name:Wt,userIDList:Yt},renameFriendGroup:{oldName:Wt,newName:Wt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:e=>Ne(e)?0!==e.length||(vt({api:"sendMessageReadReceipt",param:"messageList",desc:Pt()}),!1):(vt({api:"sendMessageReadReceipt",param:"messageList",desc:Ut()}),!1)}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:e=>Ne(e)?0!==e.length||(vt({api:"getMessageReadReceiptList",param:"messageList",desc:Pt()}),!1):(vt({api:"getMessageReadReceiptList",param:"messageList",desc:Ut()}),!1)}],createTopicInCommunity:{groupID:Wt,topicName:Wt},deleteTopicFromCommunity:{groupID:Wt,topicIDList:{type:"Array",validator:e=>!e||(!!Ne(e)||(vt({api:"deleteTopicFromCommunity",param:"topicIDList",desc:Ut()}),!1))}},updateTopicProfile:{groupID:Wt,topicID:Wt},getTopicList:{groupID:Wt,topicIDList:{type:"Array",validator:e=>!e||(!!Ne(e)||(vt({api:"getTopicList",param:"topicIDList",desc:Ut()}),!1))}}},Qt={login:1,logout:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,createTextMessage:1,createTextAtMessage:1,createImageMessage:1,createAudioMessage:1,createVideoMessage:1,createCustomMessage:1,createFaceMessage:1,createFileMessage:1,createLocationMessage:1,createMergerMessage:1,downloadMergerMessage:1,createForwardMessage:1,sendMessage:1,resendMessage:1,revokeMessage:1,deleteMessage:1,translateText:1,modifyMessage:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,pinConversation:1,getTotalUnreadMessageCount:1,setConversationCustomData:1,markConversation:1,createConversationGroup:1,getConversationGroupList:1,deleteConversationGroup:1,renameConversationGroup:1,addConversationsToGroup:1,deleteConversationsFromGroup:1,clearHistoryMessage:1,getGroupList:1,getGroupProfile:1,createGroup:1,joinGroup:1,updateGroupProfile:1,quitGroup:1,dismissGroup:1,changeGroupOwner:1,searchGroupByID:1,setMessageRemindType:1,getGroupApplicationList:1,handleGroupApplication:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getJoinedCommunityList:1,createTopicInCommunity:1,deleteTopicFromCommunity:1,updateTopicProfile:1,getTopicList:1,getGroupMemberProfile:1,getGroupMemberList:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberNameCard:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberCustomField:1,getGroupOnlineMemberCount:1,markGroupMemberList:1,getMyProfile:1,getUserProfile:1,updateMyProfile:1,setSelfStatus:1,getUserStatus:1,subscribeUserStatus:1,unsubscribeUserStatus:1,getBlacklist:1,addToBlacklist:1,removeFromBlacklist:1,getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,updateFriend:1,getFriendProfile:1,getFriendApplicationList:1,refuseFriendApplication:1,deleteFriendApplication:1,acceptFriendApplication:1,setFriendApplicationRead:1,getFriendGroupList:1,createFriendGroup:1,renameFriendGroup:1,deleteFriendGroup:1,addToFriendGroup:1,removeFromFriendGroup:1,callExperimentalAPI:1},es=1,ts=2,ss=3,os=4,is=6,ns=7,rs=8,as=9,us=10,cs=11,ls=12,ds=13,ps=14,hs=15,gs=16,_s=17,ms=18,Ms=19,fs=20,Is=21,Cs=22,Ts=23,ys=24,Ds=25,Es=26,Ss=27,vs=28,Ls=29,As=30,Rs=31,Ns=32,Os=37;class Gs{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.getModule(ls).isLoggedIn()}isOversea(){return this._m.getModule(ls).isOversea()}isPrivateNetWork(){return this._m.getModule(ls).isPrivateNetWork()}getFileDownloadProxy(){return this._m.getModule(ls).getFileDownloadProxy()}getMyUserID(){return this._m.getModule(ls).getUserID()}getMyTinyID(){return this._m.getModule(ls).getTinyID()}getSDKAppID(){return this._m.getModule(ls).getSDKAppID()}isIntl(){return this._m.getModule(ls).isIntl()}isDevMode(){return this._m.getModule(ls).isDevMode()}getModule(e){return this._m.getModule(e)}getPlatform(){return q}getNetworkType(){return this._m.getModule(hs).getNetworkType()}probeNetwork(e){return this._m.getModule(hs).probe(e)}getCloudConfig(e){return this._m.getModule(Ts).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.getModule(ls).getTinyID()+"-"+e.random}filterModifiedMessage(t){if(Ct(t))return;const s=t.filter(e=>!0===e.isModified);s.length>0&&this.emitOuterEvent(e.MESSAGE_MODIFIED,s)}filterUnmodifiedMessage(e){if(Ct(e))return[];return e.filter(e=>!1===e.isModified)}request(e){return this._m.getModule(fs).request(e)}canIUse(e){return this._m.getModule(Ss).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){const o=this.getErrorMessage(e,t,s);o&&ge.w(o)}}const Us="wslogin",Ps="wslogout",ks="wshello",bs="KickOther",ws="getmsg",$s="authkey",Fs="sendmsg",qs="send_group_msg",xs="portrait_get_all",Vs="portrait_set",Bs="black_list_get",Hs="black_list_add",Ks="black_list_delete",Ws="msgwithdraw",Ys="msgreaded",js="set_c2c_peer_mute_notifications",zs="get_c2c_peer_mute_notifications",Js="getroammsg",Xs="get_peer_read_time",Zs="delete_c2c_msg_ramble",Qs="modify_c2c_msg",eo="set_key_values",to="get_key_values",so="page_get",oo="get",io="batch_delete",no="clear_msg",ro="top",ao="deletemsg",uo="set_conv_custom_data",co="mark_contact",lo="create_contact_group",po="del_contact_group",ho="update_contact_group",go="add_conv_to_group",_o="del_conv_from_group",mo="get_contact_group",Mo="get_joined_group_list",fo="get_group_self_member_info",Io="create_group",Co="destroy_group",To="modify_group_base_info",yo="apply_join_group",Do="apply_join_group_noauth",Eo="quit_group",So="get_group_public_info",vo="change_group_owner",Lo="handle_apply_join_group",Ao="handle_invite_join_permission_group",Ro="handle_invite_join_group",No="group_msg_recall",Oo="msg_read_report",Go="read_all_unread_msg",Uo="group_msg_get",Po="get_group_msg_receipt",ko="group_msg_receipt",bo="c2c_msg_read_receipt",wo="get_group_msg_receipt_detail",$o="get_pendency",Fo="deletemsg",qo="get_msg",xo="get_msg_noauth",Vo="get_online_member_num",Bo="delete_group_ramble_msg_by_seq",Ho="modify_group_msg",Ko="set_group_attr",Wo="modify_group_attr",Yo="delete_group_attr",jo="clear_group_attr",zo="get_group_attr",Jo="group_set_key_values",Xo="group_get_key_values",Zo="get_group_notify",Qo="update_group_counter",ei="get_group_counter",ti="get_group_member_info",si="get_members",oi="get_specified_group_member_info",ii="add_group_member",ni="delete_group_member",ri="ban_group_member",ai="modify_group_member_info",ui="modify_user_info",ci="cos",li="pre_sig",di="video_cover",pi="tim_web_report_v2",hi="alive",gi="msg_push",_i="multi_msg_push_ws",mi="ws_msg_push_ack",Mi="stat_forceoffline",fi="save_relay_json_msg",Ii="get_relay_json_msg",Ci="fetch_config",Ti="push_configv2",yi="fetch_imsdk_purchase_bitsv2",Di="push_imsdk_purchase_bitsv2",Ei="notify2",Si="create_topic",vi="destroy_topic",Li="modify_topic",Ai="get_topic",Ri="ws_set_custom_status",Ni="ws_get_user_status",Oi="ws_status_subscribe",Gi="ws_status_unsubscribe",Ui="ws_stat_background",Pi="ws_stat_foreground",ki="ws_stat_settoken",bi="get_local_words",wi="ws_batch_trans_text",$i={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_SEND_FAIL_NOT_IN_AVCHATROOM:2101,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MESSAGE_LIST_EMPTY:2114,MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GROUP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_MODIFY_CONFLICT:2480,MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,INVALID_CONVERSATION_ID:2503,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_FIND_GROUP:2603,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_WORK:2622,MEMBER_NOT_IN_GROUP:2623,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,NOT_OWNER:2681,CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:2682,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,BAN_DURATION_INVALID:2686,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,INVALID_TRTC_CMD:2995,OVER_FREQUENCY_LIMIT:2996,CANNOT_FIND_PROTOCOL:2997,CANNOT_FIND_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,CANNOT_USE_COMMERCIAL_ABILITY:3122,PROFANITY_FOUND:3123,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},Fi="networkRTT",qi="messageE2EDelay",xi="sendMessageC2C",Vi="sendMessageGroup",Bi="sendMessageGroupAV",Hi="sendMessageRichMedia",Ki="cosUpload",Wi="messageReceivedGroup",Yi="messageReceivedGroupAVPush",ji="messageReceivedGroupAVPull",zi={[Fi]:2,[qi]:3,[xi]:4,[Vi]:5,[Bi]:6,[Hi]:7,[Wi]:8,[Yi]:9,[ji]:10,[Ki]:11},Ji={info:4,warning:5,error:6},Xi={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Zi={login:4};class Qi{constructor(e){this._n="SSOLogData",this.eventType=Zi[e]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=e,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=ue()}static bindEventStatModule(e){Qi.prototype._eventStatModule=e}updateTimeStamp(){this.timestamp=ue()}start(e){return this._startts=e,this}end(e=!1){if(this._sentFlag)return;const t=ue();0===this.costTime&&(this.costTime=t-this._startts),this.setMoreMessage(`startts:${this._startts} endts:${t}`),e?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}setError(e,t,s){if(!(e instanceof Error))return ge.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;if(this.setNetworkType(s),t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=$i.NO_NETWORK;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return Oe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),ve(e)?this.code=e:ge.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return Oe(e)||this._sentFlag||(ve(e)&&(this.message=e.toString()),Le(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return Oe(e)||this._sentFlag||(this.level=Ji[e]),this}setMoreMessage(e){return Ct(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){if(Oe(e))ge.w(this._n+".setNetworkType value is undefined, please check!");else{const t=Xi[e.toLowerCase()];Oe(t)||(this.networkType=t)}return this}getStartTs(){return this._startts}setUIPlatform(e){this.uiPlatform=e}}class en{constructor(e){this.type=t.MSG_TEXT,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}class tn{constructor(e,s){this._imageMemoryURL="",this._fileDownloadProxy=s,P?this.createImageDataASURLInWXMiniApp(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||_e.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){const e=this;this._ImageInfoModel=function(t){this.instanceID=qe(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=ft(t.url||e._imageMemoryURL,e._fileDownloadProxy)},this._ImageInfoModel.prototype={setSizeType(e){this.sizeType=e},setType(e){this.type=e},setImageUrl(e){e&&(this.imageUrl=e)},getImageUrl(){return this.imageUrl}}}initImageInfoArray(e){let t=0,s=null,o=null;for(;t<=2;)o=Oe(e)||Oe(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],s=new this._ImageInfoModel(o),s.setSizeType(t+1),s.setType(t),this.addImageInfo(s),t++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(e){const t=this.content.imageInfoArray.length;let s;for(let o=0;o1&&(this._percent=1)}updateImageFormat(e){this.content.imageFormat=_e[e.toUpperCase()]||_e.UNKNOWN}createImageDataASURLInWeb(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}createImageDataASURLInWXMiniApp(e){e&&e.url&&(this._imageMemoryURL=e.url)}replaceImageInfo(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}addImageInfo(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}updateAccessSideImageInfoArray(){const e=this.content.imageInfoArray,{width:t=0,height:s=0}=e[0];0!==t&&0!==s&&(at(e),Object.assign(e[2],rt({originWidth:t,originHeight:s,min:720})))}sendable(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}class sn{constructor(e){this.type=t.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class on{constructor(e,s){this.type=t.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:e.second,size:e.size,url:ft(e.url,s),remoteAudioUrl:e.url||"",uuid:e.uuid}}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateAudioUrl(e){this.content.remoteAudioUrl=e}sendable(){return""!==this.content.remoteAudioUrl}}const nn={from:!0,groupID:!0,groupName:!0,to:!0};class rn{constructor(e){this.type=t.MSG_GRP_TIP,this.content={},this._initContent(e)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[t]=e[t],this.content.memberCount=e[t];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(e[t]);break;default:this.content[t]=e[t]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){const t=Object.keys(e);for(let s=0;s{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(e){const t=Object.keys(e);for(let s=0;s{switch(t){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;default:this.content[t]=e[t]}})}_initGroupProfile(e){const t=Object.keys(e);for(let s=0;s1&&(this._percent=1)}updateFileUrl(e){this.content.fileUrl=e}sendable(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}class ln{constructor(e){this.type=t.MSG_CUSTOM,this.content={data:e.data||"",description:e.description||"",extension:e.extension||""}}setData(e){return this.content.data=e,this}setDescription(e){return this.content.description=e,this}setExtension(e){return this.content.extension=e,this}sendable(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}class dn{constructor(e,s){this.type=t.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:e.remoteVideoUrl||e.videoUrl||"",videoFormat:e.videoFormat,videoSecond:parseInt(e.videoSecond,10),videoSize:e.videoSize,videoUrl:ft(e.videoUrl,s),videoDownloadFlag:2,videoUUID:e.videoUUID,thumbUUID:e.thumbUUID,thumbFormat:e.thumbFormat,thumbWidth:e.thumbWidth,snapshotWidth:e.thumbWidth,thumbHeight:e.thumbHeight,snapshotHeight:e.thumbHeight,thumbSize:e.thumbSize,snapshotSize:e.thumbSize,thumbDownloadFlag:2,thumbUrl:ft(e.thumbUrl,s),snapshotUrl:ft(e.thumbUrl,s)}}updatePercent(e){this._percent=e,this._percent>1&&(this._percent=1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=e)}updateSnapshotInfo(e){const{snapshotUrl:t,snapshotWidth:s,snapshotHeight:o}=e;Ct(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Ct(s)||(this.content.thumbWidth=this.content.snapshotWidth=Number(s)),Ct(o)||(this.content.thumbHeight=this.content.snapshotHeight=Number(o))}sendable(){return""!==this.content.remoteVideoUrl}}class pn{constructor(e){this.type=t.MSG_LOCATION;const{description:s,longitude:o,latitude:i}=e;this.content={description:s,longitude:o,latitude:i}}sendable(){return!0}}class hn{constructor(e,s){if(this.from=e.from,this.messageSender=e.from,this.time=e.time,this.messageSequence=e.sequence,this.clientSequence=e.clientSequence||e.sequence,this.messageRandom=e.random,this.cloudCustomData=e.cloudCustomData||"",this.clientTime=e.clientTime||void 0,e.ID)this.ID=e.ID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.messageBody=[{type:e.type,payload:e.payload}],e.conversationType.startsWith(t.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(t.CONV_GROUP)&&(this.receiverGroupID=e.to),this.messageReceiver=e.to;else{this.nick=e.nick||"",this.avatar=e.avatar||"",this.messageBody=[];const o=e.elements[0].type,i=e.elements[0].content;this._patchRichMediaPayload(o,i),this._updateRichMediaDownloadUrl(o,i,s),o===t.MSG_MERGER?this.messageBody.push({type:o,payload:new gn(i).content}):this.messageBody.push({type:o,payload:i}),e.groupID&&(this.receiverGroupID=e.groupID,this.messageReceiver=e.groupID),e.to&&(this.receiverUserID=e.to,this.messageReceiver=e.to),this.ID=`${e.tinyID}-${e.clientTime}-${e.random}`}}_patchRichMediaPayload(e,s){e===t.MSG_IMAGE?s.imageInfoArray.forEach(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===t.MSG_VIDEO?!s.remoteVideoUrl&&s.videoUrl&&(s.remoteVideoUrl=s.videoUrl):e===t.MSG_AUDIO?!s.remoteAudioUrl&&s.url&&(s.remoteAudioUrl=s.url):e===t.MSG_FILE&&!s.fileUrl&&s.url&&(s.fileUrl=s.url,s.url=void 0)}_updateRichMediaDownloadUrl(e,s,o){o&&(e===t.MSG_IMAGE?s.imageInfoArray.forEach(e=>{e.url=ft(e.url,o)}):e===t.MSG_VIDEO?(s.videoUrl=ft(s.videoUrl,o),s.snapshotUrl=ft(s.thumbUrl,o),s.snapshotHeight=s.thumbHeight,s.snapshotWidth=s.thumbWidth):e===t.MSG_AUDIO?s.url=ft(s.url,o):e===t.MSG_FILE&&(s.fileUrl=ft(s.fileUrl,o)))}}var gn=class{constructor(e,s){if(this.type=t.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},e.downloadKey){const{downloadKey:t,pbDownloadKey:s,title:o,abstractList:i,compatibleText:n,version:r}=e;this.content.downloadKey=t,this.content.pbDownloadKey=s,this.content.title=o,this.content.abstractList=i,this.content.compatibleText=n,this.content.version=r||0}else if(Ct(e.messageList))1===e.layersOverLimit&&(this.content.layersOverLimit=!0);else{const{messageList:t,title:o,abstractList:i,compatibleText:n,version:r}=e,a=[];t.forEach(e=>{if(!Ct(e)){const t=new hn(e,s);a.push(t)}}),this.content.messageList=a,this.content.title=o,this.content.abstractList=i,this.content.compatibleText=n,this.content.version=r||0}}sendable(){return!Ct(this.content.messageList)||!Ct(this.content.downloadKey)}};const _n={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST};class mn{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||t.CONV_C2C,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:qe(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this._elements=[],this.isPlaceMessage=e.isPlaceMessage||0,this.isRevoked=2===e.isPlaceMessage||8===e.msgFlagBits,this.from=e.from||null,this.to=e.to||null,this.flow="",this.isSystemMessage=e.isSystemMessage||!1,this.protocol=e.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=e.status||Dt.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=e.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromLastMessage),this.clientTime=e.clientTime||le()||0,this.senderTinyID=e.senderTinyID||e.tinyID||"",this.readReceiptInfo=e.readReceiptInfo||{readCount:void 0,unreadCount:void 0,isPeerRead:void 0},this.needReadReceipt=!0===e.needReadReceipt||1===e.needReadReceipt,this.version=e.messageVersion||0,this.isBroadcastMessage=e.isBroadcastMessage||!1,this._receiverList=e.receiverList||void 0,this.isSupportExtension=!0===e.isSupportExtension||1===e.isSupportExtension,this.revoker=e.revokerInfo&&e.revokerInfo.revoker||null,this.reInitialize(e.currentUser),this.extractGroupInfo(e.groupProfile||null),this.handleGroupAtInfo(e),this.initC2CReadReceiptInfo(e.readReceiptSentByPeer)}get elements(){return this._elements}getElements(){return this._elements}extractGroupInfo(e){if(null===e)return;Le(e.nick)&&(this.nick=e.nick),Le(e.avatar)&&(this.avatar=e.avatar);const{messageFromAccountExtraInformation:t}=e;Re(t)&&Le(t.nameCard)&&(this.nameCard=t.nameCard)}handleGroupAtInfo(e){e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach(e=>{e!==t.MSG_AT_ALL?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(t.MSG_AT_ALL))}),Ne(e.groupAtInfo)&&e.groupAtInfo.forEach(e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(t.MSG_AT_ALL)})}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?Dt.SUCCESS:Dt.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&("function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===t.CONV_GROUP&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return!1;if(void 0===He[e]){const t=new Date;let s=("3"+t.getHours()).slice(-2),o=("0"+t.getMinutes()).slice(-2),i=("0"+t.getSeconds()).slice(-2);He[e]=parseInt([s,o,i,"0001"].join("")),s=null,o=null,i=null,ge.l("autoIncrementIndex start index:"+He[e])}return He[e]++}(e)),0===this.sequence&&this.conversationType===t.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===t.CONV_SYSTEM&&(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){const{to:s}=this;let o="";const i=this.conversationType;i!==t.CONV_SYSTEM?(o=i===t.CONV_C2C?e===this.from?s:this.from:this.to,this.conversationID=o?`${i}${o}`:null):this.conversationID=t.CONV_SYSTEM}isElement(e){return e instanceof en||e instanceof tn||e instanceof sn||e instanceof on||e instanceof cn||e instanceof dn||e instanceof rn||e instanceof un||e instanceof ln||e instanceof pn||e instanceof gn}setElement(e,s){if(this.isElement(e))return this._elements=[e],void this._initProxy();const o=e=>{if(e.type&&e.content)switch(e.type){case t.MSG_TEXT:this.setTextElement(e.content);break;case t.MSG_IMAGE:this.setImageElement(e.content,s);break;case t.MSG_AUDIO:this.setAudioElement(e.content,s);break;case t.MSG_FILE:this.setFileElement(e.content,s);break;case t.MSG_VIDEO:this.setVideoElement(e.content,s);break;case t.MSG_CUSTOM:this.setCustomElement(e.content);break;case t.MSG_LOCATION:this.setLocationElement(e.content);break;case t.MSG_GRP_TIP:this.setGroupTipElement(e.content);break;case t.MSG_GRP_SYS_NOTICE:this.setGroupSystemNoticeElement(e.content);break;case t.MSG_FACE:this.setFaceElement(e.content);break;case t.MSG_MERGER:this.setMergerElement(e.content,s)}};if(Ne(e))for(let t=0;t{e.reason=t})}const{nick:i,avatar:n}=s;Le(i)&&(this.nick=i),Le(n)&&(this.avatar=n);const r=new rn(e);this._elements.push(r)}setGroupSystemNoticeElement(e){const t=new un(e);this._elements.push(t)}setFaceElement(e){const t=new sn(e);this._elements.push(t)}setMergerElement(e,t){const s=new gn(e,t);this._elements.push(s)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}getRelayFlag(){return this._relayFlag}_computePriority(e){if(Oe(e))return t.MSG_PRIORITY_NORMAL;if(Le(e)&&-1!==Object.values(_n).indexOf(e))return e;if(ve(e)){const t=""+e;if(-1!==Object.keys(_n).indexOf(t))return _n[t]}return t.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){const{nick:t,avatar:s}=e;Le(t)&&(this.nick=t),Le(s)&&(this.avatar=s)}setNameCard(e){Le(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){this.conversationType===t.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e)}}const Mn=function(e){return{code:0,data:e||{}}};class fn extends Error{constructor(e){super();const{code:t,message:s,data:o}=e;this.code=t,this.message=s||this._getErrorMessage(this.code),this.data=o||{}}}let In=null;const Cn=function(e){In=e},Tn=function(e){return Promise.resolve(Mn(e))},yn=function(t,s=!1){if(t instanceof fn)return s&&null!==In&&In.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){const t=new fn({code:$i.UNCAUGHT_ERROR});return s&&null!==In&&In.emit(e.ERROR,t),Promise.reject(t)}if(Oe(t)||Oe(t.code))return;const o=new fn(t);return s&&null!==In&&In.emit(e.ERROR,o),Promise.reject(o)};class Dn extends Gs{constructor(e){super(e),this._n="C2CModule",this._messageFromUnreadDBMap=new Map,this._signalingFromUnreadDBList=[]}onNewC2CMessage(t){const{dataList:s,isInstantMessage:o,C2CRemainingUnreadList:i,C2CPairUnreadList:n}=t;ge.d(`${this._n}.onNewC2CMessage count:${s.length} isInstantMessage:${o}`);const{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:u}=this._newC2CMessageStoredAndSummary({dataList:s,C2CRemainingUnreadList:i,C2CPairUnreadList:n,isInstantMessage:o});if(this.filterModifiedMessage(a),r.length>0){this.getModule(cs).onNewMessage({conversationOptionsList:r,isInstantMessage:o,isUnreadC2CMessage:u})}const c=this.filterUnmodifiedMessage(a);o&&c.length>0&&this.emitOuterEvent(e.MESSAGE_RECEIVED,c),a.length=0}_newC2CMessageStoredAndSummary({dataList:e,C2CRemainingUnreadList:s,C2CPairUnreadList:o,isInstantMessage:i}){let n=null;const r=[],a=[],u={},c=this.getModule(gs),l=this.getModule(Es);let d=!1;const p=this.getModule(cs),h=this.getFileDownloadProxy();for(let _=0,m=e.length;_0&&l.addMessageDelay(n.clientTime)}else this._messageFromUnreadDBMap.set(n.ID,1);if(0!==s.msgLifeTime){if(!1===n._onlineOnlyFlag){const e=p.getLastMessageTime(o);if(ve(e)&&n.time0){g=!0;const e=r.find(({conversationID:e})=>e==="C2C"+o[_].from);e?e.unreadCount=o[_].unreadCount:r.push({conversationID:"C2C"+o[_].from,unreadCount:o[_].unreadCount,type:t.CONV_C2C})}if(Ne(s))for(let _=0,m=s.length;_e==="C2C"+s[_].from)||r.push({conversationID:"C2C"+s[_].from,type:t.CONV_C2C,lastMsgTime:s[_].lastMsgTime})}return{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:g}}_isSignaling(e){const{eventArray:t}=e;return!(!Ne(t)||10!==t[0].event)}_handleSignalingFromUnreadDB(){const e=this._signalingFromUnreadDBList.length;if(ge.l(`${this._n}._handleSignalingFromUnreadDB signalingCount:${e}`),0===e)return;const t=[];this._signalingFromUnreadDBList.forEach(e=>{e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)}),this.onC2CMessageRevoked({dataList:t}),this._signalingFromUnreadDBList.length=0,t.length=0}onC2CMessageRevoked(s){const o=this.getModule(cs),i=[];let n=null,r=!0;s.dataList.forEach(e=>{if(e.c2cMessageRevokedNotify){const{revokedInfos:s}=e.c2cMessageRevokedNotify;Oe(s)||s.forEach(e=>{const s=this.getMyUserID()===e.from?`${t.CONV_C2C}${e.to}`:`${t.CONV_C2C}${e.from}`;n=o.revoke(s,e.sequence,e.random);const a=e.revokerInfo&&e.revokerInfo.revoker;if(n)n.revoker||(n.revoker=a,i.push(n));else{const t={conversationID:s,sequence:e.sequence,time:e.time,revoker:a};o.isLastMessageRevoked(t)&&(i.push(t),r=!1)}})}}),0!==i.length&&(o.onMessageRevoked(i),!0===r&&(ge.l(`${this._n}.onC2CMessageRevoked count:${i.length}`),this.emitOuterEvent(e.MESSAGE_REVOKED,i)))}onC2CMessageReadReceipt(e){e.dataList.forEach(e=>{if(!Ct(e.c2cMessageReadReceipt)){const{to:s}=e.c2cMessageReadReceipt;e.c2cMessageReadReceipt.uinPairReadArray.forEach(e=>{const{peerReadTime:o}=e;ge.d(`${this._n}._onC2CMessageReadReceipt to:${s} peerReadTime:${o}`);const i=`${t.CONV_C2C}${s}`,n=this.getModule(cs);n.recordPeerReadTime(i,o),n.updateMessageIsPeerReadProperty(i,o)})}})}onC2CMessageReadNotice(e){e.dataList.forEach(e=>{if(!Ct(e.c2cMessageReadNotice)){const s=this.getModule(cs);e.c2cMessageReadNotice.uinPairReadArray.forEach(e=>{const{from:o,peerReadTime:i}=e;ge.d(`${this._n}.onC2CMessageReadNotice from:${o} lastReadTime:${i}`);const n=`${t.CONV_C2C}${o}`;s.updateIsReadAfterReadReport({conversationID:n,lastMessageTime:i}),s.updateUnreadCount(n)})}})}onC2CMessageModified(e){ge.d(this._n+".onC2CMessageModified options:",JSON.stringify(e));const s=this.getModule(cs);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_C2C})})}onReadReceiptList(e){ge.d(this._n+".onReadReceiptList options:",JSON.stringify(e));const{userID:t,readReceiptList:s}=e.dataList;this.getModule(cs).updateReadReceiptInfo({userID:t,readReceiptList:s})}sendMessage(e,t){const s=this._createC2CMessagePack(e,t);return this.request(s)}_createC2CMessagePack(e,t){let s=null;t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly&&(s?s.disablePush=!0:s={disablePush:!0}));let o="";Le(e.cloudCustomData)&&e.cloudCustomData.length>0&&(o=e.cloudCustomData);const i=[];if(Re(t)&&Re(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}const n=this.isOnlineMessage(e,t)?0:void 0;return{protocolName:Fs,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:o,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:n,nick:e.nick,avatar:e.avatar,offlinePushInfo:s?{pushFlag:!0===s.disablePush?1:0,title:s.title||"",desc:s.description||"",ext:s.extension||"",apnsInfo:{badgeMode:!0===s.ignoreIOSBadge?1:0,isVoipPush:this._isVoipPush(s)},androidInfo:{OPPOChannelID:s.androidOPPOChannelID||""}}:void 0,messageControlInfo:0!==n?i:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0}}}_isVoipPush(e){let t=void 0;return Oe(e.disableVoipPush)||(t=!1===e.disableVoipPush?1:0),t}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.request({protocolName:Ws,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}deleteMessage(e){const{to:t,keyList:s}=e;return ge.l(`${this._n}.deleteMessage toAccount:${t} count:${s.length}`),this.request({protocolName:Zs,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:s}})}modifyRemoteMessage(e){const{from:t,to:s,version:o=0,sequence:i,random:n,time:r,payload:a,type:u,cloudCustomData:c}=e;let l=void 0;return gt(u)&&(l=[],l.push({type:u,content:a})),this.request({protocolName:Qs,requestData:{from:t,to:s,version:o,sequence:i,random:n,time:r,elements:l,cloudCustomData:c}})}setMessageRead({conversationID:e,lastMessageTime:t}){const s=this._n+".setMessageRead";ge.l(`${s} conversationID:${e} lastMessageTime:${t}`),ve(t)||this.outputWarning("DoNotModifyLastTime");const o=new Qi("setC2CMessageRead");return o.setMessage(`conversationID:${e} lastMessageTime:${t}`),this.request({protocolName:Ys,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:e.replace("C2C",""),lastMessageTime:t,receipt:1}]}}}).then(()=>{o.setNetworkType(this.getNetworkType()).end(),ge.l(s+" ok");const i=this.getModule(cs);return i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:t}),i.updateUnreadCount(e),Mn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.l(s+" failed. error:",e),yn(e)))}getRoamingMessage(e){const s=this._n+".getRoamingMessage",{peerAccount:o,conversationID:i,count:n,lastMessageTime:r,messageKey:a}=e,u=`peerAccount:${o} count:${n||15} lastMessageTime:${r||0} messageKey:${a}`;ge.l(`${s} ${u}`);const c=new Qi("getC2CRoamingMessages");return this.request({protocolName:Js,requestData:{peerAccount:o,count:n||15,lastMessageTime:r||0,messageKey:a}}).then(e=>{const{complete:o,messageList:n,messageKey:r,lastMessageTime:a}=e.data;Oe(n)?ge.l(`${s} ok. complete:${o} but messageList is undefined!`):ge.l(`${s} ok. complete:${o} count:${n.length}`),c.setNetworkType(this.getNetworkType()).setMessage(`${u} complete:${o} length:${n.length}`).end();const l=this.getModule(cs);1===o&&l.setCompleted(i);const d=l.onRoamingMessage(n,i);l.modifyMessageList(i),l.updateIsRead(i),l.updateRoamingMessageKeyAndTime(i,r,a);const p=l.getPeerReadTime(i);if(ge.l(`${s} update isPeerRead property. conversationID:${i} peerReadTime:${p}`),p)l.updateMessageIsPeerReadProperty(i,p);else{const e=i.replace(t.CONV_C2C,"");this.getRemotePeerReadTime([e]).then(()=>{l.updateMessageIsPeerReadProperty(i,l.getPeerReadTime(i))})}let h="";if(d.length>0)h=d[0].ID;else{const e=l.getLocalOldestMessage(i);e&&(h=e.ID)}return ge.l(`${s} nextReqID:${h} stored message count:${d.length}`),{nextReqID:h,storedMessageList:d}}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setMessage(u).setError(e,t,s).end()}),ge.w(s+" failed. error:",e),yn(e)))}getRoamingMessagesHopping(e){const s=this._n+".getRoamingMessagesHopping",{peerAccount:o,time:i=0,count:n,direction:r}=e,a=`${t.CONV_C2C}${o}`,u=`peerAccount:${o} count:${n} time:${i} direction:${r}`;ge.l(`${s} ${u}`);const c=new Qi("getC2CRoamingMessagesHopping");return this.request({protocolName:Js,requestData:{peerAccount:o,count:n+1,lastMessageTime:i,direction:r}}).then(e=>{const{complete:t,messageList:o=[],lastMessageTime:i}=e.data;ge.l(`${s} ok. complete:${t} count:${o.length}`),c.setNetworkType(this.getNetworkType()).setMessage(`${u} complete:${t} length:${o.length}`).end(),1!==t&&(1===r?o.pop():o.shift());const n=this.getModule(cs).onRoamingMessage(o,a,!1);this._modifyMessageList(a,n);const l=this._computeResult({complete:t,lastMessageTime:i,resultList:n});return Mn(l)}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setMessage(u).setError(e,t,s).end()}),ge.w(s+" failed. error:",e),yn(e)))}_computeResult(e){const{complete:t=0,lastMessageTime:s,resultList:o=[]}=e,i={messageList:[...o],isCompleted:!1,nextMessageTime:""};return 1===t?(i.isCompleted=!0,i):(i.nextMessageTime=s,i)}_modifyMessageList(e,t){const s=this.getModule(cs).getLocalConversation(e);if(!s)return;const o=s.userProfile.nick,i=s.userProfile.avatar,n=this.getModule(os).getNickAndAvatarByUserID(this.getMyUserID()),r=n.nick,a=n.avatar;for(let u=t.length-1;u>=0;u--){const e=t[u];"in"===e.flow&&(e.nick!==o&&e.setNickAndAvatar({nick:o}),e.avatar!==i&&e.setNickAndAvatar({avatar:i})),"out"===e.flow&&(e.nick!==r&&e.setNickAndAvatar({nick:r}),e.avatar!==a&&e.setNickAndAvatar({avatar:a}))}}getRemotePeerReadTime(e){const t=this._n+".getRemotePeerReadTime";if(Ct(e))return ge.w(t+" userIDList is empty!"),Promise.resolve();const s=new Qi("getPeerReadTime");return ge.l(`${t} userIDList:${e}`),this.request({protocolName:Xs,requestData:{userIDList:e}}).then(o=>{const{peerReadTimeList:i}=o.data;ge.l(`${t} ok. peerReadTimeList:${i}`);let n="";const r=this.getModule(cs);for(let t=0;t0&&r.recordPeerReadTime("C2C"+e[t],i[t]);s.setNetworkType(this.getNetworkType()).setMessage(n).end()}).catch(e=>{this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.w(t+" failed. error:",e)})}sendReadReceipt(e){const s=e[0].conversationID.replace(t.CONV_C2C,""),o=new Qi("sendC2CReadReceipt");o.setMessage("peerAccount:"+s);const i=this.getMyUserID(),n=e.filter(e=>e.from!==i&&!0===e.needReadReceipt).map(e=>{const{from:t,to:s,sequence:o,random:i,time:n,clientTime:r}=e;return{fromAccount:t,toAccount:s,sequence:o,random:i,time:n,clientTime:r}});if(0===n.length)return yn({code:$i.READ_RECEIPT_MESSAGE_LIST_EMPTY});const r=this._n+".sendReadReceipt";return ge.l(`${r}. peerAccount:${s} messageInfoList length:${n.length}`),this.request({protocolName:bo,requestData:{peerAccount:s,messageInfoList:n}}).then(e=>(o.end(),ge.l(r+" ok"),Mn())).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.w(r+" failed. error:",e),yn(e)))}getReadReceiptList(e){const t=this._n+".getReadReceiptList",s=this.getMyUserID(),o=e.filter(e=>e.from===s&&!0===e.needReadReceipt);return ge.l(`${t} userID:${s} messageList length:${o.length}`),Tn({messageList:o})}getMessageExtensions(e,t){return ge.l(`${this._n}.getMessageExtensions startSequence:${t}`),this.request({protocolName:to,requestData:{from:e.from,to:e.to,messageKey:this._getMessageKey(e),startSequence:t}})}modifyMessageExtensions(e,t,s=1){return ge.l(`${this._n}.modifyMessageExtensions operateType:${s}`),this.request({protocolName:eo,requestData:{from:e.from,to:e.to,messageKey:this._getMessageKey(e),extensionList:t,operateType:s}})}_getMessageKey(e){const{clientSequence:t,random:s,time:o}=e;return`${t}_${s}_${o}`}reset(){ge.l(this._n+".reset"),this._messageFromUnreadDBMap.clear(),this._signalingFromUnreadDBList.length=0}}class En{constructor(){this.list=new Map,this._n="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map}getLocalOldestMessageByConversationID(e){if(!e)return null;if(!this.list.has(e))return null;const t=this.list.get(e).values();return t?t.next().value:null}pushIn(e,t=!1){const{conversationID:s}=e;let o=!0;this.list.has(s)||this.list.set(s,new Map);const i=this._getUniqueIDOfMessage(e);if(this.list.get(s).has(i)){const e=this.list.get(s).get(i);if(!t||!0===e.isModified)return o=!1,o}return this.list.get(s).set(i,e),this._setLatestMessageSentByPeer(s,e),this._setLatestMessageSentByMe(s,e),o}unshift(e,s){let o;if(Ne(e)?e.length>0&&(o=e[0].conversationID,this._unshiftMultipleMessages(e,s)):(o=e.conversationID,this._unshiftSingleMessage(e,s)),o&&o.startsWith(t.CONV_C2C)){const e=Array.from(this.list.get(o).values()),t=e.length;if(0===t)return;for(let s=t-1;s>=0;s--)if("out"===e[s].flow){this._setLatestMessageSentByMe(o,e[s]);break}for(let s=t-1;s>=0;s--)if("in"===e[s].flow){this._setLatestMessageSentByPeer(o,e[s]);break}}}_unshiftSingleMessage(e,t){const{conversationID:s}=e,o=this._getUniqueIDOfMessage(e);if(!this.list.has(s))return this.list.set(s,new Map),this.list.get(s).set(o,e),void t.push(e);const i=this.list.get(s),n=Array.from(i);i.has(o)||(n.unshift([o,e]),this.list.set(s,new Map(n)),t.push(e))}_unshiftMultipleMessages(e,t){const s=e.length,o=[],i=e[0].conversationID,n=this.list.get(i),r=this.list.has(i)?Array.from(n):[];for(let a=0;a=0;l--)"in"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),c=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),c=!0),c&&(u+=1));ge.l(`${this._n}.modifyMessageSentByPeer conversationID:${t} count:${u}`)}modifyMessageSentByMe(e){const{conversationID:t,latestNick:s,latestAvatar:o}=e,i=this.list.get(t);if(Ct(i))return;const n=Array.from(i.values()),r=n.length;if(0===r)return;let a=null,u=0,c=!1;for(let l=r-1;l>=0;l--)"out"===n[l].flow&&(a=n[l],a.nick!==s&&(a.setNickAndAvatar({nick:s}),c=!0),a.avatar!==o&&(a.setNickAndAvatar({avatar:o}),c=!0),c&&(u+=1));ge.l(`${this._n}.modifyMessageSentByMe conversationID:${t} count:${u}`)}getTopicConversationIDList(e){return[...this.list.keys()].filter(s=>s.startsWith(`${t.CONV_GROUP}${e}`))}traversal(){if(0!==this.list.size&&-1===ge.getLevel()){console.group("conversationID-messageCount");for(const[e,t]of this.list)console.log(`${e}-${t.size}`);console.groupEnd()}}onMessageModified(e,t){if(!this.list.has(e))return{isUpdated:!1,message:null};const s=this._getUniqueIDOfMessage(t),o=this.list.get(e).has(s);if(ge.d(`${this._n}.onMessageModified conversationID:${e} uniqueID:${s} has:${o}`),o){const o=this.list.get(e).get(s),{messageVersion:i,elements:n,cloudCustomData:r}=t;return o.version{const e=this._readyQueue;this._readyQueue=[],e&&e.length>0&&e.forEach((function(e){e.call(this)}),this)},1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};const Rn=["jpg","jpeg","gif","png","bmp","image","webp"],Nn=["mp4","quicktime","mov"],On=1,Gn=2,Un=3,Pn=255;class kn{constructor(e){Ct(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||t.ALLOW_TYPE_ALLOW_ANY,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||t.FORBID_TYPE_NONE,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Ct(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(Ct(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){const t=e.profileCustomField.length;let s=null;for(let o=0;o500&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${Fe(e[o])} bytes`,t=!1);break;case"gender":Be(Me,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":ve(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":Le(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":Le(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":Be(Ie,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":ve(e.language)||(s="language must be a number",t=!1);break;case"avatar":Le(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":Be(fe,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":ve(e.level)||(s="level must be a number",t=!1);break;case"role":ve(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+o+" "+e[o],t=!1}}return{valid:t,tips:s}}}class bn{constructor(e){this.value=e,this.next=null}}class wn{constructor(e){this.MAX_LENGTH=e,this.pTail=null,this.pNodeToDel=null,this.map=new Map}set(e){const t=new bn(e);if(this.map.size0&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&we(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n}){const r={nameCard:e,joinTime:t,role:s,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:n};we(this.selfInfo,{...r},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const qn=function(e,t){return Oe(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:e instanceof mn?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:ht(e.type,e.payload,t),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1,revoker:e.revoker||null}:{...e,messageForShow:ht(e.type,e.payload,t)}};class xn{constructor(e,t){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=qn(e.lastMessage,t),e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=e.isPinned||!1,this.messageRemindType="",this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this._initProfile(e)}get toAccount(){return this.conversationID.startsWith(t.CONV_C2C)?this.conversationID.replace(t.CONV_C2C,""):this.conversationID.startsWith(t.CONV_GROUP)?this.conversationID.replace(t.CONV_GROUP,""):""}get subType(){return this.groupProfile?this.groupProfile.type:""}_initProfile(e){Object.keys(e).forEach(t=>{switch(t){case"userProfile":this.userProfile=e.userProfile;break;case"groupProfile":this.groupProfile=e.groupProfile}}),Oe(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new kn({userID:e.conversationID.replace("C2C","")}):Oe(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new Fn({groupID:e.conversationID.replace("GROUP","")}))}updateUnreadCount(e){const{nextUnreadCount:s,isFromGetConversations:o,isUnreadC2CMessage:i}=e;Oe(s)||(je(this.subType)?this.unreadCount=0:o&&this.type===t.CONV_GROUP||o&&this.type===t.CONV_TOPIC||i&&this.type===t.CONV_C2C?this.unreadCount=s:this.unreadCount=this.unreadCount+s)}updateLastMessage(e){this.lastMessage=qn(e)}updateGroupAtInfoList(e){if(this._isNeedMergeGroupAtInfo(e))return;let[...s]=e.groupAtType;-1!==s.indexOf(t.CONV_AT_ME)&&-1!==s.indexOf(t.CONV_AT_ALL)&&(s=[t.CONV_AT_ALL_AT_ME]);const o={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:s,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(o)}_isNeedMergeGroupAtInfo(e){const{groupID:s,sequence:o}=e;if(!ze({groupID:s}))return!1;let i=!1;return this.groupAtInfoList.forEach(s=>{s.messageSequence===o&&(s.atTypeArray.indexOf(t.CONV_AT_ME)>-1&&e.groupAtType.indexOf(t.CONV_AT_ALL)>-1&&(s.atTypeArray=[t.CONV_AT_ALL_AT_ME]),s.atTypeArray.indexOf(t.CONV_AT_ALL)>-1&&e.groupAtType.indexOf(t.CONV_AT_ME)>-1&&(s.atTypeArray=[t.CONV_AT_ALL_AT_ME],s.__random=e.__random,s.__sequence=e.__sequence),i=!0)}),i}clearGroupAtInfoList(){this.groupAtInfoList.length=0}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked({sequence:e,time:s}){return this.type===t.CONV_C2C&&e===this.lastMessage.lastSequence&&s===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}}class Vn{constructor(e){this._conversationModule=e,this._n="MessageRemindHandler",this._updateSequence=0}getC2CMessageRemindType(){const e=this._n+".getC2CMessageRemindType";return this._conversationModule.request({protocolName:zs,updateSequence:this._updateSequence}).then(t=>{ge.l(e+" ok");const{updateSequence:s,muteFlagList:o}=t.data;this._updateSequence=s,this._patchC2CMessageRemindType(o)}).catch(t=>{ge.e(e+" failed. error:",t)})}_patchC2CMessageRemindType(e){let s=0,o="";Ne(e)&&e.length>0&&e.forEach(e=>{const{userID:i,muteFlag:n}=e;0===n?o=t.MSG_REMIND_ACPT_AND_NOTE:1===n?o=t.MSG_REMIND_DISCARD:2===n&&(o=t.MSG_REMIND_ACPT_NOT_NOTE),!0===this._conversationModule.patchMessageRemindType({ID:i,isC2CConversation:!0,messageRemindType:o})&&(s+=1)}),ge.l(`${this._n}._patchC2CMessageRemindType count:${s}`)}set(e){return e.groupID?this._setGroupMessageRemindType(e):Ne(e.userIDList)?this._setC2CMessageRemindType(e):void 0}_setGroupMessageRemindType(e){const t=this._n+"._setGroupMessageRemindType",{groupID:s,messageRemindType:o}=e,i=`groupID:${s} messageRemindType:${o}`,n=new Qi("setMessageRemindType");n.setMessage(i);return this._getModule(as).modifyGroupMemberInfo({groupID:s,messageRemindType:o,userID:this._conversationModule.getMyUserID()}).then(()=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(`${t} ok. ${i}`);const s=this.onGroupMessageRemindTypeUpdated(e);return this._conversationModule.emitTotalUnreadMessageCountUpdate(),Mn(s)}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}onGroupMessageRemindTypeUpdated(t){const{groupID:s,messageRemindType:o}=t,i=this._getModule(ns).getLocalGroupProfile(s);if(i&&(i.selfInfo.messageRemindType=o),Je(s)){const t=s,i=pt(t),n=this._getModule(us).getLocalTopic(i,t);return n&&(n.updateSelfInfo({messageRemindType:o}),this._conversationModule.emitOuterEvent(e.TOPIC_UPDATED,{groupID:i,topic:n})),{topic:n}}return this._conversationModule.patchMessageRemindType({ID:s,isC2CConversation:!1,messageRemindType:o})&&this._emitConversationUpdate(),{group:i}}_setC2CMessageRemindType(e){const s=this._n+"._setC2CMessageRemindType",{userIDList:o,messageRemindType:i}=e,n=o.slice(0,30);let r=0;i===t.MSG_REMIND_DISCARD?r=1:i===t.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);const a=`userIDList:${n} messageRemindType:${i}`,u=new Qi("setMessageRemindType");return u.setMessage(a),this._conversationModule.request({protocolName:js,requestData:{userIDList:n,muteFlag:r}}).then(e=>{u.setNetworkType(this._conversationModule.getNetworkType()).end();const{updateSequence:t,errorList:o}=e.data;this._updateSequence=t;const r=[],a=[];Ne(o)&&o.forEach(e=>{r.push(e.userID),a.push({userID:e.userID,code:e.errorCode})});const c=n.filter(e=>-1===r.indexOf(e));ge.l(`${s} ok. successUserIDList:${c} failureUserIDList:${JSON.stringify(a)}`);let l=0;return c.forEach(e=>{this._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(l+=1)}),l>=1&&this._emitConversationUpdate(),n.length=r.length=0,this._conversationModule.emitTotalUnreadMessageCountUpdate(),Tn({successUserIDList:c.map(e=>({userID:e})),failureUserIDList:a})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}_getModule(e){return this._conversationModule.getModule(e)}_emitConversationUpdate(){this._conversationModule.emitConversationUpdate(!0,!1)}setUpdateSequence(e){this._updateSequence=e}reset(){ge.l(this._n+".reset"),this._updateSequence=0}}class Bn{constructor(e){this._conversationModule=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=Et.NOT_START}setConvCustomData(e){const s=this._n+".setConvCustomData",{conversationIDList:o,customData:i}=e;ge.l(s+" options:",e);const n=new Qi("setConvCustomData");n.setMessage(JSON.stringify(e));const r={fromAccount:this._getMyUserID(),itemList:[]},a=[],u=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(u,e),!0;if(!Xe(e)&&!Ze(e))return this._onConversationIDInvalid(u,e),!0;const s={operationType:2,contactItem:void 0,customMark:i};Xe(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:Ze(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),r.itemList.push(s)}),u.length===o.length?Tn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:uo,requestData:r}).then(e=>{n.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(s+" ok");const{resultItem:t}=e.data;if(Ne(t)){let e,s,o=!1;t.forEach(t=>{e=this._concatConversationID(t.contactItem),0===t.resultCode?(a.push(e),s=this._getLocalConversation(e),s&&s.customData!==i&&(s.customData=i,o=!0)):u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return Mn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}markConversation(e){if(!this._conversationModule.canIUse(M.CONV_MARK))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".markConversation",{conversationIDList:o,markType:i,enableMark:n}=e;ge.l(s+" options:",e);const r=new Qi("markConversation");r.setMessage(JSON.stringify(e));let a=void 0,u=void 0;const c=this._getFlagBit(i);!0===n?u=[c]:a=[c];const l={fromAccount:this._getMyUserID(),itemList:[]},d=[],p=[];return o.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(p,e),!0;if(!Xe(e)&&!Ze(e))return this._onConversationIDInvalid(p,e),!0;const s={operationType:1,contactItem:void 0,clearMark:a,setMark:u};Xe(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:Ze(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),l.itemList.push(s)}),p.length===o.length?Tn({successConversationIDList:d,failureConversationIDList:p}):this._conversationModule.request({protocolName:co,requestData:l}).then(e=>{r.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(s+" ok");const{resultItem:t}=e.data;if(Ne(t)){let e,s,o=!1;t.forEach(t=>{if(e=this._concatConversationID(t.contactItem),0===t.resultCode){if(d.push(e),s=this._getLocalConversation(e),s){const e=s.markList.indexOf(i);!0===n?-1===e&&(s.markList.push(i),o=!0):-1!==e&&(s.markList.splice(e,1),o=!0)}}else p.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&this._emitConversationUpdate()}return Mn({successConversationIDList:d,failureConversationIDList:p})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}getLocalConvGroupList(){return ge.l(`${this._n}.getLocalConvGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===Et.REJECTED?this.getRemoteConvGroupList().then(()=>Mn([...this._convGroupMap.values()])):Tn([...this._convGroupMap.values()])}getRemoteConvGroupList(){const e=this._n+".getRemoteConvGroupList";return this._pagingStatus=Et.PENDING,this._conversationModule.request({protocolName:mo,requestData:{fromAccount:this._getMyUserID(),startIndex:this._startIndex,startTime:le()}}).then(t=>{const{completeFlag:s,contactItem:o,nextStartIndex:i=0,groupItem:n}=t.data;if(this._startIndex=i,ge.l(`${e} completeFlag:${s} nextStartIndex:${i}`),Ne(n)&&n.forEach(e=>{const{convGroupID:t,groupName:s}=e;this._convGroupMap.set(t,s)}),Ne(o)){let e,t;o.forEach(s=>{const{standardMark:o,customData:i,convGroupIDList:n}=s;if(e=this._concatConversationID(s),t=this._getLocalConversation(e),t&&(t.markList=_t(o),t.customData=i||"",Ne(n))){const e=[];n.forEach(t=>{this._convGroupMap.has(t)&&e.push(this._convGroupMap.get(t))}),t.conversationGroupList=[...e],e.length=0}})}if(0===s)return this.getRemoteConvGroupList();1===s&&(this._pagingStatus=Et.RESOLVED,this._emitConversationUpdate(),this._emitConvGroupListUpdate())}).catch(t=>{this._pagingStatus=Et.REJECTED,ge.w(e+" failed. error:",t)})}createConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".createConvGroup";ge.l(s+" options:",e);const o=new Qi("createConvGroup");o.setMessage(JSON.stringify(e));const{groupName:i,conversationIDList:n}=e,r={fromAccount:this._getMyUserID(),itemList:[{groupName:i,contactItem:[]}]},a=[],u=[];return n.forEach(e=>this._hasLocalConversation(e)?Xe(e)||Ze(e)?void(Xe(e)?r.itemList[0].contactItem.push({type:1,toAccount:e.replace(t.CONV_C2C,"")}):Ze(e)&&r.itemList[0].contactItem.push({type:2,groupID:e.replace(t.CONV_GROUP,"")})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===n.length?Tn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:lo,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(s+" ok");const{groupResultItem:t}=e.data,{groupItem:n,resultItem:r}=t[0];if(Re(n)&&(this._convGroupMap.set(n.convGroupID,n.groupName),this._emitConvGroupListUpdate()),Ne(r)){let e,t,s=!1;r.forEach(o=>{e=this._concatConversationID(o.contactItem),0===o.resultCode?(a.push(e),t=this._getLocalConversation(e),t&&-1===t.conversationGroupList.indexOf(i)&&(t.conversationGroupList.push(i),s=!0)):u.push({conversationID:e,code:o.resultCode,message:o.resultInfo})}),!0===s&&(this._emitConversationUpdate(),this._emitConvGroupListUpdate())}return Mn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}deleteConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".deleteConvGroup";ge.l(`${t} groupName:${e}`);const s=new Qi("deleteConvGroup");return s.setMessage(e),this._conversationModule.request({protocolName:po,requestData:{fromAccount:this._getMyUserID(),groupName:[e]}}).then(o=>{s.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(t+" ok");const{groupItem:i}=o.data;if(Ne(i)){let e=!1;i.forEach(t=>{this._convGroupMap.has(t.convGroupID)&&(this._convGroupMap.delete(t.convGroupID),e=!0)}),!0===e&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList([e])}).catch(e=>(this._conversationModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}renameConvGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".renameConvGroup";ge.l(t+" options:",e);const s=new Qi("renameConvGroup");s.setMessage(JSON.stringify(e));const{oldName:o,newName:i}=e;return this._conversationModule.request({protocolName:ho,requestData:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:o,newName:i}}}).then(e=>{s.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(t+" ok");const{updateGroupResult:n}=e.data,{convGroupID:r}=n;this._convGroupMap.set(r,i),this._emitConvGroupListUpdate();const a=this._conversationModule.getLocalConversationList();let u,c,l=!1;a.forEach(e=>{u=e.conversationGroupList,c=u.indexOf(o),-1!==c&&(u.splice(c,1,i),l=!0)}),!0===l&&this._emitConversationUpdate()}).catch(e=>(this._conversationModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}addConvsToGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".addConvsToGroup";ge.l(s+" options:",e);const o=new Qi("addConvsToGroup");o.setMessage(JSON.stringify(e));const{conversationIDList:i,groupName:n}=e,r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],u=[];return i.forEach(e=>this._hasLocalConversation(e)?Xe(e)||Ze(e)?void(Xe(e)?r.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):Ze(e)&&r.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===i.length?Tn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:go,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(s+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(Ne(t)){let e,s,o=!1;t.forEach(t=>{e=this._concatConversationID(t.contactItem),0===t.resultCode?(s=this._getLocalConversation(e),s&&-1===s.conversationGroupList.indexOf(n)&&(s.conversationGroupList.push(n),a.push(e),o=!0)):u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(n))}return Mn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}deleteConvsFromGroup(e){if(!this._conversationModule.canIUse(M.CONV_GROUP))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".deleteConvsFromGroup";ge.l(s+" options:",e);const o=new Qi("deleteConvsFromGroup");o.setMessage(JSON.stringify(e));const{conversationIDList:i,groupName:n}=e,r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],u=[];return i.forEach(e=>this._hasLocalConversation(e)?Xe(e)||Ze(e)?void(Xe(e)?r.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):Ze(e)&&r.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(u,e),!0):(this._onConversationNotFound(u,e),!0)),u.length===i.length?Tn({successConversationIDList:a,failureConversationIDList:u}):this._conversationModule.request({protocolName:_o,requestData:r}).then(e=>{o.setNetworkType(this._conversationModule.getNetworkType()).end(),ge.l(s+" ok");const{contactResultItem:t}=e.data.updateGroupResult;if(Ne(t)){let e,s,o=!1;t.forEach(t=>{if(e=this._concatConversationID(t.contactItem),0===t.resultCode){if(s=this._getLocalConversation(e),s){const t=s.conversationGroupList.indexOf(n);-1!==t&&(s.conversationGroupList.splice(t,1),a.push(e),o=!0)}}else u.push({conversationID:e,code:t.resultCode,message:t.resultInfo})}),!0===o&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(n))}return Mn({successConversationIDList:a,failureConversationIDList:u})}).catch(e=>(this._conversationModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}onConvMarkUpdated(e){if(Ct(e))return;let t,s;ge.d(this._n+".onConvMarkUpdated markItemList:",e);let o=!1;e.forEach(e=>{const{recentContactItem:i,optType:n,standardMark:r,customMark:a}=e;if(t=this._concatConversationID(i),s=this._getLocalConversation(t),s)if(1===n){const e=_t(r);!0!==function(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let s=0,o=e.length;s{const{groupID:o,groupName:i}=e.msgGroupItem;this._convGroupMap.get(o)!==i&&(this._convGroupMap.set(o,i),s=!0);const n=e.msgRecentContactItem;if(Ne(n)){let e,s;n.forEach(o=>{e=this._concatConversationID(o),s=this._getLocalConversation(e),s&&-1===s.conversationGroupList.indexOf(i)&&(s.conversationGroupList.push(i),t=!0)})}}),!0===t&&this._emitConversationUpdate(),!0===s&&this._emitConvGroupListUpdate())}onConvGroupDeleted(e){ge.d(this._n+".onConvGroupDeleted groupItemList:",e);const t=[];if(Ne(e)){let s=!1;e.forEach(e=>{const{groupID:o,groupName:i}=e;this._convGroupMap.has(o)&&(this._convGroupMap.delete(o),s=!0,t.push(i))}),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(t)}_eraseFromConversationGroupList(e){if(Ct(e))return;this._conversationModule.getLocalConversationList().forEach(t=>{t.conversationGroupList=t.conversationGroupList.filter(t=>!e.includes(t))}),this._emitConversationUpdate()}onConvGroupNameUpdated(e){ge.d(this._n+".onConvGroupNameUpdated options:",e);const{groupID:t,groupName:s,oldGroupName:o}=e;if(this._convGroupMap.get(t)===s)return;this._convGroupMap.set(t,s),this._emitConvGroupListUpdate();const i=this._conversationModule.getLocalConversationList();let n,r,a=!1;i.forEach(e=>{n=e.conversationGroupList,r=n.indexOf(o),-1!==r&&(n.splice(r,1,s),a=!0)}),!0===a&&this._emitConversationUpdate()}onConvInGroupUpdated(e){ge.d(this._n+".onConvInGroupUpdated options:",e);const{oldGroupName:t,recentContactUpdateGroupItem:s}=e;if(Ne(s)){let e,o,i,n=!1;s.forEach(s=>{const{contactOptType:r,recentContactItem:a}=s;e=this._concatConversationID(a),o=this._getLocalConversation(e),o&&(i=o.conversationGroupList.indexOf(t),1===r?-1===i&&(o.conversationGroupList.push(t),n=!0):2===r&&-1!==i&&(o.conversationGroupList.splice(i,1),n=!0))}),!0===n&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(t))}}onConvAddedToOrDeletedFromGroup(e){ge.d(this._n+".onConvAddedToOrDeletedFromGroup options:",e);const{msgRecentContactItem:t,msgRecentContactUpdateContactItem:s}=e,o=this._concatConversationID(t),i=this._getLocalConversation(o);if(i&&Ne(s)){let e,t=!1;s.forEach(s=>{const{groupOptType:o,recentContactGroupItem:n}=s,{groupName:r}=n;e=i.conversationGroupList.indexOf(r),1===o?-1===e&&(i.conversationGroupList.push(r),t=!0):2===o&&-1!==e&&(i.conversationGroupList.splice(e,1),t=!0),!0===t&&this._emitConvInGroupUpdate(r)}),!0===t&&this._emitConversationUpdate()}}onConvGroupListSynced(e){Ne(e)&&0!==e.length&&(ge.l(this._n+".onConvGroupListSynced groupItemList:",e),e.forEach(e=>{this._convGroupMap.set(e.convGroupID,e.groupName)}))}getConvGroupListByID(e){if(Ct(e))return;const t=[];return e.forEach(e=>{this._convGroupMap.has(e)&&t.push(this._convGroupMap.get(e))}),t}_onConversationNotFound(e,t){e.push({conversationID:t,code:$i.CONVERSATION_NOT_FOUND,message:this._conversationModule.getErrorMessage($i.CONVERSATION_NOT_FOUND)})}_onConversationIDInvalid(e,t){e.push({conversationID:t,code:$i.INVALID_CONVERSATION_ID,message:this._conversationModule.getErrorMessage($i.INVALID_CONVERSATION_ID)})}_getFlagBit(e){const t=e.toString(2),s=t.length;for(let o=s-1;o>=0;o--)if("1"===t[o])return s-o-1}_concatConversationID(e){const{type:s,to:o,groupID:i,userID:n}=e;let r;return 1===s?Oe(n)?Oe(o)||(r=`${t.CONV_C2C}${o}`):r=`${t.CONV_C2C}${n}`:2===s&&(r=`${t.CONV_GROUP}${i}`),r}_getMyUserID(){return this._conversationModule.getMyUserID()}_insertConversationGroup(e,t){const s=this._getLocalConversation(e);if(s){const e=s.conversationGroupList;-1===e.indexOf(t)&&e.push(t)}}_getLocalConversation(e){return this._conversationModule.getLocalConversation(e)}_hasLocalConversation(e){return this._conversationModule.hasLocalConversation(e)}_emitConversationUpdate(){this._conversationModule.emitConversationUpdate(!0,!1)}_emitConvGroupListUpdate(){this._conversationModule.emitOuterEvent(e.CONVERSATION_GROUP_LIST_UPDATED,[...this._convGroupMap.values()])}_emitConvInGroupUpdate(t){const s={groupName:t,conversationList:[]},o=this._conversationModule.getLocalConversationList();s.conversationList=o.filter(e=>e.conversationGroupList.includes(t)),this._conversationModule.emitOuterEvent(e.CONVERSATION_IN_GROUP_UPDATED,s)}reset(){ge.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=Et.NOT_START}}class Hn extends Gs{constructor(e){super(e),this._n="ConversationModule",An.mixin(this),this._messageListHandler=new En,this._messageRemindHandler=new Vn(this),this._convGroupHandler=new Bn(this),this.singlyLinkedList=new wn(100),this._pagingStatus=Et.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._pagingConvIDMap=new Map,this._convIDFromUnreadDBMap=new Map,this._conversationMap=new Map,this._tmpGroupList=[],this._tmpGroupAtTipsList=[],this._peerReadTimeMap=new Map,this._completedMap=new Map,this._roamingMessageKeyAndTimeMap=new Map,this._roamingMessageSequenceMap=new Map,this._remoteGroupReadSequenceMap=new Map,this._convTotalUnreadCount=0,this._pagingGetCostList=[],this._initListeners()}_initListeners(){const e=this.getInnerEmitterInstance();e.on(Sn,this._initLocalConversationList,this),e.on(Ln,this._onProfileUpdated,this)}onCheckTimer(e){e%60==0&&this._messageListHandler.traversal()}_initLocalConversationList(){const e=new Qi("_initLocalConversationList");ge.l(this._n+"._initLocalConversationList");let s="";const o=this._getStorageConversationList(),i=this.isIntl();if(o){const e=o.length;for(let s=0;s{this._tmpGroupList.length>0&&(this.updateConversationGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)}),this.syncConversationList()}onMessageSent(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}onNewMessage(e){this._onSendOrReceiveMessage(e)}_onSendOrReceiveMessage(e){const{conversationOptionsList:s,isInstantMessage:o=!0,isUnreadC2CMessage:i=!1,updateUnreadCount:n=!0}=e;if(!this._isReady)return void this.ready(()=>{this._onSendOrReceiveMessage(e)});if(0===s.length)return;this._getC2CPeerReadTime(s),this._updateLocalConversationList({conversationOptionsList:s,isInstantMessage:o,isUnreadC2CMessage:i,isFromGetConversations:!1,updateUnreadCount:n}),o||(this._convIDFromUnreadDBMap=new Map([...this._convIDFromUnreadDBMap,...s.map(e=>[e.conversationID,1])]),this._diffAndDeleteConversation()),this._setStorageConversationList();s.filter(e=>e.type===t.CONV_TOPIC).length>0||this.emitConversationUpdate()}updateConversationGroupProfile(e){if(Ne(e)&&0===e.length)return;if(0===this._conversationMap.size)return void(this._tmpGroupList=e);let t=!1;e.forEach(e=>{const s="GROUP"+e.groupID;if(this._conversationMap.has(s)){t=!0;const o=this._conversationMap.get(s);o.groupProfile=JSON.parse(JSON.stringify(e)),o.lastMessage.lastSequence{const t="C2C"+e.userID;this._conversationMap.has(t)&&(this._conversationMap.get(t).userProfile=e)}),this.emitConversationUpdate(!0,!1)}onMessageRevoked(e){if(0===e.length)return;let s=null,o=!1;const i=[];e.forEach(e=>{s=this._conversationMap.get(e.conversationID),s&&(s.type===t.CONV_TOPIC?i.push(e):(s.reduceUnreadCount()&&(o=!0),s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),o=!0)))});this.getModule(us).onMessageRevoked(i),o&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())}isLastMessageRevoked(e){let s=!1;const{conversationID:o,sequence:i,time:n}=e,r=this._conversationMap.get(o);if(r)if(r.type===t.CONV_TOPIC){s=this.getModule(us).isLastMessageRevoked({topicID:o.replace(t.CONV_GROUP,""),sequence:i})}else s=r.isLastMessageRevoked({sequence:i,time:n});return ge.l(`${this._n}.isLastMessageRevoked options:${JSON.stringify(e)} ret:${s}`),s}onMessageDeleted(e){if(0===e.length)return;let s=null;e.forEach(e=>{s=this._messageListHandler.getLocalMessage(e.conversationID,e.ID),s&&(s.isDeleted=!0),e!==s&&(e.isDeleted=!0)});const o=e[0].conversationID,i=this._messageListHandler.getLocalMessageList(o);let n={};for(let t=i.length-1;t>=0;t--)if(!i[t].isDeleted){n=i[t];break}const r=this._conversationMap.get(o);if(!r)return;let a=!1;r.lastMessage.lastSequence===n.sequence&&r.lastMessage.lastTime===n.time||(Ct(n)&&(n=void 0),r.updateLastMessage(n),r.type!==t.CONV_TOPIC&&(a=!0),ge.l(`${this._n}.onMessageDeleted. update conversationID:${o} with lastMessage:`,r.lastMessage)),o.startsWith(t.CONV_C2C)&&this.updateUnreadCount(o),a&&this.emitConversationUpdate(!0,!1)}onMessageModified(s){const{conversationType:o,from:i,to:n,time:r,sequence:a,elements:u,cloudCustomData:c,messageVersion:l}=s;let d=`${o}${n}`;n===this.getMyUserID()&&o===t.CONV_C2C&&(d=`${o}${i}`);const{isUpdated:p,message:h}=this._messageListHandler.onMessageModified(d,s);!0===p&&this.emitOuterEvent(e.MESSAGE_MODIFIED,[h]);const g=this._isTopicConversation(d);if(ge.l(`${this._n}.onMessageModified isUpdated:${p} isTopicMessage:${g} from:${i} to:${n}`),g){this.getModule(us).onMessageModified(s)}else{const e=this._conversationMap.get(d);if(e){const t=e.lastMessage;ge.d(this._n.onMessageModified+" lastMessage:",JSON.stringify(t),"options:",JSON.stringify(s)),t&&t.lastTime===r&&t.lastSequence===a&&t.version!==l&&(t.type=u[0].type,t.payload=u[0].content,t.messageForShow=ht(t.type,t.payload,this.isIntl()),t.cloudCustomData=c,t.version=l,this.emitConversationUpdate(!0,!1))}}return h}onNewGroupAtTips(e){const t=e.dataList;let s=null;t.forEach(e=>{e.groupAtTips?s=e.groupAtTips:e.elements?s={...e.elements,sync:!0}:e.groupAtType&&(s={...e,sync:!0}),s.__random=e.random,s.__sequence=e.clientSequence,this._tmpGroupAtTipsList.push(s)}),ge.d(`${this._n}.onNewGroupAtTips isReady:${this._isReady}`,this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}_handleGroupAtTipsList(){if(0===this._tmpGroupAtTipsList.length)return;let e=!1;this._tmpGroupAtTipsList.forEach(s=>{const{groupID:o,from:i,topicID:n,sync:r=!1}=s;if(i!==this.getMyUserID())if(Oe(n)){const i=this._conversationMap.get(`${t.CONV_GROUP}${o}`);i&&(i.updateGroupAtInfoList(s),e=!0)}else{const e=this._conversationMap.get(`${t.CONV_GROUP}${n}`);if(e){e.updateGroupAtInfoList(s);const t=this.getModule(us),{groupAtInfoList:o}=e;t.onConversationProxy({topicID:n,groupAtInfoList:o})}if(Ct(e)&&r){this.updateTopicConversation([{conversationID:`${t.CONV_GROUP}${n}`,type:t.CONV_TOPIC}]);this._conversationMap.get(`${t.CONV_GROUP}${n}`).updateGroupAtInfoList(s)}}}),e&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}_getC2CPeerReadTime(e){const s=[];if(e.forEach(e=>{this._conversationMap.has(e.conversationID)||e.type!==t.CONV_C2C||s.push(e.conversationID.replace(t.CONV_C2C,""))}),s.length>0){ge.d(`${this._n}._getC2CPeerReadTime userIDList:${s}`);const e=this.getModule(is);e&&e.getRemotePeerReadTime(s)}}_getStorageConversationList(){return this.getModule(ds).getItem("conversationMap")}_setStorageConversationList(){const e=this.getLocalConversationList().filter(e=>e.type===t.CONV_C2C||e.type===t.CONV_GROUP&&e.lastMessage.type!==t.MSG_GRP_TIP).slice(0,20).map(e=>({conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}));this.getModule(ds).setItem("conversationMap",e)}emitConversationUpdate(t=!0,s=!0){const o=this.getLocalConversationList();if(s){const e=this.getModule(ns);e&&e.updateGroupLastMessage(o)}t&&this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED)}getLocalConversationList(){return[...this._conversationMap.values()].filter(e=>e.type!==t.CONV_TOPIC)}getLocalConversation(e){return this._conversationMap.get(e)}hasLocalConversation(e){return this._conversationMap.has(e)}getLocalOldestMessage(e){return this._messageListHandler.getLocalOldestMessage(e)}syncConversationList(){const e=new Qi("syncConversationList");return this._pagingStatus===Et.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then(t=>{const s=function(e){if(!Ne(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}(this._pagingGetCostList);return ge.l(`${this._n}.syncConversationList. sum ${function(e){if(!Ne(e)||0===e.length)return;let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}(this._pagingGetCostList)} ms, average ${s} ms`),this._pagingGetCostList.length=0,this._pagingStatus=Et.RESOLVED,this._diffAndDeleteConversation(),this.emitConversationUpdate(!0,!1),this._setStorageConversationList(),this._handleC2CPeerReadTime(),this._patchConversationProperties(),e.setMessage(this._conversationMap.size).setMoreMessage(s).setNetworkType(this.getNetworkType()).end(),t}).catch(t=>(this._pagingStatus=Et.REJECTED,e.setMessage(this._pagingTimeStamp),this.probeNetwork().then(([s,o])=>{e.setError(t,s,o).end()}),yn(t)))}_diffAndDeleteConversation(){if(this._isSyncCompleted()){const e=[];this._conversationMap.forEach((t,s)=>{!this._pagingConvIDMap.has(s)&&this._convIDFromUnreadDBMap.has(s)&&(this._conversationMap.delete(s),e.push(s))}),ge.l(`${this._n}._diffAndDeleteConversation list:${e}`)}}_patchConversationProperties(){const e=Date.now(),t=this.checkAndPatchRemark(),s=this._messageRemindHandler.getC2CMessageRemindType(),o=this.getModule(ns).getGroupList();Promise.all([t,s,o]).then(()=>{const t=Date.now()-e;ge.l(`${this._n}._patchConversationProperties ok. cost ${t} ms`),this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate()})}_pagingGetConversationList(){const e=this._n+"._pagingGetConversationList";ge.l(`${e} timeStamp:${this._pagingTimeStamp} startIndex:${this._pagingStartIndex} pinnedTimeStamp:${this._pagingPinnedTimeStamp} pinnedStartIndex:${this._pagingPinnedStartIndex}`);const t=Date.now();return this._pagingStatus=Et.PENDING,this.request({protocolName:so,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingPinnedStartIndex,orderType:1}}).then(s=>{const{completeFlag:o,conversations:i=[],timeStamp:n,startIndex:r,pinnedTimeStamp:a,pinnedStartIndex:u,groupItem:c}=s.data,l=Date.now()-t;if(this._pagingGetCostList.push(l),ge.l(`${e} ok. completeFlag:${o} count:${i.length} cost ${l} ms`),this._convGroupHandler.onConvGroupListSynced(c),i.length>0){const e=this._getConversationOptions(i);this._pagingConvIDMap=new Map([...this._pagingConvIDMap,...e.map(e=>[e.conversationID,1])]),this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0}),this.isLoggedIn()&&this.emitConversationUpdate()}if(!this._isReady){if(!this.isLoggedIn())return Tn();this.triggerReady()}return this._pagingTimeStamp=n,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=u,1!==o?this._pagingGetConversationList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),Tn())}).catch(t=>{throw this.isLoggedIn()&&(this._isReady||(ge.w(e+" failed. error:",t),this.triggerReady())),t})}_updateLocalConversationList(e){const{isFromGetConversations:t,isInstantMessage:s}=e,o=Date.now();let i={toBeUpdatedConversationList:[],newConversationList:[]};i=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([...i.toBeUpdatedConversationList,...this._conversationMap])),t||(this._updateUserOrGroupProfile(i.newConversationList),s&&this.emitTotalUnreadMessageCountUpdate()),ge.d(`${this._n}._updateLocalConversationList cost ${Date.now()-o} ms`)}_getTmpConversationListMapping(e){const{conversationOptionsList:s,isFromGetConversations:o,isInstantMessage:i,isUnreadC2CMessage:n=!1,updateUnreadCount:r}=e,a=[],u=[],c=this.getModule(ns),l=this.getModule(rs),d=this.isIntl();for(let h=0,g=s.length;h{if(e[1].type===t.CONV_TOPIC){const{conversationID:s,unreadCount:o,groupAtInfoList:i}=e[1];p.onConversationProxy({topicID:s.replace(t.CONV_GROUP,""),unreadCount:o,groupAtInfoList:Ct(i)?void 0:i})}}),{toBeUpdatedConversationList:a,newConversationList:u}}_onLastMessageNotExist(e){new Qi("lastMessageNotExist").setMessage(""+JSON.stringify(e)).setNetworkType(this.getNetworkType()).end()}_sortConversationList(e){const t=[],s=[],o=[],i=[];return e.forEach(e=>{!0===e[1].isPinned?Ct(e[1].lastMessage.lastTime)?s.push(e):t.push(e):Ct(e[1].lastMessage.lastTime)?i.push(e):o.push(e)}),t.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime).concat(s).concat(o.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(i)}_sortConversationListAndEmitEvent(){this._conversationMap=new Map(this._sortConversationList([...this._conversationMap])),this.emitConversationUpdate(!0,!1)}_updateUserOrGroupProfile(e){if(0===e.length)return;const s=[],o=[],i=this.getModule(os),n=this.getModule(ns);e.forEach(e=>{if(e.type===t.CONV_C2C)s.push(e.toAccount);else if(e.type===t.CONV_GROUP){const t=e.toAccount;n.hasLocalGroup(t)?e.groupProfile=n.getLocalGroupProfile(t):o.push(t)}}),ge.l(`${this._n}._updateUserOrGroupProfile c2cUserIDList:${s} groupIDList:${o}`),s.length>0&&i.getUserProfile({userIDList:s}).then(({data:e})=>{Ne(e)?e.forEach(e=>{this._doUpdateUserProfile("C2C"+e.userID,e)}):this._doUpdateUserProfile("C2C"+e.userID,e)}),o.length>0&&n.getGroupProfileAdvance({groupIDList:o,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then(({data:{successGroupList:e}})=>{e.forEach(e=>{const t="GROUP"+e.groupID;if(this._conversationMap.has(t)){const s=this._conversationMap.get(t);we(s.groupProfile,e,[],[null,void 0,"",0,NaN]),!s.subType&&e.type&&(s.subType=e.type)}})})}_doUpdateUserProfile(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t)}_getConversationOptions(e){const t=[],s=e.filter(({type:e,userID:t})=>1===e&&"@TLS#NOT_FOUND"!==t&&"@TLS#ERROR"!==t||2===e),o=this.getMyUserID(),i=s.map(e=>{if(Oe(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type){const s={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return t.push(s),{conversationID:"C2C"+e.userID,type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?this._amendLayersOverLimitProperty(e.lastMsg.elements[0].content):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===o&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},userProfile:new kn(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:"",customData:e.customMark||"",markList:_t(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId)}}return{conversationID:"GROUP"+e.groupID,type:"GROUP",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow,...this._patchTypeAndPayload(e),cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||"",revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},groupProfile:new Fn({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:"",version:0,customData:e.customMark||"",markList:_t(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId)}});if(t.length>0){this.getModule(os).onConversationsProfileUpdated(t)}return i}_patchTypeAndPayload(e){const{event:s,elements:o=[],groupTips:i={}}=e.lastMsg;if(!Oe(s)&&!Ct(i)){let e=new mn(i);e.setElement({type:t.MSG_GRP_TIP,content:{...i.elements,groupProfile:i.groupProfile}});const s=JSON.parse(JSON.stringify(e.payload));return e=null,{type:t.MSG_GRP_TIP,payload:s}}return{type:o[0]?o[0].type:null,payload:o[0]?this._amendLayersOverLimitProperty(o[0].content):null}}_amendLayersOverLimitProperty(e){const{layersOverLimit:t}=e;return 0===t?e.layersOverLimit=!1:1===t&&(e.layersOverLimit=!0),e}getLocalMessageList(e){return this._messageListHandler.getLocalMessageList(e)}deleteLocalMessage(e){e instanceof mn&&this._messageListHandler.remove(e)}onConversationDeleted(e){if(!Ne(e))return;const s=e.map(e=>{const{type:s,userID:o,groupID:i}=e;return 1===s?`${t.CONV_C2C}${o}`:2===s?`${t.CONV_GROUP}${i}`:void 0});ge.l(`${this._n}.onConversationDeleted conversationIDList:${s}`),this.deleteLocalConversationList(s)}onConversationPinned(e){if(!Ne(e))return;let s=!1;e.forEach(e=>{const{type:o,userID:i,groupID:n}=e;let r;1===o?r=this.getLocalConversation(`${t.CONV_C2C}${i}`):2===o&&(r=this.getLocalConversation(`${t.CONV_GROUP}${n}`)),r&&(ge.l(`${this._n}.onConversationPinned conversationID:${r.conversationID} isPinned:${r.isPinned}`),r.isPinned||(r.isPinned=!0,s=!0))}),s&&this._sortConversationListAndEmitEvent()}onConversationUnpinned(e){if(!Ne(e))return;let s=!1;e.forEach(e=>{const{type:o,userID:i,groupID:n}=e;let r;1===o?r=this.getLocalConversation(`${t.CONV_C2C}${i}`):2===o&&(r=this.getLocalConversation(`${t.CONV_GROUP}${n}`)),r&&(ge.l(`${this._n}.onConversationUnpinned conversationID:${r.conversationID} isPinned:${r.isPinned}`),r.isPinned&&(r.isPinned=!1,s=!0))}),s&&this._sortConversationListAndEmitEvent()}getMessageList({conversationID:e,nextReqMessageID:t,count:s}){const o=this._n+".getMessageList",i=this.getLocalConversation(e);let n="";if(i&&i.groupProfile&&(n=i.groupProfile.type),je(n))return ge.l(`${o} not available in avchatroom. conversationID:${e}`),Tn({messageList:[],nextReqMessageID:"",isCompleted:!0});(Oe(s)||s>15)&&(s=15),!t&&this._isNotInCommunity(e)&&(this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e));const r=this._computeRemainingCount({conversationID:e,nextReqMessageID:t}),a=this._completedMap.has(e);if(ge.l(`${o} conversationID:${e} nextReqMessageID:${t} remainingCount:${r} count:${s} isCompleted:${a}`),this._needGetHistory({conversationID:e,remainingCount:r,count:s}))return this.getHistoryMessages({conversationID:e,nextReqMessageID:t,count:20}).then(t=>{const{nextReqID:s,storedMessageList:i}=t,n=this._completedMap.has(e);let a=i;if(r>0){a=this._messageListHandler.getLocalMessageList(e).slice(0,i.length+r)}const u={nextReqMessageID:n?"":s,messageList:a,isCompleted:n};return ge.l(`${o} ret.nextReqMessageID:${u.nextReqMessageID} ret.isCompleted:${u.isCompleted} ret.length:${a.length}`),Mn(u)});this.modifyMessageList(e);const u=this._getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s});return Tn(u)}_getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s}){const o=this._n+"._getMessageListFromMemory",i=this._messageListHandler.getLocalMessageList(e),n=i.length;let r=0;const a={isCompleted:!1,nextReqMessageID:"",messageList:[]};return t?(r=i.findIndex(e=>e.ID===t),r>s?(a.messageList=i.slice(r-s,r),a.nextReqMessageID=i[r-s].ID):(a.messageList=i.slice(0,r),a.isCompleted=!0)):n>s?(r=n-s,a.messageList=i.slice(r,n),a.nextReqMessageID=i[r].ID):(a.messageList=i.slice(0,n),a.isCompleted=!0),ge.l(`${o} conversationID:${e} ret.nextReqMessageID:${a.nextReqMessageID} ret.isCompleted:${a.isCompleted} ret.length:${a.messageList.length}`),a}getMessageListHopping(e){let{conversationID:s,sequence:o,time:i,count:n,direction:r=0}=e;if((Oe(n)||n>15)&&(n=15),s.startsWith(t.CONV_C2C)){const e=this.getModule(is),o=s.replace(t.CONV_C2C,"");return e.getRoamingMessagesHopping({peerAccount:o,time:i,count:n,direction:r})}if(s.startsWith(t.CONV_GROUP)){const e=this.getModule(ns),i=s.replace(t.CONV_GROUP,"");return e.getRoamingMessagesHopping({groupID:i,sequence:o,count:n,direction:r})}}_computeRemainingCount({conversationID:e,nextReqMessageID:t}){const s=this._messageListHandler.getLocalMessageList(e),o=s.length;if(!t)return o;let i=0;return Xe(e)?i=s.findIndex(e=>e.ID===t):Ze(e)&&(i=-1!==t.indexOf("-")?s.findIndex(e=>e.ID===t):s.findIndex(e=>e.sequence===t)),-1===i&&(i=0),i}_getMessageListSize(e){return this._messageListHandler.getLocalMessageList(e).length}_needGetHistory({conversationID:e,remainingCount:t,count:s}){const o=this.getLocalConversation(e);let i="";return o&&o.groupProfile&&(i=o.groupProfile.type),!Qe(e)&&!je(i)&&(!(Ze(e)&&this._isPagingGetGroupListCompleted()&&this._getLocalGroupCount()<=4e3&&!this._hasLocalGroup(e)&&!this._isTopicConversation(e))&&(t<=s&&!this._completedMap.has(e)))}_isTopicConversation(e){const s=e.replace(t.CONV_GROUP,"");return Je(s)}getHistoryMessages(e){const{conversationID:s,count:o}=e;if(s===t.CONV_SYSTEM)return Tn();let i=15;o>20&&(i=20);let n=null;if(Xe(s)){const e=this._roamingMessageKeyAndTimeMap.has(s);return n=this.getModule(is),n?n.getRoamingMessage({conversationID:s,peerAccount:s.replace(t.CONV_C2C,""),count:i,lastMessageTime:e?this._roamingMessageKeyAndTimeMap.get(s).lastMessageTime:0,messageKey:e?this._roamingMessageKeyAndTimeMap.get(s).messageKey:""}):yn({code:$i.CANNOT_FIND_MODULE})}if(Ze(s)){if(n=this.getModule(ns),!n)return yn({code:$i.CANNOT_FIND_MODULE});let e=null;this._conversationMap.has(s)&&(e=this._conversationMap.get(s).lastMessage);let o=0;e&&(o=e.lastSequence);const r=this._roamingMessageSequenceMap.get(s);return n.getRoamingMessage({conversationID:s,groupID:s.replace(t.CONV_GROUP,""),count:i,sequence:r||o})}return Tn()}patchConversationLastMessage(e){const t=this.getLocalConversation(e);if(!t)return;const{messageForShow:s,payload:o}=t.lastMessage;if(Ct(s)||Ct(o)){const s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;const o=s[s.length-1];ge.l(`${this._n}.patchConversationLastMessage conversationID:${e} payload:`,o.payload),t.updateLastMessage(o)}}onRoamingMessage(e=[],s,o=!0){const i=s.startsWith(t.CONV_C2C)?t.CONV_C2C:t.CONV_GROUP;let n=null,r=[],a=[],u=0,c=e.length,l=null;const d=i===t.CONV_GROUP,p=this.getModule(gs),h=this.getFileDownloadProxy();let g=()=>{u=d?e.length-1:0,c=d?0:e.length},_=()=>{d?--u:++u},m=()=>d?u>=c:u{this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e)})}deleteGroupRomaingMessageInfo(e){const s=`${t.CONV_GROUP}${e}`;this._messageListHandler.removeByConversationID(s),this._completedMap.delete(s),this._roamingMessageSequenceMap.delete(s)}setMessageRead({conversationID:e}){const s=this.getLocalConversation(e);if(ge.l(`${this._n}.setMessageRead conversationID:${e} unreadCount:${s?s.unreadCount:0}`),!s)return Tn();if(s.type!==t.CONV_GROUP&&s.type!==t.CONV_TOPIC||Ct(s.groupAtInfoList)||this.deleteGroupAtTips(e),0===s.unreadCount)return Tn();if(s.type===t.CONV_GROUP&&!this._hasLocalGroup(e))return 0!==s.unreadCount&&(s.unreadCount=0,this.emitConversationUpdate(!0,!1)),Tn();const o=this._messageListHandler.getLocalLastMessage(e);let i=s.lastMessage.lastTime;o&&i{const{data:s}=t,o=this._handleAllMessageRead(s);return i.setMessage(`scope:${e.scope} failureGroups:${JSON.stringify(o)}`).setNetworkType(this.getNetworkType()).end(),Tn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.w(s+" failed. error:",e),yn({code:e&&e.code?e.code:$i.MESSAGE_UNREAD_ALL_FAIL,message:e&&e.message?e.message:void 0})))}setConversationCustomData(e){return this._convGroupHandler.setConvCustomData(e)}markConversation(e){return this._convGroupHandler.markConversation(e)}getConversationGroupList(){return this._convGroupHandler.getLocalConvGroupList()}createConversationGroup(e){return this._convGroupHandler.createConvGroup(e)}deleteConversationGroup(e){return this._convGroupHandler.deleteConvGroup(e)}renameConversationGroup(e){return this._convGroupHandler.renameConvGroup(e)}addConversationsToGroup(e){return this._convGroupHandler.addConvsToGroup(e)}deleteConversationsFromGroup(e){return this._convGroupHandler.deleteConvsFromGroup(e)}onConversationMarkUpdated(e){this._convGroupHandler.onConvMarkUpdated(e)}onConversationGroupCreated(e){this._convGroupHandler.onConvGroupCreated(e)}onConversationGroupDeleted(e){this._convGroupHandler.onConvGroupDeleted(e)}onConversationGroupNameUpdated(e){this._convGroupHandler.onConvGroupNameUpdated(e)}onConversationInGroupUpdated(e){this._convGroupHandler.onConvInGroupUpdated(e)}onConversationAddedToOrDeletedFromGroup(e){this._convGroupHandler.onConvAddedToOrDeletedFromGroup(e)}_getConversationLastMessageSequence(e){const t=this._messageListHandler.getLocalLastMessage(e.conversationID);let s=e.lastMessage.lastSequence;return t&&s0)if(i.type===t.CONV_C2C&&0===s.readAllC2CMessage){if(o===t.READ_ALL_MSG)s.readAllC2CMessage=1;else if(o===t.READ_ALL_C2C_MSG){s.readAllC2CMessage=1;break}}else if(i.type===t.CONV_GROUP&&(o===t.READ_ALL_GROUP_MSG||o===t.READ_ALL_MSG)){const e=this._getConversationLastMessageSequence(i);s.groupMessageReadInfoList.push({groupID:i.groupProfile.groupID,messageSequence:e})}return s}onPushedAllMessageRead(e){this._handleAllMessageRead(e)}_handleAllMessageRead(e){const{groupMessageReadInfoList:t,readAllC2CMessage:s}=e,o=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:s})>=1&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate()),o}_parseGroupReadInfo(e){const t=[];if(e&&e.length)for(let s=0,o=e.length;s=1){if(1===s&&n.type===t.CONV_C2C){const e=this._getConversationLastMessageTime(n);this.updateIsReadAfterReadReport({conversationID:i,lastMessageTime:e})}else if(n.type===t.CONV_GROUP){const e=i.replace(t.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(e)){const t=this._remoteGroupReadSequenceMap.get(e),s=this._getConversationLastMessageSequence(n);this.updateIsReadAfterReadReport({conversationID:i,remoteReadSequence:t}),s>=t&&this._remoteGroupReadSequenceMap.delete(e)}}this.updateUnreadCount(i,!1)&&(o+=1)}return o}isRemoteRead(e){const{conversationID:s,sequence:o}=e,i=s.replace(t.CONV_GROUP,"");let n=!1;if(this._remoteGroupReadSequenceMap.has(i)){const e=this._remoteGroupReadSequenceMap.get(i);o<=e&&(n=!0,ge.l(`${this._n}.isRemoteRead conversationID:${s} messageSequence:${o} remoteReadSequence:${e}`)),o>=e+10&&this._remoteGroupReadSequenceMap.delete(i)}return n}updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:t,lastMessageTime:s}){const o=this._messageListHandler.getLocalMessageList(e);if(0===o.length)return;let i;for(let n=o.length-1;n>=0;n--)if(i=o[n],!(s&&i.time>s||t&&i.sequence>t)){if("in"===i.flow&&i.isRead)break;i.setIsRead(!0)}}updateUnreadCount(e,s=!0){let o=!1;const i=this.getLocalConversation(e),n=this._messageListHandler.getLocalMessageList(e);if(!i)return;const r=i.unreadCount,a=n.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;if(r!==a&&(i.unreadCount=a,o=!0,ge.l(`${this._n}.updateUnreadCount from ${r} to ${a}, conversationID:${e}`),!0===s&&(this.emitConversationUpdate(!0,!1),this.emitTotalUnreadMessageCountUpdate())),o&&i.type===t.CONV_TOPIC){const{unreadCount:s}=i,o=this.getModule(us),n=e.replace(t.CONV_GROUP,"");o.onConversationProxy({topicID:n,unreadCount:s})}return o}clearGroupAtInfoList(e,s=!0){const o=this.getLocalConversation(e);if(o&&o.groupAtInfoList.length>0){if(o.clearGroupAtInfoList(),ge.l(`${this._n}.clearGroupAtInfoList conversationID:${e}`),o.type===t.CONV_TOPIC){const{groupAtInfoList:s}=o,i=this.getModule(us),n=e.replace(t.CONV_GROUP,"");i.onConversationProxy({topicID:n,groupAtInfoList:s})}!0===s&&this.emitConversationUpdate(!0,!1)}}updateReadReceiptInfo(s){const{userID:o,groupID:i,readReceiptList:n}=s;if(Ct(n))return;const r=[];if(Oe(o)){if(!Oe(i)){const e=`${t.CONV_GROUP}${i}`;n.forEach(t=>{const{tinyID:s,clientTime:o,random:n,readCount:a,unreadCount:u}=t,c=`${s}-${o}-${n}`,l=this._messageListHandler.getLocalMessage(e,c),d={groupID:i,messageID:c,readCount:0,unreadCount:0};l&&(ve(a)&&(l.readReceiptInfo.readCount=a,d.readCount=a),ve(u)&&(l.readReceiptInfo.unreadCount=u,d.unreadCount=u),r.push(d))})}}else{const e=`${t.CONV_C2C}${o}`;n.forEach(t=>{const{tinyID:s,clientTime:i,random:n}=t,a=`${s}-${i}-${n}`,u=this._messageListHandler.getLocalMessage(e,a);if(u){u.readReceiptInfo.isPeerRead=!0;const e={userID:o,messageID:a,isPeerRead:!0};r.push(e)}})}r.length>0&&this.emitOuterEvent(e.MESSAGE_READ_RECEIPT_RECEIVED,r)}recomputeGroupUnreadCount(e){const{conversationID:t,count:s}=e,o=this.getLocalConversation(t);if(o){const e=o.unreadCount;let i=e-s;i<0&&(i=0),o.unreadCount=i,ge.l(`${this._n}.recomputeGroupUnreadCount from ${e} to ${i}, conversationID:${t}`)}}updateIsRead(e){const s=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(!s||0===o.length||Qe(s.type))return;const i=[];for(let t=0,r=o.length;te.isRevoked).length;n=i.length-s.unreadCount-e}else n=i.length-s.unreadCount;for(let t=0;t!e.atTypeArray.includes(t.CONV_AT_ALL)),0===r.length))return this.clearGroupAtInfoList(e,!1),Promise.resolve();const a=this.getMyUserID();return this.request({protocolName:ao,requestData:{messageListToDelete:r.map(e=>({from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:Oe(e.topicID)?e.groupID:e.topicID}))}}).then(()=>(ge.l(`${s} ok. count:${i.length}`),this.clearGroupAtInfoList(e,!1),Promise.resolve())).catch(e=>(ge.e(s+" failed. error:",e),yn(e)))}appendToMessageList(e){this._messageListHandler.pushIn(e)}setMessageRandom(e){this.singlyLinkedList.set(e.random)}deleteMessageRandom(e){this.singlyLinkedList.delete(e.random)}pushIntoMessageList(e,t,s){return!(!this._messageListHandler.pushIn(t,s)||this._isMessageFromCurrentInstance(t)&&!s)&&(e.push(t),!0)}_isMessageFromCurrentInstance(e){return this.singlyLinkedList.has(e.random)}revoke(e,t,s){return this._messageListHandler.revoke(e,t,s)}getPeerReadTime(e){return this._peerReadTimeMap.get(e)}recordPeerReadTime(e,t){if(this._peerReadTimeMap.has(e)){this._peerReadTimeMap.get(e)0){const t=this._messageListHandler.updateMessageIsPeerReadProperty(s,o);if(t.length>0&&this.emitOuterEvent(e.MESSAGE_READ_BY_PEER,t),this._conversationMap.has(s)){const e=this._conversationMap.get(s).lastMessage;Ct(e)||e.fromAccount===this.getMyUserID()&&e.lastTime<=o&&!e.isPeerRead&&(e.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}updateMessageIsModifiedProperty(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}setCompleted(e){ge.l(`${this._n}.setCompleted. conversationID:${e}`),this._completedMap.set(e,!0)}updateRoamingMessageKeyAndTime(e,t,s){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:s})}updateRoamingMessageSequence(e,t){this._roamingMessageSequenceMap.set(e,t)}getConversationList(e){const t="getConversationList",s=`${this._n}.${t}`,o=`pagingStatus:${this._pagingStatus}, local conversation count:${this._conversationMap.size}, options:${e}`;if(ge.l(`${s}. ${o}`),this._pagingStatus===Et.REJECTED){const i=new Qi(t);return i.setMessage(o),this.syncConversationList().then(()=>{i.setNetworkType(this.getNetworkType()).end();const t=this._getConversationList(e);return Mn({conversationList:t,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}if(0===this._conversationMap.size){const i=new Qi(t);return i.setMessage(o),this.syncConversationList().then(()=>{i.setNetworkType(this.getNetworkType()).end();const t=this._getConversationList(e);return Mn({conversationList:t,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}const i=this._getConversationList(e);return ge.l(`${s}. returned conversation count:${i.length}`),Tn({conversationList:i,isSyncCompleted:this._isSyncCompleted()})}_getConversationList(e){if(Oe(e))return this.getLocalConversationList();if(Ne(e)){if(0===e.length)return[];return this.getLocalConversationList().filter(t=>e.includes(t.conversationID))}if(Re(e)){const{type:s,markType:o,groupName:i}=e;return this.getLocalConversationList().filter(e=>(s!==t.CONV_C2C&&s!==t.CONV_GROUP||e.type===s)&&(!Le(i)||e.conversationGroupList.includes(i))&&(!ve(o)||e.markList.includes(o)))}return[]}_handleC2CPeerReadTime(){for(const[e,s]of this._conversationMap)s.type===t.CONV_C2C&&(ge.d(`${this._n}._handleC2CPeerReadTime conversationID:${e} peerReadTime:${s.peerReadTime}`),this.recordPeerReadTime(e,s.peerReadTime))}_isPagingGetGroupListCompleted(){return this.getModule(ns).isPagingGetCompleted()}_getLocalGroupCount(){return this.getModule(ns).getLocalGroupList().length}_hasLocalGroup(e){return this.getModule(ns).hasLocalGroup(e.replace(t.CONV_GROUP,""))}getConversationProfile(e){let s;if(s=this._conversationMap.has(e)?this._conversationMap.get(e):new xn({conversationID:e,type:e.slice(0,3)===t.CONV_C2C?t.CONV_C2C:t.CONV_GROUP},this.isIntl()),s._isInfoCompleted||s.type===t.CONV_SYSTEM)return Tn({conversation:s});if(Ze(e)&&!this._hasLocalGroup(e))return Tn({conversation:s});const o=this._n+".getConversationProfile",i=new Qi("getConversationProfile");return ge.l(`${o}. conversationID:${e} remark:${s.remark} lastMessage:`,s.lastMessage),this._updateUserOrGroupProfileCompletely(s).then(n=>{i.setNetworkType(this.getNetworkType()).setMessage(`conversationID:${e} unreadCount:${n.data.conversation.unreadCount}`).end();const r=this.getModule(rs);if(r&&s.type===t.CONV_C2C){const i=e.replace(t.CONV_C2C,"");if(r.isMyFriend(i)){const t=r.getFriendRemark(i);s.remark!==t&&(s.remark=t,ge.l(`${o}. conversationID:${e} patch remark:${s.remark}`))}}return ge.l(`${o} ok. conversationID:${e}`),n}).catch(t=>(this.probeNetwork().then(([s,o])=>{i.setError(t,s,o).setMessage("conversationID:"+e).end()}),ge.e(o+" failed. error:",t),yn(t)))}_updateUserOrGroupProfileCompletely(e){if(e.type===t.CONV_C2C){return this.getModule(os).getUserProfile({userIDList:[e.toAccount]}).then(t=>{const s=t.data;return 0===s.length?yn(new fn({code:$i.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=s[0],e._isInfoCompleted=!0,this._unshiftConversation(e),Tn({conversation:e}))})}return this.getModule(ns).getGroupProfile({groupID:e.toAccount}).then(t=>(e.groupProfile=t.data.group,e._isInfoCompleted=!0,this._unshiftConversation(e),Tn({conversation:e})))}_unshiftConversation(e){e instanceof xn&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e],...this._conversationMap]),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}_onProfileUpdated(e){e.data.forEach(e=>{const{userID:s}=e;if(s===this.getMyUserID())this._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{const o=this._conversationMap.get(`${t.CONV_C2C}${s}`);o&&(o.userProfile=e)}})}_isSyncCompleted(){return this._pagingStatus===Et.RESOLVED}_errorLog(e,t,s,o){const i=new Error("Params validate failed."),n=`${this.getErrorMessage("API_REFER")}${e}`;throw ge.w(`[${e}] | ${t} | ${this.getErrorMessage(s,o)}, ${n}`),ge.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),i}_isValidConversationID(e){return Xe(e)||Ze(e)||Qe(e)}deleteConversation(e){const t="deleteConversation";return Le(e)||Ae(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),Le(e)?(this._isValidConversationID(e)||this._errorLog(t,"options","InvalidConversationID",e),ge.l(`${this._n}.${t} conversationID:${e}`),this.deleteConversationList({conversationIDList:[e],flag:1})):(Ne(e.conversationIDList)||this._errorLog(t,"conversationIDList","ArrayRequiredLog"),0===e.conversationIDList.length&&this._errorLog(t,"conversationIDList","NonEmptyArrayLog"),e.conversationIDList.forEach(e=>{this._isValidConversationID(e)||this._errorLog(t,"conversationIDList","InvalidConversationID",e)}),"clearHistoryMessage"in e&&"boolean"!=typeof e.clearHistoryMessage&&this._errorLog(t,"clearHistoryMessage","BooleanRequiredLog"),e.conversationIDList.length>100&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConversationList(e))}deleteConversationList(e){const{conversationIDList:t=[],clearHistoryMessage:s=!0,flag:o=0}=e,i=this._n+".deleteConversationList";ge.l(`${i} conversationIDList.length:${t.length} clearHistoryMessage:${s}`);const n=new Qi("deleteConversationList");return n.setMessage("conversationIDList:"+t),Promise.all([this.rmLocalOnlyConversationList(t),this.rmLocalAndRemoteConversationList(t,s)]).then(e=>{n.setNetworkType(this.getNetworkType()).end();const t=[...e[0],...e[1]];return 0===t.length?yn(new fn({code:$i.CONVERSATION_NOT_FOUND})):(ge.l(i+" ok"),Tn(1===o?{conversationID:t[0]}:{conversationIDList:t}))}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(i+" failed. error:",e),yn(e)))}rmLocalOnlyConversationList(e){return e.filter(e=>{if(!this._conversationMap.has(e))return!1;const s=this.getLocalConversation(e).type;if(s===t.CONV_GROUP&&!this._hasLocalGroup(e))return this.deleteLocalConversation(e),!0;if(s===t.CONV_SYSTEM){return this.getModule(ns).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),!0}return!1})}rmLocalAndRemoteConversationList(e,s){const o={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:s?1:0};return e.forEach(e=>{if(this._conversationMap.has(e)){const s=this.getLocalConversation(e).type;s===t.CONV_C2C?o.conversationList.push({toAccount:e.replace(s,""),type:1}):s===t.CONV_GROUP&&this._hasLocalGroup(e)&&o.conversationList.push({toGroupID:e.replace(s,""),type:2})}}),0===o.conversationList.length?[]:this.request({protocolName:io,requestData:o}).then(e=>{const s=[];return e.data.resultList.length>0&&e.data.resultList.map(e=>{if(0===e.code){const o=1===e.type?`${t.CONV_C2C}${e.to}`:`${t.CONV_GROUP}${e.groupID}`;s.push(o)}}),this.deleteLocalConversationList(s),s})}clearHistoryMessage(e){const s={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(e))return yn({code:$i.CONVERSATION_NOT_FOUND});const o=this._conversationMap.get(e).type;if(o===t.CONV_C2C)s.type=1,s.toAccount=e.replace(t.CONV_C2C,"");else{if(o!==t.CONV_GROUP){if(o===t.CONV_SYSTEM){return this.getModule(ns).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),Tn({conversationID:e})}return yn({code:$i.CONVERSATION_UN_RECORDED_TYPE})}s.type=2,s.toGroupID=e.replace(t.CONV_GROUP,"")}const i=this._n+".clearHistoryMessage",n=new Qi("clearHistoryMessage");return n.setMessage("conversationID:"+e),ge.l(`${i}. conversationID:${e}`),this.setMessageRead({conversationID:e}).then(()=>this.request({protocolName:no,requestData:s})).then(()=>{n.setNetworkType(this.getNetworkType()).end(),ge.l(i+" ok"),this._messageListHandler.removeByConversationID(e),this.setCompleted(e);const t=this.getLocalConversation(e);return t&&(t.updateLastMessage(),this._sortConversationListAndEmitEvent()),Tn({conversationID:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(i+" failed. error:",e),yn(e)))}pinConversation(e){const{conversationID:s,isPinned:o}=e;if(!this._conversationMap.has(s))return yn({code:$i.CONVERSATION_NOT_FOUND});const i=this.getLocalConversation(s);if(i.isPinned===o)return Tn({conversationID:s});const n=this._n+".pinConversation",r=new Qi("pinConversation");r.setMessage(`conversationID:${s} isPinned:${o}`),ge.l(`${n}. conversationID:${s} isPinned:${o}`);let a=null;return Xe(s)?a={type:1,toAccount:s.replace(t.CONV_C2C,"")}:Ze(s)&&(a={type:2,groupID:s.replace(t.CONV_GROUP,"")}),this.request({protocolName:ro,requestData:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[a]}}).then(()=>(r.setNetworkType(this.getNetworkType()).end(),ge.l(n+" ok"),i.isPinned!==o&&(i.isPinned=o,this._sortConversationListAndEmitEvent()),Mn({conversationID:s}))).catch(e=>(this.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),ge.e(n+" failed. error:",e),yn(e)))}setMessageRemindType(e){return this._messageRemindHandler.set(e)}patchMessageRemindType(e){const{ID:s,isC2CConversation:o,messageRemindType:i}=e;let n=!1;const r=this.getLocalConversation(o?`${t.CONV_C2C}${s}`:`${t.CONV_GROUP}${s}`);return r&&r.messageRemindType!==i&&(r.messageRemindType=i,n=!0),ge.d(this._n+".patchMessageRemindType options:",e,"ret:"+n),n}onC2CMessageRemindTypeSynced(e){const s=this._n+".onC2CMessageRemindTypeSynced";ge.d(s,e),e.dataList.forEach(e=>{if(!Ct(e.muteNotificationsSync)){const{to:o,updateSequence:i,muteFlag:n}=e.muteNotificationsSync;let r;this._messageRemindHandler.setUpdateSequence(i),0===n?r=t.MSG_REMIND_ACPT_AND_NOTE:1===n?r=t.MSG_REMIND_DISCARD:2===n&&(r=t.MSG_REMIND_ACPT_NOT_NOTE);let a=0;this.patchMessageRemindType({ID:o,isC2CConversation:!0,messageRemindType:r})&&(a+=1),ge.l(`${s} updateCount:${a}`),a>=1&&this.emitConversationUpdate(!0,!1)}})}onGroupMessageRemindTypeSynced(e){ge.d(this._n+".onGroupMessageRemindTypeSynced options:",e),this._messageRemindHandler.onGroupMessageRemindTypeUpdated(e)}deleteLocalConversation(e,t=!0){const s=this._conversationMap.has(e);if(ge.d(`${this._n}.deleteLocalConversation conversationID:${e} has:${s}`),s&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.has(e)&&this._roamingMessageKeyAndTimeMap.delete(e),this._roamingMessageSequenceMap.has(e)&&this._roamingMessageSequenceMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),t)){const t=!this._isTopicConversation(e);this.emitConversationUpdate(t,!1)}}deleteLocalConversationList(e){let t=0,s=!1;e.forEach(e=>{this._conversationMap.has(e)&&(t+=this._conversationMap.get(e).unreadCount||0,this.deleteLocalConversation(e,!1),s=!0)}),ge.l(`${this._n}.deleteLocalConversationList conversationIDList.length:${e.length} isConvIDExisted:${s}`),s&&(this.emitConversationUpdate(!0,!1),t>0&&this.emitTotalUnreadMessageCountUpdate())}isMessageSentByCurrentInstance(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}modifyMessageList(e){if(!e.startsWith(t.CONV_C2C))return;if(!this._conversationMap.has(e))return;const s=this._conversationMap.get(e),o=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:s.userProfile.nick,latestAvatar:s.userProfile.avatar});const i=this.getModule(os).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:i.nick,latestAvatar:i.avatar}),ge.l(`${this._n}.modifyMessageList conversationID:${e} cost ${Date.now()-o} ms`)}updateUserProfileSpecifiedKey(e){ge.l(this._n+".updateUserProfileSpecifiedKey options:",e);const{conversationID:t,nick:s,avatar:o}=e;if(this._conversationMap.has(t)){const e=this._conversationMap.get(t).userProfile;Le(s)&&e.nick!==s&&(e.nick=s),Le(o)&&e.avatar!==o&&(e.avatar=o),this.emitConversationUpdate(!0,!1)}}_onMyProfileModified(e){const t=this.getLocalConversationList(),s=Date.now();t.forEach(t=>{this.modifyMessageSentByMe({conversationID:t.conversationID,...e})}),ge.l(`${this._n}._onMyProfileModified. modify all messages sent by me, cost ${Date.now()-s} ms`)}modifyMessageSentByMe(e){this._messageListHandler.modifyMessageSentByMe(e)}getLatestMessageSentByMe(e){return this._messageListHandler.getLatestMessageSentByMe(e)}modifyMessageSentByPeer(e){this._messageListHandler.modifyMessageSentByPeer(e)}getLatestMessageSentByPeer(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}pushIntoNoticeResult(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}getLocalLastMessage(e){return this._messageListHandler.getLocalLastMessage(e)}checkAndPatchRemark(){const e=Promise.resolve();if(0===this._conversationMap.size)return e;const s=this.getModule(rs);if(!s)return e;const o=[...this._conversationMap.values()].filter(e=>e.type===t.CONV_C2C);if(0===o.length)return e;let i=0;return o.forEach(e=>{const o=e.conversationID.replace(t.CONV_C2C,"");if(s.isMyFriend(o)){const t=s.getFriendRemark(o);e.remark!==t&&(e.remark=t,i+=1)}}),ge.l(`${this._n}.checkAndPatchRemark. c2c conversation count:${o.length}, patched count:${i}`),e}updateTopicConversation(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0})}sendReadReceipt(e){const s=e[0];let o=null;return s.conversationType===t.CONV_C2C?o=this._m.getModule(is):s.conversationType===t.CONV_GROUP&&(o=this._m.getModule(ns)),o?o.sendReadReceipt(e):yn({code:$i.CANNOT_FIND_MODULE})}getReadReceiptList(e){const s=e[0];let o=null;return s.conversationType===t.CONV_C2C?o=this._m.getModule(is):s.conversationType===t.CONV_GROUP&&(o=this._m.getModule(ns)),o?o.getReadReceiptList(e):yn({code:$i.CANNOT_FIND_MODULE})}getLastMessageTime(e){const t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}getTotalUnreadMessageCount(){const e=this.getLocalConversationList();let s=0;return e.forEach(e=>{e.type!==t.CONV_SYSTEM&&(""!==e.messageRemindType&&e.messageRemindType!==t.MSG_REMIND_ACPT_AND_NOTE||(s+=e.unreadCount))}),s}emitTotalUnreadMessageCountUpdate(){const t=this.getTotalUnreadMessageCount();this._convTotalUnreadCount!==t&&(ge.l(`${this._n}.emitTotalUnreadMessageCountUpdate from ${this._convTotalUnreadCount} to ${t}`),this._convTotalUnreadCount=t,this.emitOuterEvent(e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}reset(){ge.l(this._n+".reset"),this._pagingStatus=Et.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.clear(),this._roamingMessageSequenceMap.clear(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._conversationMap.clear(),this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._remoteGroupReadSequenceMap.clear(),this._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this.resetReady()}}class Kn{constructor(e){this._groupModule=e,this._n="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map}onCheckTimer(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}_checkCachedGroupTips(){this._cachedGroupTipsMap.forEach((e,t)=>{let s=this._checkCountMap.get(t);const o=this._groupModule.hasLocalGroup(t);ge.l(`${this._n}._checkCachedGroupTips groupID:${t} hasLocalGroup:${o} checkCount:${s}`),o?(this._notifyCachedGroupTips(t),this._checkCountMap.delete(t),this._groupModule.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupTips(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}onNewGroupTips(t){ge.d(`${this._n}.onReceiveGroupTips count:${t.dataList.length}`);const{eventDataList:s,result:o,AVChatRoomMessageList:i}=this.newGroupTipsStoredAndSummary(t);if(i.length>0&&this._groupModule.onAVChatRoomMessage(i),s.length>0){this._groupModule.updateNextMessageSeq(s);this._groupModule.getModule(cs).onNewMessage({conversationOptionsList:s,isInstantMessage:!0})}o.length>0&&(this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,o),this.handleMessageList(o))}newGroupTipsStoredAndSummary(e){const{event:s,dataList:o}=e;let i=null;const n=[],r=[],a={},u=[];for(let c=0,l=o.length;c{this._getTopicPendingMap.delete(p)}))}const m=this._groupModule.hasLocalGroup(l);if(!m&&this._groupModule.isUnjoinedAVChatRoom(l))continue;if(!m&&!_){this._cacheGroupTipsAndProbe({groupID:l,event:s,item:e});continue}if(this._groupModule.isMessageFromOrToAVChatroom(l)){e.event=s,u.push(e);continue}if(e.currentUser=this._groupModule.getMyUserID(),e.conversationType=t.CONV_GROUP,i=new mn(e),i.setElement({type:t.MSG_GRP_TIP,content:{...e.elements,groupProfile:e.groupProfile}}),i.isSystemMessage=!1,1===h){this._qualityStat(i);continue}const M=this._groupModule.getModule(cs),{conversationID:f,sequence:I}=i;if(6===s)i._onlineOnlyFlag=!0,r.push(i);else{if(!M.pushIntoNoticeResult(r,i))continue}if(this._groupModule.isMessageFromCommunityOfTopic(d,p))continue;if(6===s&&M.getLocalConversation(f))continue;6!==s&&this._qualityStat(i);const C=M.isRemoteRead({conversationID:f,sequence:I});if(Oe(a[f])){let e=0;"in"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||C||(e=1)),a[f]=n.push({conversationID:f,unreadCount:e,type:Oe(g)?i.conversationType:g,subType:i.conversationSubType,lastMessage:i._isExcludedFromLastMessage?"":i})-1}else{const e=a[f];n[e].type=i.conversationType,n[e].subType=i.conversationSubType,n[e].lastMessage=i._isExcludedFromLastMessage?"":i,"in"===i.flow&&(i._isExcludedFromUnreadCount||i._onlineOnlyFlag||C||n[e].unreadCount++)}}return{eventDataList:n,result:r,AVChatRoomMessageList:u}}_qualityStat(e){this._groupModule.getModule(Es).addMessageSequence({key:Wi,message:e})}handleMessageList(e){e.forEach(e=>{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:ge.w(`${this._n}.handleMessageList unknown operationType:${e.payload.operationType}`)}})}_onNewMemberComeIn(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&ve(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o))}_onMemberQuit(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&ve(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o));this._groupModule.getModule(as).deleteLocalGroupMembers(s,e.payload.userIDList)}_onMemberKickedOut(e){const{memberNum:t,groupProfile:{groupID:s}}=e.payload,o=this._groupModule.getLocalGroupProfile(s);o&&ve(t)&&o.memberCount!==t&&(o.memberCount=t,this._updateConversationGroupProfile(o));this._groupModule.getModule(as).deleteLocalGroupMembers(s,e.payload.userIDList)}_updateConversationGroupProfile(e){this._groupModule.getModule(cs).updateConversationGroupProfile([e])}_onMemberSetAdmin(e){const s=e.payload.groupProfile.groupID,o=e.payload.userIDList,i=this._groupModule.getModule(as);o.forEach(e=>{const o=i.getLocalGroupMemberInfo(s,e);o&&o.updateRole(t.GRP_MBR_ROLE_ADMIN)})}_onMemberCancelledAdmin(e){const s=e.payload.groupProfile.groupID,o=e.payload.userIDList,i=this._groupModule.getModule(as);o.forEach(e=>{const o=i.getLocalGroupMemberInfo(s,e);o&&o.updateRole(t.GRP_MBR_ROLE_MEMBER)})}_onGroupProfileModified(e){const{newGroupProfile:t,groupProfile:s}=e.payload,{groupID:o}=s,i=this._groupModule.getLocalGroupProfile(o);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]}});const n=!i.isSupportTopic;this._groupModule.emitGroupListUpdate(!0,n)}_ownerChanged({groupID:e},s){const o=this._groupModule.getLocalGroupProfile(e),i=this._groupModule.getMyUserID();if(i===s.ownerID){o.updateGroup({selfInfo:{role:t.GRP_MBR_ROLE_OWNER}});const s=this._groupModule.getModule(as),n=s.getLocalGroupMemberInfo(e,i),r=this._groupModule.getLocalGroupProfile(e).ownerID,a=s.getLocalGroupMemberInfo(e,r);n&&n.updateRole(t.GRP_MBR_ROLE_OWNER),a&&a.updateRole(t.GRP_MBR_ROLE_MEMBER)}}_onMemberInfoModified(e){const{to:t,payload:{groupProfile:s,memberList:o}}=e,i=s.groupID;Je(t)&&this._updateTopicMuteTime(e);const n=this._groupModule.getModule(as);o.forEach(e=>{const t=n.getLocalGroupMemberInfo(i,e.userID);t&&ve(e.muteTime)&&t.updateMuteUntil(e.muteTime)})}_updateTopicMuteTime(t){const{to:s,payload:{groupProfile:o,memberList:i=[]}}=t,n=this._groupModule.getModule(us),{groupID:r}=o,a=n.getLocalTopic(r,s);if(a){let t=!1;for(let e=0;e=0){a.updateSelfInfo({muteTime:s.muteTime}),t=!0;break}}t&&this._groupModule.emitOuterEvent(e.TOPIC_UPDATED,{groupID:r,topic:a})}}_onTopicProfileUpdated(e){const{groupProfile:{groupID:t},newTopicInfo:s}=e.payload;this._groupModule.getModule(us).onTopicProfileUpdated({groupID:t,topicID:e.to,...s})}_cacheGroupTips(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}_deleteCachedGroupTips(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}_notifyCachedGroupTips(e){const t=this._cachedGroupTipsMap.get(e)||[];t.forEach(e=>{this.onNewGroupTips(e)}),this._deleteCachedGroupTips(e),ge.l(`${this._n}._notifyCachedGroupTips groupID:${e} count:${t.length}`)}_cacheGroupTipsAndProbe(e){const{groupID:s,event:o,item:i}=e;this._cacheGroupTips(s,{event:o,dataList:[i]}),this._groupModule.getGroupSimplifiedInfo(s).then(e=>{const{type:o}=e;o===t.GRP_AVCHATROOM?this._groupModule.hasLocalGroup(s)?this._notifyCachedGroupTips(s):this._groupModule.setUnjoinedAVChatRoom(s):(this._groupModule.updateGroupMap([e]),this._notifyCachedGroupTips(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),ge.l(`${this._n}._cacheGroupTipsAndProbe groupID:${s}`)}reset(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear()}}class Wn{constructor(e){this._groupModule=e,this._n="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,this._getTopicPendingMap=new Map,this._isPagingGetCompleted=!1;e.getInnerEmitterInstance().once(Sn,this._initGroupList,this)}onCheckTimer(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}_checkCachedGroupMessage(){this._cachedGroupMessageMap.forEach((e,t)=>{let s=this._checkCountMap.get(t);const o=this._groupModule.hasLocalGroup(t);ge.l(`${this._n}._checkCachedGroupMessage groupID:${t} hasLocalGroup:${o} checkCount:${s}`),o?(this._notifyCachedGroupMessage(t),this._checkCountMap.delete(t),this._groupModule.deleteUnjoinedAVChatRoom(t)):s>=this.MAX_CHECK_COUNT?(this._deleteCachedGroupMessage(t),this._checkCountMap.delete(t)):(s++,this._checkCountMap.set(t,s))})}_initGroupList(){ge.l(this._n+"._initGroupList");const e=new Qi("getGroupListInStorage"),t=this._groupModule.getStorageGroupList();if(Ne(t)&&t.length>0){t.forEach(e=>{this._groupModule.initGroupMap(e)}),this._groupModule.emitGroupListUpdate(!0,!1);const s=this._groupModule.getLocalGroupList().length;e.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:"+s).end()}else e.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();ge.l(this._n+"._initGroupList ok")}handleUpdateGroupLastMessage(e){const s=this._n+".handleUpdateGroupLastMessage";if(ge.l(`${s} conversation count:${e.length}, local group count:${this._groupModule.getLocalGroupList().length}`),0===this._groupModule.getGroupMap().size)return void(this.tempConversationList=e);let o,i,n,r=!1;for(let a=0,u=e.length;a0&&this._groupModule.onAVChatRoomMessage(i),this._groupModule.filterModifiedMessage(o),s.length>0){this._groupModule.updateNextMessageSeq(s);this._groupModule.getModule(cs).onNewMessage({conversationOptionsList:s,isInstantMessage:t.isInstantMessage||!0,updateUnreadCount:t.updateUnreadCount||!0})}const n=this._groupModule.filterUnmodifiedMessage(o);n.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,n),o.length=0}_newGroupMessageStoredAndSummary(e){const{dataList:s,event:o,isInstantMessage:i}=e;let n=null;const r=[],a=[],u=[],c={},l=this._groupModule.getModule(gs),d=this._groupModule.getFileDownloadProxy(),p=s.length;p>1&&s.sort((e,t)=>e.sequence-t.sequence);for(let h=0;h{this._getTopicPendingMap.delete(_)}))}const I=this._groupModule.hasLocalGroup(p);if(!I&&this._groupModule.isUnjoinedAVChatRoom(p))continue;if(!I&&!f){this._cacheGroupMessageAndProbe({groupID:p,event:o,item:e});continue}if(this._groupModule.isMessageFromOrToAVChatroom(p)){e.event=o,u.push(e);continue}if(e.currentUser=this._groupModule.getMyUserID(),e.conversationType=t.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage,n=new mn(e),e.elements=l.parseElements(e.elements,e.from),n.setElement(e.elements,d),1===m){this._qualityStat(i,n);continue}let C=1===s[h].isModified;const T=this._groupModule.getModule(cs);if(T.isMessageSentByCurrentInstance(n)?n.isModified=C:C=!1,1===e.onlineOnlyFlag)n._onlineOnlyFlag=!0,T.isMessageSentByCurrentInstance(n)||a.push(n);else{if(this._groupModule.isMessageFromCommunityOfTopic(g,_)){a.push(n);continue}if(!T.pushIntoMessageList(a,n,C))continue;this._qualityStat(i,n);const{conversationID:e,sequence:t}=n,s=T.isRemoteRead({conversationID:e,sequence:t});if(Oe(c[e])){let t=0;"in"===n.flow&&(n._isExcludedFromUnreadCount||s||(t=1)),c[e]=r.push({conversationID:e,unreadCount:t,type:Oe(M)?n.conversationType:M,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{const t=c[e];r[t].type=Oe(M)?n.conversationType:M,r[t].subType=n.conversationSubType,r[t].lastMessage=n._isExcludedFromLastMessage?"":n,"in"===n.flow&&(n._isExcludedFromUnreadCount||s||r[t].unreadCount++)}}}return{conversationOptionsList:r,messageList:a,AVChatRoomMessageList:u}}_qualityStat(e,t){const s=this._groupModule.getModule(Es);s.addMessageSequence({key:Wi,message:t}),e&&t.clientTime>0&&s.addMessageDelay(t.clientTime)}onGroupMessageRevoked(t){const s=this._groupModule.getModule(cs),o=[];let i=null,n=!0;t.dataList.forEach(e=>{const{revokedInfos:t}=e.elements;Oe(t)||t.forEach(e=>{const t=Ct(e.topicID)?"GROUP"+e.groupID:"GROUP"+e.topicID;i=s.revoke(t,e.sequence,e.random);const r=e.revokerInfo&&e.revokerInfo.revoker;if(i)i.revoker=r,o.push(i);else{const i={conversationID:t,to:e.topicID||"",sequence:e.sequence,time:e.time,revoker:r};s.isLastMessageRevoked(i)&&(o.push(i),n=!1)}})}),0!==o.length&&(s.onMessageRevoked(o),!0===n&&(ge.l(`${this._n}.onGroupMessageRevoked count:${o.length}`),this._groupModule.emitOuterEvent(e.MESSAGE_REVOKED,o)))}_groupListTreeShaking(e){const t=new Map([...this._groupModule.getGroupMap()]);for(let o=0,i=e.length;o{t.delete(e)})}this._groupModule.getGroupMap().forEach((e,s)=>{e.isSupportTopic&&t.delete(s)});const s=[...t.keys()];for(let o=0,i=s.length;o{o[e]&&i.push(o[e])});const{isGroupWithTopicOnly:r=!1}=e||{};return this._pagingGetGroupList({limit:50,offset:0,groupBaseInfoFilter:i,groupList:n,isGroupWithTopicOnly:r}).then(()=>{ge.l(`${t} ok. count:${n.length} isGroupWithTopicOnly:${r}`),r||this._groupListTreeShaking(n),this._groupModule.updateGroupMap(n);const e=this._groupModule.getLocalGroupList().length;s.setNetworkType(this._groupModule.getNetworkType()).setMessage(`remote count:${n.length}, after tree shaking, local count:${e}, isGroupWithTopicOnly:${r}`).end(),this.tempConversationList&&(this.handleUpdateGroupLastMessage(this.tempConversationList),this.tempConversationList=null),this._groupModule.patchGroupMessageRemindType(),this._groupModule.recomputeUnreadCount(),this._groupModule.emitGroupListUpdate(!0,!r);const o=this._groupModule.getLocalGroupList();if(r){const e=o.filter(e=>!0===e.isSupportTopic);return Mn({groupList:e})}return this._isPagingGetCompleted=!0,Mn({groupList:o})}).catch(e=>(this._groupModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}isPagingGetCompleted(){return this._isPagingGetCompleted}_pagingGetGroupList(e){const s=this._n+"._pagingGetGroupList";let{isCommunityRelay:o=!1,isGroupWithTopicOnly:i=!1,limit:n,offset:r,groupBaseInfoFilter:a,groupList:u}=e;if(i)return this._pagingGetGroupListWithTopic({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u});let c=new Qi("_pagingGetGroupList");return this._groupModule.request({protocolName:Mo,requestData:{type:o?t.GRP_COMMUNITY:void 0,memberAccount:this._groupModule.getMyUserID(),limit:n,offset:r,responseFilter:{groupBaseInfoFilter:a,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]}}}).then(e=>{const{groups:t=[],totalCount:i}=e.data;u.push(...t),this._handleGroupAtInfoWithoutTopic(o,t);const l=r+n,d=!(i>l),p=`offset:${r} totalCount:${i} isCompleted:${d} currentCount:${u.length} isCommunityRelay:${o}`;return c.setNetworkType(this._groupModule.getNetworkType()).setMessage(""+p).end(),o||d?!o&&d?(ge.l(s+" start to get community list"),r=0,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:!0})):o&&!d?(r=l,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u,isCommunityRelay:!0})):(ge.l(`${s} ok. totalCount:${u.length}`),Mn({groupList:u})):(r=l,this._pagingGetGroupList({limit:n,offset:r,groupBaseInfoFilter:a,groupList:u}))}).catch(e=>(11e3!==e.code&&this._groupModule.probeNetwork().then(([t,s])=>{c.setMessage("isCommunityRelay:"+o).setError(e,t,s).end()}),o?(11e3===e.code&&(c=null,ge.l(s+" ok. community unavailable")),Tn({groupList:u})):yn(e)))}_pagingGetGroupListWithTopic(e){const s=this._n+"._pagingGetGroupListWithTopic";let{limit:o,offset:i,groupBaseInfoFilter:n,groupList:r}=e;const a=new Qi("pagingGetGroupListWithTopic");return this._groupModule.request({protocolName:Mo,requestData:{type:t.GRP_COMMUNITY,memberAccount:this._groupModule.getMyUserID(),limit:o,offset:i,responseFilter:{groupBaseInfoFilter:n,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]},isSupportTopic:1}}).then(e=>{const{groups:t=[],totalCount:u}=e.data;r.push(...t);const c=i+o,l=!(u>c),d=`offset:${i} totalCount:${u} isCompleted:${l} currentCount:`+r.length;return a.setNetworkType(this._groupModule.getNetworkType()).setMessage(""+d).end(),l?(ge.l(`${s} ok. totalCount:${r.length}`),Mn({groupList:r})):(i=c,this._pagingGetGroupListWithTopic({limit:o,offset:i,groupBaseInfoFilter:n,groupList:r}))}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),yn(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){const t=this._cachedGroupMessageMap.get(e)||[];t.forEach(e=>{this.onNewGroupMessage(e)}),this._deleteCachedGroupMessage(e),ge.l(`${this._n}._notifyCachedGroupMessage groupID:${e} count:${t.length}`)}_cacheGroupMessageAndProbe(e){const{groupID:s,event:o,item:i}=e;this._cacheGroupMessage(s,{event:o,dataList:[i]}),this._groupModule.getGroupSimplifiedInfo(s).then(e=>{const{type:o}=e;o===t.GRP_AVCHATROOM?this._groupModule.hasLocalGroup(s)?this._notifyCachedGroupMessage(s):this._groupModule.setUnjoinedAVChatRoom(s):(this._groupModule.updateGroupMap([e]),this._notifyCachedGroupMessage(s))}),this._checkCountMap.has(s)||this._checkCountMap.set(s,0),ge.l(`${this._n}._cacheGroupMessageAndProbe groupID:${s}`)}_handleGroupAtInfoWithoutTopic(e,t){e&&0!==t.length&&t.forEach(e=>{const{groupID:t,groupAtInfoList:s}=e,o=[];if(!Oe(s)){s.forEach(e=>{o.push({...e,groupID:t})});this._groupModule.getModule(cs).onNewGroupAtTips({dataList:o})}})}reset(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._getTopicPendingMap.clear(),this._isPagingGetCompleted=!1;this._groupModule.getInnerEmitterInstance().once(Sn,this._initGroupList,this)}}const Yn=1,jn=2,zn=3,Jn=4,Xn=5;class Zn{constructor(e){this._groupModule=e,this._n="GroupAttributesHandler",this._groupAttributesMap=new Map,this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4;this._groupModule.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._groupModule.getCloudConfig("grp_attr_cache_time");Oe(e)||(this.CACHE_EXPIRE_TIME=Number(e))}updateLocalMainSequenceOnReconnected(){this._groupAttributesMap.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdatedNotice(e){const{to:t,elements:{newGroupProfile:s}}=e,o=!Oe(s)&&!Ct(s.groupAttributeOption);return o&&this._onGroupAttributesUpdated({groupID:t,groupAttributeOption:s.groupAttributeOption}),o}_onGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:s}=e,{mainSequence:o,isWithChangedAttributeInfo:i,groupAttributeList:n=[],operationType:r}=s;if(ge.l(this._n+".onGroupAttributesUpdated. "+`groupID:${t} isWithChangedAttributeInfo:${i} operationType:${r}`),Oe(r))return;this._groupAttributesCopy=this._getCachedAttributes({groupID:t});const{localMainSequence:a}=this._getLocalGroupAttributes(t),u=o-a;if(0!==u){if(1===i&&1===u)return this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:n,operationType:r}),void this._emitGroupAttributesUpdated(t);if(this._hasLocalGroupAttributes(t)){const{avChatRoomKey:e}=this._getLocalGroupAttributes(t);this._getGroupAttributes({groupID:t,avChatRoomKey:e}).then(()=>{this._emitGroupAttributesUpdated(t)})}}}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:s}),ge.l(`${this._n}.initGroupAttributesCache groupID:${t} avChatRoomKey:${s}`)}initGroupAttributes(e){const{groupID:t,groupAttributes:s}=e,{remoteMainSequence:o,avChatRoomKey:i}=this._getLocalGroupAttributes(t),n=new Qi("initGroupAttributes");return n.setMessage(`groupID:${t} avChatRoomKey:${i} mainSequence:${o}`),this._groupModule.request({protocolName:Ko,requestData:{groupID:t,avChatRoomKey:i,mainSequence:o,groupAttributeList:this._transformGroupAttributes(s)}}).then(e=>{ge.l(`${this._n}.initGroupAttributes ok. groupID:${t}`);const{mainSequence:o,groupAttributeList:i}=e.data,r=[...i];return r.forEach(e=>{e.value=s[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:o,groupAttributeList:r,operationType:Yn}),this._emitGroupAttributesUpdated(t),n.setNetworkType(this._groupModule.getNetworkType()).end(),Mn({groupAttributes:s})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),yn(e)))}setGroupAttributes(e){const t=this._n+".setGroupAttributes",{groupID:s,groupAttributes:o}=e,{remoteMainSequence:i,avChatRoomKey:n,attributes:r}=this._getLocalGroupAttributes(s),a=this._transformGroupAttributes(o);a.forEach(e=>{const{key:t}=e;e.sequence=0,r.has(t)&&(e.sequence=r.get(t).sequence)});const u=new Qi("setGroupAttributes");return u.setMessage(`groupID:${s} groupAttributes:${JSON.stringify(o)}`),ge.l(`${t}. groupID:${s} mainSequence:${i}`),this._groupModule.request({protocolName:Wo,requestData:{groupID:s,avChatRoomKey:n,mainSequence:i,groupAttributeList:a}}).then(e=>{ge.l(t+" ok.");const{mainSequence:i,groupAttributeList:n}=e.data,r=[...n];return r.forEach(e=>{e.value=o[e.key]}),this._groupAttributesCopy=this._getCachedAttributes({groupID:s}),this._refreshCachedGroupAttributes({groupID:s,remoteMainSequence:i,groupAttributeList:r,operationType:jn}),this._emitGroupAttributesUpdated(s),u.setNetworkType(this._groupModule.getNetworkType()).end(),Mn({groupAttributes:o})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),yn(e)))}deleteGroupAttributes(e){const{groupID:t,keyList:s=[]}=e,{remoteMainSequence:o,avChatRoomKey:i,attributes:n}=this._getLocalGroupAttributes(t);let r=[...n.keys()],a=jo,u=zn;const c={groupID:t,avChatRoomKey:i,mainSequence:o},l=[];s.length>0&&(r=[],a=Yo,u=Jn,s.forEach(e=>{let t=0;n.has(e)&&(t=n.get(e).sequence,r.push(e)),l.push({key:e,sequence:t})}),c.groupAttributeList=l);const d=new Qi("deleteGroupAttributes");return d.setMessage(`groupID:${t} mainSequence:${o} keyList:${s} protocolName:${a}`),this._groupModule.request({protocolName:a,requestData:c}).then(e=>{ge.l(`${this._n}.deleteGroupAttributes ok. groupID:${t}`);const{mainSequence:s}=e.data;return this._groupAttributesCopy=this._getCachedAttributes({groupID:t}),this._refreshCachedGroupAttributes({groupID:t,remoteMainSequence:s,groupAttributeList:l,operationType:u}),this._emitGroupAttributesUpdated(t),d.setNetworkType(this._groupModule.getNetworkType()).end(),Mn({keyList:r})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{d.setError(e,t,s).end()}),yn(e)))}getGroupAttributes(e){const t=this._n+".getGroupAttributes",{groupID:s}=e,{avChatRoomKey:o,lastUpdateTime:i,localMainSequence:n,remoteMainSequence:r}=this._getLocalGroupAttributes(s),a=new Qi("getGroupAttributes");if(a.setMessage(`groupID:${s} localMainSequence:${n} remoteMainSequence:${r} keyList:${e.keyList}`),Date.now()-i>=this.CACHE_EXPIRE_TIME||n{a.setMoreMessage("get attributes from remote. count:"+o.length).setNetworkType(this._groupModule.getNetworkType()).end(),ge.l(`${t} from remote. groupID:${s}`);const i=this._getCachedAttributes(e);return Mn({groupAttributes:i})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),yn(e)));a.setMoreMessage("get attributes from cache").setNetworkType(this._groupModule.getNetworkType()).end(),ge.l(`${t} from cache. groupID:${s}`);const u=this._getCachedAttributes(e);return Tn({groupAttributes:u})}_getGroupAttributes(e){let t=0;return Oe(e.avChatRoomKey)||(t=1),this._groupModule.request({protocolName:zo,requestData:{...e,groupType:t}}).then(t=>{ge.l(`${this._n}._getGroupAttributes ok. groupID:${e.groupID}`);const{mainSequence:s,groupAttributeList:o}=t.data,i=[...o];return Oe(s)||this._refreshCachedGroupAttributes({groupID:e.groupID,remoteMainSequence:s,groupAttributeList:i,operationType:Xn}),o}).catch(e=>yn(e))}_refreshCachedGroupAttributes(e){const{groupID:t,remoteMainSequence:s,groupAttributeList:o,operationType:i}=e;if(this._hasLocalGroupAttributes(t)){const e=this._getLocalGroupAttributes(t),{localMainSequence:n}=e;if(i===Xn||s-n==1)e.remoteMainSequence=s,e.localMainSequence=s,e.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:e,groupAttributeList:o,operationType:i});else{if(n===s)return;e.remoteMainSequence=s}this._groupAttributesMap.set(t,e);const r=`operationType:${i} localMainSequence:${n} remoteMainSequence:${s}`;ge.l(`${this._n}._refreshCachedGroupAttributes. ${r}`)}}_getCachedAttributes(e){const{groupID:t,keyList:s=[]}=e,o={};if(this._hasLocalGroupAttributes(t)){const{attributes:e}=this._getLocalGroupAttributes(t);if(s.length>0)s.forEach(t=>{e.has(t)&&(o[t]=e.get(t).value)});else for(const t of e.keys())o[t]=e.get(t).value}return o}_updateCachedAttributes(e){const{groupAttributes:t,groupAttributeList:s,operationType:o}=e;o!==zn?o!==Jn?(o===Yn&&t.attributes.clear(),s.forEach(e=>{const{key:s,value:o,sequence:i}=e;t.attributes.set(s,{value:o,sequence:i})})):s.forEach(e=>{t.attributes.delete(e.key)}):t.attributes.clear()}_hasLocalGroupAttributes(e){return this._groupAttributesMap.has(e)}_getLocalGroupAttributes(e){return this._hasLocalGroupAttributes(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesMap.get(e)}_transformGroupAttributes(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}_emitGroupAttributesUpdated(t){const s=this._getCachedAttributes({groupID:t}),{updatedKeyList:o,deletedKeyList:i}=this._computeAttrChangedInfo(s);ge.l(`${this._n}._emitGroupAttributesUpdated update:${o.length}, delete:${i.length}`),0===o.length&&0===i.length||this._groupModule.emitOuterEvent(e.GROUP_ATTRIBUTES_UPDATED,{groupID:t,groupAttributes:s,updatedKeyList:o,deletedKeyList:i})}_computeAttrChangedInfo(e){const t=[],s=[];return Object.keys(e).forEach(s=>{e[s]!==this._groupAttributesCopy[s]&&t.push(s)}),Object.keys(this._groupAttributesCopy).forEach(t=>{Oe(e[t])&&s.push(t)}),this._groupAttributesCopy={},{updatedKeyList:t,deletedKeyList:s}}deleteLocalGroupAttributes(e){this._hasLocalGroupAttributes(e)&&this._groupAttributesMap.delete(e)}reset(){this._groupAttributesMap.clear(),this._groupAttributesCopy={},this.CACHE_EXPIRE_TIME=3e4}}const Qn="Set",er="Increase",tr="Decrease";class sr{constructor(e){this._groupModule=e,this._n="GroupCountersHandler",this._groupCountersMap=new Map,this.EXPIRE_TIME=3e4;this._groupModule.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._groupModule.getCloudConfig("grp_counter_expire_time");Oe(e)||(this.EXPIRE_TIME=Number(e))}isGroupCountersNotice(e){const{to:t,elements:{groupCounterInfo:s}}=e;let o=!1;return Ct(s)||(this._onGroupCountersUpdated({groupID:t,groupCounterInfo:s}),o=!0),o}_onGroupCountersUpdated(t){const{groupID:s,groupCounterInfo:o}=t;o.forEach(t=>{const{type:o,groupCounterSeq:i,counterList:n=[]}=t;0!==o&&2!==o||(this._updateLocalGroupCounters({groupID:s,groupCounterSeq:i,counterList:n}),n.forEach(t=>{this._groupModule.emitOuterEvent(e.GROUP_COUNTER_UPDATED,{groupID:s,key:t.key,value:t.value})})),1===o&&this._deleteLocalGroupCounters({groupID:s,groupCounterSeq:i,counterList:n})}),ge.l(`${this._n}._onGroupCountersUpdated groupID:${s}`)}initGroupCountersCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:s}),ge.l(`${this._n}.initGroupCountersCache groupID:${t} avChatRoomKey:${s}`)}setGroupCounters(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".setGroupCounters",{groupID:s,counters:o}=e,i=this._convertObjectToList(o),{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} count:${i.length}`,a=new Qi("setGroupCounters");return a.setMessage(""+r),ge.l(`${t}. ${r}`),this._updateGroupCounters({groupID:s,counterList:i,avChatRoomKey:n,mode:Qn}).then(e=>(a.end(),ge.l(t+" ok."),Mn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}increaseGroupCounter(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".increaseGroupCounters",{groupID:s,key:o,value:i}=e,{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} key:${o} value:${i}`,a=new Qi("increaseGroupCounter");a.setMessage(""+r),ge.l(`${t}. ${r}`);const u=[{key:o,value:i}];return this._updateGroupCounters({groupID:s,counterList:u,avChatRoomKey:n,mode:er}).then(e=>(a.end(),ge.l(t+" ok."),Mn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}decreaseGroupCounter(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".decreaseGroupCounter",{groupID:s,key:o,value:i}=e,{avChatRoomKey:n}=this._getLocalGroupCounters(s),r=`groupID:${s} key:${o} value:${i}`,a=new Qi("decreaseGroupCounter");a.setMessage(""+r),ge.l(`${t}. ${r}`);const u=[{key:o,value:i}];return this._updateGroupCounters({groupID:s,counterList:u,avChatRoomKey:n,mode:tr}).then(e=>(a.end(),ge.l(t+" ok."),Mn({counters:e}))).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}getGroupCounters(e){if(!this._groupModule.canIUse(M.GRP_COUNTER))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".getGroupCounters",{groupID:s,keyList:o=[]}=e,{avChatRoomKey:i,lastUpdateTime:n}=this._getLocalGroupCounters(s),r=new Qi("getGroupCounters");if(r.setMessage("groupID:"+s),Date.now()-n>=this.EXPIRE_TIME)return this._getRemoteGroupCounters({groupID:s,avChatRoomKey:i}).then(e=>{r.setMoreMessage("from remote. count:"+e.length).end(),ge.l(`${t} from remote. groupID:${s}`);const i=this._getLocalCounters(s,o);return Mn({counters:i})}).catch(e=>(this._groupModule.probeNetwork().then(([t,s])=>{r.setError(e,t,s).end()}),yn(e)));r.setMoreMessage("from cache").end(),ge.l(`${t} from cache. groupID:${s}`);const a=this._getLocalCounters(s,o);return Tn({counters:a})}_getRemoteGroupCounters(e){return this._groupModule.request({protocolName:ei,requestData:{...e}}).then(t=>{const{counterList:s=[],groupCounterSeq:o}=t.data;return this._updateLocalGroupCounters({groupID:e.groupID,counterList:s,groupCounterSeq:o}),ge.l(`${this._n}._getRemoteGroupCounters ok. groupID:${e.groupID}`),s}).catch(e=>yn(e))}_convertObjectToList(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}_updateGroupCounters(e){const t=this._n+"._updateGroupCounters",{groupID:s,avChatRoomKey:o,mode:i}=e;return ge.l(`${t}. groupID:${s} avChatRoomKey:${o} mode:${i}`),this._groupModule.request({protocolName:Qo,requestData:{...e}}).then(e=>{ge.l(t+" ok.");const{counterList:s=[]}=e.data,o={};return s.forEach(e=>{const{key:t,value:s}=e;o[t]=s}),o}).catch(e=>yn(e))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}_getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}_updateLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:o}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i,groupCounterSeq:n}=this._getLocalGroupCounters(t);if(o>0&&o{const{key:s,value:o}=t;e.set(s,o)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:e,avChatRoomKey:i})}}_deleteLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:o}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:i}=this._getLocalGroupCounters(t);s.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:o,counters:e,avChatRoomKey:i})}}_getLocalCounters(e,t){const s={};if(!this._hasLocalGroupCounters(e))return s;const{counters:o}=this._getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{o.has(e)&&(s[e]=o.get(e))});else for(const i of o.keys())s[i]=o.get(i);return s}reset(){this._groupCountersMap.clear(),this.EXPIRE_TIME=3e4}}class or{constructor(e){const{manager:t,groupID:s,onInit:o,onSuccess:i,onFail:n}=e;this._n="Polling",this._manager=t,this._groupModule=t._groupModule,this._onInit=o,this._onSuccess=i,this._onFail=n,this._groupID=s,this._timeoutID=-1,this._isRunning=!1,this._protocolName=qo}start(){const e=this._groupModule.isLoggedIn();e||(this._protocolName=xo),ge.l(`${this._n}.start pollingInterval:${this._manager.getPollingInterval()} isLoggedIn:${e}`),this._isRunning=!0,this._request()}isRunning(){return this._isRunning}_request(){const e=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:e}).then(e=>{this._onSuccess(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.getPollingInterval()))}).catch(e=>{this._onFail(this._groupID,e),this.isRunning()&&(clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),this._manager.MAX_POLLING_INTERVAL))})}stop(){ge.l(this._n+".stop"),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}getPollingTimerID(){return this._timeoutID}}const ir={3:!0,4:!0,5:!0,6:!0,17:!0};class nr{constructor(e){this._groupModule=e,this._n="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new wn(200),this.messageIDLinkedList=new wn(100),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60,this.DEFAULT_POLLING_INTERVAL=300,this.MAX_POLLING_INTERVAL=2e3,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0,this._startBroadcastSeq=1,this._broadcastMessageIDMap=new Map,this.DEFAULT_POLLING_SIMPLIFIED_MSG=0}hasJoinedAVChatRoom(){return this._joinedGroupMap.size>0}checkJoinedAVChatRoomByID(e){return this._joinedGroupMap.has(e)}getJoinedAVChatRoom(){return this._joinedGroupMap.size>0?[...this._joinedGroupMap.keys()]:null}_updateRequestData(e){const t=this._pollingRequestInfoMap.get(e);return e===[...this._pollingInstanceMap.keys()][0]?{...t,startBroadcastSeq:this._startBroadcastSeq,simplifiedMessage:this.DEFAULT_POLLING_SIMPLIFIED_MSG}:{...t,simplifiedMessage:this.DEFAULT_POLLING_SIMPLIFIED_MSG}}_handleSuccess(e,t){const{key:s,nextSeq:o,rspMsgList:i,errorCode:n,nextBroadcastSeq:r,broadcastMessageList:a}=t.data;if(0!==n){const s=this._pollingRequestInfoMap.get(e),o=new Qi("longPollingAVError"),i=s?`${s.key}-${s.startSeq}`:"requestInfo is undefined";o.setMessage(`${e}-${i}-${t.errorInfo}`).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;Le(s)&&ve(o)&&this._pollingRequestInfoMap.set(e,{key:s,startSeq:o}),ve(r)&&r>this._startBroadcastSeq&&(this._startBroadcastSeq=r),Ne(i)&&i.length>0?(i.forEach(e=>{e.to=e.groupID}),this.onMessage(i)):(this._pollingNoMessageCount+=1,this._pollingNoMessageCount===this.DEFAULT_POLLING_NO_MESSAGE_COUNT&&(this._pollingInterval=this.DEFAULT_POLLING_INTERVAL+this.DEFAULT_POLLING_INTERVAL_PLUS)),this._onBroadcastMessage(a)}}_handleFailure(e,t){}onMessage(s){if(!Ne(s)||0===s.length)return;0!==this._pollingNoMessageCount&&(this._pollingNoMessageCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL);let o=null;const i=[],n=this._getModule(cs),r=this._getModule(Es),a=s.length;a>1&&s.sort((e,t)=>e.sequence-t.sequence);const u=this._getModule(ls);for(let e=0;e1&&t<=20?this._getModule(Cs).onMessageMaybeLost(d,e+1,t-1):t<-1&&t>=-20&&this._getModule(Cs).onMessageMaybeLost(d,o.sequence+1,Math.abs(t)-1)}this.sequencesLinkedList.set(o.sequence),this.messageIDLinkedList.set(o.ID);let p=!1;if(this._isMessageSentByCurrentInstance(o)?c&&(p=!0,o.isModified=c,n.updateMessageIsModifiedProperty(o)):p=!0,p){if(o.conversationType===t.CONV_SYSTEM&&5===o.payload.operationType&&this._onGroupDismissed(o.payload.groupProfile.groupID),!l&&o.conversationType!==t.CONV_SYSTEM){const e=o.conversationID.replace(t.CONV_GROUP,"");this._pollingInstanceMap.has(e)?this._groupModule.isLoggedIn()&&r.addMessageSequence({key:ji,message:o}):(o.type!==t.MSG_GRP_TIP&&o.clientTime>0&&r.addMessageDelay(o.clientTime),r.addMessageSequence({key:Yi,message:o}))}i.push(o)}}if(0===i.length)return;this._groupModule.filterModifiedMessage(i);const c=this.packConversationOption(i);if(c.length>0){this._getModule(cs).onNewMessage({conversationOptionsList:c,isInstantMessage:!0})}ge.d(`${this._n}.onMessage count:${i.length}`),this._checkMessageStacked(i);const l=this._groupModule.filterUnmodifiedMessage(i);l.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,l),i.length=0}isBroadcastOrNormal(e){return 3===e||17===e}isGroupTip(e){return 4===e||6===e}isGroupSystemNotice(e){return 5===e}restoreGroupTipElements(e={}){e.groupJoinType||(e.groupJoinType=1);const{operatorInfo:t={},operatorID:s,userIDList:o=[]}=e,{userID:i=s,avatar:n="",nick:r=""}=t;e.operatorInfo={userID:i,avatar:n,nick:r};const a=o.map(e=>({userID:e}));return e.memberInfoList=e.memberInfoList||a,e}restoreMessageFromSimplified(e){const{event:s}=e;if(this.isBroadcastOrNormal(s)&&(e.cloudCustomData=e.cloudCustomData||"",e.elements=e.elements.map(e=>{if(e.type===t.MSG_CUSTOM){const{content:t={}}=e;e.content={data:"",description:"",extension:"",...t}}return e})),(this.isGroupTip(s)||this.isGroupSystemNotice(s))&&(e.from=e.from||"@TIM#SYSTEM"),this.isGroupTip(s)){e.elements=this.restoreGroupTipElements(e.elements);const{elements:t={}}=e,{operationType:s,operatorInfo:o={}}=t;if(1===s){const e=[{userID:o.userID}];t.memberInfoList=t.memberInfoList||e}}if(this.isGroupSystemNotice(s)){let{memberInfoList:t,operatorInfo:s={}}=e.elements;t||(t=s),e.elements.memberInfoList={userID:e.elements.operatorID,avatar:"",nick:"",...t},e.elements={authentication:"",remarkInfo:"",messageKey:1e3*e.time,...e.elements};const o=Object.keys(e.elements).filter(e=>"operatorInfo"!==e).reduce((t,s)=>({...t,[s]:e.elements[s]}),{});e.elements=o}return e}_onGroupDismissed(e){ge.l(`${this._n}._onGroupDismissed groupID:${e}`),this._groupModule.deleteLocalGroupAndConversation(e),this.reset(e)}_checkMessageStacked(e){const t="MessageStacked",s=e.length;if(s>=100&&(this._groupModule.outputWarning(t,s),this._reportMessageStackedCount<5)){new Qi(t).setNetworkType(this._groupModule.getNetworkType()).setMessage(`count:${s} groupID:${[...this._joinedGroupMap.keys()]}`).setLevel("warning").end(),this._reportMessageStackedCount+=1}}_isMessageSentByCurrentInstance(e){return!!this._getModule(cs).isMessageSentByCurrentInstance(e)}packMessage(e,s){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===s?t.CONV_SYSTEM:t.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;const o=new mn(e),i=this.packElements(e,s);return o.setElement(i,this._groupModule.getFileDownloadProxy()),o}packElements(e,s){if(4===s||6===s)return this._updateMemberCountByGroupTips(e),{type:t.MSG_GRP_TIP,content:{...e.elements,groupProfile:e.groupProfile}};if(5===s)return{type:t.MSG_GRP_SYS_NOTICE,content:{...e.elements,groupProfile:{...e.groupProfile,groupID:e.groupID}}};return this._getModule(gs).parseElements(e.elements,e.from)}packConversationOption(e){const t=new Map;for(let s=0;s0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,s)}start(e){if(this._pollingInstanceMap.has(e)){const t=this._pollingInstanceMap.get(e);return void(t.isRunning()||t.start())}const t=new or({manager:this,groupID:e,onInit:this._updateRequestData.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});t.start(),this._pollingInstanceMap.set(e,t),ge.l(`${this._n}.start groupID:${e}`)}handleJoinResult(e){return this._preCheck().then(()=>{const{longPollingKey:t,group:s}=e,o=s.groupID;return this._joinedGroupMap.set(o,s),this._groupModule.updateGroupMap([s]),this._groupModule.deleteUnjoinedAVChatRoom(o),this._groupModule.emitGroupListUpdate(!0,!1),Oe(t)?Tn({status:Ce,group:s}):Promise.resolve()})}startRunLoop(e){return this.handleJoinResult(e).then(()=>{const{longPollingKey:t,group:s,startSeq:o=0}=e,i=s.groupID;return this._pollingRequestInfoMap.set(i,{key:t,startSeq:o}),this.start(i),this._groupModule.isLoggedIn()?Tn({status:Ce,group:s}):Tn({status:Ce})})}_preCheck(){if(this._getModule(ls).isUnlimitedAVChatRoom())return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();const[e,s]=this._joinedGroupMap.entries().next().value;if(this._groupModule.isLoggedIn()){if(!(s.selfInfo.role===t.GRP_MBR_ROLE_OWNER||s.ownerID===this._groupModule.getMyUserID()))return this._groupModule.quitGroup(e);this._groupModule.deleteLocalGroupAndConversation(e)}else this._groupModule.deleteLocalGroupAndConversation(e);return this.reset(e),Promise.resolve()}joinWithoutAuth(e){const{groupID:s}=e,o=this._n+".joinWithoutAuth",i=new Qi("joinWithoutAuth");return this._groupModule.request({protocolName:Do,requestData:e}).then(({data:{longPollingKey:e}})=>{if(this._groupModule.probeNetwork().then(([t,o])=>{i.setNetworkType(o).setMessage(`groupID:${s} longPollingKey:${e}`).end(!0)}),Oe(e))return yn({code:$i.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN});ge.l(`${o} ok. groupID:${s}`);this._getModule(cs).setCompleted(`${t.CONV_GROUP}${s}`);const n=new Fn({groupID:s});return this.startRunLoop({group:n,longPollingKey:e}),Mn({status:Ce})}).catch(e=>(ge.e(`${o} failed. groupID:${s} error:`,e),this._groupModule.probeNetwork().then(([t,o])=>{i.setError(e,t,o).setMessage("groupID:"+s).end(!0)}),yn(e))).finally(()=>{this._groupModule.getModule(ps).reportAtOnce()})}getGroupOnlineMemberCount(e){const t=this._onlineMemberCountMap.get(e)||{},s=Date.now();return Ct(t)||s-t.lastSyncTime>1e3*t.expireTime&&s-t.latestUpdateTime>1e4&&s-t.lastReqTime>3e3?(t.lastReqTime=s,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then(e=>Mn({memberCount:e.memberCount})).catch(e=>yn(e))):Tn({memberCount:t.memberCount})}_getGroupOnlineMemberCount(e){const t=this._n+"._getGroupOnlineMemberCount";return this._groupModule.request({protocolName:Vo,requestData:{groupID:e}}).then(s=>{const o=this._onlineMemberCountMap.get(e)||{},{data:{onlineMemberNum:i=0,expireTime:n=this.DEFAULT_EXPIRE_TIME}}=s;ge.l(`${t} ok. groupID:${e} memberCount:${i} expireTime:${n}`);const r=Date.now();return Ct(o)&&(o.lastReqTime=r),this._onlineMemberCountMap.set(e,Object.assign(o,{lastSyncTime:r,latestUpdateTime:r,memberCount:i,expireTime:n})),{memberCount:i}}).catch(s=>{ge.w(t+" failed. error:",s);return new Qi("_getGroupOnlineMemberCount").setCode(s.code).setMessage(`groupID:${e} error:${JSON.stringify(s)}`).setNetworkType(this._groupModule.getNetworkType()).end(),Promise.reject(s)})}_getModule(e){return this._groupModule.getModule(e)}setPollingInterval(e){Oe(e)||(ve(e)?this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=e:this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=parseInt(e,10))}setPollingIntervalPlus(e){Oe(e)||(ve(e)?this.DEFAULT_POLLING_INTERVAL_PLUS=e:this.DEFAULT_POLLING_INTERVAL_PLUS=parseInt(e,10))}setPollingNoMessageCount(e){Oe(e)||(ve(e)?this.DEFAULT_POLLING_NO_MESSAGE_COUNT=e:this.DEFAULT_POLLING_NO_MESSAGE_COUNT=parseInt(e,10))}setPollingSimplifiedMessage(e){Oe(e)||"0"!==e&&"1"!==e||(this.DEFAULT_POLLING_SIMPLIFIED_MSG=parseInt(e,10))}getPollingInterval(){return this._pollingInterval}onAVChatRoomMemberBanned(e){const{groupID:t}=e.payload.groupProfile;ge.l(`${this._n}.onAVChatRoomMemberBanned groupID:${t}`),this._groupModule.deleteLocalGroupAndConversation(t),this.reset(t)}restartPolling(){ge.l(`${this._n}.restartPolling count:${this._pollingInstanceMap.size}`);for(const e of this._pollingInstanceMap.values())e.stop(),e.start()}getPollingTimerID(e){if(!this._pollingInstanceMap.has(e))return-1;const t=this._pollingInstanceMap.get(e).getPollingTimerID();return ge.l(`${this._n}.getPollingTimerID groupID:${e} timerID:${t}`),t}reset(e){if(e){ge.l(`${this._n}.reset groupID:${e}`);const t=this._pollingInstanceMap.get(e);t&&t.stop(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e)}else{ge.l(this._n+".reset all");for(const e of this._pollingInstanceMap.values())e.stop();this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear(),this._broadcastMessageIDMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL=300,this.DEFAULT_POLLING_NO_MESSAGE_COUNT=20,this.DEFAULT_POLLING_INTERVAL_PLUS=2e3,this._pollingNoMessageCount=0}}const rr=1,ar=15;class ur{constructor(e){this._groupModule=e,this._n="GroupSystemNoticeHandler",this.pendencyMap=new Map}onNewGroupSystemNotice(t){const{dataList:s,isSyncingEnded:o,isInstantMessage:i}=t;ge.d(`${this._n}.onReceiveSystemNotice count:${s.length}`);const{eventDataList:n,result:r}=this.newSystemNoticeStoredAndSummary({notifiesList:s,isInstantMessage:i});if(n.length>0){this._groupModule.getModule(cs).onNewMessage({conversationOptionsList:n,isInstantMessage:i}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:i})}i?r.length>0&&this._groupModule.emitOuterEvent(e.MESSAGE_RECEIVED,r):!0===o&&this._clearGroupSystemNotice()}newSystemNoticeStoredAndSummary({notifiesList:e,isInstantMessage:s}){let o=null;const i=e.length;let n=0;const r=[],a={conversationID:t.CONV_SYSTEM,unreadCount:0,type:t.CONV_SYSTEM,subType:null,lastMessage:null};for(n=0;n0?[a]:[],result:r}}_clearGroupSystemNotice(){this._getPendencyList().then(e=>{e.forEach(e=>{this.pendencyMap.set(`${e.from}_${e.groupID}_${e.to}`,e)});const s=this._groupModule.getModule(cs).getLocalMessageList(t.CONV_SYSTEM),o=[];s.forEach(e=>{const{operatorID:t,operationType:s,groupProfile:i}=e.payload;if(s===rr){const s=`${t}_${i.groupID}_${i.to}`,n=this.pendencyMap.get(s);n&&ve(n.handled)&&0!==n.handled&&o.push(e)}}),this.deleteGroupSystemNotice({messageList:o})})}deleteGroupSystemNotice(e){const s=this._n+".deleteGroupSystemNotice";return Ne(e.messageList)&&0!==e.messageList.length?(ge.l(s+" "+e.messageList.map(e=>e.ID)),this._groupModule.request({protocolName:Fo,requestData:{messageListToDelete:e.messageList.map(e=>({from:t.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}))}}).then(()=>{ge.l(s+" ok");const t=this._groupModule.getModule(cs);return e.messageList.forEach(e=>{t.deleteLocalMessage(e)}),Mn()}).catch(e=>(ge.e(s+" error:",e),yn(e)))):Tn()}_getPendencyList(e={}){const{type:t,startTime:s=0,limit:o=20}=e;return this._groupModule.request({protocolName:$o,requestData:{type:t,startTime:s,limit:o,handleAccount:this._groupModule.getMyUserID()}}).then(e=>{const 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(e=>this._getPendencyList({type:t.GRP_COMMUNITY}).then(t=>(e.push(...t),this._handlePendencyResult(e))).catch(t=>this._handlePendencyResult(e)))}_handlePendencyResult(e){const 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})}),Tn({applicationList:t})}_onReceivedGroupSystemNotice({result:e,isInstantMessage:t}){t&&e.forEach(e=>{switch(e.payload.operationType){case 1:break;case 2:this._onApplyGroupRequestAgreed(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._groupModule.onAVChatRoomMemberBanned(e)}})}_onApplyGroupRequestAgreed(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)||this._groupModule.getGroupProfile({groupID:t}).then(({data:{group:e}})=>{if(e){this._groupModule.updateGroupMap([e]);const t=!e.isSupportTopic;this._groupModule.emitGroupListUpdate(!0,t)}})}_onMemberKicked(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}_onGroupDismissed(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);const{_AVChatRoomHandler:s}=this._groupModule;s&&s.checkJoinedAVChatRoomByID(t)&&s.reset(t)}_onInviteGroup(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)||this._groupModule.getGroupProfile({groupID:t}).then(({data:{group:e}})=>{e&&(this._groupModule.updateGroupMap([e]),this._groupModule.emitGroupListUpdate())})}_onQuitGroup(e){const t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}_onSetManager(e){const{to:s,groupID:o}=e.payload.groupProfile,i=this._groupModule.getModule(as).getLocalGroupMemberInfo(o,s);i&&i.updateRole(t.GRP_MBR_ROLE_ADMIN)}_onDeleteManager(e){const{to:s,groupID:o}=e.payload.groupProfile,i=this._groupModule.getModule(as).getLocalGroupMemberInfo(o,s);i&&i.updateRole(t.GRP_MBR_ROLE_MEMBER)}_onMessageRemindTypeSynced(e){const{groupID:t}=e.payload.groupProfile,s=e.payload.messageRemindType;this._groupModule.getModule(cs).onGroupMessageRemindTypeSynced({groupID:t,messageRemindType:s})}_handleTopicSystemNotice(e){const{groupProfile:{groupID:t,topicID:s},elements:{operationType:o,topicIDList:i,messageRemindType:n}}=e,r=this._groupModule.getModule(us);17===o?r.onTopicCreated({groupID:t,topicID:s}):18===o?r.onTopicDeleted({groupID:t,topicIDList:i}):20===o&&r.onTopicMessageRemindTypeUpdated({groupID:t,topicID:s,messageRemindType:n})}reset(){this.pendencyMap.clear()}}class cr extends Gs{constructor(e){super(e),this._n="GroupModule",this._commonGroupHandler=null,this._AVChatRoomHandler=null,this._groupSystemNoticeHandler=null,this._commonGroupHandler=new Wn(this),this._groupAttributesHandler=new Zn(this),this._groupCountersHandler=new sr(this),this._AVChatRoomHandler=new nr(this),this._groupTipsHandler=new Kn(this),this._groupSystemNoticeHandler=new ur(this),this.groupMap=new Map,this._unjoinedAVChatRoomList=new Map,this._receiptDetailCompleteMap=new Map;this.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this.getCloudConfig("polling_interval"),t=this.getCloudConfig("polling_interval_plus"),s=this.getCloudConfig("polling_no_msg_count"),o=this.getCloudConfig("polling_simplified_msg");this._AVChatRoomHandler&&(ge.l(`${this._n}._onCloudConfigUpdated pollingInterval:${e} pollingIntervalPlus:${t} pollingNoMessageCount:${s} pollingSimplifiedMessage:`+o),this._AVChatRoomHandler.setPollingInterval(e),this._AVChatRoomHandler.setPollingIntervalPlus(t),this._AVChatRoomHandler.setPollingNoMessageCount(s),this._AVChatRoomHandler.setPollingSimplifiedMessage(o))}onCheckTimer(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}guardForAVChatRoom(e){if(e.conversationType===t.CONV_GROUP){const s=Je(e.to)?pt(e.to):e.to;return this.hasLocalGroup(s)?Tn():this.getGroupProfile({groupID:s}).then(o=>{const i=o.data.group.type;if(ge.l(`${this._n}.guardForAVChatRoom. groupID:${s} type:${i}`),i===t.GRP_AVCHATROOM){const t=$i.MESSAGE_SEND_FAIL_NOT_IN_AVCHATROOM;return yn(new fn({code:t,message:this.getErrorMessage(t,e.from,s),data:{message:e}}))}return Tn()})}return Tn()}checkJoinedAVChatRoomByID(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}onNewGroupMessage(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}updateNextMessageSeq(e){if(Ne(e)){const s=this.getModule(us);e.forEach(e=>{const o=e.conversationID.replace(t.CONV_GROUP,"");Je(o)&&s.updateLastMessage(o,e.lastMessage),this.groupMap.has(o)&&(this.groupMap.get(o).nextMessageSeq=e.lastMessage.sequence+1)})}}onNewGroupTips(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}onGroupMessageRevoked(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}onNewGroupSystemNotice(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}onGroupMessageReadNotice(e){e.dataList.forEach(e=>{const{groupMessageReadNotice:s}=e.elements;if(!Oe(s)){const e=this.getModule(cs);s.forEach(s=>{const{groupID:o,topicID:i,lastMessageSeq:n}=s;ge.d(`${this._n}.onGroupMessageReadNotice groupID:${o} lastMessageSeq:${n}`);let r=`${t.CONV_GROUP}${o}`,a=!0;Ct(i)||(r=`${t.CONV_GROUP}${i}`,a=!1),e.updateIsReadAfterReadReport({conversationID:r,lastMessageSeq:n}),e.updateUnreadCount(r,a),e.clearGroupAtInfoList(r,a)})}})}onReadReceiptList(e){ge.d(this._n+".onReadReceiptList options:",JSON.stringify(e)),e.dataList.forEach(e=>{const{groupProfile:t,elements:s}=e,{groupID:o}=t,i=this.getModule(cs),{readReceiptList:n}=s;i.updateReadReceiptInfo({groupID:o,readReceiptList:n})})}onGroupMessageModified(e){ge.d(this._n+".onGroupMessageModified options:",JSON.stringify(e));const s=this.getModule(cs);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_GROUP,to:e.topicID?e.topicID:e.groupID})})}deleteGroupSystemNotice(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}initGroupMap(e){this.groupMap.set(e.groupID,new Fn(e))}deleteGroup(e){this.groupMap.delete(e)}updateGroupMap(e){const t=this.getModule(cs);let s;e.forEach(e=>{s=e.groupID,this.groupMap.has(s)?this.groupMap.get(s).updateGroup(e):(this.groupMap.set(s,new Fn(e)),t.deleteGroupRomaingMessageInfo(s))});const o=this.getMyUserID();for(const[,i]of this.groupMap)i.selfInfo.userID=o,"Owner"===i.selfInfo.role&&(i.ownerID=o);this._setStorageGroupList()}getStorageGroupList(){return this.getModule(ds).getItem("groupMap")}_setStorageGroupList(){const e=this.getLocalGroupList().filter(({type:e})=>!je(e)).filter(({isSupportTopic:e})=>!e).slice(0,20).map(({groupID:e,name:t,avatar:s,type:o})=>({groupID:e,name:t,avatar:s,type:o}));this.getModule(ds).setItem("groupMap",e)}getGroupMap(){return this.groupMap}getLocalGroupList(){return[...this.groupMap.values()]}getLocalGroupProfile(e){return this.groupMap.get(e)}sortLocalGroupList(){const e=[...this.groupMap].filter(([e,t])=>!Ct(t.lastMessage));e.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime),this.groupMap=new Map([...e])}updateGroupLastMessage(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}emitGroupListUpdate(t=!0,s=!0){const o=this.getLocalGroupList();if(t&&this.emitOuterEvent(e.GROUP_LIST_UPDATED),s){const e=JSON.parse(JSON.stringify(o));this.getModule(cs).updateConversationGroupProfile(e)}}patchGroupMessageRemindType(){const e=this.getLocalGroupList(),t=this.getModule(cs);let s=0;e.forEach(e=>{!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(s+=1)}),ge.l(`${this._n}.patchGroupMessageRemindType count:${s}`)}recomputeUnreadCount(){const e=this.getLocalGroupList(),s=this.getModule(cs);e.forEach(e=>{const{groupID:o}=e,{excludedUnreadSequenceList:i,readedSequence:n}=e.selfInfo;if(Ne(i)){let r=0;i.forEach(t=>{t>=n&&t<=e.nextMessageSeq-1&&(r+=1)}),r>=1&&s.recomputeGroupUnreadCount({conversationID:`${t.CONV_GROUP}${o}`,count:r})}})}getMyNameCardByGroupID(e){const t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}isPagingGetCompleted(){return!!this._commonGroupHandler&&this._commonGroupHandler.isPagingGetCompleted()}getGroupList(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):Tn()}getGroupProfile(e){const t=this._n+".getGroupProfile",s=new Qi("getGroupProfile"),{groupID:o,groupCustomFieldFilter:i}=e;ge.l(`${t} groupID:${o}`);const n={groupIDList:[o],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption"],groupCustomFieldFilter:i,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(n).then(({data:{successGroupList:e,failureGroupList:i}})=>{if(ge.l(t+" ok"),i.length>0)return yn(i[0]);let n;if(je(e[0].type)&&!this.hasLocalGroup(o)?n=new Fn(e[0]):(this.updateGroupMap(e),n=this.getLocalGroupProfile(o)),!n.isSupportTopic){this.getModule(cs).updateConversationGroupProfile([n])}return s.setNetworkType(this.getNetworkType()).setMessage(`groupID:${o} type:${n.type} muteAllMembers:${n.muteAllMembers} ownerID:${n.ownerID}`).end(),Mn({group:n})}).catch(o=>(this.probeNetwork().then(([t,i])=>{s.setError(o,t,i).setMessage("groupID:"+e.groupID).end()}),ge.e(t+" failed. error:",o),yn(o)))}getGroupProfileAdvance(e){const t=this._n+".getGroupProfileAdvance",{groupIDList:s}=e;Ne(s)&&s.length>50&&(this.outputWarning("GetGroupProfileLimit"),s.length=50);const o=[],i=[];s.forEach(e=>{ze({groupID:e})?i.push(e):o.push(e)});const n=[];if(o.length>0){const t=this._getGroupProfileAdvance({...e,groupIDList:o});n.push(t)}if(i.length>0){const t=this._getGroupProfileAdvance({...e,groupIDList:i,relayFlag:o.length>0});n.push(t)}return Promise.all(n).then(e=>{const t=[],s=[];return e.forEach(e=>{t.push(...e.successGroupList),s.push(...e.failureGroupList)}),Mn({successGroupList:t,failureGroupList:s})}).catch(e=>(ge.e(t+" failed. error:",e),yn(e)))}_getGroupProfileAdvance(e){const{relayFlag:t=!1,...s}=e;return this.request({protocolName:fo,requestData:s}).then(e=>{ge.l(this._n+"._getGroupProfileAdvance ok.");const{groups:t}=e.data;return{successGroupList:t.filter(e=>Oe(e.errorCode)||0===e.errorCode),failureGroupList:t.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>new fn({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}))}}).catch(s=>t&&ze({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:yn(s))}createGroup(e){const s=this._n+".createGroup",{type:o,groupID:i}=e;if(e.name&&!1===this._filterProfanity("name",e))return yn({code:$i.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return yn({code:$i.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return yn({code:$i.PROFANITY_FOUND});if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(o))return yn({code:$i.ILLEGAL_GROUP_TYPE});if(!ze({type:o})){if(!Ct(i)&&ze({groupID:i}))return yn({code:$i.ILLEGAL_GROUP_ID});e.isSupportTopic=void 0}if(je(o)&&!Oe(e.memberList)&&e.memberList.length>0&&(e.memberList=void 0),this._canIUseJoinOption(o)||Oe(e.joinOption)||(e.joinOption=void 0),ze({type:o})){if(!Ct(i)&&!ze({groupID:i}))return yn({code:$i.ILLEGAL_GROUP_ID});e.isSupportTopic=!0===e.isSupportTopic?1:0}const n=new Qi("createGroup");ge.l(s+" options:",e);let r=null,a=[];return this.request({protocolName:Io,requestData:{...e,ownerID:this.getMyUserID(),webPushFlag:1}}).then(o=>{const{groupID:i,overLimitUserIDList:u=[]}=o.data;if(r=i,a=u,n.setNetworkType(this.getNetworkType()).setMessage(`groupType:${e.type} groupID:${i} overLimitUserIDList=${u}`).end(),ge.l(`${s} ok groupID:${i} overLimitUserIDList:`,u),e.type===t.GRP_AVCHATROOM)return this.getGroupProfile({groupID:i});if(e.type===t.GRP_COMMUNITY&&1===e.isSupportTopic)return this.getGroupProfile({groupID:i});Ct(e.memberList)||Ct(u)||(e.memberList=e.memberList.filter(e=>-1===u.indexOf(e.userID))),this.updateGroupMap([{...e,groupID:i}]);const c=this.getModule(ts),l=c.createCustomMessage({to:i,conversationType:t.CONV_GROUP,payload:{data:"group_create",extension:this.isIntl()?this.getMyUserID()+" created a group":this.getMyUserID()+"创建群组"}});return c.sendMessageInstance(l),this.emitGroupListUpdate(),this.getGroupProfile({groupID:i})}).then(e=>{const{group:s}=e.data,{nameCard:o,joinTime:i}=s.selfInfo;return s.updateSelfInfo({nameCard:o,joinTime:i,messageRemindType:t.MSG_REMIND_ACPT_AND_NOTE,role:t.GRP_MBR_ROLE_OWNER}),Mn({group:s,overLimitUserIDList:a})}).catch(t=>{if(n.setMessage("groupType:"+e.type),this.probeNetwork().then(([e,s])=>{n.setError(t,e,s).end()}),10010===t.code||10007===t.code){this.updateGroupMap([{...e,groupID:r}]);const t=this.getLocalGroupProfile(r);return ge.l(s+" success, but failed to get group profile."),Mn({group:t,overLimitUserIDList:a})}return ge.e(s+" failed. error:",t),yn(t)})}dismissGroup(e){const s=this._n+".dismissGroup";if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===t.GRP_WORK)return yn(new fn({code:$i.CANNOT_DISMISS_WORK}));const o=new Qi("dismissGroup");return o.setMessage("groupID:"+e),ge.l(`${s} groupID:${e}`),this.request({protocolName:Co,requestData:{groupID:e}}).then(()=>(o.setNetworkType(this.getNetworkType()).end(),ge.l(s+" ok"),this.deleteLocalGroupAndConversation(e),this.checkJoinedAVChatRoomByID(e)&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),Mn({groupID:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}updateGroupProfile(e){const t=this._n+".updateGroupProfile";if(this.hasLocalGroup(e.groupID)){const s=this.getLocalGroupProfile(e.groupID).type;this._canIUseJoinOption(s)||Oe(e.joinOption)||(ge.w(t+" joinOption is unavailable for Work/Meeting/AVChatRoom"),e.joinOption=void 0)}if(Oe(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off"),e.name&&!1===this._filterProfanity("name",e))return yn({code:$i.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return yn({code:$i.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return yn({code:$i.PROFANITY_FOUND});const s=new Qi("updateGroupProfile");return s.setMessage(JSON.stringify(e)),ge.l(`${t} groupID:${e.groupID}`),this.request({protocolName:To,requestData:e}).then(()=>{if(s.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this.hasLocalGroup(e.groupID)){this.groupMap.get(e.groupID).updateGroup(e),this._setStorageGroupList()}return Mn({group:this.groupMap.get(e.groupID)})}).catch(e=>(this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.l(t+" failed. error:",e),yn(e)))}_filterProfanity(e,t){const s=this.getModule(Ls);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],D);return!0===o&&(t[e]=i,!0)}joinGroup(e){const{groupID:s,type:o}=e,i=this._n+".joinGroup";if(o===t.GRP_WORK)return yn({code:$i.CANNOT_JOIN_WORK});if(this.deleteUnjoinedAVChatRoom(s),this.hasLocalGroup(s)){if(!this.isLoggedIn())return Tn({status:t.JOIN_STATUS_ALREADY_IN_GROUP});const o=new Qi("applyJoinGroup");return this.getGroupProfile({groupID:s}).then(()=>(o.setNetworkType(this.getNetworkType()).setMessage(`groupID:${s} joinedStatus:${t.JOIN_STATUS_ALREADY_IN_GROUP}`).end(),Tn({status:t.JOIN_STATUS_ALREADY_IN_GROUP}))).catch(t=>(o.setNetworkType(this.getNetworkType()).setMessage(`groupID:${s} unjoined`).end(),ge.w(`${i} ${s} was unjoined, now join!`),this.groupMap.delete(s),this.applyJoinGroup(e)))}return ge.l(`${i} groupID:${s}`),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}applyJoinGroup(e){const t=this._n+".applyJoinGroup",{groupID:s,applyMessage:o}=e;if(!Ct(o)&&!1===this._filterProfanity("applyMessage",e))return yn({code:$i.PROFANITY_FOUND});const i=new Qi("applyJoinGroup"),n={...e},r=this.canIUse(M.AVCHATROOM_HISTORY_MSG);r&&(n.historyMessageFlag=1);return this.getModule(cs).deleteTopicRoamingMessageInfo(s),this.request({protocolName:yo,requestData:n}).then(({data:{joinedStatus:e,longPollingKey:o,startSeq:n,avChatRoomFlag:a,avChatRoomKey:u,messageList:c}})=>{const l=`groupID:${s} joinedStatus:${e} longPollingKey:${o} startSeq:${n} avChatRoomFlag:${a} canGetAVChatRoomHistoryMessage:${r}, history message count:`+(Ct(c)?0:c.length);switch(i.setNetworkType(this.getNetworkType()).setMessage(""+l).end(),ge.l(`${t} ok. ${l}`),e){case Te:return Mn({status:Te});case Ce:return this.getGroupProfile({groupID:s}).then(({data:{group:e}})=>this._handleJoinResult({group:e,avChatRoomFlag:a,longPollingKey:o,startSeq:n,avChatRoomKey:u,messageList:c})).catch(()=>{const e=new Fn({groupID:s});return this._handleJoinResult({group:e,avChatRoomFlag:a,longPollingKey:o,startSeq:n,avChatRoomKey:u,messageList:c})});default:{const e=new fn({code:$i.JOIN_GROUP_FAIL});return ge.e(t+" failed. error:",e),yn(e)}}}).catch(e=>(i.setMessage("groupID:"+s),this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}_handleJoinResult(e){const{group:s,avChatRoomFlag:o,longPollingKey:i,startSeq:n,avChatRoomKey:r,messageList:a}=e,{groupID:u}=s;if(1===o){let e;return this.getModule(cs).setCompleted(`${t.CONV_GROUP}${u}`),this._groupAttributesHandler.initGroupAttributesCache({groupID:u,avChatRoomKey:r}),this._groupCountersHandler.initGroupCountersCache({groupID:u,avChatRoomKey:r}),e=Oe(i)?this._AVChatRoomHandler.handleJoinResult({group:s}):this._AVChatRoomHandler.startRunLoop({group:s,longPollingKey:i,startSeq:n}),e.then(()=>{this._onAVChatRoomHistoryMessage(a)}),e}return this.emitGroupListUpdate(!0,!1),Mn({status:Ce,group:s})}quitGroup(e){const t=this._n+".quitGroup";ge.l(`${t} groupID:${e}`);const s=this.checkJoinedAVChatRoomByID(e);if(!s&&!this.hasLocalGroup(e))return yn({code:$i.MEMBER_NOT_IN_GROUP});if(s&&!this.isLoggedIn())return ge.l(`${t} anonymously ok. groupID:${e}`),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),Tn({groupID:e});const o=new Qi("quitGroup");return o.setMessage("groupID:"+e),this.request({protocolName:Eo,requestData:{groupID:e}}).then(()=>(o.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this.deleteLocalGroupAndConversation(e),s&&this._AVChatRoomHandler.reset(e),this._groupAttributesHandler.deleteLocalGroupAttributes(e),Mn({groupID:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}searchGroupByID(e){const t=this._n+".searchGroupByID",s={groupIDList:[e]},o=new Qi("searchGroupByID");return o.setMessage("groupID:"+e),ge.l(`${t} groupID:${e}`),this.request({protocolName:So,requestData:s}).then(({data:{groupProfile:e}})=>{if(0!==e[0].errorCode)throw new fn({code:e[0].errorCode,message:e[0].errorInfo});return o.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),Mn({group:new Fn(e[0])})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.w(t+" failed. error:",e),yn(e)))}changeGroupOwner(e){const s=this._n+".changeGroupOwner";if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===t.GRP_AVCHATROOM)return yn({code:$i.CANNOT_CHANGE_OWNER_IN_AVCHATROOM});if(e.newOwnerID===this.getMyUserID())return yn({code:$i.CANNOT_CHANGE_OWNER_TO_SELF});const o=new Qi("changeGroupOwner");return o.setMessage(`groupID:${e.groupID} newOwnerID:${e.newOwnerID}`),ge.l(`${s} groupID:${e.groupID}`),this.request({protocolName:vo,requestData:e}).then(()=>{o.setNetworkType(this.getNetworkType()).end(),ge.l(s+" ok");const{groupID:t,newOwnerID:i}=e;this.groupMap.get(t).ownerID=i;const n=this.getModule(as).getLocalGroupMemberList(t);if(n instanceof Map){const e=n.get(this.getMyUserID());Oe(e)||(e.updateRole("Member"),this.groupMap.get(t).selfInfo.role="Member");const s=n.get(i);Oe(s)||s.updateRole("Owner")}return this.emitGroupListUpdate(!0,!1),Mn({group:this.groupMap.get(t)})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}getGroupApplicationList(){return this._groupSystemNoticeHandler.getGroupApplicationList()}handleGroupApplication(e){const t=this._n+".handleGroupApplication",{handleAction:s,handleMessage:o,message:i,application:n}=e;let r,a,u,c,l;i?(r=i.payload.operatorID,a=i.payload.groupProfile.groupID,u=i.payload.authentication,c=i.payload.messageKey):n&&(r=n.applicant,a=n.groupID,u=n.authentication,c=n.messageKey);let d=Lo;n&&2===n.applicationType&&(d=Ao,l=n.userID);const p=new Qi("handleGroupApplication");return p.setMessage("groupID:"+a),ge.l(`${t} groupID:${a}`),this.request({protocolName:d,requestData:{handleAction:s,handleMessage:o,applicant:r,invitee:l,groupID:a,authentication:u,messageKey:c}}).then(()=>(p.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),i&&this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),Mn({group:this.getLocalGroupProfile(a)}))).catch(e=>(this.probeNetwork().then(([t,s])=>{p.setError(e,t,s).end()}),ge.e(t+" failed. error",e),yn(e)))}handleGroupInvitation(e){const t=this._n+".handleGroupInvitation",{groupProfile:{groupID:s},authentication:o,messageKey:i,operatorID:n}=e.message.payload,{handleAction:r}=e,a=new Qi("handleGroupInvitation");return a.setMessage(`groupID:${s} inviter:${n} handleAction:${r}`),ge.l(`${t} groupID:${s} inviter:${n} handleAction:${r}`),this.request({protocolName:Ro,requestData:{...e,inviter:n,groupID:s,authentication:o,messageKey:i}}).then(()=>(a.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),Mn({group:this.getLocalGroupProfile(s)}))).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),ge.e(t+" failed. error",e),yn(e)))}getGroupOnlineMemberCount(e){if(!this._AVChatRoomHandler)return yn({code:$i.CANNOT_FIND_MODULE});return this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):Tn({memberCount:0})}hasLocalGroup(e){return this.groupMap.has(e)}deleteLocalGroupAndConversation(e){const s=this.checkJoinedAVChatRoomByID(e);if(ge.l(`${this._n}.deleteLocalGroupAndConversation isJoinedAVChatRoom:${s}`),s){this.getModule(cs).deleteLocalConversation(`${t.CONV_GROUP}${e}`)}if(ze({groupID:e})){const t=this.getLocalGroupProfile(e);if(t&&!0===t.isSupportTopic){this.getModule(us).deleteTopicListInCommunity(e)}}this._deleteLocalGroup(e),this.emitGroupListUpdate(!0,!1)}_deleteLocalGroup(e){this.groupMap.delete(e);this.getModule(as).deleteGroupMemberList(e),this._setStorageGroupList()}sendMessage(e,t){if(Ne(e._receiverList)&&e._receiverList.length>0){if(!this.canIUse(M.MSG_TO_SPECIFIED_GRP_MBR))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY})}const s=this.createGroupMessagePack(e,t);return this.request(s)}createGroupMessagePack(e,s){let o=null;s&&s.offlinePushInfo&&(o=s.offlinePushInfo);let i="";Le(e.cloudCustomData)&&e.cloudCustomData.length>0&&(i=e.cloudCustomData);const n=[];if(Re(s)&&Re(s.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:o}=s.messageControlInfo;!0===e&&n.push("NoUnread"),!0===t&&n.push("NoLastMsg"),!0===o&&n.push("NoMsgCheck")}let r=void 0;Ne(e._receiverList)&&e._receiverList.length>0&&(r=e._receiverList,e._receiverList.length>50&&(r=e._receiverList.slice(0,50),this.outputWarning("ReceiverListLimit")));const a=this.isOnlineMessage(e,s)?1:0,u=e.getGroupAtInfoList(),c={fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:i,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==t.MSG_TEXT||Ct(u)?void 0:u,onlineOnlyFlag:a,clientTime:e.clientTime,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0,isVoipPush:this._isVoipPush(o)},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:0===a?n:void 0,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1,receiverList:r,isSupportExtension:!0===e.isSupportExtension?1:0};return Je(e.to)&&(c.groupID=pt(e.to),c.topicID=e.to),{protocolName:qs,tjgID:this.generateTjgID(e),requestData:c}}_isVoipPush(e){let t=void 0;return Oe(e.disableVoipPush)||(t=!1===e.disableVoipPush?1:0),t}revokeMessage(e){const t={groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]};return Je(e.to)&&(t.groupID=pt(e.to),t.topicID=e.to),this.request({protocolName:No,requestData:t})}deleteMessage(e){const{to:t,keyList:s}=e;ge.l(`${this._n}.deleteMessage groupID:${t} count:${s.length}`);const o={groupID:t,deleter:this.getMyUserID(),keyList:s};return Je(t)&&(o.groupID=pt(t),o.topicID=t),this.request({protocolName:Bo,requestData:o})}modifyRemoteMessage(e){const{to:t,sequence:s,payload:o,type:i,version:n=0,cloudCustomData:r}=e;let a=t,u=void 0;Je(t)&&(a=pt(t),u=t);let c=void 0;return gt(i)&&(c=[],c.push({type:i,content:o})),this.request({protocolName:Ho,requestData:{groupID:a,topicID:u,sequence:s,version:n,elements:c,cloudCustomData:r}})}getRoamingMessage(e){const t=this._n+".getRoamingMessage";let{conversationID:s,groupID:o,sequence:i}=e;const n=new Qi("getGroupRoamingMessages");let r=0,a=void 0;return Je(o)&&(a=o,o=pt(a)),this._computeLastSequence({groupID:o,topicID:a,sequence:i}).then(e=>(r=e,ge.l(`${t} groupID:${o} startSequence:${r}`),this.request({protocolName:Uo,requestData:{groupID:o,count:21,sequence:r,topicID:a}}))).then(e=>{const{messageList:i,complete:u,invisibleSequenceList:c=[]}=e.data;Oe(i)?ge.l(`${t} ok. complete:${u} but messageList is undefined!`):ge.l(`${t} ok. complete:${u} count:${i.length}`);let l=this._getMinSequence(c,i)-1;n.setNetworkType(this.getNetworkType()).setMessage(`groupID:${o} topicID:${a} startSequence:${r} complete:${u} nextSequence:${l}`).end();const d=this.getModule(cs);let p=[];return Ct(i)||(d.updateRoamingMessageSequence(s,l),p=d.onRoamingMessage(i,s),d.updateIsRead(s),d.patchConversationLastMessage(s)),(2===u||l<=1)&&(d.setCompleted(s),l=""),ge.l(`${t} nextReqID:${l}, stored message count:${p.length}, invisible sequence count:${c.length}`),{nextReqID:l+"",storedMessageList:p}}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).setMessage(`groupID:${o} topicID:${a} startSequence:${r}`).end()}),ge.w(t+" failed. error:",e),yn(e)))}_getGroupIDOfMessage(e){return e.conversationID.replace(t.CONV_GROUP,"")}_getMinSequence(e,t){let s=0;Ct(t)||(s=t[t.length-1].sequence);let o=0;if(!Ct(e)){o=e[e.length-1]}return ge.l(`${this._n}._getMinSequence minVisibleSequence:${s} minInvisibleSequence:${o}`),o>0&&oe.from===o&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));if(ge.l(`${t} groupID:${s} sequenceList:${JSON.stringify(i)}`),0===i.length)return Tn({messageList:e});const n=new Qi("getReadReceiptList");return n.setMessage("groupID:"+s),this.request({protocolName:Po,requestData:{groupID:s,sequenceList:i}}).then(s=>{n.end(),ge.l(t+" ok");const{readReceiptList:o}=s.data;return Ne(o)&&o.forEach(t=>{e.forEach(e=>{0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)})}),Mn({messageList:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.w(t+" failed. error:",e),yn(e)))}sendReadReceipt(e){const t=this._n+".sendReadReceipt",s=this._getGroupIDOfMessage(e[0]),o=new Qi("sendReadReceipt");o.setMessage("groupID:"+s);const i=this.getMyUserID(),n=e.filter(e=>e.from!==i&&!0===e.needReadReceipt).map(e=>({sequence:e.sequence}));return 0===n.length?yn({code:$i.READ_RECEIPT_MESSAGE_LIST_EMPTY}):(ge.l(`${t}. sequenceList:${JSON.stringify(n)}`),this.request({protocolName:ko,requestData:{groupID:s,sequenceList:n}}).then(e=>(o.end(),ge.l(t+" ok"),Mn())).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.w(t+" failed. error:",e),yn(e))))}getReadReceiptDetail(e){const{message:t,filter:s,cursor:o,count:i}=e,n=this._getGroupIDOfMessage(t),r=t.ID,a=t.sequence,u=this._n+".getReadReceiptDetail",c=this._receiptDetailCompleteMap.get(r)||!1,l=0!==s&&1!==s?0:s,d=Le(o)?o:"",p=!ve(i)||i<=0||i>=100?100:i,h=`groupID:${n} sequence:${a} cursor:${d} filter:${l} completeFlag:${c}`;ge.l(`${u} ${h}`);const g={cursor:"",isCompleted:!1,messageID:r,unreadUserIDList:[],readUserIDList:[]},_=new Qi("getReadReceiptDetail");return _.setMessage(h),this.request({protocolName:wo,requestData:{groupID:n,sequence:a,flag:l,cursor:d,count:p}}).then(e=>{_.end();const{cursor:t,isCompleted:s,unreadUserIDList:o,readUserIDList:i}=e.data;return g.cursor=t,1===s&&(g.isCompleted=!0,this._receiptDetailCompleteMap.set(r,!0)),0===l?g.readUserIDList=i.map(e=>e.userID):1===l&&(g.unreadUserIDList=o.map(e=>e.userID)),ge.l(u+" ok"),Mn(g)}).catch(e=>(this.probeNetwork().then(([t,s])=>{_.setError(e,t,s).end()}),ge.w(u+" failed. error:",e),yn(e)))}getRoamingMessagesHopping(e){const s=this._n+".getRoamingMessagesHopping",o=new Qi("getGroupRoamingMessagesHopping");let{groupID:i,count:n,sequence:r,direction:a}=e,u=r;1===a&&(u=r+n-1);let c=void 0;Je(i)&&(c=i,i=pt(c));const l=`${c?"topicID:"+c:"groupID:"+i} sequence:${r} direction:${a}`;return ge.l(`${s} ${l}`),this.request({protocolName:Uo,requestData:{groupID:i,topicID:c,count:n,sequence:u}}).then(i=>{const{messageList:n,complete:u}=i.data,c=`complete:${u} count:${n?n.length:0}`;if(ge.l(`${s} ok. ${c}`),o.setNetworkType(this.getNetworkType()).setMessage(`${l} ${c}`).end(),2===u||Ct(n)){const e=this._computeResult();return Mn(e)}const d=`${t.CONV_GROUP}${e.groupID}`,p=this.getModule(cs).onRoamingMessage(n,d,!1),h=this._computeResult({direction:a,sequence:r,remoteMessageList:n,processedMessageList:p});return Mn(h)}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).setMessage(`groupID:${i} sequence:${r} count:${n}`).end()}),ge.w(s+" failed. error:",e),yn(e)))}_computeResult(e){const t={messageList:[],isCompleted:!1,nextMessageSeq:""};if(Oe(e))return t.isCompleted=!0,t;const{direction:s,sequence:o,remoteMessageList:i=[],processedMessageList:n=[]}=e,r=i.length;return 1===s?(t.nextMessageSeq=i[0].sequence+1,n.forEach(e=>{e.sequence>=o&&t.messageList.push(e)}),0===t.messageList.length&&i[0].sequence{i.setNetworkType(this.getNetworkType()).end(),ge.l(o+" ok.");const t=this.getModule(cs);t.updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:s});let a=!0;if(!Oe(r)){a=!1;const e=this.getModule(us).getLocalTopic(n,r);e&&e.updateSelfInfo({readedSequence:s})}return t.updateUnreadCount(e,a),Mn()}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.l(o+" failed. error:",e),yn(e)))}_computeLastSequence(e){const{groupID:t,topicID:s,sequence:o}=e;return o>0?Promise.resolve(o):Oe(s)||this.hasLocalGroup(t)?Oe(s)?this.getGroupLastSequence(t):this.getTopicLastSequence({groupID:t,topicID:s}):Promise.resolve(0)}getGroupLastSequence(e){const t=this._n+".getGroupLastSequence",s=new Qi("getGroupLastSequence");let o=0,i="";if(this.hasLocalGroup(e)){const n=this.getLocalGroupProfile(e),r=n.lastMessage;if(r.lastSequence>0&&!1===r.onlineOnlyFlag)return o=r.lastSequence,i=`got lastSequence:${o} from local group profile[lastMessage.lastSequence]. groupID:${e}`,ge.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o);if(n.nextMessageSeq>1)return o=n.nextMessageSeq-1,i=`got lastSequence:${o} from local group profile[nextMessageSeq]. groupID:${e}`,ge.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o)}const n="GROUP"+e,r=this.getModule(cs).getLocalConversation(n);if(r&&r.lastMessage.lastSequence&&!1===r.lastMessage.onlineOnlyFlag)return o=r.lastMessage.lastSequence,i=`got lastSequence:${o} from local conversation profile[lastMessage.lastSequence]. groupID:${e}`,ge.l(`${t} ${i}`),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),Promise.resolve(o);const a={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(a).then(({data:{successGroupList:n}})=>(Ct(n)?ge.l(`${t} successGroupList is empty. groupID:${e}`):(o=n[0].nextMessageSeq-1,i=`got lastSequence:${o} from getGroupProfileAdvance. groupID:${e}`,ge.l(`${t} ${i}`)),s.setNetworkType(this.getNetworkType()).setMessage(""+i).end(),o)).catch(o=>(this.probeNetwork().then(([t,i])=>{s.setError(o,t,i).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:"+e).end()}),ge.w(t+" failed. error:",o),yn(o)))}getTopicLastSequence({groupID:e,topicID:t}){const s=this._n+".getTopicLastSequence",o=new Qi("getTopicLastSequence");let i=0,n="";const r=this.getModule(us);return r.hasLocalTopic(e,t)?(i=r.getLocalTopic(e,t).nextMessageSeq-1,n=`get lastSequence:${i} from local topic info[nextMessageSeq]. topicID:${t}`,ge.l(`${s} ${n}`),o.setNetworkType(this.getNetworkType()).setMessage(""+n).end(),Promise.resolve(i)):r.getTopicList({groupID:e,topicIDList:[t]}).then(({data:{successTopicList:e}})=>(Ct(e)?ge.l(`${s} successTopicList is empty. topicID:${t}`):(i=e[0].nextMessageSeq-1,n=`get lastSequence:${i} from getTopicList. topicID:${t}`,ge.l(`${s} ${n}`)),o.setNetworkType(this.getNetworkType()).setMessage(""+n).end(),i)).catch(e=>(this.probeNetwork().then(([s,i])=>{o.setError(e,s,i).setMessage("get lastSequence failed from getTopicList. topicID:"+t).end()}),ge.w(s+" failed. error:",e),yn(e)))}isMessageFromOrToAVChatroom(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}hasJoinedAVChatRoom(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}getJoinedAVChatRoom(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}isOnlineMessage(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}_canIUseOnlineOnlyFlag(e){const s=this.getJoinedAVChatRoom();return!s||!s.includes(e.to)||e.conversationType!==t.CONV_GROUP}_onAVChatRoomHistoryMessage(e){if(Ct(e))return;ge.l(`${this._n}._onAVChatRoomHistoryMessage count:${e.length}`);const t=[];e.forEach(e=>{t.push({...e,isHistoryMessage:1})}),this.onAVChatRoomMessage(t)}onAVChatRoomMessage(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}onAVChatRoomMemberBanned(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onAVChatRoomMemberBanned(e)}getGroupSimplifiedInfo(e){const t=new Qi("getGroupSimplifiedInfo"),s={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(s).then(({data:{successGroupList:s}})=>(t.setNetworkType(this.getNetworkType()).setMessage(`groupID:${e} type:${s[0].type}`).end(),s[0])).catch(s=>{this.probeNetwork().then(([o,i])=>{t.setError(s,o,i).setMessage("groupID:"+e).end()})})}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&&!Ct(t)}isMessageFromCommunityOfTopic(e,t){return 2===e&&Ct(t)}getMessageExtensions(e,t){return ge.l(`${this._n}.getMessageExtensions startSequence:${t}`),this.request({protocolName:Xo,requestData:{groupID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){return ge.l(`${this._n}.modifyMessageExtensions operateType:${s}`),this.request({protocolName:Jo,requestData:{groupID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}getGroupNotify(e){if(!this.hasLocalGroup(e))return;const s=this.getLocalGroupProfile(e),{type:o,isSupportTopic:i}=s;if(je(o)||i)return;const n=this._n+".getGroupNotify",r=this._getGroupLastRevokedTime(e),a=1e3*ue();ge.l(`${n} groupID:${e} type:${o} beginTime:${r} endTime:${a}`),this.request({protocolName:Zo,requestData:{type:ze({type:o,groupID:e})?t.GRP_COMMUNITY:void 0,groupID:e,beginTime:r,endTime:a}}).then(t=>{const{nextRevokedTime:s,notifyList:o}=t.data;ge.l(`${n} ok. groupID:${e} nextRevokedTime:${s}`);const i={dataList:[{elements:{revokedInfos:[]}}]};Ne(o)&&o.forEach(t=>{i.dataList[0].elements.revokedInfos.push({groupID:e,sequence:t.sequence,random:t.random,revokerInfo:{...t.revokerInfo}})}),this.onGroupMessageRevoked(i),0!==s?(this._setGroupLastRevokedTime(e,s),this.getGroupNotify(e)):this._setGroupLastRevokedTime(e,1e3*ue())}).catch(e=>{ge.e(n+" failed. error:",e)})}_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)}restartPolling(){this._AVChatRoomHandler&&this._AVChatRoomHandler.restartPolling()}getPollingTimerID(e){if(!e)return-1;const t=this.getLocalGroupProfile(e);return t&&je(t.type)?this._AVChatRoomHandler.getPollingTimerID(e):-1}_canIUseJoinOption(e){return(e=>e===t.GRP_PUBLIC)(e)||ze({type:e})}reset(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._groupAttributesHandler.reset(),this._groupCountersHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}class lr{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(e)}_initMember(e){this.updateMember(e)}updateMember(e){const t=[null,void 0,"",0,NaN];e.memberCustomField&&Ye(this.memberCustomField,e.memberCustomField),we(this,e,["memberCustomField","marks"],t)}updateRole(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}updateMuteUntil(e){Oe(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}updateNameCard(e){Oe(e)||(this.nameCard=e)}updateMemberCustomField(e){e&&Ye(this.memberCustomField,e)}}class dr extends Gs{constructor(e){super(e),this._n="GroupMemberModule",this.groupMemberListMap=new Map,this.getInnerEmitterInstance().on(Ln,this._onProfileUpdated,this)}_onProfileUpdated({data:e}){for(let t=0;t{e.has(s.userID)&&e.get(s.userID).updateMember({nick:s.nick,avatar:s.avatar})})}}deleteGroupMemberList(e){this.groupMemberListMap.delete(e)}getGroupMemberList({groupID:e,offset:s=0,count:o=15,filter:i}){const n=this._n+".getGroupMemberList",r=this.getModule(ns),a=r.hasLocalGroup(e);if(ge.l(`${n} groupID:${e} offset:${s} count:${o} hasLocalGroup:${a}`),!a)return Tn({memberList:[],offset:0});if(r.getLocalGroupProfile(e).type===t.GRP_AVCHATROOM){if(this.canIUse(M.AVCHATROOM_MBR_LIST))return this._getAVChatRoomMemberList({groupID:e,offset:s,filter:i});this.outputWarning("LiveOnlineMember")}const u=new Qi("getGroupMemberList");let c=0;const l={groupID:e,limit:o>100?100:o};ze({groupID:e})?l.next=""+s:(l.offset=s,c=s+o);let d=[];return this.request({protocolName:ti,requestData:l}).then(({data:{members:t,memberNum:s,next:o}})=>{if(Oe(o)||(c=Ct(o)?0:o),!Ne(t)||0===t.length)return c=0,Promise.resolve([]);const i=this.getModule(ns);i.hasLocalGroup(e)&&(i.getLocalGroupProfile(e).memberNum=s),d=this._updateLocalGroupMemberMap(e,t);return this.getModule(os).getUserProfile({userIDList:t.map(e=>e.userID),tagList:[me.NICK,me.AVATAR]})}).then(t=>{const{data:i}=t;if(!Ne(i)||0===i.length)return Tn({memberList:[],offset:c});const r=i.map(e=>({userID:e.userID,nick:e.nick,avatar:e.avatar}));return this._updateLocalGroupMemberMap(e,r),d.length(this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),ge.e(n+" failed. error:",e),yn(e)))}_getAVChatRoomMemberList({groupID:e,offset:t,filter:s}){const o=this._n+"._getAVChatRoomMemberList",i=new Qi("_getAVChatRoomMemberList");return i.setMessage(`groupID:${e} offset:${t} filter:${s}`),this.request({protocolName:si,requestData:{groupID:e,offset:t,filter:s}}).then(t=>{const{memberList:s=[],offset:n=0}=t.data;i.setNetworkType(this.getNetworkType()).end(),ge.l(`${o} ok. member count:${s.length}, next request timestamp:${n}`);const r=this._updateLocalGroupMemberMap(e,s);return Mn({memberList:r,offset:n})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.e(o+" failed. error:",e),yn(e)))}getGroupMemberProfile(e){const t=this._n+".getGroupMemberProfile",s=new Qi("getGroupMemberProfile");s.setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList),ge.l(`${t} groupID:${e.groupID} userIDList:${e.userIDList.join(",")}`),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));const{groupID:o,userIDList:i}=e;return this._getGroupMemberProfileAdvance({...e,userIDList:i}).then(e=>{const{members:t}=e.data;if(!Ne(t)||0===t.length)return Tn([]);this._updateLocalGroupMemberMap(o,t);return this.getModule(os).getUserProfile({userIDList:t.map(({userID:e})=>e),tagList:[me.NICK,me.AVATAR]})}).then(e=>{const t=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s}));this._updateLocalGroupMemberMap(o,t);const n=i.filter(e=>this.hasLocalGroupMember(o,e)).map(e=>this.getLocalGroupMemberInfo(o,e));return s.setNetworkType(this.getNetworkType()).end(),Mn({memberList:n})})}addGroupMember(e){const t=this._n+".addGroupMember",{groupID:s}=e,o=this.getModule(ns).getLocalGroupProfile(s),{type:i}=o,n=new Qi("addGroupMember");if(n.setMessage(`groupID:${s} groupType:${i}`),je(i)){const e=new fn({code:$i.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return n.setError(e,!0,this.getNetworkType()).end(),yn(e)}return e.userIDList=e.userIDList.map(e=>({userID:e})),ge.l(`${t} groupID:${s}`),this.request({protocolName:ii,requestData:e}).then(({data:{members:s}})=>{ge.l(t+" ok");const i=s.filter(e=>1===e.result).map(e=>e.userID),r=s.filter(e=>0===e.result).map(e=>e.userID),a=s.filter(e=>2===e.result).map(e=>e.userID),u=s.filter(e=>4===e.result).map(e=>e.userID),c=`groupID:${e.groupID}, successUserIDList:${i}, failureUserIDList:${r}, existedUserIDList:${a}, overLimitUserIDList:`+u;return n.setNetworkType(this.getNetworkType()).setMoreMessage(c).end(),0===i.length?Mn({successUserIDList:i,failureUserIDList:r,existedUserIDList:a,overLimitUserIDList:u}):(o.memberCount+=i.length,this._updateConversationGroupProfile(o),Mn({successUserIDList:i,failureUserIDList:r,existedUserIDList:a,overLimitUserIDList:u,group:o}))}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}deleteGroupMember(e){const t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,i=this.getModule(ns).getLocalGroupProfile(s);if(Oe(i))return yn({code:$i.CANNOT_FIND_GROUP});if(je(i.type)){return this.canIUse(M.AVCHATROOM_BAN_MBR)?this._banAVChatRoomMember(e):yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY})}const n=new Qi("deleteGroupMember"),r=`groupID:${s} ${o.length>5?"userIDList.length:"+o.length:"userIDList:"+o}`;return n.setMessage(r),ge.l(`${t} groupID:${s} userIDList:`,o),this.request({protocolName:ni,requestData:e}).then(()=>(n.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),i.memberCount-=1,this._updateConversationGroupProfile(i),this.deleteLocalGroupMembers(s,o),Mn({group:i,userIDList:o}))).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}_updateConversationGroupProfile(e){this.getModule(cs).updateConversationGroupProfile([e])}_banAVChatRoomMember(e){const t=this._n+".deleteGroupMember",{groupID:s,userIDList:o}=e,i=`groupID:${s} ${o.length>5?"userIDList.length:"+o.length:"userIDList:"+o}`,n=new Qi("deleteGroupMember");n.setMessage(i),ge.l(`${t} groupID:${s} userIDList:`,o);const r=this.getModule(ns).getLocalGroupProfile(s);return Oe(e.duration)||0===e.duration?yn({code:$i.BAN_DURATION_INVALID}):this.request({protocolName:ri,requestData:e}).then(()=>(n.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this.deleteLocalGroupMembers(s,o),Mn({group:r,userIDList:o}))).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}setGroupMemberMuteTime(e){const{groupID:t,userID:s,muteTime:o}=e,i=this._n+".setGroupMemberMuteTime";if(s===this.getMyUserID())return yn(new fn({code:$i.CANNOT_MUTE_SELF}));ge.l(`${i} groupID:${t} userID:${s}`);const n=new Qi("setGroupMemberMuteTime");return n.setMessage(`groupID:${t} userID:${s} muteTime:${o}`),this.modifyGroupMemberInfo({groupID:t,userID:s,muteTime:o}).then(e=>{n.setNetworkType(this.getNetworkType()).end(),ge.l(i+" ok");const s=this.getModule(ns);return Mn({group:s.getLocalGroupProfile(t),member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(i+" failed. error:",e),yn(e)))}setGroupMemberRole(e){const s=this._n+".setGroupMemberRole",{groupID:o,userID:i,role:n}=e,r=this.getModule(ns).getLocalGroupProfile(o);if(r.selfInfo.role!==t.GRP_MBR_ROLE_OWNER)return yn({code:$i.NOT_OWNER});if([t.GRP_WORK,t.GRP_AVCHATROOM].includes(r.type))return yn({code:$i.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});const a=[t.GRP_MBR_ROLE_ADMIN,t.GRP_MBR_ROLE_MEMBER];if(ze({groupID:o})&&a.push(t.GRP_MBR_ROLE_CUSTOM),a.indexOf(n)<0)return yn({code:$i.INVALID_MEMBER_ROLE});if(i===this.getMyUserID())return yn({code:$i.CANNOT_SET_SELF_MEMBER_ROLE});const u=new Qi("setGroupMemberRole");return u.setMessage(`groupID:${o} userID:${i} role:${n}`),ge.l(`${s} groupID:${o} userID:${i}`),this.modifyGroupMemberInfo({groupID:o,userID:i,role:n}).then(e=>(u.setNetworkType(this.getNetworkType()).end(),ge.l(s+" ok"),Mn({group:r,member:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}_filterProfanity(e,t){const s=this.getModule(Ls);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],E);return!0===o&&(t[e]=i,!0)}setGroupMemberNameCard(e){const t=this._n+".setGroupMemberNameCard";if(e.nameCard&&!1===this._filterProfanity("nameCard",e))return yn({code:$i.PROFANITY_FOUND});const{groupID:s,userID:o=this.getMyUserID(),nameCard:i}=e;ge.l(`${t} groupID:${s} userID:${o}`);const n=new Qi("setGroupMemberNameCard");return n.setMessage(`groupID:${s} userID:${o} nameCard:${i}`),this.modifyGroupMemberInfo({groupID:s,userID:o,nameCard:i}).then(e=>{ge.l(t+" ok"),n.setNetworkType(this.getNetworkType()).end();const r=this.getModule(ns).getLocalGroupProfile(s);return o===this.getMyUserID()&&r&&r.setSelfNameCard(i),Mn({group:r,member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}setGroupMemberCustomField(e){const t=this._n+".setGroupMemberCustomField",{groupID:s,userID:o=this.getMyUserID(),memberCustomField:i}=e;ge.l(`${t} groupID:${s} userID:${o}`);const n=new Qi("setGroupMemberCustomField");return n.setMessage(`groupID:${s} userID:${o} memberCustomField:${JSON.stringify(i)}`),this.modifyGroupMemberInfo({groupID:s,userID:o,memberCustomField:i}).then(e=>{n.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok");const o=this.getModule(ns).getLocalGroupProfile(s);return Mn({group:o,member:e})}).catch(e=>(this.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}modifyGroupMemberInfo(e){let{groupID:t,userID:s}=e,o=void 0;return Je(t)&&(o=t,t=pt(o)),this.request({protocolName:ai,requestData:{...e,groupID:t,topicID:o}}).then(()=>{if(this.hasLocalGroupMember(t,s)){const o=this.getLocalGroupMemberInfo(t,s);return Oe(e.muteTime)||o.updateMuteUntil(e.muteTime),Oe(e.role)||o.updateRole(e.role),Oe(e.nameCard)||o.updateNameCard(e.nameCard),Oe(e.memberCustomField)||o.updateMemberCustomField(e.memberCustomField),o}return this.getGroupMemberProfile({groupID:t,userIDList:[s]}).then(({data:{memberList:[e]}})=>e)})}markGroupMemberList(e){const t=this._n+".markGroupMemberList",{groupID:s,markType:o,enableMark:i,userIDList:n=[]}=e,r=`groupID:${s} markType:${o} enableMark:${i} userIDList count: ${n.length}`;ge.l(`${t} ${r}`);let a=2;const u=[];!0===i&&(a=1);let c=[...n];n.length>500&&(c=n.slice(0,500),ge.w(`${t} ${Mt(500)}`)),c.forEach(e=>{u.push({userID:e,markType:[o]})}),c=null;const l=new Qi("markGroupMemberList");return l.setMessage(""+r),this.request({protocolName:ui,requestData:{groupID:s,operationType:a,memberList:u}}).then(e=>{const{memberList:s=[]}=e.data,o=[],i=[];s.length===n.length?o.push(...n):(s.forEach(e=>{o.push(e.userID)}),n.forEach(e=>{o.includes(e)||i.push(e)}));const r=`success count:${o.length} fail count:${i.length}`;return l.setNetworkType(this.getNetworkType()).setMessage(r).end(),ge.l(`${t} ok. ${r}`),Mn({successUserIDList:o,failureUserIDList:i})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}_getGroupMemberProfileAdvance(e){return this.request({protocolName:oi,requestData:{...e,memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]}})}_updateLocalGroupMemberMap(e,t){if(!Ne(t)||0===t.length)return[];return t.map(t=>(this.hasLocalGroupMember(e,t.userID)?this.getLocalGroupMemberInfo(e,t.userID).updateMember(t):this.setLocalGroupMember(e,new lr(t)),this.getLocalGroupMemberInfo(e,t.userID)))}deleteLocalGroupMembers(e,t){const 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){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{const s=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,s)}}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)}reset(){this.groupMemberListMap.clear()}}const pr=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],hr=function(e,t){return Ct(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",messageForShow:"",nick:"",version:0,cloudCustomData:"",isRevoked:!1,revoker:null}:{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",messageForShow:ht(e.type,e.payload,t),nick:e.nick||"",version:e.version||0,cloudCustomData:e.cloudCustomData||"",isRevoked:e.isRevoked||!1,revoker:e.revoker||null}};class gr{constructor(e,t){this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=hr(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(const t in e)pr.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=hr(e)}updateGroupAtInfoList(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}updateTopic(e){Oe(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Oe(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),we(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg"])}updateSelfInfo(e){return 0!==we(this.selfInfo,e,[],[""])}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked({sequence:e}){return e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}}class _r extends Gs{constructor(e){super(e),this._n="TopicModule",this._topicMap=new Map,this._getTopicTimeMap=new Map,this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600;this.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Oe(e)||(this.TOPIC_CACHE_TIME=Number(e)),Oe(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}onTopicCreated(t){const{groupID:s}=t;this.resetGetTopicTime(s),this.emitOuterEvent(e.TOPIC_CREATED,t)}onTopicDeleted(t){const{groupID:s,topicIDList:o=[]}=t;o.forEach(e=>{this._deleteLocalTopic(s,e)}),this.emitOuterEvent(e.TOPIC_DELETED,t)}onTopicMessageRemindTypeUpdated(t){const{groupID:s,topicID:o,messageRemindType:i}=t,n=this.getLocalTopic(s,o);if(n){const t=n.updateSelfInfo({messageRemindType:i});t&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}),ge.d(`${this._n}.onTopicMessageRemindTypeUpdated topicID:${o} messageRemindType:${i} isTopicUpdated:${t}`)}}onTopicProfileUpdated(t){const{groupID:s,topicID:o}=t,i=this.getLocalTopic(s,o);i&&(i.updateTopic(t),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:i}))}onConversationProxy(t){const{topicID:s,unreadCount:o,groupAtInfoList:i}=t,n=pt(s),r=this.getLocalTopic(n,s);let a=!1;r&&(Oe(o)||r.unreadCount===o||(r.updateUnreadCount(o),a=!0),Oe(i)||(r.updateGroupAtInfoList(i),a=!0)),a&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:n,topic:r})}onMessageSent(t){const{groupID:s,topicID:o,lastMessage:i}=t,n=this.getLocalTopic(s,o);n&&(n.nextMessageSeq+=1,n.updateLastMessage(i),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}))}onMessageModified(t){const{to:s,time:o,sequence:i,elements:n,cloudCustomData:r,messageVersion:a}=t,u=pt(s),c=this.getLocalTopic(u,s);if(c){const l=c.lastMessage;ge.d(`${this._n}.onMessageModified topicID:${s} lastMessage:`,JSON.stringify(l),"options:",JSON.stringify(t)),l&&(null===l.payload||l.lastTime===o&&l.lastSequence===i&&l.version!==a)&&(l.type=n[0].type,l.payload=n[0].content,l.messageForShow=ht(l.type,l.payload,this.isIntl()),l.cloudCustomData=r,l.version=a,l.lastSequence=i,l.lastTime=o,this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:u,topic:c}))}}onMessageRevoked(t){if(0===t.length)return;let s=null,o=null,i=!1;t.forEach(e=>{const t=e.to;o=pt(t),s=this.getLocalTopic(o,t),s&&(s.reduceUnreadCount()&&(i=!0),s.isLastMessageRevoked(e)&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))}),i&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:o,topic:s})}isLastMessageRevoked(e){const{topicID:t,sequence:s}=e,o=pt(t),i=this.getLocalTopic(o,t);let n=!1;return i&&(n=i.isLastMessageRevoked({sequence:s})),n}getJoinedCommunityList(){return this.getModule(ns).getGroupList({isGroupWithTopicOnly:!0}).then(e=>{const{groupList:t=[]}=e.data;return Mn({groupList:t})}).catch(e=>yn(e))}createTopicInCommunity(e){const t=this._n+".createTopicInCommunity",{topicID:s}=e;if(!Oe(s)&&!Je(s))return yn({code:$i.ILLEGAL_TOPIC_ID});if(e.topicName&&!1===this._filterProfanity("topicName",e))return yn({code:$i.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return yn({code:$i.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return yn({code:$i.PROFANITY_FOUND});const o=new Qi("createTopicInCommunity");return this.request({protocolName:Si,requestData:{...e}}).then(s=>{const{topicID:i}=s.data;return o.setMessage("topicID:"+i).setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this._updateTopicMap([{...e,topicID:i}]),Mn({topicID:i})}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}deleteTopicFromCommunity(e){const t=this._n+".deleteTopicFromCommunity",{groupID:s,topicIDList:o=[]}=e,i=new Qi("deleteTopicFromCommunity");return i.setMessage(`groupID:${s} topicIDList:${o}`),this.request({protocolName:vi,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{resultList:t=[]}=e.data,o=[],n=[];t.forEach(e=>{const{topicID:t,errorCode:s,errorInfo:i}=e;0===s?o.push({topicID:t}):n.push({topicID:t,code:s,message:i})});const r=`success count:${o.length}, fail count:${n.length}`;return i.setMoreMessage(""+r).setNetworkType(this.getNetworkType()).end(),ge.l(""+r),o.forEach(e=>{this._deleteLocalTopic(s,e.topicID)}),Mn({successTopicList:o,failureTopicList:n})}).catch(e=>(this.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}updateTopicProfile(e){const t=this._n+".updateTopicProfile";if(ge.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return yn({code:$i.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return yn({code:$i.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return yn({code:$i.PROFANITY_FOUND});const s=new Qi("updateTopicProfile");return s.setMessage(`groupID:${e.groupID} topicID:${e.topicID}`),Oe(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.request({protocolName:Li,requestData:{...e}}).then(()=>(s.setNetworkType(this.getNetworkType()).end(),ge.l(t+" ok"),this._updateTopicMap([e]),Mn({topic:this.getLocalTopic(e.groupID,e.topicID)}))).catch(e=>(this.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}getTopicList(e){const t=this._n+".getTopicList",{groupID:s,topicIDList:o=[]}=e,i=0===o.length,n=new Qi("getTopicList");if(n.setMessage("groupID:"+s),this._getTopicTimeMap.has(s)){const{isGetAll:e,time:r}=this._getTopicTimeMap.get(s);if((e||!e&&!i)&&Date.now()-r<1e3*this.TOPIC_CACHE_TIME){const e=this._getLocalTopicList(s,o);if(i||e.length===o.length)return n.setNetworkType(this.getNetworkType()).setMoreMessage("from cache, topic count:"+e.length).end(),ge.l(`${t} groupID:${s} from cache, topic count:${e.length}`),Tn({successTopicList:e,failureTopicList:[]})}}return this.request({protocolName:Ai,requestData:{groupID:s,topicIDList:o}}).then(e=>{const{topicInfoList:o=[]}=e.data,r=[],a=[],u=[];o.forEach(e=>{const{topic:t,selfInfo:s,errorCode:o,errorInfo:i}=e,{topicID:n}=t;0===o?(r.push({...t,selfInfo:s}),a.push(n)):u.push({topicID:n,code:o,message:i})}),this._updateTopicMap(r),this._handleTopicAtInfo(r);const c=`success count:${a.length}, fail count:${u.length}`;n.setNetworkType(this.getNetworkType()).setMoreMessage(""+c).end(),ge.l(`${t} groupID:${s} from remote, ${c}`);let l=[];return Ct(a)||(this._getTopicTimeMap.set(s,{time:Date.now(),isGetAll:i}),l=this._getLocalTopicList(s,a)),Mn({successTopicList:l,failureTopicList:u})}).catch(e=>(this.probeNetwork(e).then(([t,s])=>{n.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}hasLocalTopic(e,t){return!!this._topicMap.has(e)&&this._topicMap.get(e).has(t)}getLocalTopic(e,t){let s=null;return this._topicMap.has(e)&&(s=this._topicMap.get(e).get(t)),s}_getLocalTopicList(e,t=[]){const s=this._topicMap.get(e);let o=[];return s&&(o=[...s.values()]),0===t.length?o:o.filter(e=>t.includes(e.topicID))}_deleteLocalTopic(e,t){this._topicMap.has(e)&&(this._topicMap.get(e).delete(t),ge.l(`${this._n}._deleteLocalTopic groupID:${e} topicID:${t}`))}_updateTopicMap(e){const s=[];if(e.forEach(e=>{const{groupID:o,topicID:i}=e;let n=null;this._topicMap.has(o)||this._topicMap.set(o,new Map);this._topicMap.get(o).has(i)?(n=this._topicMap.get(o).get(i),n.updateTopic(e)):(this._getTopicLastMessage(e),n=new gr(e,this.isIntl()),this._topicMap.get(o).set(i,n));const r=this._computeUnreadCount(n);n.updateUnreadCount(r),s.push({conversationID:`${t.CONV_GROUP}${i}`,type:t.CONV_TOPIC,unreadCount:r})}),s.length>0){this.getModule(cs).updateTopicConversation(s)}}resetGetTopicTime(e){if(!Oe(e))return void this._getTopicTimeMap.set(e,0);[...this._getTopicTimeMap.keys()].forEach(e=>{this._getTopicTimeMap.set(e,0)})}getTopicListOnReconnected(){const e=[...this._topicMap.keys()],t=[];e.forEach(e=>{const s=[];this._getLocalTopicList(e).forEach(e=>{const{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&s.push(e.topicID)}),s.length>0&&t.push({groupID:e,topicIDList:s})}),ge.l(`${this._n}.getTopicListOnReconnected. active community count:${t.length}`),this._relayGetTopicList(t)}_relayGetTopicList(e){if(0===e.length)return;const t=e.shift(),s=t.topicIDList.length>5?"topicIDList.length:"+t.topicIDList.length:"topicIDList:"+t.topicIDList,o=new Qi("relayGetTopicList");o.setMessage(s),ge.l(`${this._n}._relayGetTopicList. ${s}`),this.getTopicList(t).then(()=>{o.setNetworkType(this.getNetworkType()).end(),this._relayGetTopicList(e)}).catch(t=>{this.probeNetwork().then(([e,s])=>{o.setError(t,e,s).end()}),this._relayGetTopicList(e)})}_handleTopicAtInfo(e){0!==e.length&&e.forEach(e=>{const{groupID:t,topicID:s,groupAtInfoList:o}=e,i=[];if(!Oe(o)){o.forEach(e=>{i.push({...e,groupID:t,topicID:s})});this.getModule(cs).onNewGroupAtTips({dataList:i})}})}_getTopicLastMessage(e){if(!Oe(e.lastMsg)){const t={time:e.lastMsg.time,sequence:e.lastMsg.sequence,from:e.lastMsg.from,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:"",nick:e.lastMsg.nick,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:Ct(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker};e.lastMessage=t}}deleteTopicListInCommunity(e){const s=this._getLocalTopicList(e),o=this.getModule(cs);s.forEach(s=>{const{topicID:i}=s;this._deleteLocalTopic(e,i),this._getTopicTimeMap.delete(e),o.deleteLocalConversation(`${t.CONV_GROUP}${i}`)})}_computeUnreadCount(e){const{excludedUnreadSequenceList:t,readedSequence:s}=e.selfInfo;let o=e.nextMessageSeq-e.selfInfo.readedSequence-1;if(Ne(t)){let i=0;t.forEach(t=>{t>=s&&t<=e.nextMessageSeq-1&&(i+=1)}),i>=1&&(o-=i)}return o<0?0:o}_filterProfanity(e,t){const s=this.getModule(Ls);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],D);return!0===o&&(t[e]=i,!0)}updateLastMessage(t,s){const o=pt(t),i=this.getLocalTopic(o,t);if(i){const t=s.sequence+1;i.updateNextMessageSeq(t),i.updateLastMessage(s),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:o,topic:i})}}getMessageExtensions(e,t){ge.l(`${this._n}.getMessageExtensions startSequence:${t}`);const s=pt(e.to);return this.request({protocolName:Xo,requestData:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){ge.l(`${this._n}.modifyMessageExtensions operateType:${s}`);const o=pt(e.to);return this.request({protocolName:Jo,requestData:{groupID:o,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){ge.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class mr{constructor(e){this._userModule=e,this._n="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}setExpirationTime(e){this.expirationTime=e}getUserProfile(e){const t=this._n+".getUserProfile",s=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),s.length>100&&(ge.w(`${t} ${Mt(100)}`),s.length=100);const o=[],i=[];let n;for(let c=0,l=s.length;c{a.push({toAccount:e,standardSequence:0,customSequence:0})}),e.userItem=a;const u=new Qi("getUserProfile");u.setMessage(s.length>5?"userIDList.length:"+s.length:"userIDList:"+s);return this._userModule.request({protocolName:xs,requestData:e}).then(e=>{u.setNetworkType(this._userModule.getNetworkType()).end(),ge.i(t+" ok");const s=this._handleResponse(e).concat(i);return Mn(r?s[0]:s)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}getMyProfile(){const e=this._userModule.getMyAccount(),t=this._n+".getMyProfile";if(ge.l(`${t} myAccount:${e}`),this._fill(),this._contains(e)){const s=this._getProfileFromMap(e);return ge.d(`${t} from cache, myProfile:${JSON.stringify(s)}`),Tn(s)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}_handleResponse(e){const{userProfileItem:t}=e.data;if(!Ne(t))return[];const s=[],o=Date.now();for(let i=0,n=t.length;i-1)s.profileCustomField.push({key:t[o].tag,value:t[o].value});else switch(t[o].tag){case me.NICK:s.nick=t[o].value;break;case me.GENDER:s.gender=t[o].value;break;case me.BIRTHDAY:s.birthday=t[o].value;break;case me.LOCATION:s.location=t[o].value;break;case me.SELFSIGNATURE:s.selfSignature=t[o].value;break;case me.ALLOWTYPE:s.allowType=t[o].value;break;case me.LANGUAGE:s.language=t[o].value;break;case me.AVATAR:s.avatar=t[o].value;break;case me.MESSAGESETTINGS:s.messageSettings=t[o].value;break;case me.ADMINFORBIDTYPE:s.adminForbidType=t[o].value;break;case me.LEVEL:s.level=t[o].value;break;case me.ROLE:s.role=t[o].value;break;default:ge.w(this._n+"._getLatestProfileFromResponse unknown tag:",t[o].tag,t[o].value)}return s}updateMyProfile(t){const s=this._n+".updateMyProfile";if(t.nick&&!1===this._userModule.filterProfanity("nick",t))return yn({code:$i.PROFANITY_FOUND});if(t.selfSignature&&!1===this._userModule.filterProfanity("selfSignature",t))return yn({code:$i.PROFANITY_FOUND});const o=new Qi("updateMyProfile");o.setMessage(JSON.stringify(t));const i=(new kn).validate(t);if(!i.valid)return o.setCode($i.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+i.tips).setNetworkType(this._userModule.getNetworkType()).end(),ge.e(`${s} info:${i.tips}`),yn({code:$i.UPDATE_PROFILE_INVALID_PARAM});const n=[];for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("profileCustomField"===e?t.profileCustomField.forEach(e=>{n.push({tag:e.key,value:e.value})}):n.push({tag:me[e.toUpperCase()],value:t[e]}));if(0===n.length){const e=new fn({code:$i.UPDATE_PROFILE_NO_KEY});return o.setError(e,!0,this._userModule.getNetworkType()).end(),ge.e(s+" failed. error:",e),yn(e)}const r=this._userModule.getMyAccount();return this._userModule.request({protocolName:Vs,requestData:{fromAccount:r,profileItem:n}}).then(i=>{o.setNetworkType(this._userModule.getNetworkType()).end(),ge.i(s+" ok");const{isProfileUpdated:n,latestProfile:a}=this._update(r,t);return!0===n&&this._userModule.emitOuterEvent(e.PROFILE_UPDATED,[a]),Tn(a)}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}onProfileModified(t){const s=t.dataList;if(Ct(s))return;const o=s.length;let i;ge.d(`${this._n}.onProfileModified count:${o} dataList:`,t.dataList);const n=[];for(let e=0;e0&&(this._userModule.emitInnerEvent(Ln,n),this._userModule.emitOuterEvent(e.PROFILE_UPDATED,n))}_fill(){if(0===this.accountProfileMap.size){const e=this._getCachedProfiles(),t=Date.now();for(let s=0,o=e.length;s0&&(s.lastUpdatedTime=i,o=!0)}else s=new kn(t),(this._userModule.isMyFriend(e)||e===this._userModule.getMyAccount())&&(s.lastUpdatedTime=i,o=!0,this.accountProfileMap.set(e,s));return this._flush(e===this._userModule.getMyAccount()),ge.l(`${this._n}._update account:${e} isProfileUpdated:${o}`),{isProfileUpdated:o,latestProfile:s}}_flush(e){const t=[...this.accountProfileMap.values()],s=this._userModule.getStorageModule();ge.d(`${this._n}._flush length:${t.length} flushAtOnce:${e}`),s.setItem(this.TAG,t,e)}_contains(e){return this.accountProfileMap.has(e)}_getProfileFromMap(e){return this.accountProfileMap.get(e)}_getCachedProfiles(){const e=this._userModule.getStorageModule().getItem(this.TAG);return Ct(e)?[]:e}onConversationsProfileUpdated(e){let t,s;const o=[];let i;for(let n=0,r=e.length;n0&&o.push(s)):o.push(t.userID));0!==o.length&&(ge.i(`${this._n}.onConversationsProfileUpdated toAccountList:${o}`),this.getUserProfile({userIDList:o}))}getNickAndAvatarByUserID(e){if(this._contains(e)){const t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}reset(){this._flush(!0),this.accountProfileMap.clear()}}class Mr{constructor(e){Ct||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class fr{constructor(e){this._userModule=e,this._n="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}getLocalBlacklist(){return[...this._blacklistMap.keys()]}getBlacklist(){const t=this._n+".getBlacklist",s={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},o=new Qi("getBlacklist");return this._userModule.request({protocolName:Bs,requestData:s}).then(s=>{const{blackListItem:i,currentSequence:n}=s.data,r=Ct(i)?0:i.length;o.setNetworkType(this._userModule.getNetworkType()).setMessage("count:"+r).end(),ge.i(t+" ok"),this.currentSequence=n,this._handleResponse(i,!0),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()])}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}addBlacklist(e){const t=new Qi("addToBlacklist"),s=this._n+".addBlacklist",o=this._userModule.getMyAccount();if(1===e.userIDList.length&&e.userIDList[0]===o){const e=$i.CANNOT_ADD_SELF_TO_BLACKLIST,o=this._userModule.getErrorMessage(e);t.setCode(e).setMessage(o).setNetworkType(this._userModule.getNetworkType()).end();const i=new fn({code:e});return ge.e(s+" failed. error:",i),yn(i)}e.userIDList.includes(o)&&(e.userIDList=e.userIDList.filter(e=>e!==o)),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList;return this._userModule.request({protocolName:Hs,requestData:e}).then(o=>(t.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),ge.i(s+" ok"),this._handleResponse(o.resultItem,!0),Mn([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),ge.e(s+" failed. error:",e),yn(e)))}_handleResponse(e,t){if(!Ct(e)){let s,o,i;for(let n=0,r=e.length;n(s.setNetworkType(this._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),ge.i(t+" ok"),this._handleResponse(o.data.resultItem,!1),Mn([...this._blacklistMap.keys()]))).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}onAccountDeleted(t){const s=[];let o;for(let e=0,i=t.length;e0&&(ge.l(`${this._n}.onAccountDeleted count:${s.length} userIDList:`,s),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}onAccountAdded(t){const s=[];let o;for(let e=0,i=t.length;e0&&(ge.l(`${this._n}.onAccountAdded count:${s.length} userIDList:`,s),this._userModule.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}reset(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}const Ir=function(e){const t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let i,n,r=0,a=0;n=t.charAt(a++);~n&&(i=r%4?64*i+n:n,r++%4)?s+=String.fromCharCode(255&i>>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);try{return decodeURIComponent(escape(s))}catch(o){return""}};class Cr{constructor(e){this._userModule=e,this._n="UserStatusHandler",this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100;this._userModule.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){const e=this._userModule.getCloudConfig("status_query_count"),t=this._userModule.getCloudConfig("status_sub_count"),s=this._userModule.getCloudConfig("status_unsub_count");ge.l(`${this._n}._onCloudConfigUpdated statusQueryCount:${e} statusSubscribeCount:${t} statusUnsubscribeCount:`+s),Oe(e)||(this.MAX_QUERY_USER_COUNT=parseInt(e,10)),Oe(e)||(this.MAX_SUBSCRIBE_USER_COUNT=parseInt(t,10)),Oe(e)||(this.MAX_UNSUBSCRIBE_USER_COUNT=parseInt(s,10))}onUserStatusUpdated(t){const{dataList:s}=t,o=this._userModule.getMyUserID(),i=this._userModule.getModule(ls),n=s.map(e=>{const{to:t,statusType:s,customStatus:n}=e,r=Ir(n);return t===o&&i.setCustomStatus(r),{userID:t,statusType:s,customStatus:r}});this._userModule.emitOuterEvent(e.USER_STATUS_UPDATED,n)}setSelfStatus(e){const t=this._n+".setSelfStatus";if(!1===this._userModule.filterProfanity("customStatus",e))return yn({code:$i.PROFANITY_FOUND});const s=new Qi("setSelfStatus"),{customStatus:o}=e;return this._userModule.request({protocolName:Ri,requestData:{customStatus:o}}).then(e=>{s.setNetworkType(this._userModule.getNetworkType()).setMessage("customStatus:"+o).end(),ge.l(`${t} ok. customStatus:${o}`);return this._userModule.getModule(ls).setCustomStatus(o),Mn({userID:this._userModule.getMyUserID(),statusType:1,customStatus:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{s.setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}getUserStatus(e){const t=this._n+".getUserStatus",{userIDList:s=[]}=e,o=this._userModule.getMyUserID();let i=[...s],n=void 0;const r=i.indexOf(o);if(r>-1){i.splice(r,1);const e=this._userModule.getModule(ls).getCustomStatus();n={userID:o,statusType:1,customStatus:e}}if(0===i.length)return Tn({successUserList:[n],failureUserList:[]});if(!this._userModule.canIUse(M.USER_STATUS))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});i.length>this.MAX_QUERY_USER_COUNT&&(ge.w(`${t} ${Mt(this.MAX_QUERY_USER_COUNT)}`),i=s.slice(0,this.MAX_QUERY_USER_COUNT));const a=new Qi("getUserStatus");return this._userModule.request({protocolName:Ni,requestData:{userIDList:i}}).then(e=>{const{successUserList:o=[],failureUserList:i=[]}=e.data,r=o.map(e=>{const{userID:t,statusType:s,customStatus:o}=e;return{userID:t,statusType:s,customStatus:Ir(o)}}),u=i.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Ct(s)?t:s,code:o,message:i}});Oe(n)||r.unshift(n);const c=`userID count:${s.length}, success count:${r.length}, fail count:${u.length}`;return a.setNetworkType(this._userModule.getNetworkType()).setMessage(""+c).end(),ge.l(`${t} ok. ${c}.`),Mn({successUserList:r,failureUserList:u})}).catch(e=>(this._userModule.probeNetwork().then(([t,o])=>{a.setMessage("userID count:"+s.length).setError(e,t,o).end()}),ge.e(t+" failed. error:",e),yn(e)))}subscribeUserStatus(e){if(!this._userModule.canIUse(M.USER_STATUS))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".subscribeUserStatus",{userIDList:s=[]}=e;let o=[...s];o.length>this.MAX_SUBSCRIBE_USER_COUNT&&(ge.w(`${t} ${Mt(this.MAX_SUBSCRIBE_USER_COUNT)}`),o=s.slice(0,this.MAX_SUBSCRIBE_USER_COUNT));const i=new Qi("subscribeUserStatus"),n="userID count:"+s.length;return ge.l(`${t} ${n}`),this._userModule.request({protocolName:Oi,requestData:{userIDList:o}}).then(e=>{const{failureUserList:s=[]}=e.data,o=s.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Ct(s)?t:s,code:o,message:i}});return i.setNetworkType(this._userModule.getNetworkType()).setMessage(`${n} fail count:${o.length}`).end(),ge.l(`${t} ok. fail count:${o.length}.`),Mn({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{i.setMessage(""+n).setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}unsubscribeUserStatus(e){if(!this._userModule.canIUse(M.USER_STATUS))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".unsubscribeUserStatus",{userIDList:s=[]}=e||{};let o=[...s];s.length>this.MAX_UNSUBSCRIBE_USER_COUNT&&(ge.w(`${t} ${Mt(this.MAX_UNSUBSCRIBE_USER_COUNT)}`),o=s.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT));const i=new Qi("unsubscribeUserStatus"),n="userID count:"+s.length;ge.l(`${t} ${n}`);const r={userIDList:o};return 0===o.length&&(r.userIDList=void 0,r.unsubscribeAll=1),this._userModule.request({protocolName:Gi,requestData:r}).then(e=>{const{failureUserList:s=[]}=e.data,o=s.map(e=>{const{userID:t,invalidUserID:s,errorCode:o,errorInfo:i}=e;return{userID:Ct(s)?t:s,code:o,message:i}});return i.setNetworkType(this._userModule.getNetworkType()).setMessage(`${n} fail count:${o.length}`).end(),ge.l(`${t} ok. fail count:${o.length}.`),Mn({failureUserList:o})}).catch(e=>(this._userModule.probeNetwork().then(([t,s])=>{i.setMessage(""+n).setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class Tr extends Gs{constructor(e){super(e),this._n="UserModule",this._profileHandler=new mr(this),this._blacklistHandler=new fr(this),this._userStatusHandler=new Cr(this);this.getInnerEmitterInstance().on(Sn,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){const{dataList:t}=e;if(Ct(t))return;const s=[];t.forEach(e=>{e.blackListDelAccount&&s.push(...e.blackListDelAccount)}),s.length>0&&this._blacklistHandler.onAccountDeleted(s);const o=[];t.forEach(e=>{e.blackListAddAccount&&o.push(...e.blackListAddAccount)}),o.length>0&&this._blacklistHandler.onAccountAdded(o)}onConversationsProfileUpdated(e){this._profileHandler.onConversationsProfileUpdated(e)}getMyAccount(){return this.getMyUserID()}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.getModule(ds)}filterProfanity(e,t){const s=this.getModule(Ls);if(!s)return!0;const{isAllowedToSend:o,modifiedText:i}=s.filterText(t[e],y);return!0===o&&(t[e]=i,!0)}isMyFriend(e){const t=this.getModule(rs);return!!t&&t.isMyFriend(e)}getUserProfile(e){return this._profileHandler.getUserProfile(e)}updateMyProfile(e){return this._profileHandler.updateMyProfile(e)}getNickAndAvatarByUserID(e){return this._profileHandler.getNickAndAvatarByUserID(e)}getLocalBlacklist(){const e=this._blacklistHandler.getLocalBlacklist();return Tn(e)}addBlacklist(e){return this._blacklistHandler.addBlacklist(e)}deleteBlacklist(e){return this._blacklistHandler.deleteBlacklist(e)}onUserStatusUpdated(e){this._userStatusHandler.onUserStatusUpdated(e)}setSelfStatus(e){return this._userStatusHandler.setSelfStatus(e)}getUserStatus(e){return this._userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this._userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._userStatusHandler.unsubscribeUserStatus(e)}reset(){ge.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class yr{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="2.27.6",this._a2Key="",this._tinyID="",this._customStatus="",this._contentType="json",this._unlimitedAVChatRoom=t.unlimitedAVChatRoom,this._scene=t.scene||"",this._oversea=t.oversea,this._instanceID=t.instanceID,this._statusInstanceID=0,this._isDevMode=t.devMode,this._proxyServer=t.proxyServer,this._fileUploadProxy=t.fileUploadProxy,this._fileDownloadProxy=t.fileDownloadProxy}isLoggedIn(){return this._isLoggedIn}isOversea(){return this._oversea}isPrivateNetWork(){return this._proxyServer}isDevMode(){return this._isDevMode}isSingaporeSite(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7||this._SDKAppID>=172e7&&this._SDKAppID<173e7}isKoreaSite(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7||this._SDKAppID>=173e7&&this._SDKAppID<174e7}isGermanySite(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7||this._SDKAppID>=174e7&&this._SDKAppID<175e7}isIndiaSite(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7||this._SDKAppID>=175e7&&this._SDKAppID<176e7}isJapanSite(){return this._SDKAppID>=6e7&&this._SDKAppID<7e7||this._SDKAppID>=176e7&&this._SDKAppID<177e7}isUSASite(){return this._SDKAppID>=7e7&&this._SDKAppID<8e7||this._SDKAppID>=177e7&&this._SDKAppID<178e7}isIntl(){return 0===(e=this._SDKAppID)||e>=2e7&&e<8e7||e>=172e7&&e<178e7;var e}isUnlimitedAVChatRoom(){return this._unlimitedAVChatRoom}setUserID(e){this._userID=e}getUserID(){return this._userID}setUserSig(e){this._userSig=e}getUserSig(){return this._userSig}getSDKAppID(){return this._SDKAppID}setTinyID(e){this._tinyID=e,this._isLoggedIn=!0}getTinyID(){return this._tinyID}setCustomStatus(e){this._customStatus=e}getCustomStatus(){return this._customStatus}getScene(){return ee?window.tencent_cloud_im_csig_flutter_for_web_25F_cy:this._isTUIKit()?"tuikit":this._scene}getInstanceID(){return this._instanceID}getStatusInstanceID(){return this._statusInstanceID}setStatusInstanceID(e){this._statusInstanceID=e}getVersion(){return this._version}getA2Key(){return this._a2Key}setA2Key(e){this._a2Key=e}getContentType(){return this._contentType}getProxyServer(){return this._proxyServer}getFileUploadProxy(){return this._fileUploadProxy}getFileDownloadProxy(){return this._fileDownloadProxy}_isTUIKit(){let e=!1,t=!1,s=!1,o=!1,i=[];P&&(i=Object.keys(b)),k&&(i=U?Object.keys(uni):Object.keys(window));for(let r=0,a=i.length;r0){for(let e=0,t=n.length;e{this._lastLoginTs=0;const i=Date.now();let r=null;const{a2Key:a,tinyID:u,helloInterval:c,instanceID:l,timeStamp:d,customStatus:p="",purchaseBits:h}=s.data;ge.l(`${n} ok. scene:${t} helloInterval:${c} instanceID:${l} timeStamp:${d}`);const g=1e3*d,_=i-o.getStartTs(),m=g+parseInt(_/2)-i,M=o.getStartTs()+m;if(o.start(M),function(e,t){ae=t;const s=new Date;s.setTime(e),ge.i(`baseTime from server:${s} offset:${ae}`)}(g,m),!u)throw r=new fn({code:$i.NO_TINYID}),o.setError(r,!0,this.getNetworkType()).end(),r;if(!a)throw r=new fn({code:$i.NO_A2KEY}),o.setError(r,!0,this.getNetworkType()).end(),r;const f=Ir(p);if(o.setNetworkType(this.getNetworkType()).setMoreMessage(`helloInterval:${c} instanceID:${l} offset:${m} customStatus:${f}`).end(),e.setA2Key(a),e.setTinyID(u),e.setStatusInstanceID(l),e.setCustomStatus(f),h){this.getModule(Ss).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:h})}this.getModule(fs).updateProtocolConfig(),this.emitInnerEvent(Sn),this._helloInterval=c,this.triggerReady();const I=this.getModule(vs);I.canIUseOfflinePush()&&(uni.setStorageSync("timUniAppInstanceID",l),I.init()),this._fetchCloudControlConfig();return this.getModule(Ls).init(),s}).catch(e=>(this.probeNetwork().then(([t,s])=>{o.setError(e,t,s).end(!0)}),this._m.setNotReadyReason($i.LOGIN_FAILED),ge.e(n+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),yn(e)))}logout(e=0){if(!this.isLoggedIn())return yn({code:$i.USER_NOT_LOGGED_IN});new Qi("logout").setNetworkType(this.getNetworkType()).setMessage("identifier:"+this.getMyUserID()).end(!0);const t=this._n+".logout";return ge.i(`${t} type:${e}`),0===e&&this._m.setNotReadyReason($i.LOGGED_OUT),this.request({protocolName:Ps,requestData:{type:e}}).then(()=>(this.resetReady(),Tn({}))).catch(e=>(ge.e(t+" error:",e),this.resetReady(),Tn({})))}_fetchCloudControlConfig(){this.getModule(Ts).fetchConfig()}_getStatusInstanceID(){return uni.getStorageSync("timUniAppInstanceID")}_hello(){this._lastWsHelloTs=Date.now(),this.request({protocolName:ks,requestData:{isWebUniapp:this._isWebUniapp}}).catch(e=>{ge.w(this._n+"._hello error:",e)})}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return Ct(this.getModule(ls).getSDKAppID())?t=$i.NO_SDKAPPID:Ct(e.userID)?t=$i.NO_IDENTIFIER:Ct(e.userSig)&&(t=$i.NO_USERSIG),{code:t}}_isReactUIKit(){return k&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(s){new Qi("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:${JSON.stringify(s)}`).end(!0),ge.w(`${this._n}.onMultipleAccountKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_ACCOUNT}),this._m.setNotReadyReason($i.KICKED_OUT_MULT_ACCOUNT),this._m.reset()})}onMultipleDeviceKickedOut(s){new Qi("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_MULT_DEVICE} newInstanceInfo:${JSON.stringify(s)}`).end(!0),ge.w(`${this._n}.onMultipleDeviceKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_DEVICE}),this._m.setNotReadyReason($i.KICKED_OUT_MULT_DEVICE),this._m.reset()})}onUserSigExpired(){new Qi("kickedOut").setNetworkType(this.getNetworkType()).setMessage(t.KICKED_OUT_USERSIG_EXPIRED).end(!0),ge.w(this._n+".onUserSigExpired: userSig expired");0!==this.getModule(ls).getStatusInstanceID()&&(this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason($i.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(s){new Qi("kickedOut").setNetworkType(this.getNetworkType()).setMessage(`type:${t.KICKED_OUT_REST_API} newInstanceInfo:${JSON.stringify(s)}`).end(!0),ge.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s);if(0!==this.getModule(ls).getStatusInstanceID()){this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_REST_API}),this._m.setNotReadyReason($i.KICKED_OUT_REST_API),this._m.reset();this.getModule(Is).onRestApiKickedOut()}}reset(){ge.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function Er(){return null}class Sr{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){P||!Oe(window)&&this._canIUseCookies()||(this.getItem=Er,this.setItem=Er,this.removeItem=Er,this.clear=Er)}onCheckTimer(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}_doFlush(){try{for(const[e,t]of this._storageQueue)this._setStorageSync(this._getKey(e),t);this._storageQueue.clear()}catch(e){ge.w(this._n+"._doFlush error:",e)}}_getPrefix(){const e=this._m.getModule(ls);return`TIM_${e.getSDKAppID()}_${e.getUserID()}_`}_getKey(e){return`${this._getPrefix()}${e}`}getItem(e,t=!0){try{const s=t?this._getKey(e):e;return this.getStorageSync(s)}catch(s){return ge.w(this._n+".getItem error:",s),{}}}setItem(e,t,s=!1,o=!0){if(s){const s=o?this._getKey(e):e;this._setStorageSync(s,t)}else this._storageQueue.set(e,t)}clear(){try{P?b.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){ge.w(this._n+".clear error:",e)}}removeItem(e,t=!0){try{const s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(s){ge.w(this._n+".removeItem error:",s)}}getSize(e,t="b"){try{const s={size:0,limitSize:5242880,unit:t};if(Object.defineProperty(s,"leftSize",{enumerable:!0,get:()=>s.limitSize-s.size}),P&&(s.limitSize=1024*b.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(P){const{keys:e}=b.getStorageInfoSync();e.forEach(e=>{s.size+=JSON.stringify(this.getStorageSync(e)).length+this._getKey(e).length})}else if(this._canIUseCookies())for(const e in localStorage)localStorage.hasOwnProperty(e)&&(s.size+=localStorage.getItem(e).length+e.length);return this._convertUnit(s)}catch(s){ge.w(this._n+" error:",s)}}_convertUnit(e){const t={},{unit:s}=e;t.unit=s;for(const o in e)"number"==typeof e[o]&&("kb"===s.toLowerCase()?t[o]=Math.round(e[o]/1024):"mb"===s.toLowerCase()?t[o]=Math.round(e[o]/1024/1024):t[o]=e[o]);return t}_setStorageSync(e,t){P?N?my.setStorageSync({key:e,data:t}):b.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){if(P){if(N){return my.getStorageSync({key:e}).data}return b.getStorageSync(e)}return this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){P?N?my.removeStorageSync({key:e}):b.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return navigator&&navigator.cookieEnabled&&localStorage}reset(){ge.l(this._n+".reset"),this._doFlush()}}class vr{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){ge.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){Ne(e)&&0!==e.length&&(ge.d(this._n+".backfill",this._report.length,e.length),this._report.unshift(...e))}getLogsNumInMemory(){return this._report.length}isEmpty(){return 0===this._report.length}_reset(){this._report.length=0,this._report=[]}getLogsInMemory(){const e=this._report.slice();return this._reset(),e}}const Lr=function(e){const t=e.getModule(ls);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:ue()}};class Ar extends Gs{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new vr,this.MIN_THRESHOLD=20,this.MAX_THRESHOLD=100,this.WAITING_TIME=6e4,this.REPORT_LEVEL=[4,5,6],this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._lastReportTime=Date.now();const t=this.getInnerEmitterInstance();t.on(Sn,this._onLoginSuccess,this),t.on(vn,this._onCloudConfigUpdated,this)}reportAtOnce(){ge.d(this._n+".reportAtOnce"),this._report()}_onLoginSuccess(){const e=this.getModule(ds),t=e.getItem(this.TAG,!1);!Ct(t)&&Ue(t.forEach)&&(ge.l(`${this._n}._onLoginSuccess get ssolog in storage, count:${t.length}`),t.forEach(e=>{this._reportBody.pushIn(e)}),e.removeItem(this.TAG,!1))}_onCloudConfigUpdated(){const e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),s=this.getCloudConfig("evt_rpt_level"),o=this.getCloudConfig("evt_rpt_sdkappid_bl"),i=this.getCloudConfig("evt_rpt_tinyid_wl");Oe(e)||(this.MIN_THRESHOLD=Number(e)),Oe(t)||(this.WAITING_TIME=Number(t)),Oe(s)||(this.REPORT_LEVEL=s.split(",").map(e=>Number(e))),Oe(o)||(this.REPORT_SDKAPPID_BLACKLIST=o.split(",").map(e=>Number(e))),Oe(i)||(this.REPORT_TINYID_WHITELIST=i.split(","))}pushIn(e){e instanceof Qi&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}onCheckTimer(){Date.now()this.REPORT_LEVEL.includes(e.level))}_report(){if(this._reportBody.isEmpty())return;const e=this._reportBody.getLogsInMemory(),t=this._filterLogs(e);if(0===t.length)return void(this._lastReportTime=Date.now());const s={header:Lr(this),event:t};this.request({protocolName:pi,requestData:{...s}}).then(()=>{this._lastReportTime=Date.now()}).catch(t=>{ge.w(`${this._n}.report failed. networkType:${this.getNetworkType()} error:`,t),this._reportBody.backfill(e);this._reportBody.getLogsNumInMemory()>this.MAX_THRESHOLD&&this._flushAtOnce()})}_flushAtOnce(){const e=this.getModule(ds),t=e.getItem(this.TAG,!1),s=this._reportBody.getLogsInMemory(),o=this._n+"._flushAtOnce";if(Ct(t))ge.l(`${o} count:${s.length}`),e.setItem(this.TAG,s,!0,!1);else{let i=s.concat(t);i.length>this.MAX_THRESHOLD&&(i=i.slice(0,this.MAX_THRESHOLD)),ge.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}}reset(){ge.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}const Rr="none",Nr="online",Or=[$i.OVER_FREQUENCY_LIMIT,$i.OPEN_SERVICE_OVERLOAD_ERROR];class Gr{constructor(e){this._m=e,this._networkType="",this._n="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}start(){P?(b.getNetworkType({success:e=>{this._networkType=e.networkType||e.subtype||"",e.networkType===Rr?ge.w(this._n+".start no network, please check!"):ge.i(`${this._n}.start networkType:${e.networkType}`)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),b.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=Nr,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}_onWebOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:Nr})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Rr})}_onNetworkStatusChange(e){const{isConnected:t,networkType:s}=e,o=this._n+"._onNetworkStatusChange";let i=!1;if(t){if(ge.i(`${o} previous:${this._networkType} current:${s}`),this._networkType!==s){i=!0;this._m.getModule(Is).reConnect(!0)}}else if(this._networkType!==s){i=!0,ge.w(o+" no network, please check!");this._m.getModule(Is).offline()}if(i){new Qi("networkChange").setMessage(`isConnected:${t} previousNetworkType:${this._networkType} networkType:${s}`).end(),this._networkType=s}}probe(e){if(!Oe(e)&&Or.includes(e.code))return Promise.resolve([!0,this._networkType]);const t=this._n+".probe";return new Promise((e,s)=>{P?b.getNetworkType({success:s=>{this._networkType=s.networkType,s.networkType===Rr?(ge.w(t+" no network, please check!"),e([!1,s.networkType])):(ge.i(`${t} networkType:${s.networkType}`),e([!0,s.networkType]))}}):this._networkType===Rr?e([!1,Rr]):e([!0,Nr])})}getNetworkType(){return this._networkType}reset(){ge.l(this._n+".reset"),P?null!==this._mpNetworkStatusCallback&&(b.offNetworkStatusChange&&(G||A?b.offNetworkStatusChange(this._mpNetworkStatusCallback):b.offNetworkStatusChange()),this._mpNetworkStatusCallback=null):window&&(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null))}}function Ur(e,t){return e(t={exports:{}},t.exports),t.exports}var Pr=Ur((function(e){var t=Object.prototype.hasOwnProperty,s="~";function o(){}function i(e,t,s){this.fn=e,this.context=t,this.once=s||!1}function n(e,t,o,n,r){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new i(o,n||e,r),u=s?s+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(s=!1)),a.prototype.eventNames=function(){var e,o,i=[];if(0===this._eventsCount)return i;for(o in e=this._events)t.call(e,o)&&i.push(s?o.slice(1):o);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=s?s+e:e,o=this._events[t];if(!o)return[];if(o.fn)return[o.fn];for(var i=0,n=o.length,r=new Array(n);i{e.data.authKey&&(this._authKey=e.data.authKey,this._expireTime=parseInt(e.data.expireTime))})}_isFromOlderVersion(e){return!(!e.content||2===e.content.downloadFlag)}parseElements(e,t){if(!Ne(e)||!t)return[];const s=[];let o=null;for(let i=0;i{const{data:i}=o;ge.l(e+" ok. data:",i);const n=i.expiredTime-s;t.setMessage(`requestId:${i.requestId} requestTime:${s} expiredTime:${i.expiredTime} diff:${n}s`).setNetworkType(this.getNetworkType()).end(),!P&&i.region&&(this.region=i.region),this.appid=i.appid,this.bucketName=i.bucketName,this.ciUrl=i.ciUrl,this.directory=i.directory,this.downloadUrl=i.downloadUrl,this.uploadUrl=i.uploadUrl,this.cosOptions={secretId:i.secretId,secretKey:i.secretKey,sessionToken:i.sessionToken,expiredTime:i.expiredTime},ge.l(`${e} ok. region:${this.region} bucketName:${this.bucketName}`),this._initUploaderMethod()}).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),ge.w(e+" failed. error:",s)})}_getCosPreSigUrl(e){const t=this._n+"._getCosPreSigUrl",s=Math.ceil(Date.now()/1e3),o=new Qi("_getCosPreSigUrl");return this.request({protocolName:li,requestData:{fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration}}).then(e=>{this.tryCount=0;const i=e.data||{},n=i.expiredTime-s;return ge.l(t+" ok. data:",i),o.setMessage(`requestId:${i.requestId} expiredTime:${i.expiredTime} diff:${n}s`).setNetworkType(this.getNetworkType()).end(),i}).catch(s=>(-1===s.code&&(s.code=$i.COS_GET_SIG_FAIL),this.probeNetwork().then(([e,t])=>{o.setError(s,e,t).end()}),ge.w(t+" failed. error:",s),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(e)):(this.tryCount=0,yn({code:$i.COS_GET_SIG_FAIL}))))}_initUploaderMethod(){if(this.TIMUploadPlugin)return this.timUploadPlugin=new this.TIMUploadPlugin,void(this._cosUploadMethod=(e,t)=>{this.timUploadPlugin.uploadFile(e,t)});this.appid&&(this.cos=P?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=P?(e,t)=>{this.cos.postObject(e,t)}:(e,t)=>{this.cos.uploadFiles(e,t)})}onCheckTimer(e){if(!this.COSSDK)return;if(this.TIMUploadPlugin)return;if(!this.isLoggedIn())return;if(e%60!=0)return;Math.ceil(Date.now()/1e3)>=this.cosOptions.expiredTime-120&&this._getAuthorizationKey()}_getAuthorization(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}upload(e){if(!0===e.getRelayFlag())return Promise.resolve();const s=this.getModule(Es);switch(e.type){case t.MSG_IMAGE:return s.addTotalCount(Ki),this._uploadImage(e);case t.MSG_FILE:return s.addTotalCount(Ki),this._uploadFile(e);case t.MSG_AUDIO:return s.addTotalCount(Ki),this._uploadAudio(e);case t.MSG_VIDEO:return s.addTotalCount(Ki),this._uploadVideo(e);default:return Promise.resolve()}}_uploadImage(e){const t=this.getModule(ts),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadImage({file:o.payload.file,to:o.to,onProgress:e=>{if(s.updatePercent(e),Ue(o.onProgress))try{o.onProgress(e)}catch(t){return yn({code:$i.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t,fileType:o,fileSize:i,width:n,height:r,smallImageUrl:a,smallImageWidth:u,smallImageHeight:c,largeImageUrl:l,largeImageWidth:d,largeImageHeight:p})=>{const h=this.isPrivateNetWork()?t:Ke(t);let g,_;return s.updateImageFormat(o),a&&l?(g={url:a,width:u,height:c},_={url:l,width:d,height:p}):(g=rt({originUrl:h,originWidth:n,originHeight:r,min:198}),_=rt({originUrl:h,originWidth:n,originHeight:r,min:720})),s.updateImageInfoArray([{size:i,url:h,width:n,height:r},{..._},{...g}]),e})}_uploadFile(e){const t=this.getModule(ts),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadFile({file:o.payload.file,to:o.to,onProgress:e=>{if(s.updatePercent(e),Ue(o.onProgress))try{o.onProgress(e)}catch(t){return yn({code:$i.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:Ke(t);return s.updateFileUrl(o),e})}_uploadAudio(e){const t=this.getModule(ts),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadAudio({file:o.payload.file,to:o.to,onProgress:e=>{if(s.updatePercent(e),Ue(o.onProgress))try{o.onProgress(e)}catch(t){return yn({code:$i.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:t})=>{const o=this.isPrivateNetWork()?t:Ke(t);return s.updateAudioUrl(o),e})}_uploadVideo(e){const t=this.getModule(ts),s=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadVideo({file:o.payload.file,to:o.to,onProgress:e=>{if(s.updatePercent(e),Ue(o.onProgress))try{o.onProgress(e)}catch(t){return yn({code:$i.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then(t=>{const{location:o,snapshotInfo:i}=t,n=this.isPrivateNetWork()?o:Ke(o);return s.updateVideoUrl(n),Ct(i)||s.updateSnapshotInfo(i),e})}_checkSizeError(e){return yn({code:$i[`MESSAGE_${e}_SIZE_LIMIT`],message:this.getErrorMessage("UploadSizeLimit",e.toLowerCase(),this.UPLOAD_SIZE_LIMIT[e]/1048576+" MB")})}doUploadImage(e){if(!e.file)return yn({code:$i.MESSAGE_IMAGE_SELECT_FILE_FIRST});const t=this._checkImageType(e.file);if(!0!==t)return t;const s=this._checkImageSize(e.file);if(!0!==s)return s;let o=null;return this._setUploadFileType(On),this.uploadByCOS(e).then(e=>(o=e,this.isPrivateNetWork()?st(e.location):st("https://"+e.location))).then(e=>(o.width=e.width,o.height=e.height,Promise.resolve(o)))}_checkImageType(e){let t="";return t=P?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),Rn.indexOf(t.toLowerCase())>=0||yn({code:$i.MESSAGE_IMAGE_TYPES_LIMIT})}_checkImageSize(e){let t=0;return t=P?e.size:e.files[0].size,0===t?yn({code:$i.MESSAGE_FILE_IS_EMPTY}):tthis.UPLOAD_SIZE_LIMIT.FILE?this._checkSizeError("FILE"):0===e.file.files[0].size?(t={code:$i.MESSAGE_FILE_IS_EMPTY},yn(t)):(this._setUploadFileType(Pn),this.uploadByCOS(e)):(t={code:$i.MESSAGE_FILE_SELECT_FILE_FIRST},yn(t))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.VIDEO?this._checkSizeError("VIDEO"):0===e.file.videoFile.size?yn({code:$i.MESSAGE_FILE_IS_EMPTY}):-1===Nn.indexOf(e.file.videoFile.type)?yn({code:$i.MESSAGE_VIDEO_TYPES_LIMIT}):(this._setUploadFileType(Gn),P?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):k?this.handleVideoUpload(e):void 0)}handleVideoUpload(e){return new Promise((t,s)=>{this.uploadByCOS(e).then(e=>{t(e)}).catch(()=>{this.uploadByCOS(e).then(e=>{t(e)}).catch(()=>{s(new fn({code:$i.MESSAGE_VIDEO_UPLOAD_FAIL}))})})})}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.AUDIO?this._checkSizeError("AUDIO"):0===e.file.size?yn({code:$i.MESSAGE_FILE_IS_EMPTY}):(this._setUploadFileType(Un),this.uploadByCOS(e)):yn({code:$i.MESSAGE_AUDIO_UPLOAD_FAIL})}uploadByCOS(e){if(!Ue(this._cosUploadMethod))return this.outputWarning("PluginUndetected"),yn({code:$i.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);const t=new Qi("upload"),s=this._n+".uploadByCOS",o=Date.now(),i=this._getFile(e);return new Promise((n,r)=>{const a=P?this._createCosOptionsWXMiniApp(e):this._createCosOptionsWeb(e),u=this;this._cosUploadMethod(a,(e,a)=>{const c=Object.create(null);if(a){if(e||Ne(a.files)&&a.files[0].error){const e=new fn({code:$i.MESSAGE_FILE_UPLOAD_FAIL});return t.setError(e,!0,this.getNetworkType()).end(),ge.l(s+" failed. error:",a.files[0].error),403===a.files[0].error.statusCode&&(ge.w(s+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),void r(e)}c.fileName=i.name,c.fileSize=i.size,c.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),c.location=P?a.Location:a.files[0].data.Location;const l=Date.now()-o,d=`size:${u._formatFileSize(i.size)} time:${l}ms speed:${u._formatSpeed(1e3*i.size/l)}`;ge.l(`${s} success. name:${i.name} ${d}`),n(c);const p=this.getModule(Es);return p.addCost(Ki,l),p.addFileSize(Ki,i.size),void t.setNetworkType(this.getNetworkType()).setMessage(d).end()}const l=new fn({code:$i.MESSAGE_FILE_UPLOAD_FAIL});t.setError(l,!0,u.getNetworkType()).end(),ge.w(s+" failed. error:",e),403===e.statusCode&&(ge.w(s+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),r(l)})})}_uploadWithPreSigUrl(e){const t=this._n+"._uploadWithPreSigUrl",s=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then(e=>new Promise((o,i)=>{const n=new Qi("upload"),{requestSnapshotUrl:r,...a}=e,u=Date.now();this._cosUploadMethod(a,(e,c)=>{if(e||403===c.statusCode)return n.setError(new fn(e),!0,this.getNetworkType()).end(),ge.l(t+" failed, error:",e),void i(new fn({code:$i.MESSAGE_FILE_UPLOAD_FAIL}));const l=Object.create(null);let d=c.data.location||"";this.isPrivateNetWork()||0!==d.indexOf("https://")&&0!==d.indexOf("http://")||(d=d.split("//")[1]),l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=d;const p=Date.now()-u,h=`size:${this._formatFileSize(s.size)},time:${p}ms,speed:${this._formatSpeed(1e3*s.size/p)} res:${JSON.stringify(c.data)}`;ge.l(`${t} success name:${s.name},${h}`),n.setNetworkType(this.getNetworkType()).setMessage(h).end();const g=this.getModule(Es);g.addCost(Ki,p),g.addFileSize(Ki,s.size);let _=[];if(a.thumbUrl&&a.largeUrl&&(_=[this._getSmallImageInfoByUrl(a.thumbUrl,l),this._getLargeImageInfoByUrl(a.largeUrl,l)]),r&&_.push(this._getSnapshotInfoByUrl(r,l)),_.length>0)return Promise.all(_).then(()=>{o(l)});o(l)})}))}_getRawOrUploadProxyUrl(e){const t=this.getModule(ls).getFileUploadProxy();let s=e;return t&&(s=e.replace(/^https:\/\/[^/]+/,t)),s}_getFile(e){let t=null;var s;return t=Ne(e.file.files)||(s=e.file.files,"filelist"===ke(s))?e.file.files[0]:e.file,t}_formatFileSize(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}_formatSpeed(e){if(e<=1048576){return ct(e/1024,1)+"KB/s"}return ct(e/1048576,1)+"MB/s"}_createCosOptionsWeb(e){const t=this._getFile(e),s=t.name,o=s.slice(s.lastIndexOf(".")),i=this._genFileName(`${qe(999999)}${o}`);return{files:[{Bucket:`${this.bucketName}-${this.appid}`,Region:this.region,Key:`${this.directory}/${i}`,Body:t}],SliceSize:1048576,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){ge.w("onProgress callback error:",s)}},onFileFinish:(e,t,s)=>{}}}_createCosOptionsWXMiniApp(e){const t=this._getFile(e),s=this._genFileName(t.name),o=t.url;return{Bucket:`${this.bucketName}-${this.appid}`,Region:this.region,Key:`${this.directory}/${s}`,FilePath:o,onProgress:t=>{if(ge.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){ge.w("onProgress callback error:",s)}}}}_createCosOptionsPreSigUrl(e){let t="",s="",o=0;const i=this._getFile(e);if(P)t=this._genFileName(i.name),s=i.url,o=1;else{const e=i.name,n=e.slice(e.lastIndexOf("."));t=this._genFileName(`${qe(999999)}${n}`),s=i,o=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:t,uploadMethod:o,duration:this.duration}).then(o=>{const{uploadUrl:i,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:u}=o;return{url:this._getRawOrUploadProxyUrl(i),fileType:this.uploadFileType,fileName:t,resources:s,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:u,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(s){ge.w("onProgress callback error:",s),ge.e(s)}}}})}_genFileName(e){return`${ot()}-${e}`}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,t){const s=new Qi("getSnapshotInfo");return this.request({protocolName:di,requestData:{platform:this.getPlatform(),coverName:this._genFileName(qe(99999)),requestSnapshotUrl:e}}).then(e=>{const{snapshotUrl:o}=e.data||{};return s.setMessage("snapshotUrl:"+o).end(),Ct(o)?{}:st(o).then(e=>{t.snapshotInfo={snapshotUrl:o,snapshotWidth:e.width,snapshotHeight:e.height}})}).catch(e=>(ge.w(this._n+"._getSnapshotInfoByUrl failed. error:",e),s.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}))}_getSmallImageInfoByUrl(e,t){return st(e).then(s=>{t.smallImageUrl=e,t.smallImageWidth=s.width,t.smallImageHeight=s.height})}_getLargeImageInfoByUrl(e,t){return st(e).then(s=>{t.largeImageUrl=e,t.largeImageWidth=s.width,t.largeImageHeight=s.height})}reset(){ge.l(this._n+".reset")}}class wr{constructor(e){this._n="MergerMessageHandler",this._messageModule=e}uploadMergerMessage(e,t){const s=this._n+".uploadMergerMessage";ge.d(s+" message:",e,"messageBytes:"+t);const{messageList:o}=e.payload,i=o.length,n=new Qi("uploadMergerMessage");return this._messageModule.request({protocolName:fi,requestData:{messageList:o}}).then(e=>{ge.d(s+" ok. response:",e.data);const{pbDownloadKey:o,downloadKey:r}=e.data,a={pbDownloadKey:o,downloadKey:r,messageNumber:i};return n.setNetworkType(this._messageModule.getNetworkType()).setMessage(`${i}-${t}-${r}`).end(),a}).catch(e=>{throw ge.w(s+" failed. error:",e),this._messageModule.probeNetwork().then(([t,s])=>{n.setError(e,t,s).end()}),e})}downloadMergerMessage(e){const t=this._n+".downloadMergerMessage";ge.d(t+" message:",e);const{downloadKey:s}=e.payload,o=this._messageModule.getFileDownloadProxy(),i=new Qi("downloadMergerMessage");return i.setMessage("downloadKey:"+s),this._messageModule.request({protocolName:Ii,requestData:{downloadKey:s}}).then(s=>{if(ge.d(t+" ok. response:",s.data),Ue(e.clearElement)){const{downloadKey:t,pbDownloadKey:i,messageList:n,...r}=e.payload;e.clearElement(),e.setElement({type:e.type,content:{messageList:s.data.messageList,...r}},o)}else{const t=[];s.data.messageList.forEach(e=>{if(!Ct(e)){const s=new hn(e,o);t.push(s)}}),e.payload.messageList=t,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return i.setNetworkType(this._messageModule.getNetworkType()).end(),e}).catch(e=>{throw ge.w(`${t} failed. key:${s} error:`,e),this._messageModule.probeNetwork().then(([t,s])=>{i.setError(e,t,s).end()}),e})}createMergerMessagePack(e,s,o){return e.conversationType===t.CONV_C2C?this._createC2CMergerMessagePack(e,s,o):this._createGroupMergerMessagePack(e,s,o)}_createC2CMergerMessagePack(e,t,s){let o=null;t&&(t.offlinePushInfo&&(o=t.offlinePushInfo),!0===t.onlineUserOnly&&(o?o.disablePush=!0:o={disablePush:!0}));const i=[];if(Re(t)&&Re(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}let n="";Le(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:u}=s,{title:c,abstractList:l,compatibleText:d}=e.payload,p=this._messageModule.getModule(is),h=p&&p.isOnlineMessage(e,t)?0:void 0;return{protocolName:Fs,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:c,abstractList:l,compatibleText:d,messageNumber:u}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:h,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,messageControlInfo:0!==h?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0}}}_createGroupMergerMessagePack(e,t,s){let o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);const i=[];if(Re(t)&&Re(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:o}=t.messageControlInfo;!0===e&&i.push("NoUnread"),!0===s&&i.push("NoLastMsg"),!0===o&&i.push("NoMsgCheck")}let n="";Le(e.cloudCustomData)&&e.cloudCustomData.length>0&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:u}=s,{title:c,abstractList:l,compatibleText:d}=e.payload,p=this._messageModule.getModule(ns),h=p&&p.isOnlineMessage(e,t)?1:0;return{protocolName:qs,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:c,abstractList:l,compatibleText:d,messageNumber:u}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:h,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||p.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0===h?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0}}}}const $r={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},Fr=[$i.MESSAGE_ONPROGRESS_FUNCTION_ERROR,$i.MESSAGE_IMAGE_SELECT_FILE_FIRST,$i.MESSAGE_IMAGE_TYPES_LIMIT,$i.MESSAGE_FILE_IS_EMPTY,$i.MESSAGE_IMAGE_SIZE_LIMIT,$i.MESSAGE_FILE_SELECT_FILE_FIRST,$i.MESSAGE_FILE_SIZE_LIMIT,$i.MESSAGE_VIDEO_SIZE_LIMIT,$i.MESSAGE_VIDEO_TYPES_LIMIT,$i.MESSAGE_AUDIO_UPLOAD_FAIL,$i.MESSAGE_AUDIO_SIZE_LIMIT,$i.COS_UNDETECTED];function qr(e){let t=!1;return Object.values($r).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}class xr extends Gs{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new wr(this)}createTextMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e),o="string"==typeof e.payload?e.payload:e.payload.text,i=new en({text:o}),n=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(n),s.setNameCard(this._getNameCardByGroupID(s)),s}createImageMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e);if(P){const{file:t}=e.payload;if(Se(t))return void this.outputWarning("FileUnsupportedInMP","createImageMessage");const s=t.tempFiles[0].path||t.tempFiles[0].tempFilePath,o={url:s,name:s.slice(s.lastIndexOf("/")+1),size:t.tempFiles&&t.tempFiles[0].size||1,type:s.slice(s.lastIndexOf(".")+1).toLowerCase()};e.payload.file=o}else if(k)if(Se(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Re(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFiles[0];e.payload.file={files:[t]}}const o=new tn({imageFormat:_e.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createAudioMessage(e){const{file:t}=e.payload;if(P){const s={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}const s=this.getMyUserID();e.currentUser=s,e.senderTinyID=this.getMyTinyID();const o=new mn(e),i=new on({second:Math.floor(t.duration/1e3),size:t.fileSize||t.size,url:t.tempFilePath,uuid:this._generateUUID(e.payload.file)}),n=this._getNickAndAvatarByUserID(s);return o.setElement(i),o.setNickAndAvatar(n),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}createVideoMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="",e.payload.file.thumbSize=0;const s={};if(P){if(N)return void this.outputWarning("VideoUnsupportedInAlipay");if(Se(e.payload.file))return void this.outputWarning("FileUnsupportedInMP","createVideoMessage");let{file:t}=e.payload;Ne(t.tempFiles)&&(t=t.tempFiles[0]),s.url=t.tempFilePath,s.name=t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),s.size=t.size||1,s.second=t.duration||0,s.type=t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(k){if(Se(e.payload.file)){const t=e.payload.file;e.payload.file.files=[t]}else if(Re(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFile;e.payload.file.files=[t]}const{file:t}=e.payload;s.url=window.URL.createObjectURL(t.files[0]),s.name=t.files[0].name,s.size=t.files[0].size||1,s.second=t.files[0].duration||0,s.type=t.files[0].type.split("/")[1]}e.payload.file.videoFile=s;const o=new mn(e),i=new dn({videoFormat:s.type,videoSecond:ct(s.second,0),videoSize:s.size,remoteVideoUrl:"",videoUrl:s.url,videoUUID:this._generateUUID(e.payload.file.videoFile),thumbUUID:this._generateUUID(e.payload.file.videoFile),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),n=this._getNickAndAvatarByUserID(t);return o.setElement(i),o.setNickAndAvatar(n),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}createCustomMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e),o=new ln({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}createFaceMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e),o=new sn(e.payload),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}createMergerMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=this._getNickAndAvatarByUserID(t),o=new mn(e),i=new gn(e.payload);return o.setElement(i),o.setNickAndAvatar(s),o.setNameCard(this._getNameCardByGroupID(o)),o.setRelayFlag(!0),o}createForwardMessage(e){const{to:s,conversationType:o,priority:i,payload:n,needReadReceipt:r,receiverList:a}=e,u=this.getMyUserID(),c=this._getNickAndAvatarByUserID(u);if(n.type===t.MSG_GRP_TIP)return yn({code:$i.MESSAGE_FORWARD_TYPE_INVALID});const l={to:s,conversationType:o,conversationID:`${o}${s}`,priority:i,isPlaceMessage:0,status:Dt.UNSEND,currentUser:u,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||n.cloudCustomData||"",needReadReceipt:r,receiverList:a,isSupportExtension:e.isSupportExtension||!1},d=new mn(l);return d.setElement(n.getElements()[0]),d.setNickAndAvatar(c),d.setNameCard(this._getNameCardByGroupID(n)),d.setRelayFlag(!0),d}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(e){if(P){if(!S&&!L&&!G)return;let e;const t=b.getSystemInfoSync().SDKVersion;if(S&&(e="2.5.0",nt(t,e)<0))return void this.outputWarning("WXChooseMessageFile");if(L&&(e="1.18.0",nt(t,e)<0))return void this.outputWarning("QQChooseMessageFile")}if(k||G){if(Se(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(Re(e.payload.file)&&"undefined"!=typeof uni){const{tempFiles:t,files:s}=e.payload.file;let o=null;Ne(t)?o=t[0]:Ne(s)&&(o=s[0]),e.payload.file={files:[o]}}}else if(S||L){const{tempFiles:t}=e.payload.file,s={...t[0],url:t[0].path};e.payload.file={files:[s]}}const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e),o=new cn({uuid:this._generateUUID(e.payload.file),file:e.payload.file}),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createLocationMessage(e){const t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new mn(e),o=new pn(e.payload),i=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(i),s.setNameCard(this._getNameCardByGroupID(s)),s}_onCannotFindModule(){return yn({code:$i.CANNOT_FIND_MODULE})}sendMessageInstance(e,s){if(!1===this.getModule(Ls).filterMessage(e,s))return this._onSendMessageFailed(e,new fn({code:$i.PROFANITY_FOUND}));let o,i=null;switch(e.conversationType){case t.CONV_C2C:if(i=this.getModule(is),!i)return this._onCannotFindModule();break;case t.CONV_GROUP:if(i=this.getModule(ns),!i)return this._onCannotFindModule();if(ze({groupID:e.to})){const t=i.getLocalGroupProfile(e.to);if(t&&t.isSupportTopic)return yn({code:$i.MESSAGE_SEND_GROUP_WITH_TOPIC_FAIL})}break;default:return yn({code:$i.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}const n=this.getModule(_s),r=this.getModule(ns);return n.upload(e).then(()=>{if(this._getSendMessageSpecifiedKey(e)===Hi){this.getModule(Es).addSuccessCount(Ki)}return r.guardForAVChatRoom(e).then(()=>{if(!e.isSendable())return yn({code:$i.MESSAGE_FILE_URL_IS_EMPTY});this._addSendMessageTotalCount(e),o=Date.now();const n=function(e){let t="utf-8";k&&document&&(t=document.charset.toLowerCase());let s,o=0,i=0;if(i=e.length,"utf-8"===t||"utf8"===t)for(let n=0;n11264)return this._mergerMessageHandler.uploadMergerMessage(e,n).then(t=>{const o=this._mergerMessageHandler.createMergerMessagePack(e,s,t);return this.request(o)});return this.getModule(cs).setMessageRandom(e),e.conversationType===t.CONV_C2C||e.conversationType===t.CONV_GROUP?i.sendMessage(e,s):void 0}).then(n=>{const{time:r,sequence:a,readReceiptCode:u}=n.data;if(ve(u)&&0!==u){new Qi("sendMessageWithReceipt").setMessage(`from:${e.from} to:${e.to} sequence:${a} readReceiptCode:${u}`).end(),ge.w(`${this._n}.sendMessageInstance readReceiptCode:${u} message:${this.getErrorMessage(u)}`)}this._addSendMessageSuccessCount(e,o),this._messageOptionsMap.delete(e.clientSequence);const c=this.getModule(cs);e.status=Dt.SUCCESS,e.time=r;let l=!1;if(e.conversationType===t.CONV_GROUP)e.sequence=a;else if(e.conversationType===t.CONV_C2C){const t=c.getLatestMessageSentByMe(e.conversationID);if(t){const{nick:s,avatar:o}=t;s===e.nick&&o===e.avatar||(l=!0)}}if(l&&c.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),i.isOnlineMessage(e,s))e._onlineOnlyFlag=!0;else{c.appendToMessageList(e);let o=e;Re(s)&&Re(s.messageControlInfo)&&(!0===s.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,o=""),!0===s.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));let i=e.conversationType;if(Je(e.to)){i=t.CONV_TOPIC;this.getModule(us).onMessageSent({groupID:pt(e.to),topicID:e.to,lastMessage:o})}c.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:i,subType:e.conversationSubType,lastMessage:o}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||at(e.payload.imageInfoArray),Mn({message:e})})}).catch(t=>this._onSendMessageFailed(e,t))}_onSendMessageFailed(e,t){e.status=Dt.FAIL;this.getModule(cs).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);const s=new Qi("sendMessage");return s.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:${e.to}`),this.probeNetwork().then(([e,o])=>{s.setError(t,e,o).end()}),ge.e(this._n+"._onSendMessageFailed error:",t),yn(new fn({code:t&&t.code?t.code:$i.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if([t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_VIDEO,t.MSG_FILE].includes(e.type))return Hi;if(e.conversationType===t.CONV_C2C)return xi;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ns).getLocalGroupProfile(e.to);if(!t)return;const s=t.type;return je(s)?Bi:Vi}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(Es).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=Math.abs(Date.now()-t),o=this._getSendMessageSpecifiedKey(e);if(o){const e=this.getModule(Es);e.addSuccessCount(o),e.addCost(o,s)}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(Es),i=this._getSendMessageSpecifiedKey(e);i===Hi&&function(e){let t=!1;return Fr.includes(e)&&(t=!0),t}(s)?o.addFailedCountOfUserSide(Ki):qr(s)&&i&&o.addFailedCountOfUserSide(i)}resendMessage(e){return e.isResend=!0,e.status=Dt.UNSEND,this.sendMessageInstance(e)}revokeMessage(e){let s=null;if(e.conversationType===t.CONV_C2C?s=this.getModule(is):e.conversationType===t.CONV_GROUP&&(s=this.getModule(ns)),!s)return this._onCannotFindModule();const o=new Qi("revokeMessage");o.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:${e.to}`);const i=this._n+".revokeMessage";return s.revokeMessage(e).then(t=>{const s=t.data.recallRetList;if(!Ct(s)&&0!==s[0].retCode){const t=new fn({code:s[0].retCode,data:{message:e}});return o.setCode(t.code).setMoreMessage(t.message).end(),yn(t)}ge.i(`${i} ok. ID:${e.ID}`),e.isRevoked=!0,o.end();return this.getModule(cs).onMessageRevoked([e]),Mn({message:e})}).catch(t=>{this.probeNetwork().then(([e,s])=>{o.setError(t,e,s).end()});const s=new fn({code:t&&t.code?t.code:$i.MESSAGE_REVOKE_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}});return ge.w(i+" failed. error:",t),yn(s)})}deleteMessage(e){let s=null;const o=e[0],i=o.conversationID;let n="",r=[],a=[];if(o.conversationType===t.CONV_C2C)s=this.getModule(is),n=i.replace(t.CONV_C2C,""),e.forEach(e=>{e&&e.status===Dt.SUCCESS&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(`${e.sequence}_${e.random}_${e.time}`),a.push(e))});else if(o.conversationType===t.CONV_GROUP)s=this.getModule(ns),n=i.replace(t.CONV_GROUP,""),e.forEach(e=>{e&&e.status===Dt.SUCCESS&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(""+e.sequence),a.push(e))});else if(o.conversationType===t.CONV_SYSTEM)return yn({code:$i.CANNOT_DELETE_GROUP_SYSTEM_NOTICE});if(!s)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(a);r.length>30&&(r=r.slice(0,30),a=a.slice(0,30));const u=new Qi("deleteMessage");u.setMessage(`to:${n} count:${r.length}`);const c=this._n+".deleteMessage";return s.deleteMessage({to:n,keyList:r}).then(e=>(u.end(),ge.i(c+" ok"),this._onMessageDeleted(a))).catch(e=>{this.probeNetwork().then(([t,s])=>{u.setError(e,t,s).end()}),ge.w(c+" failed. error:",e);const t=new fn({code:e&&e.code?e.code:$i.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:void 0});return yn(t)})}_onMessageDeleted(e){return this.getModule(cs).onMessageDeleted(e),Tn({messageList:e})}translateText(e){const t=this._n+".translateText",{sourceTextList:s,sourceLanguage:o,targetLanguage:i}=e,n=new Qi("translateText");return n.setMessage(`sourceLanguage:${o} targetLanguage:${i}`),this.request({protocolName:wi,requestData:{sourceTextList:s,source:o||"auto",target:i,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then(e=>{const{error:s,requestID:o,translatedTextList:i}=e.data,{code:r}=s;if(0===r)return n.end(),ge.i(`${t} ok. requestID:${o}`),Mn({translatedTextList:i});throw{...s,requestID:o}}).catch(e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),ge.w(t+" failed. error:",e),yn({code:$i.TRANSLATE_TEXT_FAIL})))}modifyRemoteMessage(e){let s=null;const{conversationType:o,to:i}=e;if(this.getModule(ns).isMessageFromOrToAVChatroom(i))return yn({code:$i.MESSAGE_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:e}});if(!1===this.getModule(Ls).filterMessage(e))return yn({code:$i.PROFANITY_FOUND,data:{message:e}});o===t.CONV_C2C?s=this.getModule(is):o===t.CONV_GROUP&&(s=this.getModule(ns));const n=new Qi("modifyMessage");n.setMessage("to:"+i);const r=this._n+".modifyRemoteMessage";return s.modifyRemoteMessage(e).then(t=>{n.end(),ge.i(r+" ok");const s=this._onModifyRemoteMessageResp(e,t.data);return Mn({message:s})}).catch(t=>{if(n.setCode(t.code).setMoreMessage(t.message).end(),ge.w(r+" failed. error:",t),20027===t.code){const s=this._onModifyRemoteMessageResp(e,t.data);return yn({code:$i.MESSAGE_MODIFY_CONFLICT,data:{message:s}})}return yn({code:t.code,message:t.message,data:{message:e}})})}_onModifyRemoteMessageResp(e,t){ge.d(this._n+"._onModifyRemoteMessageResp options:",t);const{conversationType:s,from:o,to:i,random:n,sequence:r,time:a}=e,{elements:u,messageVersion:c,cloudCustomData:l=""}=t;return this.getModule(cs).onMessageModified({conversationType:s,from:o,to:i,time:a,random:n,sequence:r,elements:u,cloudCustomData:l,messageVersion:c})}_generateUUID(e){const t=this.getModule(ls);let s=`${t.getSDKAppID()}-${t.getUserID()}-${function(){let e="";for(let t=32;t>0;--t)e+=xe[Math.floor(Math.random()*Ve)];return e}()}`;const o=e.name||e.value||e.url||e.tempFilePath,i=o&&o.slice(o.lastIndexOf(".")+1);return i&&(s=`${s}.${i}`),s}getMessageOption(e){return this._messageOptionsMap.get(e)}_getNickAndAvatarByUserID(e){return this.getModule(os).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(e){if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ns);if(t)return t.getMyNameCardByGroupID(e.to)}return""}reset(){ge.l(this._n+".reset"),this._messageOptionsMap.clear()}}class Vr extends Gs{constructor(e){super(e),this._n="MessageExtensionModule",this.messageExtensionMap=new Map,this.globalSeqMap=new Map,this.getMessageExtensionsMap=new Map}onMessageExtensionNotify(t){const{messageInfo:s,operateType:o,operateResultList:i,tinyID:n,globalSequence:r}=t.dataList,{clientTime:a,random:u}=s,c=`${n}-${a}-${u}`,l=[],d=[];ge.l(`${this._n}.onMessageExtensionNotify messageID:${c} operateType:${o} globalSequence:${r}`),this._updateGlobalSequence(c,r);let p=!1,h=!1;i.forEach(e=>{const{extensions:t=[],clearSequence:s}=e;if(1===o)p=!0,t.forEach(e=>{l.push({key:e.key,value:e.value})}),this._updateLocalExtension(c,t);else if(2===o)h=!0,t.forEach(e=>{d.push(e.key)}),this._updateLocalExtension(c,t);else if(3===o){if(h=!0,this._hasLocalExtension(c)){this._getLocalExtension(c).forEach((e,t)=>{e.seq<=s&&!Ct(e.value)&&d.push(t)})}this._clearLocalExtension(c,s)}}),p&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_UPDATED,{messageID:c,extensions:l}),h&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_DELETED,{messageID:c,keyList:d})}setMessageExtensions(e,t){if(!this.canIUse(M.MSG_EXT))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".setMessageExtensions",{ID:o,conversationID:i,sequence:n,time:r}=e;let a=[...t];t.length>20&&(a=t.slice(0,20),ge.w(s+". the length of extensions cannot exceed 20."));const u=`conversationID:${i} messageID:${o} sequence:${n} time:${r} count:${a.length}`,c=new Qi("setMessageExtensions");return c.setMessage(u),ge.l(`${s} ${u}`),this._modifyMessageExtensions(e,a).then(e=>{const{resultList:t,successCount:o,failureCount:i}=e,n=`success count:${o} fail count:${i}`;return c.setMoreMessage(n).end(),ge.l(`${s} ok. ${n}`),Mn({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{c.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}getMessageExtensions(e){if(!this.canIUse(M.MSG_EXT))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const t=this._n+".getMessageExtensions",{ID:s,conversationID:o,sequence:i,time:n}=e,r=`conversationID:${o} messageID:${s} sequence:${i} time:${n}`,a=new Qi("getMessageExtensions");a.setMessage(r),ge.l(`${t} ${r}`);let u=void 0;return this.getMessageExtensionsMap.has(s)&&(u=this._getGlobalSequence(s)),this._getMessageExtensions(e,u).then(e=>(a.end(),ge.l(`${t} ok. total count:${e.length}`),Oe(u)&&e.length>0&&this.getMessageExtensionsMap.set(s,1),Mn({extensions:e}))).catch(e=>(this.probeNetwork().then(([t,s])=>{a.setError(e,t,s).end()}),ge.e(t+" failed. error:",e),yn(e)))}deleteMessageExtensions(e,t){if(!this.canIUse(M.MSG_EXT))return yn({code:$i.CANNOT_USE_COMMERCIAL_ABILITY});const s=this._n+".deleteMessageExtensions",o=[];let i=3;Ct(t)||(i=2,t.forEach(e=>{o.push({key:e,value:"",seq:0})}));const{ID:n,conversationID:r,sequence:a,time:u}=e,c=`conversationID:${r} messageID:${n} sequence:${a} time:${u} operateType:${i}`,l=new Qi("deleteMessageExtensions");return l.setMessage(c),ge.l(`${s} ${c}`),this._modifyMessageExtensions(e,o,i).then(e=>{const{resultList:t,successCount:o,failureCount:n}=e;let r="";return 2===i&&(r=`success count:${o} fail count:${n}`),l.setMoreMessage(""+r).end(),ge.l(`${s} ok. ${r}`),Mn({extensions:t})}).catch(e=>(this.probeNetwork().then(([t,s])=>{l.setError(e,t,s).end()}),ge.e(s+" failed. error:",e),yn(e)))}_modifyMessageExtensions(e,s,o=1){const i=Je(e.to)?t.CONV_TOPIC:e.conversationType;let n=void 0;3!==o&&(n=this._getRequestExtensions(e,s));let r=null;switch(i){case t.CONV_C2C:r=this.getModule(is);break;case t.CONV_GROUP:r=this.getModule(ns);break;case t.CONV_TOPIC:r=this.getModule(us);break;default:return yn({code:$i.CANNOT_FIND_MODULE})}return r.modifyMessageExtensions(e,n,o).then(t=>{let{extensions:s,seq:o}=t.data;const i=[];let n=0,r=0,a=[];return s=Ct(s)?[]:s,s.forEach(e=>{const{errorCode:t,extension:s}=e,{key:o,value:u,seq:c}=s;i.push({code:t,key:o,value:u}),0===t?n++:r++,a.push({key:o,value:u,seq:c})}),this._updateGlobalSequence(e.ID,o),a.length>0&&(this._updateLocalExtension(e.ID,a),a=null),{resultList:i,successCount:n,failureCount:r}}).catch(e=>yn(e))}_getRequestExtensions(e,t){const s=[];if(this._hasLocalExtension(e.ID)){const o=this._getLocalExtension(e.ID);return t.forEach(e=>{const{key:t,value:i}=e;let n=0;o.has(t)&&(n=o.get(t).seq),s.push({key:t,value:i,seq:n})}),s}return t.forEach(e=>{const{key:t,value:o}=e;s.push({key:t,value:o,seq:0})}),s}_getMessageExtensions(e,s){const o=this._n+"._getMessageExtensions",{ID:i,to:n}=e;let r=null;switch(Je(n)?t.CONV_TOPIC:e.conversationType){case t.CONV_C2C:r=this.getModule(is);break;case t.CONV_GROUP:r=this.getModule(ns);break;case t.CONV_TOPIC:r=this.getModule(us);break;default:return yn({code:$i.CANNOT_FIND_MODULE})}return r.getMessageExtensions(e,s).then(t=>{let{extensions:s,completeFlag:n,globalSequence:r,clearSequence:a}=t.data;if(s=Ct(s)?[]:s,ge.l(`${o} ok. completeFlag:${n} globalSequence:${r} clearSequence:${a} count:${s.length}`),this._updateLocalExtension(i,s),this._clearLocalExtension(i,a),this._updateGlobalSequence(i,r),1!==n){const t=s.slice(-1)[0].seq+1;return this._getMessageExtensions(e,t)}return this._getLocalExtensions(i)}).catch(e=>yn(e))}_hasLocalExtension(e){return this.messageExtensionMap.has(e)}_getLocalExtension(e){return this.messageExtensionMap.get(e)}_updateLocalExtension(e,t){this._hasLocalExtension(e)||this.messageExtensionMap.set(e,new Map);const s=this._getLocalExtension(e);t.forEach(e=>{const{key:t,value:o="",seq:i}=e;s.set(t,{value:o,seq:i})})}_clearLocalExtension(e,t){if(!(t<=0)&&this._hasLocalExtension(e)){const s=this._getLocalExtension(e);s.forEach((e,o)=>{e.seq<=t&&s.delete(o)})}}_getLocalExtensions(e){const t=[];if(this._hasLocalExtension(e)){this._getLocalExtension(e).forEach((e,s)=>{const{value:o}=e;Ct(o)||t.push({key:s,value:o})})}return t}_getGlobalSequence(e){return this.globalSeqMap.get(e)}_updateGlobalSequence(e,t){this.globalSeqMap.set(e,t)}reset(){ge.l(this._n+".reset"),this.messageExtensionMap.clear(),this.globalSeqMap.clear(),this.getMessageExtensionsMap.clear()}}class Br extends Gs{constructor(e){super(e),this._n="ComboMessageModule"}sendMessage(e){const s=this._constructMessageInstance(e);if(null===s)return yn({code:$i.MESSAGE_SEND_FAIL});this._addSendMessageTotalCount(s);const o=Date.now();return this.getModule(cs).setMessageRandom(s),this._sendComboMessage(s,e).then(e=>{const{time:i,sequence:n,readReceiptCode:r}=e.data;if(ve(r)&&0!==r){new Qi("sendMessageWithReceipt").setMessage(`from:${s.from} to:${s.to} sequence:${n} readReceiptCode:${r}`).end(),ge.w(`${this._n}.sendMessage readReceiptCode:${r} message:${this.getErrorMessage(r)}`)}this._addSendMessageSuccessCount(s,o);const a=this.getModule(cs);s.status=Dt.SUCCESS,s.time=i,s.conversationType===t.CONV_GROUP&&(s.sequence=n),a.appendToMessageList(s);let u=s;return!0===s._isExcludedFromLastMessage&&(u=""),a.onMessageSent({conversationOptionsList:[{conversationID:s.conversationID,unreadCount:0,type:s.conversationType,subType:s.conversationSubType,lastMessage:u}]}),Mn({message:s})}).catch(e=>this._onSendMessageFailed(s,e))}_sendComboMessage(e,s){const o=this._m.getModule(fs);let i="";return e.conversationType===t.CONV_C2C&&(i=`${m.NAME.OPEN_IM}.${m.CMD.SEND_MESSAGE}`),e.conversationType===t.CONV_GROUP&&(i=`${m.NAME.GROUP}.${m.CMD.SEND_GROUP_MESSAGE}`),o.sendComboMessage({servcmd:i,data:s})}_constructMessageInstance(e){const s=this._n+"._constructMessageInstance";let o=null;try{const i=this.getMyUserID(),n={};if(n.senderTinyID=this.getMyTinyID(),n.currentUser=i,n.from=e.From_Account||i,e.GroupId?(n.conversationID=`${t.CONV_GROUP}${e.GroupId}`,n.conversationType=t.CONV_GROUP,n.to=e.GroupId):e.To_Account&&(n.conversationID=`${t.CONV_C2C}${e.To_Account}`,n.conversationType=t.CONV_C2C,n.to=e.To_Account),n.time=e.MsgTimeStamp||0,n.random=e.Random||e.MsgRandom||0,n.priority=e.MsgPriority,Le(e.CloudCustomData)&&e.CloudCustomData.length>0&&(n.cloudCustomData=e.CloudCustomData),Ne(e.SendMsgControl)&&(n.messageControlInfo={},e.SendMsgControl.includes("NoUnread")&&(n.messageControlInfo.excludedFromUnreadCount=1),e.SendMsgControl.includes("NoLastMsg")&&(n.messageControlInfo.excludedFromLastMessage=1)),n.conversationType===t.CONV_GROUP&&Ne(e.To_Account)&&e.To_Account.length>0){let t=e.To_Account;e.To_Account.length>50&&(t=e.To_Account.slice(0,50),ge.w(s+" To_Account must be less than or equal to 50.")),n.receiverList=[...t],e.To_Account=[...t]}1!==e.IsNeedReadReceipt&&1!==e.NeedReadReceipt||(n.needReadReceipt=!0),1===e.SupportMessageExtension&&(n.isSupportExtension=!0),o=new mn(n),o.status=Dt.UNSEND,e.MsgClientTime=o.clientTime,o.conversationType===t.CONV_C2C&&(e.MsgSeq=o.sequence);const r=e.MsgBody.length;let a;for(let t=0;t{s.setError(t,e,o).end()}),ge.e(this._n+"._onSendMessageFailed error:",t),yn(new fn({code:t&&t.code?t.code:$i.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if(e.conversationType===t.CONV_C2C)return xi;if(e.conversationType===t.CONV_GROUP){const t=this.getModule(ns).getLocalGroupProfile(e.to);if(!t)return;const s=t.type;return je(s)?Bi:Vi}}_addSendMessageTotalCount(e){const t=this._getSendMessageSpecifiedKey(e);if(t){this.getModule(Es).addTotalCount(t)}}_addSendMessageSuccessCount(e,t){const s=Math.abs(Date.now()-t),o=this._getSendMessageSpecifiedKey(e);if(o){const e=this.getModule(Es);e.addSuccessCount(o),e.addCost(o,s)}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,o=this.getModule(Es),i=this._getSendMessageSpecifiedKey(e);qr(s)&&i&&o.addFailedCountOfUserSide(i)}}class Hr extends Gs{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(e){Object.keys(e).forEach(t=>{this.plugins[t]=e[t]});new Qi("registerPlugin").setMessage(""+Object.keys(e)).end()}getPlugin(e){return this.plugins[e]}reset(){}}class Kr extends Gs{constructor(e){super(e),this._n="SyncUnreadMessageModule",this._cookie="",this._onlineSyncFlag=!1,this.getInnerEmitterInstance().on(Sn,this._onLoginSuccess,this)}_onLoginSuccess(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}_startSync(e){const{cookie:t,syncFlag:s,isOnlineSync:o}=e,i=this._n+"._startSync";ge.l(`${i} cookie:${t} syncFlag:${s} isOnlineSync:${o}`),this.request({protocolName:ws,requestData:{cookie:t,syncFlag:s,isOnlineSync:o}}).then(e=>{const{cookie:t,syncFlag:s}=e.data;this._cookie=t,Ct(t)||(0===s||1===s?(this._dispatchUnreadMessage({...e.data,isSyncingEnded:!1}),this._startSync({cookie:t,syncFlag:s,isOnlineSync:0})):2===s&&this._dispatchUnreadMessage({...e.data,isSyncingEnded:!0}))}).catch(e=>{ge.e(i+" failed. error:",e)})}_dispatchUnreadMessage(e){if(e.eventArray){this.getModule(fs).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}})}this.getModule(is).onNewC2CMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList})}startOnlineSync(){ge.l(this._n+".startOnlineSync"),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}startSyncOnReconnected(){ge.l(this._n+".startSyncOnReconnected."),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){ge.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}const Wr={request:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic",isWebUniapp:"is_web_uniapp",isSupportExtension:"SupportMessageExtension",messageSequence:"MsgSeq",messageKey:"MsgKey",startSequence:"startSeq",simplifiedMessage:"DownsizeFlag"},response:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"isWithChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified",ApplyJoinOption:"joinOption",MsgFlag:"messageRemindType",AtInfoList:"groupAtInfoList",AtFlagList:"groupAtType",AtMsgSeq:"sequence",BanDuration:"duration",BanDescription:"reason",NotVisible:"invisible",BytesTag:"tag",BytesValue:"value",RptBytesValue:"value",LatestSeq:"globalSequence",ClearSeq:"clearSequence",SupportMessageExtension:"isSupportExtension",ExtensionList:"extensions",GroupCounter:"counterList",Revoker_Account:"revoker",MsgExtensionNotify:"messageExtensionNotify",ExtensionC2cMsgInfo:"messageInfo",ExtensionGroupMsgInfo:"messageInfo",MsgOptType:"operateType",SetKVInfo:"operateResultList",DeleteKVInfo:"operateResultList",ClearKVInfo:"operateResultList",MsgKeyValue:"extensions",ClearMsgSeq:"clearSequence",MsgLastSeq:"globalSequence",InviteJoinOption:"inviteOption",MemberList_Account:"inviteeList",MsgMemberExtraInfoList:"inviteeInfoList",E:"event",GInf:"groupProfile",MCT:"clientTime",MR:"random",MP:"priority",MTS:"time",GId:"groupID",MS:"sequence",CCD:"cloudCustomData",F_Account:"from",F_Hd:"avatar",F_NN:"nick",GN:"groupName",GT:"groupType",IsSys:"isSystemMessage",OpInf:"operatorInfo",Img:"avatar",NN:"nick",OnlineInf:"onlineMemberInfo",ET:"expireTime",Num:"onlineMemberNum",Opt:"operationType",O_Account:"operatorID",RT:"operationType",UDF:"userDefinedField",L_Account:"userIDList"},ignoreKeyWord:["C2C","ID","USP"]};function Yr(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);if(0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)return"";if(1===e.length)return t.pascalCase?e.toUpperCase():e.toLowerCase();return e!==e.toLowerCase()&&(e=jr(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,t)=>t.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase()),s=e,t.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;var s}const jr=e=>{let t=!1,s=!1,o=!1;for(let i=0;i100)return s--,t;if(Ne(t)){const i=t.map(t=>Ae(t)?e(t,o):t);return s--,i}if(Ae(t)){let i=function(e,t){const s=Object.create(null);return Object.keys(e).forEach(o=>{const i=t(e[o],o);i&&(s[i]=e[o])}),s}(t,(e,t)=>{if(!be(t))return!1;if((s=t)!==Yr(s))for(let o=0;oNe(t)||Ae(t)?e(t,o):t),s--,i}}(e,t)}function Jr(e,t){if(Ne(e))return e.map(e=>Ae(e)?Jr(e,t):e);if(Ae(e)){let s=function(e,t){const s={};return Object.keys(e).forEach(o=>{s[t(e[o],o)]=e[o]}),s}(e,(e,s)=>Oe(t[s])?Yr(s):t[s]);return s=et(s,e=>Ne(e)||Ae(e)?Jr(e,t):e),s}}const Xr=String.fromCharCode,Zr=function(e){let t=0|e.charCodeAt(0);if(55296<=t)if(t<56320){const s=0|e.charCodeAt(1);if(56320<=s&&s<=57343){if(t=(t<<10)+s-56613888|0,t>65535)return Xr(240|t>>>18,128|t>>>12&63,128|t>>>6&63,128|63&t)}else t=65533}else t<=57343&&(t=65533);return t<=2047?Xr(192|t>>>6,128|63&t):Xr(224|t>>>12,128|t>>>6&63,128|63&t)},Qr=function(e){const t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,Zr),s=0|t.length,o=new Uint8Array(s);let i=0;for(;i{}}),this._socket.onClose(this._onClose.bind(this)),this._socket.onOpen(this._onOpen.bind(this)),this._socket.onMessage(this._onMessage.bind(this)),this._socket.onError(this._onError.bind(this))):k&&(this._socket=new WebSocket(t),this._socket.binaryType="arraybuffer",this._socket.onopen=this._onOpen.bind(this,this._socket.extensions),this._socket.onmessage=this._onMessage.bind(this),this._socket.onclose=this._onClose.bind(this),this._socket.onerror=this._onError.bind(this));this._canIUseBinaryFrame=e.canIUseBinaryFrame()}getID(){return this._id}_onOpen(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onMessage(e){let t;t=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):function(e){const t=new Uint8Array(e);let s="",o=0;const i=t.length;for(;o0){let s=0;for(;s{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{})):k&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),R?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}send(e){if(this._workerSocket)this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?Qr(e.data).buffer:e.data});else{if(N)return void b.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}});this._socket&&(P?this._socket.send({data:this._canIUseBinaryFrame?Qr(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):k&&this._socket.send(this._canIUseBinaryFrame?Qr(e.data):e.data))}}}const ta=4e3,sa=4001,oa="connected",ia="connecting",na="disconnected";class ra{constructor(e){this._channelModule=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=na,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=qe(),this._startTs=0,this._reConnectFlag=!1,this._nextPingTs=0,this._reConnectCount=0,this.MAX_RECONNECT_COUNT=3,this._socketID=-1,this._random=0,this._socket=null,this._url="",this._onOpenTs=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0,this._setWebsocketHost(),this._initConnection()}_setWebsocketHost(){const e=this._channelModule.getModule(ls);let t=u;this._channelModule.isOversea()&&(t=c),e.isSingaporeSite()?t=l:e.isKoreaSite()?t=d:e.isGermanySite()?t=p:e.isIndiaSite()?t=h:e.isJapanSite()?t=g:e.isUSASite()&&(t=_),m.HOST.setCurrent(t)}_initConnection(){Oe(m.HOST.CURRENT.BACKUP)||""===this._url?this._url=m.HOST.CURRENT.DEFAULT:this._url===m.HOST.CURRENT.DEFAULT?this._url=m.HOST.CURRENT.BACKUP:this._url===m.HOST.CURRENT.BACKUP?this._url=this._canIUseAnyCast()?m.HOST.CURRENT.ANYCAST:m.HOST.CURRENT.DEFAULT:this._url===m.HOST.CURRENT.ANYCAST&&(m.HOST.CURRENT.ANYCAST="",this._url=m.HOST.CURRENT.DEFAULT);const e=this._channelModule.getModule(ls).getProxyServer();Ct(e)||(this._url=e),this._connect(),this._nextPingTs=0}_canIUseAnyCast(){return k&&m.HOST.CURRENT.ANYCAST}onCheckTimer(e){e%1==0&&this._checkPromiseMap()}_checkPromiseMap(){0!==this._promiseMap.size&&this._promiseMap.forEach((e,t)=>{const{reject:s,timestamp:o}=e;let i=15e3;-1!==t.indexOf(Us)?i=9e4:-1!==t.indexOf(hi)&&(i=3e3),Date.now()-o>=i&&(ge.l(`${this._n}._checkPromiseMap request timeout, delete requestID:${t}`),this._promiseMap.delete(t),s(new fn({code:$i.NETWORK_TIMEOUT})),this._channelModule.onRequestTimeout(t))})}onOpen(e){if(""===this._readyState)return;this._onOpenTs=Date.now();const{id:t,res:s}=e;this._socketID=t;const o=Date.now()-this._startTs,i=`socketID:${t} res:${s}`;ge.l(`${this._n}._onOpen cost:${o} ms. ${i}`);new Qi("wsOnOpen").setMessage(o).setCostTime(o).setMoreMessage(i).end(),e.id===this._socketID&&(this._readyState=oa,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}onClose(e){const t=new Qi("wsOnClose"),{id:s,e:o}=e,i=`sourceSocketID:${s} currentSocketID:${this._socketID} code:${o.code} reason:${o.reason}`;let n=0;0!==this._onOpenTs&&(n=Date.now()-this._onOpenTs),t.setMessage(n).setCostTime(n).setMoreMessage(i).setCode(o.code).end(),ge.l(`${this._n}._onClose ${i} onlineTime:${n}`),s===this._socketID&&(this._readyState=na,n<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}onError(e){const{id:t,e:s}=e,o=`sourceSocketID:${t} currentSocketID:${this._socketID}`;new Qi("wsOnError").setMessage(s.errMsg||$e(s)).setMoreMessage(o).setLevel("error").end(),ge.w(this._n+"._onError",s,o),t===this._socketID&&(this._readyState="",this._channelModule.onError())}onMessage(e){let t;try{t=JSON.parse(e.data)}catch(i){new Qi("jsonParseError").setMessage(e.data).end()}if(!t||!t.head)return;const s=this._getRequestIDFromHead(t.head);let o=t.body;if(!this._isTRTCCommand(s)){const e=ut(t.head);o=Jr(t.body,this._getResponseKeyMap(e))}if(ge.d(`${this._n}.onMessage ret:${JSON.stringify(o)} requestID:${s} has:${this._promiseMap.has(s)}`),this._setNextPingTs(),this._promiseMap.has(s)){const{resolve:e,reject:t,timestamp:i}=this._promiseMap.get(s);return this._promiseMap.delete(s),this._calcRTT(i),void(o.errorCode&&0!==o.errorCode?(this._channelModule.onErrorCodeNotZero(o),t(new fn({code:o.errorCode,message:o.errorInfo||"",data:s.includes(Qs)||s.includes(Ho)?{elements:o.elements,messageVersion:o.messageVersion,cloudCustomData:o.cloudCustomData}:void 0}))):e(Mn(o)))}this._channelModule.onMessage({head:t.head,body:o})}_isTRTCCommand(e){const t=this._channelModule.getModule(As).getCommandList();let s=!1;for(let o=0;o0&&this._promiseMap.forEach((e,t)=>{const{uplinkData:s,resolve:o,reject:i}=e;this._promiseMap.set(t,{resolve:o,reject:i,timestamp:Date.now(),uplinkData:s}),this._execute(t,s)}),this._simpleRequestMap.size>0){for(const[e,t]of this._simpleRequestMap)this._execute(e,t);this._simpleRequestMap.clear()}}send(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);const{keyMap:t,...s}=e,o=this._getRequestIDFromHead(e.head),i=JSON.stringify(s);return new Promise((e,t)=>{if(this._promiseMap.set(o,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:i}),ge.d(`${this._n}.send uplinkData:${JSON.stringify(s)} requestID:${o} readyState:${this._readyState}`),this._readyState!==oa)this._reConnect();else{this._execute(o,i);this._channelModule.getModule(Es).addRequestCount()}})}simplySend(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);const{keyMap:t,...s}=e,o=this._getRequestIDFromHead(e.head),i=JSON.stringify(s);this._readyState!==oa?(this._simpleRequestMap.size{t?(ge.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(sa),this._initConnection()):this._channelModule.onReconnectFailed()}))}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===oa}canIUseBinaryFrame(){return this._canIUseBinaryFrame}inflate(e){if(this._channelModule.canIUseInflate())return this._channelModule.getModule(Os).inflate(e)}setIsWorkerEnabled(e){ge.l(`${this._n}.setIsWorkerEnabled flag:${e}`),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&Z}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}close(){ge.l(this._n+".close"),this._closeConnection(ta),this._promiseMap.clear(),this._startSequence=qe(),this._readyState=na,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}class aa extends Gs{constructor(e){if(super(e),this._n="ChannelModule",this._socketHandler=new ra(this),this._probing=!1,this._isAppShowing=!0,this._previousState=t.NET_STATE_CONNECTED,P&&"function"==typeof b.onAppShow&&"function"==typeof b.onAppHide){const e=this._onAppHide.bind(this),t=this._onAppShow.bind(this);"function"==typeof b.offAppHide&&b.offAppHide(e),"function"==typeof b.offAppShow&&b.offAppShow(t),b.onAppHide(e),b.onAppShow(t)}this._timerForNotLoggedIn=-1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._fatalErrorFlag=!1}onCheckTimer(e){this._socketHandler&&(this.isLoggedIn()?(this._timerForNotLoggedIn>0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}onErrorCodeNotZero(e){this.getModule(fs).onErrorCodeNotZero(e)}onMessage(e){this.getModule(fs).onMessage(e)}send(e){return this._socketHandler?this._previousState!==t.NET_STATE_CONNECTED&&e.head.servcmd.includes(pi)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}_sendLogViaHTTP(e){const t=m.HOST.CURRENT.STAT;return new Promise((s,o)=>{const i=`${t}/v4/imopenstat/tim_web_report_v2?sdkappid=${e.head.sdkappid}&reqtime=${Date.now()}`,n=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(P)b.request({url:i,data:n,method:"POST",timeout:3e3,header:{"content-type":r},success:()=>{s()},fail:()=>{o(new fn({code:$i.NETWORK_ERROR}))}});else{const e=new XMLHttpRequest,t=setTimeout(()=>{e.abort(),o(new fn({code:$i.NETWORK_TIMEOUT}))},3e3);e.onreadystatechange=function(){4===e.readyState&&(clearTimeout(t),200===e.status||304===e.status?s():o(new fn({code:$i.NETWORK_ERROR})))},e.open("POST",i,!0),e.setRequestHeader("Content-type",r),e.send(n)}})}simplySend(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}onOpen(){this._ping()}onClose(){if(this._socketHandler){this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}this.reConnect()}onError(){P&&!G&&this.outputWarning("DomainNameInMP"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}getKeyMap(e){return this.getModule(fs).getKeyMap(e)}_onAppHide(){this._isAppShowing=!1}_onAppShow(){this._isAppShowing=!0}onRequestTimeout(e){}onReconnected(){ge.l(this._n+".onReconnected"),this._m.restartTimer();this.getModule(fs).onReconnected(),this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED)}onReconnectFailed(){ge.l(this._n+".onReconnectFailed"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}setIsWorkerEnabled(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}offline(){this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}reConnect(e=!1){let s=!1;this._socketHandler&&(s=this._socketHandler.getReconnectFlag());const o=`forcedFlag:${e} fatalErrorFlag:${this._fatalErrorFlag} previousState:${this._previousState} reconnectFlag:${s}`;if(ge.l(`${this._n}.reConnect ${o}`),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===t.NET_STATE_CONNECTING&&s)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(t.NET_STATE_CONNECTING)}}_emitNetStateChangeEvent(t){this._previousState!==t&&(ge.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to ${t}`),this._previousState=t,this.emitOuterEvent(e.NET_STATE_CHANGE,{state:t}))}_ping(){if(!0===this._probing)return;this._probing=!0;const e=this.getModule(fs).getProtocolData({protocolName:hi});this.send(e).then(()=>{this._probing=!1}).catch(e=>{if(ge.w(this._n+"._ping failed. error:",e),this._probing=!1,e&&60002===e.code){return new Qi("error").setMessage(`code:${e.code} message:${e.message}`).setNetworkType(this.getModule(hs).getNetworkType()).end(),this._fatalErrorFlag=!0,void this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}this.probeNetwork().then(([e,s])=>{ge.l(`${this._n}._ping failed. probe network, isAppShowing:${this._isAppShowing} online:${e} networkType:${s}`),e?this.reConnect():this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)})})}_checkNextPing(){if(!this._socketHandler)return;if(!this._socketHandler.isConnected())return;Date.now()>=this._socketHandler.getNextPingTs()&&this._ping()}canIUseInflate(){return this._m.canIUseInflate()}dealloc(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}onRestApiKickedOut(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}reset(){ge.l(this._n+".reset"),this._previousState=t.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}class ua{constructor(e){this._n="ProtocolHandler",this._sessionModule=e,this._configMap=new Map,this._fillConfigMap()}_fillConfigMap(){this._configMap.clear();const e=this._sessionModule.genCommonHead(),t=this._sessionModule.genCosSpecifiedHead(),s=this._sessionModule.genSSOReportHead(),o=this._sessionModule.isIntl();this._configMap.set(Us,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.LOGIN}`},body:{state:"Online",isWebUniapp:0,deviceBrand:0},keyMap:{request:{deviceBrand:"InstType"},response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(Ps,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.LOGOUT}`},body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(ks,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.HELLO}`},body:{isWebUniapp:0},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(bs,function(e){return{head:{...e,servcmd:`${m.NAME.STAT_SERVICE}.${m.CMD.KICK_OTHER}`},body:{}}}(e)),this._configMap.set(ci,function(e){return{head:{...e,servcmd:`${m.NAME.IM_COS_SIGN}.${m.CMD.COS_SIGN}`},body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(t)),this._configMap.set(li,function(e){return{head:{...e,servcmd:`${m.NAME.CUSTOM_UPLOAD}.${m.CMD.COS_PRE_SIG}`},body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(t)),this._configMap.set(di,function(e){return{head:{...e,servcmd:`${m.NAME.CUSTOM_UPLOAD}.${m.CMD.VIDEO_COVER}`},body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(t)),this._configMap.set(yi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.FETCH_COMMERCIAL_CONFIG}`},body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Di,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.PUSHED_COMMERCIAL_CONFIG}`},body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Ci,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.FETCH_CLOUD_CONTROL_CONFIG}`},body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Ti,function(e){return{head:{...e,servcmd:`${m.NAME.IM_CONFIG_MANAGER}.${m.CMD.PUSHED_CLOUD_CONTROL_CONFIG}`},body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(Ei,function(e){return{head:{...e,servcmd:`${m.NAME.OVERLOAD_PUSH}.${m.CMD.OVERLOAD_NOTIFY}`},body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(ws,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_MESSAGES}`},body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0,needSignaling:1},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},response:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"to",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),o||(this._configMap.set($s,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.BIG_DATA_HALLWAY_AUTH_KEY}`},body:{}}}(e)),this._configMap.set(bi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_MSG_AUDIT_MGR}.${m.CMD.GET_RPOFANITY_LIST}`},body:{version:0,deviceID:"",startIndex:void 0},keyMap:{request:{version:"uint64_version",deviceID:"str_device_id",startIndex:"uint64_start_index"},response:{msg_cmd_error_code:"errorInfo",str_err_msg:"errorMessage",uint32_code:"errorCode",msg_scene_ctl_config:"filterConfig",uint64_c2c_custom_msg_flag:"c2c_custom_message",uint64_c2c_text_msg_flag:"c2c_text_message",uint64_group_custom_msg_flag:"group_custom_message",uint64_group_text_msg_flag:"group_text_message",uint64_group_info_flag:"group_profile",uint64_group_member_info_flag:"group_member_profile",uint64_relation_chain_flag:"sns",uint64_user_info_flag:"user_profile",rpt_msg_dirty_word:"lexicon",str_dirty_word:"profanity",str_replaced_content:"replacement",uint64_filter_type:"filterType",uint64_id:"id",uint64_word_type:"profanityType",uint64_complete_flag:"completeFlag",uint64_next_start_index:"nextStartIndex",uint64_version:"version",uint64_expired_time:"expiredTime"}}}}(e))),this._configMap.set(Fs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SEND_MESSAGE}`},body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension:0},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt"}}}}(e)),this._configMap.set(qs,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEND_GROUP_MESSAGE}`},body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0,isVoipPush:void 0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0,receiverList:void 0,isSupportExtension:0},keyMap:{request:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"NeedReadReceipt",receiverList:"To_Account"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Ws,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.REVOKE_C2C_MESSAGE}`},body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(No,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.REVOKE_GROUP_MESSAGE}`},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(Js,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_C2C_ROAM_MESSAGES}`},body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},response:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer"}}}}(e)),this._configMap.set(Qs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MODIFY_C2C_MESSAGE}`},body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(Uo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_ROAM_MESSAGES}`},body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList"}}}}(e)),this._configMap.set(Ys,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_C2C_MESSAGE_READ}`},body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(js,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(zs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS}`},body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(Oo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SET_GROUP_MESSAGE_READ}`},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(Go,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SET_ALL_MESSAGE_READ}`},body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(Zs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_C2C_MESSAGE}`},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(Bo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_MESSAGE}`},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(wi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_TRANSLATE}.${m.CMD.TRANSLATE_TEXT}`},body:{sourceTextList:void 0,SDKAppID:0,from:0,source:"",target:""},keyMap:{request:{sourceTextList:"SourceText",SDKAppID:"SdkAppId",from:"FromAccount"},response:{TargetText:"translatedTextList",RequestId:"requestID",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._configMap.set(Ho,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MODIFY_GROUP_MESSAGE}`},body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{request:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._configMap.set(Po,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(bo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.SEND_C2C_READ_RECEIPT}`},body:{peerAccount:"",messageInfoList:void 0},keyMap:{request:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._configMap.set(ko,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEND_READ_RECEIPT}`},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(wo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_READ_RECEIPT_DETAIL}`},body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(eo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.MODIFY_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(to,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.GET_C2C_MESSAGE_EXTENSIONS}`},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}}(e)),this._configMap.set(Jo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.MODIFY_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._configMap.set(Xo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM_MSG_EXT}.${m.CMD.GET_GROUP_MESSAGE_EXTENSIONS}`},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}}(e)),this._configMap.set(Xs,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.GET_PEER_READ_TIME}`},body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(oo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.GET_CONVERSATION_LIST}`},body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set(so,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.PAGING_GET_CONVERSATION_LIST}`},body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex",GroupId:"convGroupID"}}}}(e)),this._configMap.set(io,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.DELETE_CONVERSATION}`},body:{fromAccount:"",conversationList:void 0,clearHistoryMessage:void 0},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble",conversationList:"ContactItem"},response:{ResultItem:"resultList",ToGroupid:"groupID",ResultCode:"code",ResultInfo:"info"}}}}(e)),this._configMap.set(no,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.CLEAR_HISTORY_MESSAGE}`},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{request:{toGroupID:"ToGroupid"}}}}(e)),this._configMap.set(ro,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.PIN_CONVERSATION}`},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(ao,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_GROUP_AT_TIPS}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(uo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(co,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.MARK_CONVERSATION}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(lo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.CREATE_CONVERSATION_GROUP}`},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"GroupContactItem",groupID:"ToGroupId"},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._configMap.set(po,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.DELETE_CONVERSATION_GROUP}`},body:{fromAccount:"",groupName:void 0},keyMap:{request:{},response:{GroupId:"convGroupID"}}}}(e)),this._configMap.set(ho,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{oldName:"OldGroupName",newName:"NewGroupName",groupID:"ToGroupId",operationType:"ContactOptType",groupName:"OldGroupName",updateItem:"ContactUpdateItem"},response:{ContactOptType:"operationType",ToGroupId:"groupID",GroupId:"convGroupID"}}}}(e)),this._configMap.set(go,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(_o,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.UPDATE_CONVERSATION_GROUP}`},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{},response:{}}}}(e)),this._configMap.set(mo,function(e){return{head:{...e,servcmd:`${m.NAME.RECENT_CONTACT}.${m.CMD.GET_CONVERSATION_GROUP_LIST}`},body:{fromAccount:"",startTime:void 0,startIndex:void 0},keyMap:{request:{},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList"}}}}(e)),this._configMap.set(xs,function(e){return{head:{...e,servcmd:`${m.NAME.PROFILE}.${m.CMD.PORTRAIT_GET}`},body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(Vs,function(e){return{head:{...e,servcmd:`${m.NAME.PROFILE}.${m.CMD.PORTRAIT_SET}`},body:{fromAccount:"",profileItem:[{tag:me.NICK,value:""},{tag:me.GENDER,value:""},{tag:me.ALLOWTYPE,value:""},{tag:me.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(Bs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.GET_BLACKLIST}`},body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(Hs,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.ADD_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Ks,function(e){return{head:{...e,servcmd:`${m.NAME.FRIEND}.${m.CMD.DELETE_BLACKLIST}`},body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Ri,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.SET_SELF_STATUS}`},body:{customStatus:""},keyMap:{}}}(e)),this._configMap.set(Ni,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.GET_USER_STATUS}`},body:{userIDList:void 0},keyMap:{response:{UserStatusList:"successUserList",ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID",Status:"statusType"}}}}(e)),this._configMap.set(Oi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.SUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Gi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.UNSUBSCRIBE_USER_STATUS}`},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}}(e)),this._configMap.set(Mo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_JOINED_GROUPS}`},body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence",LastRecallTime:"_lastRevokedTime"}}}}(e)),this._configMap.set(fo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_INFO}`},body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers"}}}}(e)),this._configMap.set(Io,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CREATE_GROUP}`},body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0,inviteOption:void 0},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",inviteOption:"InviteJoinOption"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set(Co,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DESTROY_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(To,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_INFO}`},body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0,inviteOption:void 0},keyMap:{request:{groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl",inviteOption:"InviteJoinOption"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers"}}}}(e)),this._configMap.set(yo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.APPLY_JOIN_GROUP}`},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(Do,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${m.NAME.BIG_GROUP_NO_AUTH}.${m.CMD.APPLY_JOIN_GROUP}`},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(Eo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.QUIT_GROUP}`},body:{groupID:void 0}}}(e)),this._configMap.set(So,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SEARCH_GROUP_BY_ID}`},body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"]}},keyMap:{response:{}}}}(e)),this._configMap.set(vo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CHANGE_GROUP_OWNER}`},body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(Lo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.HANDLE_APPLY_JOIN_GROUP}`},body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(Ao,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.HANDLE_INVITE_JOIN_GROUP}`},body:{groupID:void 0,applicant:void 0,invitee:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",invitee:"Invited_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg"}}}}(e)),this._configMap.set(Ro,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.HANDLE_GROUP_INVITATION}`},body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set($o,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_APPLICATION}`},body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"},response:{To_Account:"userID"}}}}(e)),this._configMap.set(Fo,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.DELETE_GROUP_SYSTEM_MESSAGE}`},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(qo,function(e){return{head:{...e,servcmd:`${m.NAME.BIG_GROUP_LONG_POLLING}.${m.CMD.AVCHATROOM_LONG_POLL}`},body:{USP:1,startSeq:1,startBroadcastSeq:void 0,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}(e)),this._configMap.set(xo,function(e){const{a2:t,tinyid:s,...o}=e;return{head:{...o,servcmd:`${m.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH}.${m.CMD.AVCHATROOM_LONG_POLL}`},body:{USP:1,startSeq:1,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}(e)),this._configMap.set(Vo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_ONLINE_MEMBER_NUM}`},body:{groupID:void 0}}}(e)),this._configMap.set(Ko,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.SET_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(Wo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(Yo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_ATTRIBUTES}`},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(jo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.CLEAR_GROUP_ATTRIBUTES}`},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(zo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_ATTR}.${m.CMD.GET_GROUP_ATTRIBUTES}`},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Zo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_NOTIFY}`},body:{notifyType:1,groupID:"",beginTime:0,endTime:0,limit:20},keyMap:{request:{},response:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList"}}}}(e)),this._configMap.set(Qo,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.UPDATE_GROUP_COUNTER}`},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{request:{counterList:"GroupCounter"}}}}(e)),this._configMap.set(ei,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_COUNTER}`},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{request:{keyList:"GroupCounterKeys"}}}}(e)),this._configMap.set(Si,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.CREATE_TOPIC}`},body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{request:{avatar:"FaceUrl"}}}}(e)),this._configMap.set(vi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.DELETE_TOPIC}`},body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList"}}}}(e)),this._configMap.set(Li,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.UPDATE_TOPIC_PROFILE}`},body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{request:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}}(e)),this._configMap.set(Ai,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_COMMUNITY}.${m.CMD.GET_TOPIC_LIST}`},body:{groupID:void 0,topicIDList:void 0,MemberInfoFilter:["NoUnreadSeqList"]},keyMap:{request:{topicIDList:"TopicIdList"},response:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",LastMsgSeq:"sequence",NoUnreadSeqList:"excludedUnreadSequenceList"}}}}(e)),this._configMap.set(ti,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_MEMBER_LIST}`},body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(si,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_AVCHATROOM}.${m.CMD.GET_AVCHATROOM_MEMBER_LIST}`},body:{groupID:void 0,offset:void 0,filter:void 0},keyMap:{request:{offset:"Timestamp",filter:"Mark"},response:{NextTimestamp:"offset"}}}}(e)),this._configMap.set(oi,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.GET_GROUP_MEMBER_INFO}`},body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(ii,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.ADD_GROUP_MEMBER}`},body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(ni,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.DELETE_GROUP_MEMBER}`},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(ri,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.BAN_AVCHATROOM_MEMBER}`},body:{groupID:void 0,userIDList:void 0,duration:void 0,reason:""},keyMap:{request:{userIDList:"Members_Account",duration:"Duration",reason:"Description"}}}}(e)),this._configMap.set(ai,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP}.${m.CMD.MODIFY_GROUP_MEMBER_INFO}`},body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(ui,function(e){return{head:{...e,servcmd:`${m.NAME.GROUP_AVCHATROOM}.${m.CMD.MARK_AVCHATROOM_MEMBER_INFO}`},body:{groupID:void 0,operationType:1,memberList:[]},keyMap:{request:{operationType:"CommandType",memberList:"MemberList",markType:"Marks",userID:"Member_Account"},response:{CommandType:"operationType",Marks:"markType",Member_Account:"userID"}}}}(e)),this._configMap.set(pi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STAT}.${m.CMD.TIM_WEB_REPORT_V2}`},body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(s)),this._configMap.set(hi,function(e){return{head:{...e,servcmd:`${m.NAME.HEARTBEAT}.${m.CMD.ALIVE}`},body:{}}}(e)),this._configMap.set(gi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_PUSH}.${m.CMD.MESSAGE_PUSH}`},body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt",Status:"statusType"}}}}(e)),this._configMap.set(_i,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_PUSH}.${m.CMD.MULTI_MESSAGE_PUSH}`},body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(mi,function(e){return{head:{...e,servcmd:`${m.NAME.OPEN_IM}.${m.CMD.MESSAGE_PUSH_ACK}`},body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(Mi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.STATUS_FORCE_OFFLINE}`},body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Ii,function(e){return{head:{...e,servcmd:`${m.NAME.IM_LONG_MESSAGE}.${m.CMD.DOWNLOAD_MERGER_MESSAGE}`},body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(fi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_LONG_MESSAGE}.${m.CMD.UPLOAD_MERGER_MESSAGE}`},body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e)),this._configMap.set(ki,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.SET_TOKEN}`},body:{tokenID:"",pushMsg:0,sdkAppID:0,businessID:"",deviceBrand:"",deviceToken:"",isTpns:0,isWebUniapp:0},keyMap:{request:{tokenID:"TokenID",pushMsg:"PushMsg",sdkAppID:"EnterVersion",businessID:"BusiID",deviceBrand:"InstType",deviceToken:"VarToken",isTpns:"IsTpns"}}}}(e)),this._configMap.set(Pi,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.STAT_FOREGROUND}`},body:{isWebUniapp:0}}}(e)),this._configMap.set(Ui,function(e){return{head:{...e,servcmd:`${m.NAME.IM_OPEN_STATUS}.${m.CMD.STAT_BACKGROUND}`},body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{request:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}}(e))}has(e){return this._configMap.has(e)}get(e){return this._configMap.get(e)}update(){this._fillConfigMap()}getKeyMap(e){return this.has(e)?this.get(e).keyMap||{}:(ge.w(`${this._n}.getKeyMap unknown protocolName:${e}`),{})}getProtocolData(e){const{protocolName:t,requestData:s}=e,o=this.get(t);let i=null;if(s){const e=this._simpleDeepCopy(o),t=this._updateService(s,e),n=t.body,r=Object.create(null);for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)){if(r[o]=n[o],void 0===s[o])continue;r[o]=s[o]}t.body=r,i=this._getUplinkData(t)}else i=this._getUplinkData(o);return i}_getUplinkData(e){const t=this._requestDataCleaner(e),s=ut(t.head),o=zr(t.body,this._getRequestKeyMap(s));return t.body=o,t}_updateService(e,t){const s=ut(t.head);if(this._isFromGroupRequest(t)){let{type:o,groupID:i,groupIDList:n=[]}=e;Oe(i)&&(i=n[0]||""),ze({type:o,groupID:i})&&(t.head.servcmd=`${m.NAME.GROUP_COMMUNITY}.${s}`)}return t}_isFromGroupRequest(e){return e.head.servcmd.includes(m.NAME.GROUP)||e.head.servcmd.includes(m.NAME.GROUP_ATTR)}_getRequestKeyMap(e){const t=this.getKeyMap(e);return{...Wr.request,...t.request}}_requestDataCleaner(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&be(s)&&null!==e[s]&&void 0!==e[s]&&("object"!=typeof e[s]?t[s]=e[s]:t[s]=this._requestDataCleaner.bind(this)(e[s]));return t}_simpleDeepCopy(e){const t=Object.keys(e),s={};let o;for(let i=0,n=t.length;i{if(1===e.isSyncMessage){const t=e.from;e.from=e.to,e.to=t}}),1===e.needSync){this._sessionModule.getModule(Ms).startOnlineSync()}t.onNewC2CMessage({dataList:e.dataList,isInstantMessage:!0})}}_c2cMessageModifiedHandler(e){const t=this._sessionModule.getModule(is);t&&t.onC2CMessageModified(e)}_groupMessageArrayHandler(e){const t=this._sessionModule.getModule(ns);t&&t.onNewGroupMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}_groupMessageModifiedHandler(e){const t=this._sessionModule.getModule(ns);t&&t.onGroupMessageModified(e)}_groupTipsHandler(e){const t=this._sessionModule.getModule(ns);if(!t)return;const{event:s,dataList:o,isInstantMessage:i=!0,isSyncingEnded:n}=e;switch(s){case 4:case 6:t.onNewGroupTips({event:s,dataList:o});break;case 5:for(let e=0;e{if(Re(e))if(e.hasOwnProperty("kickoutMsgNotify")){const{kickoutMsgNotify:{kickType:t,newInstanceInfo:s={}}}=e;1===t?this._sessionModule.onMultipleAccountKickedOut(s):2===t?this._sessionModule.onMultipleDeviceKickedOut(s):3===t&&this._sessionModule.onRestApiKickedOut(s)}else if(e.hasOwnProperty("c2cMessageRevokedNotify"))s&&s.onC2CMessageRevoked({dataList:t});else if(e.hasOwnProperty("c2cMessageReadReceipt"))s&&s.onC2CMessageReadReceipt({dataList:t});else if(e.hasOwnProperty("c2cMessageReadNotice"))s&&s.onC2CMessageReadNotice({dataList:t});else if(e.hasOwnProperty("muteNotificationsSync")){this._sessionModule.getModule(cs).onC2CMessageRemindTypeSynced({dataList:t})}})}_C2CReadReceiptArrayHandler(e){this._sessionModule.getModule(is).onReadReceiptList(e)}_profileHandler(e){this._sessionModule.getModule(os).onProfileModified({dataList:e.dataList});const t=this._sessionModule.getModule(rs);t&&t.onFriendProfileModified({dataList:e.dataList})}_relationChainHandler(e){this._sessionModule.getModule(os).onRelationChainModified({dataList:e.dataList});const t=this._sessionModule.getModule(rs);t&&t.onRelationChainModified({dataList:e.dataList})}_recentContactHandler(e){const{dataList:t}=e;if(!Ne(t))return;const s=this._sessionModule.getModule(cs);s&&t.forEach(e=>{const{pushType:t}=e;if(1===t){const{recentContactDeleteItem:t}=e;s.onConversationDeleted(t.recentContactList)}else if(2===t){const{recentContactTopItem:t}=e;s.onConversationPinned(t.recentContactList)}else if(3===t){const{recentContactTopItem:t}=e;s.onConversationUnpinned(t.recentContactList)}else if(4===t){const{recentContactMarkContact:t}=e;s.onConversationMarkUpdated(t.recentContactMarkContactItem)}else if(5===t){const{recentContactCreateContactGroup:t}=e;s.onConversationGroupCreated(t.msgContactGroupContactItem)}else if(6===t){const{recentContactDelContactGroup:t}=e;s.onConversationGroupDeleted(t.msgGroupItem)}else if(7===t){const{recentContactUpdateContactGroup:t}=e,{updateType:o,msgUpdateGroup:i,msgUpdateContact:n}=t;if(1===o){const{updateGroupType:e}=i;1===e?s.onConversationGroupNameUpdated(i):2===e&&s.onConversationInGroupUpdated(i)}else 2===o&&s.onConversationAddedToOrDeletedFromGroup(n)}})}_allMessageReadHandler(e){const{dataList:t}=e,s=this._sessionModule.getModule(cs);s&&s.onPushedAllMessageRead(t)}_userStatusListHandler(e){this._sessionModule.getModule(os).onUserStatusUpdated(e)}_messageExtensionNotifyHandler(e){this._sessionModule.getModule(ss).onMessageExtensionNotify(e)}onMessage(e){const{body:t}=e;if(!this._filterMessageFromIMOpenPush(e))return;const{eventArray:s,isInstantMessage:o,isSyncingEnded:i,needSync:n}=t;if(!Ne(s))return;let r=null,a=null,u=0;for(let c=0,l=s.length;c-1!==this._keys.indexOf(e));e?(a=14===u?{readAllC2CMessage:r[e],groupMessageReadInfoList:r.groupMessageReadNotice||[]}:16===u?{userID:r.userID,readReceiptList:r[e]}:r[e],this._eventHandlerMap.get(e)({event:u,dataList:a,isInstantMessage:o,isSyncingEnded:i,needSync:n})):ge.l(`${this._n}.onMessage unknown eventItem:${r}`)}}_filterMessageFromIMOpenPush(e){const{head:t,body:s}=e,{servcmd:o}=t;let i=!1;if(Oe(o)||(i=o.includes(m.NAME.IM_CONFIG_MANAGER)||o.includes(m.NAME.OVERLOAD_PUSH)||o.includes(m.NAME.STAT_SERVICE)),!i)return!0;if(o.includes(m.CMD.PUSHED_CLOUD_CONTROL_CONFIG)){this._sessionModule.getModule(Ts).onPushedCloudControlConfig(s)}else if(o.includes(m.CMD.PUSHED_COMMERCIAL_CONFIG)){this._sessionModule.getModule(Ss).onPushedConfig(s)}else if(o.includes(m.CMD.OVERLOAD_NOTIFY))this._sessionModule.onPushedServerOverload(s);else if(o.includes(m.CMD.KICK_OTHER)){const e=Date.now();this._sessionModule.reLoginOnKickOther();const t=new Qi("kickOther"),s=this._sessionModule.getModule(es).getLastWsHelloTs(),o=e-s;t.setMessage(`last wshello time:${s} diff:${o}ms`).setNetworkType(this._sessionModule.getNetworkType()).end()}return!1}}const da=[{cmd:m.CMD.GET_GROUP_INFO,interval:1,count:20},{cmd:m.CMD.GET_AVCHATROOM_MEMBER_LIST,interval:3,count:1},{cmd:m.CMD.GET_GROUP_APPLICATION,interval:1,count:15},{cmd:m.CMD.GET_TOPIC_LIST,interval:1,count:10},{cmd:m.CMD.SET_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.MODIFY_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.DELETE_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.CLEAR_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:m.CMD.GET_GROUP_ATTRIBUTES,interval:5,count:20},{cmd:m.CMD.UPDATE_GROUP_COUNTER,interval:5,count:20},{cmd:m.CMD.GET_GROUP_COUNTER,interval:5,count:20},{cmd:m.CMD.SET_ALL_MESSAGE_READ,interval:1,count:1},{cmd:m.CMD.GET_USER_STATUS,interval:5,count:20},{cmd:m.CMD.SUBSCRIBE_USER_STATUS,interval:5,count:20},{cmd:m.CMD.UNSUBSCRIBE_USER_STATUS,interval:5,count:20}];class pa extends Gs{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._protocolHandler=new ua(this),this._messageDispatcher=new la(this),this._commandFrequencyLimitMap=new Map,this._commandRequestInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._init();this.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}_init(){this._updateCommandFrequencyLimitMap(da)}_onCloudConfigUpdated(){let e=this.getCloudConfig("cmd_frequency_limit");Oe(e)||(e=JSON.parse(e),this._updateCommandFrequencyLimitMap(e))}_updateCommandFrequencyLimitMap(e){e.forEach(e=>{this._commandFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}updateProtocolConfig(){this._protocolHandler.update()}request(e){ge.d(this._n+".request options:",e);const{protocolName:t,tjgID:s}=e;if(!this._protocolHandler.has(t))return ge.w(`${this._n}.request unknown protocol:${t}`),yn({code:$i.CANNOT_FIND_PROTOCOL});const o=this.getProtocolData(e),{servcmd:i}=o.head;if(this._isFrequencyOverLimit(i))return yn({code:$i.OVER_FREQUENCY_LIMIT});if(this._isServerOverload(i))return yn({code:$i.OPEN_SERVICE_OVERLOAD_ERROR});Ct(s)||(o.head.tjgID=s);const n=this.getModule(Is);return ca.includes(t)?n.simplySend(o):n.send(o)}getKeyMap(e){return this._protocolHandler.getKeyMap(e)}genCommonHead(){const e=this.getModule(ls);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,a2:e.getA2Key()||void 0,tinyid:e.getTinyID()||void 0,status_instid:e.getStatusInstanceID(),sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getA2Key()?void 0:e.getUserID(),usersig:e.getA2Key()?void 0:e.getUserSig(),sdkability:192371,tjgID:""}}genCosSpecifiedHead(){const e=this.getModule(ls);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:192371}}genSSOReportHead(){const e=this.getModule(ls);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:192371}}getProtocolData(e){return this._protocolHandler.getProtocolData(e)}trans(e){const{servcmd:t,data:s}=e,o={head:{...this.genCommonHead(),servcmd:t},body:s};return this.getModule(Is).send(o)}sendComboMessage(e){const{servcmd:t,data:s}=e,o={head:{...this.genCommonHead(),servcmd:t},body:s};return this.getModule(Is).send(o)}onErrorCodeNotZero(e){const{errorCode:t}=e;if(t===$i.HELLO_ANSWER_KICKED_OUT){const{kickType:t,newInstanceInfo:s={}}=e;1===t?this.onMultipleAccountKickedOut(s):2===t?this.onMultipleDeviceKickedOut(s):3===t&&this.onRestApiKickedOut(s)}if(t===$i.MESSAGE_A2KEY_EXPIRED||t===$i.ACCOUNT_A2KEY_EXPIRED){this._onUserSigExpired();this.getModule(Is).reConnect()}}onMessage(e){const{body:t}=e,{needAck:s=0,sessionData:o}=t;1===s&&this._sendACK(o),this._messageDispatcher.onMessage(e)}onReconnected(){this._reLoginOnReconnected()}reLoginOnKickOther(){ge.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){ge.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){if(this.isLoggedIn()){let e=0;const t=this.getModule(vs);t.canIUseOfflinePush()&&(e=t.getUniAppPlatform()),this.request({protocolName:Us,requestData:{isWebUniapp:e}}).then(e=>{const{instanceID:t}=e.data;this.getModule(ls).setStatusInstanceID(t),ge.l(this._n+"._reLogin ok.");this.getModule(cs).syncConversationList().then(()=>{ge.l(this._n+"._reLogin, sync conversation list ok.");this.getModule(Ds).start()});this.getModule(ns).updateLocalMainSequenceOnReconnected();const s=this.getModule(us);s.resetGetTopicTime(),s.getTopicListOnReconnected()})}}onMultipleAccountKickedOut(e){this.getModule(es).onMultipleAccountKickedOut(e)}onMultipleDeviceKickedOut(e){this.getModule(es).onMultipleDeviceKickedOut(e)}_onUserSigExpired(){this.getModule(es).onUserSigExpired()}onRestApiKickedOut(e){this.getModule(es).onRestApiKickedOut(e)}_sendACK(e){this.request({protocolName:mi,requestData:{sessionData:e}})}_isFrequencyOverLimit(e){const t=e.split(".")[1];if(!this._commandFrequencyLimitMap.has(t))return!1;if(!this._commandRequestInfoMap.has(t))return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;const{count:s,interval:o}=this._commandFrequencyLimitMap.get(t);let{startTime:i,requestCount:n}=this._commandRequestInfoMap.get(t);if(Date.now()-i>1e3*o)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;n+=1,this._commandRequestInfoMap.set(t,{startTime:i,requestCount:n});let r=!1;return n>s&&(r=!0),r}_isServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return!1;const{overloadTime:t,waitingTime:s}=this._serverOverloadInfoMap.get(e);let o=!1;return Date.now()-t<=1e3*s?o=!0:(this._serverOverloadInfoMap.delete(e),o=!1),o}onPushedServerOverload(e){const{overloadCommand:t,waitingTime:s}=e;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:s}),ge.w(`${this._n}.onPushedServerOverload waitingTime:${s}s`)}reset(){ge.l(this._n+".reset"),this._updateCommandFrequencyLimitMap(da),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}class ha extends Gs{constructor(e){super(e),this._n="MessageLossDetectionModule",this._maybeLostSequencesMap=new Map,this._firstRoundRet=[]}onMessageMaybeLost(e,t,s){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);const o=this._maybeLostSequencesMap.get(e);for(let i=0;i-1===t.indexOf(e));0===o.length?ge.i(`${this._n}.detectFirstRound no message loss. conversationID:${e}`):this._firstRoundRet=this._firstRoundRet.concat(o),s.length=0}detectSecondRound(e,t){if(Ct(this._firstRoundRet)||Ct(t))return;const s=this._firstRoundRet.filter(e=>-1===t.indexOf(e));this._firstRoundRet.length=0;const o=s.length;if(0===o)return;let i;o<=5?i=e+"-"+s.join("-"):(s.sort((e,t)=>e-t),i=e+" start:"+s[0]+" end:"+s[o-1]+" count:"+o);new Qi("messageLoss").setMessage(i).setNetworkType(this.getNetworkType()).setLevel("warning").end(),ge.i(`${this._n}.detectSecondRound message loss detected. conversationID:${e} lostSequences:${s}`)}reset(){ge.l(this._n+".reset"),this._maybeLostSequencesMap.clear(),this._firstRoundRet.length=0}}class ga extends Gs{constructor(e){super(e),this._n="CloudControlModule",this._cloudConfig=new Map,this._expiredTime=0,this._version=0,this._isFetching=!1}getCloudConfig(e){return Oe(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}_canFetchConfig(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}fetchConfig(){const e=this._canFetchConfig();if(ge.l(`${this._n}.fetchConfig canFetchConfig:${e}`),!e)return;const t=new Qi("fetchCloudControlConfig"),s=this.getModule(ls).getSDKAppID();this._isFetching=!0,this.request({protocolName:Ci,requestData:{SDKAppID:s,version:this._version}}).then(e=>{this._isFetching=!1,t.setMessage(`version:${this._version} newVersion:${e.data.version} config:${e.data.cloudControlConfig}`).setNetworkType(this.getNetworkType()).end(),ge.l(this._n+".fetchConfig ok"),this._parseCloudControlConfig(e.data)}).catch(e=>{this._isFetching=!1,this.probeNetwork().then(([s,o])=>{t.setError(e,s,o).end()}),ge.l(this._n+".fetchConfig failed. error:",e),this._setExpiredTimeOnResponseError(12e4)})}onPushedCloudControlConfig(e){ge.l(this._n+".onPushedCloudControlConfig");new Qi("pushedCloudControlConfig").setNetworkType(this.getNetworkType()).setMessage(`newVersion:${e.version} config:${e.cloudControlConfig}`).end(),this._parseCloudControlConfig(e)}onCheckTimer(e){this._canFetchConfig()&&this.fetchConfig()}_parseCloudControlConfig(e){const t=this._n+"._parseCloudControlConfig",{errorCode:s,errorMessage:o,cloudControlConfig:i,version:n,expiredTime:r}=e;if(0===s){if(this._version!==n){let e=null;try{e=JSON.parse(i)}catch(a){this.isPrivateNetWork()||ge.e(t+" JSON parse error. cloudControlConfig:",i)}e&&(this._cloudConfig.clear(),Object.keys(e).forEach(t=>{this._cloudConfig.set(t,e[t])}),this._version=n,this.emitInnerEvent(vn))}this._expiredTime=Date.now()+1e3*r}else Oe(s)?(ge.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(ge.e(`${t} errorCode:${s} errorMessage:${o}`),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}reset(){ge.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class _a extends Gs{constructor(e){super(e),this._n="RecoverMessageModule",this.PULL_LIMIT_COUNT=15}start(){this._recoverGroupChat(),this._recoverC2CChat()}_recoverGroupChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_GROUP&&e.groupProfile.type!==t.GRP_AVCHATROOM),s=this.getModule(cs);let o,i,n=0,r=0,a=0;e.forEach(e=>{const{conversationID:u,lastMessage:c}=e;i=u.replace(t.CONV_GROUP,""),o=s.getLocalLastMessage(u),c&&0!==c.lastSequence&&o?(r=c.lastSequence,n=o.sequence,a=r-n,n>0&&a>=1&&a<300?this._recoverGroupMessage({groupID:i,localLastMessageSequence:n,remoteLastMessageSequence:r}):this._getGroupNotify(i)):this._getGroupNotify(i)})}_recoverC2CChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_C2C),s=this.getModule(cs);let o,i=0,n=0,r=0;const a=[Promise.resolve()];e.forEach(e=>{const{conversationID:t,lastMessage:u}=e;o=s.getLocalLastMessage(t),u&&0!==u.lastTime&&o&&(n=u.lastTime,i=o.time,r=n-i,i>0&&r>=1&&r<=600&&a.push(this._recoverC2CMessage({conversationID:t,localLastMessageTime:i,remoteLastMessageTime:n})))}),Promise.all(a).then(()=>{ge.l(this._n+"._recoverC2CChat all promise fulfilled, start to sync unread messages");this.getModule(Ms).startSyncOnReconnected()})}_getLocalConversationList(){return this.getModule(cs).getLocalConversationList()}_recoverGroupMessage(e){const s=this._n+"._recoverGroupMessage";ge.l(s+" options:",e);const{groupID:o,localLastMessageSequence:i,remoteLastMessageSequence:n}=e;this._getGroupRomaingMessage({groupID:o,sequence:i}).then(e=>{const{complete:i,messageList:r}=e.data;if(!Oe(r)){const e=r[0].sequence;ge.l(`${s} pkgLastMessageSequence:${e} complete:${i}`),e1&&r.sort((e,t)=>e.sequence-t.sequence);for(let s=0;s{const{complete:o,messageList:n}=e.data;if(!Oe(n)){const e=n.length;new Qi("recoverMessage").setNetworkType(this.getNetworkType()).setMessage(`${s} complete:${o} messageList length:${e}`).end();this.getModule(is).onNewC2CMessage({dataList:n,isInstantMessage:!0});const r=n[e-1].time;if(ge.l(`${t} pkgLastMessageTime:${r} complete:${o}`),r=0&&this._e2eDelayArray.push(t)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),ct(s/t,1)}_calcCountWithLimit(e){const{e2eDelayArray:t,min:s,max:o}=e;return t.filter(e=>s<=e&&e100&&(s=100),s}_checkE2EDelayException(e,t){const s=e.filter(e=>e>t);if(s.length>0){const t=s.length,o=Math.min(...s),i=Math.max(...s),n=this._calcAvg(s,t),r=ct(t/e.length*100,2);if(r>50){new Qi("messageE2EDelayException").setMessage(`count:${t} min:${o} max:${i} avg:${n} percent:${r}`).setLevel("warning").end()}}}getStatResult(){const e=this._e2eDelayArray.length;if(0===e)return null;const t=[...this._e2eDelayArray],s=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),o=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),i=this._calcPercent(s,e),n=this._calcPercent(o,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:s,percentOfCountLessThan1Second:i,countLessThan3Second:o,percentOfCountLessThan3Second:n,avgDelay:r}}reset(){this._e2eDelayArray.length=0}}class Ma{constructor(){this._n="AvgRTT",this._requestCount=0,this._rttArray=[]}addRequestCount(){this._requestCount+=1}addRTT(e){this._rttArray.push(e)}_calcTotalCount(){return this._requestCount}_calcRTTCount(e){return e.length}_calcSuccessRateOfRequest(e,t){if(0===t)return 0;let s=ct(e/t*100,2);return s>100&&(s=100),s}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),parseInt(s/t)}_calcMax(){return Math.max(...this._rttArray)}_calcMin(){return Math.min(...this._rttArray)}getStatResult(){const e=this._calcTotalCount(),t=[...this._rttArray];if(0===e)return null;const s=this._calcRTTCount(t),o=this._calcSuccessRateOfRequest(s,e),i=this._calcAvg(t,s);return ge.l(`${this._n}.getStatResult max:${this._calcMax()} min:${this._calcMin()} avg:${i}`),this.reset(),{totalCount:e,rttCount:s,successRateOfRequest:o,avgRTT:i}}reset(){this._requestCount=0,this._rttArray.length=0}}class fa{constructor(){this._map=new Map}initMap(e){e.forEach(e=>{this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})})}addTotalCount(e){return!(Oe(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}addSuccessCount(e){return!(Oe(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}addFailedCountOfUserSide(e){return!(Oe(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}addCost(e,t){return!(Oe(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}addFileSize(e,t){return!(Oe(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}_calcSuccessRateOfBusiness(e){if(Oe(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=ct(t.successCount/t.totalCount*100,2);return s>100&&(s=100),s}_calcSuccessRateOfPlatform(e){if(Oe(e)||!this._map.has(e))return-1;const t=this._map.get(e);let s=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return s=ct(s,2),s>100&&(s=100),s}_calcTotalCount(e){return Oe(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}_calcSuccessCountOfBusiness(e){return Oe(e)||!this._map.has(e)?-1:this._map.get(e).successCount}_calcSuccessCountOfPlatform(e){if(Oe(e)||!this._map.has(e))return-1;const t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}_calcAvg(e){return Oe(e)||!this._map.has(e)?-1:e===Ki?this._calcAvgSpeed(e):this._calcAvgCost(e)}_calcAvgCost(e){const t=this._map.get(e).costArray.length;if(0===t)return 0;let s=0;return this._map.get(e).costArray.forEach(e=>{s+=e}),parseInt(s/t)}_calcAvgSpeed(e){let t=0,s=0;return this._map.get(e).costArray.forEach(e=>{t+=e}),this._map.get(e).fileSizeArray.forEach(e=>{s+=e}),parseInt(1e3*s/t)}getStatResult(e){const t=this._calcTotalCount(e);if(0===t)return null;const s=this._calcSuccessCountOfBusiness(e),o=this._calcSuccessRateOfBusiness(e),i=this._calcSuccessCountOfPlatform(e),n=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:s,successRateOfBusiness:o,successCountOfPlatform:i,successRateOfPlatform:n,avgValue:r}}reset(e){Oe(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}class Ia{constructor(){this._lastMap=new Map,this._currentMap=new Map}initMap(e){e.forEach(e=>{this._lastMap.set(e,new Map),this._currentMap.set(e,new Map)})}addMessageSequence(e){const{key:s,message:o}=e;if(Oe(s)||!this._lastMap.has(s)||!this._currentMap.has(s))return!1;const{conversationID:i,sequence:n}=o,r=i.replace(t.CONV_GROUP,"");if(0===this._lastMap.get(s).size)this._addCurrentMap(e);else if(this._lastMap.get(s).has(r)){const t=this._lastMap.get(s).get(r),o=t.length-1;n>t[0]&&n{const i=[...e.values()],n=i.length;t+=i[n-1]-i[0]+1,s+=n}),0===t)return null;let o=ct(s/t*100,2);return o>100&&(o=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:s,successRateOfMessageReceived:o}}reset(){this._currentMap.clear(),this._lastMap.clear()}}class Ca extends Gs{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[Fi,qi,xi,Vi,Bi,Hi,Ki,Wi,Yi,ji],this._messageSentItems=[xi,Vi,Bi,Hi,Ki],this._messageReceivedItems=[Wi,Yi,ji],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new Ma,this._avgE2EDelay=new ma,this._rateMessageSent=new fa,this._rateMessageReceived=new Ia;const t=this.getInnerEmitterInstance();t.on(Sn,this._onLoginSuccess,this),t.on(vn,this._onCloudConfigUpdated,this)}_onLoginSuccess(){this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);const e=this.getModule(ds),t=e.getItem(this.TAG,!1);!Ct(t)&&Ue(t.forEach)&&(ge.l(`${this._n}._onLoginSuccess get quality stat logs from local storage, count:${t.length}`),t.forEach(e=>{this._statInfoArr.push(e)}),e.removeItem(this.TAG,!1))}_onCloudConfigUpdated(){const e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),s=this.getCloudConfig("q_rpt_tinyid_wl");Oe(e)||(this.REPORT_INTERVAL=Number(e)),Oe(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map(e=>Number(e))),Oe(s)||(this.REPORT_TINYID_WHITELIST=s.split(","))}onCheckTimer(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}addRequestCount(){this._avgRTT.addRequestCount()}addRTT(e){this._avgRTT.addRTT(e)}addMessageDelay(e){this._avgE2EDelay.addMessageDelay(e)}addTotalCount(e){this._rateMessageSent.addTotalCount(e)||ge.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||ge.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||ge.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||ge.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||ge.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||ge.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=Xi[this.getNetworkType()];Oe(s)&&(s=8);const o={qualityType:zi[e],timestamp:ue(),networkType:s,extension:""};switch(e){case Fi:t=this._avgRTT.getStatResult();break;case qi:t=this._avgE2EDelay.getStatResult();break;case xi:case Vi:case Bi:case Hi:case Ki:t=this._rateMessageSent.getStatResult(e);break;case Wi:case Yi:case ji:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:{...o,...t}}_report(e){let t=[],s=null;Oe(e)?this._qualityItems.forEach(e=>{s=this._getQualityItem(e),null!==s&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))}):(s=this._getQualityItem(e),null!==s&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))),ge.d(this._n+"._report",t),this._statInfoArr.length>0&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);const o=this.getModule(ls),i=o.getSDKAppID(),n=o.getTinyID();lt(this.REPORT_SDKAPPID_BLACKLIST,i)&&!dt(this.REPORT_TINYID_WHITELIST,n)&&(t=[]),t.length>0&&this._doReport(t)}_doReport(e){const t={header:Lr(this),quality:e};this.request({protocolName:pi,requestData:{...t}}).then(()=>{this.reportIndex++,this.wholePeriod=!1}).catch(t=>{ge.w(`${this._n}._doReport, online:${this.getNetworkType()} error:`,t),this._statInfoArr=this._statInfoArr.concat(e),this._flushAtOnce()})}_flushAtOnce(){const e=this.getModule(ds),t=e.getItem(this.TAG,!1),s=this._statInfoArr,o=this._n+"._flushAtOnce";if(Ct(t))ge.l(`${o} count:${s.length}`),e.setItem(this.TAG,s,!0,!1);else{let i=s.concat(t);i.length>10&&(i=i.slice(0,10)),ge.l(`${o} count:${i.length}`),e.setItem(this.TAG,i,!0,!1)}this._statInfoArr=[]}reset(){ge.l(this._n+".reset"),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}class Ta extends Gs{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init();this.getInnerEmitterInstance().on(vn,this._onCloudConfigUpdated,this)}isWorkerEnabled(){return this._isWorkerEnabled&&Z}startWorkerTimer(){ge.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){ge.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(Z){const e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000); postMessage(interval); } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);const t=this;this._workerTimer.onmessage=function(e){e.data?(t._timerID=e.data,ge.l(`${t._n}._init seed:${t._timerID}`)):t._m.onCheckTimer()}}}_onCloudConfigUpdated(){const e=this.getCloudConfig("enable_worker");ge.l(`${this._n}._onCloudConfigUpdated enableWorker:${e}`),Oe(e)||"1"===e?!this._isWorkerEnabled&&Z&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&Z&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){ge.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){ge.l(this._n+".reset")}}class ya{constructor(){this._n="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}isValidPurchaseBits(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}parsePurchaseBits(e){if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();let t=null;for(let s=e.length-1,i=0;s>=0;s--,i++)t=i<32?new o(0,Math.pow(2,i)).toString():new o(Math.pow(2,i-32),0).toString(),"1"===e[s]?this._purchasedFeatureMap.set(t,!0):this._purchasedFeatureMap.set(t,!1)}else ge.w(`${this._n}.parsePurchaseBits invalid purchasebits:${e}`)}hasPurchasedFeature(e){return!!this._purchasedFeatureMap.get(e)}isFeatureEnabled(e){const t=parseInt(e).toString(2);let s=void 0,i=!0;for(let n=t.length-1,r=0;n>=0;n--,r++)if("1"===t.charAt(n)&&(s=r<32?new o(0,Math.pow(2,r)).toString():new o(Math.pow(2,r-32),0).toString(),!this._purchasedFeatureMap.get(s))){i=!1;break}return ge.l(`${this._n}.isFeatureEnabled decimalNumber:${e} binaryString:${t} ret:${i}`),Tn({enabled:i})}clear(){this._purchasedFeatureMap.clear()}}class Da{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new ya}_canFetch(){return this._getModule(ls).isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}onCheckTimer(e){this._canFetch()&&this.fetchConfig()}fetchConfig(){const e=this._canFetch(),t=this._n+".fetchConfig";if(ge.l(`${t} canFetch:${e}`),!e)return;const s=this._getModule(hs),o=new Qi("fetchCommercialConfig");o.setNetworkType(s.getNetworkType());const i=this._getModule(ls).getSDKAppID(),n=this._getModule(fs);this._isFetching=!0,n.request({protocolName:yi,requestData:{SDKAppID:i}}).then(e=>{o.setMessage("purchaseBits:"+e.data.purchaseBits).end(),ge.l(t+" ok."),this._parseConfig(e.data),this._isFetching=!1}).catch(e=>{s.probe().then(([t,s])=>{o.setError(e,t,s).end()}),this._isFetching=!1})}onPushedConfig(e){const t=`${this._n}.onPushedConfig data:${JSON.stringify(e)}`;ge.l(""+t);new Qi("pushedCommercialConfig").setNetworkType(this._getModule(hs).getNetworkType()).setMessage("purchaseBits:"+e.purchaseBits).end(),this._parseConfig(e)}_parseConfig(e){const t=this._n+"._parseConfig",{errorCode:s,errorMessage:o,purchaseBits:i,expiredTime:n}=e;0===s?(this._purchasedFeatureHandler.parsePurchaseBits(i),this._expiredTime=Date.now()+1e3*n):Oe(s)?(ge.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(ge.e(`${t} errorCode:${s} errorMessage:${o}`),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}canIUse(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}isFeatureEnabled(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}_getModule(e){return this._m.getModule(e)}reset(){ge.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class Ea extends Gs{constructor(e){super(e),this._m=e,this._n="OfflinePushModule",this._offlinePushPlugin=void 0,this._androidPushConfig={huaweiPushBussinessId:"",xiaomiPushBussinessId:"",xiaomiPushAppId:"",xiaomiPushAppKey:"",meizuPushBussinessId:"",meizuPushAppId:"",meizuPushAppKey:"",vivoPushBussinessId:"",fcmPushBussinessId:"",oppoPushBussinessId:"",oppoPushAppKey:"",oppoPushAppSecret:"",honorPushBussinessId:""},this._deviceToken="",this._businessID=0,this._iosBusinessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0}registerPlugin(e){if(!G)return void this.outputWarning("OfflinePushInUniapp");this._offlinePushPlugin=e["tim-offline-push-plugin"];const{huaweiBusinessID:t,xiaomiBusinessID:s,xiaomiAppID:o,xiaomiAppKey:i,meizuBusinessID:n,meizuAppID:r,meizuAppKey:a,vivoBusinessID:u,oppoBusinessID:c,oppoAppKey:l,oppoAppSecret:d,honorBusinessID:p,iosBusinessID:h}=e.offlinePushConfig||{};this._androidPushConfig.huaweiPushBussinessId=t,this._androidPushConfig.xiaomiPushBussinessId=s,this._androidPushConfig.xiaomiPushAppId=o,this._androidPushConfig.xiaomiPushAppKey=i,this._androidPushConfig.meizuPushBussinessId=n,this._androidPushConfig.meizuPushAppId=r,this._androidPushConfig.meizuPushAppKey=a,this._androidPushConfig.vivoPushBussinessId=u,this._androidPushConfig.oppoPushBussinessId=c,this._androidPushConfig.oppoPushAppKey=l,this._androidPushConfig.oppoPushAppSecret=d,this._androidPushConfig.honorPushBussinessId=p;new Qi("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!Oe(this._offlinePushPlugin)).end(!0),ge.l(`${this._n}.registerPlugin ok. offlinePushConfig:${JSON.stringify(e.offlinePushConfig)}`),this._iosBusinessID=h,this._setAppShowListener()}init(){this._isWebUniapp=this.getUniAppPlatform(),this._getDeviceToken()}_getDeviceToken(){const e=this._n+"._getDeviceToken";if(!Ue(this._offlinePushPlugin.getDeviceToken))return void ge.e(e+" getDeviceToken is not a function");let t=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:${this._iosBusinessID}`;ge.l(`${e} start. ${t}`);new Qi("_getDeviceToken").setMessage(""+t).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,s=>{const o=new Qi("getDeviceTokenRes"),{code:i,msg:n}=s;if(0===i){const{deviceToken:i,deviceBrand:n,deviceType:r,bussinessId:a}=s.data;this._deviceToken=i,this._businessID=a||this._iosBusinessID,t=`deviceToken:${i}, deviceBrand:${n||r}, businessID:${this._businessID}`,ge.l(`${e} ok. ${t}`),o.setMessage(t).end(!0),this._setToken()}else o.setMessage(`code:${i}, msg:${n}`).end(!0),ge.e(e+" failed. error:",s)})}canIUseOfflinePush(){return G&&!Oe(this._offlinePushPlugin)}_setAppShowListener(){const e=this._n+"._setAppShowListener";if(Oe(this._offlinePushPlugin))return void ge.e(e+" offlinePushPlugin is undefined");if(!Ue(this._offlinePushPlugin.setAppShowListener))return void ge.e(e+" setAppShowListener is not a function");new Qi("_setAppShowListener").end(!0),ge.l(e+" start"),this._offlinePushPlugin.setAppShowListener(t=>{const{appShow:s}=t||{};new Qi("setAppShowListenerRes").setMessage("appShow:"+s).end(!0),ge.l(`${e} ok. appShow:${s}`),this._m.isReady()&&(0===s?(this._getConvUnreadCount(),this._onBackground()):1===s&&this._onForeground())})}getDeviceBrand(){if(!Oe(this._offlinePushPlugin)&&Ue(this._offlinePushPlugin.getDeviceType)){const{deviceType:e}=this._offlinePushPlugin.getDeviceType()||{};return ge.l(`${this._n}.getDeviceBrand ok. deviceType:${e}`),e}}_setToken(){const e=this._n+"._setToken",t=this.getModule(ls);let s="",o=1,i="",r="";Ct(this._deviceToken)&&(o=0);const a=this.getUniAppPlatform(),u=this.getDeviceBrand();a===n.IOS||a===n.IPAD||a===n.MAC?r=this._deviceToken:a===n.ANDROID&&(i=this._deviceToken);const c=new Qi("offlinePushSetToken");return s=`deviceToken:${r||i}, businessID:${this._businessID}, deviceBrand:${u}, isWebUniapp:${this._isWebUniapp}, pushMsg:${o}, platform:${a}`,c.setMessage(""+s),ge.l(`${e} ${s}`),this.request({protocolName:ki,requestData:{tokenID:i,pushMsg:o,sdkAppID:t.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:u,deviceToken:r,isWebUniapp:this._isWebUniapp}}).then(t=>(c.end(),ge.l(e+" ok"),t)).catch(t=>(this.probeNetwork().then(([e,s])=>{c.setError(t,e,s).end()}),ge.e(e+" failed. error:",t),yn(t)))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0;this.getModule(cs).getLocalConversationList().forEach(e=>{e.type===t.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===t.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)})}_onBackground(){const e=this._n+"._onBackground",t=new Qi("_onBackground");this.request({protocolName:Ui,requestData:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(s=>(t.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: ${this._groupUnreadCount}`).end(),ge.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),ge.e(e+" failed. error:",s)})}_onForeground(){const e=this._n+"._onForeground",t=new Qi("_onForeground");this.request({protocolName:Pi,requestData:{isWebUniapp:this._isWebUniapp}}).then(s=>(t.end(),ge.l(e+" ok"),s)).catch(s=>{this.probeNetwork().then(([e,o])=>{t.setError(s,e,o).end()}),ge.e(e+" failed. error:",s)})}getUniAppPlatform(){const e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?n.IOS:"android"===e?n.ANDROID:1002===t?n.IPAD:1001===t?n.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,ge.l(this._n+".reset")}}class Sa extends Gs{constructor(e){super(e),this._n="ProfanityFilterModule",this._plugin=null,this._filterConfigMap=new Map,this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}init(){const e=this.getModule(ms).getPlugin("tim-profanity-filter-plugin");e?(this._plugin=new e({logger:ge,isArray:Ne,isMap:Ee,isDevMode:this.isDevMode()}),this._getLexicon()):this.outputWarning("ProfanityPluginNotFound")}onCheckTimer(){this._plugin&&this._canIUseLexicon&&this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime&&this._getLexicon()}filterMessage(e,s){let o=!0;if(!this._plugin||!this._canIUseLexicon)return o;if(s&&s.messageControlInfo&&!0===s.messageControlInfo.excludedFromContentModeration)return o;const{type:i,conversationType:n}=e;if(i!==t.MSG_TEXT&&i!==t.MSG_CUSTOM)return o;const r=this._n+".filterMessage";let a;if(ge.l(""+r),i===t.MSG_TEXT){if(n===t.CONV_C2C?a=f:n===t.CONV_GROUP&&(a=C),!this._isConfigOn(a))return o;const{type:s,modifiedText:i}=this._plugin.filter(e.payload.text);1===s?o=!1:2===s&&(e.payload.text=i)}else if(i===t.MSG_CUSTOM){if(n===t.CONV_C2C?a=I:n===t.CONV_GROUP&&(a=T),!this._isConfigOn(a))return o;const s=this._plugin.filter(e.payload.data),i=this._plugin.filter(e.payload.description),r=this._plugin.filter(e.payload.extension);1===s.type||1===i.type||1===r.type?o=!1:(2===s.type&&(e.payload.data=s.modifiedText),2===i.type&&(e.payload.description=i.modifiedText),2===r.type&&(e.payload.extension=r.modifiedText))}return ge.l(`${r} done. isAllowedToSend:${o}`),o}filterText(e,t){const s=this._n+".filterText",o={isAllowedToSend:!0,modifiedText:e};if(!this._plugin||!this._canIUseLexicon)return o;if(!this._isConfigOn(t))return o;ge.l(""+s);const{type:i,modifiedText:n}=this._plugin.filter(e);return 1===i?o.isAllowedToSend=!1:2===i&&(o.modifiedText=n),ge.l(s+" done. ret:",o),o}_getLexicon(){const e=new Qi("profanityFilter"),t=this._n+"._getLexicon";this._isFetching=!0,this.request({protocolName:bi,requestData:{startIndex:this._startIndex,version:this._version}}).then(s=>{const{errorInfo:o,filterConfig:i,lexicon:n,strToken:r,completeFlag:a,nextStartIndex:u,version:c,expiredTime:l}=s.data,{errorCode:d,errorMessage:p}=o;return 0!==d?(this._isFetching=!1,ge.w(t+" failed. error:",o),void e.setCode(d).setMessage(p).end()):(this._onFilterConfig(i),this._getToken(r),1===a?(ge.l(`${t} done. version:${c} expiredTime:${l}`),this._version=c,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*l,void this._plugin.onLexiconCompleted(n)):(this._startIndex=u,this._plugin.onLexiconSliced(n),void this._getLexicon()))}).catch(s=>{this.probeNetwork().then(([t,o])=>{e.setError(s,t,o).end()}),this._isFetching=!1,ge.l(t+" failed. error:",s)})}_onFilterConfig(e){Ct(e)||(this._filterConfigMap.clear(),Object.keys(e).forEach(t=>{this._filterConfigMap.set(t,e[t])}),ge.l(`${this._n}._onFilterConfig. keys:${Array.from(this._filterConfigMap.keys())} values:${Array.from(this._filterConfigMap.values())}`))}_isConfigOn(e){return 1===this._filterConfigMap.get(e)}_getToken(e){if(!Le(e))return;const t=e.length;let s="";if(t%2==0)for(let o=0;o<=t-1;o+=2)s+=e[o+1],s+=e[o];else{for(let o=0;o{this._TRTCCommandList.includes(e)||this._TRTCCommandList.push(e)}))}sendTRTCCustomData(e){const{serviceCommand:t,data:s}=e;let o=m.NAME.TUIROOM_SVR+".*";return Oe(t)||(o=t),this._TRTCCommandList.includes(o)?this._trans({servcmd:o,data:s}):yn({code:$i.INVALID_TRTC_CMD})}_trans(e){ge.d(`${this._n}._trans. options:${JSON.stringify(e)}`);const{servcmd:t,data:s}=e;return this._m.getModule(fs).trans({servcmd:t,data:Le(s)?JSON.parse(s):s})}getCommandList(){return this._TRTCCommandList}reset(){ge.l(this._n+".reset")}}class La{constructor(e){this._m=e,this._n="ErrorMessageModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this._map=new Map,this._init()}_init(){const e=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(!e)return void this._fetch();let t;try{t=JSON.parse(e)}catch(s){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),ge.w(this._n+"._init error:",s)}t&&(this._needToUpdate(t)?this._fetch():this._fillMap(t.message))}_needToUpdate(e){const{localSavedTime:t,localSavedVersion:s}=e,o=t&&(new Date).getTime()-t>=this.STORAGE_EXPIRES_TIME,i=!s||"2.27.6"!==s;return ge.l(`${this._n}._needToUpdate isTimeout:${o} isDifferentVersion:${i}`),o||i}_fetch(){if(this._m.getModule(ls).isPrivateNetWork())return;const e="https://web.sdk.qcloud.com/im/download/error-message/0.0.1/tim-error-message.txt",t="application/x-www-form-urlencoded;charset=UTF-8",s=this._n+"._fetch ok in",o=this;if(P)b.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:e=>{o._fillAndSave(e.data),ge.l(s+" mini program")},fail:()=>{}});else{const i=new XMLHttpRequest,n=setTimeout(()=>{i.abort()},3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(n),200!==i.status&&304!==i.status||(ge.l(s+" browser"),o._fillAndSave(i.responseText)))},i.open("GET",e,!0),i.setRequestHeader("Content-type",t),i.send()}}_fillAndSave(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:"2.27.6"}),!0,!1)}_getStorageModule(){return this._m.getModule(ds)}_fillMap(e){this._map.clear();const t=e.split(";\n"),s=t.length;let o,i,n;const r=new RegExp(/'/g);for(let a=0;a>>16&65535|0,r=0;0!==s;){s-=r=s>2e3?2e3:s;do{n=n+(i=i+t[o++]|0)|0}while(--r);i%=65521,n%=65521}return i|n<<16|0};var Na=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var o=0;o<8;o++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();var Oa=function(e,t,s,o){var i=Na,n=o+s;e^=-1;for(var r=o;r>>8^i[255&(e^t[r])];return-1^e},Ga=function(e,t){var s,o,i,n,r,a,u,c,l,d,p,h,g,_,m,M,f,I,C,T,y,D,E,S,v;s=e.state,o=e.next_in,S=e.input,i=o+(e.avail_in-5),n=e.next_out,v=e.output,r=n-(t-e.avail_out),a=n+(e.avail_out-257),u=s.dmax,c=s.wsize,l=s.whave,d=s.wnext,p=s.window,h=s.hold,g=s.bits,_=s.lencode,m=s.distcode,M=(1<>>=C=I>>>24,g-=C,0===(C=I>>>16&255))v[n++]=65535&I;else{if(!(16&C)){if(0==(64&C)){I=_[(65535&I)+(h&(1<>>=C,g-=C),g<15&&(h+=S[o++]<>>=C=I>>>24,g-=C,!(16&(C=I>>>16&255))){if(0==(64&C)){I=m[(65535&I)+(h&(1<u){e.msg="invalid distance too far back",s.mode=30;break e}if(h>>>=C,g-=C,y>(C=n-r)){if((C=y-C)>l&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(D=0,E=p,0===d){if(D+=c-C,C2;)v[n++]=E[D++],v[n++]=E[D++],v[n++]=E[D++],T-=3;T&&(v[n++]=E[D++],T>1&&(v[n++]=E[D++]))}else{D=n-y;do{v[n++]=v[D++],v[n++]=v[D++],v[n++]=v[D++],T-=3}while(T>2);T&&(v[n++]=v[D++],T>1&&(v[n++]=v[D++]))}break}}break}}while(o>3,h&=(1<<(g-=T<<3))-1,e.next_in=o,e.next_out=n,e.avail_in=o=1&&0===N[T];T--);if(y>T&&(y=T),0===T)return i[n++]=20971520,i[n++]=20971520,a.bits=1,0;for(C=1;C0&&(0===e||1!==T))return-1;for(O[1]=0,f=1;f<15;f++)O[f+1]=O[f]+N[f];for(I=0;I852||2===e&&v>592)return 1;for(;;){g=f-E,r[I]h?(_=G[U+r[I]],m=A[R+r[I]]):(_=96,m=0),u=1<>E)+(c-=u)]=g<<24|_<<16|m|0}while(0!==c);for(u=1<>=1;if(0!==u?(L&=u-1,L+=u):L=0,I++,0==--N[f]){if(f===T)break;f=t[s+r[I]]}if(f>y&&(L&d)!==l){for(0===E&&(E=y),p+=C,S=1<<(D=f-E);D+E852||2===e&&v>592)return 1;i[l=L&d]=y<<24|D<<16|p-n|0}}return 0!==L&&(i[p+L]=f-E<<24|64<<16|0),a.bits=y,0};function $a(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Fa(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Aa.Buf16(320),this.work=new Aa.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function qa(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Aa.Buf32(852),t.distcode=t.distdyn=new Aa.Buf32(592),t.sane=1,t.back=-1,0):-2}function xa(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,qa(e)):-2}function Va(e,t){var s,o;return e&&e.state?(o=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==o.window&&o.wbits!==t&&(o.window=null),o.wrap=s,o.wbits=t,xa(e))):-2}function Ba(e,t){var s,o;return e?(o=new Fa,e.state=o,o.window=null,0!==(s=Va(e,t))&&(e.state=null),s):-2}var Ha,Ka,Wa=!0;function Ya(e){if(Wa){var t;for(Ha=new Aa.Buf32(512),Ka=new Aa.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(wa(1,e.lens,0,288,Ha,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;wa(2,e.lens,0,32,Ka,0,e.work,{bits:5}),Wa=!1}e.lencode=Ha,e.lenbits=9,e.distcode=Ka,e.distbits=5}function ja(e,t,s,o){var i,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(Aa.arraySet(n.window,t,s-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((i=n.wsize-n.wnext)>o&&(i=o),Aa.arraySet(n.window,t,s-o,i,n.wnext),(o-=i)?(Aa.arraySet(n.window,t,s-o,o,0),n.wnext=o,n.whave=n.wsize):(n.wnext+=i,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,s.check=Oa(s.check,L,2,0),c=0,l=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&c)){e.msg="unknown compression method",s.mode=30;break}if(l-=4,y=8+(15&(c>>>=4)),0===s.wbits)s.wbits=y;else if(y>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<>8&1),512&s.flags&&(L[0]=255&c,L[1]=c>>>8&255,s.check=Oa(s.check,L,2,0)),c=0,l=0,s.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,c+=o[n++]<>>8&255,L[2]=c>>>16&255,L[3]=c>>>24&255,s.check=Oa(s.check,L,4,0)),c=0,l=0,s.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,c+=o[n++]<>8),512&s.flags&&(L[0]=255&c,L[1]=c>>>8&255,s.check=Oa(s.check,L,2,0)),c=0,l=0,s.mode=5;case 5:if(1024&s.flags){for(;l<16;){if(0===a)break e;a--,c+=o[n++]<>>8&255,s.check=Oa(s.check,L,2,0)),c=0,l=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=s.length)>a&&(h=a),h&&(s.head&&(y=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),Aa.arraySet(s.head.extra,o,n,h,y)),512&s.flags&&(s.check=Oa(s.check,o,h,n)),a-=h,n+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;h=0;do{y=o[n+h++],s.head&&y&&s.length<65536&&(s.head.name+=String.fromCharCode(y))}while(y&&h>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;l<32;){if(0===a)break e;a--,c+=o[n++]<>>=7&l,l-=7&l,s.mode=27;break}for(;l<3;){if(0===a)break e;a--,c+=o[n++]<>>=1)){case 0:s.mode=14;break;case 1:if(Ya(s),s.mode=20,6===t){c>>>=2,l-=2;break e}break;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,c+=o[n++]<>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,c=0,l=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(h>a&&(h=a),h>u&&(h=u),0===h)break e;Aa.arraySet(i,o,n,h,r),a-=h,n+=h,u-=h,r+=h,s.length-=h;break}s.mode=12;break;case 17:for(;l<14;){if(0===a)break e;a--,c+=o[n++]<>>=5,l-=5,s.ndist=1+(31&c),c>>>=5,l-=5,s.ncode=4+(15&c),c>>>=4,l-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have>>=3,l-=3}for(;s.have<19;)s.lens[A[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,E={bits:s.lenbits},D=wa(0,s.lens,0,19,s.lencode,0,s.work,E),s.lenbits=E.bits,D){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have>>16&255,f=65535&v,!((m=v>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<>>=m,l-=m,s.lens[s.have++]=f;else{if(16===f){for(S=m+2;l>>=m,l-=m,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}y=s.lens[s.have-1],h=3+(3&c),c>>>=2,l-=2}else if(17===f){for(S=m+3;l>>=m)),c>>>=3,l-=3}else{for(S=m+7;l>>=m)),c>>>=7,l-=7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=y}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,E={bits:s.lenbits},D=wa(1,s.lens,0,s.nlen,s.lencode,0,s.work,E),s.lenbits=E.bits,D){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,E={bits:s.distbits},D=wa(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,E),s.distbits=E.bits,D){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(a>=6&&u>=258){e.next_out=r,e.avail_out=u,e.next_in=n,e.avail_in=a,s.hold=c,s.bits=l,Ga(e,p),r=e.next_out,i=e.output,u=e.avail_out,n=e.next_in,o=e.input,a=e.avail_in,c=s.hold,l=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;M=(v=s.lencode[c&(1<>>16&255,f=65535&v,!((m=v>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<>I)])>>>16&255,f=65535&v,!(I+(m=v>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<>>=I,l-=I,s.back+=I}if(c>>>=m,l-=m,s.back+=m,s.length=f,0===M){s.mode=26;break}if(32&M){s.back=-1,s.mode=12;break}if(64&M){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&M,s.mode=22;case 22:if(s.extra){for(S=s.extra;l>>=s.extra,l-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;M=(v=s.distcode[c&(1<>>16&255,f=65535&v,!((m=v>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<>I)])>>>16&255,f=65535&v,!(I+(m=v>>>24)<=l);){if(0===a)break e;a--,c+=o[n++]<>>=I,l-=I,s.back+=I}if(c>>>=m,l-=m,s.back+=m,64&M){e.msg="invalid distance code",s.mode=30;break}s.offset=f,s.extra=15&M,s.mode=24;case 24:if(s.extra){for(S=s.extra;l>>=s.extra,l-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===u)break e;if(h=p-u,s.offset>h){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}h>s.wnext?(h-=s.wnext,g=s.wsize-h):g=s.wnext-h,h>s.length&&(h=s.length),_=s.window}else _=i,g=r-s.offset,h=s.length;h>u&&(h=u),u-=h,s.length-=h;do{i[r++]=_[g++]}while(--h);0===s.length&&(s.mode=21);break;case 26:if(0===u)break e;i[r++]=s.length,u--,s.mode=21;break;case 27:if(s.wrap){for(;l<32;){if(0===a)break e;a--,c|=o[n++]<=252?6:Qa>=248?5:Qa>=240?4:Qa>=224?3:Qa>=192?2:1;Za[254]=Za[254]=1;function eu(e,t){if(t<65534&&(e.subarray&&Xa||!e.subarray&&Ja))return String.fromCharCode.apply(null,Aa.shrinkBuf(e,t));for(var s="",o=0;o>>6,t[n++]=128|63&s):s<65536?(t[n++]=224|s>>>12,t[n++]=128|s>>>6&63,t[n++]=128|63&s):(t[n++]=240|s>>>18,t[n++]=128|s>>>12&63,t[n++]=128|s>>>6&63,t[n++]=128|63&s);return t},su=function(e){for(var t=new Aa.Buf8(e.length),s=0,o=t.length;s4)a[o++]=65533,s+=n-1;else{for(i&=2===n?31:3===n?15:7;n>1&&s1?a[o++]=65533:i<65536?a[o++]=i:(i-=65536,a[o++]=55296|i>>10&1023,a[o++]=56320|1023&i)}return eu(a,o)},iu=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+Za[e[s]]>t?s:t},nu={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},ru={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};var au=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};var uu=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},cu=Object.prototype.toString;function lu(e){if(!(this instanceof lu))return new lu(e);this.options=Aa.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new au,this.strm.avail_out=0;var s=za.inflateInit2(this.strm,t.windowBits);if(s!==nu.Z_OK)throw new Error(ru[s]);if(this.header=new uu,za.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=tu(t.dictionary):"[object ArrayBuffer]"===cu.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=za.inflateSetDictionary(this.strm,t.dictionary))!==nu.Z_OK))throw new Error(ru[s])}function du(e,t){var s=new lu(t);if(s.push(e,!0),s.err)throw s.msg||ru[s.err];return s.result}lu.prototype.push=function(e,t){var s,o,i,n,r,a=this.strm,u=this.options.chunkSize,c=this.options.dictionary,l=!1;if(this.ended)return!1;o=t===~~t?t:!0===t?nu.Z_FINISH:nu.Z_NO_FLUSH,"string"==typeof e?a.input=su(e):"[object ArrayBuffer]"===cu.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new Aa.Buf8(u),a.next_out=0,a.avail_out=u),(s=za.inflate(a,nu.Z_NO_FLUSH))===nu.Z_NEED_DICT&&c&&(s=za.inflateSetDictionary(this.strm,c)),s===nu.Z_BUF_ERROR&&!0===l&&(s=nu.Z_OK,l=!1),s!==nu.Z_STREAM_END&&s!==nu.Z_OK)return this.onEnd(s),this.ended=!0,!1;a.next_out&&(0!==a.avail_out&&s!==nu.Z_STREAM_END&&(0!==a.avail_in||o!==nu.Z_FINISH&&o!==nu.Z_SYNC_FLUSH)||("string"===this.options.to?(i=iu(a.output,a.next_out),n=a.next_out-i,r=ou(a.output,i),a.next_out=n,a.avail_out=u-n,n&&Aa.arraySet(a.output,a.output,i,n,0),this.onData(r)):this.onData(Aa.shrinkBuf(a.output,a.next_out)))),0===a.avail_in&&0===a.avail_out&&(l=!0)}while((a.avail_in>0||0===a.avail_out)&&s!==nu.Z_STREAM_END);return s===nu.Z_STREAM_END&&(o=nu.Z_FINISH),o===nu.Z_FINISH?(s=za.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===nu.Z_OK):o!==nu.Z_SYNC_FLUSH||(this.onEnd(nu.Z_OK),a.avail_out=0,!0)},lu.prototype.onData=function(e){this.chunks.push(e)},lu.prototype.onEnd=function(e){e===nu.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Aa.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pu={Inflate:lu,inflate:du,inflateRaw:function(e,t){return(t=t||{}).raw=!0,du(e,t)},ungzip:du},hu={};(0,Aa.assign)(hu,pu,nu);var gu=hu;class _u{constructor(e){this._m=e,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1}inflate(e){const t=new Uint8Array(e).slice(4),s=Date.now();let o;try{o=gu.inflate(t,{to:"string"}),this._bLogForInflateOK||(this._bLogForInflateOK=!0,new Qi("inflateOK").end())}catch(r){if(this._bLogForInflateError)return;return this._bLogForInflateError=!0,void new Qi("inflateError").setMessage(r).end()}const i=t.length+4,n=o.length;return ge.d(`inflate ok. zipped:${i} unzipped:${n} compression ratio:${Math.round(100*(n-i)/n)}% cost:${Date.now()-s}`),o}reset(){ge.l(this._n+".reset"),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}class mu{constructor(e){const t=new Qi("sdkConstruct");this._n="ModuleManager",this._isReady=!1,this._reason=$i.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._moduleMap=new Map,this._innerEmitter=null,this._outerEmitter=null,this._checkCount=0,this._checkTimer=-1,this._moduleMap.set(ls,new yr(this,e)),this._moduleMap.set(Os,new _u(this)),this._moduleMap.set(Ss,new Da(this)),this._moduleMap.set(Ts,new ga(this)),this._moduleMap.set(ys,new Ta(this)),this._moduleMap.set(Es,new Ca(this)),this._moduleMap.set(Is,new aa(this)),this._moduleMap.set(fs,new pa(this)),this._moduleMap.set(es,new Dr(this)),this._moduleMap.set(ts,new xr(this)),this._moduleMap.set(ss,new Vr(this)),this._moduleMap.set(Rs,new Br(this)),this._moduleMap.set(os,new Tr(this)),this._moduleMap.set(is,new Dn(this)),this._moduleMap.set(cs,new Hn(this)),this._moduleMap.set(ns,new cr(this)),this._moduleMap.set(as,new dr(this)),this._moduleMap.set(us,new _r(this)),this._moduleMap.set(ds,new Sr(this)),this._moduleMap.set(Ns,new La(this)),this._moduleMap.set(ps,new Ar(this)),this._moduleMap.set(hs,new Gr(this)),this._moduleMap.set(gs,new kr(this)),this._moduleMap.set(_s,new br(this)),this._moduleMap.set(ms,new Hr(this)),this._moduleMap.set(Ms,new Kr(this)),this._moduleMap.set(Cs,new ha(this)),this._moduleMap.set(Ds,new _a(this)),this._moduleMap.set(vs,new Ea(this)),this._moduleMap.set(Ls,new Sa(this)),this._moduleMap.set(As,new va(this)),this._eventThrottleMap=new Map;const{instanceID:s,oversea:o,SDKAppID:i}=e,n=`instanceID:${s} SDKAppID:${i} host:${it()} oversea:${o} inBrowser:${k} inMiniApp:${P} canIUseInflate:`+this.canIUseInflate()+` workerAvailable:${Z} UserAgent:${w}`;Qi.bindEventStatModule(this._moduleMap.get(ps)),t.setMessage(`${n} ${function(){let e="";if(P)try{const{model:t,version:s,system:o,platform:i,SDKVersion:n}=b.getSystemInfoSync();e=`model:${t} version:${s} system:${o} platform:${i} SDKVersion:${n}`}catch(t){e=""}return e}()}`).end(),ge.i("SDK "+n),fn.prototype._getErrorMessage=this.getErrorMessage.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}_startTimer(){const e=this._moduleMap.get(ys),t=e.isWorkerEnabled();ge.l(`${this._n}.startTimer isWorkerEnabled:${t} seed:${this._checkTimer}`),t?e.startWorkerTimer():this._startMainThreadTimer()}_startMainThreadTimer(){this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3)),ge.l(`${this._n}._startMainThreadTimer seed:${this._checkTimer}`)}stopTimer(){const e=this._moduleMap.get(ys),t=e.isWorkerEnabled();ge.l(`${this._n}.stopTimer isWorkerEnabled:${t} seed:${this._checkTimer}`),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){ge.l(this._n+"._stopMainThreadTimer"),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){ge.l(this._n+"._stopMainThreadSocket");const e=this._moduleMap.get(Is);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){ge.l(this._n+"._startMainThreadSocket");const e=this._moduleMap.get(Is);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){ge.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){ge.l(this._n+".onWorkerTimerDisabled, enable main thread timer and socket"),this._startMainThreadTimer(),this._startMainThreadSocket()}onCheckTimer(){this._checkCount+=1;for(const[,e]of this._moduleMap)e.onCheckTimer&&e.onCheckTimer(this._checkCount)}_initReadyList(){this._readyList=[this._moduleMap.get(es),this._moduleMap.get(cs)],this._readyList.forEach(e=>{e.ready(()=>this._onModuleReady())})}_onModuleReady(){let t=!0;if(this._readyList.forEach(e=>{e.isReady()||(t=!1)}),t&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(e.SDK_READY);const t=Date.now()-this._startLoginTs;ge.w(`SDK is ready. cost ${t} ms`),this._startLoginTs=Date.now();const s=this._moduleMap.get(hs).getNetworkType(),o=this._ssoLogForReady.getStartTs()+ae;this._ssoLogForReady.setNetworkType(s).setMessage(t).start(o).end()}}login(){0===this._startLoginTs&&(ce(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(hs).start(),this._ssoLogForReady=new Qi("sdkReady"),this._reason=$i.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOuterEmitterInstance(){return null===this._outerEmitter&&(this._outerEmitter=new Pr,Cn(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(t,s){if(t===e.CONVERSATION_LIST_UPDATED||t===e.FRIEND_LIST_UPDATED||t===e.GROUP_LIST_UPDATED||t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED)if(this._eventThrottleMap.has(t)){const e=Date.now(),s=this._eventThrottleMap.get(t);e-s.last<=1e3?(s.timeoutID&&clearTimeout(s.timeoutID),s.timeoutID=setTimeout(()=>{s.last=Date.now(),this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}])},1e3)):(s.last=e,this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}]))}else this._eventThrottleMap.set(t,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:this._getEventData(t)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[t,{name:t,data:arguments[1]}])}.bind(this)),this._outerEmitter}_getEventData(t){return t===e.CONVERSATION_LIST_UPDATED?this._moduleMap.get(cs).getLocalConversationList():t===e.FRIEND_LIST_UPDATED?this._moduleMap.get(rs).getLocalFriendList(!1):t===e.GROUP_LIST_UPDATED?this._moduleMap.get(ns).getLocalGroupList():t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._moduleMap.get(cs).getTotalUnreadMessageCount():void 0}getInnerEmitterInstance(){return null===this._innerEmitter&&(this._innerEmitter=new Pr,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){let s;s=Re(arguments[1])&&arguments[1].data?[e,{name:arguments[0],data:arguments[1].data}]:[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,s)}.bind(this)),this._innerEmitter}hasModule(e){return this._moduleMap.has(e)}getModule(e){return this._moduleMap.get(e)}canIUseInflate(){return!!this._moduleMap.get(Os)}isReady(){return this._isReady}isIntl(){return this.getModule(ls).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrorMessage(e,t,s){return this._moduleMap.get(Ns).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}outputWarning(e,t,s){const o=this.getErrorMessage(e,t,s);o&&ge.w(o)}onError(t){const s=`code:${t.code} message:${t.message}`;ge.w("Oops! "+s);new Qi("error").setMessage(s).setNetworkType(this.getModule(hs).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(e.ERROR,t)}restartTimer(){ge.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer(),this.getModule(ns).restartPolling()}getTimerID(){const e=this._moduleMap.get(ys);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._moduleMap.get(ns).getPollingTimerID(e)}reset(){ge.l(this._n+".reset"),ce();for(const[,e]of this._moduleMap)e.reset&&e.reset();this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(e.SDK_NOT_READY);for(const[,e]of this._eventThrottleMap)e.timeoutID&&clearTimeout(e.timeoutID);this._eventThrottleMap.clear()}}class Mu{constructor(e){this._funcMap=new Map,this._m=e}defense(e,t,s){if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);let o=null;return this._funcMap.get(e).has(t)?o=this._funcMap.get(e).get(t):(o=this._pack(e,t,s),this._funcMap.get(e).set(t,o)),o}defenseOnce(e,t,s){return"function"!=typeof t?null:this._pack(e,t,s)}find(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)&&this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(this._m.outputWarning("ListenerFnNotFound",e),null)}delete(e,t){return"function"==typeof t&&(!!this._funcMap.has(e)&&(!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)))}_pack(t,s,o){const i=this;return function(){try{s.apply(o,Array.from(arguments))}catch(n){const s=Object.values(e).indexOf(t),o="CallbackError";if(-1!==s){const t=Object.keys(e)[s];i._m.outputWarning(o,t,n)}new Qi(o).setMessage("eventName:"+t).setMoreMessage(n.message).end()}}}}class fu{constructor(e){const t={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:ot(),devMode:e.devMode||!1,proxyServer:e.proxyServer||void 0,fileUploadProxy:e.fileUploadProxy||void 0,fileDownloadProxy:e.fileDownloadProxy||e.fileUploadProxy||void 0};this._m=new mu(t),this._safetyCallbackFactory=new Mu(this._m)}onError(e){this._m.onError(e)}login(e){this._m.login();return this._getModule(es).login(e)}logout(){return this._getModule(es).logout().then(e=>(this._m.reset(),e))}isReady(){return this._m.isReady()}isIntl(){return this._m.isIntl()}getNotReadyReason(){return this._m.getNotReadyReason()}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}_getModule(e){return this._m.getModule(e)}destroy(){return this.logout().finally(()=>{this._m.stopTimer();this._getModule(ys).terminate();this._getModule(Is).dealloc();const t=this._m.getOuterEmitterInstance(),s=this._getModule(ls);t.emit(e.SDK_DESTROY,{SDKAppID:s.getSDKAppID()})})}on(e,t,s){ge.d("on","eventName:"+e);this._m.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){ge.d("once","eventName:"+e);this._m.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,o){ge.d("off","eventName:"+e);const i=this._safetyCallbackFactory.find(e,t);if(null!==i){this._m.getOuterEmitterInstance().off(e,i,s,o),this._safetyCallbackFactory.delete(e,t)}}registerPlugin(e){if(Oe(e["tim-offline-push-plugin"])){this._getModule(ms).registerPlugin(e)}else{this._getModule(vs).registerPlugin(e)}}setLogLevel(e){if(e<=0){const e=this.getErrorMessage("TIM_ASCII_ART");e&&console.log(e);const t=this.getErrorMessage("API_REFER");if(t){const e="IM SDK API ->";mt()?console.log(`%c ${e} %c`,"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",t):console.log(e,t)}const s=this.getErrorMessage("DOCS_GUIDE");s&&console.log(s)}ge.setLevel(e)}createTextMessage(e){return this._getModule(ts).createTextMessage(e)}createTextAtMessage(e){return this._getModule(ts).createTextMessage(e)}createImageMessage(e){return this._getModule(ts).createImageMessage(e)}createAudioMessage(e){return this._getModule(ts).createAudioMessage(e)}createVideoMessage(e){return this._getModule(ts).createVideoMessage(e)}createCustomMessage(e){return this._getModule(ts).createCustomMessage(e)}createFaceMessage(e){return this._getModule(ts).createFaceMessage(e)}createFileMessage(e){return this._getModule(ts).createFileMessage(e)}createLocationMessage(e){return this._getModule(ts).createLocationMessage(e)}createMergerMessage(e){return this._getModule(ts).createMergerMessage(e)}downloadMergerMessage(e){if(e.type!==t.MSG_MERGER)return yn({code:$i.MESSAGE_MERGER_TYPE_INVALID});if(Ct(e.payload.downloadKey))return yn({code:$i.MESSAGE_MERGER_KEY_INVALID});return this._getModule(ts).downloadMergerMessage(e).catch(e=>yn({code:$i.MESSAGE_MERGER_DOWNLOAD_FAIL}))}createForwardMessage(e){return this._getModule(ts).createForwardMessage(e)}sendMessage(e,t){if(!(e instanceof mn))return yn({code:$i.MESSAGE_SEND_NEED_MESSAGE_INSTANCE});return this._getModule(ts).sendMessageInstance(e,t)}callExperimentalAPI(e,t){if("sendComboMessage"===e){return this._getModule(Rs).sendMessage(t)}if("handleGroupInvitation"===e){return this._getModule(ns).handleGroupInvitation(t)}if("isCommercialAbilityEnabled"===e){return this._getModule(Ss).isFeatureEnabled(t)}if("isIntl"===e)return this.isIntl();if("sendTRTCCustomData"===e){return this._getModule(As).sendTRTCCustomData(t)}return"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):yn({code:$i.INVALID_OPERATION})}revokeMessage(e){return this._getModule(ts).revokeMessage(e)}resendMessage(e){return this._getModule(ts).resendMessage(e)}deleteMessage(e){return this._getModule(ts).deleteMessage(e)}translateText(e){return this._getModule(ts).translateText(e)}setMessageExtensions(e,t){return this._getModule(ss).setMessageExtensions(e,t)}getMessageExtensions(e){return this._getModule(ss).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._getModule(ss).deleteMessageExtensions(e,t)}modifyMessage(e){return this._getModule(ts).modifyRemoteMessage(e)}getMessageList(e){return this._getModule(cs).getMessageList(e)}getMessageListHopping(e){return this._getModule(cs).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._getModule(cs).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._getModule(cs).getReadReceiptList(e)}getGroupMessageReadMemberList(e){return this._getModule(ns).getReadReceiptDetail(e)}findMessage(e){return this._getModule(cs).findMessage(e)}setMessageRead(e){return this._getModule(cs).setMessageRead(e)}getConversationList(e){return this._getModule(cs).getConversationList(e)}getConversationProfile(e){return this._getModule(cs).getConversationProfile(e)}deleteConversation(e){return this._getModule(cs).deleteConversation(e)}clearHistoryMessage(e){return this._getModule(cs).clearHistoryMessage(e)}pinConversation(e){return this._getModule(cs).pinConversation(e)}setAllMessageRead(e){return this._getModule(cs).setAllMessageRead(e)}setMessageRemindType(e){return this._getModule(cs).setMessageRemindType(e)}getTotalUnreadMessageCount(){return this._getModule(cs).getTotalUnreadMessageCount()}setConversationCustomData(e){return this._getModule(cs).setConversationCustomData(e)}markConversation(e){return this._getModule(cs).markConversation(e)}getConversationGroupList(){return this._getModule(cs).getConversationGroupList()}createConversationGroup(e){return this._getModule(cs).createConversationGroup(e)}deleteConversationGroup(e){return this._getModule(cs).deleteConversationGroup(e)}renameConversationGroup(e){return this._getModule(cs).renameConversationGroup(e)}addConversationsToGroup(e){return this._getModule(cs).addConversationsToGroup(e)}deleteConversationsFromGroup(e){return this._getModule(cs).deleteConversationsFromGroup(e)}getMyProfile(){return this._getModule(os).getMyProfile()}getUserProfile(e){return this._getModule(os).getUserProfile(e)}updateMyProfile(e){return this._getModule(os).updateMyProfile(e)}getBlacklist(){return this._getModule(os).getLocalBlacklist()}addToBlacklist(e){return this._getModule(os).addBlacklist(e)}removeFromBlacklist(e){return this._getModule(os).deleteBlacklist(e)}setSelfStatus(e){return this._getModule(os).setSelfStatus(e)}getUserStatus(e){return this._getModule(os).getUserStatus(e)}subscribeUserStatus(e){return this._getModule(os).subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._getModule(os).unsubscribeUserStatus(e)}getFriendList(){const e=this._getModule(rs);return e?e.getLocalFriendList():yn({code:$i.CANNOT_FIND_MODULE})}addFriend(e){const t=this._getModule(rs);return t?t.addFriend(e):yn({code:$i.CANNOT_FIND_MODULE})}deleteFriend(e){const t=this._getModule(rs);return t?t.deleteFriend(e):yn({code:$i.CANNOT_FIND_MODULE})}checkFriend(e){const t=this._getModule(rs);return t?t.checkFriend(e):yn({code:$i.CANNOT_FIND_MODULE})}getFriendProfile(e){const t=this._getModule(rs);return t?t.getFriendProfile(e):yn({code:$i.CANNOT_FIND_MODULE})}updateFriend(e){const t=this._getModule(rs);return t?t.updateFriend(e):yn({code:$i.CANNOT_FIND_MODULE})}getFriendApplicationList(){const e=this._getModule(rs);return e?e.getLocalFriendApplicationList():yn({code:$i.CANNOT_FIND_MODULE})}acceptFriendApplication(e){const t=this._getModule(rs);return t?t.acceptFriendApplication(e):yn({code:$i.CANNOT_FIND_MODULE})}refuseFriendApplication(e){const t=this._getModule(rs);return t?t.refuseFriendApplication(e):yn({code:$i.CANNOT_FIND_MODULE})}deleteFriendApplication(e){const t=this._getModule(rs);return t?t.deleteFriendApplication(e):yn({code:$i.CANNOT_FIND_MODULE})}setFriendApplicationRead(){const e=this._getModule(rs);return e?e.setFriendApplicationRead():yn({code:$i.CANNOT_FIND_MODULE})}getFriendGroupList(){const e=this._getModule(rs);return e?e.getLocalFriendGroupList():yn({code:$i.CANNOT_FIND_MODULE})}createFriendGroup(e){const t=this._getModule(rs);return t?t.createFriendGroup(e):yn({code:$i.CANNOT_FIND_MODULE})}deleteFriendGroup(e){const t=this._getModule(rs);return t?t.deleteFriendGroup(e):yn({code:$i.CANNOT_FIND_MODULE})}addToFriendGroup(e){const t=this._getModule(rs);return t?t.addToFriendGroup(e):yn({code:$i.CANNOT_FIND_MODULE})}removeFromFriendGroup(e){const t=this._getModule(rs);return t?t.removeFromFriendGroup(e):yn({code:$i.CANNOT_FIND_MODULE})}renameFriendGroup(e){const t=this._getModule(rs);return t?t.renameFriendGroup(e):yn({code:$i.CANNOT_FIND_MODULE})}getGroupList(e){return this._getModule(ns).getGroupList(e)}getGroupProfile(e){return this._getModule(ns).getGroupProfile(e)}createGroup(e){return this._getModule(ns).createGroup(e)}dismissGroup(e){return this._getModule(ns).dismissGroup(e)}updateGroupProfile(e){return this._getModule(ns).updateGroupProfile(e)}joinGroup(e){return this._getModule(ns).joinGroup(e)}quitGroup(e){return this._getModule(ns).quitGroup(e)}searchGroupByID(e){return this._getModule(ns).searchGroupByID(e)}getGroupOnlineMemberCount(e){return this._getModule(ns).getGroupOnlineMemberCount(e)}changeGroupOwner(e){return this._getModule(ns).changeGroupOwner(e)}getGroupApplicationList(){return this._getModule(ns).getGroupApplicationList()}handleGroupApplication(e){return this._getModule(ns).handleGroupApplication(e)}initGroupAttributes(e){return this._getModule(ns).initGroupAttributes(e)}setGroupAttributes(e){return this._getModule(ns).setGroupAttributes(e)}deleteGroupAttributes(e){return this._getModule(ns).deleteGroupAttributes(e)}getGroupAttributes(e){return this._getModule(ns).getGroupAttributes(e)}setGroupCounters(e){return this._getModule(ns).setGroupCounters(e)}increaseGroupCounter(e){return this._getModule(ns).increaseGroupCounter(e)}decreaseGroupCounter(e){return this._getModule(ns).decreaseGroupCounter(e)}getGroupCounters(e){return this._getModule(ns).getGroupCounters(e)}getGroupMemberList(e){return this._getModule(as).getGroupMemberList(e)}getGroupMemberProfile(e){return this._getModule(as).getGroupMemberProfile(e)}addGroupMember(e){return this._getModule(as).addGroupMember(e)}deleteGroupMember(e){return this._getModule(as).deleteGroupMember(e)}setGroupMemberMuteTime(e){return this._getModule(as).setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this._getModule(as).setGroupMemberRole(e)}setGroupMemberNameCard(e){return this._getModule(as).setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this._getModule(as).setGroupMemberCustomField(e)}markGroupMemberList(e){return this._getModule(as).markGroupMemberList(e)}getJoinedCommunityList(){return this._getModule(us).getJoinedCommunityList()}createTopicInCommunity(e){return this._getModule(us).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._getModule(us).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._getModule(us).updateTopicProfile(e)}getTopicList(e){return this._getModule(us).getTopicList(e)}}const Iu={login:1,logout:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1};function Cu(e,t){if(e.isReady()||1===Iu[t])return!0;const s=e.getNotReadyReason(),o={code:s,message:`${e.getErrorMessage(s)} | ${t} | ${e.getErrorMessage($i.SDK_IS_NOT_READY)}`};return e.onError(o),o}const Tu={},yu={};yu.create=function(t){let o=0;const{SDKAppID:i}=t;if(ve(i))o=i;else if(o=parseInt(i),isNaN(i))return ge.e("TIM.create failed. Failed to parse the SDKAppID, please check the arguments"),null;if(o&&Tu[o])return Tu[o];ge.l("TIM.create");const n=new fu({...t,SDKAppID:o});n.on(e.SDK_DESTROY,e=>{Tu[e.data.SDKAppID]=null,delete Tu[e.data.SDKAppID]});const r=function(e){const t=Object.create(null);return Object.keys(Qt).forEach(o=>{if(!e[o])return;const i=new s;t[o]=function(){const t=Array.from(arguments);return i.use((function(t,s){const i=Cu(e,o);return!0===i?s():yn(i)})).use((function(e,t){if(!0===Tt(e,Zt[o],o))return t()})).use((function(t,s){return e[o].apply(e,t)})),i.run(t)}}),t}(n);return Tu[o]=r,Zt.hookGetAPITips(n.getErrorMessage.bind(n)),ge.l("TIM.create ok"),r},yu.TYPES=t,yu.EVENT=e,yu.VERSION="2.27.6",ge.l("TIM.VERSION:"+yu.VERSION);export{yu as default};