zoujiandong 2bd2fd31ac 1.22
2024-01-22 08:55:30 +08:00

1 line
413 KiB
JavaScript

"use strict";const e={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",ROOM_CUSTOM_DATA_RECEIVED:"onRoomCustomDataReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",MESSAGE_REACTIONS_UPDATED:"onMessageReactionsUpdated",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_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",MY_FOLLOWERS_LIST_UPDATED:"onMyFollowersListUpdated",MY_FOLLOWING_LIST_UPDATED:"onMyFollowingListUpdated",MUTUAL_FOLLOWERS_LIST_UPDATED:"onMutualFollowersListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange"},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&&0<this.middlewares.length)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 i{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}const n={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{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",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},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",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},o={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,c="CHINA",u="OVERSEA",l="SINGAPORE",d="KOREA",_="GERMANY",p="IND",h="JPN",g="USA",m="INDONESIA",M={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=c){this.CURRENT=n.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow"}},I={SEARCH_MSG:new i(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new i(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new i(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new i(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new i(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new i(0,Math.pow(2,6)).toString(),USER_STATUS:new i(0,Math.pow(2,7)).toString(),CONV_MARK:new i(0,Math.pow(2,9)).toString(),CONV_GROUP:new i(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new i(0,Math.pow(2,11)).toString(),MSG_EXT:new i(0,Math.pow(2,13)).toString(),GRP_COUNTER:new i(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new i(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new i(Math.pow(2,7)).toString(),PLUGIN_CS:new i(Math.pow(2,8)).toString(),PLUGIN_PUSH:new i(Math.pow(2,9)).toString(),PLUGIN_BOT:new i(Math.pow(2,10)).toString(),MSG_REACTION:new i(Math.pow(2,16)).toString()},f="c2c_text_message",C="c2c_custom_message",T="group_text_message",y="group_custom_message",D="user_profile",S="group_profile",E=(M.HOST.setCurrent(c),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),v=E&&"function"==typeof wx.createGamePortal,A="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),R="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),L="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,P="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,U="undefined"!=typeof uni,G=E||A||R||L||N||P||O,k=("undefined"!=typeof uni||"undefined"!=typeof window)&&!G,F=A?qq:R?tt:L?swan:N?my:E?wx:P?uni:O?jd:{},$=k&&window&&window.navigator&&window.navigator.userAgent||"",w=/(micromessenger|webbrowser)/i.test($),b=/AppleWebKit\/([\d.]+)/i.exec($),q=(b&&parseFloat(b.pop()),function(){let e="WEB";return w?e="WEB":A?e="QQ_MP":R?e="TT_MP":L?e="BAIDU_MP":N?e="ALI_MP":E?e="WX_MP":P&&(e="UNI_NATIVE_APP"),o[e]}()),x=/iPad/i.test($),V=/iPhone/i.test($)&&!x,B=/iPod/i.test($),K=V||x||B,H=function(){var e=$.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),W=/Android/i.test($),Y=function(){var e=$.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(e[1]+"."+e[2]):t||null}(),z=/Edge/i.test($),j=!z&&/Chrome/i.test($),X=(!function(){var e=$.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test($)||-1<$.indexOf("Trident")&&-1<$.indexOf("rv:11.0")),J=function(){var e=/MSIE\s(\d+)\.\d/.exec($);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test($)&&/rv:11.0/.test($)?11:t}(),Q=/Safari/i.test($)&&!j&&!W&&!z,Z=(!function(){var e=$.match(/TBS\/(\d+)/i);e&&e[1]&&e[1]}(),/Windows/i.test($)),ee=/MAC OS X/i.test($),te=k&&"undefined"!=typeof Worker&&!X,se=W||K,ie=k&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ne=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;var e=window.navigator.standalone;return!(!K||e||Q)}();let oe,re;oe="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const ae=function(){},ce=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let ue=ce.length;for(;ue--;)re=ce[ue],console[re]||(oe[re]=ae);var le=oe;let de=0;const _e=function(){return(new Date).getTime()+de},pe=function(){de=0},he=function(){return Math.floor(_e()/1e3)};let ge=0;function me(){return Tt()?"%c Chat %c":"Chat"}function Me(){const e=function(){const e=new Date;return e.setTime(_e()),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 Ie={arguments2String(s){let i="";if(1===s.length)i=s[0];else for(let e=0,t=s.length;e<t;e++)we(s[e])?qe(s[e])?i+=He(s[e]):i+=JSON.stringify(s[e]):i+=s[e],i+=" ";return i},_exec(e,t){Tt()?le[e](me(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Me(),t):le[e](`${me()} ${Me()} `+t)},d:function(){var e;ge<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;ge<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;ge<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;ge<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;ge<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;ge<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+ge+" to "+e),ge=e},getLevel:function(){return ge}},fe={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},Ce={NICK:"Tag_Profile_IM_Nick",GENDER:"Tag_Profile_IM_Gender",BIRTHDAY:"Tag_Profile_IM_BirthDay",LOCATION:"Tag_Profile_IM_Location",SELFSIGNATURE:"Tag_Profile_IM_SelfSignature",ALLOWTYPE:"Tag_Profile_IM_AllowType",LANGUAGE:"Tag_Profile_IM_Language",AVATAR:"Tag_Profile_IM_Image",MESSAGESETTINGS:"Tag_Profile_IM_MsgSettings",ADMINFORBIDTYPE:"Tag_Profile_IM_AdminForbidType",LEVEL:"Tag_Profile_IM_Level",ROLE:"Tag_Profile_IM_Role"},Te="Gender_Type_",ye={UNKNOWN:Te+"Unknown",FEMALE:Te+"Female",MALE:Te+"Male"},De={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},Se={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},Ee="@TGS#_",ve="@TOPIC#_",Ae=Object.prototype.hasOwnProperty;function Re(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(ke(e)){for(const t in e)if(Ae.call(e,t))return!1;return!0}return!!(Le(e)||Ne(e)||Oe(e))&&0===e.size}const Le=function(e){return"map"===Ve(e)},Ne=function(e){return"set"===Ve(e)},Oe=function(e){return"file"===Ve(e)},Pe=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},Ue=function(e){return"string"==typeof e},Ge=function(e){return null!==e&&"object"==typeof e},ke=function(e){if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t},Fe=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===Ve(e)},$e=function(e){return void 0===e},we=function(e){return Fe(e)||Ge(e)},be=function(e){return"function"==typeof e},qe=function(e){return e instanceof Error},xe=function(e){return"filelist"===Ve(e)},Ve=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},Be=function(e){if("string"!=typeof e)return!1;e=e[0];return!/[^a-zA-Z0-9]/.test(e)},Ke=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(s,i,o,n){if(!we(s)||!we(i))return 0;let r=0;var a,c=Object.keys(i);for(let e=0,t=c.length;e<t;e++)if(a=c[e],!($e(i[a])||o&&o.includes(a)))if(we(s[a])&&we(i[a]))r+=Ke(s[a],i[a],o,n);else{if(n&&n.includes(i[a]))continue;s[a]!==i[a]&&(s[a]=i[a],r+=1)}return r}),He=function(e){return JSON.stringify(e,["message","code"])},We=function(e){if(0===e.length)return 0;let t=0,s=0,i;for(var o="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)i=e[t++].charCodeAt[t]<=255?1:!1===o?3:2,s+=i;return s},Ye=function(e){e=e||99999999;return Math.round(Math.random()*e)},ze="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",je=ze.length,Xe=function(e,t){for(const s in e)if(e[s]===t)return!0;return!1},Je={},Qe=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function Ze(i,e){if(!Fe(i)||!Fe(e))return!1;let o=!1;return e.forEach(({key:t,value:e})=>{const s=i.find(e=>e.key===t);s?s.value!==e&&(s.value=e,o=!0):(i.push({key:t,value:e}),o=!0)}),o}const et=e=>e===t.GRP_AVCHATROOM,st=({type:e,groupID:s})=>e===t.GRP_COMMUNITY||(""+s).startsWith(Ee)&&!(""+s).includes(ve),it=e=>(""+e).startsWith(Ee)&&(""+e).includes(ve),nt=e=>Ue(e)&&e.slice(0,3)===t.CONV_C2C,ot=e=>Ue(e)&&e.slice(0,5)===t.CONV_GROUP,rt=e=>Ue(e)&&e===t.CONV_SYSTEM;function at(t,s){const i={};return Object.keys(t).forEach(e=>{i[e]=s(t[e],e)}),i}function ct(i){return G?new Promise((t,e)=>{F.getImageInfo({src:i,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})}):X&&9===J?Promise.resolve({width:0,height:0}):new Promise((e,t)=>{let s=new Image;s.onload=function(){e({width:this.width,height:this.height}),s=null},s.onerror=function(){e({width:0,height:0}),s=null},s.src=i})}function ut(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+(e()+e())+e()+e()+e()+e()+e()+e()}function lt(){let e="unknown";if(ee&&(e="mac"),Z&&(e="windows"),K&&(e="ios"),W&&(e="android"),G)try{var t=F.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(e){}return e}function dt(t,s){t=t.split("."),s=s.split(".");const i=Math.max(t.length,s.length);for(;t.length<i;)t.push("0");for(;s.length<i;)s.push("0");for(let e=0;e<i;e++){const i=parseInt(t[e]),o=parseInt(s[e]);if(i>o)return 1;if(i<o)return-1}return 0}function _t(e){const{originUrl:t,originWidth:s,originHeight:i,min:o=198}=e,n=parseInt(s),r=parseInt(i),a={url:void 0,width:0,height:0};if((n<=r?n:r)<=o)a.url=t,a.width=n,a.height=r;else{r<=n?(a.width=Math.ceil(n*o/r),a.height=o):(a.width=o,a.height=Math.ceil(r*o/n));const e=t&&-1<t.indexOf("?")?t+"&":t+"?";a.url=198===o?e+"imageView2/3/w/198/h/198":e+"imageView2/3/w/720/h/720"}if($e(t)){const{url:e,...t}=a;return t}return a}function pt(t){var e=t[2];t[2]=t[1],t[1]=e;for(let e=0;e<t.length;e++)t[e].setType(e)}function ht(e){const t=e["servcmd"];return t.slice(t.indexOf(".")+1)}function gt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function mt(e,t){return e.includes(t)}function Mt(e,t){return e.includes(t)}function It(e){return e.split(ve)[0]}const ft=function(e,s,i){if($e(s))return"";switch(e){case t.MSG_TEXT:return s.text;case t.MSG_IMAGE:return i?"[Image]":"[图片]";case t.MSG_LOCATION:return i?"[Location]":"[位置]";case t.MSG_AUDIO:return i?"[Voice]":"[语音]";case t.MSG_VIDEO:return i?"[Video]":"[视频]";case t.MSG_FILE:return i?"[File]":"[文件]";case t.MSG_CUSTOM:return i?"[Custom Messages]":"[自定义消息]";case t.MSG_GRP_TIP:return i?"[Group Notification]":"[群提示消息]";case t.MSG_GRP_SYS_NOTICE:return i?"[Group System Message]":"[群系统通知]";case t.MSG_FACE:return i?"[Animated Sticker]":"[动画表情]";case t.MSG_MERGER:return i?"[Chat Record]":"[聊天记录]";default:return""}};function Ct(t){const s=[];if(!Ue(t))return s;var i=t.length;if(0===i)return s;for(let e=i-1;0<=e;e--)"1"===t[e]&&s.push(Math.pow(2,i-e-1));return s}function Tt(){return!X&&!G}function yt(e){return"the length of userIDList cannot exceed "+e}function Dt(t,s){if(t){let e=t;return s&&(t.startsWith("http://")?e=t.replace(/^http:\/\/[^/]+/,s):t.startsWith("https://")&&(e=t.replace(/^https:\/\/[^/]+/,s))),e}}function St(e,t=!0,s=!0){var i=Date.now();return t?s?i-e+" ms":Math.round((i-e)/1e3)+" s":s?i-e:Math.round((i-e)/1e3)}function Et(e){let t=e&&1<e?!0:!1;return t}function vt(s,i,o){if(void 0===i)return!0;let n=!0;if(ke(i))Object.keys(i).forEach(e=>{var t=1===s.length?s[0][e]:void 0;n=!!At(t,i[e],o,e)&&n});else if(Fe(i))for(let e=0;e<i.length;e++)n=!!At(s[e],i[e],o,i[e].name)&&n;if(n)return n;throw new Error("Params validate failed.")}function At(e,t,s,i){if(void 0===t)return!0;let o=!0;var n,r;return t.required&&Re(e)&&(Ie.e(`[${s}] Missing required params: "${i}".`),o=!1),Re(e)||(n=Ve(e))!==(r=t.type.toLowerCase())&&("asyncfunction"===n&&"function"===r||(Ie.e(`[${s}] Invalid params: type check failed for "${i}". Expected ${t.type}.`),o=!1)),t.validator&&!t.validator(e,s,i)&&(Ie.e(`[${s}] Invalid params: custom validator check failed for "${i}".`),o=!1),o}const Rt="unSend",Lt="success",Nt="fail",Ot="notStart",Pt="pending",Ut="resolved",Gt="rejected",kt=function(e){if(!e)return!1;if(nt(e)||ot(e)||rt(e))return!0;e=ls("InvalidConversationID",e);return e&&Ie.w(e),!1},Ft=function(e){""!==e.desc&&""!==ls("API_REFER")&&Ie.w(`[${e.api}] | ${e.paramName} | ${e.desc}, `+ls("API_REFER")+e.api)},$t=function(){return ls("StringRequiredLog")},wt=function(e){return ls("NonEmptyStringRequiredLog",e)},bt=function(){return ls("NumberRequiredLog")},qt=function(){return ls("UndefinedNotAllowedLog")},xt=function(){return ls("FileRequiredLog")},Vt=function(){return ls("FunctionRequiredLog")},Bt=function(){return ls("ArrayRequiredLog")},Kt=function(){return ls("NonEmptyArrayLog")},Ht=function(){return ls("CallbackMissingLog")},Wt=function(){return ls("PositiveIntegerRequiredLog")},Yt=function(e,t){return ls("StringNotLongerThanLog",e,t)},zt=function(e,t){return ls("NumberLessThanLog",e,t)},jt=function(e,t){return ls("NumberGreaterOrEqualLog",e,t)},Xt=function(e){return ls("KeyValueStringRequiredLog",e)},Jt=function(){return ls("PlainObjectRequiredLog")},Qt=function(){return ls("NonEmptyContentRequiredLog")},Zt=function(){return ls("FileNotSelectedLog")},es=function(){return ls("MessageInstanceRequiredLog")},ts=function(){return ls("NonAnonymousFunctionLog")},ss=function(){return ls("MessageExtensionNotAvailableLog")},is=function(){return ls("MessageReactionRequiredLog")},ns=function(e,t){return ls("MaximumArrayLengthLog",e,t)},os={type:"String",required:!0},rs={type:"Array",required:!0},as={type:"Object",required:!0},cs={type:"Boolean",required:!0},us={type:"number",required:!0};let ls=null;const ds={hookGetAPITips:function(e){ls=e},login:{userID:os,userSig:os},addToBlacklist:{userIDList:rs},removeFromBlacklist:{userIDList:rs},on:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ft({api:t,paramName:s,desc:wt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ft({api:t,paramName:s,desc:Vt()}),!1):(""===e.name&&Ft({api:t,paramName:s,desc:ts()}),!0)}],once:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ft({api:t,paramName:s,desc:wt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ft({api:t,paramName:s,desc:Vt()}),!1):(""===e.name&&Ft({api:t,paramName:s,desc:ts()}),!0)}],off:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ft({api:t,paramName:s,desc:wt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ft({api:t,paramName:s,desc:Vt()}),!1):(""===e.name&&Ft({api:t,paramName:s,desc:ts()}),!0)}],sendMessage:[{name:"message",...as}],setMessageExtensions:[{name:"message",...as,validator:(e,t,s)=>e.status===Lt&&!0===e.isSupportExtension||(Ft({api:t,paramName:s,desc:ss()}),!1)},{name:"extensions",...rs}],getMessageExtensions:[{name:"message",...as,validator:(e,t,s)=>e.status===Lt&&!0===e.isSupportExtension||(Ft({api:t,paramName:s,desc:ss()}),!1)}],deleteMessageExtensions:[{name:"message",...as,validator:(e,t,s)=>e.status===Lt&&!0===e.isSupportExtension||(Ft({api:t,paramName:s,desc:ss()}),!1)}],addMessageReaction:[{name:"message",...as,validator:(e,t,s)=>e.status===Lt||(Ft({api:t,paramName:s,desc:is()}),!1)},{name:"reactionID",...os}],removeMessageReaction:[{name:"message",...as,validator:(e,t,s)=>e.status===Lt||(Ft({api:t,paramName:s,desc:is()}),!1)},{name:"reactionID",...os}],getMessageReactions:{messageList:{...rs}},getAllUserListOfMessageReaction:{message:{...as,validator:(e,t,s)=>e.status===Lt||(Ft({api:t,paramName:s,desc:is()}),!1)},reactionID:{...os},nextSeq:{type:"Number"},count:{type:"Number"}},getMessageList:{conversationID:{...os,validator:e=>kt(e)},nextReqMessageID:{type:"String"},count:{type:"Number",validator:(e,t,s)=>!(!$e(e)&&!/^[1-9][0-9]*$/.test(e)&&(Ft({api:t,paramName:s,desc:Wt()}),1))}},getMessageListHopping:{conversationID:{...os,validator:e=>kt(e)},sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:(e,t,s)=>!(!$e(e)&&0!==e&&1!==e&&(Ft({api:t,paramName:s,desc:ls("0Or1RequiredLog")}),1))},count:{type:"Number",validator:(e,t,s)=>!(!$e(e)&&!/^[1-9][0-9]*$/.test(e)&&(Ft({api:t,paramName:s,desc:Wt}),1))}},setMessageRead:{conversationID:{...os,validator:e=>kt(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:(e,s,i)=>!e||-1!==[t.READ_ALL_C2C_MSG,t.READ_ALL_GROUP_MSG,t.READ_ALL_MSG].indexOf(e)||(Ft({api:s,paramName:i,desc:ls("ValidScopeRequired")}),!1)}},getConversationProfile:[{name:"conversationID",...os,validator:e=>kt(e)}],clearHistoryMessage:[{name:"conversationID",...os,validator:e=>kt(e)}],pinConversation:{conversationID:{...os,validator:e=>kt(e)},isPinned:{...cs}},setConversationDraft:{conversationID:{...os,validator:e=>kt(e)},draftText:{type:"String",validator:(e,t,s)=>!!Ue(e)||(Ft({api:t,paramName:s,desc:$t()}),!1)}},setConversationCustomData:{conversationIDList:{...rs},customData:{type:"String",validator:(e,t,s)=>Ue(e)?!(256<e.length&&(Ft({api:t,paramName:s,desc:Yt(s,256)}),1)):(Ft({api:t,paramName:s,desc:$t()}),!1)}},markConversation:{conversationIDList:{...rs},markType:{type:"number",validator:(e,t,s)=>{return Pe(e)?e<=0?(Ft({api:t,paramName:s,desc:(i=s,ls("NumberGreaterThanLog",i,0))}),!1):!(e>=Math.pow(2,64)&&(Ft({api:t,paramName:s,desc:zt(s,"Math.pow(2,64)")}),1)):(Ft({api:t,paramName:s,desc:bt()}),!1);var i}},enableMark:{...cs}},createConversationGroup:{conversationIDList:{...rs},groupName:{...os,validator:(e,t,s)=>!(!e||32<e.length&&(Ft({api:t,paramName:s,desc:Yt(s,32)}),1))}},deleteConversationGroup:[{name:"groupName",...os}],renameConversationGroup:{oldName:{...os},newName:{...os,validator:(e,t,s)=>!(!e||32<e.length&&(Ft({api:t,paramName:s,desc:Yt(s,32)}),1))}},addConversationsToGroup:{conversationIDList:{...rs},groupName:{...os}},deleteConversationsFromGroup:{conversationIDList:{...rs},groupName:{...os}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:os,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:rs},createGroup:{name:os},joinGroup:{groupID:os,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...os}],handleApplication:{message:as,handleAction:os,handleMessage:{type:"String"}},changeGroupOwner:{groupID:os,newOwnerID:os},updateGroupProfile:{groupID:os,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...os}],searchGroupByID:[{name:"groupID",...os}],getGroupOnlineMemberCount:[{name:"groupID",...os}],initGroupAttributes:{groupID:os,groupAttributes:{...as,validator:(t,s,i)=>{let o=!0;return Object.keys(t).forEach(e=>{if(!Ue(t[e]))return Ft({api:s,paramName:i,desc:Xt("value")}),o=!1}),o}}},setGroupAttributes:{groupID:os,groupAttributes:{...as,validator:(t,s,i)=>{let o=!0;return Object.keys(t).forEach(e=>{if(!Ue(t[e]))return Ft({api:s,paramName:i,desc:Xt("value")}),o=!1}),o}}},deleteGroupAttributes:{groupID:os,keyList:{type:"Array",validator:(e,s,i)=>{if($e(e)||!Fe(e))return Ft({api:s,paramName:i,desc:Bt()}),!1;if(Re(e))return!0;{let t=!0;return e.forEach(e=>{if(!Ue(e))return Ft({api:s,paramName:i,desc:ls("StringArrayRequiredLog")}),t=!1}),t}}}},getGroupAttributes:{groupID:os,keyList:{type:"Array",validator:(e,s,i)=>{if($e(e)||!Fe(e))return Ft({api:s,paramName:i,desc:Bt()}),!1;if(Re(e))return!0;{let t=!0;return e.forEach(e=>{if(!Ue(e))return Ft({api:s,paramName:i,desc:Xt("key")}),t=!1}),t}}}},setGroupCounters:{groupID:os,counters:as},increaseGroupCounter:{groupID:os,key:os,value:us},decreaseGroupCounter:{groupID:os,key:os,value:us},getGroupCounters:{groupID:os},getGroupMemberList:{groupID:os,count:{type:"Number"}},getGroupMemberProfile:{groupID:os,userIDList:rs,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:os,userIDList:rs},setGroupMemberRole:{groupID:os,userID:os,role:os},setGroupMemberMuteTime:{groupID:os,userID:os,muteTime:{type:"Number",validator:e=>0<=e}},setGroupMemberNameCard:{groupID:os,userID:{type:"String"},nameCard:{type:"String",validator:(e,t,s)=>Ue(e)?(e.length,!0):(Ft({api:t,paramName:s,desc:$t()}),!1)}},setGroupMemberCustomField:{groupID:os,userID:{type:"String"},memberCustomField:rs},deleteGroupMember:{groupID:os},markGroupMemberList:{groupID:os,markType:{type:"number",validator:(e,t,s)=>Pe(e)?!(e<1e3&&(Ft({api:t,paramName:s,desc:jt(s,1e3)}),1)):(Ft({api:t,paramName:s,desc:bt()}),!1)},userIDList:{...rs},enableMark:{...cs}},createTextMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>ke(e)?Ue(e.text)?0!==e.text.length||(Ft({api:t,paramName:"payload.text",desc:Qt()}),!1):(Ft({api:t,paramName:"payload.text",desc:$t()}),!1):(Ft({api:t,paramName:s,desc:Jt()}),!1)}},createTextAtMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>ke(e)?Ue(e.text)?0===e.text.length?(Ft({api:t,paramName:"payload.text",desc:Qt()}),!1):!(e.atUserList&&!Fe(e.atUserList)&&(Ft({api:t,paramName:"payload.atUserList",desc:Bt()}),1)):(Ft({api:t,paramName:"payload.text",desc:$t()}),!1):(Ft({api:t,paramName:s,desc:Jt()}),!1)}},createCustomMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>ke(e)?e.data&&!Ue(e.data)?(Ft({api:t,paramName:"payload.data",desc:$t()}),!1):e.description&&!Ue(e.description)?(Ft({api:t,paramName:"payload.description",desc:$t()}),!1):!(e.extension&&!Ue(e.extension)&&(Ft({api:t,paramName:"payload.extension",desc:$t()}),1)):(Ft({api:t,paramName:"payload",desc:Jt()}),!1)}},createImageMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>{if(!ke(e))return Ft({api:t,paramName:s,desc:Jt()}),!1;if($e(e.file))return Ft({api:t,paramName:"payload.file",desc:qt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return ke(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Ft({api:t,paramName:"payload.file",desc:Zt()}),!1):(Ft({api:t,paramName:"payload.file",desc:xt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ft({api:t,paramName:"payload.file",desc:Zt()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Ht()}),!0)}}},createAudioMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>!!ke(e)||(Ft({api:t,paramName:s,desc:Jt()}),!1)},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Ht()}),!0)}},createVideoMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>{if(!ke(e))return Ft({api:t,paramName:s,desc:Jt()}),!1;if($e(e.file))return Ft({api:t,paramName:"payload.file",desc:qt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return ke(e.file)&&"undefined"!=typeof uni?!!Oe(e.file.tempFile)||(Ft({api:t,paramName:"payload.file",desc:Zt()}),!1):(Ft({api:t,paramName:"payload.file",desc:xt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ft({api:t,paramName:"payload.file",desc:Zt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Ht()}),!0)}},createFaceMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>ke(e)?Pe(e.index)?!!Ue(e.data)||(Ft({api:t,paramName:"payload.data",desc:$t()}),!1):(Ft({api:t,paramName:"payload.index",desc:bt()}),!1):(Ft({api:t,paramName:s,desc:Jt()}),!1)}},createFileMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>{if(!ke(e))return Ft({api:t,paramName:s,desc:Jt()}),!1;if($e(e.file))return Ft({api:t,paramName:"payload.file",desc:qt()}),!1;if(k){if(!(e.file instanceof HTMLInputElement||Oe(e.file)))return ke(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Ft({api:t,paramName:"payload.file",desc:Zt()}),!1):(Ft({api:t,paramName:"payload.file",desc:xt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Ft({api:t,paramName:"payload.file",desc:Zt()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Ht()}),!0)}},createLocationMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>ke(e)?Ue(e.description)?Pe(e.longitude)?!!Pe(e.latitude)||(Ft({api:t,paramName:"payload.latitude",desc:bt()}),!1):(Ft({api:t,paramName:"payload.longitude",desc:bt()}),!1):(Ft({api:t,paramName:"payload.description",desc:$t()}),!1):(Ft({api:t,paramName:s,desc:Jt()}),!1)}},createMergerMessage:{to:os,conversationType:os,payload:{...as,validator:(e,t,s)=>{if(Re(e.messageList))return Ft({api:t,paramName:"payload.messageList",desc:Kt()}),!1;if(Re(e.compatibleText))return Ft({api:t,paramName:"payload.compatibleText",desc:wt("compatibleText")}),!1;let i=!1;return e.messageList.forEach(e=>{e.status===Nt&&(i=!0)}),!i||(Ft({api:t,paramName:"payload.messageList",desc:ls("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...as,validator:(e,s,i)=>Re(e)?(Ft({api:s,paramName:i,desc:es()}),!1):e.conversationType===t.CONV_SYSTEM?(Ft({api:s,paramName:i,desc:ls("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Ft({api:s,paramName:i,desc:ls("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",...rs,validator:(e,t,s)=>!Re(e)||(Ft({api:t,paramName:s,desc:Kt()}),!1)}],translateText:{sourceTextList:rs,sourceLanguage:os,targetLanguage:os},convertVoiceToText:{message:{...as,validator:(e,s,i)=>Re(e)?(Ft({api:s,paramName:i,desc:es()}),!1):e.type===t.MSG_AUDIO&&e.status===Lt||(Ft({api:s,paramName:i,desc:ls("AudioMessageRequiredLog")}),!1)}},modifyMessage:[{name:"message",...as,validator:(e,s,i)=>Re(e)?(Ft({api:s,paramName:i,desc:es()}),!1):e.conversationType===t.CONV_SYSTEM?(Ft({api:s,paramName:i,desc:ls("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Ft({api:s,paramName:i,desc:ls("OnlineMessageNotSupportLog")}),!1)}],searchCloudMessages:{keywordList:{type:"Array",required:!1,validator:(e,t,s)=>!(e&&(Fe(e)?0===e.length?(Ft({api:t,paramName:s,desc:Kt()}),1):5<e.length&&(Ft({api:t,paramName:s,desc:ns(s,5)}),1):(Ft({api:t,paramName:s,desc:Bt()}),1)))},keywordListMatchType:{type:"String",required:!1,validator:(e,t,s)=>!e||"or"===e||"and"===e||Ft({api:t,paramName:s,desc:e+" is invalid match type"})},senderUserIDList:{type:"Array",required:!1,validator:(e,t,s)=>!(e&&(Fe(e)?(0===e.length&&Ft({api:t,paramName:s,desc:Kt()}),5<e.length&&(Ft({api:t,paramName:s,desc:ns(s,5)}),1)):(Ft({api:t,paramName:s,desc:Bt()}),1)))},messageTypeList:{type:"Array",required:!1,validator:(e,s,i)=>{if(!e)return!0;if(!Fe(e))return Ft({api:s,paramName:i,desc:Bt()}),!1;0===e.length&&Ft({api:s,paramName:i,desc:Kt()});const o=[t.MSG_TEXT,t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_FILE,t.MSG_VIDEO,t.MSG_LOCATION,t.MSG_CUSTOM,t.MSG_MERGER];return!(0<e.filter(e=>-1===o.indexOf(e)).length&&(Ft({api:s,paramName:i,desc:(e=i,ls("ContainsUnsupportedMessageTypeLog",e))}),1))}},conversationID:{type:"String",required:!1,validator:e=>!e||kt(e)},timePosition:{type:"number",required:!1,validator:(e,t,s)=>!(e&&e<0&&(Ft({api:t,paramName:s,desc:jt(s,0)}),1))},timePeriod:{type:"number",required:!1,validator:(e,t,s)=>!(e&&e<0&&(Ft({api:t,paramName:s,desc:jt(s,0)}),1))},cursor:{type:"String",required:!1}},getUserProfile:{userIDList:{type:"Array",validator:(e,t,s)=>Fe(e)?(0===e.length&&Ft({api:t,paramName:s,desc:Kt()}),!0):(Ft({api:t,paramName:s,desc:Bt()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:(e,t,s)=>!!$e(e)||!!Fe(e)||(Ft({api:t,paramName:s,desc:Bt()}),!1)}},setSelfStatus:{customStatus:{type:"String",validator:(e,t,s)=>!!Ue(e)||(Ft({api:t,paramName:s,desc:$t()}),!1)}},getUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Fe(e)?0!==e.length||(Ft({api:t,paramName:s,desc:Kt()}),!1):(Ft({api:t,paramName:s,desc:Bt()}),!1)}},subscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Fe(e)?0!==e.length||(Ft({api:t,paramName:s,desc:Kt()}),!1):(Ft({api:t,paramName:s,desc:Bt()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>!e||!!Fe(e)||(Ft({api:t,paramName:s,desc:Bt()}),!1)}},addFriend:{to:os,source:{type:"String",required:!0,validator:(e,t,s)=>!!e&&(e.startsWith("AddSource_Type_")?!(8<e.replace("AddSource_Type_","").length&&(Ft({api:t,paramName:s,desc:Yt("keyword",8)}),1)):(Ft({api:t,paramName:s,desc:ls("SourcePrefixLog")}),!1))},remark:{type:"String",required:!1,validator:(e,t,s)=>!(Ue(e)&&96<e.length&&(Ft({api:t,paramName:s,desc:Yt(s,96)}),1))}},deleteFriend:{userIDList:rs},checkFriend:{userIDList:rs},getFriendProfile:{userIDList:rs},updateFriend:{userID:os,remark:{type:"String",required:!1,validator:(e,t,s)=>!(Ue(e)&&96<e.length&&(Ft({api:t,paramName:s,desc:Yt(s,96)}),1))},friendCustomField:{type:"Array",required:!1,validator:(e,s,i)=>{if(e){if(!Fe(e))return Ft({api:s,paramName:i,desc:Bt()}),!1;let t=!0;return e.forEach(e=>Ue(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?Ue(e.value)?8<e.key.replace("Tag_SNS_Custom_","").length?(Ft({api:s,paramName:i,desc:Yt("keyword",8)}),t=!1):void 0:(Ft({api:s,paramName:i,desc:Xt("value")}),t=!1):(Ft({api:s,paramName:i,desc:ls("FriendCustomFieldPrefixLog")}),t=!1)),t}return!0}}},acceptFriendApplication:{userID:os},refuseFriendApplication:{userID:os},deleteFriendApplication:{userID:os},createFriendGroup:{name:os},deleteFriendGroup:{name:os},addToFriendGroup:{name:os,userIDList:rs},removeFromFriendGroup:{name:os,userIDList:rs},renameFriendGroup:{oldName:os,newName:os},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:(e,t,s)=>Fe(e)?0!==e.length||(Ft({api:t,paramName:s,desc:Kt()}),!1):(Ft({api:t,paramName:s,desc:Bt()}),!1)}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:(e,t,s)=>Fe(e)?0!==e.length||(Ft({api:t,paramName:s,desc:Kt()}),!1):(Ft({api:t,paramName:s,desc:Bt()}),!1)}],createTopicInCommunity:{groupID:os,topicName:os},deleteTopicFromCommunity:{groupID:os,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Fe(e)||(Ft({api:t,paramName:s,desc:Bt()}),!1)}},updateTopicProfile:{groupID:os,topicID:os},getTopicList:{groupID:os,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Fe(e)||(Ft({api:t,paramName:s,desc:Bt()}),!1)}},followUser:[{name:"userIDList",...rs}],unfollowUser:[{name:"userIDList",...rs}],getMyFollowingList:[{name:"startIndex",...os,required:!1}],getMyFollowersList:[{name:"startIndex",...os,required:!1}],getMutualFollowersList:[{name:"startIndex",...os,required:!1}],getUserFollowInfo:[{name:"userIDList",...rs,required:!1}],addSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ft({api:t,paramName:s,desc:wt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ft({api:t,paramName:s,desc:Vt()}),!1):(""===e.name&&Ft({api:t,paramName:s,desc:ts()}),!0)}],removeSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Ft({api:t,paramName:s,desc:wt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Ft({api:t,paramName:s,desc:Vt()}),!1):(""===e.name&&Ft({api:t,paramName:s,desc:ts()}),!0)}],invite:{userID:os},inviteSync:[{...as,validator:(e,t,s)=>ke(e)?!!Ue(e.userID)||(Ft({api:t,paramName:"options.userID",desc:$t()}),!1):(Ft({api:t,paramName:"options",desc:Jt()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Vt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Vt()}),!0)}],inviteInGroup:{groupID:os,inviteeList:rs},inviteInGroupSync:[{...as,validator:(e,t,s)=>ke(e)?Ue(e.groupID)?!!Fe(e.inviteeList)||(Ft({api:t,paramName:"options.inviteeList",desc:Bt()}),!1):(Ft({api:t,paramName:"options.groupID",desc:$t()}),!1):(Ft({api:t,paramName:"options",desc:Jt()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Vt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>($e(e)&&Ft({api:t,paramName:s,desc:Vt()}),!0)}],accept:{inviteID:os},reject:{inviteID:os},getSignalingInfo:[{name:"message",...as,validator:(e,t,s)=>!Re(e)||(Ft({api:t,paramName:s,desc:es()}),!1)}],modifyInvitation:{inviteID:os,data:os}},_s={login:1,logout:1,getLoginUser:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,isReady: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,convertVoiceToText:1,modifyMessage:1,searchCloudMessages:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,setConversationDraft: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,followUser:1,unfollowUser:1,getMyFollowingList:1,getMyFollowersList:1,getMutualFollowersList:1,getUserFollowInfo:1,callExperimentalAPI:1,addSignalingListener:1,removeSignalingListener:1,invite:1,inviteSync:1,inviteInGroup:1,inviteInGroupSync:1,cancel:1,accept:1,reject:1,getSignalingInfo:1,modifyInvitation:1},ps=1,hs=2,gs=3,ms=4,Ms=6,Is=7,fs=8,Cs=10,Ts=11,ys=12,Ds=13,Ss=14,Es=15,vs=17,As=18,Rs=19,Ls=20,Ns=21,Os=23,Ps=24,Us=25,Gs=26,ks=27,Fs=28,$s=29,ws=30,bs=31,qs=32,xs=33,Vs=34,Bs=35,Ks=function(e){return{code:0,data:e||{}}};class Hs extends Error{constructor(e){super();var{code:e,message:t,data:s}=e;this.code=e,this.message=t||this._getErrorMessage(this.code),this.data=s||{}}}const Ws={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,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AVCHATROOM:2101,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_F_IS_EMPTY:2108,MSG_ONPROGRESS_FUNCTION_ERROR:2109,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,VOICE_TO_TEXT_FAIL:2118,UNSUPPORTED_VOICE_FORMAT:2119,MSG_I_SELECT_F_FIRST:2251,MSG_I_TYPES_LIMIT:2252,MSG_I_SIZE_LIMIT:2253,MSG_A_UPLOAD_FAIL:2300,MSG_A_SIZE_LIMIT:2301,MSG_V_UPLOAD_FAIL:2350,MSG_V_SIZE_LIMIT:2351,MSG_V_TYPES_LIMIT:2352,MSG_F_UPLOAD_FAIL:2400,MSG_F_SELECT_F_FIRST:2401,MSG_F_SIZE_LIMIT:2402,MSG_F_URL_IS_EMPTY:2403,MSG_MERGER_TYPE_INVALID:2450,MSG_MERGER_KEY_INVALID:2451,MSG_MERGER_DOWNLOAD_FAIL:2452,MSG_FORWARD_TYPE_INVALID:2453,MSG_FORWARD_INVALID_ELEMENTS:2454,MSG_MODIFY_CONFLICT:2480,MSG_MODIFY_DISABLED_IN_AVCHATROOM:2481,CONV_NOT_FOUND:2500,USER_OR_GRP_NOT_FOUND:2501,CONV_UN_RECORDED_TYPE:2502,INVALID_CONV_ID:2503,ILLEGAL_GRP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GRP_ID:2602,CANNOT_FIND_GRP:2603,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_WORK:2622,MEMBER_NOT_IN_GRP:2623,JOIN_GRP_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,OPERATION_NOT_SUPPORTED_IN_AVCHATROOM:2687,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GRP_EXISTED:2710,FRIEND_GRP_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,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022,SIGNALING_INVALID_INVITE_ID:8010,SIGNALING_NO_PERMISSION:8011,SIGNALING_ALREADY_EXISTS:8012,INVALID_CANCEL_MESSAGE:8020,MSG_SEARCH_CURSOR_INVALID:27002,MSG_SEARCH_CURSOR_EXPIRED:27003};let Ys=null;const zs=function(e){Ys=e},js=function(e){return Promise.resolve(Ks(e))},Xs=function(t,s=!1){if(t instanceof Hs)return s&&null!==Ys&&Ys.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){const t=new Hs({code:Ws.UNCAUGHT_ERROR});return s&&null!==Ys&&Ys.emit(e.ERROR,t),Promise.reject(t)}if($e(t)||$e(t.code))return Promise.reject(new Hs({code:Ws.UNCAUGHT_ERROR}));t=new Hs(t);return s&&null!==Ys&&Ys.emit(e.ERROR,t),Promise.reject(t)};class Js{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(ys).isLoggedIn()}isOversea(){return this._m.get(ys).isOversea()}isPrivateNetWork(){return this._m.get(ys).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(ys).getFileDownloadProxy()}getMyUserID(){return this._m.get(ys).getUserID()}getMyTinyID(){return this._m.get(ys).getTinyID()}getSDKAppID(){return this._m.get(ys).getSDKAppID()}isIntl(){return this._m.get(ys).isIntl()}isUsingChatCore(){return this._m.get(ys).isUsingChatCore()}isDevMode(){return this._m.get(ys).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return q}getCloudConfig(e){return this._m.get(Os).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.get(ys).getTinyID()+"-"+e.random}req(e){return this._m.get(Ls).req(e)}canIUse(e){return this._m.get(ks).canIUse(e)}getErrorMessage(e,t,s){return this._m.getErrorMessage(e,t,s)}outputWarning(e,t,s){e=this.getErrorMessage(e,t,s);e&&Ie.w(e)}cannotUseCommercialAbility(e){var t=Ws.CANNOT_USE_COMMERCIAL_ABILITY;return Xs({code:t,message:this.getErrorMessage(t,e)})}}const Qs={LOGIN:"wslogin",LOGOUT:"wslogout",HELLO:"wshello",KICK_OTHER:"KickOther",SYNC_UNREAD_MSG:"getmsg",SEND_C2C_MSG:"sendmsg",SEND_GRP_MSG:"send_group_msg",GET_USER_PROFILE:"portrait_get_all",UPDATE_MY_PROFILE:"portrait_set",GET_BL:"black_list_get",ADD_TO_BL:"black_list_add",RM_FROM_BL:"black_list_delete",GET_FD_LIST:"friend_get",GET_FD_PROFILE:"friend_get_specified",CHECK_FD:"friend_check",DEL_FD:"friend_delete",ADD_FD:"friend_add",UPDATE_FD:"friend_update",RESPOND_FD_APPLICATION:"friend_response",GET_FD_APPLICATION_LIST:"pendency_get",DEL_FD_APPLICATION:"pendency_delete",REFUSE_FD_APPLICATION:"pendency_refuse",REPORT_FD_APPLICATION:"pendency_report",GET_FD_GRP_LIST:"group_get",CREATE_FD_GRP:"group_add",DEL_FD_GRP:"group_delete",UPDATE_FD_GRP:"group_update",REVOKE_C2C_MSG:"msgwithdraw",SET_C2C_MSG_READ:"msgreaded",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_C2C_ROAMING_MSG:"getroammsg",GET_C2C_PEER_READ_TIME:"get_peer_read_time",DEL_C2C_MSG:"delete_c2c_msg_ramble",MODIFY_C2C_MSG:"modify_c2c_msg",MODIFY_C2C_MSG_EXT:"set_key_values",GET_C2C_MSG_EXT:"get_key_values",ADD_C2C_MSG_REACTION:"reaction_add",RM_C2C_MSG_REACTION:"reaction_del",GET_C2C_MSG_REACTIONS:"reaction_multi_stat",GET_C2C_MSG_REACTION_USER_LIST:"reaction_iterate",PAGING_GET_CONV_LIST:"page_get",DEL_CONV:"batch_delete",CLEAR_HISTORY_MSG:"clear_msg",PIN_CONV:"top",DEL_GROUP_AT_TIPS:"deletemsg",SET_CONV_CUSTOM_DATA:"set_conv_custom_data",MARK_CONV:"mark_contact",CREATE_CONV_GRP:"create_contact_group",DEL_CONV_GRP:"del_contact_group",RENAME_CONV_GRP:"update_contact_group",ADD_CONV_TO_GRP:"add_conv_to_group",DEL_CONV_FROM_GRP:"del_conv_from_group",GET_CONV_GRP_LIST:"get_contact_group",GET_GRP_LIST:"get_joined_group_list",GET_GRP_PROFILE:"get_group_self_member_info",CREATE_GRP:"create_group",DISMISS_GRP:"destroy_group",UPDATE_GRP_PROFILE:"modify_group_base_info",APPLY_JOIN_GRP:"apply_join_group",APPLY_JOIN_GRP_NOAUTH:"apply_join_group_noauth",QUIT_GRP:"quit_group",SEARCH_GRP:"get_group_public_info",CHANGE_GRP_OWNER:"change_group_owner",HANDLE_GRP_APPLICATION:"handle_apply_join_group",HANDLE_INVITE_JOIN_GRP:"handle_invite_join_permission_group",HANDLE_GRP_INVITATION:"handle_invite_join_group",REVOKE_GRP_MSG:"group_msg_recall",SET_GRP_MSG_READ:"msg_read_report",SET_ALL_MSG_READ:"read_all_unread_msg",GET_GRP_ROAMING_MSG:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",GET_GRP_PENDENCY:"get_pendency",DEL_GRP_SYSTEM_NOTICE:"deletemsg",AV_POLLING:"get_msg",AV_NOAUTH_POLLING:"get_msg_noauth",GET_ONLINE_MBR_NUM:"get_online_member_num",DEL_GRP_MSG:"delete_group_ramble_msg_by_seq",MODIFY_GRP_MSG:"modify_group_msg",SET_GRP_ATTR:"set_group_attr",MODIFY_GRP_ATTR:"modify_group_attr",DEL_GRP_ATTR:"delete_group_attr",CLEAR_GRP_ATTR:"clear_group_attr",GET_GRP_ATTR:"get_group_attr",MODIFY_GRP_MSG_EXT:"group_set_key_values",GET_GRP_MSG_EXT:"group_get_key_values",GET_GRP_NOTIFY:"batch_get_group_notify",UPDATE_GRP_COUNTER:"update_group_counter",GET_GRP_COUNTER:"get_group_counter",ADD_GRP_MSG_REACTION:"group_reaction_add",RM_GRP_MSG_REACTION:"group_reaction_del",GET_GRP_MSG_REACTIONS:"group_reaction_multi_stat",GET_GRP_MSG_REACTION_USER_LIST:"group_reaction_iterate",GET_GRP_MBR_LIST:"get_group_member_info",GET_AV_MBR_LIST:"get_members",GET_GRP_MBR_PROFILE:"get_specified_group_member_info",ADD_GRP_MBR:"add_group_member",DEL_GRP_MBR:"delete_group_member",BAN_AV_MBR:"ban_group_member",MODIFY_GRP_MBR_INFO:"modify_group_member_info",MARK_AV_MBR_INFO:"modify_user_info",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",SIMPLE_COS_PRE_SIG:"simple_sig",GET_IMAGE_INFO:"get_imageinfo",GET_IP:"get_final_ip",VIDEO_COVER:"video_cover",SSO_STAT:"tim_web_report_v2",PING:"alive",MSG_PUSH:"msg_push",MSG_CLOUD_SEARCH:"query",MULTI_MSG_PUSH:"multi_msg_push_ws",MSG_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",UPLOAD_MERGER_MSG:"save_relay_json_msg",DOWNLOAD_MERGER_MSG:"get_relay_json_msg",FETCH_CLOUD_CTRL_CONFIG:"fetch_config",PUSHED_CLOUD_CTRL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",OVERLOAD_NOTIFY:"notify2",CREATE_TOPIC:"create_topic",DEL_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",SUB_USER_STATUS:"ws_status_subscribe",UNSUB_USER_STATUS:"ws_status_unsubscribe",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",GET_PROFANITY_LIST:"get_local_words",TRANSLATE_TEXT:"ws_batch_trans_text",VOICE_TO_TEXT:"ws_sentence_recognition",FOLLOW:"follow_add",UNFOLLOW:"follow_delete",GET_FOLLOW:"follow_get",GET_FOLLOW_INFO:"follow_get_info"},Zs="networkRTT",ei="messageE2EDelay",ti="sendMessageC2C",si="sendMessageGroup",ii="sendMessageGroupAV",ni="sendMessageRichMedia",oi="cosUpload",ri="messageReceivedGroup",ai="messageReceivedGroupAVPush",ci="messageReceivedGroupAVPull",ui={[Zs]:2,[ei]:3,[ti]:4,[si]:5,[ii]:6,[ni]:7,[ri]:8,[ai]:9,[ci]:10,[oi]:11},li={info:4,warning:5,error:6},di={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},_i={login:4,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16};class pi{constructor(e){this._n="SSOLogData",this.eventType=_i[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=_e()}static bindEventStatModule(e){pi.prototype._eventStatModule=e}static bindNetMonitorModule(e){pi.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=_e()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){const e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=_e();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){if(!(e instanceof Error))return Ie.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=Ws.NO_NETWORK;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return $e(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Pe(e)?this.code=e:Ie.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return $e(e)||this._sentFlag||(Pe(e)&&(this.message=e.toString()),Ue(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return $e(e)||this._sentFlag||(this.level=li[e]),this}setMoreMessage(e){return Re(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return $e(e)?Ie.w(this._n+".setNetworkType value is undefined, please check!"):(e=di[e.toLowerCase()],$e(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}class hi{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 gi{constructor(e,s){this._imageMemoryURL="",this._fileDownloadProxy=s,G?this.createImageDataASURLInWXMiniApp(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||fe.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){const t=this;this._ImageInfoModel=function(e){this.instanceID=Ye(9999999),this.sizeType=e.type||0,this.type=0,this.size=e.size||0,this.width=e.width||0,this.height=e.height||0,this.imageUrl=e.imageUrl||e.url||"",this.url=Dt(e.url||t._imageMemoryURL,t._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,i;for(;t<=2;)i=$e(e)||$e(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(s=new this._ImageInfoModel(i)).setSizeType(t+1),s.setType(t),this.addImageInfo(s),t++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(t){var s=this.content.imageInfoArray.length;let i;for(let e=0;e<s;e++)i=this.content.imageInfoArray[e],t[e].size&&(i.size=t[e].size),t[e].url&&i.setImageUrl(t[e].url),t[e].width&&(i.width=t[e].width),t[e].height&&(i.height=t[e].height)}_autoFixUrl(){var t=this.content.imageInfoArray.length;let s="",i="";const o=["http","https"];let n=null;for(let e=0;e<t;e++)this.content.imageInfoArray[e].url&&(""!==(n=this.content.imageInfoArray[e]).imageUrl&&(i=n.imageUrl.slice(0,n.imageUrl.indexOf("://")+1),s=n.imageUrl.slice(n.imageUrl.indexOf("://")+1),o.indexOf(i)<0&&(i="https:"),this.content.imageInfoArray[e].setImageUrl([i,s].join(""))))}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateImageFormat(e){this.content.imageFormat=fe[e.toUpperCase()]||fe.UNKNOWN}createImageDataASURLInWeb(e){void 0!==e&&0<e.files.length&&(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){3<=this.content.imageInfoArray.length||this.content.imageInfoArray.push(e)}updateAccessSideImageInfoArray(){var e=this.content.imageInfoArray,{width:t=0,height:s=0}=e[0];0!==t&&0!==s&&(pt(e),Object.assign(e[2],_t({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 mi{constructor(e){this.type=t.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class Mi{constructor(e,s){this.type=t.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:e.second,size:e.size,url:Dt(e.url,s),remoteAudioUrl:e.url||"",uuid:e.uuid}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateAudioUrl(e){this.content.remoteAudioUrl=e}sendable(){return""!==this.content.remoteAudioUrl}}const Ii={from:!0,groupID:!0,groupName:!0,to:!0};class fi{constructor(e){this.type=t.MSG_GRP_TIP,this.content={},this._initContent(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[e]=t[e],this.content.memberCount=t[e];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(t[e]);break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];Ii[i]&&(this.content.groupProfile[i]=t[i])}}_updateMemberList(e){Re(this.content.memberList)?this.content.memberList=e:this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];this.content.newGroupProfile[i]="muteAllMembers"!==i?t[i]:1===t[i]}}}const Ci={from:!0,groupID:!0,groupName:!0,to:!0};class Ti{constructor(e){this.type=t.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;default:this.content[e]=t[e]}})}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];Ci[i]&&("groupName"===i?this.content.groupProfile.name=t[i]:this.content.groupProfile[i]=t[i])}}}class yi{constructor(e,s){this.type=t.MSG_FILE,this._percent=0;var i=this._getFileInfo(e);this.content={downloadFlag:2,fileUrl:Dt(e.url||e.fileUrl,s)||"",uuid:e.uuid,fileName:i.name||"",fileSize:i.size||0}}_getFileInfo(e){if(!$e(e.fileName)&&!$e(e.fileSize))return{size:e.fileSize,name:e.fileName};const t=e.file.files[0];if(P){if(t.path&&-1!==t.path.indexOf(".")){const e=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase();t.type=e,t.name||(t.name=Ye(999999)+"."+e)}t.name||(t.type="",t.name=t.path.slice(t.path.lastIndexOf("/")+1).toLowerCase()),t.suffix&&(t.type=t.suffix),t.url||(t.url=t.path)}return{size:t.size,name:t.name}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateFileUrl(e){this.content.fileUrl=e}sendable(){return""!==this.content.fileUrl&&""!==this.content.fileName&&0!==this.content.fileSize}}class Di{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 Si{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:Dt(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:Dt(e.thumbUrl,s),snapshotUrl:Dt(e.thumbUrl,s)}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=e)}updateSnapshotInfo(e){var{snapshotUrl:e,snapshotWidth:t,snapshotHeight:s}=e;Re(e)||(this.content.thumbUrl=this.content.snapshotUrl=e),Re(t)||(this.content.thumbWidth=this.content.snapshotWidth=Number(t)),Re(s)||(this.content.thumbHeight=this.content.snapshotHeight=Number(s))}sendable(){return""!==this.content.remoteVideoUrl}}class Ei{constructor(e){this.type=t.MSG_LOCATION;var{description:e,longitude:s,latitude:i}=e;this.content={description:e,longitude:s,latitude:i}}sendable(){return!0}}class vi{constructor(e,s){var i,o;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||"",e.messageBody?this.messageBody=JSON.parse(JSON.stringify(e.messageBody)):this.messageBody=[{type:e.type,payload:e.payload}],e.conversationType?e.conversationType.startsWith(t.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(t.CONV_GROUP)&&(this.receiverGroupID=e.to):e.receiverGroupID?this.receiverGroupID=e.receiverGroupID:e.receiverUserID&&(this.receiverUserID=e.receiverUserID),this.messageReceiver=e.to||e.messageReceiver):(this.nick=e.nick||"",this.avatar=e.avatar||"",this.messageBody=[],i=e.elements[0].type,o=e.elements[0].content,this._patchRichMediaPayload(i,o),this._updateRichMediaDownloadUrl(i,o,s),i===t.MSG_MERGER?this.messageBody.push({type:i,payload:new Ai(o).content}):this.messageBody.push({type:i,payload:o}),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,i){i&&(e===t.MSG_IMAGE?s.imageInfoArray.forEach(e=>{e.url=Dt(e.url,i)}):e===t.MSG_VIDEO?(s.videoUrl=Dt(s.videoUrl,i),s.snapshotUrl=Dt(s.thumbUrl,i),s.snapshotHeight=s.thumbHeight,s.snapshotWidth=s.thumbWidth):e===t.MSG_AUDIO?s.url=Dt(s.url,i):e===t.MSG_FILE&&(s.fileUrl=Dt(s.fileUrl,i)))}}var Ai=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:i,abstractList:o,compatibleText:n,version:r}=e;this.content.downloadKey=t,this.content.pbDownloadKey=s,this.content.title=i,this.content.abstractList=o,this.content.compatibleText=n,this.content.version=r||0}else if(Re(e.messageList))1===e.layersOverLimit&&(this.content.layersOverLimit=!0);else{const{messageList:t,title:a,abstractList:c,compatibleText:l,version:u}=e,d=[];t.forEach(e=>{Re(e)||(e=new vi(e,s),d.push(e))}),this.content.messageList=d,this.content.title=a,this.content.abstractList=c,this.content.compatibleText=l,this.content.version=u||0}}sendable(){return!Re(this.content.messageList)||!Re(this.content.downloadKey)}};const Ri={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST};class Li{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:Ye(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=Et(e.checkResult),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||Lt,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||he()||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||"",this.revokerInfo=e.revokerInfo||{userID:"",nick:"",avatar:""},this.revokeReason=e.revokeReason||"",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){null!==e&&(Ue(e.nick)&&(this.nick=e.nick),Ue(e.avatar)&&(this.avatar=e.avatar),e=e["messageFromAccountExtraInformation"],ke(e)&&Ue(e.nameCard)&&(this.nameCard=e.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))}),Fe(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?Lt:Rt,this.from||(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===t.CONV_GROUP&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(i){if(!i)return!1;if(void 0===Je[i]){const o=new Date;let e=("3"+o.getHours()).slice(-2),t=("0"+o.getMinutes()).slice(-2),s=("0"+o.getSeconds()).slice(-2);Je[i]=parseInt([e,t,s,"0001"].join("")),e=null,t=null,s=null,Ie.l("autoIncrementIndex start index:"+Je[i])}return Je[i]++}(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){var s=this["to"],i=this.conversationType;i!==t.CONV_SYSTEM?(e=i===t.CONV_C2C?e===this.from?s:this.from:this.to,this.conversationID=e?""+i+e:null):this.conversationID=t.CONV_SYSTEM}isElement(e){return e instanceof hi||e instanceof gi||e instanceof mi||e instanceof Mi||e instanceof yi||e instanceof Si||e instanceof fi||e instanceof Ti||e instanceof Di||e instanceof Ei||e instanceof Ai}setElement(s,i){if(this.isElement(s))return this._elements=[s],void this._initProxy();var 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,i);break;case t.MSG_AUDIO:this.setAudioElement(e.content,i);break;case t.MSG_FILE:this.setFileElement(e.content,i);break;case t.MSG_VIDEO:this.setVideoElement(e.content,i);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,i)}};if(Fe(s))for(let e=0;e<s.length;e++)o(s[e]);else o(s);this._initProxy()}clearElement(){this._elements.length=0}setTextElement(e){e="string"==typeof e?e:e.text,e=new hi({text:e});this._elements.push(e)}setImageElement(e,t){e=new gi(e,t);this._elements.push(e)}setAudioElement(e,t){e=new Mi(e,t);this._elements.push(e)}setFileElement(e,t){e=new yi(e,t);this._elements.push(e)}setVideoElement(e,t){e=new Si(e,t);this._elements.push(e)}setLocationElement(e){e=new Ei(e);this._elements.push(e)}setCustomElement(e){e=new Di(e);this._elements.push(e)}setGroupTipElement(e){let s={};var i=e.operationType;if(Re(e.memberInfoList)?e.operatorInfo&&(s=e.operatorInfo):i!==t.GRP_TIP_MBR_JOIN&&i!==t.GRP_TIP_MBR_KICKED_OUT&&i!==t.GRP_TIP_MBR_SET_ADMIN&&i!==t.GRP_TIP_MBR_CANCELED_ADMIN||(s=e.memberInfoList[0]),!Re(e.memberExtraInfo)){const t=e.memberExtraInfo["reason"];e.msgMemberInfo.forEach(e=>{e.reason=t})}var{nick:i,avatar:o}=s,i=(Ue(i)&&(this.nick=i),Ue(o)&&(this.avatar=o),new fi(e));this._elements.push(i)}setGroupSystemNoticeElement(e){e=new Ti(e);this._elements.push(e)}setFaceElement(e){e=new mi(e);this._elements.push(e)}setMergerElement(e,t){e=new Ai(e,t);this._elements.push(e)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(e){if($e(e))return t.MSG_PRIORITY_NORMAL;if(Ue(e)&&-1!==Object.values(Ri).indexOf(e))return e;if(Pe(e)){const t=""+e;if(-1!==Object.keys(Ri).indexOf(t))return Ri[t]}return t.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){var{nick:e,avatar:t}=e;Ue(e)&&(this.nick=e),Ue(t)&&(this.avatar=t)}setNameCard(e){Ue(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){this.conversationType===t.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e)}}class Ni extends Js{constructor(e){super(e),this._n="C2CModule",this._messageFromUnreadDBMap=new Map,this._noticeFromUnreadDBList=[]}onNewC2CMessage(t){var{dataList:t,isInstantMessage:s,C2CRemainingUnreadList:i,C2CPairUnreadList:o,isSyncingEnded:n}=t;Ie.d(`${this._n}.onNewC2CMessage count:${t.length} isInstantMessage:`+s);const{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:c}=this._newC2CMessageStoredAndSummary({dataList:t,C2CRemainingUnreadList:i,C2CPairUnreadList:o,isInstantMessage:s}),l=Re(t=a)?[]:t.filter(e=>!0===e.isModified);0<l.length&&this.emitOuterEvent(e.MESSAGE_MODIFIED,l),this.get(Ts).onNewMessage({conversationOptionsList:r,isInstantMessage:s,isUnreadC2CMessage:c,isSyncingEnded:n});o=Re(i=a)?[]:i.filter(e=>!1===e.isModified);s&&0<o.length&&this.emitOuterEvent(e.MESSAGE_RECEIVED,o),a.length=0}_newC2CMessageStoredAndSummary({dataList:o,C2CRemainingUnreadList:n,C2CPairUnreadList:r,isInstantMessage:a}){let c=null;const l=[],d=[],s={},p=this.get(Gs);let u=!1;const _=this.get(Ts),h=this.get(ms),g=this.getFileDownloadProxy();for(let i=0,e=o.length;i<e;i++)if(this._isC2CNotice(o[i]))this._noticeFromUnreadDBList.push(o[i].eventArray[0].c2CNotifyMsgArray[0]);else{const n=o[i],r=(n.currentUser=this.getMyUserID(),n.conversationType=t.CONV_C2C,n.isSystemMessage=!!n.isSystemMessage,($e(n.nick)||$e(n.avatar))&&(u=!0,Ie.d(this._n+"._newC2CMessageStoredAndSummary nick or avatar missing!")),(c=new Li(n)).setElement(n.elements,g),c.setNickAndAvatar({nick:n.nick,avatar:n.avatar}),c)["conversationID"];if(a){if(1===this._messageFromUnreadDBMap.get(c.ID))continue;let e=!1;if(c.from!==this.getMyUserID()){const o=_.getLatestMessageSentByPeer(r);if(o){const{nick:n,avatar:r}=o;u?c.setNickAndAvatar({nick:n,avatar:r}):n===c.nick&&r===c.avatar||(e=!0)}}else{const o=_.getLatestMessageSentByMe(r);if(o){const{nick:t,avatar:n}=o;t===c.nick&&n===c.avatar||(_.modifyMessageSentByMe({conversationID:r,latestNick:c.nick,latestAvatar:c.avatar}),h.mockOnNickAvatarModified(c.nick,c.avatar))}}let s=1===o[i].isModified;if(_.isMessageSentByCurrentInstance(c)?c.isModified=s:s=!1,0===n.msgLifeTime)c._onlineOnlyFlag=!0,_.isMessageSentByCurrentInstance(c)||d.push(c);else{if(!_.pushIntoMessageList(d,c,s))continue;e&&(_.modifyMessageSentByPeer({conversationID:r,latestNick:c.nick,latestAvatar:c.avatar}),_.updateUserProfileSpecifiedKey({conversationID:r,nick:c.nick,avatar:c.avatar}))}a&&0<c.clientTime&&p.addMessageDelay(c.clientTime)}else this._messageFromUnreadDBMap.set(c.ID,1);if(0!==n.msgLifeTime){if(!1===c._onlineOnlyFlag){const o=_.getLastMessageTime(r);if(!(Pe(o)&&c.time<o))if($e(s[r])){let e=0;"in"===c.flow&&(c._isExcludedFromUnreadCount||(e=1)),s[r]=l.push({conversationID:r,unreadCount:e,type:c.conversationType,subType:c.conversationSubType,lastMessage:c._isExcludedFromLastMessage?"":c})-1}else{const o=s[r];l[o].type=c.conversationType,l[o].subType=c.conversationSubType,l[o].lastMessage=c._isExcludedFromLastMessage?"":c,"in"===c.flow&&(c._isExcludedFromUnreadCount||l[o].unreadCount++)}}}else c._onlineOnlyFlag=!0}this._handleRevokedNoticeFromUnreadDB();let i=!1;if(Fe(r))for(let s=0,e=r.length;s<e;s++)if(0<r[s].unreadCount){i=!0;const o=l.find(({conversationID:e})=>e==="C2C"+r[s].from);o?o.unreadCount=r[s].unreadCount:l.push({conversationID:"C2C"+r[s].from,unreadCount:r[s].unreadCount,type:t.CONV_C2C})}if(Fe(n))for(let s=0,e=n.length;s<e;s++)l.find(({conversationID:e})=>e==="C2C"+n[s].from)||l.push({conversationID:"C2C"+n[s].from,type:t.CONV_C2C,lastMsgTime:n[s].lastMsgTime});return{conversationOptionsList:l,messageList:d,isUnreadC2CMessage:i}}_isC2CNotice(e){e=e.eventArray;return!(!Fe(e)||10!==e[0].event)}_handleRevokedNoticeFromUnreadDB(){var e=this._noticeFromUnreadDBList.length;if(0!==e){Ie.l(this._n+"._handleRevokedNoticeFromUnreadDB count:"+e);const t=[];this._noticeFromUnreadDBList.forEach(e=>{e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)}),this.onC2CMessageRevoked({dataList:t}),this._noticeFromUnreadDBList.length=0,t.length=0}}onC2CMessageRevoked(s){const r=this.get(Ts),a=[];let c;s.dataList.forEach(e=>{if(e.c2cMessageRevokedNotify){const s=e.c2cMessageRevokedNotify["revokedInfos"];$e(s)||s.forEach(e=>{var s=this.getMyUserID()===e.from?""+t.CONV_C2C+e.to:""+t.CONV_C2C+e.from,i=(c=r.revoke(s,e.sequence,e.random),e.revokerInfo&&e.revokerInfo.revoker),o=e.revokerInfo&&e.revokerInfo.reason||"";let n;c?n=c:(n={conversationID:s,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(n.ID=`${e.tinyID}-${e.clientTime}-`+e.random),e.time&&(n.time=e.time)),n&&(n.revoker=i,n.revokeReason=o,n.revokerInfo={userID:i,nick:"",avatar:""},a.push(n))})}}),0!==a.length&&(r.onMessageRevoked(a),Ie.l(this._n+".onC2CMessageRevoked count:"+a.length),r.updateRevokerInfo(a).then(t=>{this.emitOuterEvent(e.MESSAGE_REVOKED,t)}))}onC2CMessageReadReceipt(e){e.dataList.forEach(e=>{if(!Re(e.c2cMessageReadReceipt)){const o=e.c2cMessageReadReceipt["to"];e.c2cMessageReadReceipt.uinPairReadArray.forEach(e=>{e=e.peerReadTime;Ie.d(`${this._n}._onC2CMessageReadReceipt to:${o} peerReadTime:`+e);const s=""+t.CONV_C2C+o,i=this.get(Ts);i.recordPeerReadTime(s,e),i.updateMessageIsPeerReadProperty(s,e)})}})}onC2CMessageReadNotice(e){e.dataList.forEach(e=>{if(!Re(e.c2cMessageReadNotice)){const i=this.get(Ts);e.c2cMessageReadNotice.uinPairReadArray.forEach(e=>{var{from:e,peerReadTime:s}=e,e=(Ie.d(this._n+`.onC2CMessageReadNotice from:${e} lastReadTime:`+s),""+t.CONV_C2C+e);i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:s}),i.updateUnreadCount(e)})}})}onC2CMessageModified(e){Ie.d(this._n+".onC2CMessageModified options:",JSON.stringify(e));const s=this.get(Ts);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_C2C})})}onReadReceiptList(e){Ie.d(this._n+".onReadReceiptList options:",JSON.stringify(e));var{userID:e,readReceiptList:t}=e.dataList;this.get(Ts).updateReadReceiptInfo({userID:e,readReceiptList:t})}sendMessage(e,t){e=this._createC2CMessagePack(e,t);return this.req(e)}_createC2CMessagePack(e,t){let s=null,i=(t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly&&(s?s.disablePush=!0:s={disablePush:!0})),"");Ue(e.cloudCustomData)&&0<e.cloudCustomData.length&&(i=e.cloudCustomData);const o=[];if(ke(t)&&ke(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}t=this.isOnlineMessage(e,t)?0:void 0;return{proto:Qs.SEND_C2C_MSG,tjgID:this.generateTjgID(e),data:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:i,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:t,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!==t?o:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_isVoipPush(e){let t=void 0;return t=$e(e.disableVoipPush)?t:!1===e.disableVoipPush?1:0}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.req({proto:Qs.REVOKE_C2C_MSG,data:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}deleteMessage(e){var{to:e,keyList:t}=e;return Ie.l(this._n+`.deleteMessage toAccount:${e} count:`+t.length),this.req({proto:Qs.DEL_C2C_MSG,data:{fromAccount:this.getMyUserID(),to:e,keyList:t}})}modifyRemoteMessage(e){var s,{from:e,to:i,version:o=0,sequence:n,random:r,time:a,payload:c,type:l,cloudCustomData:u}=e;let d=void 0;return(s=l)!==t.MSG_TEXT&&s!==t.MSG_CUSTOM&&s!==t.MSG_LOCATION&&s!==t.MSG_FACE||(d=[]).push({type:l,content:c}),this.req({proto:Qs.MODIFY_C2C_MSG,data:{from:e,to:i,version:o,sequence:n,random:r,time:a,elements:d,cloudCustomData:u}})}setMessageRead({conversationID:t,lastMessageTime:s}){const i=this._n+".setMessageRead",o=(Ie.l(i+` conversationID:${t} lastMessageTime:`+s),Pe(s)||this.outputWarning("DoNotModifyLastTime"),new pi("setC2CMessageRead"));return o.setMessage(`conversationID:${t} lastMessageTime:`+s),this.req({proto:Qs.SET_C2C_MSG_READ,data:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:t.replace("C2C",""),lastMessageTime:s,receipt:1}]}}}).then(()=>{o.end(),Ie.l(i+" ok");const e=this.get(Ts);return e.updateIsReadAfterReadReport({conversationID:t,lastMessageTime:s}),e.updateUnreadCount(t),Ks()}).catch(e=>(o.setError(e).end(),Ie.l(i+" failed. error:",e),Xs(e)))}getRoamingMessage(e){const a=this._n+".getRoamingMessage",{peerAccount:s,conversationID:c,count:i,lastMessageTime:o,messageKey:n}=e,l=`peerAccount:${s} count:${i||15} lastMessageTime:${o||0} messageKey:`+n,d=(Ie.l(a+" "+l),new pi("getC2CRoamingMessages"));return this.req({proto:Qs.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:i||15,lastMessageTime:o||0,messageKey:n}}).then(e=>{var{complete:e,messageList:s,messageKey:i,lastMessageTime:o}=e.data;$e(s)?Ie.l(a+` ok. complete:${e} but messageList is undefined!`):Ie.l(a+` ok. complete:${e} count:`+s.length),d.setMessage(l+` complete:${e} length:`+s.length).end();const n=this.get(Ts);1===e&&n.setCompleted(c);e=n.onRoamingMessage(s,c),n.modifyMessageList(c),n.updateIsRead(c),n.updateRoamingMessageKeyAndTime(c,i,o),s=n.getPeerReadTime(c);if(Ie.l(a+` update isPeerRead property. conversationID:${c} peerReadTime:`+s),s)n.updateMessageIsPeerReadProperty(c,s);else{const e=c.replace(t.CONV_C2C,"");this.getRemotePeerReadTime([e]).then(()=>{n.updateMessageIsPeerReadProperty(c,n.getPeerReadTime(c))})}let r="";if(0<e.length)r=e[0].ID;else{const e=n.getLocalOldestMessage(c);e&&(r=e.ID)}return Ie.l(a+` nextReqID:${r} stored message count:`+e.length),{nextReqID:r,storedMessageList:e}}).catch(e=>(d.setMessage(l).setError(e).end(),Ie.w(a+" failed. error:",e),Xs(e)))}getRoamingMessagesHopping(e){const o=this._n+".getRoamingMessagesHopping",{peerAccount:s,time:i=0,count:n,direction:r}=e,a=""+t.CONV_C2C+s,c=`peerAccount:${s} count:${n} time:${i} direction:`+r,l=(Ie.l(o+" "+c),new pi("getC2CRoamingMessagesHopping"));return this.req({proto:Qs.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:n+1,lastMessageTime:i,direction:r}}).then(e=>{const{complete:t,messageList:s=[],lastMessageTime:i}=e.data;Ie.l(o+` ok. complete:${t} count:`+s.length),l.setMessage(c+` complete:${t} length:`+s.length).end(),1!==t&&(1===r?s.pop():s.shift());e=this.get(Ts).onRoamingMessage(s,a,!1),this._modifyMessageList(a,e),e=this._computeResult({complete:t,lastMessageTime:i,resultList:e});return Ks(e)}).catch(e=>(l.setMessage(c).setError(e).end(),Ie.w(o+" failed. error:",e),Xs(e)))}_computeResult(e){const{complete:t=0,lastMessageTime:s,resultList:i=[]}=e,o={messageList:[...i],isCompleted:!1,nextMessageTime:""};return 1===t?o.isCompleted=!0:o.nextMessageTime=s,o}_modifyMessageList(t,s){t=this.get(Ts).getLocalConversation(t);if(t){var i=t.userProfile.nick,o=t.userProfile.avatar,t=this.get(ms).getNickAndAvatarByUserID(this.getMyUserID()),n=t.nick,r=t.avatar;for(let e=s.length-1;0<=e;e--){const t=s[e];"in"===t.flow&&(t.nick!==i&&t.setNickAndAvatar({nick:i}),t.avatar!==o&&t.setNickAndAvatar({avatar:o})),"out"===t.flow&&(t.nick!==n&&t.setNickAndAvatar({nick:n}),t.avatar!==r&&t.setNickAndAvatar({avatar:r}))}}}getRemotePeerReadTime(o){const n=this._n+".getRemotePeerReadTime";if(Re(o))return Ie.w(n+" userIDList is empty!"),Promise.resolve();const r=new pi("getPeerReadTime");return Ie.l(n+" userIDList:"+o),this.req({proto:Qs.GET_C2C_PEER_READ_TIME,data:{userIDList:o}}).then(e=>{var t=e.data["peerReadTimeList"];Ie.l(n+" ok. peerReadTimeList:"+t);let s="";const i=this.get(Ts);for(let e=0;e<o.length;e++)s+=`${o[e]}-${t[e]} `,0<t[e]&&i.recordPeerReadTime("C2C"+o[e],t[e]);r.setMessage(s).end()}).catch(e=>{r.setError(e).end(),Ie.w(n+" failed. error:",e)})}sendReadReceipt(e){const s=e[0].conversationID.replace(t.CONV_C2C,""),i=new pi("sendC2CReadReceipt"),o=(i.setMessage("peerAccount:"+s),this.getMyUserID()),n=e.filter(e=>e.from!==o&&!0===e.needReadReceipt).map(e=>{var{from:e,to:t,sequence:s,random:i,time:o,clientTime:n}=e;return{fromAccount:e,toAccount:t,sequence:s,random:i,time:o,clientTime:n}});if(0===n.length)return Xs({code:Ws.READ_RECEIPT_MSG_LIST_EMPTY});const r=this._n+".sendReadReceipt";return Ie.l(r+`. peerAccount:${s} messageInfoList length:`+n.length),this.req({proto:Qs.SEND_C2C_READ_RECEIPT,data:{peerAccount:s,messageInfoList:n}}).then(e=>(i.end(),Ie.l(r+" ok"),Ks())).catch(e=>(i.setError(e).end(),Ie.w(r+" failed. error:",e),Xs(e)))}getReadReceiptList(e){const t=this._n+".getReadReceiptList",s=this.getMyUserID(),i=e.filter(e=>e.from===s&&!0===e.needReadReceipt);return Ie.l(t+` userID:${s} messageList length:`+i.length),js({messageList:i})}getMessageExtensions(e,t){return Ie.l(this._n+".getMessageExtensions startSequence:"+t),this.req({proto:Qs.GET_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}modifyMessageExtensions(e,t,s=1){return Ie.l(this._n+".modifyMessageExtensions operateType:"+s),this.req({proto:Qs.MODIFY_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),extensionList:t,operateType:s}})}getMessageKey(e){var{clientSequence:e,random:t,time:s}=e;return e+`_${t}_`+s}reset(){Ie.l(this._n+".reset"),this._messageFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0}}class Oi{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){var s=e["conversationID"];let i=!0;this.list.has(s)||this.list.set(s,new Map);var o=this._getUniqueIDOfMessage(e);if(this.list.get(s).has(o)){const e=this.list.get(s).get(o);if(!t||!0===e.isModified)return i=!1}return this.list.get(s).set(o,e),this._setLatestMessageSentByPeer(s,e),this._setLatestMessageSentByMe(s,e),i}unshift(s,i){let o;if(Fe(s)?0<s.length&&(o=s[0].conversationID,this._unshiftMultipleMessages(s,i)):(o=s.conversationID,this._unshiftSingleMessage(s,i)),o){const s=Array.from(this.list.get(o).values()),i=s.length;if(0!==i){for(let e=i-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMessageSentByMe(o,s[e]);break}if(o.startsWith(t.CONV_C2C))for(let e=i-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMessageSentByPeer(o,s[e]);break}}}}_unshiftSingleMessage(e,t){var s=e["conversationID"],i=this._getUniqueIDOfMessage(e);if(!this.list.has(s))return this.list.set(s,new Map),this.list.get(s).set(i,e),void t.push(e);const o=this.list.get(s),n=Array.from(o);o.has(i)||(n.unshift([i,e]),this.list.set(s,new Map(n)),t.push(e))}_unshiftMultipleMessages(t,s){const i=t.length,o=[],e=t[0].conversationID,n=this.list.get(e),r=this.list.has(e)?Array.from(n):[];for(let e=0;e<i;e++){const i=this._getUniqueIDOfMessage(t[e]);n&&n.has(i)||(o.push([i,t[e]]),s.push(t[e]))}this.list.set(e,new Map(o.concat(r)))}remove(e){var t=e["conversationID"],e=this._getUniqueIDOfMessage(e);this.list.has(t)&&this.list.get(t).delete(e)}revoke(e,t,s){if(Ie.d("revoke message",e,t,s),this.list.has(e)){var i=this.list.get(e);for(const[,e]of i)if(e.sequence===t&&($e(s)||e.random===s))return e.isRevoked||(e.isRevoked=!0),e}return null}removeByConversationID(e){var t=this.list.has(e);Ie.l(this._n+`.removeByConversationID conversationID:${e} has:`+t),t&&(this.list.delete(e),this._latestMessageSentByPeerMap.delete(e),this._latestMessageSentByMeMap.delete(e))}findMessage(t){let s=null;for(var[,e]of this.list){var i=[...e.values()],o=i.length;for(let e=0;e<o;e++)if(i[e].ID===t){s=i[e];break}}return s}updateMessageIsPeerReadProperty(e,t){const s=[];if(this.list.has(e)){var i=this.list.get(e);for(const[,e]of i)e.time<=t&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,s.push(e));Ie.l(this._n+`.updateMessageIsPeerReadProperty conversationID:${e} peerReadTime:${t} count:`+s.length)}return s}updateMessageIsModifiedProperty(e){var t=e["conversationID"];if(this.list.has(t)){const s=this._getUniqueIDOfMessage(e),i=this.list.get(t).get(s);i&&(i.isModified=!0)}}hasLocalMessageList(e){return this.list.has(e)}getLocalMessageList(e){return this.hasLocalMessageList(e)?[...this.list.get(e).values()]:[]}hasLocalMessage(e,t){let s=!1;var i=this.getLocalMessageList(e),o=i.length;for(let e=0;e<o;e++)i[e].ID===t&&(s=!0);return s}getLocalMessage(e,t){let s=null;var i=this.getLocalMessageList(e),o=i.length;for(let e=0;e<o;e++)if(i[e].ID===t){s=i[e];break}return s}getLocalLastMessage(e){e=this.getLocalMessageList(e);return e[e.length-1]}getLocalOldestMessage(e){return this.getLocalMessageList(e)[0]}_setLatestMessageSentByPeer(e,s){e.startsWith(t.CONV_C2C)&&"in"===s.flow&&this._latestMessageSentByPeerMap.set(e,s)}_setLatestMessageSentByMe(e,t){"out"===t.flow&&this._latestMessageSentByMeMap.set(e,t)}getLatestMessageSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMessageSentByMe(e){return this._latestMessageSentByMeMap.get(e)}modifyMessageSentByPeer(o){const{conversationID:e,latestNick:n,latestAvatar:r}=o,t=this.list.get(e);if(!Re(t)){var a=Array.from(t.values()),o=a.length;if(0!==o){let t=null,s=0,i=!1;for(let e=o-1;0<=e;e--)"in"===a[e].flow&&((t=a[e]).nick!==n&&(t.setNickAndAvatar({nick:n}),i=!0),t.avatar!==r&&(t.setNickAndAvatar({avatar:r}),i=!0),i&&(s+=1));Ie.l(this._n+`.modifyMessageSentByPeer conversationID:${e} count:`+s)}}}modifyMessageSentByMe(o){const{conversationID:e,latestNick:n,latestAvatar:r}=o,t=this.list.get(e);if(!Re(t)){var a=Array.from(t.values()),o=a.length;if(0!==o){let t=null,s=0,i=!1;for(let e=o-1;0<=e;e--)"out"===a[e].flow&&((t=a[e]).nick!==n&&(t.setNickAndAvatar({nick:n}),i=!0),t.avatar!==r&&(t.setNickAndAvatar({avatar:r}),i=!0),i&&(s+=1));Ie.l(this._n+`.modifyMessageSentByMe conversationID:${e} count:`+s)}}}getTopicConversationIDList(s){return[...this.list.keys()].filter(e=>e.startsWith(""+t.CONV_GROUP+s))}traversal(){if(0!==this.list.size&&-1===Ie.getLevel()){console.group("conversationID-messageCount");for(var[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._n+".onMessageModified",i=this._getUniqueIDOfMessage(t),o=this.list.get(e).has(i);if(Ie.l(s+` conversationID:${e} uniqueID:${i} has:`+o),o){const o=this.list.get(e).get(i),{messageVersion:n,elements:r,cloudCustomData:a,checkResult:c}=t;return Ie.l(s+` localVersion:${o.version} remoteVersion:`+n),o.version<n?(o.version=n,o._elements=JSON.parse(JSON.stringify(r)),o.payload=JSON.parse(JSON.stringify(r[0].content)),o.type=r[0].type,o.cloudCustomData=a,o.isModified=!0,o.hasRiskContent=Et(c),{isUpdated:!0,message:o}):{isUpdated:!1,message:o}}return{isUpdated:!1,message:null}}_getUniqueIDOfMessage(e){var{from:e,to:t,random:s,sequence:i,time:o}=e;return e+`-${t}-${s}-${i}-`+o}reset(){this.list.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear()}}const Pi={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};function Ui(e){this.mixin(e)}Ui.mixin=function(e){const t=e.prototype||e;t._isReady=!1,t.ready=function(e,t=!1){if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},t.triggerReady=function(){this._isReady=!0,setTimeout(()=>{const e=this._readyQueue;this._readyQueue=[],e&&0<e.length&&e.forEach(function(e){e.call(this)},this)},1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};const Gi=["jpg","jpeg","gif","png","bmp","image","webp"],ki=["mp4","quicktime","mov"],Fi=1,$i=2,wi=3,bi=255;class qi{constructor(e){Re(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=[],Re(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(s){let i=!0,e="";if(Re(s))return{valid:!1,tips:"empty options"};if(s.profileCustomField){const i=s.profileCustomField.length;let t=null;for(let e=0;e<i;e++){if(t=s.profileCustomField[e],!Ue(t.key)||-1===t.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!Ue(t.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t)){if("profileCustomField"===t)continue;if(Re(s[t])&&!Ue(s[t])&&!Pe(s[t])){e="key:"+t+", invalid value:"+s[t],i=!1;continue}switch(t){case"nick":Ue(s[t])||(e="nick must be a string",i=!1),500<We(s[t])&&(e=`nick name limited: must less than or equal to 500 bytes, current size: ${We(s[t])} bytes`,i=!1);break;case"gender":Xe(ye,s.gender)||(e="key:gender, invalid value:"+s.gender,i=!1);break;case"birthday":Pe(s.birthday)||(e="birthday must be a number",i=!1);break;case"location":Ue(s.location)||(e="location must be a string",i=!1);break;case"selfSignature":Ue(s.selfSignature)||(e="selfSignature must be a string",i=!1);break;case"allowType":Xe(Se,s.allowType)||(e="key:allowType, invalid value:"+s.allowType,i=!1);break;case"language":Pe(s.language)||(e="language must be a number",i=!1);break;case"avatar":Ue(s.avatar)||(e="avatar must be a string",i=!1);break;case"messageSettings":0!==s.messageSettings&&1!==s.messageSettings&&(e="messageSettings must be 0 or 1",i=!1);break;case"adminForbidType":Xe(De,s.adminForbidType)||(e="key:adminForbidType, invalid value:"+s.adminForbidType,i=!1);break;case"level":Pe(s.level)||(e="level must be a number",i=!1);break;case"role":Pe(s.role)||(e="role must be a number",i=!1);break;default:e="unknown key:"+t+" "+s[t],i=!1}}return{valid:i,tips:e}}}class xi{constructor(e){this.value=e,this.next=null}}class Vi{constructor(e){this.MAX_LENGTH=e,this.pTail=null,this.pNodeToDel=null,this.map=new Map}set(t){var s=new xi(t);if(this.map.size<this.MAX_LENGTH)null===this.pTail?(this.pTail=s,this.pNodeToDel=s):(this.pTail.next=s,this.pTail=s),this.map.set(t,1);else{let e=this.pNodeToDel;this.pNodeToDel=this.pNodeToDel.next,this.map.delete(e.value),e.next=null,e=null,this.pTail.next=s,this.pTail=s,this.map.set(t,1)}}has(e){return this.map.has(e)}delete(e){this.has(e)&&this.map.delete(e)}tail(){return this.pTail}size(){return this.map.size}data(){return Array.from(this.map.keys())}reset(){let e;for(;null!==this.pNodeToDel;)e=this.pNodeToDel,this.pNodeToDel=this.pNodeToDel.next,e.next=null,e=null;this.pTail=null,this.map.clear()}}const Bi=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class Ki{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime="",this.infoSequence="",this.lastInfoTime="",this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:"",lastSequence:"",fromAccount:"",messageForShow:""},this.nextMessageSeq="",this.memberNum="",this.memberCount="",this.maxMemberNum="",this.maxMemberCount="",this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}set memberNum(e){}set maxMemberNum(e){}get memberNum(){return this.memberCount}get maxMemberNum(){return this.maxMemberCount}_initGroup(e){for(const t in e)Bi.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}updateGroup(e){e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);const t=JSON.parse(JSON.stringify(e));t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),$e(t.muteAllMembers)||("On"===t.muteAllMembers?t.muteAllMembers=!0:t.muteAllMembers=!1),t.groupCustomField&&Ze(this.groupCustomField,t.groupCustomField),$e(t.memberNum)||(this.memberCount=t.memberNum),$e(t.maxMemberNum)||(this.maxMemberCount=t.maxMemberNum),$e(t.isSupportTopic)||(this.isSupportTopic=Pe(t.isSupportTopic)?1===t.isSupportTopic:t.isSupportTopic),Ke(this,t,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),Fe(t.members)&&0<t.members.length&&t.members.forEach(e=>{e.userID===this.selfInfo.userID&&Ke(this.selfInfo,e,["sequence"])})}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:i,readedSequence:o,excludedUnreadSequenceList:n}){e={nameCard:e,joinTime:t,role:s,messageRemindType:i,readedSequence:o,excludedUnreadSequenceList:n};Ke(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}const Hi=function(e,t,s){return $e(e)?{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:s&&e.ID||e instanceof Li?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:ft(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:ft(e.type,e.payload,t)}};class Wi{constructor(e,t,s=!1){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=Hi(e.lastMessage,t,s),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=e.messageRemindType,this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this.draftText=e.draftText||"",this._initProfile(e),this.subType=this.groupProfile?this.groupProfile.type:""}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,""):""}_initProfile(s){Object.keys(s).forEach(e=>{switch(e){case"userProfile":this.userProfile=s.userProfile;break;case"groupProfile":this.groupProfile=s.groupProfile}}),$e(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new qi({userID:s.conversationID.replace("C2C","")}):$e(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new Ki({groupID:s.conversationID.replace("GROUP","")}))}updateUnreadCount(e){var{nextUnreadCount:e,isFromGetConversations:s,isUnreadC2CMessage:i}=e;$e(e)||(et(this.subType)?this.unreadCount=0:s&&this.type===t.CONV_GROUP||s&&this.type===t.CONV_TOPIC||i&&this.type===t.CONV_C2C?this.unreadCount=e:this.unreadCount=this.unreadCount+e)}updateLastMessage(e){this.lastMessage=Hi(e)}updateGroupAtInfoList(s){if(!this._isNeedMergeGroupAtInfo(s)){let[...e]=s.groupAtType;-1!==e.indexOf(t.CONV_AT_ME)&&-1!==e.indexOf(t.CONV_AT_ALL)&&(e=[t.CONV_AT_ALL_AT_ME]);s={from:s.from,groupID:s.groupID,topicID:s.topicID,messageSequence:s.sequence,atTypeArray:e,__random:s.__random,__sequence:s.__sequence};this.groupAtInfoList.push(s)}}_isNeedMergeGroupAtInfo(s){const{groupID:e,sequence:i}=s;if(!st({groupID:e}))return!1;let o=!1;return this.groupAtInfoList.forEach(e=>{e.messageSequence===i&&(-1<e.atTypeArray.indexOf(t.CONV_AT_ME)&&-1<s.groupAtType.indexOf(t.CONV_AT_ALL)&&(e.atTypeArray=[t.CONV_AT_ALL_AT_ME]),-1<e.atTypeArray.indexOf(t.CONV_AT_ALL)&&-1<s.groupAtType.indexOf(t.CONV_AT_ME)&&(e.atTypeArray=[t.CONV_AT_ALL_AT_ME],e.__random=s.__random,e.__sequence=s.__sequence),o=!0)}),o}clearGroupAtInfoList(){this.groupAtInfoList.length=0}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!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}setDraftText(e){this.draftText=e}}class Yi{constructor(e){this._convM=e,this._n="MessageRemindHandler"}getC2CMessageRemindType(t){const s=this._n+".getC2CMessageRemindType";return this._convM.req({proto:Qs.GET_C2C_PEER_MUTE_NOTIFICATIONS,data:{toAccount:this._convM.getMyUserID(),userIDList:t}}).then(e=>{Ie.l(s+" ok. userIDList:"+t);e=e.data.muteFlagList;this._convM.onC2CMessageRemindTypeFetched(e)}).catch(e=>{Ie.e(s+" failed. error:",e)})}set(e){return e.groupID?this._setGroupMessageRemindType(e):Fe(e.userIDList)?this._setC2CMessageRemindType(e):void 0}_setGroupMessageRemindType(t){const s=this._n+"._setGroupMessageRemindType",{groupID:e,messageRemindType:i}=t,o=`groupID:${e} messageRemindType:`+i,n=new pi("setMessageRemindType"),r=(n.setMessage(o),this._get(Is));return r?r.modifyGroupMemberInfo({groupID:e,messageRemindType:i,userID:this._convM.getMyUserID()}).then(()=>{n.end(),Ie.l(s+" ok. "+o);var e=this.onGroupMessageRemindTypeUpdated(t);return this._convM.emitTotalUnreadMessageCountUpdate(),Ks(e)}).catch(e=>(n.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e))):Xs({code:Ws.CANNOT_FIND_MODULE})}onGroupMessageRemindTypeUpdated(t){var{groupID:s,messageRemindType:i}=t;Ie.l(this._n+`.onGroupMessageRemindTypeUpdated groupID:${s} messageRemindType:`+i);const o=this._get(Is).getLocalGroupProfile(s);if(o&&(o.selfInfo.messageRemindType=i),it(s)){const t=s,o=It(t),n=this._get(Cs).getLocalTopic(o,t);return n&&(n.updateSelfInfo({messageRemindType:i}),this._convM.emitOuterEvent(e.TOPIC_UPDATED,{groupID:o,topic:n})),{topic:n}}return this._convM.patchMessageRemindType({ID:s,isC2CConversation:!1,messageRemindType:i})&&this._emitConversationUpdate(),{group:o}}_setC2CMessageRemindType(e){const r=this._n+"._setC2CMessageRemindType",{userIDList:s,messageRemindType:a}=e,c=s.slice(0,30);let i=0;a===t.MSG_REMIND_DISCARD?i=1:a===t.MSG_REMIND_ACPT_NOT_NOTE&&(i=2);const l=`userIDList:${c} messageRemindType:`+a,d=new pi("setMessageRemindType");return d.setMessage(l),this._convM.req({proto:Qs.SET_C2C_PEER_MUTE_NOTIFICATIONS,data:{userIDList:c,muteFlag:i}}).then(e=>{d.end();const t=e.data["errorList"],s=[],i=[],o=(Fe(t)&&t.forEach(e=>{s.push(e.userID),i.push({userID:e.userID,code:e.errorCode})}),c.filter(e=>-1===s.indexOf(e)));Ie.l(r+` ok. ${l} successUserIDList:${o} failureUserIDList:`+JSON.stringify(i));let n=0;return o.forEach(e=>{this._convM.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:a})&&(n+=1)}),1<=n&&this._emitConversationUpdate(),c.length=s.length=0,this._convM.emitTotalUnreadMessageCountUpdate(),js({successUserIDList:o.map(e=>({userID:e})),failureUserIDList:i})}).catch(e=>(d.setError(e).end(),Ie.e(r+" failed. error:",e),Xs(e)))}_get(e){return this._convM.get(e)}_emitConversationUpdate(){this._convM.emitConversationUpdate(!0,!1)}reset(){Ie.l(this._n+".reset")}}class zi{constructor(e){this._convM=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=Ot}setConvCustomData(e){const s=this._n+".setConvCustomData",{conversationIDList:i,customData:n}=e,r=(Ie.l(s+" options:",e),new pi("setConvCustomData")),o=(r.setMessage(JSON.stringify(e)),{fromAccount:this._getMyUserID(),itemList:[]}),a=[],c=[];return i.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(c,e),!0;if(!nt(e)&&!ot(e))return this._onConversationIDInvalid(c,e),!0;const s={operationType:2,contactItem:void 0,customMark:n};nt(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:ot(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),o.itemList.push(s)}),c.length===i.length?js({successConversationIDList:a,failureConversationIDList:c}):this._convM.req({proto:Qs.SET_CONV_CUSTOM_DATA,data:o}).then(e=>{r.end(),Ie.l(s+" ok");const o=e.data["resultItem"];if(Fe(o)){let t,s,i=!1;o.forEach(e=>{t=this._concatConversationID(e.contactItem),0===e.resultCode?(a.push(t),(s=this._getLocalConversation(t))&&s.customData!==n&&(s.customData=n,i=!0)):c.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&this._emitConversationUpdate()}return Ks({successConversationIDList:a,failureConversationIDList:c})}).catch(e=>(r.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}markConversation(e){if(!this._convM.canIUse(I.CONV_MARK))return this._convM.cannotUseCommercialAbility("markConversation");const s=this._n+".markConversation",{conversationIDList:i,markType:n,enableMark:r}=e,a=(Ie.l(s+" options:",e),new pi("markConversation"));a.setMessage(JSON.stringify(e));let o=void 0,c=void 0;e=this._getFlagBit(n);!0===r?c=[e]:o=[e];const u={fromAccount:this._getMyUserID(),itemList:[]},l=[],d=[];return i.forEach(e=>{if(!this._hasLocalConversation(e))return this._onConversationNotFound(d,e),!0;if(!nt(e)&&!ot(e))return this._onConversationIDInvalid(d,e),!0;const s={operationType:1,contactItem:void 0,clearMark:o,setMark:c};nt(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:ot(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),u.itemList.push(s)}),d.length===i.length?js({successConversationIDList:l,failureConversationIDList:d}):this._convM.req({proto:Qs.MARK_CONV,data:u}).then(e=>{a.end(),Ie.l(s+" ok");const o=e.data["resultItem"];if(Fe(o)){let t,s,i=!1;o.forEach(e=>{if(t=this._concatConversationID(e.contactItem),0===e.resultCode){if(l.push(t),s=this._getLocalConversation(t)){const t=s.markList.indexOf(n);!0===r?-1===t&&(s.markList.push(n),i=!0):-1!==t&&(s.markList.splice(t,1),i=!0)}}else d.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&this._emitConversationUpdate()}return Ks({successConversationIDList:l,failureConversationIDList:d})}).catch(e=>(a.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}getLocalConvGroupList(){return Ie.l(this._n+".getLocalConvGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===Gt?this.getRemoteConvGroupList().then(()=>Ks([...this._convGroupMap.values()])):js([...this._convGroupMap.values()])}getRemoteConvGroupList(){const n=this._n+".getRemoteConvGroupList";return this._pagingStatus=Pt,this._convM.req({proto:Qs.GET_CONV_GRP_LIST,data:{fromAccount:this._getMyUserID(),startIndex:this._startIndex,startTime:he()}}).then(e=>{const{completeFlag:t,contactItem:s,nextStartIndex:i=0,groupItem:o}=e.data;if(this._startIndex=i,Ie.l(n+` completeFlag:${t} nextStartIndex:`+i),Fe(o)&&o.forEach(e=>{var{convGroupID:e,groupName:t}=e;this._convGroupMap.set(e,t)}),Fe(s)){let o,n;s.forEach(e=>{const{standardMark:t,customData:s,convGroupIDList:i}=e;if(o=this._concatConversationID(e),(n=this._getLocalConversation(o))&&(n.markList=Ct(t),n.customData=s||"",Fe(i))){const o=[];i.forEach(e=>{this._convGroupMap.has(e)&&o.push(this._convGroupMap.get(e))}),n.conversationGroupList=[...o],o.length=0}})}if(0===t)return this.getRemoteConvGroupList();1===t&&(this._pagingStatus=Ut,this._emitConversationUpdate(),this._emitConvGroupListUpdate())}).catch(e=>{this._pagingStatus=Gt,Ie.w(n+" failed. error:",e)})}createConvGroup(e){var s="createConversationGroup";if(!this._convM.canIUse(I.CONV_GROUP))return this._convM.cannotUseCommercialAbility(s);const i=this._n+"."+s,n=(Ie.l(i+" options:",e),new pi(s)),{groupName:r,conversationIDList:o}=(n.setMessage(JSON.stringify(e)),e),a={fromAccount:this._getMyUserID(),itemList:[{groupName:r,contactItem:[]}]},c=[],l=[];return o.forEach(e=>this._hasLocalConversation(e)?nt(e)||ot(e)?void(nt(e)?a.itemList[0].contactItem.push({type:1,toAccount:e.replace(t.CONV_C2C,"")}):ot(e)&&a.itemList[0].contactItem.push({type:2,groupID:e.replace(t.CONV_GROUP,"")})):(this._onConversationIDInvalid(l,e),!0):(this._onConversationNotFound(l,e),!0)),l.length===o.length?js({successConversationIDList:c,failureConversationIDList:l}):this._convM.req({proto:Qs.CREATE_CONV_GRP,data:a}).then(e=>{n.end(),Ie.l(i+" ok");const t=e.data["groupResultItem"],{groupItem:s,resultItem:o}=t[0];if(ke(s)&&(this._convGroupMap.set(s.convGroupID,s.groupName),this._emitConvGroupListUpdate()),Fe(o)){let t,s,i=!1;o.forEach(e=>{t=this._concatConversationID(e.contactItem),0===e.resultCode?(c.push(t),(s=this._getLocalConversation(t))&&-1===s.conversationGroupList.indexOf(r)&&(s.conversationGroupList.push(r),i=!0)):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&(this._emitConversationUpdate(),this._emitConvGroupListUpdate())}return Ks({successConversationIDList:c,failureConversationIDList:l})}).catch(e=>(n.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}deleteConvGroup(t){var e="deleteConversationGroup";if(!this._convM.canIUse(I.CONV_GROUP))return this._convM.cannotUseCommercialAbility(e);const i=this._n+"."+e,o=(Ie.l(i+" groupName:"+t),new pi(e));return o.setMessage(t),this._convM.req({proto:Qs.DEL_CONV_GRP,data:{fromAccount:this._getMyUserID(),groupName:[t]}}).then(e=>{o.end(),Ie.l(i+" ok");const s=e.data["groupItem"];if(Fe(s)){let t=!1;s.forEach(e=>{this._convGroupMap.has(e.convGroupID)&&(this._convGroupMap.delete(e.convGroupID),t=!0)}),!0===t&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList([t])}).catch(e=>(o.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}renameConvGroup(e){var t="renameConversationGroup";if(!this._convM.canIUse(I.CONV_GROUP))return this._convM.cannotUseCommercialAbility(t);const n=this._n+"."+t,r=(Ie.l(n+" options:",e),new pi(t)),{oldName:a,newName:c}=(r.setMessage(JSON.stringify(e)),e);return this._convM.req({proto:Qs.RENAME_CONV_GRP,data:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:a,newName:c}}}).then(e=>{r.end(),Ie.l(n+" ok");e=e.data.updateGroupResult,e=e.convGroupID;this._convGroupMap.set(e,c),this._emitConvGroupListUpdate();const t=this._convM.getLocalConversationList();let s,i,o=!1;t.forEach(e=>{s=e.conversationGroupList,-1!==(i=s.indexOf(a))&&(s.splice(i,1,c),o=!0)}),!0===o&&this._emitConversationUpdate()}).catch(e=>(r.setError(e).end(),Ie.e(n+" failed. error:",e),Xs(e)))}addConvsToGroup(e){var s="addConversationsToGroup";if(!this._convM.canIUse(I.CONV_GROUP))return this._convM.cannotUseCommercialAbility(s);const i=this._n+"."+s,n=(Ie.l(i+" options:",e),new pi(s)),{conversationIDList:o,groupName:r}=(n.setMessage(JSON.stringify(e)),e),a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:r,updateItem:[]}},c=[],l=[];return o.forEach(e=>this._hasLocalConversation(e)?nt(e)||ot(e)?void(nt(e)?a.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):ot(e)&&a.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(l,e),!0):(this._onConversationNotFound(l,e),!0)),l.length===o.length?js({successConversationIDList:c,failureConversationIDList:l}):this._convM.req({proto:Qs.ADD_CONV_TO_GRP,data:a}).then(e=>{n.end(),Ie.l(i+" ok");const o=e.data.updateGroupResult["contactResultItem"];if(Fe(o)){let t,s,i=!1;o.forEach(e=>{t=this._concatConversationID(e.contactItem),0===e.resultCode?(s=this._getLocalConversation(t))&&-1===s.conversationGroupList.indexOf(r)&&(s.conversationGroupList.push(r),c.push(t),i=!0):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(r))}return Ks({successConversationIDList:c,failureConversationIDList:l})}).catch(e=>(n.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}deleteConvsFromGroup(e){var s="deleteConversationsFromGroup";if(!this._convM.canIUse(I.CONV_GROUP))return this._convM.cannotUseCommercialAbility(s);const i=this._n+"."+s,n=(Ie.l(i+" options:",e),new pi(s)),{conversationIDList:o,groupName:r}=(n.setMessage(JSON.stringify(e)),e),a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:r,updateItem:[]}},c=[],l=[];return o.forEach(e=>this._hasLocalConversation(e)?nt(e)||ot(e)?void(nt(e)?a.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):ot(e)&&a.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConversationIDInvalid(l,e),!0):(this._onConversationNotFound(l,e),!0)),l.length===o.length?js({successConversationIDList:c,failureConversationIDList:l}):this._convM.req({proto:Qs.DEL_CONV_FROM_GRP,data:a}).then(e=>{n.end(),Ie.l(i+" ok");const o=e.data.updateGroupResult["contactResultItem"];if(Fe(o)){let t,s,i=!1;o.forEach(e=>{if(t=this._concatConversationID(e.contactItem),0===e.resultCode){if(s=this._getLocalConversation(t)){const e=s.conversationGroupList.indexOf(r);-1!==e&&(s.conversationGroupList.splice(e,1),c.push(t),i=!0)}}else l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(r))}return Ks({successConversationIDList:c,failureConversationIDList:l})}).catch(e=>(n.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}onConvMarkUpdated(e){if(!Re(e)){let o,n,r=(Ie.d(this._n+".onConvMarkUpdated markItemList:",e),!1);e.forEach(e=>{var{recentContactItem:e,optType:t,standardMark:s,customMark:i}=e;o=this._concatConversationID(e),(n=this._getLocalConversation(o))&&(1===t?r=this._diffStandardMark(n,s):2===t?r=this._diffCustomMark(n,i):3===t&&(r=this._diffStandardMark(n,s)||this._diffCustomMark(n,i)))}),!0===r&&this._emitConversationUpdate()}}_diffStandardMark(e,t){t=Ct(t);let s=!1;return!0!==function(s,i){if(s===i)return!0;if(!s||!i)return!1;if(s.length!==i.length)return!1;for(let e=0,t=s.length;e<t;e++)if(s[e]!==i[e])return!1;return!0}(e.markList,t)&&(e.markList=t,s=!0),s}_diffCustomMark(e,t){let s=!1;return e.customData!==t&&void 0!==t&&(e.customData=t,s=!0),s}onConvGroupCreated(e){Ie.d(this._n+".onConvGroupCreated resultList:",e);let n=!1,s=!1;Fe(e)&&(e.forEach(e=>{const{groupID:t,groupName:i}=e.msgGroupItem,o=(this._convGroupMap.get(t)!==i&&(this._convGroupMap.set(t,i),s=!0),e.msgRecentContactItem);if(Fe(o)){let t,s;o.forEach(e=>{t=this._concatConversationID(e),(s=this._getLocalConversation(t))&&-1===s.conversationGroupList.indexOf(i)&&(s.conversationGroupList.push(i),n=!0)})}}),!0===n&&this._emitConversationUpdate(),!0===s&&this._emitConvGroupListUpdate())}onConvGroupDeleted(e){Ie.d(this._n+".onConvGroupDeleted groupItemList:",e);const i=[];if(Fe(e)){let s=!1;e.forEach(e=>{var{groupID:e,groupName:t}=e;this._convGroupMap.has(e)&&(this._convGroupMap.delete(e),s=!0,i.push(t))}),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(i)}_eraseFromConversationGroupList(t){Re(t)||(this._convM.getLocalConversationList().forEach(e=>{e.conversationGroupList=e.conversationGroupList.filter(e=>!t.includes(e))}),this._emitConversationUpdate())}onConvGroupNameUpdated(e){Ie.d(this._n+".onConvGroupNameUpdated options:",e);const{groupID:o,groupName:n,oldGroupName:r}=e;if(this._convGroupMap.get(o)!==n){this._convGroupMap.set(o,n),this._emitConvGroupListUpdate();const a=this._convM.getLocalConversationList();let t,s,i=!1;a.forEach(e=>{t=e.conversationGroupList,-1!==(s=t.indexOf(r))&&(t.splice(s,1,n),i=!0)}),!0===i&&this._emitConversationUpdate()}}onConvInGroupUpdated(e){Ie.d(this._n+".onConvInGroupUpdated options:",e);const{oldGroupName:r,recentContactUpdateGroupItem:t}=e;if(Fe(t)){let s,i,o,n=!1;t.forEach(e=>{var{contactOptType:e,recentContactItem:t}=e;s=this._concatConversationID(t),(i=this._getLocalConversation(s))&&(o=i.conversationGroupList.indexOf(r),1===e?-1===o&&(i.conversationGroupList.push(r),n=!0):2===e&&-1!==o&&(i.conversationGroupList.splice(o,1),n=!0))}),!0===n&&(this._emitConversationUpdate(),this._emitConvInGroupUpdate(r))}}onConvAddedToOrDeletedFromGroup(e){Ie.d(this._n+".onConvAddedToOrDeletedFromGroup options:",e);const{msgRecentContactItem:t,msgRecentContactUpdateContactItem:o}=e,s=this._concatConversationID(t),n=this._getLocalConversation(s);if(n&&Fe(o)){let s,i=!1;o.forEach(e=>{var{groupOptType:e,recentContactGroupItem:t}=e,t=t["groupName"];s=n.conversationGroupList.indexOf(t),1===e?-1===s&&(n.conversationGroupList.push(t),i=!0):2===e&&-1!==s&&(n.conversationGroupList.splice(s,1),i=!0),!0===i&&this._emitConvInGroupUpdate(t)}),!0===i&&this._emitConversationUpdate()}}onConvGroupListSynced(e){Fe(e)&&0!==e.length&&(Ie.l(this._n+".onConvGroupListSynced groupItemList:",e),e.forEach(e=>{this._convGroupMap.set(e.convGroupID,e.groupName)}))}getConvGroupListByID(e){if(!Re(e)){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:Ws.CONV_NOT_FOUND,message:this._convM.getErrorMessage(Ws.CONV_NOT_FOUND)})}_onConversationIDInvalid(e,t){e.push({conversationID:t,code:Ws.INVALID_CONV_ID,message:this._convM.getErrorMessage(Ws.INVALID_CONV_ID)})}_getFlagBit(e){var t=e.toString(2),s=t.length;for(let e=s-1;0<=e;e--)if("1"===t[e])return s-e-1}_concatConversationID(e){var{type:e,to:s,groupID:i,userID:o}=e;let n;return 1===e?$e(o)?$e(s)||(n=""+t.CONV_C2C+s):n=""+t.CONV_C2C+o:2===e&&(n=""+t.CONV_GROUP+i),n}_getMyUserID(){return this._convM.getMyUserID()}_insertConversationGroup(e,t){var s=this._getLocalConversation(e);if(s){const e=s.conversationGroupList;-1===e.indexOf(t)&&e.push(t)}}_getLocalConversation(e){return this._convM.getLocalConversation(e)}_hasLocalConversation(e){return this._convM.hasLocalConversation(e)}_emitConversationUpdate(){this._convM.emitConversationUpdate(!0,!1)}_emitConvGroupListUpdate(){this._convM.emitOuterEvent(e.CONVERSATION_GROUP_LIST_UPDATED,[...this._convGroupMap.values()])}_emitConvInGroupUpdate(t){const s={groupName:t,conversationList:[]},i=this._convM.getLocalConversationList();s.conversationList=i.filter(e=>e.conversationGroupList.includes(t)),this._convM.emitOuterEvent(e.CONVERSATION_IN_GROUP_UPDATED,s)}reset(){Ie.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=Ot}}class ji extends Js{constructor(e){super(e),this._n="ConversationModule",Ui.mixin(this),this._messageListHandler=new Oi,this._messageRemindHandler=new Yi(this),this._convGroupHandler=new zi(this),this.singlyLinkedList=new Vi(100),this._pagingStatus=Ot,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(Pi.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Pi.PROFILE_UPDATED,this._onProfileUpdated,this)}onCheckTimer(e){e%60==0&&this._messageListHandler.traversal()}_init(){Ie.l(this._n+"._init");const t=this.get(Ds).getItem("conversationMap"),s=this.isIntl(),i=this.isUsingChatCore();if(t){var o=t.length;for(let e=0;e<o;e++){var n=t[e];if(n){if(this._isNonExistentAccount(n.conversationID))continue;if(n.groupProfile){const t=n.groupProfile.type;if(et(t))continue}}this._conversationMap.set(n.conversationID,new Wi(t[e],s,i))}this.emitConversationUpdate(!0,!1)}this.ready(()=>{0<this._tmpGroupList.length&&(this.updateConversationGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)}),this.syncConversationList()}_isNonExistentAccount(e){let s;return"@TLS#ERROR"===(s=e.startsWith(t.CONV_C2C)?e.replace(t.CONV_C2C,""):s)||"@TLS#NOT_FOUND"===s}onMessageSent(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}onNewMessage(e){this._onSendOrReceiveMessage(e)}_onSendOrReceiveMessage(e){const{conversationOptionsList:s,isInstantMessage:i=!0,isUnreadC2CMessage:o=!1,updateUnreadCount:n=!0,isSyncingEnded:r=!1}=e;this._isReady?0!==s.length?(!0===i&&this._checkNewConversation(s),this._updateLocalConversationList({conversationOptionsList:s,isInstantMessage:i,isUnreadC2CMessage:o,isFromGetConversations:!1,updateUnreadCount:n}),i||(this._convIDFromUnreadDBMap=new Map([...this._convIDFromUnreadDBMap,...s.map(e=>[e.conversationID,1])]),this._diffAndDeleteConversation(),r&&this.emitInnerEvent(Pi.C2C_UNREAD_HANDLE_COMPLETED)),0<s.filter(e=>e.type===t.CONV_TOPIC).length||this.emitConversationUpdate()):r&&this.emitInnerEvent(Pi.C2C_UNREAD_HANDLE_COMPLETED):this.ready(()=>{this._onSendOrReceiveMessage(e)})}updateConversationGroupProfile(e){if(!Fe(e)||0!==e.length)if(0!==this._conversationMap.size){let i=!1;e.forEach(e=>{var t="GROUP"+e.groupID;if(this._conversationMap.has(t)){i=!0;const s=this._conversationMap.get(t);s.groupProfile=JSON.parse(JSON.stringify(e)),s.lastMessage.lastSequence<e.nextMessageSeq&&(s.lastMessage.lastSequence=e.nextMessageSeq-1),s.subType||(s.subType=e.type)}}),i&&this.emitConversationUpdate(!0,!1)}else this._tmpGroupList=e}_updateConversationUserProfile({data:e}){e.forEach(e=>{var t="C2C"+e.userID;this._conversationMap.has(t)&&(this._conversationMap.get(t).userProfile=e)}),this.emitConversationUpdate(!0,!1)}onMessageRevoked(e){if(0!==e.length){let s=null,i=!1;const o=[];e.forEach(e=>{(s=this._conversationMap.get(e.conversationID))&&(s.reduceUnreadCount()&&(i=s.type!==t.CONV_TOPIC),s.type===t.CONV_TOPIC?o.push(e):s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))}),this.get(Cs).onMessageRevoked(o),i&&this.emitConversationUpdate(!0,!1)}}updateRevokerInfo(o){const t=new Set;for(let e=0;e<o.length;e++){const s=o[e]["revoker"];t.add(s)}const s=[...t],e=this.get(ms);return new Promise(i=>{e.getUserProfile({userIDList:s}).then(e=>{e=e.data;if(!Fe(e)||0===e.length)return i(o);const s={};for(const{userID:o,nick:i,avatar:t}of e)s[o]={nick:i,avatar:t};o.forEach(e=>{var t=e["revoker"];s[t]&&(e.revokerInfo.nick=s[t].nick||"",e.revokerInfo.avatar=s[t].avatar||"")}),i(o)}).catch(()=>{i(o)})})}isLastMessageRevoked(e){let s=!1;const{conversationID:i,sequence:o,time:n}=e,r=this._conversationMap.get(i);return r&&(s=r.type===t.CONV_TOPIC?this.get(Cs).isLastMessageRevoked({topicID:i.replace(t.CONV_GROUP,""),sequence:o}):r.isLastMessageRevoked({sequence:o,time:n})),Ie.l(`${this._n}.isLastMessageRevoked options:${JSON.stringify(e)} ret:`+s),s}onMessageDeleted(e){if(0!==e.length){let s=null;e.forEach(e=>{(s=this._messageListHandler.getLocalMessage(e.conversationID,e.ID))&&(s.isDeleted=!0),e!==s&&(e.isDeleted=!0)});const o=e[0].conversationID,n=this._messageListHandler.getLocalMessageList(o);let i={};for(let e=n.length-1;0<=e;e--)if(!n[e].isDeleted){i=n[e];break}const r=this._conversationMap.get(o);if(r){let e=!1;r.lastMessage.lastSequence===i.sequence&&r.lastMessage.lastTime===i.time||(Re(i)&&(i=void 0),r.updateLastMessage(i),r.type!==t.CONV_TOPIC&&(e=!0),Ie.l(`${this._n}.onMessageDeleted. update conversationID:${o} with lastMessage:`,r.lastMessage)),o.startsWith(t.CONV_C2C)&&this.updateUnreadCount(o),e&&this.emitConversationUpdate(!0,!1)}}}onMessageModified(s){var i=this._n+".onMessageModified",{conversationType:o,from:n,to:r,time:_,sequence:p,elements:a,cloudCustomData:h,messageVersion:c}=s;let l=""+o+r;r===this.getMyUserID()&&o===t.CONV_C2C&&(l=""+o+n);var{isUpdated:o,message:d}=this._messageListHandler.onMessageModified(l,s),u=(!0===o&&this.emitOuterEvent(e.MESSAGE_MODIFIED,[d]),this._isTopicConversation(l));if(null===d?Ie.l(i+` message is null! options:${JSON.stringify(s)}}`):Ie.l(i+` isUpdated:${o} isTopicMessage:${u} from:${n} to:${r} sequence:${d.sequence} time:`+d.time),u)this.get(Cs).onMessageModified(s);else{const e=this._conversationMap.get(l);if(e){const t=e.lastMessage;t&&t.lastTime===_&&t.lastSequence===p&&t.version!==c&&(Ie.l(i+` conversationID:${l} lastMessage updated`),t.type=a[0].type,t.payload=a[0].content,t.messageForShow=ft(t.type,t.payload,this.isIntl()),t.cloudCustomData=h,t.version=c,this.emitConversationUpdate(!0,!1))}}return d}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)}),Ie.d(this._n+".onNewGroupAtTips isReady:"+this._isReady,this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}_handleGroupAtTipsList(){if(0!==this._tmpGroupAtTipsList.length){let r=!1;this._tmpGroupAtTipsList.forEach(e=>{const{groupID:s,from:i,topicID:o,sync:n=!1}=e;if(i!==this.getMyUserID())if($e(o)){const i=this._conversationMap.get(""+t.CONV_GROUP+s);i&&(i.updateGroupAtInfoList(e),r=!0)}else{const r=this._conversationMap.get(""+t.CONV_GROUP+o);if(r){r.updateGroupAtInfoList(e);const t=this.get(Cs),s=r["groupAtInfoList"];t.onConversationProxy({topicID:o,groupAtInfoList:s})}Re(r)&&n&&(this.updateTopicConversation([{conversationID:""+t.CONV_GROUP+o,type:t.CONV_TOPIC}]),this._conversationMap.get(""+t.CONV_GROUP+o).updateGroupAtInfoList(e))}}),r&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}_checkNewConversation(e){let s=[],i=[];e.forEach(e=>{this._conversationMap.has(e.conversationID)||(e.type===t.CONV_C2C?s.push(e.conversationID.replace(t.CONV_C2C,"")):e.type===t.CONV_GROUP&&i.push(e.conversationID.replace(t.CONV_GROUP,"")))}),0<s.length&&(this._onNewC2CConversation(s),s=null),0<i.length&&(this._onNewGroupConversation(i),i=null)}_onNewC2CConversation(e){this.get(Ms).getRemotePeerReadTime(e),this._messageRemindHandler.getC2CMessageRemindType(e)}_onNewGroupConversation(e){const t=this.get(Is);t&&t.getMessageRemindType(e)}_setStorageConversationList(e=!1){var s=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.get(Ds).setItem("conversationMap",s,e)}emitConversationUpdate(t=!0,s=!0){var i=this.getLocalConversationList();if(s){const e=this.get(Is);e&&e.updateGroupLastMessage(i)}t&&(this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED),this.emitTotalUnreadMessageCountUpdate())}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(e=!0){const i=new pi("syncConversationList");return this._pagingStatus===Ot&&this._conversationMap.clear(),this._pagingGetConversationList(e).then(e=>{var t=function(e){if(Fe(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}}(this._pagingGetCostList),s=function(e){if(Fe(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}}(this._pagingGetCostList),s=(this._pagingGetCostList.length=0,this._pagingStatus=Ut,this._diffAndDeleteConversation(),this.emitConversationUpdate(!0,!1),this._setStorageConversationList(),this._handleC2CPeerReadTime(),this.emitInnerEvent(Pi.CONV_SYNC_COMPLETED),`count:${this._conversationMap.size} sum:${s} avg:`+t);return Ie.l(this._n+".syncConversationList. "+s),i.setMessage(s).end(),e}).catch(e=>(this._pagingStatus=Gt,i.setMessage(this._pagingTimeStamp).setError(e).end(),Xs(e)))}_diffAndDeleteConversation(){if(this._isSyncCompleted()){let s=[];this._conversationMap.forEach((e,t)=>{!this._pagingConvIDMap.has(t)&&this._convIDFromUnreadDBMap.has(t)&&(this._conversationMap.delete(t),s.push(t))}),Ie.l(this._n+"._diffAndDeleteConversation list:"+s),s=null}}_pagingGetConversationList(e=!0){const a=this._n+"._pagingGetConversationList",c=(Ie.l(a+` incrementalPullFlag:${e} timeStamp:${this._pagingTimeStamp} startIndex:${this._pagingStartIndex} pinnedTimeStamp:${this._pagingPinnedTimeStamp} pinnedStartIndex:`+this._pagingPinnedStartIndex),Date.now());return this._pagingStatus=Pt,this.req({proto:Qs.PAGING_GET_CONV_LIST,data:{fromAccount:this.getMyUserID(),timeStamp:e?this._pagingTimeStamp:0,startIndex:e?this._pagingStartIndex:0,pinnedTimeStamp:e?this._pagingPinnedTimeStamp:0,pinnedStartIndex:e?this._pagingPinnedStartIndex:0,orderType:1}}).then(e=>{var{completeFlag:e,conversations:t=[],timeStamp:s,startIndex:i,pinnedTimeStamp:o,pinnedStartIndex:n,groupItem:r}=e.data;if(this._pagingGetCostList.push(St(c,!1)),Ie.l(a+` ok. completeFlag:${e} count:${t.length} cost:`+St(c)),this._convGroupHandler.onConvGroupListSynced(r),0<t.length){const e=this._getConversationOptions(t);this._pagingConvIDMap=new Map([...this._pagingConvIDMap,...e.map(e=>[e.conversationID,1])]),this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0}),this.isLoggedIn()&&this.emitConversationUpdate()}if(!this._isReady){if(!this.isLoggedIn())return js();this.triggerReady()}return this._pagingTimeStamp=s,this._pagingStartIndex=i,this._pagingPinnedTimeStamp=o,this._pagingPinnedStartIndex=n,1!==e?this._pagingGetConversationList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),js())}).catch(e=>{throw this.isLoggedIn()&&(this._isReady||(Ie.w(a+" failed. error:",e),this.triggerReady())),e})}_updateLocalConversationList(e){var t=e["isFromGetConversations"],s=Date.now(),e=this._getTmpConversationListMapping(e);this._conversationMap=new Map(this._sortConversationList([...e.toBeUpdatedConversationList,...this._conversationMap])),t||this._updateUserOrGroupProfile(e.newConversationList),Ie.l(this._n+"._updateLocalConversationList cost:"+St(s))}_getTmpConversationListMapping(i){const{conversationOptionsList:o,isFromGetConversations:n,isInstantMessage:r,isUnreadC2CMessage:p=!1,updateUnreadCount:h}=i,a=[],c=[],l=this.get(Is),d=this.get(fs),u=this.isIntl(),g=this.isUsingChatCore();for(let e=0,s=o.length;e<s;e++){const i=new Wi(o[e],u,g),_=i["conversationID"];if(!this._isNonExistentAccount(_))if(this._conversationMap.has(_)){const c=this._conversationMap.get(_),l=["unreadCount","allowType","adminForbidType","payload"],d=(!1===r?l.push("lastMessage"):l.push("isPinned"),o[e].lastMessage),u=!$e(d);u||o[e].type===t.CONV_TOPIC||this._onLastMessageNotExist(o[e]),$e(r)&&u&&null===c.lastMessage.payload&&(c.lastMessage.payload=d.payload),Re(c.lastMessage.revoker)||(c.lastMessage.revoker=null),Ke(c,i,l,[null,void 0,"",0,NaN]),!0===h&&c.updateUnreadCount({nextUnreadCount:i.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:p}),r&&u&&(d.payload&&(c.lastMessage.payload=d.payload),c.type===t.CONV_GROUP&&(c.lastMessage.nameCard=d.nameCard,c.lastMessage.nick=d.nick)),u&&c.lastMessage.cloudCustomData!==d.cloudCustomData&&(c.lastMessage.cloudCustomData=d.cloudCustomData||""),this._conversationMap.delete(_),a.push([_,c])}else{if(i.type===t.CONV_GROUP&&l){const t=i.groupProfile["groupID"],o=l.getLocalGroupProfile(t);o&&(i.groupProfile=o,!0===h&&i.updateUnreadCount({nextUnreadCount:0}))}else if(i.type===t.CONV_C2C){const o=_.replace(t.CONV_C2C,"");d&&d.isMyFriend(o)&&(i.remark=d.getFriendRemark(o))}c.push(i),a.push([_,i])}}const _=this.get(Cs),s=a.length;for(let e=0;e<s;e++)if(a[e][1].type===t.CONV_TOPIC){const{conversationID:i,unreadCount:o,groupAtInfoList:n}=a[e][1];_.onConversationProxy({topicID:i.replace(t.CONV_GROUP,""),unreadCount:o,groupAtInfoList:Re(n)?void 0:n})}return{toBeUpdatedConversationList:a,newConversationList:c}}_onLastMessageNotExist(e){new pi("lastMessageNotExist").setMessage(JSON.stringify(e)).end()}_sortConversationList(e){const t=[],s=[],i=[],o=[];return e.forEach(e=>{(!0===e[1].isPinned?Re(e[1].lastMessage.lastTime)?s:t:Re(e[1].lastMessage.lastTime)?o:i).push(e)}),t.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime).concat(s).concat(i.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(o)}_sortConversationListAndEmitEvent(){this._conversationMap=new Map(this._sortConversationList([...this._conversationMap])),this.emitConversationUpdate(!0,!1)}_updateUserOrGroupProfile(e){if(0!==e.length){const s=[],i=[],o=this.get(ms),n=this.get(Is);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):i.push(t)}}),Ie.l(`${this._n}._updateUserOrGroupProfile c2cUserIDList:${s} groupIDList:`+i),0<s.length&&o.getUserProfile({userIDList:s}).then(({data:e})=>{Fe(e)?e.forEach(e=>{this._doUpdateUserProfile("C2C"+e.userID,e)}):this._doUpdateUserProfile("C2C"+e.userID,e)}),0<i.length&&n.getGroupProfileAdvance({groupIDList:i,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then(({data:{successGroupList:e}})=>{e.forEach(e=>{var t="GROUP"+e.groupID;if(this._conversationMap.has(t)){const s=this._conversationMap.get(t);Ke(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 s=[],t=e.filter(({type:e,userID:t})=>1===e&&!this._isNonExistentAccount(t)||2===e),i=this.getMyUserID(),o=t.map(e=>{var t;return $e(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type?(t={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar},s.push(t),{conversationID:"C2C"+e.userID,type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,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===i&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},userProfile:new qi(t),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Ct(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:this._transMessageRemindType(e.messageRemindType)}):{conversationID:"GROUP"+e.groupID,type:"GROUP",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount,...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 Ki({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq}),unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Ct(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:this._transMessageRemindType(e.messageRemindType)}});return 0<s.length&&this.get(ms).onConversationsProfileUpdated(s),o}_transMessageRemindType(e){let s="";return 0===e?s=t.MSG_REMIND_ACPT_AND_NOTE:1===e?s=t.MSG_REMIND_DISCARD:2===e&&(s=t.MSG_REMIND_ACPT_NOT_NOTE),s}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_patchTypeAndPayload(e){const{event:s,elements:i=[],groupTips:o={}}=e.lastMsg;if($e(s)||Re(o))return{type:i[0]?i[0].type:null,payload:i[0]?this._amendLayersOverLimitProperty(i[0].content):null};{let e=new Li(o);e.setElement({type:t.MSG_GRP_TIP,content:{...o.elements,groupProfile:o.groupProfile}});const s=JSON.parse(JSON.stringify(e.payload));return e=null,{type:t.MSG_GRP_TIP,payload:s}}}_amendLayersOverLimitProperty(e){var t=e["layersOverLimit"];return 0===t?e.layersOverLimit=!1:1===t&&(e.layersOverLimit=!0),e}getLocalMessageList(e){return this._messageListHandler.getLocalMessageList(e)}deleteLocalMessage(e){e instanceof Li&&this._messageListHandler.remove(e)}onConversationDeleted(e){Fe(e)&&(e=e.map(e=>{var{type:e,userID:s,groupID:i}=e;return 1===e?""+t.CONV_C2C+s:2===e?""+t.CONV_GROUP+i:void 0}),Ie.l(this._n+".onConversationDeleted conversationIDList:"+e),this.deleteLocalConversationList(e))}onConversationPinned(e){if(Fe(e)){let n=!1;e.forEach(e=>{var{type:e,userID:s,groupID:i}=e;let o;1===e?o=this.getLocalConversation(""+t.CONV_C2C+s):2===e&&(o=this.getLocalConversation(""+t.CONV_GROUP+i)),o&&(Ie.l(`${this._n}.onConversationPinned conversationID:${o.conversationID} isPinned:`+o.isPinned),o.isPinned||(o.isPinned=!0,n=!0))}),n&&this._sortConversationListAndEmitEvent()}}onConversationUnpinned(e){if(Fe(e)){let n=!1;e.forEach(e=>{var{type:e,userID:s,groupID:i}=e;let o;1===e?o=this.getLocalConversation(""+t.CONV_C2C+s):2===e&&(o=this.getLocalConversation(""+t.CONV_GROUP+i)),o&&(Ie.l(`${this._n}.onConversationUnpinned conversationID:${o.conversationID} isPinned:`+o.isPinned),o.isPinned&&(o.isPinned=!1,n=!0))}),n&&this._sortConversationListAndEmitEvent()}}getMessageList({conversationID:a,nextReqMessageID:e,count:t}){const c=this._n+".getMessageList",s=this.getLocalConversation(a);let i="";if(s&&s.groupProfile&&(i=s.groupProfile.type),et(i))return Ie.l(c+" not available in avchatroom. conversationID:"+a),js({messageList:[],nextReqMessageID:"",isCompleted:!0});($e(t)||15<t)&&(t=15),!e&&this._isNotInCommunity(a)&&(this._messageListHandler.removeByConversationID(a),this._completedMap.delete(a),this._roamingMessageSequenceMap.delete(a));const l=this._computeRemainingCount({conversationID:a,nextReqMessageID:e}),o=this._completedMap.has(a);if(Ie.l(c+` conversationID:${a} nextReqMessageID:${e} remainingCount:${l} count:${t} isCompleted:`+o),this._needGetHistory({conversationID:a,remainingCount:l,count:t}))return this.getHistoryMessages({conversationID:a,nextReqMessageID:e,count:20}).then(e=>{var{nextReqID:e,storedMessageList:t}=e,s=this._completedMap.has(a);let i=t;const o={nextReqMessageID:s?"":e,messageList:i=0<l?this._messageListHandler.getLocalMessageList(a).slice(0,t.length+l):i,isCompleted:s},n=o.messageList.filter(e=>e.isRevoked)||[],r=i.map(e=>e.sequence);return Ie.l(c+` ret.nextReqMessageID:${o.nextReqMessageID} ret.isCompleted:${o.isCompleted} ret.length:${i.length} sequenceList:`+r),Fe(n)&&0!==n.length?this.updateRevokerInfo(n).then(e=>(e.forEach(t=>{const s=t["revokerInfo"];o.messageList=o.messageList.map(e=>(e.ID===t.ID&&s&&(e.revokeReason=s.reason||"",e.revokerInfo={userID:s.revoker||e.revoker,nick:s.nick,avatar:s.avatar}),e))}),Ks(o))):Ks(o)});this.modifyMessageList(a);e=this._getMessageListFromMemory({conversationID:a,nextReqMessageID:e,count:t});return js(e)}_getMessageListFromMemory({conversationID:e,nextReqMessageID:t,count:s}){const i=this._n+"._getMessageListFromMemory",o=this._messageListHandler.getLocalMessageList(e),n=o.length;let r=0;const a={isCompleted:!1,nextReqMessageID:"",messageList:[]};return t?(r=o.findIndex(e=>e.ID===t))>s?(a.messageList=o.slice(r-s,r),a.nextReqMessageID=o[r-s].ID):(a.messageList=o.slice(0,r),a.isCompleted=!0):s<n?(r=n-s,a.messageList=o.slice(r,n),a.nextReqMessageID=o[r].ID):(a.messageList=o.slice(0,n),a.isCompleted=!0),Ie.l(i+` conversationID:${e} ret.nextReqMessageID:${a.nextReqMessageID} ret.isCompleted:${a.isCompleted} ret.length:`+a.messageList.length),a}getMessageListHopping(e){let{conversationID:s,sequence:i,time:o,count:n,direction:r=0}=e;if(($e(n)||15<n)&&(n=15),s.startsWith(t.CONV_C2C)){const e=this.get(Ms),i=s.replace(t.CONV_C2C,"");return e.getRoamingMessagesHopping({peerAccount:i,time:o,count:n,direction:r})}if(s.startsWith(t.CONV_GROUP)){const e=this.get(Is),o=s.replace(t.CONV_GROUP,"");return e.getRoamingMessagesHopping({groupID:o,sequence:i,count:n,direction:r})}}_computeRemainingCount({conversationID:e,nextReqMessageID:t}){const s=this._messageListHandler.getLocalMessageList(e),i=s.length;if(!t)return i;let o=0;return nt(e)?o=s.findIndex(e=>e.ID===t):ot(e)&&(o=-1!==t.indexOf("-")?s.findIndex(e=>e.ID===t):s.findIndex(e=>e.sequence===t)),o=-1===o?0:o}_getMessageListSize(e){return this._messageListHandler.getLocalMessageList(e).length}_needGetHistory({conversationID:e,remainingCount:t,count:s}){const i=this.getLocalConversation(e);let o="";if(i&&i.groupProfile&&(o=i.groupProfile.type),rt(e)||et(o))return!1;let n=!1;var r=this._n+"._needGetHistory conversationID:"+e;if(ot(e)){const t=this._isPagingGetGroupListCompleted(),s=this._getLocalGroupCount(),i=this._hasLocalGroup(e),o=this._isTopicConversation(e);if(Ie.l(r+` isGroupListCompleted:${t} localGroupCount:${s} isGroupInList:${i} isTopic:`+o),t&&s<=500&&!i&&!o)return n}return n=t<=s&&!this._completedMap.has(e),Ie.l(r+" ret:"+n),n}_isTopicConversation(e){e=e.replace(t.CONV_GROUP,"");return it(e)}getHistoryMessages(i){const{conversationID:o,count:e}=i;if(o===t.CONV_SYSTEM)return js();let n=15,r=(20<e&&(n=20),null);if(nt(o)){const i=this._roamingMessageKeyAndTimeMap.has(o);return(r=this.get(Ms))?r.getRoamingMessage({conversationID:o,peerAccount:o.replace(t.CONV_C2C,""),count:n,lastMessageTime:i?this._roamingMessageKeyAndTimeMap.get(o).lastMessageTime:0,messageKey:i?this._roamingMessageKeyAndTimeMap.get(o).messageKey:""}):Xs({code:Ws.CANNOT_FIND_MODULE})}if(ot(o)){if(!(r=this.get(Is)))return Xs({code:Ws.CANNOT_FIND_MODULE});const i=o.replace(t.CONV_GROUP,"");let e=null,s=0;(e=this._conversationMap.has(o)&&!it(i)?this._conversationMap.get(o).lastMessage:e)&&(s=e.lastSequence);var a=this._roamingMessageSequenceMap.get(o);return r.getRoamingMessage({conversationID:o,groupID:i,count:n,sequence:a||s})}return js()}patchConversationLastMessage(e){const t=this.getLocalConversation(e);if(t){const{messageForShow:s,payload:i}=t.lastMessage;if(Re(s)||Re(i)){const s=this._messageListHandler.getLocalMessageList(e);if(0!==s.length){const i=s[s.length-1];Ie.l(this._n+`.patchConversationLastMessage conversationID:${e} payload:`,i.payload),t.updateLastMessage(i)}}}}onRoamingMessage(e=[],s,u=!0){var i=s.startsWith(t.CONV_C2C)?t.CONV_C2C:t.CONV_GROUP;let o=null,n=[],r=[],a=0,c=e.length,l;const d=i===t.CONV_GROUP,_=this.getFileDownloadProxy();let p=()=>{d?--a:++a},h=()=>d?a>=c:a<c;for(a=d?e.length-1:0,c=d?0:e.length;h();p())if(d&&1===e[a].sequence&&u&&this.setCompleted(s),1!==e[a].isPlaceMessage)if((o=new Li(e[a])).to=e[a].to,i!==t.CONV_GROUP||$e(e[a].topicID)||(o.to=e[a].topicID),o.isSystemMessage=!!e[a].isSystemMessage,o.conversationType=i,l=4===e[a].event?{type:t.MSG_GRP_TIP,content:{...e[a].elements,groupProfile:e[a].groupProfile}}:e[a].elements,d||o.setNickAndAvatar({nick:e[a].nick,avatar:e[a].avatar}),Re(l)){const t=new pi("emptyMessageBody");t.setMessage(`from:${o.from} to:${o.to} sequence:${o.sequence} event:`+e[a].event),t.setLevel("warning").end()}else o.setElement(l,_),o.reInitialize(this.getMyUserID()),n.push(o);return p=h=null,u?(this._messageListHandler.unshift(n,r),n=null,r):(r=null,n)}findMessage(e){return this._messageListHandler.findMessage(e)}_isNotInCommunity(e){let s=!1;return e.startsWith(t.CONV_GROUP)&&this._isTopicConversation(e)&&(e=It(e.replace(t.CONV_GROUP,"")),this.get(Is).hasLocalGroup(e)||(s=!0)),s}deleteTopicRoamingMessageInfo(e){st({groupID:e})&&this._messageListHandler.getTopicConversationIDList(e).forEach(e=>{this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e)})}deleteGroupRoamingMessageInfo(e){e=""+t.CONV_GROUP+e;this._completedMap.delete(e),this._roamingMessageSequenceMap.delete(e)}setMessageRead({conversationID:e}){const s=this.getLocalConversation(e);if(Ie.l(this._n+`.setMessageRead conversationID:${e} unreadCount:`+(s?s.unreadCount:0)),!s)return js();if(s.type!==t.CONV_GROUP&&s.type!==t.CONV_TOPIC||Re(s.groupAtInfoList)||this.deleteGroupAtTips(e),0===s.unreadCount)return js();if(s.type===t.CONV_GROUP&&!this._hasLocalGroup(e))return 0!==s.unreadCount&&(s.unreadCount=0,this.emitConversationUpdate(!0,!1)),js();const i=this._messageListHandler.getLocalLastMessage(e);let o=s.lastMessage.lastTime,n=(i&&o<i.time&&(o=i.time),s.lastMessage.lastSequence);if(i&&n<i.sequence&&(n=i.sequence),s.type===t.CONV_TOPIC&&$e(i)){const s=this.get(Cs),i=e.replace(t.CONV_GROUP,""),o=It(i),r=s.getLocalTopic(o,i);r&&(n=r.nextMessageSeq-1)}let r=null;switch(s.type){case t.CONV_C2C:return(r=this.get(Ms))?r.setMessageRead({conversationID:e,lastMessageTime:o}):Xs({code:Ws.CANNOT_FIND_MODULE});case t.CONV_GROUP:case t.CONV_TOPIC:return(r=this.get(Is))?r.setMessageRead({conversationID:e,lastMessageSeq:n}):Xs({code:Ws.CANNOT_FIND_MODULE});case t.CONV_SYSTEM:return s.unreadCount=0,this.emitConversationUpdate(!0,!1),js();default:return js()}}setAllMessageRead(s={}){const i=this._n+".setAllMessageRead";s.scope||(s.scope=t.READ_ALL_MSG),Ie.l(i+" options:",s);var e=this._createSetAllMessageReadPack(s);if(0===e.readAllC2CMessage&&0===e.groupMessageReadInfoList.length)return js();const o=new pi("setAllMessageRead");return this.req({proto:Qs.SET_ALL_MSG_READ,data:e}).then(e=>{e=e.data,e=this._handleAllMessageRead(e);return o.setMessage(`scope:${s.scope} failureGroups:`+JSON.stringify(e)).end(),js()}).catch(e=>(o.setError(e).end(),Ie.w(i+" failed. error:",e),Xs({code:e&&e.code?e.code:Ws.MSG_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){var t=this._messageListHandler.getLocalLastMessage(e.conversationID);let s=e.lastMessage.lastSequence;return s=t&&s<t.sequence?t.sequence:s}_getConversationLastMessageTime(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID);let s=e.lastMessage.lastTime;return s=t&&s<t.time?t.time:s}_createSetAllMessageReadPack(e){const s={readAllC2CMessage:0,groupMessageReadInfoList:[]},i=e["scope"];for(var[,o]of this._conversationMap)if(0<o.unreadCount)if(o.type===t.CONV_C2C&&0===s.readAllC2CMessage){if(i===t.READ_ALL_MSG)s.readAllC2CMessage=1;else if(i===t.READ_ALL_C2C_MSG){s.readAllC2CMessage=1;break}}else if(o.type===t.CONV_GROUP&&(i===t.READ_ALL_GROUP_MSG||i===t.READ_ALL_MSG)){const e=this._getConversationLastMessageSequence(o);s.groupMessageReadInfoList.push({groupID:o.groupProfile.groupID,messageSequence:e})}return s}onPushedAllMessageRead(e){this._handleAllMessageRead(e)}_handleAllMessageRead(e){var{groupMessageReadInfoList:e,readAllC2CMessage:t}=e,e=this._parseGroupReadInfo(e);return 1<=this._updateAllConversationUnreadCount({readAllC2CMessage:t})&&this.emitConversationUpdate(!0,!1),e}_parseGroupReadInfo(s){const i=[];if(s&&s.length)for(let e=0,t=s.length;e<t;e++){var{groupID:o,sequence:n,retCode:r,lastMessageSeq:a}=s[e];$e(r)?this._remoteGroupReadSequenceMap.set(o,a):(this._remoteGroupReadSequenceMap.set(o,n),0!==r&&i.push(o+`-${n}-`+r))}return i}_updateAllConversationUnreadCount(e){const s=e["readAllC2CMessage"];let i=0;for(var[o,n]of this._conversationMap)if(1<=n.unreadCount){if(1===s&&n.type===t.CONV_C2C){const e=this._getConversationLastMessageTime(n);this.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:e})}else if(n.type===t.CONV_GROUP){const e=o.replace(t.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(e)){const t=this._remoteGroupReadSequenceMap.get(e),s=this._getConversationLastMessageSequence(n);this.updateIsReadAfterReadReport({conversationID:o,remoteReadSequence:t}),s>=t&&this._remoteGroupReadSequenceMap.delete(e)}}this.updateUnreadCount(o,!1)&&(i+=1)}return i}isRemoteRead(e){const{conversationID:s,sequence:i}=e,o=s.replace(t.CONV_GROUP,"");let n=!1;if(this._remoteGroupReadSequenceMap.has(o)){const e=this._remoteGroupReadSequenceMap.get(o);i<=e&&(n=!0,Ie.l(`${this._n}.isRemoteRead conversationID:${s} messageSequence:${i} remoteReadSequence:`+e)),i>=e+10&&this._remoteGroupReadSequenceMap.delete(o)}return n}updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:s,lastMessageTime:i}){var o=this._messageListHandler.getLocalMessageList(e);if(0!==o.length){let t;for(let e=o.length-1;0<=e;e--)if(t=o[e],!(i&&t.time>i||s&&t.sequence>s)){if("in"===t.flow&&t.isRead)break;t.setIsRead(!0)}}}updateUnreadCount(e,s=!0){let i=!1;const o=this.getLocalConversation(e),n=this._messageListHandler.getLocalMessageList(e);if(o){var r=o.unreadCount,a=n.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;if(r!==a&&(o.unreadCount=a,i=!0,Ie.l(this._n+`.updateUnreadCount from ${r} to ${a}, conversationID:`+e),!0===s&&this.emitConversationUpdate(!0,!1)),i&&o.type===t.CONV_TOPIC){const s=o["unreadCount"],i=this.get(Cs),n=e.replace(t.CONV_GROUP,"");i.onConversationProxy({topicID:n,unreadCount:s})}return i}}clearGroupAtInfoList(e,s=!0){const i=this.getLocalConversation(e);if(i&&0<i.groupAtInfoList.length){if(i.clearGroupAtInfoList(),Ie.l(this._n+".clearGroupAtInfoList conversationID:"+e),i.type===t.CONV_TOPIC){const s=i["groupAtInfoList"],o=this.get(Cs),n=e.replace(t.CONV_GROUP,"");o.onConversationProxy({topicID:n,groupAtInfoList:s})}!0===s&&this.emitConversationUpdate(!0,!1)}}updateReadReceiptInfo(s){const{userID:a,groupID:d,readReceiptList:i}=s;if(!Re(i)){const u=[];if($e(a)){if(!$e(d)){const e=""+t.CONV_GROUP+d;i.forEach(t=>{const{tinyID:s,clientTime:i,random:o,readCount:n,unreadCount:r}=t,a=s+`-${i}-`+o,c=this._messageListHandler.getLocalMessage(e,a),l={groupID:d,messageID:a,readCount:0,unreadCount:0};c&&(Pe(n)&&(c.readReceiptInfo.readCount=n,l.readCount=n),Pe(r)&&(c.readReceiptInfo.unreadCount=r,l.unreadCount=r),u.push(l))})}}else{const e=""+t.CONV_C2C+a;i.forEach(t=>{const{tinyID:s,clientTime:i,random:o}=t,n=s+`-${i}-`+o,r=this._messageListHandler.getLocalMessage(e,n);if(r){r.readReceiptInfo.isPeerRead=!0;const e={userID:a,messageID:n,isPeerRead:!0};u.push(e)}})}0<u.length&&this.emitOuterEvent(e.MESSAGE_READ_RECEIPT_RECEIVED,u)}}updateIsRead(e){const i=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(i&&0!==o.length&&!rt(i.type)){const n=[];for(let e=0,t=o.length;e<t;e++)"in"!==o[e].flow?"out"!==o[e].flow||o[e].isRead||o[e].setIsRead(!0):n.push(o[e]);let s=0;if(i.type===t.CONV_C2C){const e=n.slice(-i.unreadCount).filter(e=>e.isRevoked).length;s=n.length-i.unreadCount-e}else s=n.length-i.unreadCount;for(let e=0;e<s&&!n[e].isRead;e++)n[e].setIsRead(!0)}}deleteGroupAtTips(e){const s=this._n+".deleteGroupAtTips";Ie.l(s);var i=this._conversationMap.get(e);if(!i)return Promise.resolve();const o=i.groupAtInfoList;if(0===o.length)return Promise.resolve();let n=void 0,r=(e.startsWith(t.CONV_GROUP)&&(n=e.replace(t.CONV_GROUP,"")),[...o]);if((st({groupID:n})||it(n))&&0===(r=o.filter(e=>!e.atTypeArray.includes(t.CONV_AT_ALL))).length)return this.clearGroupAtInfoList(e,!1),Promise.resolve();const a=this.getMyUserID();return this.req({proto:Qs.DEL_GROUP_AT_TIPS,data:{messageListToDelete:r.map(e=>({from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:$e(e.topicID)?e.groupID:e.topicID}))}}).then(()=>(Ie.l(s+" ok. count:"+o.length),this.clearGroupAtInfoList(e,!1),Promise.resolve())).catch(e=>(Ie.e(s+" failed. error:",e),Xs(e)))}appendToMessageList(e){return 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){(!this._peerReadTimeMap.has(e)||this._peerReadTimeMap.get(e)<t)&&this._peerReadTimeMap.set(e,t)}updateMessageIsPeerReadProperty(s,i){if(s.startsWith(t.CONV_C2C)&&0<i){const t=this._messageListHandler.updateMessageIsPeerReadProperty(s,i);if(0<t.length&&this.emitOuterEvent(e.MESSAGE_READ_BY_PEER,t),this._conversationMap.has(s)){const e=this._conversationMap.get(s).lastMessage;Re(e)||e.fromAccount===this.getMyUserID()&&e.lastTime<=i&&!e.isPeerRead&&(e.isPeerRead=!0,this.emitConversationUpdate(!0,!1))}}}updateMessageIsModifiedProperty(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}setCompleted(e){Ie.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(t){const s=this._n+".getConversationList",e=`pagingStatus:${this._pagingStatus}, local conversation count:${this._conversationMap.size}, options:`+t;if(Ie.l(s+". "+e),this._pagingStatus===Gt){const i=new pi("getConversationList");return i.setMessage(e),this.syncConversationList().then(()=>{i.end();var e=this._getConversationList(t);return Ks({conversationList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>(i.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}const i=this._getConversationList(t);return Ie.l(s+". returned conversation count:"+i.length),js({conversationList:i,isSyncCompleted:this._isSyncCompleted()})}_getConversationList(s){if($e(s))return this.getLocalConversationList();if(Fe(s))return 0===s.length?[]:this.getLocalConversationList().filter(e=>s.includes(e.conversationID));if(ke(s)){const{type:i,markType:o,groupName:n}=s;return this.getLocalConversationList().filter(e=>(i!==t.CONV_C2C&&i!==t.CONV_GROUP||e.type===i)&&(!Ue(n)||e.conversationGroupList.includes(n))&&(!Pe(o)||e.markList.includes(o)))}return[]}_handleC2CPeerReadTime(){for(var[e,s]of this._conversationMap)s.type===t.CONV_C2C&&(Ie.d(`${this._n}._handleC2CPeerReadTime conversationID:${e} peerReadTime:`+s.peerReadTime),this.recordPeerReadTime(e,s.peerReadTime))}_isPagingGetGroupListCompleted(){const e=this.get(Is);return!e||e.isPagingGetCompleted()}_getLocalGroupCount(){const e=this.get(Is);return e?e.getLocalGroupList().length:0}_hasLocalGroup(e){const s=this.get(Is);return!!s&&s.hasLocalGroup(e.replace(t.CONV_GROUP,""))}getConversationProfile(i){let o;if((o=this._conversationMap.has(i)?this._conversationMap.get(i):new Wi({conversationID:i,type:i.slice(0,3)===t.CONV_C2C?t.CONV_C2C:t.CONV_GROUP},this.isIntl(),this.isUsingChatCore()))._isInfoCompleted||o.type===t.CONV_SYSTEM)return js({conversation:o});if(ot(i)&&!this._hasLocalGroup(i))return js({conversation:o});const n=this._n+".getConversationProfile",r=new pi("getConversationProfile");return Ie.l(n+`. conversationID:${i} remark:${o.remark} lastMessage:`,o.lastMessage),this._updateUserOrGroupProfileCompletely(o).then(e=>{r.setMessage(`conversationID:${i} unreadCount:`+e.data.conversation.unreadCount).end();const s=this.get(fs);if(s&&o.type===t.CONV_C2C){const r=i.replace(t.CONV_C2C,"");if(s.isMyFriend(r)){const t=s.getFriendRemark(r);o.remark!==t&&(o.remark=t,Ie.l(n+`. conversationID:${i} patch remark:`+o.remark))}}return Ie.l(n+" ok. conversationID:"+i),e}).catch(e=>(r.setError(e).setMessage("conversationID:"+i).end(),Ie.e(n+" failed. error:",e),Xs(e)))}_updateUserOrGroupProfileCompletely(s){return s.type===t.CONV_C2C?this.get(ms).getUserProfile({userIDList:[s.toAccount]}).then(e=>{e=e.data;return 0===e.length?Xs(new Hs({code:Ws.USER_OR_GRP_NOT_FOUND})):(s.userProfile=e[0],s._isInfoCompleted=!0,this._unshiftConversation(s),js({conversation:s}))}):this.get(Is).getGroupProfile({groupID:s.toAccount}).then(e=>(s.groupProfile=e.data.group,s._isInfoCompleted=!0,this._unshiftConversation(s),js({conversation:s})))}_unshiftConversation(e){e instanceof Wi&&!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=>{var s=e["userID"];if(s===this.getMyUserID())this._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{const i=this._conversationMap.get(""+t.CONV_C2C+s);i&&(i.userProfile=e)}})}_isSyncCompleted(){return this._pagingStatus===Ut}_errorLog(e,t,s,i){var o=new Error("Params validate failed."),n=""+this.getErrorMessage("API_REFER")+e;throw Ie.w(`[${e}] | ${t} | ${this.getErrorMessage(s,i)}, `+n),Ie.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),o}_isValidConversationID(e){return nt(e)||ot(e)||rt(e)}deleteConversation(e){const t="deleteConversation";return Ue(e)||Ge(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),Ue(e)?(this._isValidConversationID(e)||this._errorLog(t,"options","InvalidConversationID",e),Ie.l(`${this._n}.${t} conversationID:`+e),this.deleteConversationList({conversationIDList:[e],flag:1})):(Fe(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"),100<e.conversationIDList.length&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConversationList(e))}deleteConversationList(e){const{conversationIDList:t=[],clearHistoryMessage:s=!0,flag:i=0}=e,o=this._n+".deleteConversationList",n=(Ie.l(o+` conversationIDList.length:${t.length} clearHistoryMessage:`+s),new pi("deleteConversationList"));return n.setMessage("conversationIDList:"+t),Promise.all([this.rmLocalOnlyConversationList(t),this.rmLocalAndRemoteConversationList(t,s)]).then(e=>{n.end();e=[...e[0],...e[1]];return 0===e.length?Xs(new Hs({code:Ws.CONV_NOT_FOUND})):(Ie.l(o+" ok"),js(1===i?{conversationID:e[0]}:{conversationIDList:e}))}).catch(e=>(n.setError(e).end(),Ie.e(o+" failed. error:",e),Xs(e)))}rmLocalOnlyConversationList(e){return e.filter(e=>{if(!this._conversationMap.has(e))return!1;var s=this.getLocalConversation(e).type;return s!==t.CONV_GROUP||this._hasLocalGroup(e)?s===t.CONV_SYSTEM&&(this.get(Is).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),!0):(this.deleteLocalConversation(e),!0)})}rmLocalAndRemoteConversationList(e,s){const i={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:s?1:0};return e.forEach(e=>{var s;this._conversationMap.has(e)&&((s=this.getLocalConversation(e).type)===t.CONV_C2C?i.conversationList.push({toAccount:e.replace(s,""),type:1}):s===t.CONV_GROUP&&this._hasLocalGroup(e)&&i.conversationList.push({toGroupID:e.replace(s,""),type:2}))}),0===i.conversationList.length?[]:this.req({proto:Qs.DEL_CONV,data:i}).then(e=>{const s=[];return 0<e.data.resultList.length&&e.data.resultList.map(e=>{0===e.code&&(e=1===e.type?""+t.CONV_C2C+e.to:""+t.CONV_GROUP+e.groupID,s.push(e))}),this.deleteLocalConversationList(s),s})}setConversationDraft(e){var{conversationID:e,draftText:t}=e,s=this._n+".setConversationDraft";if(Ie.l(s+` conversationID:${e} draftText:`+t),!this._conversationMap.has(e))return Xs({code:Ws.CONV_NOT_FOUND});const i=this._conversationMap.get(e);return i.setDraftText(t),js({code:0,conversation:i})}clearHistoryMessage(s){const e={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._conversationMap.has(s))return Xs({code:Ws.CONV_NOT_FOUND});var i=this._conversationMap.get(s).type;if(i===t.CONV_C2C)e.type=1,e.toAccount=s.replace(t.CONV_C2C,"");else{if(i!==t.CONV_GROUP)return i===t.CONV_SYSTEM?(this.get(Is).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(s)}),js({conversationID:s})):Xs({code:Ws.CONV_UN_RECORDED_TYPE});e.type=2,e.toGroupID=s.replace(t.CONV_GROUP,"")}const o=this._n+".clearHistoryMessage",n=new pi("clearHistoryMessage");return n.setMessage("conversationID:"+s),Ie.l(o+". conversationID:"+s),this.setMessageRead({conversationID:s}).then(()=>this.req({proto:Qs.CLEAR_HISTORY_MSG,data:e})).then(()=>{n.end(),Ie.l(o+" ok"),this._messageListHandler.removeByConversationID(s),this.setCompleted(s);const e=this.getLocalConversation(s);return e&&(e.updateLastMessage(),this._sortConversationListAndEmitEvent()),js({conversationID:s})}).catch(e=>(n.setError(e).end(),Ie.e(o+" failed. error:",e),Xs(e)))}pinConversation(e){const{conversationID:s,isPinned:i}=e;if(!this._conversationMap.has(s))return Xs({code:Ws.CONV_NOT_FOUND});const o=this.getLocalConversation(s);if(o.isPinned===i)return js({conversationID:s});const n=this._n+".pinConversation",r=new pi("pinConversation");r.setMessage(`conversationID:${s} isPinned:`+i),Ie.l(n+`. conversationID:${s} isPinned:`+i);let a=null;return nt(s)?a={type:1,toAccount:s.replace(t.CONV_C2C,"")}:ot(s)&&(a={type:2,groupID:s.replace(t.CONV_GROUP,"")}),this.req({proto:Qs.PIN_CONV,data:{fromAccount:this.getMyUserID(),operationType:!0===i?1:2,itemList:[a]}}).then(()=>(r.end(),Ie.l(n+" ok"),o.isPinned!==i&&(o.isPinned=i,this._sortConversationListAndEmitEvent()),Ks({conversationID:s}))).catch(e=>(r.setError(e).end(),Ie.e(n+" failed. error:",e),Xs(e)))}setMessageRemindType(e){return this._messageRemindHandler.set(e)}patchMessageRemindType(e){var{ID:s,isC2CConversation:i,messageRemindType:o}=e;let n=!1;const r=this.getLocalConversation(i?""+t.CONV_C2C+s:""+t.CONV_GROUP+s);return r&&r.messageRemindType!==o&&(r.messageRemindType=o,n=!0),Ie.d(this._n+".patchMessageRemindType options:",e,"ret:"+n),n}onC2CMessageRemindTypeFetched(e){if(Fe(e)&&0<e.length){let s=0;e.forEach(e=>{var{userID:e,muteFlag:t}=e,t=this._transMessageRemindType(t);!0===this.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:t})&&(s+=1)}),Ie.l(this._n+".onC2CMessageRemindTypeFetched updateCount:"+s),1<=s&&this.emitConversationUpdate(!0,!1)}}onC2CMessageRemindTypeSynced(e){const i=this._n+".onC2CMessageRemindTypeSynced";Ie.d(i,e),e.dataList.forEach(t=>{if(!Re(t.muteNotificationsSync)){var{to:t,muteFlag:s}=t.muteNotificationsSync,s=this._transMessageRemindType(s);let e=0;this.patchMessageRemindType({ID:t,isC2CConversation:!0,messageRemindType:s})&&(e+=1),Ie.l(i+" updateCount:"+e),1<=e&&this.emitConversationUpdate(!0,!1)}})}onGroupMessageRemindTypeUpdated(e){Ie.d(this._n+".onGroupMessageRemindTypeUpdated options:",e),this._messageRemindHandler.onGroupMessageRemindTypeUpdated(e)}deleteLocalConversation(e,t=!0){var s=this._conversationMap.has(e);if(Ie.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=!1;e.forEach(e=>{this._conversationMap.has(e)&&(this.deleteLocalConversation(e,!1),t=!0)}),Ie.l(`${this._n}.deleteLocalConversationList conversationIDList.length:${e.length} isConvIDExisted:`+t),t&&this.emitConversationUpdate(!0,!1)}isMessageSentByCurrentInstance(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}modifyMessageList(e){var s,i;e.startsWith(t.CONV_C2C)&&this._conversationMap.has(e)&&(i=this._conversationMap.get(e),s=Date.now(),this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:i.userProfile.nick,latestAvatar:i.userProfile.avatar}),i=this.get(ms).getNickAndAvatarByUserID(this.getMyUserID()),this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:i.nick,latestAvatar:i.avatar}),Ie.l(this._n+`.modifyMessageList conversationID:${e} cost:`+St(s)))}updateUserProfileSpecifiedKey(e){Ie.l(this._n+".updateUserProfileSpecifiedKey options:",e);var{conversationID:t,nick:s,avatar:i}=e;if(this._conversationMap.has(t)){const e=this._conversationMap.get(t).userProfile;Ue(s)&&e.nick!==s&&(e.nick=s),Ue(i)&&e.avatar!==i&&(e.avatar=i),this.emitConversationUpdate(!0,!1)}}_onMyProfileModified(t){const e=this.getLocalConversationList(),s=Date.now();e.forEach(e=>{this.modifyMessageSentByMe({conversationID:e.conversationID,...t})}),Ie.l(this._n+"._onMyProfileModified. modify all messages sent by me, cost:"+St(s))}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 o=this.get(fs);if(0!==this._conversationMap.size&&o){const e=[...this._conversationMap.values()].filter(e=>e.type===t.CONV_C2C);if(0!==e.length){let i=0;e.forEach(e=>{var s=e.conversationID.replace(t.CONV_C2C,"");if(o.isMyFriend(s)){const t=o.getFriendRemark(s);e.remark!==t&&(e.remark=t,i+=1)}}),Ie.l(`${this._n}.checkAndPatchRemark. c2c conversation count:${e.length}, patched count:`+i)}}}updateTopicConversation(e){this._updateLocalConversationList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}sendReadReceipt(e){var s=e[0];let i=null;return s.conversationType===t.CONV_C2C?i=this._m.get(Ms):s.conversationType===t.CONV_GROUP&&(i=this._m.get(Is)),i?i.sendReadReceipt(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getReadReceiptList(e){var s=e[0];let i=null;return s.conversationType===t.CONV_C2C?i=this._m.get(Ms):s.conversationType===t.CONV_GROUP&&(i=this._m.get(Is)),i?i.getReadReceiptList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getLastMessageTime(e){e=this.getLocalConversation(e);return e?e.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(){var t=this.getTotalUnreadMessageCount();this._convTotalUnreadCount!==t&&(Ie.l(`${this._n}.emitTotalUnreadMessageCountUpdate from ${this._convTotalUnreadCount} to `+t),this._convTotalUnreadCount=t,this.emitOuterEvent(e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}reset(){Ie.l(this._n+".reset"),this._setStorageConversationList(!0),this._pagingStatus=Ot,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._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this.resetReady()}}const Xi=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Ji=function(e,t){return Re(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",messageForShow:"",nick:"",avatar:"",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:ft(e.type,e.payload,t),nick:e.nick||"",avatar:e.avatar||"",version:e.version||0,cloudCustomData:e.cloudCustomData||"",isRevoked:e.isRevoked||!1,revoker:e.revoker||null}};class Qi{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=Ji(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(const t in e)Xi.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=Ji(e)}updateGroupAtInfoList(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}updateTopic(e){$e(e.selfInfo)||this.updateSelfInfo(e.selfInfo),$e(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),Ke(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg"])}updateSelfInfo(e){return 0!==Ke(this.selfInfo,e,[],[""])}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked({sequence:e}){return e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}}class Zi extends Js{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(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");$e(e)||(this.TOPIC_CACHE_TIME=Number(e)),$e(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}onTopicCreated(t){var s=t["groupID"];this.resetGetTopicTime(s),this.emitOuterEvent(e.TOPIC_CREATED,t)}onTopicDeleted(t){const{groupID:s,topicIDList:i=[]}=t;i.forEach(e=>{this._deleteLocalTopic(s,e)}),this.emitOuterEvent(e.TOPIC_DELETED,t)}onTopicMessageRemindTypeUpdated(t){const{groupID:s,topicID:i,messageRemindType:o}=t,n=this.getLocalTopic(s,i);if(n){const t=n.updateSelfInfo({messageRemindType:o});t&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}),Ie.d(this._n+`.onTopicMessageRemindTypeUpdated topicID:${i} messageRemindType:${o} isTopicUpdated:`+t)}}onTopicProfileUpdated(t){const{groupID:s,topicID:i}=t,o=this.getLocalTopic(s,i);o&&(o.updateTopic(t),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:o}))}onConversationProxy(t){const{topicID:s,unreadCount:i,groupAtInfoList:o}=t,n=It(s),r=this.getLocalTopic(n,s);let a=!1;r&&($e(i)||r.unreadCount===i||(r.updateUnreadCount(i),a=!0),$e(o)||(r.updateGroupAtInfoList(o),a=!0)),a&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:n,topic:r})}onMessageSent(t){const{groupID:s,topicID:i,lastMessage:o}=t,n=this.getLocalTopic(s,i);n&&(n.nextMessageSeq+=1,n.updateLastMessage(o),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:s,topic:n}))}onMessageModified(t){var{to:s,time:i,sequence:o,elements:n,cloudCustomData:r,messageVersion:a}=t,c=It(s),l=this.getLocalTopic(c,s);if(l){const d=l.lastMessage;Ie.d(this._n+`.onMessageModified topicID:${s} lastMessage:`,JSON.stringify(d),"options:",JSON.stringify(t)),d&&(null===d.payload||d.lastTime===i&&d.lastSequence===o&&d.version!==a)&&(d.type=n[0].type,d.payload=n[0].content,d.messageForShow=ft(d.type,d.payload,this.isIntl()),d.cloudCustomData=r,d.version=a,d.lastSequence=o,d.lastTime=i,this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:c,topic:l}))}}onMessageRevoked(t){if(0!==t.length){let s=null,i=null,o=!1;t.forEach(e=>{var t=e.to;i=It(t),(s=this.getLocalTopic(i,t))&&(s.reduceUnreadCount()&&(o=!0),s.isLastMessageRevoked(e)&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),o=!0))}),o&&this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:i,topic:s})}}isLastMessageRevoked(e){const{topicID:t,sequence:s}=e,i=It(t),o=this.getLocalTopic(i,t);let n=!1;return n=o?o.isLastMessageRevoked({sequence:s}):n}getJoinedCommunityList(){return this.get(Is).syncCommunityWithTopic()}createTopicInCommunity(t){const s=this._n+".createTopicInCommunity",e=t["topicID"];if(!$e(e)&&!it(e))return Xs({code:Ws.ILLEGAL_TOPIC_ID});if(t.topicName&&!1===this._filterProfanity("topicName",t))return Xs({code:Ws.PROFANITY_FOUND});if(t.introduction&&!1===this._filterProfanity("introduction",t))return Xs({code:Ws.PROFANITY_FOUND});if(t.notification&&!1===this._filterProfanity("notification",t))return Xs({code:Ws.PROFANITY_FOUND});const i=new pi("createTopicInCommunity");return this.req({proto:Qs.CREATE_TOPIC,data:{...t}}).then(e=>{e=e.data.topicID;return i.setMessage("topicID:"+e).end(),Ie.l(s+" ok. topicID:"+e),this._updateTopicMap([{...t,topicID:e}]),Ks({topicID:e})}).catch(e=>(i.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}deleteTopicFromCommunity(e){const s=this._n+".deleteTopicFromCommunity",{groupID:n,topicIDList:t=[]}=e,r=new pi("deleteTopicFromCommunity");return r.setMessage(`groupID:${n} topicIDList:`+t),this.req({proto:Qs.DELETE_TOPIC,data:{groupID:n,topicIDList:t}}).then(e=>{const{resultList:t=[]}=e.data,i=[],o=[];t.forEach(e=>{var{topicID:e,errorCode:t,errorInfo:s}=e;0===t?i.push({topicID:e}):o.push({topicID:e,code:t,message:s})});e=`success count:${i.length}, fail count:`+o.length;return r.setMoreMessage(e).end(),Ie.l(s+" ok. "+e),i.forEach(e=>{this._deleteLocalTopic(n,e.topicID)}),Ks({successTopicList:i,failureTopicList:o})}).catch(e=>(r.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}updateTopicProfile(e){const t=this._n+".updateTopicProfile";if(Ie.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return Xs({code:Ws.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return Xs({code:Ws.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return Xs({code:Ws.PROFANITY_FOUND});const s=new pi("updateTopicProfile");return s.setMessage(`groupID:${e.groupID} topicID:`+e.topicID),$e(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.req({proto:Qs.UPDATE_TOPIC_PROFILE,data:{...e}}).then(()=>(s.end(),Ie.l(t+" ok"),this._updateTopicMap([e]),Ks({topic:this.getLocalTopic(e.groupID,e.topicID)}))).catch(e=>(s.setError(e).end(),Ie.e(t+" failed. error:",e),Xs(e)))}getTopicList(e){const i=this._n+".getTopicList",{groupID:o,topicIDList:t=[]}=e,c=0===t.length,l=new pi("getTopicList");if(l.setMessage("groupID:"+o),this._getTopicTimeMap.has(o)){const{isGetAll:e,time:s}=this._getTopicTimeMap.get(o);if((e||!e&&!c)&&Date.now()-s<1e3*this.TOPIC_CACHE_TIME){const e=this._getLocalTopicList(o,t);if(c||e.length===t.length)return l.setMoreMessage("from cache, topic count:"+e.length).end(),Ie.l(i+` groupID:${o} from cache, topic count:`+e.length),js({successTopicList:e,failureTopicList:[]})}}return this.req({proto:Qs.GET_TOPIC_LIST,data:{groupID:o,topicIDList:t}}).then(e=>{const{topicInfoList:t=[]}=e.data,n=[],r=[],a=[];t.forEach(e=>{var{topic:e,selfInfo:t,errorCode:s,errorInfo:i}=e,o=e["topicID"];0===s?(n.push({...e,selfInfo:t}),r.push(o)):a.push({topicID:o,code:s,message:i})}),this._updateTopicMap(n),this._handleTopicAtInfo(n);e=`success count:${r.length}, fail count:`+a.length;l.setMoreMessage(e).end(),Ie.l(i+` groupID:${o} from remote, `+e);let s=[];return Re(r)||(this._getTopicTimeMap.set(o,{time:Date.now(),isGetAll:c}),s=this._getLocalTopicList(o,r)),Ks({successTopicList:s,failureTopicList:a})}).catch(e=>(l.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}hasLocalTopic(e,t){return!!this._topicMap.has(e)&&this._topicMap.get(e).has(t)}getLocalTopic(e,t){let s=null;return s=this._topicMap.has(e)?this._topicMap.get(e).get(t):s}_getLocalTopicList(e,t=[]){const s=this._topicMap.get(e);let i=[];return s&&(i=[...s.values()]),0===t.length?i:i.filter(e=>t.includes(e.topicID))}_deleteLocalTopic(e,t){this._topicMap.has(e)&&this._topicMap.get(e).has(t)&&(this._topicMap.get(e).delete(t),Ie.l(this._n+`._deleteLocalTopic groupID:${e} topicID:`+t))}_updateTopicMap(e){const n=[];e.forEach(e=>{var{groupID:s,topicID:i}=e;let o=null;this._topicMap.has(s)||this._topicMap.set(s,new Map),this._topicMap.get(s).has(i)?(o=this._topicMap.get(s).get(i)).updateTopic(e):(this._getTopicLastMessage(e),o=new Qi(e,this.isIntl()),this._topicMap.get(s).set(i,o));e=this._computeUnreadCount(o);o.updateUnreadCount(e),n.push({conversationID:""+t.CONV_GROUP+i,type:t.CONV_TOPIC,unreadCount:e})}),0<n.length&&this.get(Ts).updateTopicConversation(n)}resetGetTopicTime(e){$e(e)?[...this._getTopicTimeMap.keys()].forEach(e=>{this._getTopicTimeMap.set(e,0)}):this._getTopicTimeMap.set(e,0)}getTopicListOnReconnected(){const e=[...this._topicMap.keys()],i=[],o=this.get(Ts);e.forEach(e=>{const s=[],t=this._getLocalTopicList(e);o.deleteTopicRoamingMessageInfo(e),t.forEach(e=>{var{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&s.push(e.topicID)}),0<s.length&&i.push({groupID:e,topicIDList:s})}),Ie.l(this._n+".getTopicListOnReconnected. active community count:"+i.length),this._relayGetTopicList(i)}_relayGetTopicList(t){if(0!==t.length){const e=t.shift(),s=5<e.topicIDList.length?"topicIDList.length:"+e.topicIDList.length:"topicIDList:"+e.topicIDList,i=new pi("relayGetTopicList");i.setMessage(s),Ie.l(this._n+"._relayGetTopicList. "+s),this.getTopicList(e).then(()=>{i.end(),this._relayGetTopicList(t)}).catch(e=>{i.setError(e).end(),this._relayGetTopicList(t)})}}_handleTopicAtInfo(e){0!==e.length&&e.forEach(e=>{const{groupID:t,topicID:s,groupAtInfoList:i}=e,o=[];$e(i)||(i.forEach(e=>{o.push({...e,groupID:t,topicID:s})}),this.get(Ts).onNewGroupAtTips({dataList:o}))})}_getTopicLastMessage(e){var t;$e(e.lastMsg)||(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,avatar:e.lastMsg.avatar,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:Re(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker},e.lastMessage=t)}deleteTopicListInCommunity(s){const e=this._getLocalTopicList(s),i=this.get(Ts);e.forEach(e=>{e=e.topicID;this._deleteLocalTopic(s,e),this._getTopicTimeMap.delete(s),i.deleteLocalConversation(""+t.CONV_GROUP+e)})}_computeUnreadCount(s){const{excludedUnreadSequenceList:e,readedSequence:i}=s.selfInfo;let o=s.nextMessageSeq-s.selfInfo.readedSequence-1;if(Fe(e)){let t=0;e.forEach(e=>{e>=i&&e<=s.nextMessageSeq-1&&(t+=1)}),1<=t&&(o-=t)}return o<0?0:o}_filterProfanity(e,t){const s=this.get($s);if(!s)return!0;var{isAllowedToSend:i,modifiedText:o}=s.filterText(t[e],S);return!0===i&&(t[e]=o,!0)}updateLastMessage(t,s){const i=It(t),o=this.getLocalTopic(i,t);if(o){const t=s.sequence+1;o.updateNextMessageSeq(t),o.updateLastMessage(s),this.emitOuterEvent(e.TOPIC_UPDATED,{groupID:i,topic:o})}}getMessageExtensions(e,t){Ie.l(this._n+".getMessageExtensions startSequence:"+t);var s=It(e.to);return this.req({proto:Qs.GET_GRP_MSG_EXT,data:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMessageExtensions(e,t,s=1){Ie.l(this._n+".modifyMessageExtensions operateType:"+s);var i=It(e.to);return this.req({proto:Qs.MODIFY_GRP_MSG_EXT,data:{groupID:i,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){Ie.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class en{constructor(e){this._userM=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,i=(e.fromAccount=this._userM.getMyAccount(),100<s.length&&(Ie.w(t+" "+yt(100)),s.length=100),[]),o=[];var n;for(let e=0,t=s.length;e<t;e++)n=s[e],this._userM.isMyFriend(n)&&this._contains(n)?o.push(this._getProfileFromMap(n)):i.push(n);if(0===i.length)return js(o);e.toAccount=i;const r=e.bFromGetMyProfile||!1,a=[],c=(e.toAccount.forEach(e=>{a.push({toAccount:e,standardSequence:0,customSequence:0})}),e.userItem=a,new pi("getUserProfile"));return c.setMessage(5<s.length?"userIDList.length:"+s.length:"userIDList:"+s),this._userM.req({proto:Qs.GET_USER_PROFILE,data:e}).then(e=>{c.end(),Ie.i(t+" ok");e=this._handleResponse(e).concat(o);return Ks(r?e[0]:e)}).catch(e=>(c.setError(e).end(),Ie.e(t+" failed. error:",e),Xs(e)))}getMyProfile(){var e,t=this._userM.getMyAccount(),s=this._n+".getMyProfile";return Ie.l(s+" myAccount:"+t),this._fill(),this._contains(t)?(e=this._getProfileFromMap(t),Ie.d(s+" from cache, myProfile:"+JSON.stringify(e)),js(e)):this.getUserProfile({fromAccount:t,userIDList:[t],bFromGetMyProfile:!0})}_handleResponse(s){var i,o=s.data["userProfileItem"];if(!Fe(o))return[];const n=[],r=Date.now();for(let e=0,t=o.length;e<t;e++){const{to:s,profileItem:r}=o[e];"@TLS#NOT_FOUND"!==s&&""!==s&&(i=this._update(s,this._getLatestProfileFromResponse(s,r))["latestProfile"],n.push(i))}return Ie.l(this._n+"._handleResponse cost:"+St(r)),n}_getLatestProfileFromResponse(e,s){const i={userID:e,profileCustomField:[]};if(!Re(s))for(let e=0,t=s.length;e<t;e++)if(-1<s[e].tag.indexOf("Tag_Profile_Custom"))i.profileCustomField.push({key:s[e].tag,value:s[e].value});else switch(s[e].tag){case Ce.NICK:i.nick=s[e].value;break;case Ce.GENDER:i.gender=s[e].value;break;case Ce.BIRTHDAY:i.birthday=s[e].value;break;case Ce.LOCATION:i.location=s[e].value;break;case Ce.SELFSIGNATURE:i.selfSignature=s[e].value;break;case Ce.ALLOWTYPE:i.allowType=s[e].value;break;case Ce.LANGUAGE:i.language=s[e].value;break;case Ce.AVATAR:i.avatar=s[e].value;break;case Ce.MESSAGESETTINGS:i.messageSettings=s[e].value;break;case Ce.ADMINFORBIDTYPE:i.adminForbidType=s[e].value;break;case Ce.LEVEL:i.level=s[e].value;break;case Ce.ROLE:i.role=s[e].value;break;default:Ie.w(this._n+"._getLatestProfileFromResponse unknown tag:",s[e].tag,s[e].value)}return i}updateMyProfile(o){const n=this._n+".updateMyProfile";if(o.nick&&!1===this._userM.filterProfanity("nick",o))return Xs({code:Ws.PROFANITY_FOUND});if(o.selfSignature&&!1===this._userM.filterProfanity("selfSignature",o))return Xs({code:Ws.PROFANITY_FOUND});const r=new pi("updateMyProfile");r.setMessage(JSON.stringify(o));var t=(new qi).validate(o);if(!t.valid)return r.setCode(Ws.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+t.tips).end(),Ie.e(n+" info:"+t.tips),Xs({code:Ws.UPDATE_PROFILE_INVALID_PARAM});const s=[];for(const e in o)Object.prototype.hasOwnProperty.call(o,e)&&("profileCustomField"===e?o.profileCustomField.forEach(e=>{s.push({tag:e.key,value:e.value})}):s.push({tag:Ce[e.toUpperCase()],value:o[e]}));if(0===s.length){const e=new Hs({code:Ws.UPDATE_PROFILE_NO_KEY});return r.setError(e).end(),Ie.e(n+" failed. error:",e),Xs(e)}const a=this._userM.getMyAccount();return this._userM.req({proto:Qs.UPDATE_MY_PROFILE,data:{fromAccount:a,profileItem:s}}).then(t=>{r.end(),Ie.i(n+" ok");var{isProfileUpdated:s,latestProfile:i}=this._update(a,o);return!0===s&&this._userM.emitOuterEvent(e.PROFILE_UPDATED,[i]),js(i)}).catch(e=>(r.setError(e).end(),Ie.e(n+" failed. error:",e),Xs(e)))}onProfileModified(t){var s,i=t.dataList;if(!Re(i)){const o=i.length;Ie.d(`${this._n}.onProfileModified count:${o} dataList:`,t.dataList);const n=[];for(let e=0;e<o;e++){s=i[e].userID;const{isProfileUpdated:t,latestProfile:o}=this._update(s,this._getLatestProfileFromResponse(s,i[e].profileList));!0===t&&n.push(o)}0<n.length&&(this._userM.emitInnerEvent(Pi.PROFILE_UPDATED,n),this._userM.emitOuterEvent(e.PROFILE_UPDATED,n))}}_fill(){if(0===this.accountProfileMap.size){var s=this._getCachedProfiles(),i=Date.now();for(let e=0,t=s.length;e<t;e++)i-s[e].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(s[e].userID,s[e]);Ie.l(this._n+"._fill from cache, size:"+this.accountProfileMap.size)}}_update(e,t){let s,i=!1;var o=Date.now();return this._contains(e)?(s=this._getProfileFromMap(e),t.profileCustomField&&!0===Ze(s.profileCustomField,t.profileCustomField)&&(s.lastUpdatedTime=o,i=!0),0<Ke(s,t,["profileCustomField"])&&(s.lastUpdatedTime=o,i=!0)):(s=new qi(t),!this._userM.isMyFriend(e)&&e!==this._userM.getMyAccount()||(s.lastUpdatedTime=o,i=!0,this.accountProfileMap.set(e,s))),this._flush(e===this._userM.getMyAccount()),!0===i&&Ie.l(this._n+`._update account:${e} isProfileUpdated:`+i),{isProfileUpdated:i,latestProfile:s}}_flush(e){const t=[...this.accountProfileMap.values()],s=this._userM.getStorageModule();Ie.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(){var e=this._userM.getStorageModule().getItem(this.TAG);return Re(e)?[]:e}onConversationsProfileUpdated(s){var i,o,n;const r=[];for(let e=0,t=s.length;e<t;e++)o=(i=s[e]).userID,this._userM.isMyFriend(o)&&(this._contains(o)?(n=this._getProfileFromMap(o),0<Ke(n,i)&&r.push(o)):r.push(i.userID));0!==r.length&&(Ie.i(this._n+".onConversationsProfileUpdated toAccountList:"+r),this.getUserProfile({userIDList:r}))}getNickAndAvatarByUserID(e){return this._contains(e)?{nick:(e=this._getProfileFromMap(e)).nick,avatar:e.avatar}:{nick:"",avatar:""}}getUserNickAndAvatar(e){var t=[...new Set(e)];Ie.l(`${this._n}.getUserNickAndAvatar userIDList.length:${e.length} uniqueUserIDList.length:`+t.length);const s=[];if(0===e.length)return Promise.resolve(s);const i=this._createUserIDListGroup(t),o=[];return i.forEach(e=>{o.push(this.getUserProfile({userIDList:e}))}),Promise.all(o).then(e=>(e.forEach(e=>{e=e.data.map(({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s}));s.push(...e)}),s))}_createUserIDListGroup(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));return t}reset(){this._flush(!0),this.accountProfileMap.clear()}}class tn{constructor(e){Re||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class sn{constructor(e){this._userM=e,this._n="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}getLocalBlacklist(){return[...this._blacklistMap.keys()]}getBlacklist(){const o=this._n+".getBlacklist",t={fromAccount:this._userM.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},n=new pi("getBlacklist");return this._userM.req({proto:Qs.GET_BL,data:t}).then(t=>{var{blackListItem:t,currentSequence:s}=t.data,i=Re(t)?0:t.length;n.setMessage("count:"+i).end(),Ie.i(o+" ok"),this.currentSequence=s,this._handleResponse(t,!0),this._userM.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()])}).catch(e=>(n.setError(e).end(),Ie.e(o+" failed. error:",e),Xs(e)))}addBlacklist(t){const s=new pi("addToBlacklist"),i=this._n+".addBlacklist",o=this._userM.getMyAccount();if(1!==t.userIDList.length||t.userIDList[0]!==o)return t.userIDList.includes(o)&&(t.userIDList=t.userIDList.filter(e=>e!==o)),t.fromAccount=this._userM.getMyAccount(),t.toAccount=t.userIDList,this._userM.req({proto:Qs.ADD_TO_BL,data:t}).then(e=>(s.setMessage(5<t.userIDList.length?"userIDList.length:"+t.userIDList.length:"userIDList:"+t.userIDList).end(),Ie.i(i+" ok"),this._handleResponse(e.resultItem,!0),Ks([...this._blacklistMap.keys()]))).catch(e=>(s.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)));{const t=Ws.CANNOT_ADD_SELF_TO_BLACKLIST,o=this._userM.getErrorMessage(t);s.setCode(t).setMessage(o).end();var e=new Hs({code:t});return Ie.e(i+" failed. error:",e),Xs(e)}}_handleResponse(n,r){if(!Re(n)){let s,i,o;for(let e=0,t=n.length;e<t;e++)i=n[e].to,o=n[e].resultCode,!$e(o)&&0!==o||(r?((s=this._blacklistMap.has(i)?this._blacklistMap.get(i):new tn).userID=i,Re(n[e].addBlackTimeStamp)||(s.timeStamp=n[e].addBlackTimeStamp),this._blacklistMap.set(i,s)):this._blacklistMap.has(i)&&(s=this._blacklistMap.get(i),this._blacklistMap.delete(i)))}Ie.l(`${this._n}._handleResponse total:${this._blacklistMap.size} bAdd:`+r)}deleteBlacklist(t){const s=this._n+".deleteBlacklist",i=new pi("removeFromBlacklist");return t.fromAccount=this._userM.getMyAccount(),t.toAccount=t.userIDList,this._userM.req({proto:Qs.RM_FROM_BL,data:t}).then(e=>(i.setMessage(5<t.userIDList.length?"userIDList.length:"+t.userIDList.length:"userIDList:"+t.userIDList).end(),Ie.i(s+" ok"),this._handleResponse(e.data.resultItem,!1),Ks([...this._blacklistMap.keys()]))).catch(e=>(i.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}onAccountDeleted(s){for(let e=0,t=s.length;e<t;e++){const i=s[e];this._blacklistMap.has(i)&&this._blacklistMap.delete(i)}const i=s.length;0<i&&(Ie.l(`${this._n}.onAccountDeleted count:${i} `+(i<30?"userIDList:"+s:"")),this._userM.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}onAccountAdded(s){const i=[];var o;for(let e=0,t=s.length;e<t;e++)o=s[e],this._blacklistMap.has(o)||(this._blacklistMap.set(o,new tn({userID:o})),i.push(o));0<i.length&&(Ie.l(`${this._n}.onAccountAdded count:${i.length} userIDList:`,i),this._userM.emitOuterEvent(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}reset(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}const nn=function(e){const o=String(e).replace(/[=]+$/,"");let n="";if(o.length%4==1)return"";for(let e,t,s=0,i=0;t=o.charAt(i++);~t&&(e=s%4?64*e+t:t,s++%4)&&(n+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(n))}catch(e){return""}};class on{constructor(e){this._userM=e,this._n="UserStatusHandler",this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100,this._userM.getInnerEmitterInstance().on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var e=this._userM.getCloudConfig("status_query_count"),t=this._userM.getCloudConfig("status_sub_count"),s=this._userM.getCloudConfig("status_unsub_count");Ie.l(this._n+`._onCloudConfigUpdated statusQueryCount:${e} statusSubscribeCount:${t} statusUnsubscribeCount:`+s),$e(e)||(this.MAX_QUERY_USER_COUNT=parseInt(e,10)),$e(e)||(this.MAX_SUBSCRIBE_USER_COUNT=parseInt(t,10)),$e(e)||(this.MAX_UNSUBSCRIBE_USER_COUNT=parseInt(s,10))}onUserStatusUpdated(t){const s=t["dataList"],i=this._userM.getMyUserID(),o=this._userM.get(ys),n=s.map(e=>{var{to:e,statusType:t,customStatus:s}=e,s=nn(s);return e===i&&o.setCustomStatus(s),{userID:e,statusType:t,customStatus:s}});this._userM.emitOuterEvent(e.USER_STATUS_UPDATED,n)}setSelfStatus(e){const t=this._n+".setSelfStatus";if(!1===this._userM.filterProfanity("customStatus",e))return Xs({code:Ws.PROFANITY_FOUND});const s=new pi("setSelfStatus"),i=e["customStatus"];return this._userM.req({proto:Qs.SET_SELF_STATUS,data:{customStatus:i}}).then(e=>(s.setMessage("customStatus:"+i).end(),Ie.l(t+" ok. customStatus:"+i),this._userM.get(ys).setCustomStatus(i),Ks({userID:this._userM.getMyUserID(),statusType:1,customStatus:i}))).catch(e=>(s.setError(e).end(),Ie.e(t+" failed. error:",e),Xs(e)))}getUserStatus(e){const n=this._n+".getUserStatus",{userIDList:r=[]}=e,t=this._userM.getMyUserID();let s=[...r],a=void 0;var i=s.indexOf(t);if(-1<i){s.splice(i,1);const e=this._userM.get(ys).getCustomStatus();a={userID:t,statusType:1,customStatus:e}}if(0===s.length)return js({successUserList:[a],failureUserList:[]});if(!this._userM.canIUse(I.USER_STATUS))return this._userM.cannotUseCommercialAbility("getUserStatus");s.length>this.MAX_QUERY_USER_COUNT&&(Ie.w(n+" "+yt(this.MAX_QUERY_USER_COUNT)),s=r.slice(0,this.MAX_QUERY_USER_COUNT));const c=new pi("getUserStatus");return this._userM.req({proto:Qs.GET_USER_STATUS,data:{userIDList:s}}).then(e=>{const{successUserList:t=[],failureUserList:s=[]}=e.data,i=t.map(e=>{var{userID:e,statusType:t,customStatus:s}=e;return{userID:e,statusType:t,customStatus:nn(s)}}),o=s.map(e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Re(t)?e:t,code:s,message:i}});$e(a)||i.unshift(a);e=`userID count:${r.length}, success count:${i.length}, fail count:`+o.length;return c.setMessage(e).end(),Ie.l(n+` ok. ${e}.`),Ks({successUserList:i,failureUserList:o})}).catch(e=>(c.setMessage("userID count:"+r.length).setError(e).end(),Ie.e(n+" failed. error:",e),Xs(e)))}subscribeUserStatus(e){var t="subscribeUserStatus";if(!this._userM.canIUse(I.USER_STATUS))return this._userM.cannotUseCommercialAbility(t);const i=this._n+"."+t,{userIDList:s=[]}=e;let o=[...s];o.length>this.MAX_SUBSCRIBE_USER_COUNT&&(Ie.w(i+" "+yt(this.MAX_SUBSCRIBE_USER_COUNT)),o=s.slice(0,this.MAX_SUBSCRIBE_USER_COUNT));const n=new pi(t),r="userID count:"+s.length;return Ie.l(i+" "+r),this._userM.req({proto:Qs.SUB_USER_STATUS,data:{userIDList:o}}).then(e=>{const{failureUserList:t=[]}=e.data,s=t.map(e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Re(t)?e:t,code:s,message:i}});return n.setMessage(r+" fail count:"+s.length).end(),Ie.l(i+` ok. fail count:${s.length}.`),Ks({failureUserList:s})}).catch(e=>(n.setMessage(r).setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}unsubscribeUserStatus(e){var t="unsubscribeUserStatus";if(!this._userM.canIUse(I.USER_STATUS))return this._userM.cannotUseCommercialAbility(t);const i=this._n+"."+t,{userIDList:s=[]}=e||{};let o=[...s];s.length>this.MAX_UNSUBSCRIBE_USER_COUNT&&(Ie.w(i+" "+yt(this.MAX_UNSUBSCRIBE_USER_COUNT)),o=s.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT));const n=new pi(t),r="userID count:"+s.length,a=(Ie.l(i+" "+r),{userIDList:o});return 0===o.length&&(a.userIDList=void 0,a.unsubscribeAll=1),this._userM.req({proto:Qs.UNSUB_USER_STATUS,data:a}).then(e=>{const{failureUserList:t=[]}=e.data,s=t.map(e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Re(t)?e:t,code:s,message:i}});return n.setMessage(r+" fail count:"+s.length).end(),Ie.l(i+` ok. fail count:${s.length}.`),Ks({failureUserList:s})}).catch(e=>(n.setMessage(r).setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class rn extends Js{constructor(e){super(e),this._n="UserModule",this._profileHandler=new en(this),this._blacklistHandler=new sn(this),this._userStatusHandler=new on(this),this.getInnerEmitterInstance().on(Pi.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}mockOnNickAvatarModified(e,t){Ie.l(this._n+`._mockOnNickAvatarModified nick:${e} avatar:`+t),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:Ce.NICK,value:e},{tag:Ce.AVATAR,value:t}]}]})}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){const t=e["dataList"];if(!Re(t)){const s=[],i=(t.forEach(e=>{e.blackListDelAccount&&s.push(...e.blackListDelAccount)}),0<s.length&&this._blacklistHandler.onAccountDeleted(s),[]);t.forEach(e=>{e.blackListAddAccount&&i.push(...e.blackListAddAccount)}),0<i.length&&this._blacklistHandler.onAccountAdded(i)}}onConversationsProfileUpdated(e){this._profileHandler.onConversationsProfileUpdated(e)}getMyAccount(){return this.getMyUserID()}getMyNick(){return this._profileHandler.getNickAndAvatarByUserID(this.getMyUserID()).nick}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.get(Ds)}filterProfanity(e,t){const s=this.get($s);if(!s)return!0;var{isAllowedToSend:i,modifiedText:o}=s.filterText(t[e],D);return!0===i&&(t[e]=o,!0)}isMyFriend(e){const t=this.get(fs);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)}getUserNickAndAvatar(e){return this._profileHandler.getUserNickAndAvatar(e)}getLocalBlacklist(){var e=this._blacklistHandler.getLocalBlacklist();return js(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(){Ie.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class an{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="3.2.4",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,this._applicationID=0,this._isUsingChatCore=!1,this._uiPlatform=0}isLoggedIn(){return this._isLoggedIn}isOversea(){return this._oversea}isPrivateNetWork(){return this._proxyServer}isDevMode(){return this._isDevMode}isSingaporeSite(){return 2e7<=this._SDKAppID&&this._SDKAppID<3e7||172e7<=this._SDKAppID&&this._SDKAppID<173e7}isKoreaSite(){return 3e7<=this._SDKAppID&&this._SDKAppID<4e7||173e7<=this._SDKAppID&&this._SDKAppID<174e7}isGermanySite(){return 4e7<=this._SDKAppID&&this._SDKAppID<5e7||174e7<=this._SDKAppID&&this._SDKAppID<175e7}isIndiaSite(){return 5e7<=this._SDKAppID&&this._SDKAppID<6e7||175e7<=this._SDKAppID&&this._SDKAppID<176e7}isJapanSite(){return 6e7<=this._SDKAppID&&this._SDKAppID<7e7||176e7<=this._SDKAppID&&this._SDKAppID<177e7}isUSASite(){return 7e7<=this._SDKAppID&&this._SDKAppID<8e7||177e7<=this._SDKAppID&&this._SDKAppID<178e7}isIndonesiaSite(){return 8e7<=this._SDKAppID&&this._SDKAppID<9e7||178e7<=this._SDKAppID&&this._SDKAppID<179e7}isIntl(){return 0===(e=this._SDKAppID)||2e7<=e&&e<9e7||172e7<=e&&e<179e7;var e}isUnlimitedAVChatRoom(){return this._unlimitedAVChatRoom}isUsingChatCore(){return this._isUsingChatCore}setUsingChatCore(e){this._isUsingChatCore=e}getUIPlatform(){return this._uiPlatform}setUIPlatform(e){this._uiPlatform=e}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 ie?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}setApplicationID(e){this._applicationID=e}getApplicationID(){return this._applicationID}_isTUIKit(){let s=!1,e=!1,t=!1,i=!1,o=[];G&&(o=Object.keys(F));for(let e=0,t=(o=k?U?Object.keys(uni):Object.keys(window):o).length;e<t;e++)if(o[e].toLowerCase().includes("uikit")){s=!0;break}if(o=null,G&&!be(F.createGamePortal)&&be(getApp)&&!$e(getApp())){const s=getApp().globalData;ke(s)&&!0===s.isTUIKit&&(e=!0)}!0===this._m.get(Ds).getStorageSync(`TIM_${this._SDKAppID}_isTUIKit`)&&(t=!0);let n=null;if(E&&!R&&"undefined"==typeof uni&&__wxConfig&&(n=__wxConfig.pages),A&&"undefined"==typeof uni&&__qqConfig&&(n=__qqConfig.pages),Fe(n)&&0<n.length){for(let e=0,t=n.length;e<t;e++)if(n[e].toLowerCase().includes("tui")){i=!0;break}n=null}return s||e||t||i}reset(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}const cn={"k-vue2-pc":1,"k-vue2-h5":2,"k-vue2-h5-uni":3,"k-vue2-app-uni":4,"k-vue2-mp-uni":5,"k-vue2-pc-uni":6,"k-vue3-pc":7,"k-vue3-h5":8,"k-vue3-h5-uni":9,"k-vue3-app-uni":10,"k-vue3-mp-uni":11,"k-vue3-pc-uni":12};class un extends Js{constructor(e){super(e),this._n="SignModule",this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0,Ui.mixin(this)}onCheckTimer(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}login(e){if(this.isLoggedIn()){const e=this.getMyUserID();return(t=this.getErrorMessage("RepeatLogin",e))&&Ie.w(t),js({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.outputWarning("LoggingIn",e.userID),Xs({code:Ws.REPEAT_LOGIN});Ie.l(this._n+".login userID:"+e.userID);var t=this._checkLoginInfo(e);if(0!==t.code)return Xs(t);const s=this.get(ys),{userID:i,userSig:o}=e;return s.setUserID(i),s.setUserSig(o),this.get(Ls).updateProtocolConfig(),this._login()}_login(){const m=this.get(ys);let I=m.getScene(),e=0,t=I;I&&I.startsWith("k-")&&(t=cn[I],I="tuikit");const M=new pi("login");M.setMessage(""+t).setMoreMessage("identifier:"+this.getMyUserID());var s="tuikit"===I;let i=0;U?i=s?3===t||4===t||5===t||6===t?31:9===t||10===t||11===t||12===t?32:4:3:G?i="tuikit"===I?12:11:k&&(i=ie?"flutter_web_uikit"===I?21:20:this._isReactUIKit()?se?25:24:s?1===t||2===t?29:7===t||8===t?30:se?17:14:se?16:13),M.setUIPlatform(i),m.setUIPlatform(i);const o=this.get(Fs);if(o.canIUseOfflinePush()){this._isWebUniapp=o.getUniAppPlatform();const I=this._getStatusInstanceID();m.setStatusInstanceID(I),this.get(Ls).updateProtocolConfig(),e=o.getDeviceBrand()}const f=this._n+"._login";return this._lastLoginTs=Date.now(),this.req({proto:Qs.LOGIN,data:{deviceBrand:e,isWebUniapp:this._isWebUniapp}}).then(e=>{this._lastLoginTs=0;var t=Date.now();let s=null;var{a2Key:i,tinyID:o,helloInterval:n,instanceID:r,timeStamp:d,customStatus:u="",purchaseBits:_}=e.data,a=1e3*d,c=t-M.getStartTs(),c=a+parseInt(c/2)-t,t=M.getStartTs()+c;M.start(t);{t=a,a=c,de=a;const l=new Date;l.setTime(t),Ie.i(`baseTime from server:${l} offset:`+de)}if(!o)throw s=new Hs({code:Ws.NO_TINYID}),M.setError(s).end(),s;if(!i)throw s=new Hs({code:Ws.NO_A2KEY}),M.setError(s).end(),s;a=nn(u),t=`scene:${I} helloInterval:${n} instanceID:${r} timeStamp:${d} offset:${c} customStatus:${a} `;Ie.l(f+" ok. "+t);let p="",h="";if(E&&be(F.getAccountInfoSync)){const m=F.getAccountInfoSync().miniProgram;m&&(p=m.appId,h=m.envVersion)}M.setMoreMessage(t+` href:${k?window.location.href:""} mpAppId:${p} envVersion:`+h).end(),m.setA2Key(i),m.setTinyID(o),m.setStatusInstanceID(r),m.setCustomStatus(a),_&&this.get(ks).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:_}),this.get(Ls).updateProtocolConfig(),this.emitInnerEvent(Pi.A2KEY_AND_TINYID_UPDATED),this._helloInterval=n,this.triggerReady();const g=this.get(Fs);return g.canIUseOfflinePush()&&(uni.setStorageSync("timUniAppInstanceID",r),g.init()),this._fetchCloudControlConfig(),this.get($s).init(),e}).catch(e=>(M.setError(e).end(!0),this._m.setNotReadyReason(Ws.LOGIN_FAILED),Ie.e(f+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),Xs(e)))}logout(e=0){if(!this.isLoggedIn())return Xs({code:Ws.USER_NOT_LOGGED_IN});new pi("logout").setMessage("identifier:"+this.getMyUserID()).end(!0);const t=this._n+".logout";return Ie.i(t+" type:"+e),0===e&&this._m.setNotReadyReason(Ws.LOGGED_OUT),this.req({proto:Qs.LOGOUT,data:{type:e}}).then(()=>(this.resetReady(),js({}))).catch(e=>(Ie.e(t+" error:",e),this.resetReady(),js({})))}getLoginUser(){return this.isLoggedIn()?this.getMyUserID():""}_fetchCloudControlConfig(){this.get(Os).fetchConfig()}_getStatusInstanceID(){return uni.getStorageSync("timUniAppInstanceID")}_hello(){this._lastWsHelloTs=Date.now(),this.req({proto:Qs.HELLO,data:{isWebUniapp:this._isWebUniapp}}).catch(e=>{Ie.w(this._n+"._hello error:",e)})}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return Re(this.get(ys).getSDKAppID())?t=Ws.NO_SDKAPPID:Re(e.userID)?t=Ws.NO_IDENTIFIER:Re(e.userSig)&&(t=Ws.NO_USERSIG),{code:t}}_isReactUIKit(){return k&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(s){new pi("kickedOut").setMessage(`type:${t.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:`+JSON.stringify(s)).end(!0),Ie.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(Ws.KICKED_OUT_MULT_ACCOUNT),this._m.reset()})}onMultipleDeviceKickedOut(s){new pi("kickedOut").setMessage(`type:${t.KICKED_OUT_MULT_DEVICE} newInstanceInfo:`+JSON.stringify(s)).end(!0),Ie.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(Ws.KICKED_OUT_MULT_DEVICE),this._m.reset()})}onUserSigExpired(){new pi("kickedOut").setMessage(t.KICKED_OUT_USERSIG_EXPIRED).end(!0),Ie.w(this._n+".onUserSigExpired userID:"+this.getMyUserID()),0!==this.get(ys).getStatusInstanceID()&&(this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(Ws.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(s){new pi("kickedOut").setMessage(`type:${t.KICKED_OUT_REST_API} newInstanceInfo:`+JSON.stringify(s)).end(!0),Ie.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),0!==this.get(ys).getStatusInstanceID()&&(this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_REST_API}),this._m.setNotReadyReason(Ws.KICKED_OUT_REST_API),this._m.reset(),this.get(Ns).onRestApiKickedOut())}reset(){Ie.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function ln(){return null}class dn{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){G||!$e(window)&&this._canIUseCookies()||(this.getItem=ln,this.setItem=ln,this.removeItem=ln,this.clear=ln)}onCheckTimer(e){e%20==0&&0!==this._storageQueue.size&&this._doFlush()}_doFlush(){try{for(var[e,t]of this._storageQueue)this._setStorageSync(this._getKey(e),t);this._storageQueue.clear()}catch(e){Ie.w(this._n+"._doFlush error:",e)}}_getPrefix(){const e=this._m.get(ys);return`TIM_${e.getSDKAppID()}_${e.getUserID()}_`}_getKey(e){return""+this._getPrefix()+e}getItem(e,t=!0){try{var s=t?this._getKey(e):e;return this.getStorageSync(s)}catch(e){return Ie.w(this._n+".getItem error:",e),{}}}setItem(e,t,s=!1,i=!0){if(s){const s=i?this._getKey(e):e;this._setStorageSync(s,t)}else this._storageQueue.set(e,t)}clear(){try{G?F.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){Ie.w(this._n+".clear error:",e)}}removeItem(e,t=!0){try{var s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(e){Ie.w(this._n+".removeItem error:",e)}}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}),G&&(s.limitSize=1024*F.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(G){const e=F.getStorageInfoSync()["keys"];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(e){Ie.w(this._n+" error:",e)}}_convertUnit(e){const t={},s=e["unit"];t.unit=s;for(const i in e)"number"==typeof e[i]&&("kb"===s.toLowerCase()?t[i]=Math.round(e[i]/1024):"mb"===s.toLowerCase()?t[i]=Math.round(e[i]/1024/1024):t[i]=e[i]);return t}_setStorageSync(e,t){G?N?my.setStorageSync({key:e,data:t}):F.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){return G?N?my.getStorageSync({key:e}).data:F.getStorageSync(e):this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){G?N?my.removeStorageSync({key:e}):F.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return navigator&&navigator.cookieEnabled&&localStorage}reset(){Ie.l(this._n+".reset"),this._doFlush()}}class _n{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){Ie.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){Fe(e)&&0!==e.length&&(Ie.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(){var e=this._report.slice();return this._reset(),e}}const pn=function(e){const t=e.get(ys);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:_e()}};class hn extends Js{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new _n,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(Pi.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),t.on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}reportAtOnce(){this._report()}_onLoginSuccess(){const e=this.get(Ds),t=e.getItem(this.TAG,!1);!Re(t)&&be(t.forEach)&&(Ie.l(this._n+"._onLoginSuccess. logs 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"),i=this.getCloudConfig("evt_rpt_sdkappid_bl"),o=this.getCloudConfig("evt_rpt_tinyid_wl");$e(e)||(this.MIN_THRESHOLD=Number(e)),$e(t)||(this.WAITING_TIME=Number(t)),$e(s)||(this.REPORT_LEVEL=s.split(",").map(e=>Number(e))),$e(i)||(this.REPORT_SDKAPPID_BLACKLIST=i.split(",").map(e=>Number(e))),$e(o)||(this.REPORT_TINYID_WHITELIST=o.split(","))}pushIn(e){e instanceof pi&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}onCheckTimer(){Date.now()<this._lastReportTime+this.WAITING_TIME||this._reportBody.isEmpty()||this._report()}_filterLogs(e){const t=this.get(ys),s=t.getSDKAppID(),i=t.getTinyID();return mt(this.REPORT_SDKAPPID_BLACKLIST,s)&&!Mt(this.REPORT_TINYID_WHITELIST,i)?[]:e.filter(e=>this.REPORT_LEVEL.includes(e.level))}_report(){if(!this._reportBody.isEmpty()){const t=this._reportBody.getLogsInMemory(),s=this._filterLogs(t);var e;0!==s.length?(e={header:pn(this),event:s},this.req({proto:Qs.SSO_STAT,data:{...e}}).then(()=>{this._lastReportTime=Date.now()}).catch(e=>{Ie.w(this._n+"._report failed. error:",e),this._lastReportTime=Date.now(),this._reportBody.backfill(t),this._reportBody.getLogsNumInMemory()>this.MAX_THRESHOLD&&this._flushAtOnce()})):this._lastReportTime=Date.now()}}_flushAtOnce(){const t=this.get(Ds),s=t.getItem(this.TAG,!1),i=this._reportBody.getLogsInMemory(),o=this._n+"._flushAtOnce";if(Re(s))Ie.l(o+" count:"+i.length),t.setItem(this.TAG,i,!0,!1);else{let e=i.concat(s);e.length>this.MAX_THRESHOLD&&(e=e.slice(0,this.MAX_THRESHOLD)),Ie.l(o+" count:"+e.length),t.setItem(this.TAG,e,!0,!1)}}reset(){Ie.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}const gn="none",mn="online";class Mn{constructor(e){this._m=e,this._networkType=mn,this._n="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}start(){const t=this._n+".start";G?(F.getNetworkType({success:e=>{this._networkType=e.networkType||e.subtype||"",e.networkType===gn?Ie.w(t+" no network, please check!"):Ie.i(t+" networkType:"+e.networkType)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),F.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=mn,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:mn})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:gn})}_onNetworkStatusChange(e){var{isConnected:e,networkType:t}=e,s=this._n+"._onNetworkStatusChange";let i=!1;var o=`previous:${this._networkType} current:`+t;e?(Ie.i(s+" "+o),this._networkType!==t&&(i=!0,this._m.get(Ns).reConnect(!0))):this._networkType!==t&&(i=!0,Ie.w(s+" no network, please check!"),this._m.get(Ns).offline()),i&&(new pi("networkChange").setMessage(`isConnected:${e} `+o).end(),this._networkType=t)}isOnline(){return this._networkType!==gn}getNetworkType(){return this._networkType}reset(){Ie.l(this._n+".reset"),G?null!==this._mpNetworkStatusCallback&&(F.offNetworkStatusChange&&(P||R?F.offNetworkStatusChange(this._mpNetworkStatusCallback):F.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))}}var In=function(e){return o=e={exports:{}},r=Object.prototype.hasOwnProperty,p="~",Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(p=!1)),t.prototype.eventNames=function(){var e,t,s=[];if(0===this._eventsCount)return s;for(t in e=this._events)r.call(e,t)&&s.push(p?t.slice(1):t);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},t.prototype.listeners=function(e){var e=p?p+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var s=0,i=t.length,o=new Array(i);s<i;s++)o[s]=t[s].fn;return o},t.prototype.listenerCount=function(e){e=p?p+e:e,e=this._events[e];return e?e.fn?1:e.length:0},t.prototype.emit=function(e,t,s,i,l,d){var u=p?p+e:e;if(!this._events[u])return!1;var o,n=this._events[u],r=arguments.length;if(n.fn){switch(n.once&&this.removeListener(e,n.fn,void 0,!0),r){case 1:return n.fn.call(n.context),!0;case 2:return n.fn.call(n.context,t),!0;case 3:return n.fn.call(n.context,t,s),!0;case 4:return n.fn.call(n.context,t,s,i),!0;case 5:return n.fn.call(n.context,t,s,i,l),!0;case 6:return n.fn.call(n.context,t,s,i,l,d),!0}for(c=1,o=new Array(r-1);c<r;c++)o[c-1]=arguments[c];n.fn.apply(n.context,o)}else for(var a,_=n.length,c=0;c<_;c++)switch(n[c].once&&this.removeListener(e,n[c].fn,void 0,!0),r){case 1:n[c].fn.call(n[c].context);break;case 2:n[c].fn.call(n[c].context,t);break;case 3:n[c].fn.call(n[c].context,t,s);break;case 4:n[c].fn.call(n[c].context,t,s,i);break;default:if(!o)for(a=1,o=new Array(r-1);a<r;a++)o[a-1]=arguments[a];n[c].fn.apply(n[c].context,o)}return!0},t.prototype.on=function(e,t,s){return i(this,e,t,s,!1)},t.prototype.once=function(e,t,s){return i(this,e,t,s,!0)},t.prototype.removeListener=function(e,t,s,i){e=p?p+e:e;if(!this._events[e])return this;if(!t)return c(this,e),this;var o=this._events[e];if(o.fn)o.fn!==t||i&&!o.once||s&&o.context!==s||c(this,e);else{for(var n=0,r=[],a=o.length;n<a;n++)(o[n].fn!==t||i&&!o[n].once||s&&o[n].context!==s)&&r.push(o[n]);r.length?this._events[e]=1===r.length?r[0]:r:c(this,e)}return this},t.prototype.removeAllListeners=function(e){return e?(e=p?p+e:e,this._events[e]&&c(this,e)):(this._events=new s,this._eventsCount=0),this},t.prototype.off=t.prototype.removeListener,t.prototype.addListener=t.prototype.on,t.prefixed=p,o.exports=t.EventEmitter=t,e.exports;function s(){}function n(e,t,s){this.fn=e,this.context=t,this.once=s||!1}function i(e,t,s,i,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");s=new n(s,i||e,o),i=p?p+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],s]:e._events[i].push(s):(e._events[i]=s,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function t(){this._events=new s,this._eventsCount=0}var o,r,p}();const fn=9999,Cn=1e4;class Tn extends Js{constructor(e){super(e),this._n="UploadModule",this.TIMUploadPlugin=null,this.timUploadPlugin=null,this.COSSDK=null,this._cosUploadMethod=null,this.expiredTimeLimit=600,this.appid=0,this.bucketName="",this.ciUrl="",this.directory="",this.downloadUrl="",this.uploadUrl="",this.region="ap-shanghai",this.cos=null,this.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},this.uploadFileType="",this.duration=900,this.tryCount=0,this.UPLOAD_SIZE_LIMIT={A:20971520,F:104857600,I:20971520,V:104857600},this.isSimpleCos=!1;const t=this.getInnerEmitterInstance();t.on(Pi.A2KEY_AND_TINYID_UPDATED,this._init,this),t.on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){const e=this.get(As);var t;this.TIMUploadPlugin=e.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin?this._initUploaderMethod():(t=G?"cos-wx-sdk":"cos-js-sdk",this.COSSDK=e.getPlugin(t),this.COSSDK?(this._getAuthorizationKey(),this.outputWarning("CosReplacement",t)):this.outputWarning("PluginUndetected"))}_onCloudConfigUpdated(){const e=this._n+"._onCloudConfigUpdated",t=this.getCloudConfig("upload_size_limit"),s=this.getCloudConfig("simple_cos");if(Ie.l(e+` uploadSizeLimit:${t} simpleCos:`+s),!$e(t))try{const e=JSON.parse(t);this.UPLOAD_SIZE_LIMIT={A:e.a?1048576*parseInt(e.a):this.UPLOAD_SIZE_LIMIT.A,F:e.f?1048576*parseInt(e.f):this.UPLOAD_SIZE_LIMIT.F,I:e.i?1048576*parseInt(e.i):this.UPLOAD_SIZE_LIMIT.I,V:e.v?1048576*parseInt(e.v):this.UPLOAD_SIZE_LIMIT.V}}catch(e){}$e(s)||(this.isSimpleCos="1"===s)}_getAuthorizationKey(){const s=this._n+"._getAuthorizationKey",i=new pi("_getAuthorizationKey"),o=Math.ceil(Date.now()/1e3);this.req({proto:Qs.COS_SIGN,data:{duration:this.expiredTimeLimit}}).then(e=>{var e=e["data"],t=(Ie.l(s+" ok. data:",e),e.expiredTime-o);i.setMessage(`requestId:${e.requestId} requestTime:${o} expiredTime:${e.expiredTime} diff:${t}s`).end(),!G&&e.region&&(this.region=e.region),this.appid=e.appid,this.bucketName=e.bucketName,this.ciUrl=e.ciUrl,this.directory=e.directory,this.downloadUrl=e.downloadUrl,this.uploadUrl=e.uploadUrl,this.cosOptions={secretId:e.secretId,secretKey:e.secretKey,sessionToken:e.sessionToken,expiredTime:e.expiredTime},Ie.l(s+` ok. region:${this.region} bucketName:`+this.bucketName),this._initUploaderMethod()}).catch(e=>{i.setError(e).end(),Ie.w(s+" failed. error:",e)})}_getCosPreSigUrl(t){const i=this._n+"._getCosPreSigUrl",o=Math.ceil(Date.now()/1e3),n=new pi("_getCosPreSigUrl");let e={uploadMethod:t.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:t.userID,conversationType:t.conversationType,uploadConfig:[{fileID:1,fileType:t.fileType,fileName:t.fileName}]},s=Qs.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(e={fileType:t.fileType,fileName:t.fileName,uploadMethod:t.uploadMethod,duration:t.duration},s=Qs.COS_PRE_SIG),this.req({proto:s,data:e}).then(e=>{this.tryCount=0;var t=e.data||{};Ie.l(`${i} ok. isSimpleCos:${this.isSimpleCos} data:`,t);let s="";if(this.isSimpleCos){const{uploadUrl:e,fileKey:i}=t.preSig[0];s=`uploadIP:${t.uploadIP} uploadUrl:${e} fileKey:${i} cost:`+St(o)}else s=`requestId:${t.requestId} expiredTime:${t.expiredTime} diff:${t.expiredTime-o}s`;return n.setMessage(s).end(),t}).catch(e=>(-1===e.code&&(e.code=Ws.COS_GET_SIG_FAIL),n.setError(e).end(),Ie.w(i+" failed. error:",e),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(t)):(this.tryCount=0,Xs({code:Ws.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=G?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=G?(e,t)=>{this.cos.postObject(e,t)}:(e,t)=>{this.cos.uploadFiles(e,t)})}onCheckTimer(e){this.COSSDK&&(this.TIMUploadPlugin||this.isLoggedIn()&&e%60==0&&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._relayFlag)return Promise.resolve();const s=this.get(Gs);switch(e.type){case t.MSG_IMAGE:return s.addTotalCount(oi),this._uploadImage(e);case t.MSG_FILE:return s.addTotalCount(oi),this._uploadFile(e);case t.MSG_AUDIO:return s.addTotalCount(oi),this._uploadAudio(e);case t.MSG_VIDEO:return s.addTotalCount(oi),this._uploadVideo(e);default:return Promise.resolve()}}_uploadImage(g){const e=this.get(hs),m=g.getElements()[0],t=e.getMessageOption(g.clientSequence);return this.doUploadImage({file:t.payload.file,to:t.to,message:g,onProgress:e=>{if(m.updatePercent(e),be(t.onProgress))try{t.onProgress(e)}catch(e){return Xs({code:Ws.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(t=>{var{location:t,fileType:e,fileSize:d,width:s,height:i,smallImageUrl:o,smallImageWidth:u,smallImageHeight:_,largeImageUrl:n,largeImageWidth:p,largeImageHeight:h,imageInfoArray:r}=t,t=this.isPrivateNetWork()?t:Qe(t);m.updateImageFormat(e);let a,c,l={size:d,url:t,width:s,height:i};if(r&&0<r.length)for(let e=0;e<r.length;e++){const t=r[e];1===t.type?a=t:2===t.type?c=t:l={...l,...t}}else c=o&&n?(a={url:o,width:u,height:_},{url:n,width:p,height:h}):(a=_t({originUrl:t,originWidth:s,originHeight:i,min:198}),_t({originUrl:t,originWidth:s,originHeight:i,min:720}));return m.updateImageInfoArray([{...l},{...c},{...a}]),g})}_uploadFile(t){const e=this.get(hs),s=t.getElements()[0],i=e.getMessageOption(t.clientSequence);return this.doUploadFile({file:i.payload.file,to:i.to,message:t,onProgress:e=>{if(s.updatePercent(e),be(i.onProgress))try{i.onProgress(e)}catch(e){return Xs({code:Ws.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:e})=>{e=this.isPrivateNetWork()?e:Qe(e);return s.updateFileUrl(e),t})}_uploadAudio(t){const e=this.get(hs),s=t.getElements()[0],i=e.getMessageOption(t.clientSequence);return this.doUploadAudio({file:i.payload.file,to:i.to,message:t,onProgress:e=>{if(s.updatePercent(e),be(i.onProgress))try{i.onProgress(e)}catch(e){return Xs({code:Ws.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(({location:e})=>{e=this.isPrivateNetWork()?e:Qe(e);return s.updateAudioUrl(e),t})}_uploadVideo(s){const e=this.get(hs),i=s.getElements()[0],t=e.getMessageOption(s.clientSequence);return this.doUploadVideo({file:t.payload.file,to:t.to,message:s,onProgress:e=>{if(i.updatePercent(e),be(t.onProgress))try{t.onProgress(e)}catch(e){return Xs({code:Ws.MSG_ONPROGRESS_FUNCTION_ERROR})}}}).then(e=>{var{location:e,snapshotInfo:t}=e,e=this.isPrivateNetWork()?e:Qe(e);return i.updateVideoUrl(e),Re(t)||i.updateSnapshotInfo(t),s})}_checkSizeError(e){let t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),Xs({code:Ws[`MSG_${e}_SIZE_LIMIT`],message:this.getErrorMessage("UploadSizeLimit",t,this.UPLOAD_SIZE_LIMIT[e]/1048576+"MB")})}doUploadImage(e){if(!e.file||this._isEmptyFileList(e.file.files))return Xs({code:Ws.MSG_I_SELECT_F_FIRST});var t=this._checkImageType(e.file);if(!0!==t)return t;t=this._checkImageSize(e.file);if(!0!==t)return t;let s=null;return this._setUploadFileType(Fi),this.uploadByCOS(e).then(e=>{var t;if(s=e,this.isPrivateNetWork())return t=this.getFileDownloadProxy(),ct(Dt(e.location,t));if(Fe(s.imageInfoArray)){const e=s.imageInfoArray.find(e=>3===e.type);if(e)return e}return ct("https://"+e.location)}).then(e=>(s.width=e.width,s.height=e.height,Promise.resolve(s)))}_checkImageType(e){let t="";return t=G?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),0<=Gi.indexOf(t.toLowerCase())||Xs({code:Ws.MSG_I_TYPES_LIMIT})}_checkImageSize(e){return 0===(e=(G?e:e.files[0]).size)?Xs({code:Ws.MSG_F_IS_EMPTY}):e<this.UPLOAD_SIZE_LIMIT.I||this._checkSizeError("I")}doUploadFile(e){let t=null;return!e.file||this._isEmptyFileList(e.file.files)?(t={code:Ws.MSG_F_SELECT_F_FIRST},Xs(t)):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?(t={code:Ws.MSG_F_IS_EMPTY},Xs(t)):(this._setUploadFileType(bi),this.uploadByCOS(e))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?Xs({code:Ws.MSG_F_IS_EMPTY}):-1===ki.indexOf(e.file.videoFile.type)?Xs({code:Ws.MSG_V_TYPES_LIMIT}):(this._setUploadFileType($i),G?this.handleVideoUpload({...e,file:e.file.videoFile}):k?this.handleVideoUpload(e):void 0)}handleVideoUpload(s){return new Promise((t,e)=>{this.uploadByCOS(s).then(e=>{t(e)}).catch(()=>{this.uploadByCOS(s).then(e=>{t(e)}).catch(()=>{e(new Hs({code:Ws.MSG_V_UPLOAD_FAIL}))})})})}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?Xs({code:Ws.MSG_F_IS_EMPTY}):(this._setUploadFileType(wi),this.uploadByCOS(e)):Xs({code:Ws.MSG_A_UPLOAD_FAIL})}uploadByCOS(t){if(!be(this._cosUploadMethod))return this.outputWarning("PluginUndetected"),Xs({code:Ws.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(t);const l=new pi("upload"),d=this._n+".uploadByCOS",u=Date.now(),_=this._getFile(t);return new Promise((r,a)=>{const e=G?this._createCosOptionsWXMiniApp(t):this._createCosOptionsWeb(t),c=this;this._cosUploadMethod(e,(e,t)=>{const s=Object.create(null);if(t){if(e||Fe(t.files)&&t.files[0].error){const e=new Hs({code:Ws.MSG_F_UPLOAD_FAIL});return l.setError(e).end(),Ie.l(d+" failed. error:",t.files[0].error),403===t.files[0].error.statusCode&&(Ie.w(d+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),void a(e)}s.fileName=_.name,s.fileSize=_.size,s.fileType=_.type.slice(_.type.indexOf("/")+1).toLowerCase(),s.location=(G?t:t.files[0].data).Location;const i=Date.now()-u,o=`size:${c._formatFileSize(_.size)} time:${i}ms speed:`+c._formatSpeed(1e3*_.size/i),n=(Ie.l(d+` success. name:${_.name} `+o),r(s),this.get(Gs));return n.addCost(oi,i),n.addFileSize(oi,_.size),void l.setMessage(o).end()}const i=new Hs({code:Ws.MSG_F_UPLOAD_FAIL});l.setError(i).end(),Ie.w(d+" failed. error:",e),403===e.statusCode&&(Ie.w(d+" failed. cos AccessKeyId was invalid, regain auth key!"),this._getAuthorizationKey()),a(i)})})}_uploadWithPreSigUrl(e){const g=this._n+"._uploadWithPreSigUrl",m=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then(h=>new Promise((c,l)=>{const d=new pi("upload"),{requestSnapshotUrl:u,..._}=h,p=Date.now();this._cosUploadMethod(_,(e,t)=>{if(e||403===t.statusCode){d.setError(new Hs(e)).end();const m={HttpStatusCode:fn,CostTime:St(p,!1),error:e,url:h.url};return t.data&&t.data.uploadIP&&(m.uploadIP=t.data.uploadIP),this._uploadSSOLog(m),Ie.l(g+" failed, error:",e),void l(new Hs({code:Ws.MSG_F_UPLOAD_FAIL}))}const s=Object.create(null);let i=t.data.location||"";this.isPrivateNetWork()||0!==i.indexOf("https://")&&0!==i.indexOf("http://")||(i=i.split("//")[1]),s.fileName=m.name,s.fileSize=m.size,s.fileType=m.type.slice(m.type.indexOf("/")+1).toLowerCase(),s.location=i;var e=St(p,!1),o=`size:${this._formatFileSize(m.size)} time:${e}ms speed:${this._formatSpeed(1e3*m.size/e)} res:`+JSON.stringify(t.data);Ie.l(g+` ok. name:${m.name} `+o),d.setMessage(o).end();const n={HttpStatusCode:t.statusCode,FileSize:m.size,CostTime:e,url:h.url},r=(t.data&&t.data.uploadIP&&(n.uploadIP=t.data.uploadIP),this._uploadSSOLog(n),this.get(Gs)),a=(r.addCost(oi,e),r.addFileSize(oi,m.size),[]);if(_.thumbUrl&&_.largeUrl&&a.push(this._getSmallImageInfoByUrl(_.thumbUrl,s),this._getLargeImageInfoByUrl(_.largeUrl,s)),this.uploadFileType===Fi&&this.isSimpleCos&&!this.isPrivateNetWork()&&(a.push(this._getImageInfoArray(_.downloadUrl,s)),t.data.uploadIP&&a.push(this._getDownloadIP(_.downloadUrl.split("//")[1].split("/")[0],s))),u&&a.push(this._getSnapshotInfoByUrl(u,s)),0<a.length)return Promise.all(a).then(()=>{c(s)});c(s)})}))}_getDownloadIP(e,s){const i=this._n+"._getDownloadIP",o=Date.now();return this.req({proto:Qs.GET_IP,data:{domainName:e}}).then(e=>{if(e.data&&e.data.ip){Ie.l(i+` ok. downloadIP:${e.data.ip} cost:`+St(o));const t=s.location.split("/");t[0]=e.data.ip,s.location=t.join("/")}}).catch(e=>{})}_getImageInfoArray(t,s){const i=this._n+"._getImageInfoArray",o=Date.now();return this.req({proto:Qs.GET_IMAGE_INFO,data:{imageUrl:t}}).then(e=>{e=e.data||{};return Ie.l(i+` ok. data: ${JSON.stringify(e)} cost:`+St(o)),s.imageInfoArray=e.imageInfoArray,e}).catch(e=>{s.imageInfoArray=void 0,this._uploadSSOLog({HttpStatusCode:Cn,CostTime:St(o,!1),url:t})})}_uploadSSOLog(t){if(this.isSimpleCos){const s=new pi;s.setEventType(18),t.error&&s.setError(new Hs(t.error));let e=`HttpStatusCode:${t.HttpStatusCode}|CosRequestId:${t.CosRequestId||""}|FileAlreadyExist:${t.FileAlreadyExist||0}|FileSize:${t.FileSize||0}|CostTime:`+t.CostTime;t.uploadIP&&(e+="|FinalIP:"+t.uploadIP),s.setMessage("OK").setMoreMessage(t.url).setExtension(e).end()}}_getRawOrUploadProxyUrl(e){var t=this.get(ys).getFileUploadProxy();let s=e;return s=t?e.replace(/^https:\/\/[^/]+/,t):s}_getFile(e){return Fe(e.file.files)||xe(e.file.files)?e.file.files[0]:e.file}_formatFileSize(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}_formatSpeed(e){return e<=1048576?gt(e/1024,1)+"KB/s":gt(e/1048576,1)+"MB/s"}_createCosOptionsWeb(t){const e=this._getFile(t),s=e.name,i=s.slice(s.lastIndexOf(".")),o=this._genFileName(""+Ye(999999)+i);return{files:[{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+o,Body:e}],SliceSize:1048576,onProgress:e=>{if("function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(e){Ie.w("onProgress callback error:",e)}},onFileFinish:(e,t,s)=>{}}}_createCosOptionsWXMiniApp(t){var e=this._getFile(t),s=this._genFileName(e.name),e=e.url;return{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+s,FilePath:e,onProgress:e=>{if(Ie.l(JSON.stringify(e)),"function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(e){Ie.w("onProgress callback error:",e)}}}}_createCosOptionsPreSigUrl(a){let c="",l="",e=0;var s=this._getFile(a);if(G){if(a.message.type===t.MSG_FILE){const a=s.name,t=a.slice(a.lastIndexOf("."));c=this._genFileName(""+Ye(999999)+t)}else c=this._genFileName(s.name);l=s.url,e=1}else{const a=s.name,t=a.slice(a.lastIndexOf("."));c=this._genFileName(""+Ye(999999)+t),l=s,e=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:c,uploadMethod:e,duration:this.duration,userID:a.message.from,conversationType:nt(a.message.conversationID)?1:2}).then(e=>{var{uploadUrl:t,downloadUrl:s,requestSnapshotUrl:i,thumbUrl:o,largeUrl:n,fileKey:r}=this.isSimpleCos?e.preSig[0]:e,{uploadIP:e=""}=e;return{url:this._getRawOrUploadProxyUrl(t),fileType:this.uploadFileType,fileName:c,resources:l,downloadUrl:s,requestSnapshotUrl:i,thumbUrl:o,largeUrl:n,fileKey:r,uploadIP:!this.isPrivateNetWork()&&e,onProgress:e=>{if("function"==typeof a.onProgress)try{a.onProgress(e.percent)}catch(e){Ie.w("onProgress callback error:",e),Ie.e(e)}}}})}_genFileName(e){return ut()+"-"+e}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,i){const o="_getSnapshotInfoByUrl",n=new pi(o);return this.req({proto:Qs.VIDEO_COVER,data:{platform:this.getPlatform(),coverName:this._genFileName(Ye(99999)),requestSnapshotUrl:e}}).then(e=>{const t=(e.data||{})["snapshotUrl"];if(Ie.l(`${this._n}.${o} ok. snapshotUrl:`+t),n.setMessage("snapshotUrl:"+t).end(),Re(t))return{};let s=t;if(this.isPrivateNetWork()){const e=this.getFileDownloadProxy();s=Dt(t,e)}return ct(s).then(e=>{i.snapshotInfo={snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height}})}).catch(e=>(Ie.w(`${this._n}.${o} failed. error:`,e),n.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}))}_getSmallImageInfoByUrl(t,s){let e=t;if(this.isPrivateNetWork()){const s=this.getFileDownloadProxy();e=Dt(t,s)}return ct(e).then(e=>{s.smallImageUrl=t,s.smallImageWidth=e.width,s.smallImageHeight=e.height})}_getLargeImageInfoByUrl(t,s){let e=t;if(this.isPrivateNetWork()){const s=this.getFileDownloadProxy();e=Dt(t,s)}return ct(e).then(e=>{s.largeImageUrl=t,s.largeImageWidth=e.width,s.largeImageHeight=e.height})}_isEmptyFileList(e){return!(!xe(e)||0!==e.length)}reset(){Ie.l(this._n+".reset")}}class yn{constructor(e){this._n="MergerMessageHandler",this._msgM=e}uploadMergerMessage(e,s){const i=this._n+".uploadMergerMessage",t=(Ie.d(i+" message:",e,"messageBytes:"+s),e.payload)["messageList"],o=t.length,n=new pi("uploadMergerMessage");return this._msgM.req({proto:Qs.UPLOAD_MERGER_MSG,data:{messageList:t}}).then(e=>{Ie.d(i+" ok. response:",e.data);var{pbDownloadKey:e,downloadKey:t}=e.data,e={pbDownloadKey:e,downloadKey:t,messageNumber:o};return n.setMessage(o+`-${s}-`+t).end(),e}).catch(e=>{throw Ie.w(i+" failed. error:",e),n.setError(e).end(),e})}downloadMergerMessage(i){const o=this._n+".downloadMergerMessage",t=(Ie.d(o+" message:",i),i.payload)["downloadKey"],n=this._msgM.getFileDownloadProxy(),r=new pi("downloadMergerMessage");return r.setMessage("downloadKey:"+t),this._msgM.req({proto:Qs.DOWNLOAD_MERGER_MSG,data:{downloadKey:t}}).then(e=>{if(Ie.d(o+" ok. response:",e.data),be(i.clearElement)){const{downloadKey:o,pbDownloadKey:r,messageList:t,...s}=i.payload;i.clearElement(),i.setElement({type:i.type,content:{messageList:e.data.messageList,...s}},n)}else{const o=[];e.data.messageList.forEach(e=>{Re(e)||(e=new vi(e,n),o.push(e))}),i.payload.messageList=o,i.payload.downloadKey="",i.payload.pbDownloadKey=""}return r.end(),i}).catch(e=>{throw Ie.w(`${o} failed. key:${t} error:`,e),r.setError(e).end(),e})}createMergerMessagePack(e,s,i){return e.conversationType===t.CONV_C2C?this._createC2CMergerMessagePack(e,s,i):this._createGroupMergerMessagePack(e,s,i)}_createC2CMergerMessagePack(e,t,s){let i=null;t&&(t.offlinePushInfo&&(i=t.offlinePushInfo),!0===t.onlineUserOnly&&(i?i.disablePush=!0:i={disablePush:!0}));const o=[];if(ke(t)&&ke(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}let n="";Ue(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:d}=s,{title:u,abstractList:_,compatibleText:p}=e.payload,c=this._msgM.get(Ms),l=c&&c.isOnlineMessage(e,t)?0:void 0;return{proto:Qs.SEND_C2C_MSG,tjgID:this._msgM.generateTjgID(e),data:{fromAccount:this._msgM.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:u,abstractList:_,compatibleText:p,messageNumber:d}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:l,offlinePushInfo:i?{pushFlag:!0===i.disablePush?1:0,title:i.title||"",desc:i.description||"",ext:i.extension||"",apnsInfo:{badgeMode:!0===i.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:i.androidOPPOChannelID||""}}:void 0,messageControlInfo:0!==l?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_createGroupMergerMessagePack(e,t,s){let i=null;t&&t.offlinePushInfo&&(i=t.offlinePushInfo);const o=[];if(ke(t)&&ke(t.messageControlInfo)){const{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}let n="";Ue(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);const{pbDownloadKey:r,downloadKey:a,messageNumber:d}=s,{title:u,abstractList:_,compatibleText:p}=e.payload,c=this._msgM.get(Is),l=c&&c.isOnlineMessage(e,t)?1:0;return{proto:Qs.SEND_GRP_MSG,tjgID:this._msgM.generateTjgID(e),data:{fromAccount:this._msgM.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:r,downloadKey:a,title:u,abstractList:_,compatibleText:p,messageNumber:d}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:l,offlinePushInfo:i?{pushFlag:!0===i.disablePush?1:0,title:i.title||"",desc:i.description||"",ext:i.extension||"",apnsInfo:{badgeMode:!0===i.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:i.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||c.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0==l?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}const Dn={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,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},Sn=[Ws.MSG_ONPROGRESS_FUNCTION_ERROR,Ws.MSG_I_SELECT_F_FIRST,Ws.MSG_I_TYPES_LIMIT,Ws.MSG_F_IS_EMPTY,Ws.MSG_I_SIZE_LIMIT,Ws.MSG_F_SELECT_F_FIRST,Ws.MSG_F_SIZE_LIMIT,Ws.MSG_V_SIZE_LIMIT,Ws.MSG_V_TYPES_LIMIT,Ws.MSG_A_UPLOAD_FAIL,Ws.MSG_A_SIZE_LIMIT,Ws.COS_UNDETECTED];function En(e){let t=!1;return Object.values(Dn).includes(e)&&(t=!0),t=120001<=e&&e<=13e4||10100<=e&&e<=10200?!0:t}class vn extends Js{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new yn(this)}createTextMessage(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Li(e),i=Ue(e.payload)?e.payload:e.payload.text,o=new hi({text:i}),n=this._getNickAndAvatarByUserID(t);return s.setElement(o),s.setNickAndAvatar(n),s.setNameCard(this._getNameCardByGroupID(s)),s}createImageMessage(e){const t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Li(e));if(G){const t=e.payload["file"];if(Oe(t))return void this.outputWarning("FileUnsupportedInMP","createImageMessage");const s=t.tempFiles[0].path||t.tempFiles[0].tempFilePath,i={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=i}else if(k)if(Oe(e.payload.file)){const t=e.payload.file;e.payload.file={files:[t]}}else if(ke(e.payload.file)&&"undefined"!=typeof uni){const t=e.payload.file.tempFiles[0];e.payload.file={files:[t]}}const i=new gi({imageFormat:fe.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file}),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createAudioMessage(e){const t=e.payload["file"];if(G){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(),i=(e.currentUser=s,e.senderTinyID=this.getMyTinyID(),new Li(e)),o=new Mi({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 i.setElement(o),i.setNickAndAvatar(n),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}createVideoMessage(t){const e=this.getMyUserID(),s=(t.currentUser=e,t.senderTinyID=this.getMyTinyID(),t.payload.file.thumbUrl="",t.payload.file.thumbSize=0,{});if(G){if(N)return void this.outputWarning("VideoUnsupportedInAlipay");if(Oe(t.payload.file))return void this.outputWarning("FileUnsupportedInMP","createVideoMessage");let e=t.payload["file"];Fe(e.tempFiles)&&(e=e.tempFiles[0]),s.url=e.tempFilePath,s.name=e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),s.size=e.size||1,s.second=e.duration||0,s.type=e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(k){if(Oe(t.payload.file)){const e=t.payload.file;t.payload.file.files=[e]}else if(ke(t.payload.file)&&"undefined"!=typeof uni){const e=t.payload.file.tempFile;t.payload.file.files=[e]}const e=t.payload["file"];s.url=window.URL.createObjectURL(e.files[0]),s.name=e.files[0].name,s.size=e.files[0].size||1,s.second=e.files[0].duration||0,s.type=e.files[0].type.split("/")[1]}t.payload.file.videoFile=s;const i=new Li(t),o=new Si({videoFormat:s.type,videoSecond:gt(s.second,0),videoSize:s.size,remoteVideoUrl:"",videoUrl:s.url,videoUUID:this._generateUUID(t.payload.file.videoFile),thumbUUID:this._generateUUID(t.payload.file.videoFile),thumbWidth:t.payload.file.width||200,thumbHeight:t.payload.file.height||200,thumbUrl:t.payload.file.thumbUrl,thumbSize:t.payload.file.thumbSize,thumbFormat:t.payload.file.thumbUrl.slice(t.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),n=this._getNickAndAvatarByUserID(e);return i.setElement(o),i.setNickAndAvatar(n),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,t),i}createCustomMessage(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Li(e),i=new Di({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),s}createFaceMessage(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Li(e),i=new mi(e.payload),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),s}createMergerMessage(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=this._getNickAndAvatarByUserID(t),i=new Li(e),o=new Ai(e.payload);return i.setElement(o),i.setNickAndAvatar(s),i.setNameCard(this._getNameCardByGroupID(i)),i.setRelayFlag(!0),i}createForwardMessage(e){var{to:s,conversationType:i,priority:o,payload:n,needReadReceipt:r,receiverList:a}=e;if(!Fe(n._elements))return Xs({code:Ws.MSG_FORWARD_INVALID_ELEMENTS});var c=this.getMyUserID(),l=this._getNickAndAvatarByUserID(c);if(n.type===t.MSG_GRP_TIP)return Xs({code:Ws.MSG_FORWARD_TYPE_INVALID});const u={to:s,conversationType:i,conversationID:""+i+s,priority:o,isPlaceMessage:0,status:Rt,currentUser:c,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||n.cloudCustomData||"",needReadReceipt:r,receiverList:a,isSupportExtension:e.isSupportExtension||!1},d=new Li(u);return d.setElement(n._elements[0]),d.setNickAndAvatar(l),d.setNameCard(this._getNameCardByGroupID(n)),d.setRelayFlag(!0),d}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(t){if(G){if(!E&&!A&&!P)return;let e;const s=F.getSystemInfoSync().SDKVersion;if(E&&dt(s,e="2.5.0")<0)return void this.outputWarning("WXChooseMessageFile");if(A&&dt(s,e="1.18.0")<0)return void this.outputWarning("QQChooseMessageFile")}if(k||P){if(Oe(t.payload.file)){const s=t.payload.file;t.payload.file={files:[s]}}else if(ke(t.payload.file)&&"undefined"!=typeof uni){const{tempFiles:s,files:i}=t.payload.file;let e=null;Fe(s)?e=s[0]:Fe(i)&&(e=i[0]),t.payload.file={files:[e]}}}else if(E||A){const s=t.payload.file["tempFiles"],i={...s[0],url:s[0].path};t.payload.file={files:[i]}}const s=this.getMyUserID(),i=(t.currentUser=s,t.senderTinyID=this.getMyTinyID(),new Li(t)),e=new yi({uuid:this._generateUUID(t.payload.file),file:t.payload.file}),o=this._getNickAndAvatarByUserID(s);return i.setElement(e),i.setNickAndAvatar(o),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,t),i}createLocationMessage(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();const s=new Li(e),i=new Ei(e.payload),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),s}_onCannotFindModule(){return Xs({code:Ws.CANNOT_FIND_MODULE})}sendMessageInstance(r,a){if(!1===this.get($s).filterMessage(r,a))return r.hasRiskContent=!0,this._onSendMessageFailed(r,new Hs({code:Ws.PROFANITY_FOUND}));let s=null;if(r.conversationType===t.CONV_C2C)s=this.get(Ms);else{if(r.conversationType!==t.CONV_GROUP)return Xs({code:Ws.MSG_INVALID_CONV_TYPE});s=this.get(Is)}if(!s)return Xs({code:Ws.CANNOT_FIND_MODULE});const c=this._n+".sendMessageInstance",l=this.get(Ts),d=s.isOnlineMessage(r,a);let u;return this.get(vs).upload(r).then(()=>(this._getSendMessageSpecifiedKey(r)===ni&&this.get(Gs).addSuccessCount(oi),this._guardForGroup(r).then(()=>{if(!r.isSendable())return Xs({code:Ws.MSG_F_URL_IS_EMPTY});this._addSendMessageTotalCount(r),u=Date.now();var e=function(t){let e="utf-8";k&&document&&(e=document.charset.toLowerCase());let s,i=0,o;if(o=t.length,"utf-8"===e||"utf8"===e)for(let e=0;e<o;e++)(s=t.codePointAt(e))<=127?i+=1:s<=2047?i+=2:s<=65535?i+=3:(i+=4,e++);else if("utf-16"===e||"utf16"===e)for(let e=0;e<o;e++)(s=t.codePointAt(e))<=65535?i+=2:(i+=4,e++);else i=t.replace(/[^\x00-\xff]/g,"aa").length;return i}(JSON.stringify(r));return r.type===t.MSG_MERGER&&11264<e?this._mergerMessageHandler.uploadMergerMessage(r,e).then(e=>{e=this._mergerMessageHandler.createMergerMessagePack(r,a,e);return this.req(e)}):(l.setMessageRandom(r),s.sendMessage(r,a))}).then(e=>{var{time:e,sequence:s,readReceiptCode:i,messageDropReason:o}=e.data;if(Pe(i)&&0!==i&&(new pi("sendMessageWithReceipt").setMessage(`from:${r.from} to:${r.to} sequence:${s} readReceiptCode:`+i).end(),Ie.w(c+` readReceiptCode:${i} message:`+this.getErrorMessage(i))),o){const t=new pi("messageDropReason"),a=`from:${r.from} to:${r.to} sequence:${s} messageDropReason:`+o;t.setMessage(a).end(),Ie.w(c+" "+a)}if(this._addSendMessageSuccessCount(r,u),this._messageOptionsMap.delete(r.clientSequence),!0===r.isResend){const t=l.findMessage(r.ID);t&&(Ie.l(c+" resend ok. ID:"+t.ID),l.deleteLocalMessage(t))}r.status=Lt,r.time=e;let n=!1;if(r.conversationType===t.CONV_GROUP)r.sequence=s;else if(r.conversationType===t.CONV_C2C){const t=l.getLatestMessageSentByMe(r.conversationID);if(t){const{nick:a,avatar:e}=t;a===r.nick&&e===r.avatar||(n=!0)}}if(n&&l.modifyMessageSentByMe({conversationID:r.conversationID,latestNick:r.nick,latestAvatar:r.avatar}),!0===d)r._onlineOnlyFlag=!0;else{l.appendToMessageList(r);let e=r,s=(ke(a)&&ke(a.messageControlInfo)&&(!0===a.messageControlInfo.excludedFromLastMessage&&(r._isExcludedFromLastMessage=!0,e=""),!0===a.messageControlInfo.excludedFromUnreadCount&&(r._isExcludedFromUnreadCount=!0)),r.conversationType);it(r.to)&&(s=t.CONV_TOPIC,this.get(Cs).onMessageSent({groupID:It(r.to),topicID:r.to,lastMessage:e})),l.onMessageSent({conversationOptionsList:[{conversationID:r.conversationID,unreadCount:0,type:s,subType:r.conversationSubType,lastMessage:e}]})}return r._relayFlag||"TIMImageElem"!==r.type||pt(r.payload.imageInfoArray),Ks({message:r})}))).catch(e=>this._onSendMessageFailed(r,e,d))}_guardForGroup(e){if(e.conversationType!==t.CONV_GROUP)return Promise.resolve();const s=this.get(Is);if(!s)return this._onCannotFindModule();if(st({groupID:e.to})){const t=s.getLocalGroupProfile(e.to);if(t&&t.isSupportTopic)return Xs({code:Ws.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return s.guardForAVChatRoom(e)}_onSendMessageFailed(e,t,s=!1){var i=this._n+"._onSendMessageFailed";e.status=Nt,80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0);const o=this.get(Ts);o.deleteMessageRandom(e);var n=10100<=t.code&&t.code<=10200||120001<=t.code&&t.code<=13e4;s||n||!0===o.appendToMessageList(e)&&Ie.l(i+" message stored, ID:"+e.ID),this._addSendMessageFailCountOnUser(e,t);const r=new pi("sendMessage");return r.setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:`+e.to),r.setError(t).end(),Ie.e(i+" error:",t),Xs(new Hs({code:t&&t.code?t.code:Ws.MSG_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 ni;if(e.conversationType===t.CONV_C2C)return ti;if(e.conversationType===t.CONV_GROUP){const t=this.get(Is);if(t){var e=t.getLocalGroupProfile(e.to);if(e)return e=e.type,et(e)?ii:si}}}_addSendMessageTotalCount(e){e=this._getSendMessageSpecifiedKey(e);e&&this.get(Gs).addTotalCount(e)}_addSendMessageSuccessCount(e,t){var s=this._getSendMessageSpecifiedKey(e);if(s){const e=this.get(Gs);e.addSuccessCount(s),e.addCost(s,St(t,!1))}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,i=this.get(Gs),o=this._getSendMessageSpecifiedKey(e);o===ni&&function(e){let t=!1;return t=Sn.includes(e)?!0:t}(s)?i.addFailedCountOfUserSide(oi):En(s)&&o&&i.addFailedCountOfUserSide(o)}resendMessage(e,t){return e.isResend=!0,e.status=Rt,this.sendMessageInstance(e,t)}revokeMessage(s){let e=null;if(s.conversationType===t.CONV_C2C?e=this.get(Ms):s.conversationType===t.CONV_GROUP&&(e=this.get(Is)),!e)return this._onCannotFindModule();const i=new pi("revokeMessage"),o=(i.setMessage(`tjg_id:${this.generateTjgID(s)} type:${s.type} from:${s.from} to:`+s.to),this._n+".revokeMessage");return e.revokeMessage(s).then(e=>{var t=e.data.recallRetList;if(Re(t)||0===t[0].retCode)return Ie.i(o+" ok. ID:"+s.ID),s.isRevoked=!0,i.end(),this.get(Ts).onMessageRevoked([s]),Ks({message:s});{const e=new Hs({code:t[0].retCode,data:{message:s}});return i.setCode(e.code).setMoreMessage(e.message).end(),Xs(e)}}).catch(e=>{i.setError(e).end();var t=new Hs({code:e&&e.code?e.code:Ws.MSG_REVOKE_FAIL,message:e&&e.message?e.message:void 0,data:{message:s}});return Ie.w(o+" failed. error:",e),Xs(t)})}deleteMessage(e){let s=null;const i=e[0],o=i.conversationID;let n="",r=[],a=[];if(i.conversationType===t.CONV_C2C)s=this.get(Ms),n=o.replace(t.CONV_C2C,""),e.forEach(e=>{e&&e.status===Lt&&e.conversationID===o&&(e._onlineOnlyFlag||r.push(`${e.sequence}_${e.random}_`+e.time),a.push(e))});else if(i.conversationType===t.CONV_GROUP)s=this.get(Is),n=o.replace(t.CONV_GROUP,""),e.forEach(e=>{e&&e.status===Lt&&e.conversationID===o&&(e._onlineOnlyFlag||r.push(""+e.sequence),a.push(e))});else if(i.conversationType===t.CONV_SYSTEM)return Xs({code:Ws.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!s)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(a);30<r.length&&(r=r.slice(0,30),a=a.slice(0,30));const c=new pi("deleteMessage"),l=(c.setMessage(`to:${n} count:`+r.length),this._n+".deleteMessage");return s.deleteMessage({to:n,keyList:r}).then(e=>(c.end(),Ie.i(l+" ok"),this._onMessageDeleted(a))).catch(e=>{c.setError(e).end(),Ie.w(l+" failed. error:",e);e=new Hs({code:e&&e.code?e.code:Ws.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0});return Xs(e)})}_onMessageDeleted(e){return this.get(Ts).onMessageDeleted(e),js({messageList:e})}translateText(e){const o=this._n+".translateText",{sourceTextList:t,sourceLanguage:s,targetLanguage:i}=e,n=new pi("translateText");return n.setMessage(`sourceLanguage:${s} targetLanguage:`+i),this.req({proto:Qs.TRANSLATE_TEXT,data:{sourceTextList:t,source:s||"auto",target:i,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then(e=>{var{error:e,requestID:t,translatedTextList:s}=e.data,i=e["code"];if(0===i)return n.end(),Ie.i(o+" ok. requestID:"+t),Ks({translatedTextList:s});throw{...e,requestID:t}}).catch(e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),Ie.w(o+" failed. error:",e),Xs({code:Ws.TRANSLATE_TEXT_FAIL})))}convertVoiceToText(e){var{message:e,language:t}=e;let s=e.payload.url;e.from===this.getMyUserID()&&"out"===e.flow&&(s=e.payload.remoteAudioUrl);const i=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/;if(!i.test(s))return Xs({code:Ws.UNSUPPORTED_VOICE_FORMAT});e=i.exec(s)[1]||"mp3";let o="16k_zh-PY";t?"zh (cmn-Hans-CN)"===t?o="16k_zh":"en-US"===t?o="16k_en":"yue-Hant-HK"===t?o="16k_yue":"ja-JP"===t&&(o="16k_ja"):o="16k_zh-PY";const n=`serviceType:${o} url:`+s,r=this._n+".convertVoiceToText",a=(Ie.i(r+" "+n),new pi("convertVoiceToText"));return a.setMessage(n),this.req({proto:Qs.VOICE_TO_TEXT,data:{url:s,language:o,SDKAppID:this.getSDKAppID(),format:e}}).then(e=>{var{error:e,requestID:t,result:s}=e.data,i=e["code"];if(0===i)return a.end(),Ie.i(r+" ok. requestID:"+t),Ks({result:s});throw{...e,requestID:t}}).catch(e=>(a.setCode(e.code).setMoreMessage(e.requestID||"").end(),Ie.w(r+" failed. error:",e),Xs({code:Ws.VOICE_TO_TEXT_FAIL})))}modifyRemoteMessage(s){let e=null;const{conversationType:i,to:o}=s,n=this.get(Is);if(!n)return this._onCannotFindModule();if(n.isMessageFromOrToAVChatroom(o))return Xs({code:Ws.MSG_MODIFY_DISABLED_IN_AVCHATROOM,data:{message:s}});if(!1===this.get($s).filterMessage(s))return s.hasRiskContent=!0,Xs({code:Ws.PROFANITY_FOUND,data:{message:s}});i===t.CONV_C2C?e=this.get(Ms):i===t.CONV_GROUP&&(e=this.get(Is));const r=new pi("modifyMessage"),a=(r.setMessage("to:"+o),this._n+".modifyRemoteMessage");return e.modifyRemoteMessage(s).then(e=>{r.end(),Ie.i(a+" ok");e=this._onModifyRemoteMessageResp(s,e.data);return Ks({message:e})}).catch(e=>{var t;return r.setCode(e.code).setMoreMessage(e.message).end(),Ie.w(a+" failed. error:",e),20027===e.code?(t=this._onModifyRemoteMessageResp(s,e.data),Xs({code:Ws.MSG_MODIFY_CONFLICT,data:{message:t}})):Xs({code:e.code,message:e.message,data:{message:s}})})}_generateSearchdata(e){const{conversationID:s,timePosition:i,timePeriod:o,...n}=e;return $e(s)||(nt(s)&&(n.account=s.replace(t.CONV_C2C,"")),ot(s)&&(n.groupID=s.replace(t.CONV_GROUP,""))),Pe(o)&&0<o&&(Pe(i)&&0<i?n.startTime=i-o:n.startTime=he()-o),n.startTime&&n.startTime<0&&(n.startTime=void 0),Pe(i)&&0<i&&(n.endTime=i),n}searchCloudMessages(o){const e="searchCloudMessages",n=this._n+"."+e;if(!o)return Xs({code:Ws.OPTIONS_IS_EMPTY,message:this.getErrorMessage(Ws.OPTIONS_IS_EMPTY,e)});var{keywordList:t,keywordListMatchType:s,conversationID:i,cursor:r}=o,a=Fe(o.senderUserIDList)&&0<o.senderUserIDList.length,d=Fe(o.messageTypeList)&&0<o.messageTypeList.length;if(!t&&!a&&!d)throw Ie.e(`[${e}] Missing required params: "keywordList".`),new Error("Params validate failed.");const u=Date.now(),c=new pi(e),l=`keywordList:${t} keywordListMatchType:${s} conversationID:${i} cursor:`+r;return Ie.l(n+" "+l),this.req({proto:Qs.MSG_CLOUD_SEARCH,data:this._generateSearchdata(o)}).then(t=>{var{code:s,message:i}=t.data;if(0!==s){let e=s;60020===s&&(e="SearchCloudMessagesUnavailable");const t=this.getErrorMessage(e)||i,n=new Hs({code:s,message:t});return c.setMessage(l).setError(n).end(),Xs(n)}var{cursor:i,totalCount:s,searchResult:t}=t.data,e=`totalCount:${s} cost:`+St(u),e=(Ie.l(n+` ok. cursor:${i} `+e),c.setMessage(l+" "+e).end(),this._handleSearchResults(t,!o.conversationID));return Ks({searchResultList:e,cursor:i,totalCount:s})}).catch(e=>(c.setMessage(l).setError(e).end(),Xs(e)))}_handleSearchResults(e,a){const c=this.get(Ts);return Fe(e)&&0!==e.length?e.map(({groupID:e,userID:s,messageCount:i,messageList:o})=>{const n=e?""+t.CONV_GROUP+e:""+t.CONV_C2C+s,r={conversationID:n,messageCount:i,messageList:[]};if(a&&1<i)return r;if(o&&0<o.length){const t=c.onRoamingMessage(o,n,!1);e&&t.reverse(),r.messageList=t}return r}):[]}_onModifyRemoteMessageResp(e,t){Ie.d(this._n+"._onModifyRemoteMessageResp options:",t);var{conversationType:e,from:s,to:i,random:o,sequence:n,time:r}=e,{elements:t,messageVersion:a,cloudCustomData:c=""}=t;return this.get(Ts).onMessageModified({conversationType:e,from:s,to:i,time:r,random:o,sequence:n,elements:t,cloudCustomData:c,messageVersion:a})}_generateUUID(e){const t=this.get(ys);let s=`${t.getSDKAppID()}-${t.getUserID()}-`+function(){let t="";for(let e=32;0<e;--e)t+=ze[Math.floor(Math.random()*je)];return t}();const i=e.name||e.value||e.url||e.tempFilePath,o=i&&i.slice(i.lastIndexOf(".")+1);return s=o?s+"."+o:s}getMessageOption(e){return this._messageOptionsMap.get(e)}_getNickAndAvatarByUserID(e){return this.get(ms).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(e){if(e.conversationType===t.CONV_GROUP){const t=this.get(Is);if(t)return t.getMyNameCardByGroupID(e.to)}return""}reset(){Ie.l(this._n+".reset"),this._messageOptionsMap.clear()}}class An extends Js{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:i,operateResultList:o,tinyID:u,globalSequence:n}=t.dataList,{clientTime:_,random:p}=s,r=u+`-${_}-`+p,a=[],c=[];Ie.l(`${this._n}.onMessageExtensionNotify messageID:${r} operateType:${i} globalSequence:`+n),this._updateGlobalSequence(r,n);let l=!1,d=!1;o.forEach(e=>{const{extensions:t=[],clearSequence:s}=e;1===i?(l=!0,t.forEach(e=>{a.push({key:e.key,value:e.value})}),this._updateLocalExtension(r,t)):2===i?(d=!0,t.forEach(e=>{c.push(e.key)}),this._updateLocalExtension(r,t)):3===i&&(d=!0,this._hasLocalExtension(r)&&this._getLocalExtension(r).forEach((e,t)=>{e.seq<=s&&!Re(e.value)&&c.push(t)}),this._clearLocalExtension(r,s))}),l&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_UPDATED,{messageID:r,extensions:a}),d&&this.emitOuterEvent(e.MESSAGE_EXTENSIONS_DELETED,{messageID:r,keyList:c})}setMessageExtensions(e,t){var s="setMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(s);const i=this._n+"."+s,{ID:o,conversationID:n,sequence:r,time:d}=e;let a=[...t];20<t.length&&(a=t.slice(0,20),Ie.w(i+". the length of extensions cannot exceed 20."));const c=`conversationID:${n} messageID:${o} sequence:${r} time:${d} count:`+a.length,l=new pi(s);return l.setMessage(c),Ie.l(i+" "+c),this._modifyMessageExtensions(e,a).then(e=>{var{resultList:e,successCount:t,failureCount:s}=e,t=`success count:${t} fail count:`+s;return l.setMoreMessage(t).end(),Ie.l(i+" ok. "+t),Ks({extensions:e})}).catch(e=>(l.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}getMessageExtensions(e){var t="getMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(t);const s=this._n+"."+t,{ID:i,conversationID:o,sequence:n,time:r}=e,a=`conversationID:${o} messageID:${i} sequence:${n} time:`+r,c=new pi(t);c.setMessage(a),Ie.l(s+" "+a);let l=void 0;return this.getMessageExtensionsMap.has(i)&&(l=this._getGlobalSequence(i)),this._getMessageExtensions(e,l).then(e=>(c.end(),Ie.l(s+" ok. total count:"+e.length),$e(l)&&0<e.length&&this.getMessageExtensionsMap.set(i,1),Ks({extensions:e}))).catch(e=>(c.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}deleteMessageExtensions(e,t){var s="deleteMessageExtensions";if(!this.canIUse(I.MSG_EXT))return this.cannotUseCommercialAbility(s);const o=this._n+"."+s,i=[];let n=3;Re(t)||(n=2,t.forEach(e=>{i.push({key:e,value:"",seq:0})}));const{ID:r,conversationID:a,sequence:d,time:u}=e,c=`conversationID:${a} messageID:${r} sequence:${d} time:${u} operateType:`+n,l=new pi(s);return l.setMessage(c),Ie.l(o+" "+c),this._modifyMessageExtensions(e,i,n).then(e=>{var{resultList:e,successCount:t,failureCount:s}=e;let i="";return 2===n&&(i=`success count:${t} fail count:`+s),l.setMoreMessage(""+i).end(),Ie.l(o+" ok. "+i),Ks({extensions:e})}).catch(e=>(l.setError(e).end(),Ie.e(o+" failed. error:",e),Xs(e)))}_modifyMessageExtensions(i,e,s=1){var o=it(i.to)?t.CONV_TOPIC:i.conversationType;let n=void 0,r=(3!==s&&(n=this._getRequestExtensions(i,e)),null);switch(o){case t.CONV_C2C:r=this.get(Ms);break;case t.CONV_GROUP:r=this.get(Is);break;case t.CONV_TOPIC:r=this.get(Cs);break;default:return Xs({code:Ws.CANNOT_FIND_MODULE})}return r.modifyMessageExtensions(i,n,s).then(e=>{let{extensions:t,seq:s}=e.data;const o=[];let n=0,r=0,a=[];return(t=Re(t)?[]:t).forEach(e=>{var{errorCode:e,extension:t}=e,{key:t,value:s,seq:i}=t;o.push({code:e,key:t,value:s}),0===e?n++:r++,a.push({key:t,value:s,seq:i})}),this._updateGlobalSequence(i.ID,s),0<a.length&&(this._updateLocalExtension(i.ID,a),a=null),{resultList:o,successCount:n,failureCount:r}}).catch(e=>Xs(e))}_getRequestExtensions(e,t){const i=[];if(this._hasLocalExtension(e.ID)){const o=this._getLocalExtension(e.ID);return t.forEach(e=>{var{key:e,value:t}=e;let s=0;o.has(e)&&(s=o.get(e).seq),i.push({key:e,value:t,seq:s})}),i}return t.forEach(e=>{var{key:e,value:t}=e;i.push({key:e,value:t,seq:0})}),i}_getMessageExtensions(n,e){const r=this._n+"._getMessageExtensions",{ID:a,to:s}=n;let i=null;switch(it(s)?t.CONV_TOPIC:n.conversationType){case t.CONV_C2C:i=this.get(Ms);break;case t.CONV_GROUP:i=this.get(Is);break;case t.CONV_TOPIC:i=this.get(Cs);break;default:return Xs({code:Ws.CANNOT_FIND_MODULE})}return i.getMessageExtensions(n,e).then(e=>{let{extensions:t,completeFlag:s,globalSequence:i,clearSequence:o}=e.data;if(t=Re(t)?[]:t,Ie.l(r+` ok. completeFlag:${s} globalSequence:${i} clearSequence:${o} count:`+t.length),this._updateLocalExtension(a,t),this._clearLocalExtension(a,o),this._updateGlobalSequence(a,i),1===s)return this._getLocalExtensions(a);{const e=t.slice(-1)[0].seq+1;return this._getMessageExtensions(n,e)}}).catch(e=>Xs(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 i=this._getLocalExtension(e);t.forEach(e=>{var{key:e,value:t="",seq:s}=e;i.set(e,{value:t,seq:s})})}_clearLocalExtension(e,s){if(!(s<=0)&&this._hasLocalExtension(e)){const i=this._getLocalExtension(e);i.forEach((e,t)=>{e.seq<=s&&i.delete(t)})}}_getLocalExtensions(e){const s=[];return this._hasLocalExtension(e)&&this._getLocalExtension(e).forEach((e,t)=>{e=e.value;Re(e)||s.push({key:t,value:e})}),s}_getGlobalSequence(e){return this.globalSeqMap.get(e)}_updateGlobalSequence(e,t){this.globalSeqMap.set(e,t)}reset(){Ie.l(this._n+".reset"),this.messageExtensionMap.clear(),this.globalSeqMap.clear(),this.getMessageExtensionsMap.clear()}}class Rn extends Js{constructor(e){super(e),this._n="MessageReactionModule",this._reactedByMyselfMap=new Map,this._reactionInfoMap=new Map}onMessageReactionNotifyList(t){const{dataList:s=[]}=t||{};s.forEach(t=>{const{C2CMessageInfo:s={},groupMessageInfo:i={},reactionList:o=[]}=t,{tinyID:n,clientTime:r,random:a}={...s,...i},c=n+`-${r}-`+a,l=[];o.forEach(e=>{$e(e.userIDList)&&(e.userIDList=[],e.count=0),l.push(...e.userIDList)}),Ie.l(this._n+`.onMessageReactionNotifyList messageID:${c} reactionList:`+o.length),this._handleReactionSummary([{messageID:c,reactionList:o}],l).then(t=>{this.emitOuterEvent(e.MESSAGE_REACTIONS_UPDATED,{...t[0]})})})}onMessageReactionNotify(t){var{C2CMessageInfo:t={},groupMessageInfo:s={},reactionID:i,operateType:o}=t.dataList||{},{tinyID:t,clientTime:s,random:n}={...t,...s},s=t+`-${s}-`+n,n=(Ie.l(this._n+`.onMessageReactionNotify messageID:${s} reactionID:${i} operateType:`+o),1===o?this._addReactedByMyselfMap(s,i):this._removeReactedByMyselfMap(s,i),s+"-"+i);if(this._reactionInfoMap.has(n)){const t=this._reactionInfoMap.get(n);t.reactedByMyself=1===o,this.emitOuterEvent(e.MESSAGE_REACTIONS_UPDATED,{messageID:s,reactionList:[t]})}}addMessageReaction(t,s){var e="addMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(e);const i=this._n+"."+e,{ID:o,conversationID:n}=t,r=`conversationID:${n} messageID:${o} reactionID:`+s,a=new pi(e);a.setMessage(r),Ie.l(i+" "+r);e=this._createReactionOperationPack(t,s,1);return this._addReactedByMyselfMap(t.ID,s),this.req(e).then(()=>(a.end(),Ie.l(i+" ok."),Ks())).catch(e=>(this._removeReactedByMyselfMap(t.ID,s),a.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}removeMessageReaction(e,t){var s="removeMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(s);const i=this._n+"."+s,{ID:o,conversationID:n}=e,r=`conversationID:${n} messageID:${o} reactionID:`+t,a=new pi(s);a.setMessage(r),Ie.l(i+" "+r);s=this._createReactionOperationPack(e,t,2);return this._removeReactedByMyselfMap(e.ID,t),this.req(s).then(()=>(a.end(),Ie.l(i+" ok."),Ks())).catch(e=>(a.setError(e).end(),Ie.e(i+" failed. error:",e),Xs(e)))}getMessageReactions(e){var t="getMessageReactions";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(t);const s=this._n+"."+t,{messageList:i,maxUserCountPerReaction:o}=e,n=i[0]["conversationID"],r=`conversationID:${n} maxUserCountPerReaction:${o} messageList:`+i.length,a=new pi(t),c=(a.setMessage(r),Ie.l(s+" "+r),new Map),l=this._createReactionSummaryPack({...e,messageIDMap:c});return this.req(l).then(e=>{const{resultList:t=[]}=e.data,n=[],r=[];return t.forEach(e=>{const{messageKey:t,messageSequence:s,reactionList:i=[]}=e,o=$e(t)?c.get(s):c.get(t);n.push({messageID:o,reactionList:i}),i.forEach(e=>{r.push(...e.userIDList)})}),this._handleReactionSummary(n,r)}).then(e=>(a.end(),Ie.l(s+" ok."),c.clear(),Ks({resultList:e}))).catch(e=>(a.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}getAllUserListOfMessageReaction(e){var t="getAllUserListOfMessageReaction";if(!this.canIUse(I.MSG_REACTION))return this.cannotUseCommercialAbility(t);const s=this._n+"."+t,{message:i,reactionID:o,nextSeq:n,count:r}=e,{ID:d,conversationID:u}=i,a=`conversationID:${u} messageID:${d} reactionID:${o} nextSeq:${n} count:`+r,c=new pi(t),l=(c.setMessage(a),Ie.l(s+" "+a),{userList:[],nextSeq:0,isCompleted:!1}),_=this._createReactionUserListPack(e);return this.req(_).then(e=>{var{userIDList:e=[],nextSeq:t=0}=e.data;return l.nextSeq=t,l.isCompleted=0===t,this.get(ms).getUserNickAndAvatar(e)}).then(e=>(l.userList=e,c.end(),Ie.l(s+" ok."),Ks(l))).catch(e=>(c.setError(e).end(),Ie.e(s+" failed. error:",e),Xs(e)))}_createReactionOperationPack(s,e,i){let o=void 0;const n={reactionID:e,userIDList:[this.getMyUserID()]};if(s.conversationType===t.CONV_C2C){const t=this.get(Ms);o=1===i?Qs.ADD_C2C_MSG_REACTION:Qs.RM_C2C_MSG_REACTION,n.from=s.from,n.to=s.to,n.messageKey=t.getMessageKey(s)}if(s.conversationType===t.CONV_GROUP){let e=void 0,t=s.to;it(s.to)&&(e=s.to,t=It(e)),o=1===i?Qs.ADD_GRP_MSG_REACTION:Qs.RM_GRP_MSG_REACTION,n.groupID=t,n.topicID=e,n.messageSequence=s.sequence}return{proto:o,data:n}}_createReactionSummaryPack(s){const{messageList:i,maxUserCountPerReaction:o=10,messageIDMap:n}=s,r=i[0];let a=void 0,c=void 0;if(r.conversationType===t.CONV_C2C){const s=this.get(Ms),t=i.map(e=>{var t=s.getMessageKey(e);return n.set(t,e.ID),t});a=Qs.GET_C2C_MSG_REACTIONS,c={from:r.from,to:r.to,messageKeyList:t,count:o}}if(r.conversationType===t.CONV_GROUP){let e=void 0,t=r.to;it(r.to)&&(e=r.to,t=It(e));s=i.map(e=>(n.set(e.sequence,e.ID),e.sequence));a=Qs.GET_GRP_MSG_REACTIONS,c={groupID:t,topicID:e,messageSequenceList:s,count:o}}return{proto:a,data:c}}_createReactionUserListPack(e){var{message:s,reactionID:e,nextSeq:i=0,count:o=100}=e;let n=void 0;const r={reactionID:e,nextSeq:i,count:100<o?100:o};if(s.conversationType===t.CONV_C2C){const e=this.get(Ms);n=Qs.GET_C2C_MSG_REACTION_USER_LIST,r.from=s.from,r.to=s.to,r.messageKey=e.getMessageKey(s)}if(s.conversationType===t.CONV_GROUP){let e=void 0,t=s.to;it(s.to)&&(e=s.to,t=It(e)),n=Qs.GET_GRP_MSG_REACTION_USER_LIST,r.groupID=t,r.topicID=e,r.messageSequence=s.sequence}return{proto:n,data:r}}_handleReactionSummary(t,e){return this.get(ms).getUserNickAndAvatar(e).then(c=>{const e=[];return t.forEach(r=>{const a=[];r.reactionList.forEach(e=>{const{reactionID:t,count:s,userIDList:i,reactedByMyself:o}=e,n=[];i.forEach(t=>{c.forEach(e=>{t===e.userID&&n.push(e)})});e={reactionID:t,totalUserCount:s,partialUserList:n,reactedByMyself:this._computeReactedByMyself({reactedByMyself:o,messageID:r.messageID,reactionID:t})};if(a.push(e),$e(o)&&!this._reactedByMyselfMap.has(r.messageID)){const c=r.messageID+"-"+t;this._reactionInfoMap.set(c,e)}}),e.push({messageID:r.messageID,reactionList:a})}),e})}_addReactedByMyselfMap(e,t){this._reactedByMyselfMap.has(e)||this._reactedByMyselfMap.set(e,[]);const s=this._reactedByMyselfMap.get(e);-1===s.indexOf(t)&&s.push(t)}_removeReactedByMyselfMap(e,t){if(this._reactedByMyselfMap.has(e)){const s=this._reactedByMyselfMap.get(e),i=s.indexOf(t);-1<i&&s.splice(i,1)}}_computeReactedByMyself({reactedByMyself:e,messageID:t,reactionID:s}){return $e(e)?!!this._reactedByMyselfMap.has(t)&&this._reactedByMyselfMap.get(t).includes(s):1===e}reset(){Ie.l(this._n+".reset"),this._reactedByMyselfMap.clear(),this._reactionInfoMap.clear()}}class Ln extends Js{constructor(e){super(e),this._n="ComboMessageModule"}sendMessage(e){const r=this._constructMessageInstance(e);if(null===r)return Xs({code:Ws.MSG_SEND_FAIL});this._addSendMessageTotalCount(r);const a=Date.now();return this.get(Ts).setMessageRandom(r),this._sendComboMessage(r,e).then(e=>{var{time:e,sequence:s,readReceiptCode:i}=e.data;Pe(i)&&0!==i&&(new pi("sendMessageWithReceipt").setMessage(`from:${r.from} to:${r.to} sequence:${s} readReceiptCode:`+i).end(),Ie.w(this._n+`.sendMessage readReceiptCode:${i} message:`+this.getErrorMessage(i))),this._addSendMessageSuccessCount(r,a);const o=this.get(Ts);r.status=Lt,r.time=e,r.conversationType===t.CONV_GROUP&&(r.sequence=s),o.appendToMessageList(r);let n=r;return!0===r._isExcludedFromLastMessage&&(n=""),o.onMessageSent({conversationOptionsList:[{conversationID:r.conversationID,unreadCount:0,type:r.conversationType,subType:r.conversationSubType,lastMessage:n}]}),Ks({message:r})}).catch(e=>this._onSendMessageFailed(r,e))}_sendComboMessage(e,s){const i=this._m.get(Ls);let o="";return e.conversationType===t.CONV_C2C&&(o=M.NAME.OPEN_IM+"."+Qs.SEND_C2C_MSG),e.conversationType===t.CONV_GROUP&&(o=M.NAME.GROUP+"."+Qs.SEND_GRP_MSG),i.sendComboMessage({servcmd:o,data:s})}_constructMessageInstance(s){var i=this._n+"._constructMessageInstance";let o=null;try{const a=this.getMyUserID(),c={};if(c.senderTinyID=this.getMyTinyID(),c.currentUser=a,c.from=s.From_Account||a,s.GroupId?(c.conversationID=""+t.CONV_GROUP+s.GroupId,c.conversationType=t.CONV_GROUP,c.to=s.GroupId):s.To_Account&&(c.conversationID=""+t.CONV_C2C+s.To_Account,c.conversationType=t.CONV_C2C,c.to=s.To_Account),c.time=s.MsgTimeStamp||0,c.random=s.Random||s.MsgRandom||0,c.priority=s.MsgPriority,Ue(s.CloudCustomData)&&0<s.CloudCustomData.length&&(c.cloudCustomData=s.CloudCustomData),Fe(s.SendMsgControl)&&(c.messageControlInfo={},s.SendMsgControl.includes("NoUnread")&&(c.messageControlInfo.excludedFromUnreadCount=1),s.SendMsgControl.includes("NoLastMsg")&&(c.messageControlInfo.excludedFromLastMessage=1)),c.conversationType===t.CONV_GROUP&&Fe(s.To_Account)&&0<s.To_Account.length){let e=s.To_Account;50<s.To_Account.length&&(e=s.To_Account.slice(0,50),Ie.w(i+" To_Account must be less than or equal to 50.")),c.receiverList=[...e],s.To_Account=[...e]}1!==s.IsNeedReadReceipt&&1!==s.NeedReadReceipt||(c.needReadReceipt=!0),1===s.SupportMessageExtension&&(c.isSupportExtension=!0),(o=new Li(c)).status=Rt,s.MsgClientTime=o.clientTime,o.conversationType===t.CONV_C2C&&(s.MsgSeq=o.sequence);var n,r=s.MsgBody.length;for(let e=0;e<r;e++)"TIMTextElem"===(n=s.MsgBody[e]).MsgType?o.setTextElement(n.MsgContent.Text):"TIMCustomElem"===n.MsgType?o.setCustomElement({data:n.MsgContent.Data||"",description:n.MsgContent.Desc||"",extension:n.MsgContent.Ext||""}):"TIMFaceElem"===n.MsgType&&o.setFaceElement({index:n.MsgContent.Index,data:n.MsgContent.Data});var e=o.getElements();o.payload=e[0].content,o.type=e[0].type}catch(e){o=null,Ie.e(i+" failed. error:",e)}return o}_onSendMessageFailed(e,t){return e.status=Nt,this.get(Ts).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t),new pi("sendMessage").setMessage(`tjg_id:${this.generateTjgID(e)} type:${e.type} from:${e.from} to:`+e.to).setError(t).end(),Ie.e(this._n+"._onSendMessageFailed error:",t),Xs(new Hs({code:t&&t.code?t.code:Ws.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if(e.conversationType===t.CONV_C2C)return ti;if(e.conversationType===t.CONV_GROUP){const t=this.get(Is).getLocalGroupProfile(e.to);if(t)return e=t.type,et(e)?ii:si}}_addSendMessageTotalCount(e){e=this._getSendMessageSpecifiedKey(e);e&&this.get(Gs).addTotalCount(e)}_addSendMessageSuccessCount(e,t){var s=this._getSendMessageSpecifiedKey(e);if(s){const e=this.get(Gs);e.addSuccessCount(s),e.addCost(s,St(t,!1))}}_addSendMessageFailCountOnUser(e,t){const{code:s=-1}=t,i=this.get(Gs),o=this._getSendMessageSpecifiedKey(e);En(s)&&o&&i.addFailedCountOfUserSide(o)}}class Nn extends Js{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(t){Object.keys(t).forEach(e=>{this.plugins[e]=t[e]}),new pi("registerPlugin").setMessage(""+Object.keys(t)).end()}getPlugin(e){return this.plugins[e]}reset(){}}class On extends Js{constructor(e){super(e),this._n="SyncUnreadMessageModule",this._cookie="",this._onlineSyncFlag=!1,this.getInnerEmitterInstance().on(Pi.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this)}_onLoginSuccess(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}_startSync(e){const{cookie:t,syncFlag:s,isOnlineSync:i}=e,o=this._n+"._startSync";Ie.l(o+` cookie:${t} syncFlag:${s} isOnlineSync:`+i),this.req({proto:Qs.SYNC_UNREAD_MSG,data:{cookie:t,syncFlag:s,isOnlineSync:i}}).then(e=>{var{cookie:t,syncFlag:s}=e.data;Re(this._cookie=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=>{Ie.e(o+" failed. error:",e)})}_dispatchUnreadMessage(e){e.eventArray&&this.get(Ls).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}}),this.get(Ms).onNewC2CMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded})}startOnlineSync(){Ie.l(this._n+".startOnlineSync"),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}startSyncOnReconnected(){Ie.l(this._n+".startSyncOnReconnected."),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){Ie.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}const Pn={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",isRelayMessage:"IsRelayMsg",reactionID:"Reaction",messageSequenceList:"MsgSeqList",messageKeyList:"MsgKeyList"},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",IsPlaceMsg:"isPlaceMessage",MsgCheckResult:"checkResult",Results:"resultList",Reaction:"reactionID",Reaction_Account:"userIDList",MsgReactionNotifyList:"messageReactionNotifyList",MsgReactionNotify:"messageReactionNotify",MsgReactionSummary:"reactionList",C2CMsgInfo:"C2CMessageInfo",GroupMsgInfo:"groupMessageInfo",int32_err_code:"errorCode",str_err_msg:"errorMsg",MsgDropReason:"messageDropReason",ReactedByMe:"reactedByMyself"},ignoreKeyWord:["C2C","ID","USP"]};function Un(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");return t=Object.assign({pascalCase:!1},t),0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e=e=(e=e!==e.toLowerCase()?Gn(e):e).replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,t)=>t.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase()),t.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e)}const Gn=t=>{let s=!1,i=!1,o=!1;for(let e=0;e<t.length;e++){const n=t[e];s&&/[a-zA-Z]/.test(n)&&n.toUpperCase()===n?(t=t.slice(0,e)+"-"+t.slice(e),s=!1,o=i,i=!0,e++):i&&o&&/[a-zA-Z]/.test(n)&&n.toLowerCase()===n?(t=t.slice(0,e-1)+"-"+t.slice(e-1),o=i,i=!1,s=!0):(s=n.toLowerCase()===n&&n.toUpperCase()!==n,o=i,i=n.toUpperCase()===n&&n.toLowerCase()!==n)}return t};function kn(e,t){let i=0;return function s(e,o){return 100<++i?(i--,e):Fe(e)?(t=e.map(e=>Ge(e)?s(e,o):e),i--,t):Ge(e)?(t=at(t=function(s){const i=Object.create(null);return Object.keys(s).forEach(e=>{var t=(t=>{if(!Be(t))return!1;if(t!==Un(t))for(let e=0;e<Pn.ignoreKeyWord.length&&!t.includes(Pn.ignoreKeyWord[e]);e++);var e,s;if($e(o[t]))return s=t,"OPPOChannelID"===s?s:s[0].toUpperCase()+Un(s).slice(1);else return o[t]})((s[e],e));t&&(i[t]=s[e])}),i}(e),(e,t)=>Fe(e)||Ge(e)?s(e,o):e),i--,t):void 0;var t}(e,t)}function Fn(e,o){return Fe(e)?e.map(e=>Ge(e)?Fn(e,o):e):Ge(e)?at(function(s){const i={};return Object.keys(s).forEach(e=>{var t;i[s[e],t=e,$e(o[t])?Un(t):o[t]]=s[e]}),i}(e),e=>Fe(e)||Ge(e)?Fn(e,o):e):void 0}const $n=String.fromCharCode,wn=function(e){let t=0|e.charCodeAt(0);if(55296<=t)if(t<56320){e=0|e.charCodeAt(1);if(56320<=e&&e<=57343){if(65535<(t=(t<<10)+e-56613888|0))return $n(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?$n(192|t>>>6,128|63&t):$n(224|t>>>12,128|t>>>6&63,128|63&t)},bn=function(e){const t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,wn),s=0|t.length,i=new Uint8Array(s);let o=0;for(;o<s;o=o+1|0)i[o]=0|t.charCodeAt(o);return i},qn=function(e){var o=new Uint8Array(e);let n="",r=0;for(var a=o.length;r<a;){let t=o[r],s=0,i=0;if(t<=127?(s=0,i=255&t):t<=223?(s=1,i=31&t):t<=239?(s=2,i=15&t):t<=244&&(s=3,i=7&t),0<a-r-s){let e=0;for(;e<s;)t=o[r+e+1],i=i<<6|63&t,e+=1}else i=65533,s=a-r;n+=String.fromCodePoint(i),r+=s+1}return n};class xn{constructor(e){var t=(this._handler=e).getURL();if(this._socket=null,this._workerSocket=null,this._id=Ye(),this._handler.getIsWorkerEnabled()){const e=URL.createObjectURL(new Blob([';let _socket = null;onmessage = function(event) { if (event.data.cmd === "start") { const url = event.data.url; _socket = new WebSocket(url); _socket.binaryType = "arraybuffer"; _socket.onopen = function() { postMessage({ callback: "onOpen" }); }; _socket.onclose = function(e) { postMessage({ callback: "onOpen", e: { code: e.code, reason: e.reason } }); }; _socket.onmessage = function(e) { postMessage({ callback: "onMessage", data: e.data }); }; _socket.onerror = function(e) { postMessage({ callback: "onError", e: { isTrusted: "true" } }); }; } else if (event.data.cmd === "sendMessage") { if (_socket !== null) { _socket.send(event.data.data); } } else if (event.data.cmd === "stop") { if (_socket !== null) { _socket.close(event.data.code); _socket = null; } }};'],{type:"application/javascript; charset=utf-8"})),i=(this._workerSocket=new Worker(e),this);this._workerSocket.onmessage=function(e){var{callback:t,e:s}=e.data;"onOpen"===t?i._onOpen():"onClose"===t?i._onClose(s):"onError"===t?i._onError(s):"onMessage"===t&&i._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:t})}else G?N?(F.connectSocket({url:t,header:{"content-type":"application/json"}}),F.onSocketClose(this._onClose.bind(this)),F.onSocketOpen(this._onOpen.bind(this)),F.onSocketMessage(this._onMessage.bind(this)),F.onSocketError(this._onError.bind(this))):(this._socket=F.connectSocket({url:t,header:{"content-type":"application/json"},complete:()=>{}}),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.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(){this._handler.onOpen({id:this._id})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onMessage(e){this._handler.onMessage({data:this._canIUseBinaryFrame?qn(e.data):e.data})}_onError(e){this._handler.onError({id:this._id,e:e})}setIsWorkerEnabled(e){this._isWorkerEnabled=!0}close(e){if(this._workerSocket&&(this._workerSocket.postMessage({cmd:"stop",code:e}),this._workerSocket.terminate(),this._workerSocket=null),N)return F.offSocketClose(),F.offSocketMessage(),F.offSocketOpen(),F.offSocketError(),void F.closeSocket();this._socket&&(G?(this._socket.onClose(()=>{}),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),L?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}send(e){this._workerSocket?this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?bn(e.data).buffer:e.data}):N?F.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket&&(G?this._socket.send({data:this._canIUseBinaryFrame?bn(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):k&&this._socket.send(this._canIUseBinaryFrame?bn(e.data).buffer:e.data))}}const Vn=4e3,Bn=4001,Kn="connected",Hn="connecting",Wn="disconnected";class Yn{constructor(e){this._chM=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=Wn,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=Ye(),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._chM.get(ys);let t=c;this._chM.isOversea()&&(t=u),e.isSingaporeSite()?t=l:e.isKoreaSite()?t=d:e.isGermanySite()?t=_:e.isIndiaSite()?t=p:e.isJapanSite()?t=h:e.isUSASite()?t=g:e.isIndonesiaSite()&&(t=m),M.HOST.setCurrent(t)}_initConnection(){$e(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);var e=this._chM.get(ys).getProxyServer();Re(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:i}=e;let o=15e3;-1!==t.indexOf(Qs.LOGIN)&&(o=9e4),Date.now()-i>=o&&(Ie.l(this._n+"._checkPromiseMap request timeout, delete requestID:"+t),this._promiseMap.delete(t),s(new Hs({code:Ws.NETWORK_TIMEOUT})),this._chM.onRequestTimeout(t))})}onOpen(e){var t,s;""!==this._readyState&&(this._onOpenTs=Date.now(),t=e["id"],this._socketID=t,s=St(this._startTs,!1),Ie.l(this._n+`._onOpen cost:${s} ms. socketID:`+t),new pi("wsOnOpen").setMessage(s).setCostTime(s).setMoreMessage("socketID:"+t).end(),e.id===this._socketID&&(this._readyState=Kn,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._chM.onReconnected(),this._reConnectFlag=!1),this._chM.onOpen()))}onClose(e){const t=new pi("wsOnClose"),{id:s,e:i}=e,o=`sourceSocketID:${s} currentSocketID:${this._socketID} code:${i.code} reason:`+i.reason;let n=0;0!==this._onOpenTs&&(n=Date.now()-this._onOpenTs),t.setMessage(n).setCostTime(n).setMoreMessage(o).setCode(i.code).end(),Ie.l(this._n+`._onClose ${o} onlineTime:`+n),s===this._socketID&&(this._readyState=Wn,n<1e3?this._chM.onReconnectFailed():this._chM.onClose())}onError(e){var{id:e,e:t}=e,s=`sourceSocketID:${e} currentSocketID:`+this._socketID;new pi("wsOnError").setMessage(t.errMsg||He(t)).setMoreMessage(s).setLevel("error").end(),Ie.w(this._n+"._onError",t,s),e===this._socketID&&(this._readyState="",this._chM.onError())}onMessage(t){let s;try{s=JSON.parse(t.data)}catch(e){new pi("jsonParseError").setMessage(t.data).end()}if(s&&s.head){const i=this._getRequestIDFromHead(s.head);let e=s.body;if(!this._chM.get(ws).isTRTCCommand(i)){const t=ht(s.head);e=Fn(s.body,this._getResponseKeyMap(t))}if(Ie.d(`${this._n}.onMessage ret:${JSON.stringify(e)} requestID:${i} has:`+this._promiseMap.has(i)),this._setNextPingTs(),this._promiseMap.has(i)){const{resolve:t,reject:s,timestamp:o}=this._promiseMap.get(i);return this._promiseMap.delete(i),this._calcRTT(o),void(e.errorCode&&0!==e.errorCode?(this._chM.onErrorCodeNotZero(e),s(new Hs({code:e.errorCode,message:e.errorInfo||"",data:i.includes(Qs.MODIFY_C2C_MSG)||i.includes(Qs.MODIFY_GRP_MSG)?{elements:e.elements,messageVersion:e.messageVersion,cloudCustomData:e.cloudCustomData}:void 0}))):t(Ks(e)))}this._chM.onMessage({head:s.head,body:e})}}_calcRTT(e){e=Date.now()-e;this._chM.get(Gs).addRTT(e)}_connect(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new xn(this),this._socketID=this._socket.getID(),this._readyState=Hn,Ie.l(`${this._n}._connect isWorkerEnabled:${this.getIsWorkerEnabled()} socketID:${this._socketID} url:`+this.getURL()),new pi("wsConnect").setMessage(`socketID:${this._socketID} url:`+this.getURL()).end()}getURL(){this._chM.isDevMode()&&(this._canIUseBinaryFrame=!1);var e=lt();(N||E&&"windows"===e||P)&&(this._canIUseBinaryFrame=!1);let t=-1;"ios"===e?t=H||-1:"android"===e&&(t=Y||-1);const s=this._chM.get(ys),i=this._chM.getPlatform();let o=`sdkappid=${s.getSDKAppID()}&instanceid=${s.getInstanceID()}&random=${this._getRandom()}&platform=${i}&host=${e}&version=${t}&sdkversion=3.2.4`;return v&&(o+="&isminigame=1"),this._canIUseBinaryFrame?this._url+"/binfo?"+o:this._url+"/info?"+o}_closeConnection(e){Ie.l(this._n+"._closeConnection socketID:"+this._socketID),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Wn)}_resend(){if(Ie.l(this._n+"._resend reConnectFlag:"+this._reConnectFlag,`promiseMap.size:${this._promiseMap.size} simpleRequestMap.size:`+this._simpleRequestMap.size),0<this._promiseMap.size&&this._promiseMap.forEach((e,t)=>{var{uplinkData:e,resolve:s,reject:i}=e;-1!==t.indexOf(Qs.AV_POLLING)?this._promiseMap.delete(t):(this._promiseMap.set(t,{resolve:s,reject:i,timestamp:Date.now(),uplinkData:e}),this._execute(t,e))}),0<this._simpleRequestMap.size){for(var[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,i=this._getRequestIDFromHead(e.head),o=JSON.stringify(s);return new Promise((e,t)=>{this._promiseMap.set(i,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:o}),Ie.d(`${this._n}.send uplinkData:${JSON.stringify(s)} requestID:${i} readyState:`+this._readyState),this._readyState!==Kn?this._reConnect():(this._execute(i,o),this._chM.get(Gs).addRequestCount())})}simplySend(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);const{keyMap:t,...s}=e,i=this._getRequestIDFromHead(e.head),o=JSON.stringify(s);this._readyState!==Kn?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(i,o):Ie.l(this._n+".simplySend. simpleRequestMap is full, drop request!"),this._reConnect()):this._execute(i,o)}_execute(e,t){this._socket.send({data:t,fail:G?this._onSendFail.bind(this):void 0,requestID:e})}_onSendFail(e){Ie.l(this._n+"._onSendFail requestID:"+e)}_getSequence(){var e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=Ye()),e}_getRequestIDFromHead(e){var{servcmd:e,seq:t}=e;return e+t}_getResponseKeyMap(e){e=this._chM.getKeyMap(e);return{...Pn.response,...e.response}}_reConnect(){this._readyState!==Kn&&this._readyState!==Hn&&this.forcedReconnect()}forcedReconnect(){var e=this._n+".forcedReconnect";Ie.l(e+` count:${this._reConnectCount} readyState:`+this._readyState),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(Bn),this._initConnection()):(this._reConnectCount=0,this._chM.get(Es).isOnline()?(Ie.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(Bn),this._initConnection()):this._chM.onReconnectFailed())}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===Kn}canIUseBinaryFrame(){return this._canIUseBinaryFrame}setIsWorkerEnabled(e){Ie.l(this._n+".setIsWorkerEnabled flag:"+e),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&te}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}close(){Ie.l(this._n+".close"),this._closeConnection(Vn),this._promiseMap.clear(),this._startSequence=Ye(),this._readyState=Wn,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}const zn=function(n,r,a){return new Promise((t,e)=>{var s="application/x-www-form-urlencoded;charset=UTF-8";if(G)F.request({url:r,data:a,method:n,timeout:3e3,header:{"content-type":s},success:e=>{e&&e.data&&e.data.NetCheckInfo&&Ie.l("getconninfo ok in miniapp. ret:",e.data),t()},fail:()=>{e(new Hs({code:Ws.NETWORK_ERROR}))}});else{const i=new XMLHttpRequest,o=setTimeout(()=>{i.abort(),e(new Hs({code:Ws.NETWORK_TIMEOUT}))},3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(o),200===i.status||304===i.status?(i.responseText&&-1<i.responseText.indexOf("NetCheckInfo")&&Ie.l("getconninfo ok in web. ret:",JSON.parse(i.responseText)),t()):e(new Hs({code:Ws.NETWORK_ERROR})))},i.open(n,r,!0),i.setRequestHeader("Content-type",s),a?i.send(a):i.send()}})};class jn extends Js{constructor(e){if(super(e),this._n="ChannelModule",this._socketHandler=new Yn(this),this._probing=!1,this._isAppShowing=!0,this._previousState=t.NET_STATE_CONNECTED,G&&"function"==typeof F.onAppShow&&"function"==typeof F.onAppHide){const e=this._onAppHide.bind(this),t=this._onAppShow.bind(this);"function"==typeof F.offAppHide&&F.offAppHide(e),"function"==typeof F.offAppShow&&F.offAppShow(t),F.onAppHide(e),F.onAppShow(t)}this._timerForNotLoggedIn=-1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._fatalErrorFlag=!1,this._disconnectedTS=0,this._diagnoseTS=0}onCheckTimer(e){this._socketHandler&&(this.isLoggedIn()?(0<this._timerForNotLoggedIn&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}onErrorCodeNotZero(e){this.get(Ls).onErrorCodeNotZero(e)}onMessage(e){this.get(Ls).onMessage(e)}send(e){return this._socketHandler?this._previousState!==t.NET_STATE_CONNECTED&&e.head.servcmd.includes(Qs.SSO_STAT)?(this.reConnect(),this.isPrivateNetWork()?Promise.resolve():this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}_sendLogViaHTTP(e){var t=`${M.HOST.CURRENT.STAT}/v4/imopenstat/tim_web_report_v2?sdkappid=${e.head.sdkappid}&reqtime=`+Date.now(),e=JSON.stringify(e.body);return zn("POST",t,e)}simplySend(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}onOpen(){this._ping()}onClose(){this._socketHandler&&this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED),this.reConnect()}onError(){G&&!P&&this.outputWarning("DomainNameInMP"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}getKeyMap(e){return this.get(Ls).getKeyMap(e)}_onAppHide(){this._isAppShowing=!1}_onAppShow(){this._isAppShowing=!0}onRequestTimeout(e){15e3<=Date.now()-this._disconnectedTS&&this.diagnose()}onReconnected(){Ie.l(this._n+".onReconnected cost:"+St(this._disconnectedTS,!0,!1)),this._m.restartTimer(),this.get(Ls).onReconnected(St(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED)}onReconnectFailed(){Ie.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());var i=`forcedFlag:${e} fatalErrorFlag:${this._fatalErrorFlag} previousState:${this._previousState} reconnectFlag:`+s;if(Ie.l(this._n+".reConnect "+i),!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(s){this._previousState!==s&&(Ie.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to `+s),s===t.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now(),this.diagnose()),this._previousState=s,this.emitOuterEvent(e.NET_STATE_CHANGE,{state:s}))}_ping(){var e;!0!==this._probing&&(this._probing=!0,e=this.get(Ls).getProtocolData({proto:Qs.PING}),this.send(e).then(()=>{this._probing=!1}).catch(e=>{if(Ie.w(this._n+"._ping failed. error:",e),this._probing=!1,e&&60002===e.code)return new pi("error").setMessage(`code:${e.code} message:`+e.message).end(),this._fatalErrorFlag=!0,void this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED);this.get(Es).isOnline()?this.reConnect():this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}))}_checkNextPing(){this._socketHandler&&this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping()}dealloc(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),-1<this._timerForNotLoggedIn&&clearInterval(this._timerForNotLoggedIn)}onRestApiKickedOut(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}diagnose(){this.isPrivateNetWork()||(this._disconnectedTS=Date.now(),this._diagnoseBySSO(),this._diagnoseByCDN())}_diagnoseBySSO(){const e=this._socketHandler.getURL(),t=e.split("/")[2];var s;t.startsWith("ws")&&(s=`https://${t}/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=`+Date.now(),zn("GET",s).catch(e=>{Ie.w(this._n+"._diagnoseBySSO failed. error:",e)}))}_diagnoseByCDN(){const e=this._socketHandler.getURL(),t=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=`+Date.now();zn("GET",t).catch(e=>{Ie.w(this._n+"._diagnoseByCDN failed. error:",e)})}reset(){Ie.l(this._n+".reset"),this._previousState=t.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0,this._diagnoseTS=0}}class Xn{constructor(e){this._n="ProtocolHandler",this._sessionM=e,this._configMap=new Map,this._fillConfigMap()}_fillConfigMap(){this._configMap.clear();var i=this._sessionM.genCommonHead(),e=this._sessionM.genCosSpecifiedHead(),t=this._sessionM.genSSOReportHead();this._configMap.set(Qs.LOGIN,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.LOGIN},body:{state:"Online",isWebUniapp:0,deviceBrand:0},keyMap:{request:{deviceBrand:"InstType"},response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}),this._configMap.set(Qs.LOGOUT,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.LOGOUT},body:{type:0},keyMap:{request:{type:"wslogout_type"}}}),this._configMap.set(Qs.HELLO,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.HELLO},body:{isWebUniapp:0},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}),this._configMap.set(Qs.KICK_OTHER,{head:{...i,servcmd:M.NAME.STAT_SERVICE+"."+Qs.KICK_OTHER},body:{}}),this._configMap.set(Qs.COS_SIGN,{head:{...e,servcmd:M.NAME.IM_COS_SIGN+"."+Qs.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"}}}),this._configMap.set(Qs.COS_PRE_SIG,{head:{...e,servcmd:M.NAME.CUSTOM_UPLOAD+"."+Qs.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"}}}),this._configMap.set(Qs.SIMPLE_COS_PRE_SIG,{head:{...e,servcmd:M.NAME.CUSTOM_UPLOAD+"."+Qs.SIMPLE_COS_PRE_SIG},body:{uploadMethod:0,platform:2,SDKAppID:0,userID:"",conversationType:1,uploadConfig:[{fileID:1,fileType:1,fileName:""}]},keyMap:{request:{platform:"uint32_platform",SDKAppID:"uint32_sdkappid",userID:"str_user_id",uploadMethod:"uint32_upload_method",conversationType:"uint32_scene",uploadConfig:"rpt_upload_object",fileID:"uint32_file_id",fileType:"uint32_file_type",fileName:"str_file_name"},response:{str_final_ip:"uploadIP",rpt_pre_sig:"preSig",uint32_file_id:"fileID",uint32_exist_flag:"existFlag",str_download_url:"downloadUrl",str_upload_url:"uploadUrl",str_snapshot_url:"requestSnapshotUrl",str_file_key:"fileKey"}}}),this._configMap.set(Qs.GET_IMAGE_INFO,{head:{...e,servcmd:M.NAME.CUSTOM_UPLOAD+"."+Qs.GET_IMAGE_INFO},body:{imageUrl:""},keyMap:{request:{imageUrl:"str_image_url"},response:{rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}),this._configMap.set(Qs.GET_IP,{head:{...e,servcmd:M.NAME.CUSTOM_UPLOAD+"."+Qs.GET_IP},body:{domainName:""},keyMap:{request:{domainName:"str_domain"},response:{str_final_ip:"ip"}}}),this._configMap.set(Qs.VIDEO_COVER,{head:{...e,servcmd:M.NAME.CUSTOM_UPLOAD+"."+Qs.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"}}}),this._configMap.set(Qs.FETCH_COMMERCIAL_CONFIG,{head:{...i,servcmd:M.NAME.IM_CONFIG_MANAGER+"."+Qs.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"}}}),this._configMap.set(Qs.PUSHED_COMMERCIAL_CONFIG,{head:{...i,servcmd:M.NAME.IM_CONFIG_MANAGER+"."+Qs.PUSHED_COMMERCIAL_CONFIG},body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}),this._configMap.set(Qs.FETCH_CLOUD_CTRL_CONFIG,{head:{...i,servcmd:M.NAME.IM_CONFIG_MANAGER+"."+Qs.FETCH_CLOUD_CTRL_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"}}}),this._configMap.set(Qs.PUSHED_CLOUD_CTRL_CONFIG,{head:{...i,servcmd:M.NAME.IM_CONFIG_MANAGER+"."+Qs.PUSHED_CLOUD_CTRL_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"}}}),this._configMap.set(Qs.OVERLOAD_NOTIFY,{head:{...i,servcmd:M.NAME.OVERLOAD_PUSH+"."+Qs.OVERLOAD_NOTIFY},body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}),this._configMap.set(Qs.SYNC_UNREAD_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.SYNC_UNREAD_MSG},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"}}}),this._configMap.set(Qs.GET_PROFANITY_LIST,{head:{...i,servcmd:M.NAME.IM_MSG_AUDIT_MGR+"."+Qs.GET_PROFANITY_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"}}}),this._configMap.set(Qs.SEND_C2C_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.SEND_C2C_MSG},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,isRelayMessage: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"}}}),this._configMap.set(Qs.SEND_GRP_MSG,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.SEND_GRP_MSG},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,isRelayMessage: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"}}}),this._configMap.set(Qs.REVOKE_C2C_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.REVOKE_C2C_MSG},body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}),this._configMap.set(Qs.REVOKE_GRP_MSG,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.REVOKE_GRP_MSG},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}),this._configMap.set(Qs.GET_C2C_ROAMING_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.GET_C2C_ROAMING_MSG},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"}}}),this._configMap.set(Qs.MODIFY_C2C_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.MODIFY_C2C_MSG},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"}}}),this._configMap.set(Qs.GET_GRP_ROAMING_MSG,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_ROAMING_MSG},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",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",NextReqMsgSeq:"nextSequence"}}}),this._configMap.set(Qs.SET_C2C_MSG_READ,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.SET_C2C_MSG_READ},body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}),this._configMap.set(Qs.SET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.SET_C2C_PEER_MUTE_NOTIFICATIONS},body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}),this._configMap.set(Qs.GET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.GET_C2C_PEER_MUTE_NOTIFICATIONS},body:{toAccount:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Peer_Account"},response:{MuteNotificationsList:"muteFlagList"}}}),this._configMap.set(Qs.SET_GRP_MSG_READ,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.SET_GRP_MSG_READ},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}),this._configMap.set(Qs.SET_ALL_MSG_READ,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.SET_ALL_MSG_READ},body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}),this._configMap.set(Qs.DEL_C2C_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.DEL_C2C_MSG},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}),this._configMap.set(Qs.DEL_GRP_MSG,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.DEL_GRP_MSG},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}),this._configMap.set(Qs.TRANSLATE_TEXT,{head:{...i,servcmd:M.NAME.IM_OPEN_TRANSLATE+"."+Qs.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"}}}),this._configMap.set(Qs.VOICE_TO_TEXT,{head:{...i,servcmd:M.NAME.IM_OPEN_SPEECH+"."+Qs.VOICE_TO_TEXT},body:{url:"",SDKAppID:0,format:"",sourceType:0,language:""},keyMap:{request:{url:"BytesUrl",SDKAppID:"Uint32Sdkappid",format:"BytesVoiceFormat",sourceType:"Uint64SourceType",language:"BytesEngServiceType"},response:{BytesRequestid:"requestID",BytesResult:"result",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}),this._configMap.set(Qs.MODIFY_GRP_MSG,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.MODIFY_GRP_MSG},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"}}}),this._configMap.set(Qs.GET_READ_RECEIPT,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}),this._configMap.set(Qs.SEND_C2C_READ_RECEIPT,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.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"}}}),this._configMap.set(Qs.SEND_READ_RECEIPT,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.SEND_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}),this._configMap.set(Qs.GET_READ_RECEIPT_DETAIL,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.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"}}}),this._configMap.set(Qs.MODIFY_C2C_MSG_EXT,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.MODIFY_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}),this._configMap.set(Qs.GET_C2C_MSG_EXT,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}),this._configMap.set(Qs.MODIFY_GRP_MSG_EXT,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.MODIFY_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}),this._configMap.set(Qs.GET_GRP_MSG_EXT,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}),this._configMap.set(Qs.MSG_CLOUD_SEARCH,{head:{...i,servcmd:M.NAME.MSG_SEARCH+"."+Qs.MSG_CLOUD_SEARCH},body:{keywordList:void 0,keywordListMatchType:"or",account:void 0,groupID:void 0,count:100,cursor:void 0,messageTypeList:void 0,senderUserIDList:void 0,startTime:void 0,endTime:void 0},keyMap:{request:{keywordListMatchType:"MatchType",account:"PeerAccount",groupID:"GroupID",messageTypeList:"MsgTypeList",senderUserIDList:"SendUserIDList"},response:{GroupID:"groupID",UserID:"userID",Count:"messageCount",LastMsgTime:"lastMessageTime",ConversationMsgs:"searchResult",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer",MsgSeq:"sequence",ReqMsgSeq:"sequence",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgContent:"content",ClientSeq:"clientSequence",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList",ErrorCode:"code",ErrorInfo:"message"}}}),this._configMap.set(Qs.ADD_C2C_MSG_REACTION,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.ADD_C2C_MSG_REACTION},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Add_Account"}}}),this._configMap.set(Qs.RM_C2C_MSG_REACTION,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.RM_C2C_MSG_REACTION},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Del_Account"}}}),this._configMap.set(Qs.GET_C2C_MSG_REACTIONS,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_C2C_MSG_REACTIONS},body:{from:void 0,to:void 0,messageKeyList:void 0,count:void 0}}),this._configMap.set(Qs.GET_C2C_MSG_REACTION_USER_LIST,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_C2C_MSG_REACTION_USER_LIST},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,count:void 0}}),this._configMap.set(Qs.ADD_GRP_MSG_REACTION,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.ADD_GRP_MSG_REACTION},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Add_Account"}}}),this._configMap.set(Qs.RM_GRP_MSG_REACTION,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.RM_GRP_MSG_REACTION},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{request:{userIDList:"Del_Account"}}}),this._configMap.set(Qs.GET_GRP_MSG_REACTIONS,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_GRP_MSG_REACTIONS},body:{groupID:void 0,topicID:void 0,messageSequenceList:void 0,count:void 0},keyMap:{response:{MsgSeq:"messageSequence"}}}),this._configMap.set(Qs.GET_GRP_MSG_REACTION_USER_LIST,{head:{...i,servcmd:M.NAME.OPEN_IM_MSG_EXT+"."+Qs.GET_GRP_MSG_REACTION_USER_LIST},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,nextSeq:void 0,count:void 0}}),this._configMap.set(Qs.GET_C2C_PEER_READ_TIME,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.GET_C2C_PEER_READ_TIME},body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}),this._configMap.set(Qs.PAGING_GET_CONV_LIST,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.PAGING_GET_CONV_LIST},body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:15,assistFlag:31},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",C2cRemark:"friendRemark",MsgRecvOption:"messageRemindType",GroupIgnoredUnreadSeqCount:"noUnreadCount",GroupNextMsgSeq:"nextMessageSeq"}}}),this._configMap.set(Qs.DEL_CONV,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.DEL_CONV},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"}}}),this._configMap.set(Qs.CLEAR_HISTORY_MSG,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.CLEAR_HISTORY_MSG},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{request:{toGroupID:"ToGroupid"}}}),this._configMap.set(Qs.PIN_CONV,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.PIN_CONV},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}),this._configMap.set(Qs.DEL_GROUP_AT_TIPS,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.DEL_GROUP_AT_TIPS},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._configMap.set(Qs.SET_CONV_CUSTOM_DATA,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}),this._configMap.set(Qs.MARK_CONV,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},response:{ToGroupId:"groupID",OptType:"operationType"}}}),this._configMap.set(Qs.CREATE_CONV_GRP,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.RENAME_CONV_GRP},body:{fromAccount:"",itemList:void 0},keyMap:{request:{itemList:"GroupContactItem",groupID:"ToGroupId"},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}),this._configMap.set(Qs.DEL_CONV_GRP,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.DEL_CONV_GRP},body:{fromAccount:"",groupName:void 0},keyMap:{request:{},response:{GroupId:"convGroupID"}}}),this._configMap.set(Qs.RENAME_CONV_GRP,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.RENAME_CONV_GRP},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"}}}),this._configMap.set(Qs.ADD_CONV_TO_GRP,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}},keyMap:{request:{},response:{}}}),this._configMap.set(Qs.DEL_CONV_FROM_GRP,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{request:{},response:{}}}),this._configMap.set(Qs.GET_CONV_GRP_LIST,{head:{...i,servcmd:M.NAME.RECENT_CONTACT+"."+Qs.GET_CONV_GRP_LIST},body:{fromAccount:"",startTime:void 0,startIndex:void 0},keyMap:{request:{},response:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList"}}}),this._configMap.set(Qs.GET_USER_PROFILE,{head:{...i,servcmd:M.NAME.PROFILE+"."+Qs.GET_USER_PROFILE},body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._configMap.set(Qs.UPDATE_MY_PROFILE,{head:{...i,servcmd:M.NAME.PROFILE+"."+Qs.UPDATE_MY_PROFILE},body:{fromAccount:"",profileItem:[{tag:Ce.NICK,value:""},{tag:Ce.GENDER,value:""},{tag:Ce.ALLOWTYPE,value:""},{tag:Ce.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._configMap.set(Qs.GET_BL,{head:{...i,servcmd:M.NAME.FD+"."+Qs.GET_BL},body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}),this._configMap.set(Qs.ADD_TO_BL,{head:{...i,servcmd:M.NAME.FD+"."+Qs.ADD_TO_BL},body:{fromAccount:"",toAccount:[]}}),this._configMap.set(Qs.RM_FROM_BL,{head:{...i,servcmd:M.NAME.FD+"."+Qs.RM_FROM_BL},body:{fromAccount:"",toAccount:[]}}),this._configMap.set(Qs.SET_SELF_STATUS,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.SET_SELF_STATUS},body:{customStatus:""},keyMap:{}}),this._configMap.set(Qs.GET_USER_STATUS,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.GET_USER_STATUS},body:{userIDList:void 0},keyMap:{response:{UserStatusList:"successUserList",ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID",Status:"statusType"}}}),this._configMap.set(Qs.SUB_USER_STATUS,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.SUB_USER_STATUS},body:{userIDList:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._configMap.set(Qs.UNSUB_USER_STATUS,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.UNSUB_USER_STATUS},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{response:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._configMap.set(Qs.GET_FD_LIST,{head:{...i,servcmd:M.NAME.FD+"."+Qs.GET_FD_LIST},body:{fromAccount:"",startIndex:0,standardSequence:0,customSequence:0},keyMap:{response:{FriendNum:"friendCount",UserDataItem:"resultList",ValueItem:"tagValueList"}}}),this._configMap.set(Qs.ADD_FD,{head:{...i,servcmd:M.NAME.FD+"."+Qs.ADD_FD},body:{fromAccount:"",addFriendItem:[],type:""},keyMap:{request:{source:"AddSource",wording:"AddWording",type:"AddType"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.UPDATE_FD,{head:{...i,servcmd:M.NAME.FD+"."+Qs.UPDATE_FD},body:{fromAccount:"",updateItem:void 0},keyMap:{request:{snsItem:"SnsItem"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.DEL_FD,{head:{...i,servcmd:M.NAME.FD+"."+Qs.DEL_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"DeleteType"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.GET_FD_PROFILE,{head:{...i,servcmd:M.NAME.FD+"."+Qs.GET_FD_PROFILE},body:{fromAccount:"",userIDList:void 0},keyMap:{response:{InfoItem:"resultList",SnsProfileItem:"tagValueList"}}}),this._configMap.set(Qs.CHECK_FD,{head:{...i,servcmd:M.NAME.FD+"."+Qs.CHECK_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{request:{type:"CheckType"},response:{InfoItem:"resultList"}}}),this._configMap.set(Qs.GET_FD_APPLICATION_LIST,{head:{...i,servcmd:M.NAME.FD+"."+Qs.GET_FD_APPLICATION_LIST},body:{fromAccount:"",applicationType:"",startTime:0,maxLimited:0,lastSequence:0},keyMap:{response:{PendencyItem:"resultList",AddSource:"source",AddTime:"time",AddWording:"wording",Image:"avatar",UnreadPendencyCount:"unreadCount",To_Account:"userID",PendencyType:"type"}}}),this._configMap.set(Qs.RESPOND_FD_APPLICATION,{head:{...i,servcmd:M.NAME.FD+"."+Qs.RESPOND_FD_APPLICATION},body:{fromAccount:"",responseFriendItem:[]},keyMap:{request:{tag:"TagName",action:"ResponseAction"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.DEL_FD_APPLICATION,{head:{...i,servcmd:M.NAME.FD+"."+Qs.DEL_FD_APPLICATION},body:{fromAccount:"",type:"",userIDList:void 0},keyMap:{request:{type:"PendencyType",userIDList:"To_Account"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.REPORT_FD_APPLICATION,{head:{...i,servcmd:M.NAME.FD+"."+Qs.REPORT_FD_APPLICATION},body:{fromAccount:"",latestTimeStamp:""},keyMap:{request:{latestTimeStamp:"LatestPendencyTimeStamp"}}}),this._configMap.set(Qs.CREATE_FD_GRP,{head:{...i,servcmd:M.NAME.FD+"."+Qs.CREATE_FD_GRP},body:{fromAccount:"",groupName:void 0,userIDList:void 0},keyMap:{request:{groupName:"GroupName",userIDList:"To_Account"},response:{ResultItem:"resultList"}}}),this._configMap.set(Qs.DEL_FD_GRP,{head:{...i,servcmd:M.NAME.FD+"."+Qs.DEL_FD_GRP},body:{fromAccount:"",nameList:void 0},keyMap:{request:{nameList:"GroupName"}}}),this._configMap.set(Qs.GET_FD_GRP_LIST,{head:{...i,servcmd:M.NAME.FD+"."+Qs.GET_FD_GRP_LIST},body:{fromAccount:"",lastSequence:0,needFriend:"Need_Friend_Type_Yes"},keyMap:{response:{ResultItem:"resultList",GroupName:"name",FriendNumber:"friendCount",To_Account:"userIDList"}}}),this._configMap.set(Qs.UPDATE_FD_GRP,{head:{...i,servcmd:M.NAME.FD+"."+Qs.UPDATE_FD_GRP},body:{fromAccount:"",oldName:"",newName:void 0,updateGroupItem:void 0},keyMap:{request:{oldName:"GroupOldName",newName:"GroupNewName"},response:{UpdateType:"type",ResultItem:"resultList"}}}),this._configMap.set(Qs.GET_GRP_LIST,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_LIST},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"}}}),this._configMap.set(Qs.GET_GRP_PROFILE,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_PROFILE},body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:void 0,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"}}}),this._configMap.set(Qs.CREATE_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.CREATE_GRP},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"}}}),this._configMap.set(Qs.DISMISS_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.DISMISS_GRP},body:{groupID:void 0}}),this._configMap.set(Qs.UPDATE_GRP_PROFILE,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.UPDATE_GRP_PROFILE},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"}}}),this._configMap.set(Qs.APPLY_JOIN_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.APPLY_JOIN_GRP},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"}}}),this._configMap.set(Qs.APPLY_JOIN_GRP_NOAUTH,function(){const{a2:e,tinyid:t,...s}=i;return{head:{...s,servcmd:M.NAME.BIG_GRP_NO_AUTH+"."+Qs.APPLY_JOIN_GRP},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}()),this._configMap.set(Qs.QUIT_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.QUIT_GRP},body:{groupID:void 0}}),this._configMap.set(Qs.SEARCH_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.SEARCH_GRP},body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"]}},keyMap:{response:{}}}),this._configMap.set(Qs.CHANGE_GRP_OWNER,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.CHANGE_GRP_OWNER},body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}),this._configMap.set(Qs.HANDLE_GRP_APPLICATION,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.HANDLE_GRP_APPLICATION},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"}}}),this._configMap.set(Qs.HANDLE_INVITE_JOIN_GRP,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.HANDLE_INVITE_JOIN_GRP},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"}}}),this._configMap.set(Qs.HANDLE_GRP_INVITATION,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.HANDLE_GRP_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"}}}),this._configMap.set(Qs.GET_GRP_PENDENCY,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_PENDENCY},body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"},response:{To_Account:"userID",ApplyInviteMsg:"note"}}}),this._configMap.set(Qs.DEL_GRP_SYSTEM_NOTICE,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.DEL_GRP_SYSTEM_NOTICE},body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._configMap.set(Qs.AV_POLLING,{head:{...i,servcmd:M.NAME.BIG_GRP_POLLING+"."+Qs.AV_POLLING},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"}}}),this._configMap.set(Qs.AV_NOAUTH_POLLING,function(){const{a2:e,tinyid:t,...s}=i;return{head:{...s,servcmd:M.NAME.BIG_GRP_POLLING_NO_AUTH+"."+Qs.AV_POLLING},body:{USP:1,startSeq:1,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}()),this._configMap.set(Qs.GET_ONLINE_MBR_NUM,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_ONLINE_MBR_NUM},body:{groupID:void 0},keyMap:{response:{OnlineMemberNum:"memberCount"}}}),this._configMap.set(Qs.SET_GRP_ATTR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.SET_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}),this._configMap.set(Qs.MODIFY_GRP_ATTR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.MODIFY_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}),this._configMap.set(Qs.DEL_GRP_ATTR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.DEL_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}),this._configMap.set(Qs.CLEAR_GRP_ATTR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.CLEAR_GRP_ATTR},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}),this._configMap.set(Qs.GET_GRP_ATTR,{head:{...i,servcmd:M.NAME.GRP_ATTR+"."+Qs.GET_GRP_ATTR},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}),this._configMap.set(Qs.GET_GRP_NOTIFY,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_NOTIFY},body:{notifyReqList:[]},keyMap:{request:{notifyReqList:"NotifyReqList"},response:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList",NotifyRspList:"notifyRspList"}}}),this._configMap.set(Qs.UPDATE_GRP_COUNTER,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.UPDATE_GRP_COUNTER},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{request:{counterList:"GroupCounter"}}}),this._configMap.set(Qs.GET_GRP_COUNTER,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_COUNTER},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{request:{keyList:"GroupCounterKeys"}}}),this._configMap.set(Qs.CREATE_TOPIC,{head:{...i,servcmd:M.NAME.GRP_COMMUNITY+"."+Qs.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"}}}),this._configMap.set(Qs.DEL_TOPIC,{head:{...i,servcmd:M.NAME.GRP_COMMUNITY+"."+Qs.DEL_TOPIC},body:{groupID:void 0,topicIDList:void 0},keyMap:{request:{topicIDList:"TopicIdList"},response:{DestroyResultItem:"resultList"}}}),this._configMap.set(Qs.UPDATE_TOPIC_PROFILE,{head:{...i,servcmd:M.NAME.GRP_COMMUNITY+"."+Qs.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"}}}),this._configMap.set(Qs.GET_TOPIC_LIST,{head:{...i,servcmd:M.NAME.GRP_COMMUNITY+"."+Qs.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"}}}),this._configMap.set(Qs.GET_GRP_MBR_LIST,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_MBR_LIST},body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}),this._configMap.set(Qs.GET_AV_MBR_LIST,{head:{...i,servcmd:M.NAME.GRP_AV+"."+Qs.GET_AV_MBR_LIST},body:{groupID:void 0,offset:void 0,filter:void 0},keyMap:{request:{offset:"Timestamp",filter:"Mark"},response:{NextTimestamp:"offset"}}}),this._configMap.set(Qs.GET_GRP_MBR_PROFILE,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.GET_GRP_MBR_PROFILE},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"}}}),this._configMap.set(Qs.ADD_GRP_MBR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.ADD_GRP_MBR},body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}),this._configMap.set(Qs.DEL_GRP_MBR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.DEL_GRP_MBR},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}),this._configMap.set(Qs.BAN_AV_MBR,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.BAN_AV_MBR},body:{groupID:void 0,userIDList:void 0,duration:void 0,reason:""},keyMap:{request:{userIDList:"Members_Account",duration:"Duration",reason:"Description"}}}),this._configMap.set(Qs.MODIFY_GRP_MBR_INFO,{head:{...i,servcmd:M.NAME.GRP+"."+Qs.MODIFY_GRP_MBR_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"}}}),this._configMap.set(Qs.MARK_AV_MBR_INFO,{head:{...i,servcmd:M.NAME.GRP_AV+"."+Qs.MARK_AV_MBR_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"}}}),this._configMap.set(Qs.SSO_STAT,{head:{...t,servcmd:M.NAME.IM_OPEN_STAT+"."+Qs.SSO_STAT},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"}}}),this._configMap.set(Qs.PING,{head:{...i,servcmd:M.NAME.HEARTBEAT+"."+Qs.PING},body:{}}),this._configMap.set(Qs.MSG_PUSH,{head:{...i,servcmd:M.NAME.IM_OPEN_PUSH+"."+Qs.MSG_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",CurrFollowType:"followType",Follow_Account:"userID"}}}),this._configMap.set(Qs.MULTI_MSG_PUSH,{head:{...i,servcmd:M.NAME.IM_OPEN_PUSH+"."+Qs.MULTI_MSG_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"}}}),this._configMap.set(Qs.MSG_PUSH_ACK,{head:{...i,servcmd:M.NAME.OPEN_IM+"."+Qs.MSG_PUSH_ACK},body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}),this._configMap.set(Qs.STATUS_FORCE_OFFLINE,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.STATUS_FORCE_OFFLINE},body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}),this._configMap.set(Qs.DOWNLOAD_MERGER_MSG,{head:{...i,servcmd:M.NAME.IM_LONG_MSG+"."+Qs.DOWNLOAD_MERGER_MSG},body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}),this._configMap.set(Qs.UPLOAD_MERGER_MSG,{head:{...i,servcmd:M.NAME.IM_LONG_MSG+"."+Qs.UPLOAD_MERGER_MSG},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"}}}),this._configMap.set(Qs.FOLLOW,{head:{...i,servcmd:M.NAME.FOLLOW+"."+Qs.FOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{request:{userIDList:"FollowItem"},response:{ResultItem:"resultList",To_Account:"userID"}}}),this._configMap.set(Qs.UNFOLLOW,{head:{...i,servcmd:M.NAME.FOLLOW+"."+Qs.UNFOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{request:{userIDList:"To_Account"},response:{ResultItem:"resultList",To_Account:"userID"}}}),this._configMap.set(Qs.GET_FOLLOW_INFO,{head:{...i,servcmd:M.NAME.FOLLOW+"."+Qs.GET_FOLLOW_INFO},body:{fromAccount:"",userIDList:[]},keyMap:{request:{userIDList:"To_Account"},response:{FollowInfo:"followInfoList",To_Account:"userID",FollowerCount:"followersCount",FollowingCount:"followingCount",MutualFollowingCount:"mutualFollowersCount"}}}),this._configMap.set(Qs.GET_FOLLOW,{head:{...i,servcmd:M.NAME.FOLLOW+"."+Qs.GET_FOLLOW},body:{fromAccount:"",type:1,startCursor:"",count:100},keyMap:{request:{type:"FollowType",count:"WantNum"},response:{FollowItem:"resultList",To_Account:"userID",ProfileItem:"profileList"}}}),this._configMap.set(Qs.SET_TOKEN,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.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"}}}),this._configMap.set(Qs.STAT_FOREGROUND,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.STAT_FOREGROUND},body:{isWebUniapp:0}}),this._configMap.set(Qs.STAT_BACKGROUND,{head:{...i,servcmd:M.NAME.IM_OPEN_STATUS+"."+Qs.STAT_BACKGROUND},body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{request:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}})}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||{}:(Ie.w(this._n+".getKeyMap unknown proto:"+e),{})}getProtocolData(e){const{proto:t,data:s}=e,i=this.get(t);let o=null;if(s){const e=this._simpleDeepCopy(i),t=this._updateService(s,e),n=t.body,r=Object.create(null);for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)){if(r[i]=n[i],void 0===s[i])continue;r[i]=s[i]}t.body=r,o=this._getUplinkData(t)}else o=this._getUplinkData(i);return o}_getUplinkData(e){const t=this._dataCleaner(e),s=ht(t.head),i=kn(t.body,this._getRequestKeyMap(s));return t.body=i,t}_updateService(i,o){var n=ht(o.head);if(this._isFromGroupRequest(o)){let{type:e,groupID:t,groupIDList:s=[]}=i;$e(t)&&(t=s[0]||""),st({type:e,groupID:t})&&(o.head.servcmd=M.NAME.GRP_COMMUNITY+"."+n)}return o}_isFromGroupRequest(e){return e.head.servcmd.includes(M.NAME.GRP)||e.head.servcmd.includes(M.NAME.GRP_ATTR)}_getRequestKeyMap(e){e=this.getKeyMap(e);return{...Pn.request,...e.request}}_dataCleaner(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._dataCleaner.bind(this)(e[s]));return t}_simpleDeepCopy(s){const i=Object.keys(s),o={};var n;for(let e=0,t=i.length;e<t;e++)n=i[e],Fe(s[n])?o[n]=Array.from(s[n]):Ge(s[n])?o[n]=this._simpleDeepCopy(s[n]):o[n]=s[n];return o}}const Jn=[Qs.MSG_PUSH_ACK];class Qn{constructor(e){this._sessionM=e,this._n="DownlinkHandler",this._eventHandlerMap=new Map,this._eventHandlerMap.set("C2CMessageArray",this._c2cMessageArrayHandler.bind(this)),this._eventHandlerMap.set("groupMessageArray",this._groupMessageArrayHandler.bind(this)),this._eventHandlerMap.set("groupTips",this._groupTipsHandler.bind(this)),this._eventHandlerMap.set("C2CNotifyMessageArray",this._C2CNotifyMessageArrayHandler.bind(this)),this._eventHandlerMap.set("C2CReadReceiptArray",this._C2CReadReceiptArrayHandler.bind(this)),this._eventHandlerMap.set("profileModify",this._profileHandler.bind(this)),this._eventHandlerMap.set("friendListMod",this._relationChainHandler.bind(this)),this._eventHandlerMap.set("recentContactMod",this._recentContactHandler.bind(this)),this._eventHandlerMap.set("readAllC2CMessage",this._allMessageReadHandler.bind(this)),this._eventHandlerMap.set("c2cMessageModified",this._c2cMessageModifiedHandler.bind(this)),this._eventHandlerMap.set("groupMessageModified",this._groupMessageModifiedHandler.bind(this)),this._eventHandlerMap.set("userStatusList",this._userStatusListHandler.bind(this)),this._eventHandlerMap.set("messageExtensionNotify",this._messageExtensionNotifyHandler.bind(this)),this._eventHandlerMap.set("messageReactionNotifyList",this._messageReactionNotifyListHandler.bind(this)),this._eventHandlerMap.set("messageReactionNotify",this._messageReactionNotifyHandler.bind(this)),this._eventHandlerMap.set("follow",this._followInfoHandler.bind(this)),this._keys=[...this._eventHandlerMap.keys()]}_c2cMessageArrayHandler(e){const t=this._sessionM.get(Ms);t&&(e.dataList.forEach(e=>{var t;1===e.isSyncMessage&&(t=e.from,e.from=e.to,e.to=t)}),1===e.needSync&&this._sessionM.get(Rs).startOnlineSync(),t.onNewC2CMessage({dataList:e.dataList,isInstantMessage:!0}))}_c2cMessageModifiedHandler(e){const t=this._sessionM.get(Ms);t&&t.onC2CMessageModified(e)}_groupMessageArrayHandler(e){const t=this._sessionM.get(Is);t&&t.onNewGroupMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}_groupMessageModifiedHandler(e){const t=this._sessionM.get(Is);t&&t.onGroupMessageModified(e)}_groupTipsHandler(e){const t=this._sessionM.get(Is);if(t){var{event:s,dataList:i,isInstantMessage:o=!0,isSyncingEnded:n}=e;switch(s){case 4:case 6:t.onNewGroupTips({event:s,dataList:i});break;case 5:for(let e=0;e<i.length;e++)if(Fe(i[e].elements.revokedInfos))t.onGroupMessageRevoked({dataList:i});else if(Fe(i[e].elements.groupMessageReadNotice))t.onGroupMessageReadNotice({dataList:i});else{if(!Fe(i[e].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:i,isInstantMessage:o,isSyncingEnded:n});break}t.onReadReceiptList({dataList:i})}break;case 12:this._sessionM.get(Ts).onNewGroupAtTips({dataList:i});break;default:Ie.l(this._n+`._groupTipsHandler unknown event:${s} dataList:`,i)}}}_C2CNotifyMessageArrayHandler(e){const t=e["dataList"];if(Fe(t)){const s=this._sessionM.get(Ms);t.forEach(e=>{if(ke(e))if(e.hasOwnProperty("kickoutMsgNotify")){const{kickoutMsgNotify:{kickType:t,newInstanceInfo:s={}}}=e;1===t?this._sessionM.onMultipleAccountKickedOut(s):2===t?this._sessionM.onMultipleDeviceKickedOut(s):3===t&&this._sessionM.onRestApiKickedOut(s)}else e.hasOwnProperty("c2cMessageRevokedNotify")?s&&s.onC2CMessageRevoked({dataList:t}):e.hasOwnProperty("c2cMessageReadReceipt")?s&&s.onC2CMessageReadReceipt({dataList:t}):e.hasOwnProperty("c2cMessageReadNotice")?s&&s.onC2CMessageReadNotice({dataList:t}):e.hasOwnProperty("muteNotificationsSync")&&this._sessionM.get(Ts).onC2CMessageRemindTypeSynced({dataList:t})})}}_C2CReadReceiptArrayHandler(e){this._sessionM.get(Ms).onReadReceiptList(e)}_profileHandler(e){this._sessionM.get(ms).onProfileModified({dataList:e.dataList});const t=this._sessionM.get(fs);t&&t.onFriendProfileModified({dataList:e.dataList})}_relationChainHandler(e){this._sessionM.get(ms).onRelationChainModified({dataList:e.dataList});const t=this._sessionM.get(fs);t&&t.onRelationChainModified({dataList:e.dataList})}_recentContactHandler(e){const t=e["dataList"];if(Fe(t)){const n=this._sessionM.get(Ts);n&&t.forEach(e=>{const t=e["pushType"];if(1===t){const t=e["recentContactDeleteItem"];n.onConversationDeleted(t.recentContactList)}else if(2===t){const t=e["recentContactTopItem"];n.onConversationPinned(t.recentContactList)}else if(3===t){const t=e["recentContactTopItem"];n.onConversationUnpinned(t.recentContactList)}else if(4===t){const t=e["recentContactMarkContact"];n.onConversationMarkUpdated(t.recentContactMarkContactItem)}else if(5===t){const t=e["recentContactCreateContactGroup"];n.onConversationGroupCreated(t.msgContactGroupContactItem)}else if(6===t){const t=e["recentContactDelContactGroup"];n.onConversationGroupDeleted(t.msgGroupItem)}else if(7===t){const t=e["recentContactUpdateContactGroup"],{updateType:s,msgUpdateGroup:i,msgUpdateContact:o}=t;if(1===s){const e=i["updateGroupType"];1===e?n.onConversationGroupNameUpdated(i):2===e&&n.onConversationInGroupUpdated(i)}else 2===s&&n.onConversationAddedToOrDeletedFromGroup(o)}})}}_allMessageReadHandler(e){const t=e["dataList"],s=this._sessionM.get(Ts);s&&s.onPushedAllMessageRead(t)}_userStatusListHandler(e){this._sessionM.get(ms).onUserStatusUpdated(e)}_messageExtensionNotifyHandler(e){this._sessionM.get(gs).onMessageExtensionNotify(e)}_messageReactionNotifyListHandler(e){this._sessionM.get(Vs).onMessageReactionNotifyList(e)}_messageReactionNotifyHandler(e){this._sessionM.get(Vs).onMessageReactionNotify(e)}_followInfoHandler(e){this._sessionM.get(Bs).onFollowInfoNotify(e)}onMessage(s){var e=s["body"];if(this._filterMessageFromIMOpenPush(s)){var{eventArray:i,isInstantMessage:o,isSyncingEnded:n,needSync:r}=e;if(Fe(i)){var a,c,l;for(let e=0,t=i.length;e<t;e++)if(100!==(l=(a=i[e]).event)){const s=Object.keys(a).find(e=>-1!==this._keys.indexOf(e));s?(c=14===l?{readAllC2CMessage:a[s],groupMessageReadInfoList:a.groupMessageReadNotice||[]}:16===l?{userID:a.userID,readReceiptList:a[s]}:a[s],this._eventHandlerMap.get(s)({event:l,dataList:c,isInstantMessage:o,isSyncingEnded:n,needSync:r})):Ie.l(this._n+".onMessage unknown eventItem:"+a)}else this._onRoomCustomData(a.content)}}}_onRoomCustomData(e){this._sessionM.get(ws).onRoomCustomDataReceived(e)}_filterMessageFromIMOpenPush(e){const{head:t,body:s}=e,i=t["servcmd"];let o=!1;if(!(o=$e(i)?o:i.includes(M.NAME.IM_CONFIG_MANAGER)||i.includes(M.NAME.OVERLOAD_PUSH)||i.includes(M.NAME.STAT_SERVICE)))return!0;if(i.includes(Qs.PUSHED_CLOUD_CTRL_CONFIG))this._sessionM.get(Os).onPushedCloudControlConfig(s);else if(i.includes(Qs.PUSHED_COMMERCIAL_CONFIG))this._sessionM.get(ks).onPushedConfig(s);else if(i.includes(Qs.OVERLOAD_NOTIFY))this._sessionM.onPushedServerOverload(s);else if(i.includes(Qs.KICK_OTHER)){const e=Date.now(),t=(this._sessionM.reLoginOnKickOther(),new pi("kickOther")),s=this._sessionM.get(ps).getLastWsHelloTs(),i=e-s;t.setMessage(`last wshello time:${s} diff:${i}ms`).end()}return!1}}const Zn=[{cmd:Qs.GET_GRP_PROFILE,interval:1,count:8},{cmd:Qs.UPDATE_GRP_PROFILE,interval:1,count:8},{cmd:Qs.GET_AVCHATROOM_MBR_LIST,interval:3,count:1},{cmd:Qs.GET_GRP_PENDENCY,interval:1,count:15},{cmd:Qs.GET_TOPIC_LIST,interval:1,count:10},{cmd:Qs.SET_GRP_ATTR,interval:5,count:10},{cmd:Qs.MODIFY_GRP_ATTR,interval:5,count:10},{cmd:Qs.DEL_GRP_ATTR,interval:5,count:10},{cmd:Qs.CLEAR_GRP_ATTR,interval:5,count:10},{cmd:Qs.GET_GRP_ATTR,interval:5,count:20},{cmd:Qs.UPDATE_GRP_COUNTER,interval:5,count:20},{cmd:Qs.GET_GRP_COUNTER,interval:5,count:20},{cmd:Qs.SET_ALL_MSG_READ,interval:1,count:1},{cmd:Qs.GET_USER_STATUS,interval:5,count:20},{cmd:Qs.SUB_USER_STATUS,interval:5,count:20},{cmd:Qs.UNSUB_USER_STATUS,interval:5,count:20},{cmd:Qs.MSG_CLOUD_SEARCH,interval:1,count:2}],eo=new Map,to=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=to.length;e<t;e++)eo.set(e,to[e]);function so(s){let i,o,n=s,r="";for(let e=0,t=(n=s.length%8!=0?"0".repeat(8-s.length%8)+s:n).length;e<t;e+=8)i=parseInt(n.slice(e,e+4),2),o=parseInt(n.slice(e+4,e+8),2),r+=eo.get(i)+eo.get(o);return r}class io extends Js{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._protocolHandler=new Xn(this),this._messageDispatcher=new Qn(this),this._commandFrequencyLimitMap=new Map,this._commandRequestInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._incrementalPullContactFlag=!0,this._init(),this.getInnerEmitterInstance().on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){this._updateCommandFrequencyLimitMap(Zn)}_onCloudConfigUpdated(){var e=this.getCloudConfig("cmd_frequency_limit");$e(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()}req(e){Ie.d(this._n+".req options:",e);var{proto:t,tjgID:s}=e;if(!this._protocolHandler.has(t))return Ie.w(this._n+".req unknown proto:"+t),Xs({code:Ws.CANNOT_FIND_PROTOCOL});const i=this.getProtocolData(e),o=i.head["servcmd"];let n;if(this._isFrequencyOverLimit(o))return n=Ws.OVER_FREQUENCY_LIMIT,Xs({code:n,message:this.getErrorMessage(n,this._getCmd(o))});if(this._isServerOverload(o))return n=Ws.OPEN_SERVICE_OVERLOAD_ERROR,Xs({code:n,message:this.getErrorMessage(n,this._getCmd(o))});Re(s)||(i.head.tjgID=s);const r=this.get(Ns);return Jn.includes(t)?r.simplySend(i):r.send(i)}getKeyMap(e){return this._protocolHandler.getKeyMap(e)}genCommonHead(){const e=this.get(ys);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,sdkability_ext:so(""),cappid:e.getApplicationID(),tjgID:""}}genCosSpecifiedHead(){const e=this.get(ys);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,sdkability_ext:so(""),cappid:e.getApplicationID()}}genSSOReportHead(){const e=this.get(ys);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:192371,sdkability_ext:so(""),cappid:e.getApplicationID()}}getProtocolData(e){return this._protocolHandler.getProtocolData(e)}trans(e){var{servcmd:e,data:t}=e,e={head:{...this.genCommonHead(),servcmd:e},body:t};return this.get(Ns).send(e)}sendComboMessage(e){var{servcmd:e,data:t}=e,e={head:{...this.genCommonHead(),servcmd:e},body:t};return this.get(Ns).send(e)}onErrorCodeNotZero(e){const t=e["errorCode"];if(t===Ws.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)}t!==Ws.MSG_A2KEY_EXPIRED&&t!==Ws.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.get(Ns).reConnect())}onMessage(e){var t=e["body"],{needAck:t=0,sessionData:s}=t;1===t&&this._sendACK(s),this._messageDispatcher.onMessage(e)}onReconnected(e){this._incrementalPullContactFlag=e<=300,this._reLoginOnReconnected()}reLoginOnKickOther(){Ie.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){Ie.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){const o=this._n+"._reLogin";if(this.isLoggedIn()){let e=0;const t=this.get(Fs);t.canIUseOfflinePush()&&(e=t.getUniAppPlatform()),this.req({proto:Qs.LOGIN,data:{isWebUniapp:e}}).then(e=>{e=e.data.instanceID;this.get(ys).setStatusInstanceID(e),Ie.l(o+" ok. instanceID:"+e),this.get(Ns).diagnose(),this.get(Ts).syncConversationList(this._incrementalPullContactFlag).then(()=>{Ie.l(o+", sync conversation list ok."),this.get(Us).start()});const t=this.get(Is),s=(t&&t.updateLocalMainSequenceOnReconnected(),this.get(Cs)),i=(s.resetGetTopicTime(),s.getTopicListOnReconnected(),this.get(Bs));i&&i.getMyFollowInfoOnReconnected()})}}onMultipleAccountKickedOut(e){this.get(ps).onMultipleAccountKickedOut(e)}onMultipleDeviceKickedOut(e){this.get(ps).onMultipleDeviceKickedOut(e)}_onUserSigExpired(){this.get(ps).onUserSigExpired()}onRestApiKickedOut(e){this.get(ps).onRestApiKickedOut(e)}_sendACK(e){this.req({proto:Qs.MSG_PUSH_ACK,data:{sessionData:e}})}_isFrequencyOverLimit(e){e=e.split(".")[1];if(!this._commandFrequencyLimitMap.has(e))return!1;if(!this._commandRequestInfoMap.has(e))return this._commandRequestInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;var{count:t,interval:s}=this._commandFrequencyLimitMap.get(e),{startTime:i,requestCount:o}=this._commandRequestInfoMap.get(e);if(Date.now()-i>1e3*s)return this._commandRequestInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;this._commandRequestInfoMap.set(e,{startTime:i,requestCount:o+=1});let n=t<o?!0:!1;return n}_isServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return!1;var{overloadTime:t,waitingTime:s}=this._serverOverloadInfoMap.get(e);let i=!1;return i=Date.now()-t<=1e3*s||(this._serverOverloadInfoMap.delete(e),!1)}_getCmd(e){let t="";if(!e.includes("."))return t;var s=e.split(".")[1];for(const i in Qs)if(Qs[i]===s){t=i;break}return t}onPushedServerOverload(e){var{overloadCommand:e,waitingTime:t}=e;this._serverOverloadInfoMap.set(e,{overloadTime:Date.now(),waitingTime:t}),Ie.w(this._n+`.onPushedServerOverload waitingTime:${t}s cmd:`+this._getCmd(e))}reset(){Ie.l(this._n+".reset"),this._updateCommandFrequencyLimitMap(Zn),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}class no extends Js{constructor(e){super(e),this._n="CloudControlModule",this._cloudConfig=new Map,this._expiredTime=0,this._version=0,this._isFetching=!1}getCloudConfig(e){return $e(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}getServerConfig(e){const t={code:0,data:""};return!$e(e)&&this._cloudConfig.has(e)&&(t.data=this._cloudConfig.get(e)),Promise.resolve(t)}_canFetchConfig(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}fetchConfig(){var e=this._canFetchConfig();if(Ie.l(this._n+".fetchConfig canFetchConfig:"+e),e){const t=new pi("fetchCloudControlConfig"),s=this.get(ys).getSDKAppID();this._isFetching=!0,this.req({proto:Qs.FETCH_CLOUD_CTRL_CONFIG,data:{SDKAppID:s,version:this._version}}).then(e=>{this._isFetching=!1,t.setMessage(`version:${this._version} newVersion:${e.data.version} config:`+e.data.cloudControlConfig).end(),Ie.l(this._n+".fetchConfig ok"),this._parseCloudControlConfig(e.data)}).catch(e=>{this._isFetching=!1,t.setError(e).end(),Ie.l(this._n+".fetchConfig failed. error:",e),this._setExpiredTimeOnResponseError(12e4)})}}onPushedCloudControlConfig(e){Ie.l(this._n+".onPushedCloudControlConfig"),new pi("pushedCloudControlConfig").setMessage(`newVersion:${e.version} config:`+e.cloudControlConfig).end(),this._parseCloudControlConfig(e)}onCheckTimer(e){this._canFetchConfig()&&this.fetchConfig()}_parseCloudControlConfig(e){var s=this._n+"._parseCloudControlConfig",{errorCode:t,errorMessage:i,cloudControlConfig:o,version:n,expiredTime:r}=e;if(0===t){if(this._version!==n){let t=null;try{t=JSON.parse(o)}catch(e){this.isPrivateNetWork()||Ie.e(s+" JSON parse error. cloudControlConfig:",o)}t&&(this._cloudConfig.clear(),Object.keys(t).forEach(e=>{this._cloudConfig.set(e,t[e])}),this._version=n,this.emitInnerEvent(Pi.CLOUD_CONFIG_UPDATED))}this._expiredTime=Date.now()+1e3*r}else $e(t)?(Ie.l(s+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(Ie.e(s+` errorCode:${t} errorMessage:`+i),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}reset(){Ie.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class oo extends Js{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),o=this.get(Ts);let n,r,a,c,l;const d=[];e.forEach(e=>{const{conversationID:s,lastMessage:i}=e;r=s.replace(t.CONV_GROUP,""),n=o.getLocalLastMessage(s),i&&0!==i.lastSequence&&n?(c=i.lastSequence,a=n.sequence,l=c-a,0<a&&1<=l&&l<300?this._recoverGroupMessage({groupID:r,localLastMessageSequence:a,remoteLastMessageSequence:c}):d.push(r)):d.push(r)}),this._getGroupNotify(d)}_recoverC2CChat(){const e=this._getLocalConversationList().filter(e=>e.type===t.CONV_C2C),s=this.get(Ts);let i,o,n,r;const a=[Promise.resolve()];e.forEach(e=>{var{conversationID:e,lastMessage:t}=e;i=s.getLocalLastMessage(e),t&&0!==t.lastTime&&i&&(n=t.lastTime,o=i.time,r=n-o,0<o&&1<=r&&r<=600&&a.push(this._recoverC2CMessage({conversationID:e,localLastMessageTime:o,remoteLastMessageTime:n})))}),Promise.all(a).then(()=>{Ie.l(this._n+"._recoverC2CChat all promise fulfilled, start to sync unread messages"),this.get(Rs).startSyncOnReconnected()})}_getLocalConversationList(){return this.get(Ts).getLocalConversationList()}_recoverGroupMessage(e){const r=this._n+"._recoverGroupMessage",{groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:c}=(Ie.l(r+" options:",e),e);this._getGroupRoamingMessage({groupID:a,sequence:s}).then(s=>{const{complete:e,messageList:i}=s.data;if(!$e(i)){const s=i[0].sequence,o=`groupID:${a} pkgLastSequence:${s} remoteLastSequence:${c} complete:${e} count:`+i.length,n=(Ie.l(r+" "+o),s<c&&2!==e&&this._recoverGroupMessage({groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:c}),new pi("recoverMessage").setMessage(o).end(),this.get(Is));1<i.length&&i.sort((e,t)=>e.sequence-t.sequence);for(let e=0;e<i.length;e++){const s=i[e];s.from!==t.CONV_SYSTEM?n.onNewGroupMessage({dataList:[s],isInstantMessage:!1,updateUnreadCount:!1}):n.onNewGroupTips({event:s.event,dataList:[s]})}this._getGroupNotify([a])}})}_genMultiGroupIDList(t,e){const s=e&&1<e?e:1,i=t.length,o=[];if(0<i)for(let e=0;e<i;e+=s)o.push(t.slice(e,e+s));return o}_getGroupNotify(s){var i=this._genMultiGroupIDList(s,10);if(0<i.length){const s=this.get(Is);for(let e=0,t=i.length;e<t;e++)s.getGroupNotify(i[e])}}_getGroupRoamingMessage(e){var{groupID:e,sequence:t}=e;return this.req({proto:Qs.GET_GRP_ROAMING_MSG,data:{groupID:e,count:this.PULL_LIMIT_COUNT,sequence:t+this.PULL_LIMIT_COUNT-1}})}_recoverC2CMessage(e){const n=this._n+"._recoverC2CMessage",{conversationID:r,localLastMessageTime:s,remoteLastMessageTime:a}=(Ie.l(n+" options:",e),e);return this._getC2CRoamingMessage({conversationID:r,time:s}).then(e=>{var{complete:s,messageList:i}=e.data;if(!$e(i)){const e=i.length;this.get(Ms).onNewC2CMessage({dataList:i,isInstantMessage:!0});var i=i[e-1].time,o=`peerAccount:${r.replace(t.CONV_C2C,"")} pkgLastTime:${i} remoteLastTime:${a} complete:${s} count:`+e;if(Ie.l(n+" "+o),new pi("recoverMessage").setMessage(o).end(),i<a&&1!==s)return this._recoverC2CMessage({conversationID:r,localLastMessageTime:i,remoteLastMessageTime:a})}})}_getC2CRoamingMessage(e){const{conversationID:s,time:i}=e;return this.req({proto:Qs.GET_C2C_ROAMING_MSG,data:{peerAccount:s.replace(t.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:i,direction:1}})}reset(){Ie.l(this._n+".reset")}}class ro{constructor(){this._n="AvgE2EDelay",this._e2eDelayArray=[]}addMessageDelay(e){e=he()-e;0<=e&&this._e2eDelayArray.push(e)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),gt(s/t,1)}_calcCountWithLimit(e){const{e2eDelayArray:t,min:s,max:i}=e;return t.filter(e=>s<=e&&e<i).length}_calcPercent(e,t){let s=gt(e/t*100,2);return s=100<s?100:s}_checkE2EDelayException(e,t){var s=e.filter(e=>t<e);if(0<s.length){const t=s.length,i=Math.min(...s),o=Math.max(...s),n=this._calcAvg(s,t),r=gt(t/e.length*100,2);50<r&&new pi("messageE2EDelayException").setMessage(`count:${t} min:${i} max:${o} avg:${n} percent:`+r).setLevel("warning").end()}}getStatResult(){var e=this._e2eDelayArray.length;if(0===e)return null;const t=[...this._e2eDelayArray],s=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),i=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),o=this._calcPercent(s,e),n=this._calcPercent(i,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:s,percentOfCountLessThan1Second:o,countLessThan3Second:i,percentOfCountLessThan3Second:n,avgDelay:r}}reset(){this._e2eDelayArray.length=0}}class ao{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=gt(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(){var e=this._calcTotalCount(),t=[...this._rttArray];if(0===e)return null;var s=this._calcRTTCount(t),i=this._calcSuccessRateOfRequest(s,e),t=this._calcAvg(t,s);return Ie.l(`${this._n}.getStatResult max:${this._calcMax()} min:${this._calcMin()} avg:`+t),this.reset(),{totalCount:e,rttCount:s,successRateOfRequest:i,avgRTT:t}}reset(){this._requestCount=0,this._rttArray.length=0}}class co{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!($e(e)||!this._map.has(e)||(this._map.get(e).totalCount+=1,0))}addSuccessCount(e){return!($e(e)||!this._map.has(e)||(this._map.get(e).successCount+=1,0))}addFailedCountOfUserSide(e){return!($e(e)||!this._map.has(e)||(this._map.get(e).failedCountOfUserSide+=1,0))}addCost(e,t){return!($e(e)||!this._map.has(e)||(this._map.get(e).costArray.push(t),0))}addFileSize(e,t){return!($e(e)||!this._map.has(e)||(this._map.get(e).fileSizeArray.push(t),0))}_calcSuccessRateOfBusiness(e){if($e(e)||!this._map.has(e))return-1;e=this._map.get(e);let t=gt(e.successCount/e.totalCount*100,2);return t=100<t?100:t}_calcSuccessRateOfPlatform(e){if($e(e)||!this._map.has(e))return-1;var t=this._map.get(e);let s=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return s=100<(s=gt(s,2))?100:s}_calcTotalCount(e){return $e(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}_calcSuccessCountOfBusiness(e){return $e(e)||!this._map.has(e)?-1:this._map.get(e).successCount}_calcSuccessCountOfPlatform(e){if($e(e)||!this._map.has(e))return-1;e=this._map.get(e);return e.successCount+e.failedCountOfUserSide}_calcAvg(e){return $e(e)||!this._map.has(e)?-1:e===oi?this._calcAvgSpeed(e):this._calcAvgCost(e)}_calcAvgCost(e){var 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){var t=this._calcTotalCount(e);if(0===t)return null;var s=this._calcSuccessCountOfBusiness(e),i=this._calcSuccessRateOfBusiness(e),o=this._calcSuccessCountOfPlatform(e),n=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:s,successRateOfBusiness:i,successCountOfPlatform:o,successRateOfPlatform:n,avgValue:r}}reset(e){$e(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}class uo{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:i}=e;if($e(s)||!this._lastMap.has(s)||!this._currentMap.has(s))return!1;const{conversationID:o,sequence:n}=i,r=o.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),i=t.length-1;n>t[0]&&n<t[i]?(t.push(n),t.sort(),this._lastMap.get(s).set(r,t)):this._addCurrentMap(e)}else this._addCurrentMap(e);return!0}_addCurrentMap(e){const{key:s,message:i}=e,{conversationID:o,sequence:n}=i,r=o.replace(t.CONV_GROUP,"");this._currentMap.get(s).has(r)||this._currentMap.get(s).set(r,[]),this._currentMap.get(s).get(r).push(n)}_copyData(t){if(!$e(t)){this._lastMap.set(t,new Map);let e=this._lastMap.get(t);for(var[s,i]of this._currentMap.get(t))e.set(s,i);e=null,this._currentMap.set(t,new Map)}}getStatResult(e){if($e(this._currentMap.get(e))||$e(this._lastMap.get(e)))return null;if(0===this._lastMap.get(e).size)return this._copyData(e),null;let i=0,o=0;if(this._lastMap.get(e).forEach((e,t)=>{var e=[...e.values()],s=e.length;i+=e[s-1]-e[0]+1,o+=s}),0===i)return null;let t=gt(o/i*100,2);return 100<t&&(t=100),this._copyData(e),{totalCount:i,successCountOfMessageReceived:o,successRateOfMessageReceived:t}}reset(){this._currentMap.clear(),this._lastMap.clear()}}class lo extends Js{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[Zs,ei,ti,si,ii,ni,oi,ri,ai,ci],this._messageSentItems=[ti,si,ii,ni,oi],this._messageReceivedItems=[ri,ai,ci],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new ao,this._avgE2EDelay=new ro,this._rateMessageSent=new co,this._rateMessageReceived=new uo;const t=this.getInnerEmitterInstance();t.on(Pi.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),t.on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onLoginSuccess(){this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);const e=this.get(Ds),t=e.getItem(this.TAG,!1);!Re(t)&&be(t.forEach)&&(Ie.l(this._n+"._onLoginSuccess. logs 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");$e(e)||(this.REPORT_INTERVAL=Number(e)),$e(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map(e=>Number(e))),$e(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)||Ie.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||Ie.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||Ie.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||Ie.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||Ie.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||Ie.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=di[this.get(Es).getNetworkType()];$e(s)&&(s=8);var i={qualityType:ui[e],timestamp:_e(),networkType:s,extension:""};switch(e){case Zs:t=this._avgRTT.getStatResult();break;case ei:t=this._avgE2EDelay.getStatResult();break;case ti:case si:case ii:case ni:case oi:t=this._rateMessageSent.getStatResult(e);break;case ri:case ai:case ci:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:{...i,...t}}_report(e){let t=[],s=null;$e(e)?this._qualityItems.forEach(e=>{null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))}):null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s)),Ie.d(this._n+"._report",t),0<this._statInfoArr.length&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);const i=this.get(ys),o=i.getSDKAppID(),n=i.getTinyID();0<(t=mt(this.REPORT_SDKAPPID_BLACKLIST,o)&&!Mt(this.REPORT_TINYID_WHITELIST,n)?[]:t).length&&this._doReport(t)}_doReport(t){var e={header:pn(this),quality:t};this.req({proto:Qs.SSO_STAT,data:{...e}}).then(()=>{this.reportIndex++,this.wholePeriod=!1}).catch(e=>{Ie.w(this._n+"._doReport failed. error:",e),this._statInfoArr=this._statInfoArr.concat(t),this._flushAtOnce()})}_flushAtOnce(){const t=this.get(Ds),s=t.getItem(this.TAG,!1),i=this._statInfoArr,o=this._n+"._flushAtOnce";if(Re(s))Ie.l(o+" count:"+i.length),t.setItem(this.TAG,i,!0,!1);else{let e=i.concat(s);10<e.length&&(e=e.slice(0,10)),Ie.l(o+" count:"+e.length),t.setItem(this.TAG,e,!0,!1)}this._statInfoArr=[]}reset(){Ie.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 _o extends Js{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init(),this.getInnerEmitterInstance().on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}isWorkerEnabled(){return this._isWorkerEnabled&&te}startWorkerTimer(){Ie.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){Ie.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(te){var 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,Ie.l(t._n+"._init seed:"+t._timerID)):t._m.onCheckTimer()}}}_onCloudConfigUpdated(){var e=this.getCloudConfig("enable_worker");Ie.l(this._n+"._onCloudConfigUpdated enableWorker:"+e),$e(e)||"1"===e?!this._isWorkerEnabled&&te&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&te&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){Ie.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){Ie.l(this._n+".reset")}}class po{constructor(e){this._commercialConfigM=e,this._n="PurchasedFeatureHandler",this._featureMap=new Map}isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}parsePurchaseBits(s){if(this.isValidPurchaseBits(s)){this._featureMap.clear();var o;for(let e=s.length-1,t=0;0<=e;e--,t++)o=(t<32?new i(0,Math.pow(2,t)):new i(Math.pow(2,t-32),0)).toString(),"1"===s[e]?this._featureMap.set(o,!0):this._featureMap.set(o,!1)}else Ie.w(this._n+".parsePurchaseBits invalid purchasebits:"+s)}hasPurchasedFeature(e){return!!this._featureMap.get(e)}isFeatureEnabled(e){const s=this._n+".isFeatureEnabled",o=parseInt(e).toString(2);let n=void 0,r=!0;for(let e=o.length-1,t=0;0<=e;e--,t++)if("1"===o.charAt(e)){if(n=(t<32?new i(0,Math.pow(2,t)):new i(Math.pow(2,t-32),0)).toString(),!this._featureMap.get(n)){r=!1;break}{let e="",t=0;if(n===I.PLUGIN_TRANSLATE?(e="plugin_translate",t=16):n===I.PLUGIN_VOICE_TO_TEXT?(e="plugin_voice_to_text",t=17):n===I.PLUGIN_CS?(e="plugin_cs",t=14):n===I.PLUGIN_PUSH?(e="plugin_push",t=13):n===I.PLUGIN_BOT&&(e="plugin_bot",t=15),""!==e){const i=this._commercialConfigM.get(ys).getUIPlatform();new pi(e).setCode(t).setUIPlatform(i).end(),Ie.l(s+` ${e} code:${t} uiPlatform:`+i)}}}return Ie.l(s+` decimalNumber:${e} key:${n} ret:`+r),js({enabled:r})}clear(){this._featureMap.clear()}}class ho{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new po(this)}_canFetch(){return this.get(ys).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(Ie.l(t+" canFetch:"+e),e){const s=new pi("fetchCommercialConfig"),i=this.get(ys).getSDKAppID(),o=this.get(Ls);this._isFetching=!0,o.req({proto:Qs.FETCH_COMMERCIAL_CONFIG,data:{SDKAppID:i}}).then(e=>{s.setMessage("purchaseBits:"+e.data.purchaseBits).end(),Ie.l(t+" ok."),this._parseConfig(e.data),this._isFetching=!1}).catch(e=>{s.setError(e).end(),this._isFetching=!1})}}onPushedConfig(e){var t=this._n+".onPushedConfig data:"+JSON.stringify(e);Ie.l(t),new pi("pushedCommercialConfig").setMessage("purchaseBits:"+e.purchaseBits).end(),this._parseConfig(e)}_parseConfig(e){var t=this._n+"._parseConfig",{errorCode:s,errorMessage:i,purchaseBits:o,expiredTime:n}=e;0===s?(this._purchasedFeatureHandler.parsePurchaseBits(o),this._expiredTime=Date.now()+1e3*n):$e(s)?(Ie.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(Ie.e(t+` errorCode:${s} errorMessage:`+i),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}canIUse(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}isFeatureEnabled(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}get(e){return this._m.get(e)}reset(){Ie.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class go extends Js{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){var t,s,i,o,n,r,a,c,l,d,u,_,p;P?(this._offlinePushPlugin=e["tim-offline-push-plugin"],{huaweiBusinessID:t,xiaomiBusinessID:s,xiaomiAppID:i,xiaomiAppKey:o,meizuBusinessID:n,meizuAppID:r,meizuAppKey:a,vivoBusinessID:c,oppoBusinessID:l,oppoAppKey:d,oppoAppSecret:u,honorBusinessID:_,iosBusinessID:p}=e.offlinePushConfig||{},this._androidPushConfig.huaweiPushBussinessId=t,this._androidPushConfig.xiaomiPushBussinessId=s,this._androidPushConfig.xiaomiPushAppId=i,this._androidPushConfig.xiaomiPushAppKey=o,this._androidPushConfig.meizuPushBussinessId=n,this._androidPushConfig.meizuPushAppId=r,this._androidPushConfig.meizuPushAppKey=a,this._androidPushConfig.vivoPushBussinessId=c,this._androidPushConfig.oppoPushBussinessId=l,this._androidPushConfig.oppoPushAppKey=d,this._androidPushConfig.oppoPushAppSecret=u,this._androidPushConfig.honorPushBussinessId=_,new pi("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!$e(this._offlinePushPlugin)).end(!0),Ie.l(this._n+".registerPlugin ok. offlinePushConfig:"+JSON.stringify(e.offlinePushConfig)),this._iosBusinessID=p,this._setAppShowListener()):this.outputWarning("OfflinePushInUniapp")}init(){this._isWebUniapp=this.getUniAppPlatform(),this._getDeviceToken()}_getDeviceToken(){const a=this._n+"._getDeviceToken";if(be(this._offlinePushPlugin.getDeviceToken)){let r=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:`+this._iosBusinessID;Ie.l(a+" start. "+r),new pi("_getDeviceToken").setMessage(r).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,e=>{const t=new pi("getDeviceTokenRes"),{code:s,msg:i}=e;if(0===s){const{deviceToken:s,deviceBrand:i,deviceType:o,bussinessId:n}=e.data;this._deviceToken=s,this._businessID=n||this._iosBusinessID,r=`deviceToken:${s}, deviceBrand:${i||o}, businessID:`+this._businessID,Ie.l(a+" ok. "+r),t.setMessage(r).end(!0),this._setToken()}else t.setMessage(`code:${s}, msg:`+i).end(!0),Ie.e(a+" failed. error:",e)})}else Ie.e(a+" getDeviceToken is not a function")}canIUseOfflinePush(){return P&&!$e(this._offlinePushPlugin)}_setAppShowListener(){const t=this._n+"._setAppShowListener";$e(this._offlinePushPlugin)?Ie.e(t+" offlinePushPlugin is undefined"):be(this._offlinePushPlugin.setAppShowListener)?(new pi("_setAppShowListener").end(!0),Ie.l(t+" start"),this._offlinePushPlugin.setAppShowListener(e=>{e=(e||{}).appShow;new pi("setAppShowListenerRes").setMessage("appShow:"+e).end(!0),Ie.l(t+" ok. appShow:"+e),this._m.isReady()&&(0===e?(this._getConvUnreadCount(),this._onBackground()):1===e&&this._onForeground())})):Ie.e(t+" setAppShowListener is not a function")}getDeviceBrand(){var e;if(!$e(this._offlinePushPlugin)&&be(this._offlinePushPlugin.getDeviceType))return e=(this._offlinePushPlugin.getDeviceType()||{})["deviceType"],Ie.l(this._n+".getDeviceBrand ok. deviceType:"+e),e}_setToken(){const t=this._n+"._setToken",e=this.get(ys);let s,i=1,n="",r="";Re(this._deviceToken)&&(i=0);var a=this.getUniAppPlatform(),c=this.getDeviceBrand();a===o.IOS||a===o.IPAD||a===o.MAC?r=this._deviceToken:a===o.ANDROID&&(n=this._deviceToken);const l=new pi("offlinePushSetToken");return s=`deviceToken:${r||n}, businessID:${this._businessID}, deviceBrand:${c}, isWebUniapp:${this._isWebUniapp}, pushMsg:${i}, platform:`+a,l.setMessage(s),Ie.l(t+" "+s),this.req({proto:Qs.SET_TOKEN,data:{tokenID:n,pushMsg:i,sdkAppID:e.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:c,deviceToken:r,isWebUniapp:this._isWebUniapp}}).then(e=>(l.end(),Ie.l(t+" ok"),e)).catch(e=>(l.setError(e).end(),Ie.e(t+" failed. error:",e),Xs(e)))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0,this.get(Ts).getLocalConversationList().forEach(e=>{e.type===t.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===t.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)})}_onBackground(){const t=this._n+"._onBackground",s=new pi("_onBackground");this.req({proto:Qs.STAT_BACKGROUND,data:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(e=>(s.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: `+this._groupUnreadCount).end(),Ie.l(t+" ok"),e)).catch(e=>{s.setError(e).end(),Ie.e(t+" failed. error:",e)})}_onForeground(){const t=this._n+"._onForeground",s=new pi("_onForeground");this.req({proto:Qs.STAT_FOREGROUND,data:{isWebUniapp:this._isWebUniapp}}).then(e=>(s.end(),Ie.l(t+" ok"),e)).catch(e=>{s.setError(e).end(),Ie.e(t+" failed. error:",e)})}getUniAppPlatform(){var e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?o.IOS:"android"===e?o.ANDROID:1002===t?o.IPAD:1001===t?o.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,Ie.l(this._n+".reset")}}class mo extends Js{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.get(As).getPlugin("tim-profanity-filter-plugin");e?(this._plugin=new e({logger:Ie,isArray:Fe,isMap:Le,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 i=!0;if(!this._plugin||!this._canIUseLexicon)return i;if(s&&s.messageControlInfo&&!0===s.messageControlInfo.excludedFromContentModeration)return i;const{type:o,conversationType:n}=e;if(o!==t.MSG_TEXT&&o!==t.MSG_CUSTOM)return i;const r=this._n+".filterMessage";let a;if(Ie.l(""+r),o===t.MSG_TEXT){if(n===t.CONV_C2C?a=f:n===t.CONV_GROUP&&(a=T),!this._isConfigOn(a))return i;const{type:s,modifiedText:o}=this._plugin.filter(e.payload.text);1===s?i=!1:2===s&&(e.payload.text=o)}else if(o===t.MSG_CUSTOM){if(n===t.CONV_C2C?a=C:n===t.CONV_GROUP&&(a=y),!this._isConfigOn(a))return i;const s=this._plugin.filter(e.payload.data),o=this._plugin.filter(e.payload.description),r=this._plugin.filter(e.payload.extension);1===s.type||1===o.type||1===r.type?i=!1:(2===s.type&&(e.payload.data=s.modifiedText),2===o.type&&(e.payload.description=o.modifiedText),2===r.type&&(e.payload.extension=r.modifiedText))}return Ie.l(r+" done. isAllowedToSend:"+i),i}filterText(e,t){const s=this._n+".filterText",i={isAllowedToSend:!0,modifiedText:e};if(!this._plugin||!this._canIUseLexicon)return i;if(!this._isConfigOn(t))return i;Ie.l(s);var{type:t,modifiedText:e}=this._plugin.filter(e);return 1===t?i.isAllowedToSend=!1:2===t&&(i.modifiedText=e),Ie.l(s+" done. ret:",i),i}_getLexicon(){const d=new pi("profanityFilter"),u=this._n+"._getLexicon";this._isFetching=!0,this.req({proto:Qs.GET_PROFANITY_LIST,data:{startIndex:this._startIndex,version:this._version}}).then(e=>{var{errorInfo:e,filterConfig:t,lexicon:s,strToken:i,completeFlag:o,nextStartIndex:n,version:r,expiredTime:a}=e.data,{errorCode:c,errorMessage:l}=e;return 0!==c?(this._isFetching=!1,Ie.w(u+" failed. error:",e),void d.setCode(c).setMessage(l).end()):(this._onFilterConfig(t),this._getToken(i),1===o?(Ie.l(u+` done. version:${r} expiredTime:`+a),this._version=r,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*a,void this._plugin.onLexiconCompleted(s)):(this._startIndex=n,this._plugin.onLexiconSliced(s),void this._getLexicon()))}).catch(e=>{d.setError(e).end(),this._isFetching=!1,Ie.l(u+" failed. error:",e)})}_onFilterConfig(t){Re(t)||(this._filterConfigMap.clear(),Object.keys(t).forEach(e=>{this._filterConfigMap.set(e,t[e])}),Ie.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(s){if(Ue(s)){var i=s.length;let t="";if(i%2==0)for(let e=0;e<=i-1;e+=2)t=(t+=s[e+1])+s[e];else{for(let e=0;e<i-1;e+=2)t=(t+=s[e+1])+s[e];t+=s[i-1]}this._plugin.onToken(t)}}reset(){Ie.l(this._n+".reset"),this._plugin&&(this._plugin.reset(),this._plugin=null),this._filterConfigMap.clear(),this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}}class Mo{constructor(e){this._m=e,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*"],this._TRTCCommandMap=new Map,this._setTRTCCommandMap(),this._m.getInnerEmitterInstance().on(Pi.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){let e=this._m.get(Os).getCloudConfig("rtc_cmd");$e(e)||((e=JSON.parse(e)).forEach(e=>{this._TRTCCommandList.includes(e)||this._TRTCCommandList.push(e)}),this._setTRTCCommandMap())}_setTRTCCommandMap(){var s;for(let e=0,t=this._TRTCCommandList.length;e<t;e++)s=this._TRTCCommandList[e].split(".")[0],this._TRTCCommandMap.set(s,1)}onRoomCustomDataReceived(t){this._m.getOuterEmitterInstance().emit(e.ROOM_CUSTOM_DATA_RECEIVED,t)}sendTRTCCustomData(e){var{serviceCommand:e,data:t}=e;let s=M.NAME.TUIROOM_SVR+".*";return $e(e)||(s=e),this._isValidServiceCommand(s)?this._trans({servcmd:s,data:t}):Xs({code:Ws.INVALID_TRTC_CMD})}_trans(e){Ie.d(this._n+"._trans. options:"+JSON.stringify(e));var{servcmd:e,data:t}=e;return this._m.get(Ls).trans({servcmd:e,data:Ue(t)?JSON.parse(t):t})}_isValidServiceCommand(e){if(e.endsWith(".*"))return this._TRTCCommandList.includes(e);e=e.split(".")[0];return this._TRTCCommandMap.has(e)}isTRTCCommand(e){e=e.split(".")[0];return this._TRTCCommandMap.has(e)}reset(){Ie.l(this._n+".reset")}}class Io{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(){var t=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(t){let e;try{e=JSON.parse(t)}catch(e){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),Ie.w(this._n+"._init error:",e)}e&&(this._needToUpdate(e)?this._fetch():this._fillMap(e.message))}else this._fetch()}_needToUpdate(e){var{localSavedTime:e,localSavedVersion:t}=e,e=e&&(new Date).getTime()-e>=this.STORAGE_EXPIRES_TIME,t=!t||"3.2.4"!==t;return Ie.l(this._n+`._needToUpdate isTimeout:${e} isDifferentVersion:`+t),e||t}_fetch(){if(!this._m.get(ys).isPrivateNetWork()){const e="https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.4/tim-error-message.txt",t="application/x-www-form-urlencoded;charset=UTF-8",s=this._n+"._fetch ok in",i=this;if(G)F.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:e=>{i._fillAndSave(e.data),Ie.l(s+" mini program")},fail:()=>{}});else{const o=new XMLHttpRequest,n=setTimeout(()=>{o.abort()},3e3);o.onreadystatechange=function(){4===o.readyState&&(clearTimeout(n),200!==o.status&&304!==o.status||(Ie.l(s+" browser"),i._fillAndSave(o.responseText)))},o.open("GET",e,!0),o.setRequestHeader("Content-type",t),o.send()}}}_fillAndSave(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:"3.2.4"}),!0,!1)}_getStorageModule(){return this._m.get(Ds)}_fillMap(e){this._map.clear();const t=e.split(";\n"),s=t.length;let i,o,n;var r=new RegExp(/'/g);for(let e=0;e<s;e++)if(i=t[e].indexOf(":"),o=t[e].slice(0,i),n=t[e].slice(i+1,t[e].length),!o.startsWith("//")){if($e(n))continue;this._map.set(o,n.replace(r,""))}}get(e){var{isIntl:e,key:t,replacement1:s,replacement2:i}=e;let o=e?t+"_en":t+"_cn",n=(!this._map.has(o)&&this._map.has(t)&&(o=t),"");return this._map.has(o)&&(n=this._map.get(o),$e(s)||(n=n.replace("$replacement1",s)),$e(i)||(n=n.replace("$replacement2",i))),n}reset(){Ie.l(this._n+".reset")}}class fo{constructor(s){const e=new pi("sdkConstruct");if(this._n="ModuleManager",this._isReady=!1,this._reason=Ws.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(ys,new an(this,s)),this._moduleMap.set(Es,new Mn(this)),this._moduleMap.set(ks,new ho(this)),this._moduleMap.set(Os,new no(this)),this._moduleMap.set(Ps,new _o(this)),this._moduleMap.set(Gs,new lo(this)),this._moduleMap.set(Ns,new jn(this)),this._moduleMap.set(Ls,new io(this)),this._moduleMap.set(ps,new un(this)),this._moduleMap.set(hs,new vn(this)),this._moduleMap.set(gs,new An(this)),this._moduleMap.set(Vs,new Rn(this)),this._moduleMap.set(bs,new Ln(this)),this._moduleMap.set(ms,new rn(this)),this._moduleMap.set(Ms,new Ni(this)),this._moduleMap.set(Ts,new ji(this)),this._moduleMap.set(Cs,new Zi(this)),this._moduleMap.set(Ds,new dn(this)),this._moduleMap.set(qs,new Io(this)),this._moduleMap.set(Ss,new hn(this)),this._moduleMap.set(vs,new Tn(this)),this._moduleMap.set(As,new Nn(this)),this._moduleMap.set(Rs,new On(this)),this._moduleMap.set(Us,new oo(this)),this._moduleMap.set(Fs,new go(this)),this._moduleMap.set($s,new mo(this)),this._moduleMap.set(ws,new Mo(this)),this._eventThrottleMap=new Map,ke(s.modules)){let t;Object.keys(s.modules).forEach(e=>{t=s.modules[e],"group-module"===e?this._moduleMap.set(Is,new t(this)):"relationship-module"===e?this._moduleMap.set(fs,new t(this)):"signaling-module"===e?this._moduleMap.set(xs,new t(this)):"follow-module"===e&&this._moduleMap.set(Bs,new t(this))}),this._moduleMap.get(ys).setUsingChatCore(!0)}else this._moduleMap.has(Is)||this._moduleMap.get(ys).setUsingChatCore(!0);var{instanceID:t,SDKAppID:i}=s,t=`instanceID:${t} SDKAppID:${i} isIntl:${this._moduleMap.get(ys).isIntl()} isUsingChatCore:${this._moduleMap.get(ys).isUsingChatCore()} host:${lt()} isIOSWebView:${ne} inBrowser:${k} inMiniApp:${G} workerAvailable:${te} UserAgent:`+$;pi.bindEventStatModule(this._moduleMap.get(Ss)),pi.bindNetMonitorModule(this._moduleMap.get(Es)),e.setMessage(t+" "+function(){let t="";if(G)try{var{model:e,version:s,system:i,platform:o,SDKVersion:n}=F.getSystemInfoSync();t=`model:${e} version:${s} system:${i} platform:${o} SDKVersion:`+n}catch(e){t=""}return t}()).end(),Ie.i("SDK "+t),Hs.prototype._getErrorMessage=this.getErrorMessage.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}_startTimer(){const e=this._moduleMap.get(Ps),t=e.isWorkerEnabled();Ie.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)),Ie.l(this._n+"._startMainThreadTimer seed:"+this._checkTimer)}stopTimer(){const e=this._moduleMap.get(Ps),t=e.isWorkerEnabled();Ie.l(this._n+`.stopTimer isWorkerEnabled:${t} seed:`+this._checkTimer),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){Ie.l(this._n+"._stopMainThreadTimer"),0<this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){Ie.l(this._n+"._stopMainThreadSocket");const e=this._moduleMap.get(Ns);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){Ie.l(this._n+"._startMainThreadSocket");const e=this._moduleMap.get(Ns);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){Ie.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){Ie.l(this._n+".onWorkerTimerDisabled, enable main thread timer and socket"),this._startMainThreadTimer(),this._startMainThreadSocket()}onCheckTimer(){this._checkCount+=1;for(var[,e]of this._moduleMap)e.onCheckTimer&&e.onCheckTimer(this._checkCount)}_initReadyList(){this._readyList=[this._moduleMap.get(ps)],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;Ie.w(`SDK is ready. cost ${t} ms`),this._startLoginTs=Date.now();var s=this._ssoLogForReady.getStartTs()+de;this._ssoLogForReady.setMessage(t).start(s).end()}}login(){0===this._startLoginTs&&(pe(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(Es).start(),this._ssoLogForReady=new pi("sdkReady"),this._reason=Ws.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOuterEmitterInstance(){return null===this._outerEmitter&&(this._outerEmitter=new In,zs(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(t,s){if(this._canIUseSignaling()&&(t===e.MESSAGE_RECEIVED&&this.get(xs).onNewMessageList(s),t===e.MESSAGE_MODIFIED&&this.get(xs).onMessageModified(s)),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:s}])}.bind(this)),this._outerEmitter}_canIUseSignaling(){const e=this.get(xs);return!!e&&e.canIUseSignaling()}_getEventData(t){return t===e.CONVERSATION_LIST_UPDATED?this._moduleMap.get(Ts).getLocalConversationList():t===e.FRIEND_LIST_UPDATED?this._moduleMap.get(fs).getLocalFriendList(!1):t===e.GROUP_LIST_UPDATED?this._moduleMap.get(Is).getLocalGroupList():t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._moduleMap.get(Ts).getTotalUnreadMessageCount():void 0}getInnerEmitterInstance(){return null===this._innerEmitter&&(this._innerEmitter=new In,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){e=ke(t)&&t.data?[e,{name:e,data:t.data}]:[e,{name:e,data:t}];this._innerEmitter._emit.apply(this._innerEmitter,e)}.bind(this)),this._innerEmitter}hasModule(e){return this._moduleMap.has(e)}get(e){return this._moduleMap.get(e)}isReady(){return this._isReady}isIntl(){return this.get(ys).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrorMessage(e,t,s){return this._moduleMap.get(qs).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}outputWarning(e,t,s){e=this.getErrorMessage(e,t,s);e&&Ie.w(e)}onError(t){var s=`code:${t.code} message:`+t.message;Ie.w("Oops! "+s),new pi("error").setMessage(s).setLevel("error").end(),this.getOuterEmitterInstance().emit(e.ERROR,t)}restartTimer(){Ie.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer();const e=this.get(Is);e&&e.restartPolling()}getTimerID(){const e=this._moduleMap.get(Ps);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._moduleMap.get(Is).getPollingTimerID(e)}reset(){Ie.l(this._n+".reset"),pe();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 Co{constructor(e){this._funcMap=new Map,this._m=e,this._n="SafetyCallback",this._reportCount=0}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 i=null;return this._funcMap.get(e).has(t)?i=this._funcMap.get(e).get(t):(i=this._pack(e,t,s),this._funcMap.get(e).set(t,i)),i}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(s,i,o){const n=this;return function(){try{i.apply(o,Array.from(arguments))}catch(t){const i=Object.values(e).indexOf(s),o="CallbackError";if(-1!==i){const s=Object.keys(e)[i];n._m.outputWarning(o,s,t)}n._reportCount<5&&(new pi(o).setMessage("eventName:"+s).setMoreMessage(t.message).end(),n._reportCount+=1)}}}destroy(){this._funcMap.clear()}reset(){Ie.l(this._n+".reset"),this._reportCount=0}}class To{constructor(e){e={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:ut(),devMode:e.devMode||!1,proxyServer:e.proxyServer||void 0,fileUploadProxy:e.fileUploadProxy||void 0,fileDownloadProxy:e.fileDownloadProxy||e.fileUploadProxy||void 0,modules:e.modules||void 0};this._m=new fo(e),this._vendorMap=new Map,this._safetyCallbackFactory=new Co(this._m)}onError(e){this._m.onError(e)}login(e){return this._m.login(),this._get(ps).login(e)}logout(){return this._get(ps).logout().then(e=>(this._safetyCallbackFactory.reset(),this._m.reset(),e))}getLoginUser(){return this._get(ps).getLoginUser()}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)}_get(e){return this._m.get(e)}destroy(){return this.logout().finally(()=>{this._safetyCallbackFactory.destroy(),this._m.stopTimer(),this._get(Ps).terminate(),this._get(Ns).dealloc();const t=this._m.getOuterEmitterInstance(),s=this._get(ys);t.emit(e.SDK_DESTROY,{SDKAppID:s.getSDKAppID()})})}on(e,t,s){Ie.d("on","eventName:"+e),this._m.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){Ie.d("once","eventName:"+e),this._m.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,i){Ie.d("off","eventName:"+e);var o=this._safetyCallbackFactory.find(e,t);null!==o&&(this._m.getOuterEmitterInstance().off(e,o,s,i),this._safetyCallbackFactory.delete(e,t))}registerPlugin(e){($e(e["tim-offline-push-plugin"])?this._get(As):this._get(Fs)).registerPlugin(e)}setLogLevel(e){if(e<=0){const e=this.getErrorMessage("TIM_ASCII_ART");e&&console.log(e);var t=this.getErrorMessage("API_REFER");if(t){const e="IM SDK API ->";Tt()?console.log(`%c ${e} %c`,"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",t):console.log(e,t)}t=this.getErrorMessage("DOCS_GUIDE"),t=(t&&console.log(t),this.getErrorMessage("IOS_WEBVIEW_WARNING"));ne&&t&&console.warn(t)}Ie.setLevel(e)}createTextMessage(e){return this._get(hs).createTextMessage(e)}createTextAtMessage(e){return this._get(hs).createTextMessage(e)}createImageMessage(e){return this._get(hs).createImageMessage(e)}createAudioMessage(e){return this._get(hs).createAudioMessage(e)}createVideoMessage(e){return this._get(hs).createVideoMessage(e)}createCustomMessage(e){return this._get(hs).createCustomMessage(e)}createFaceMessage(e){return this._get(hs).createFaceMessage(e)}createFileMessage(e){return this._get(hs).createFileMessage(e)}createLocationMessage(e){return this._get(hs).createLocationMessage(e)}createMergerMessage(e){return this._get(hs).createMergerMessage(e)}downloadMergerMessage(e){return e.type!==t.MSG_MERGER?Xs({code:Ws.MSG_MERGER_TYPE_INVALID}):Re(e.payload.downloadKey)?Xs({code:Ws.MSG_MERGER_KEY_INVALID}):this._get(hs).downloadMergerMessage(e).catch(e=>Xs({code:Ws.MSG_MERGER_DOWNLOAD_FAIL}))}createForwardMessage(e){return this._get(hs).createForwardMessage(e)}sendMessage(e,t){return e instanceof Li?this._get(hs).sendMessageInstance(e,t):Xs({code:Ws.MSG_INSTANCE_REQUIRED})}searchCloudMessages(e){return this._get(hs).searchCloudMessages(e)}callExperimentalAPI(e,t){return"sendComboMessage"===e?this._get(bs).sendMessage(t):"handleGroupInvitation"===e?this._get(Is).handleGroupInvitation(t):"isCommercialAbilityEnabled"===e?this._get(ks).isFeatureEnabled(t):"isIntl"===e?this.isIntl():"sendTRTCCustomData"===e||"sendRoomCustomData"===e?this._get(ws).sendTRTCCustomData(t):"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):"setApplicationID"!==e?"getServerConfig"===e?this._get(Os).getServerConfig(t):Xs({code:Ws.INVALID_OPERATION}):(this._get(ys).setApplicationID(t),void this._get(Ls).updateProtocolConfig())}revokeMessage(e){return this._get(hs).revokeMessage(e)}resendMessage(e,t){return e instanceof Li?this._get(hs).resendMessage(e,t):Xs({code:Ws.MSG_INSTANCE_REQUIRED})}deleteMessage(e){return this._get(hs).deleteMessage(e)}translateText(e){return this._get(hs).translateText(e)}convertVoiceToText(e){return this._get(hs).convertVoiceToText(e)}setMessageExtensions(e,t){return this._get(gs).setMessageExtensions(e,t)}getMessageExtensions(e){return this._get(gs).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._get(gs).deleteMessageExtensions(e,t)}addMessageReaction(e,t){return this._get(Vs).addMessageReaction(e,t)}removeMessageReaction(e,t){return this._get(Vs).removeMessageReaction(e,t)}getMessageReactions(e){return this._get(Vs).getMessageReactions(e)}getAllUserListOfMessageReaction(e){return this._get(Vs).getAllUserListOfMessageReaction(e)}modifyMessage(e){return this._get(hs).modifyRemoteMessage(e)}getMessageList(e){return this._get(Ts).getMessageList(e)}getMessageListHopping(e){return this._get(Ts).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._get(Ts).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._get(Ts).getReadReceiptList(e)}getGroupMessageReadMemberList(e){const t=this._get(Is);return t?t.getReadReceiptDetail(e):Xs({code:Ws.CANNOT_FIND_MODULE})}findMessage(e){return this._get(Ts).findMessage(e)}setMessageRead(e){return this._get(Ts).setMessageRead(e)}getConversationList(e){return this._get(Ts).getConversationList(e)}getConversationProfile(e){return this._get(Ts).getConversationProfile(e)}deleteConversation(e){return this._get(Ts).deleteConversation(e)}setConversationDraft(e){return this._get(Ts).setConversationDraft(e)}clearHistoryMessage(e){return this._get(Ts).clearHistoryMessage(e)}pinConversation(e){return this._get(Ts).pinConversation(e)}setAllMessageRead(e){return this._get(Ts).setAllMessageRead(e)}setMessageRemindType(e){return this._get(Ts).setMessageRemindType(e)}getTotalUnreadMessageCount(){return this._get(Ts).getTotalUnreadMessageCount()}setConversationCustomData(e){return this._get(Ts).setConversationCustomData(e)}markConversation(e){return this._get(Ts).markConversation(e)}getConversationGroupList(){return this._get(Ts).getConversationGroupList()}createConversationGroup(e){return this._get(Ts).createConversationGroup(e)}deleteConversationGroup(e){return this._get(Ts).deleteConversationGroup(e)}renameConversationGroup(e){return this._get(Ts).renameConversationGroup(e)}addConversationsToGroup(e){return this._get(Ts).addConversationsToGroup(e)}deleteConversationsFromGroup(e){return this._get(Ts).deleteConversationsFromGroup(e)}getMyProfile(){return this._get(ms).getMyProfile()}getUserProfile(e){return this._get(ms).getUserProfile(e)}updateMyProfile(e){return this._get(ms).updateMyProfile(e)}getBlacklist(){return this._get(ms).getLocalBlacklist()}addToBlacklist(e){return this._get(ms).addBlacklist(e)}removeFromBlacklist(e){return this._get(ms).deleteBlacklist(e)}setSelfStatus(e){return this._get(ms).setSelfStatus(e)}getUserStatus(e){return this._get(ms).getUserStatus(e)}subscribeUserStatus(e){return this._get(ms).subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._get(ms).unsubscribeUserStatus(e)}getFriendList(){const e=this._get(fs);return e?e.getLocalFriendList():Xs({code:Ws.CANNOT_FIND_MODULE})}addFriend(e){const t=this._get(fs);return t?t.addFriend(e):Xs({code:Ws.CANNOT_FIND_MODULE})}deleteFriend(e){const t=this._get(fs);return t?t.deleteFriend(e):Xs({code:Ws.CANNOT_FIND_MODULE})}checkFriend(e){const t=this._get(fs);return t?t.checkFriend(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getFriendProfile(e){const t=this._get(fs);return t?t.getFriendProfile(e):Xs({code:Ws.CANNOT_FIND_MODULE})}updateFriend(e){const t=this._get(fs);return t?t.updateFriend(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getFriendApplicationList(){const e=this._get(fs);return e?e.getLocalFriendApplicationList():Xs({code:Ws.CANNOT_FIND_MODULE})}acceptFriendApplication(e){const t=this._get(fs);return t?t.acceptFriendApplication(e):Xs({code:Ws.CANNOT_FIND_MODULE})}refuseFriendApplication(e){const t=this._get(fs);return t?t.refuseFriendApplication(e):Xs({code:Ws.CANNOT_FIND_MODULE})}deleteFriendApplication(e){const t=this._get(fs);return t?t.deleteFriendApplication(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setFriendApplicationRead(){const e=this._get(fs);return e?e.setFriendApplicationRead():Xs({code:Ws.CANNOT_FIND_MODULE})}getFriendGroupList(){const e=this._get(fs);return e?e.getLocalFriendGroupList():Xs({code:Ws.CANNOT_FIND_MODULE})}createFriendGroup(e){const t=this._get(fs);return t?t.createFriendGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}deleteFriendGroup(e){const t=this._get(fs);return t?t.deleteFriendGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}addToFriendGroup(e){const t=this._get(fs);return t?t.addToFriendGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}removeFromFriendGroup(e){const t=this._get(fs);return t?t.removeFromFriendGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}renameFriendGroup(e){const t=this._get(fs);return t?t.renameFriendGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}followUser(e){const t=this._get(Bs);return t?t.followUser(e):Xs({code:Ws.CANNOT_FIND_MODULE})}unfollowUser(e){const t=this._get(Bs);return t?t.unfollowUser(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getMyFollowersList(e){const t=this._get(Bs);return t?t.getMyFollowersList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getMyFollowingList(e){const t=this._get(Bs);return t?t.getMyFollowingList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getMutualFollowersList(e){const t=this._get(Bs);return t?t.getMutualFollowersList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getUserFollowInfo(e){const t=this._get(Bs);return t?t.getUserFollowInfo(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupList(){const e=this._get(Is);return e?e.getGroupList():Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupProfile(e){const t=this._get(Is);return t?t.getGroupProfile(e):Xs({code:Ws.CANNOT_FIND_MODULE})}createGroup(e){const t=this._get(Is);return t?t.createGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}dismissGroup(e){const t=this._get(Is);return t?t.dismissGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}updateGroupProfile(e){const t=this._get(Is);return t?t.updateGroupProfile(e):Xs({code:Ws.CANNOT_FIND_MODULE})}joinGroup(e){const t=this._get(Is);return t?t.joinGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}quitGroup(e){const t=this._get(Is);return t?t.quitGroup(e):Xs({code:Ws.CANNOT_FIND_MODULE})}searchGroupByID(e){const t=this._get(Is);return t?t.searchGroupByID(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupOnlineMemberCount(e){const t=this._get(Is);return t?t.getGroupOnlineMemberCount(e):Xs({code:Ws.CANNOT_FIND_MODULE})}changeGroupOwner(e){const t=this._get(Is);return t?t.changeGroupOwner(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupApplicationList(){const e=this._get(Is);return e?e.getGroupApplicationList():Xs({code:Ws.CANNOT_FIND_MODULE})}handleGroupApplication(e){const t=this._get(Is);return t?t.handleGroupApplication(e):Xs({code:Ws.CANNOT_FIND_MODULE})}initGroupAttributes(e){const t=this._get(Is);return t?t.initGroupAttributes(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupAttributes(e){const t=this._get(Is);return t?t.setGroupAttributes(e):Xs({code:Ws.CANNOT_FIND_MODULE})}deleteGroupAttributes(e){const t=this._get(Is);return t?t.deleteGroupAttributes(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupAttributes(e){const t=this._get(Is);return t?t.getGroupAttributes(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupCounters(e){const t=this._get(Is);return t?t.setGroupCounters(e):Xs({code:Ws.CANNOT_FIND_MODULE})}increaseGroupCounter(e){const t=this._get(Is);return t?t.increaseGroupCounter(e):Xs({code:Ws.CANNOT_FIND_MODULE})}decreaseGroupCounter(e){const t=this._get(Is);return t?t.decreaseGroupCounter(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupCounters(e){const t=this._get(Is);return t?t.getGroupCounters(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupMemberList(e){const t=this._get(Is);return t?t.getGroupMemberList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getGroupMemberProfile(e){const t=this._get(Is);return t?t.getGroupMemberProfile(e):Xs({code:Ws.CANNOT_FIND_MODULE})}addGroupMember(e){const t=this._get(Is);return t?t.addGroupMember(e):Xs({code:Ws.CANNOT_FIND_MODULE})}deleteGroupMember(e){const t=this._get(Is);return t?t.deleteGroupMember(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupMemberMuteTime(e){const t=this._get(Is);return t?t.setGroupMemberMuteTime(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupMemberRole(e){const t=this._get(Is);return t?t.setGroupMemberRole(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupMemberNameCard(e){const t=this._get(Is);return t?t.setGroupMemberNameCard(e):Xs({code:Ws.CANNOT_FIND_MODULE})}setGroupMemberCustomField(e){const t=this._get(Is);return t?t.setGroupMemberCustomField(e):Xs({code:Ws.CANNOT_FIND_MODULE})}markGroupMemberList(e){const t=this._get(Is);return t?t.markGroupMemberList(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getJoinedCommunityList(){return this._get(Cs).getJoinedCommunityList()}createTopicInCommunity(e){return this._get(Cs).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._get(Cs).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._get(Cs).updateTopicProfile(e)}getTopicList(e){return this._get(Cs).getTopicList(e)}addSignalingListener(e,t,s){const i=this._get(xs);i&&i.addSignalingListener(e,this._safetyCallbackFactory.defense(e,t,s),s)}removeSignalingListener(e,t,s){var i=this._safetyCallbackFactory.find(e,t);if(null!==i){const o=this._get(xs);o&&(o.removeSignalingListener(e,i,s),this._safetyCallbackFactory.delete(e,t))}}invite(e){const t=this._get(xs);return t?t.invite(e):Xs({code:Ws.CANNOT_FIND_MODULE})}inviteSync(e,t,s){const i=this._get(xs);return i?i.inviteSync(e,t,s):""}inviteInGroup(e){const t=this._get(xs);return t?t.invite(e):Xs({code:Ws.CANNOT_FIND_MODULE})}inviteInGroupSync(e,t,s){const i=this._get(xs);return i?i.inviteSync(e,t,s):""}cancel(e){const t=this._get(xs);return t?t.cancel(e):Xs({code:Ws.CANNOT_FIND_MODULE})}accept(e){const t=this._get(xs);return t?t.accept(e):Xs({code:Ws.CANNOT_FIND_MODULE})}reject(e){const t=this._get(xs);return t?t.reject(e):Xs({code:Ws.CANNOT_FIND_MODULE})}getSignalingInfo(e){const t=this._get(xs);return t?t.getSignalingInfo(e):null}modifyInvitation(e){const t=this._get(xs);return t?t.modifyInvitation(e):Xs({code:Ws.CANNOT_FIND_MODULE})}}const yo={login:1,logout:1,getLoginUser:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1,isReady:1,addSignalingListener:1,removeSignalingListener:1,callExperimentalAPI:1};function Do(e,t){if(e.isReady()||1===yo[t])return!0;var s=e.getNotReadyReason(),s={code:s,message:e.getErrorMessage(s)+` | ${t} | `+e.getErrorMessage(Ws.SDK_IS_NOT_READY)};return e.onError(s),s}const So={},Eo={create:function(t){var i="TencentCloudChat.create";let o=0;var n=t["SDKAppID"];if(Pe(n))o=n;else if(o=parseInt(n),isNaN(n))return Ie.e(i+" failed. Failed to parse the SDKAppID, please check the arguments"),null;if(o&&So[o])return So[o];Ie.l(i);const r=new To({...t,SDKAppID:o});r.on(e.SDK_DESTROY,e=>{So[e.data.SDKAppID]=null,delete So[e.data.SDKAppID]});n=function(o){const e=Object.create(null);return Object.keys(_s).forEach(i=>{if(o[i]){const t=new s;e[i]=function(){var e=Array.from(arguments);return t.use(function(e,t){var s=Do(o,i);return!0===s?t():Xs(s)}).use(function(e,t){if(!0===vt(e,ds[i],i))return t()}).use(function(e,t){return o[i].apply(o,e)}),t.run(e)}}}),e}(r);return So[o]=n,ds.hookGetAPITips(r.getErrorMessage.bind(r)),Ie.l(i+" ok"),n}};Eo.TYPES=t,Eo.EVENT=e,Eo.TSignaling={NEW_INVITATION_RECEIVED:"newInvitationReceived",INVITEE_ACCEPTED:"ts_invitee_accepted",INVITEE_REJECTED:"ts_invitee_rejected",INVITATION_CANCELLED:"ts_invitation_cancelled",INVITATION_TIMEOUT:"ts_invitation_timeout",INVITATION_MODIFIED:"ts_invitation_modified",ACTION_TYPE_UNKNOWN:0,ACTION_TYPE_INVITE:1,ACTION_TYPE_CANCEL_INVITE:2,ACTION_TYPE_ACCEPT_INVITE:3,ACTION_TYPE_REJECT_INVITE:4,ACTION_TYPE_INVITE_TIMEOUT:5},Eo.VERSION="3.2.4",Ie.l("TencentCloudChat.VERSION:"+Eo.VERSION);export{Eo as default};