| 1 |
- 'use strict';!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TIM=t()}(this,(function(){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function d(e,t,n){return(d=l()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var a=new(Function.bind.apply(e,o));return n&&u(a,n.prototype),a}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return d(e,arguments,c(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),u(o,e)})(e)}function g(e,t){if(null==e)return{};var n,o,a=function(e,t){if(null==e)return{};var n,o,a={},s=Object.keys(e);for(o=0;o<s.length;o++)n=s[o],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)n=s[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_(e):t}function f(e){return function(){var t,n=c(e);if(l()){var o=c(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return h(this,t)}}function m(e,t){return v(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],o=!0,a=!1,s=void 0;try{for(var r,i=e[Symbol.iterator]();!(o=(r=i.next()).done)&&(n.push(r.value),!t||n.length!==t);o=!0);}catch(c){a=!0,s=c}finally{try{o||null==i.return||i.return()}finally{if(a)throw s}}return n}(e,t)||I(e,t)||T()}function M(e){return function(e){if(Array.isArray(e))return E(e)}(e)||y(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){if(Array.isArray(e))return e}function y(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function I(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function T(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=I(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a,s=!0,r=!1;return{s:function(){o=e[Symbol.iterator]()},n:function(){var e=o.next();return s=e.done,e},e:function(e){r=!0,a=e},f:function(){try{s||null==o.return||o.return()}finally{if(r)throw a}}}}var S={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",PROFILE_UPDATED:"onProfileUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},D={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_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,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,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",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",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_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"},N=function(){function e(){t(this,e),this.cache=[],this.options=null}return o(e,[{key:"use",value:function(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}},{key:"next",value:function(e){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}},{key:"run",value:function(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}]),e}(),A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function k(e,t){return e(t={exports:{}},t.exports),t.exports}var R=k((function(e,t){var n,o,a,s,r,i,c,u,l,d,p,g,_,h,f,m,M,v;e.exports=(n="function"==typeof Promise,o="object"==typeof self?self:A,a="undefined"!=typeof Symbol,s="undefined"!=typeof Map,r="undefined"!=typeof Set,i="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,l=a&&void 0!==Symbol.iterator,d=a&&void 0!==Symbol.toStringTag,p=r&&"function"==typeof Set.prototype.entries,g=s&&"function"==typeof Map.prototype.entries,_=p&&Object.getPrototypeOf((new Set).entries()),h=g&&Object.getPrototypeOf((new Map).entries()),f=l&&"function"==typeof Array.prototype[Symbol.iterator],m=f&&Object.getPrototypeOf([][Symbol.iterator]()),M=l&&"function"==typeof String.prototype[Symbol.iterator],v=M&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=typeof e;if("object"!==t)return t;if(null===e)return"null";if(e===o)return"global";if(Array.isArray(e)&&(!1===d||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var a=d&&e[Symbol.toStringTag];if("string"==typeof a)return a;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":n&&l===Promise.prototype?"Promise":r&&l===Set.prototype?"Set":s&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":i&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":s&&l===h?"Map Iterator":r&&l===_?"Set Iterator":f&&l===m?"Array Iterator":M&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),O=function(){function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,e),this.high=n,this.low=o}return o(e,[{key:"equal",value:function(e){return null!==e&&(this.low===e.low&&this.high===e.high)}},{key:"toString",value:function(){var e=Number(this.high).toString(16),t=Number(this.low).toString(16);if(t.length<8)for(var n=8-t.length;n;)t="0"+t,n--;return e+t}}]),e}(),L={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"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://api.im.qcloud.com"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com"},IND:{DEFAULT:"wss://wssind.im.qcloud.com",BACKUP:"wss://wssind.my-imcloud.com",STAT:"https://apiind.my-imcloud.com"}}},G={WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,UNI_NATIVE_APP:15},P="1.7.3",w=537048168,b="CHINA",U="OVERSEA",F="SINGAPORE",q="KOREA",V="GERMANY",K="IND",x={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://api.im.qcloud.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b;this.CURRENT=L.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",GROUP:"group_open_http_svc",GROUP_COMMUNITY:"million_group_open_http_svc",GROUP_ATTR:"group_open_attr_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MESSAGE:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush"},CMD:{ACCESS_LAYER:"accesslayer",LOGIN:"wslogin",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT:"wslogout",HELLO:"wshello",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",ADD_FRIEND:"friend_add",UPDATE_FRIEND:"friend_update",GET_FRIEND_LIST:"friend_get",GET_FRIEND_PROFILE:"friend_get_list",DELETE_FRIEND:"friend_delete",CHECK_FRIEND:"friend_check",GET_FRIEND_GROUP_LIST:"group_get",RESPOND_FRIEND_APPLICATION:"friend_response",GET_FRIEND_APPLICATION_LIST:"pendency_get",DELETE_FRIEND_APPLICATION:"pendency_delete",REPORT_FRIEND_APPLICATION:"pendency_report",GET_GROUP_APPLICATION:"get_pendency",CREATE_FRIEND_GROUP:"group_add",DELETE_FRIEND_GROUP:"group_delete",UPDATE_FRIEND_GROUP:"group_update",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SET_GROUP_ATTRIBUTES:"set_group_attr",MODIFY_GROUP_ATTRIBUTES:"modify_group_attr",DELETE_GROUP_ATTRIBUTES:"delete_group_attr",CLEAR_GROUP_ATTRIBUTES:"clear_group_attr",GET_GROUP_ATTRIBUTES:"get_group_attr",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",DELETE_C2C_MESSAGE:"delete_c2c_msg_ramble",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",DELETE_GROUP_MESSAGE:"delete_group_ramble_msg_by_seq",GET_GROUP_INFO:"get_group_self_member_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",HANDLE_GROUP_INVITATION:"handle_invite_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",DELETE_GROUP_AT_TIPS:"deletemsg",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"delete",PIN_CONVERSATION:"top",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_GROUP_ROAM_MESSAGES:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",SEND_READ_RECEIPT:"group_msg_receipt",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",VIDEO_COVER:"video_cover",TIM_WEB_REPORT_V2:"tim_web_report_v2",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num",ALIVE:"alive",MESSAGE_PUSH:"msg_push",MULTI_MESSAGE_PUSH:"multi_msg_push_ws",MESSAGE_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCEOFFLINE:"stat_forceoffline",DOWNLOAD_MERGER_MESSAGE:"get_relay_json_msg",UPLOAD_MERGER_MESSAGE:"save_relay_json_msg",FETCH_CLOUD_CONTROL_CONFIG:"fetch_config",PUSHED_CLOUD_CONTROL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",KICK_OTHER:"KickOther",OVERLOAD_NOTIFY:"notify2",SET_ALL_MESSAGE_READ:"read_all_unread_msg"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",im_cos_msg:"v4",webim:"v4",im_open_push:"v4",im_open_status:"v4"}},B={SEARCH_MSG:new O(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new O(0,Math.pow(2,1)).toString(),AVCHATROOM_HISTORY_MSG:new O(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new O(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new O(0,Math.pow(2,4)).toString()};x.HOST.setCurrent(b);var H,j,W,Y,$="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),z="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),J="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),X="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),Q="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),Z="undefined"!=typeof uni&&"undefined"==typeof window,ee="undefined"!=typeof uni,te=$||z||J||X||Q||Z,ne=("undefined"!=typeof uni||"undefined"!=typeof window)&&!te,oe=z?qq:J?tt:X?swan:Q?my:$?wx:Z?uni:{},ae=(H="WEB",ve?H="WEB":z?H="QQ_MP":J?H="TT_MP":X?H="BAIDU_MP":Q?H="ALI_MP":$?H="WX_MP":Z&&(H="UNI_NATIVE_APP"),G[H]),se=ne&&window&&window.navigator&&window.navigator.userAgent||"",re=/AppleWebKit\/([\d.]+)/i.exec(se),ie=(re&&parseFloat(re.pop()),/iPad/i.test(se)),ce=/iPhone/i.test(se)&&!ie,ue=/iPod/i.test(se),le=ce||ie||ue,de=(j=se.match(/OS (\d+)_/i))&&j[1]?j[1]:null,pe=/Android/i.test(se),ge=function(){var e=se.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),_e=(pe&&/webkit/i.test(se),/Firefox/i.test(se),/Edge/i.test(se)),he=!_e&&/Chrome/i.test(se),fe=(function(){var e=se.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(se)||se.indexOf("Trident")>-1&&se.indexOf("rv:11.0")>-1),me=(/MSIE\s8\.0/.test(se),function(){var e=/MSIE\s(\d+)\.\d/.exec(se),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(se)&&/rv:11.0/.test(se)&&(t=11),t}()),Me=(/Safari/i.test(se),/TBS\/\d+/i.test(se)),ve=(function(){var e=se.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}(),!Me&&/MQQBrowser\/\d+/i.test(se),!Me&&/ QQBrowser\/\d+/i.test(se),/(micromessenger|webbrowser)/i.test(se)),ye=/Windows/i.test(se),Ie=/MAC OS X/i.test(se),Ee=(/MicroMessenger/i.test(se),ne&&"undefined"!=typeof Worker&&!fe),Te="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};W="undefined"!=typeof console?console:void 0!==Te&&Te.console?Te.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Ce=function(){},Se=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],De=Se.length;De--;)Y=Se[De],console[Y]||(W[Y]=Ce);W.methods=Se;var Ne=W,Ae=0,ke=function(){return(new Date).getTime()+Ae},Re=function(){Ae=0},Oe=function(){return Math.floor(ke()/1e3)},Le=0,Ge=new Map;function Pe(){var e,t=((e=new Date).setTime(ke()),e);return"TIM "+t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(t.getMilliseconds())+":"}var we={arguments2String:function(e){var t;if(1===e.length)t=Pe()+e[0];else{t=Pe();for(var n=0,o=e.length;n<o;n++)Xe(e[n])?Ze(e[n])?t+=rt(e[n]):t+=JSON.stringify(e[n]):t+=e[n],t+=" "}return t},debug:function(){if(Le<=-1){var e=this.arguments2String(arguments);Ne.debug(e)}},log:function(){if(Le<=0){var e=this.arguments2String(arguments);Ne.log(e)}},info:function(){if(Le<=1){var e=this.arguments2String(arguments);Ne.info(e)}},warn:function(){if(Le<=2){var e=this.arguments2String(arguments);Ne.warn(e)}},error:function(){if(Le<=3){var e=this.arguments2String(arguments);Ne.error(e)}},time:function(e){Ge.set(e,at.now())},timeEnd:function(e){if(Ge.has(e)){var t=at.now()-Ge.get(e);return Ge.delete(e),t}return Ne.warn("未找到对应label: ".concat(e,", 请在调用 logger.timeEnd 前,调用 logger.time")),0},setLevel:function(e){e<4&&Ne.log(Pe()+"set level from "+Le+" to "+e),Le=e},getLevel:function(){return Le}},be={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},Ue={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"},Fe={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},qe={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},Ve={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},Ke="JoinedSuccess",xe="WaitAdminApproval",Be="@TGS#_",He=function(e){return"file"===et(e)},je=function(t){return null!==t&&("number"==typeof t&&!isNaN(t-0)||"object"===e(t)&&t.constructor===Number)},We=function(e){return"string"==typeof e},Ye=function(t){return null!==t&&"object"===e(t)},$e=function(t){if("object"!==e(t)||null===t)return!1;var n=Object.getPrototypeOf(t);if(null===n)return!0;for(var o=n;null!==Object.getPrototypeOf(o);)o=Object.getPrototypeOf(o);return n===o},ze=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===et(e)},Je=function(e){return void 0===e},Xe=function(e){return ze(e)||Ye(e)},Qe=function(e){return"function"==typeof e},Ze=function(e){return e instanceof Error},et=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},nt=function(e){if("string"!=typeof e)return!1;var t=e[0];return!/[^a-zA-Z0-9]/.test(t)},ot=0;Date.now||(Date.now=function(){return(new Date).getTime()});var at={now:function(){0===ot&&(ot=Date.now()-1);var e=Date.now()-ot;return e>4294967295?(ot+=4294967295,Date.now()-ot):e},utc:function(){return Math.round(Date.now()/1e3)}},st=function e(t,n,o,a){if(!Xe(t)||!Xe(n))return 0;for(var s,r=0,i=Object.keys(n),c=0,u=i.length;c<u;c++)if(s=i[c],!(Je(n[s])||o&&o.includes(s)))if(Xe(t[s])&&Xe(n[s]))r+=e(t[s],n[s],o,a);else{if(a&&a.includes(n[s]))continue;t[s]!==n[s]&&(t[s]=n[s],r+=1)}return r},rt=function(e){return JSON.stringify(e,["message","code"])},it=function(e){if(0===e.length)return 0;for(var t=0,n=0,o="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)n+=e[t++].charCodeAt[t]<=255?1:!1===o?3:2;return n},ct=function(e){var t=e||99999999;return Math.round(Math.random()*t)},ut="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",lt=ut.length,dt=function(e,t){for(var n in e)if(e[n]===t)return!0;return!1},pt={},gt=function(){if(te)return"https:";if(ne&&"undefined"==typeof window)return"https:";var e=window.location.protocol;return["http:","https:"].indexOf(e)<0&&(e="http:"),e},_t=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")},ht=function t(n){if(0===Object.getOwnPropertyNames(n).length)return Object.create(null);var o=Array.isArray(n)?[]:Object.create(null),a="";for(var s in n)null!==n[s]?void 0!==n[s]?(a=e(n[s]),["string","number","function","boolean"].indexOf(a)>=0?o[s]=n[s]:o[s]=t(n[s])):o[s]=void 0:o[s]=null;return o};function ft(e,t){ze(e)&&ze(t)?t.forEach((function(t){var n=t.key,o=t.value,a=e.find((function(e){return e.key===n}));a?a.value=o:e.push({key:n,value:o})})):we.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var mt=function(e){return e===D.GRP_PUBLIC},Mt=function(e){return e===D.GRP_AVCHATROOM},vt=function(e){var t=e.type,n=e.groupID;return t===D.GRP_COMMUNITY||"".concat(n).startsWith(Be)},yt=function(e){return We(e)&&e.slice(0,3)===D.CONV_C2C},It=function(e){return We(e)&&e.slice(0,5)===D.CONV_GROUP},Et=function(e){return We(e)&&e===D.CONV_SYSTEM};function Tt(e,t){var n={};return Object.keys(e).forEach((function(o){n[o]=t(e[o],o)})),n}function Ct(e){return te?new Promise((function(t,n){oe.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})})):fe&&9===me?Promise.resolve({width:0,height:0}):new Promise((function(t,n){var o=new Image;o.onload=function(){t({width:this.width,height:this.height}),o=null},o.onerror=function(){t({width:0,height:0}),o=null},o.src=e}))}function St(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(e()+e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}function Dt(){var e="unknown";if(Ie&&(e="mac"),ye&&(e="windows"),le&&(e="ios"),pe&&(e="android"),te)try{var t=oe.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(n){}return e}function Nt(e){var t=e.originUrl,n=void 0===t?void 0:t,o=e.originWidth,a=e.originHeight,s=e.min,r=void 0===s?198:s,i=parseInt(o),c=parseInt(a),u={url:void 0,width:0,height:0};if((i<=c?i:c)<=r)u.url=n,u.width=i,u.height=c;else{c<=i?(u.width=Math.ceil(i*r/c),u.height=r):(u.width=r,u.height=Math.ceil(c*r/i));var l=n&&n.indexOf("?")>-1?"".concat(n,"&"):"".concat(n,"?");u.url="".concat(l,198===r?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")}return Je(n)?g(u,["url"]):u}function At(e){var t=e[2];e[2]=e[1],e[1]=t;for(var n=0;n<e.length;n++)e[n].setType(n)}function kt(e){var t=e.servcmd;return t.slice(t.indexOf(".")+1)}function Rt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function Ot(e,t){return e.includes(t)}function Lt(e,t){return e.includes(t)}var Gt=Object.prototype.hasOwnProperty;function Pt(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($e(e)){for(var t in e)if(Gt.call(e,t))return!1;return!0}return!("map"!==et(e)&&!function(e){return"set"===et(e)}(e)&&!He(e))&&0===e.size}function wt(e,t,n){if(void 0===t)return!0;var o=!0;if("object"===R(t).toLowerCase())Object.keys(t).forEach((function(a){var s=1===e.length?e[0][a]:void 0;o=!!bt(s,t[a],n,a)&&o}));else if("array"===R(t).toLowerCase())for(var a=0;a<t.length;a++)o=!!bt(e[a],t[a],n,t[a].name)&&o;if(o)return o;throw new Error("Params validate failed.")}function bt(e,t,n,o){if(void 0===t)return!0;var a=!0;return t.required&&Pt(e)&&(Ne.error("TIM [".concat(n,'] Missing required params: "').concat(o,'".')),a=!1),Pt(e)||R(e).toLowerCase()===t.type.toLowerCase()||(Ne.error("TIM [".concat(n,'] Invalid params: type check failed for "').concat(o,'".Expected ').concat(t.type,".")),a=!1),t.validator&&!t.validator(e)&&(Ne.error("TIM [".concat(n,"] Invalid params: custom validator check failed for params.")),a=!1),a}var Ut,Ft={UNSEND:"unSend",SUCCESS:"success",FAIL:"fail"},qt={NOT_START:"notStart",PENDING:"pengding",RESOLVED:"resolved",REJECTED:"rejected"},Vt=function(e){return!!e&&(!!(yt(e)||It(e)||Et(e))||(console.warn("非法的会话 ID:".concat(e,"。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)")),!1))},Kt="请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#",xt=function(e){return e.param?"".concat(e.api," ").concat(e.param," ").concat(e.desc,"。").concat(Kt).concat(e.api):"".concat(e.api," ").concat(e.desc,"。").concat(Kt).concat(e.api)},Bt={type:"String",required:!0},Ht={type:"Array",required:!0},jt={type:"Object",required:!0},Wt={login:{userID:Bt,userSig:Bt},addToBlacklist:{userIDList:Ht},on:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(xt({api:"on",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(xt({api:"on",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。"),!0)}}],once:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(xt({api:"once",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(xt({api:"once",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("once 接口的 handler 参数推荐使用具名函数。"),!0)}}],off:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(xt({api:"off",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(xt({api:"off",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("off 接口无法为匿名函数取消监听事件。"),!0)}}],sendMessage:[r({name:"message"},jt)],getMessageList:{conversationID:r({},Bt,{validator:function(e){return Vt(e)}}),nextReqMessageID:{type:"String"},count:{type:"Number",validator:function(e){return!(!Je(e)&&!/^[1-9][0-9]*$/.test(e))||(console.warn(xt({api:"getMessageList",param:"count",desc:"必须为正整数"})),!1)}}},setMessageRead:{conversationID:r({},Bt,{validator:function(e){return Vt(e)}})},setAllMessageRead:{scope:{type:"String",required:!1,validator:function(e){return!e||-1!==[D.READ_ALL_C2C_MSG,D.READ_ALL_GROUP_MSG,D.READ_ALL_MSG].indexOf(e)||(console.warn(xt({api:"setAllMessageRead",param:"scope",desc:"取值必须为 TIM.TYPES.READ_ALL_C2C_MSG, TIM.TYPES.READ_ALL_GROUP_MSG 或 TIM.TYPES.READ_ALL_MSG"})),!1)}}},getConversationProfile:[r({name:"conversationID"},Bt,{validator:function(e){return Vt(e)}})],deleteConversation:[r({name:"conversationID"},Bt,{validator:function(e){return Vt(e)}})],pinConversation:{conversationID:r({},Bt,{validator:function(e){return Vt(e)}}),isPinned:r({},{type:"Boolean",required:!0})},getConversationList:[{name:"options",type:"Array",validator:function(e){return!!Je(e)||(0!==e.length||(console.warn(xt({api:"getConversationList",desc:"获取指定会话时不能传入空数组"})),!1))}}],getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:Bt,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:Ht},createGroup:{name:Bt},joinGroup:{groupID:Bt,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[r({name:"groupID"},Bt)],handleApplication:{message:jt,handleAction:Bt,handleMessage:{type:"String"}},changeGroupOwner:{groupID:Bt,newOwnerID:Bt},updateGroupProfile:{groupID:Bt,muteAllMembers:{type:"Boolean"}},dismissGroup:[r({name:"groupID"},Bt)],searchGroupByID:[r({name:"groupID"},Bt)],initGroupAttributes:{groupID:Bt,groupAttributes:r({},jt,{validator:function(e){var t=!0;return Object.keys(e).forEach((function(n){if(!We(e[n]))return console.warn(xt({api:"initGroupAttributes",desc:"群属性 value 必须是字符串"})),t=!1})),t}})},setGroupAttributes:{groupID:Bt,groupAttributes:r({},jt,{validator:function(e){var t=!0;return Object.keys(e).forEach((function(n){if(!We(e[n]))return console.warn(xt({api:"setGroupAttributes",desc:"群属性 value 必须是字符串"})),t=!1})),t}})},deleteGroupAttributes:{groupID:Bt,keyList:{type:"Array",validator:function(e){if(Je(e))return console.warn(xt({api:"deleteGroupAttributes",desc:"缺少必填参数:keyList"})),!1;if(!ze(e))return!1;if(!Pt(e)){var t=!0;return e.forEach((function(e){if(!We(e))return console.warn(xt({api:"deleteGroupAttributes",desc:"群属性 key 必须是字符串"})),t=!1})),t}return!0}}},getGroupAttributes:{groupID:Bt,keyList:{type:"Array",validator:function(e){if(Je(e))return console.warn(xt({api:"getGroupAttributes",desc:"缺少必填参数:keyList"})),!1;if(!ze(e))return!1;if(!Pt(e)){var t=!0;return e.forEach((function(e){if(!We(e))return console.warn(xt({api:"getGroupAttributes",desc:"群属性 key 必须是字符串"})),t=!1})),t}return!0}}},getGroupMemberList:{groupID:Bt,count:{type:"Number"}},getGroupMemberProfile:{groupID:Bt,userIDList:Ht,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:Bt,userIDList:Ht},setGroupMemberRole:{groupID:Bt,userID:Bt,role:Bt},setGroupMemberMuteTime:{groupID:Bt,userID:Bt,muteTime:{type:"Number",validator:function(e){return e>=0}}},setGroupMemberNameCard:{groupID:Bt,userID:{type:"String"},nameCard:{type:"String",validator:function(e){return We(e)?(e.length,!0):(console.warn(xt({api:"setGroupMemberNameCard",param:"nameCard",desc:"类型必须为 String"})),!1)}}},setGroupMemberCustomField:{groupID:Bt,userID:{type:"String"},memberCustomField:Ht},deleteGroupMember:{groupID:Bt},createTextMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return $e(e)?We(e.text)?0!==e.text.length||(console.warn(xt({api:"createTextMessage",desc:"消息内容不能为空"})),!1):(console.warn(xt({api:"createTextMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn(xt({api:"createTextMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createTextAtMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return $e(e)?We(e.text)?0===e.text.length?(console.warn(xt({api:"createTextAtMessage",desc:"消息内容不能为空"})),!1):!(e.atUserList&&!ze(e.atUserList))||(console.warn(xt({api:"createTextAtMessage",desc:"payload.atUserList 类型必须为数组"})),!1):(console.warn(xt({api:"createTextAtMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn(xt({api:"createTextAtMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createCustomMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return $e(e)?e.data&&!We(e.data)?(console.warn(xt({api:"createCustomMessage",param:"payload.data",desc:"类型必须为 String"})),!1):e.description&&!We(e.description)?(console.warn(xt({api:"createCustomMessage",param:"payload.description",desc:"类型必须为 String"})),!1):!(e.extension&&!We(e.extension))||(console.warn(xt({api:"createCustomMessage",param:"payload.extension",desc:"类型必须为 String"})),!1):(console.warn(xt({api:"createCustomMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createImageMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){if(!$e(e))return console.warn(xt({api:"createImageMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Je(e.file))return console.warn(xt({api:"createImageMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(ne){if(!(e.file instanceof HTMLInputElement||He(e.file)))return $e(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn(xt({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn(xt({api:"createImageMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(xt({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return Je(e)&&console.warn(xt({api:"createImageMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}})},createAudioMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return!!$e(e)||(console.warn(xt({api:"createAudioMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e){return Je(e)&&console.warn(xt({api:"createAudioMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createVideoMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){if(!$e(e))return console.warn(xt({api:"createVideoMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Je(e.file))return console.warn(xt({api:"createVideoMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(ne){if(!(e.file instanceof HTMLInputElement||He(e.file)))return $e(e.file)&&"undefined"!=typeof uni?!!He(e.file.tempFile)||(console.warn(xt({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn(xt({api:"createVideoMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(xt({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Je(e)&&console.warn(xt({api:"createVideoMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createFaceMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return $e(e)?je(e.index)?!!We(e.data)||(console.warn(xt({api:"createFaceMessage",param:"payload.data",desc:"类型必须为 String"})),!1):(console.warn(xt({api:"createFaceMessage",param:"payload.index",desc:"类型必须为 Number"})),!1):(console.warn(xt({api:"createFaceMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createFileMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){if(!$e(e))return console.warn(xt({api:"createFileMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(Je(e.file))return console.warn(xt({api:"createFileMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(ne){if(!(e.file instanceof HTMLInputElement||He(e.file)))return $e(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(console.warn(xt({api:"createFileMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1):(console.warn(xt({api:"createFileMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(xt({api:"createFileMessage",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return Je(e)&&console.warn(xt({api:"createFileMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createLocationMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){return $e(e)?We(e.description)?je(e.longitude)?!!je(e.latitude)||(console.warn(xt({api:"createLocationMessage",param:"payload.latitude",desc:"类型必须为 Number"})),!1):(console.warn(xt({api:"createLocationMessage",param:"payload.longitude",desc:"类型必须为 Number"})),!1):(console.warn(xt({api:"createLocationMessage",param:"payload.description",desc:"类型必须为 String"})),!1):(console.warn(xt({api:"createLocationMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createMergerMessage:{to:Bt,conversationType:Bt,payload:r({},jt,{validator:function(e){if(Pt(e.messageList))return console.warn(xt({api:"createMergerMessage",desc:"不能为空数组"})),!1;if(Pt(e.compatibleText))return console.warn(xt({api:"createMergerMessage",desc:"类型必须为 String,且不能为空"})),!1;var t=!1;return e.messageList.forEach((function(e){e.status===Ft.FAIL&&(t=!0)})),!t||(console.warn(xt({api:"createMergerMessage",desc:"不支持合并已发送失败的消息"})),!1)}})},revokeMessage:[r({name:"message"},jt,{validator:function(e){return Pt(e)?(console.warn("revokeMessage 请传入消息(Message)实例"),!1):e.conversationType===D.CONV_SYSTEM?(console.warn("revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息"),!1):!0!==e.isRevoked||(console.warn("revokeMessage 消息已经被撤回,请勿重复操作"),!1)}})],deleteMessage:[r({name:"messageList"},Ht,{validator:function(e){return!Pt(e)||(console.warn(xt({api:"deleteMessage",param:"messageList",desc:"不能为空数组"})),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e){return ze(e)?(0===e.length&&console.warn(xt({api:"getUserProfile",param:"userIDList",desc:"不能为空数组"})),!0):(console.warn(xt({api:"getUserProfile",param:"userIDList",desc:"必须为数组"})),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!Je(e)||(!!ze(e)||(console.warn(xt({api:"updateMyProfile",param:"profileCustomField",desc:"必须为数组"})),!1))}}},addFriend:{to:Bt,source:{type:"String",required:!0,validator:function(e){return!!e&&(e.startsWith("AddSource_Type_")?!(e.replace("AddSource_Type_","").length>8)||(console.warn(xt({api:"addFriend",desc:"加好友来源字段的关键字长度不得超过8字节"})),!1):(console.warn(xt({api:"addFriend",desc:"加好友来源字段的前缀必须是:AddSource_Type_"})),!1))}},remark:{type:"String",required:!1,validator:function(e){return!(We(e)&&e.length>96)||(console.warn(xt({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}}},deleteFriend:{userIDList:Ht},checkFriend:{userIDList:Ht},getFriendProfile:{userIDList:Ht},updateFriend:{userID:Bt,remark:{type:"String",required:!1,validator:function(e){return!(We(e)&&e.length>96)||(console.warn(xt({api:"updateFriend",desc:" 备注长度最长不得超过 96 个字节"})),!1)}},friendCustomField:{type:"Array",required:!1,validator:function(e){if(e){if(!ze(e))return console.warn(xt({api:"updateFriend",param:"friendCustomField",desc:"必须为数组"})),!1;var t=!0;return e.forEach((function(e){return We(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?We(e.value)?e.value.length>8?(console.warn(xt({api:"updateFriend",desc:"好友自定义字段的关键字长度不得超过8字节"})),t=!1):void 0:(console.warn(xt({api:"updateFriend",desc:"类型必须为 String"})),t=!1):(console.warn(xt({api:"updateFriend",desc:"好友自定义字段的前缀必须是 Tag_SNS_Custom"})),t=!1)})),t}return!0}}},acceptFriendApplication:{userID:Bt},refuseFriendApplication:{userID:Bt},deleteFriendApplication:{userID:Bt},createFriendGroup:{name:Bt},deleteFriendGroup:{name:Bt},addToFriendGroup:{name:Bt,userIDList:Ht},removeFromFriendGroup:{name:Bt,userIDList:Ht},renameFriendGroup:{oldName:Bt,newName:Bt},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e){return ze(e)?0===e.length?(console.warn(xt({api:"sendMessageReadReceipt",param:"messageList",desc:"不能为空数组"})),!1):(e.forEach((function(e){if(e.conversationType===D.CONV_C2C)return console.warn(xt({api:"sendMessageReadReceipt",param:"messageList",desc:"仅支持群消息"})),!1})),!0):(console.warn(xt({api:"sendMessageReadReceipt",param:"messageList",desc:"必须为数组"})),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e){return ze(e)?0===e.length?(console.warn(xt({api:"getMessageReadReceiptList",param:"messageList",desc:"不能为空数组"})),!1):(e.forEach((function(e){if(e.conversationType===D.CONV_C2C)return console.warn(xt({api:"getMessageReadReceiptList",param:"messageList",desc:"仅支持群消息"})),!1})),!0):(console.warn(xt({api:"getMessageReadReceiptList",param:"messageList",desc:"必须为数组"})),!1)}}]},Yt={login:"login",logout:"logout",on:"on",once:"once",off:"off",setLogLevel:"setLogLevel",registerPlugin:"registerPlugin",destroy:"destroy",createTextMessage:"createTextMessage",createTextAtMessage:"createTextAtMessage",createImageMessage:"createImageMessage",createAudioMessage:"createAudioMessage",createVideoMessage:"createVideoMessage",createCustomMessage:"createCustomMessage",createFaceMessage:"createFaceMessage",createFileMessage:"createFileMessage",createLocationMessage:"createLocationMessage",createMergerMessage:"createMergerMessage",downloadMergerMessage:"downloadMergerMessage",createForwardMessage:"createForwardMessage",sendMessage:"sendMessage",resendMessage:"resendMessage",revokeMessage:"revokeMessage",deleteMessage:"deleteMessage",sendMessageReadReceipt:"sendMessageReadReceipt",getGroupMessageReadMemberList:"getGroupMessageReadMemberList",getMessageReadReceiptList:"getMessageReadReceiptList",getMessageList:"getMessageList",findMessage:"findMessage",setMessageRead:"setMessageRead",setAllMessageRead:"setAllMessageRead",getConversationList:"getConversationList",getConversationProfile:"getConversationProfile",deleteConversation:"deleteConversation",pinConversation:"pinConversation",getGroupList:"getGroupList",getGroupProfile:"getGroupProfile",createGroup:"createGroup",joinGroup:"joinGroup",updateGroupProfile:"updateGroupProfile",quitGroup:"quitGroup",dismissGroup:"dismissGroup",changeGroupOwner:"changeGroupOwner",searchGroupByID:"searchGroupByID",setMessageRemindType:"setMessageRemindType",handleGroupApplication:"handleGroupApplication",initGroupAttributes:"initGroupAttributes",setGroupAttributes:"setGroupAttributes",deleteGroupAttributes:"deleteGroupAttributes",getGroupAttributes:"getGroupAttributes",getGroupMemberProfile:"getGroupMemberProfile",getGroupMemberList:"getGroupMemberList",addGroupMember:"addGroupMember",deleteGroupMember:"deleteGroupMember",setGroupMemberNameCard:"setGroupMemberNameCard",setGroupMemberMuteTime:"setGroupMemberMuteTime",setGroupMemberRole:"setGroupMemberRole",setGroupMemberCustomField:"setGroupMemberCustomField",getGroupOnlineMemberCount:"getGroupOnlineMemberCount",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList",addFriend:"addFriend",deleteFriend:"deleteFriend",checkFriend:"checkFriend",updateFriend:"updateFriend",getFriendProfile:"getFriendProfile",getFriendApplicationList:"getFriendApplicationList",refuseFriendApplication:"refuseFriendApplication",deleteFriendApplication:"deleteFriendApplication",acceptFriendApplication:"acceptFriendApplication",setFriendApplicationRead:"setFriendApplicationRead",getFriendGroupList:"getFriendGroupList",createFriendGroup:"createFriendGroup",renameFriendGroup:"renameFriendGroup",deleteFriendGroup:"deleteFriendGroup",addToFriendGroup:"addToFriendGroup",removeFromFriendGroup:"removeFromFriendGroup",callExperimentalAPI:"callExperimentalAPI"},$t="sign",zt="message",Jt="user",Xt="c2c",Qt="group",Zt="sns",en="groupMember",tn="conversation",nn="context",on="storage",an="eventStat",sn="netMonitor",rn="bigDataChannel",cn="upload",un="plugin",ln="syncUnreadMessage",dn="session",pn="channel",gn="message_loss_detection",_n="cloudControl",hn="workerTimer",fn="pullGroupMessage",mn="qualityStat",Mn="commercialConfig",vn=function(){function e(n){t(this,e),this._moduleManager=n,this._className=""}return o(e,[{key:"isLoggedIn",value:function(){return this._moduleManager.getModule(nn).isLoggedIn()}},{key:"isOversea",value:function(){return this._moduleManager.getModule(nn).isOversea()}},{key:"getMyUserID",value:function(){return this._moduleManager.getModule(nn).getUserID()}},{key:"getMyTinyID",value:function(){return this._moduleManager.getModule(nn).getTinyID()}},{key:"getModule",value:function(e){return this._moduleManager.getModule(e)}},{key:"getPlatform",value:function(){return ae}},{key:"getNetworkType",value:function(){return this._moduleManager.getModule(sn).getNetworkType()}},{key:"probeNetwork",value:function(){return this._moduleManager.getModule(sn).probe()}},{key:"getCloudConfig",value:function(e){return this._moduleManager.getModule(_n).getCloudConfig(e)}},{key:"emitOuterEvent",value:function(e,t){this._moduleManager.getOuterEmitterInstance().emit(e,t)}},{key:"emitInnerEvent",value:function(e,t){this._moduleManager.getInnerEmitterInstance().emit(e,t)}},{key:"getInnerEmitterInstance",value:function(){return this._moduleManager.getInnerEmitterInstance()}},{key:"generateTjgID",value:function(e){return this._moduleManager.getModule(nn).getTinyID()+"-"+e.random}},{key:"filterModifiedMessage",value:function(e){if(!Pt(e)){var t=e.filter((function(e){return!0===e.isModified}));t.length>0&&this.emitOuterEvent(S.MESSAGE_MODIFIED,t)}}},{key:"filterUnmodifiedMessage",value:function(e){return Pt(e)?[]:e.filter((function(e){return!1===e.isModified}))}},{key:"request",value:function(e){return this._moduleManager.getModule(dn).request(e)}},{key:"canIUse",value:function(e){return this._moduleManager.getModule(Mn).hasPurchasedFeature(e)}}]),e}(),yn="wslogin",In="wslogout",En="wshello",Tn="KickOther",Cn="getmsg",Sn="authkey",Dn="sendmsg",Nn="send_group_msg",An="portrait_get_all",kn="portrait_set",Rn="black_list_get",On="black_list_add",Ln="black_list_delete",Gn="msgwithdraw",Pn="msgreaded",wn="set_c2c_peer_mute_notifications",bn="get_c2c_peer_mute_notifications",Un="getroammsg",Fn="get_peer_read_time",qn="delete_c2c_msg_ramble",Vn="page_get",Kn="get",xn="delete",Bn="top",Hn="deletemsg",jn="get_joined_group_list",Wn="get_group_self_member_info",Yn="create_group",$n="destroy_group",zn="modify_group_base_info",Jn="apply_join_group",Xn="apply_join_group_noauth",Qn="quit_group",Zn="get_group_public_info",eo="change_group_owner",to="handle_apply_join_group",no="handle_invite_join_group",oo="group_msg_recall",ao="msg_read_report",so="read_all_unread_msg",ro="group_msg_get",io="get_group_msg_receipt",co="group_msg_receipt",uo="get_group_msg_receipt_detail",lo="get_pendency",po="deletemsg",go="get_msg",_o="get_msg_noauth",ho="get_online_member_num",fo="delete_group_ramble_msg_by_seq",mo="set_group_attr",Mo="modify_group_attr",vo="delete_group_attr",yo="clear_group_attr",Io="get_group_attr",Eo="get_group_member_info",To="get_specified_group_member_info",Co="add_group_member",So="delete_group_member",Do="modify_group_member_info",No="cos",Ao="pre_sig",ko="video_cover",Ro="tim_web_report_v2",Oo="alive",Lo="msg_push",Go="multi_msg_push_ws",Po="ws_msg_push_ack",wo="stat_forceoffline",bo="save_relay_json_msg",Uo="get_relay_json_msg",Fo="fetch_config",qo="push_configv2",Vo="fetch_imsdk_purchase_bitsv2",Ko="push_imsdk_purchase_bitsv2",xo="notify2",Bo={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MESSAGE_SEND_FAIL:2100,MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:2103,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_DELETE_FAIL:2111,MESSAGE_UNREAD_ALL_FAIL:2112,MESSAGE_CONTROL_INFO_FAIL:2113,READ_RECEIPT_SEQUENCE_LIST_EMPTY:2114,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,MESSAGE_MERGER_TYPE_INVALID:2450,MESSAGE_MERGER_KEY_INVALID:2451,MESSAGE_MERGER_DOWNLOAD_FAIL:2452,MESSAGE_FORWARD_TYPE_INVALID:2453,MESSAGE_AT_TYPE_INVALID:2454,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,ILLEGAL_GROUP_ID:2602,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_Work:2622,MEMBER_NOT_IN_GROUP:2623,CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM:2641,CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN:2642,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,CANNOT_KICK_MEMBER_IN_AVCHATROOM:2680,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,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GROUP_EXISTED:2710,FRIEND_GROUP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,ADD_BLACKLIST_INVALID_PARAM:2740,DEL_BLACKLIST_INVALID_PARAM:2741,CANNOT_ADD_SELF_TO_BLACKLIST:2742,ADD_FRIEND_INVALID_PARAM:2760,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NETWORK_BASE_OPTIONS_NO_URL:2802,NETWORK_UNDEFINED_SERVER_NAME:2803,NETWORK_PACKAGE_UNDEFINED:2804,NO_NETWORK:2805,CONVERTOR_IRREGULAR_PARAMS:2900,NOTICE_RUNLOOP_UNEXPECTED_CONDITION:2901,NOTICE_RUNLOOP_OFFSET_LOST:2902,UNCAUGHT_ERROR:2903,GET_LONGPOLL_ID_FAILED:2904,INVALID_OPERATION:2905,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,LONG_POLL_KICK_OUT:91101,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,LONG_POLL_API_PARAM_ERROR:90001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},Ho={NO_SDKAPPID:"无 SDKAppID",NO_ACCOUNT_TYPE:"无 accountType",NO_IDENTIFIER:"无 userID",NO_USERSIG:"无 userSig",NO_TINYID:"无 tinyID",NO_A2KEY:"无 a2key",USER_NOT_LOGGED_IN:"用户未登录",REPEAT_LOGIN:"重复登录",COS_UNDETECTED:"未检测到 COS 上传插件",COS_GET_SIG_FAIL:"获取 COS 预签名 URL 失败",MESSAGE_SEND_FAIL:"消息发送失败",MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:"MessageController.constructor() 需要参数 options",MESSAGE_SEND_NEED_MESSAGE_INSTANCE:"需要 Message 的实例",MESSAGE_SEND_INVALID_CONVERSATION_TYPE:'Message.conversationType 只能为 "C2C" 或 "GROUP"',MESSAGE_FILE_IS_EMPTY:"无法发送空文件",MESSAGE_ONPROGRESS_FUNCTION_ERROR:"回调函数运行时遇到错误,请检查接入侧代码",MESSAGE_REVOKE_FAIL:"消息撤回失败",MESSAGE_DELETE_FAIL:"消息删除失败",MESSAGE_UNREAD_ALL_FAIL:"设置所有未读消息为已读处理失败",MESSAGE_CONTROL_INFO_FAIL:"社群不支持消息发送控制选项",READ_RECEIPT_SEQUENCE_LIST_EMPTY:"发送群已读回执时 sequenceList 为空",MESSAGE_IMAGE_SELECT_FILE_FIRST:"请先选择一个图片",MESSAGE_IMAGE_TYPES_LIMIT:"只允许上传 jpg png jpeg gif bmp image webp 格式的图片",MESSAGE_IMAGE_SIZE_LIMIT:"图片大小超过20M,无法发送",MESSAGE_AUDIO_UPLOAD_FAIL:"语音上传失败",MESSAGE_AUDIO_SIZE_LIMIT:"语音大小大于20M,无法发送",MESSAGE_VIDEO_UPLOAD_FAIL:"视频上传失败",MESSAGE_VIDEO_SIZE_LIMIT:"视频大小超过100M,无法发送",MESSAGE_VIDEO_TYPES_LIMIT:"只允许上传 mp4 格式的视频",MESSAGE_FILE_UPLOAD_FAIL:"文件上传失败",MESSAGE_FILE_SELECT_FILE_FIRST:"请先选择一个文件",MESSAGE_FILE_SIZE_LIMIT:"文件大小超过100M,无法发送 ",MESSAGE_FILE_URL_IS_EMPTY:"缺少必要的参数文件 URL",MESSAGE_MERGER_TYPE_INVALID:"非合并消息",MESSAGE_MERGER_KEY_INVALID:"合并消息的 messageKey 无效",MESSAGE_MERGER_DOWNLOAD_FAIL:"下载合并消息失败",MESSAGE_FORWARD_TYPE_INVALID:"选择的消息类型(如群提示消息)不可以转发",MESSAGE_AT_TYPE_INVALID:"社群不支持 @ 所有人",CONVERSATION_NOT_FOUND:"没有找到相应的会话,请检查传入参数",USER_OR_GROUP_NOT_FOUND:"没有找到相应的用户或群组,请检查传入参数",CONVERSATION_UN_RECORDED_TYPE:"未记录的会话类型",ILLEGAL_GROUP_TYPE:"非法的群类型,请检查传入参数",CANNOT_JOIN_WORK:"不能加入 Work 类型的群组",ILLEGAL_GROUP_ID:"群组 ID 非法,Public/Work/Meeting/AVChatRoom 类型群组不能以 @TGS#_ 为前缀,社群必须以 @TGS#_ 为前缀",CANNOT_CHANGE_OWNER_IN_AVCHATROOM:"AVChatRoom 类型的群组不能转让群主",CANNOT_CHANGE_OWNER_TO_SELF:"不能把群主转让给自己",CANNOT_DISMISS_WORK:"不能解散 Work 类型的群组",MEMBER_NOT_IN_GROUP:"用户不在该群组内",JOIN_GROUP_FAIL:"加群失败,请检查传入参数或重试",CANNOT_ADD_MEMBER_IN_AVCHATROOM:"AVChatRoom 类型的群不支持邀请群成员",CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:"非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",CANNOT_KICK_MEMBER_IN_AVCHATROOM:"不能在 AVChatRoom 类型的群组踢人",NOT_OWNER:"你不是群主,只有群主才有权限操作",CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:"不能在 Work / AVChatRoom 类型的群中设置群成员身份",INVALID_MEMBER_ROLE:"不合法的群成员身份,请检查传入参数",CANNOT_SET_SELF_MEMBER_ROLE:"不能设置自己的群成员身份,请检查传入参数",CANNOT_MUTE_SELF:"不能将自己禁言,请检查传入参数",NOT_MY_FRIEND:"非好友关系",ALREADY_MY_FRIEND:"已经是好友关系",FRIEND_GROUP_EXISTED:"好友分组已存在",FRIEND_GROUP_NOT_EXIST:"好友分组不存在",FRIEND_APPLICATION_NOT_EXIST:"好友申请不存在",UPDATE_PROFILE_INVALID_PARAM:"传入 updateMyProfile 接口的参数无效",UPDATE_PROFILE_NO_KEY:"updateMyProfile 无标配资料字段或自定义资料字段",ADD_BLACKLIST_INVALID_PARAM:"传入 addToBlacklist 接口的参数无效",DEL_BLACKLIST_INVALID_PARAM:"传入 removeFromBlacklist 接口的参数无效",CANNOT_ADD_SELF_TO_BLACKLIST:"不能拉黑自己",ADD_FRIEND_INVALID_PARAM:"传入 addFriend 接口的参数无效",NETWORK_ERROR:"网络错误",NETWORK_TIMEOUT:"请求超时",NETWORK_BASE_OPTIONS_NO_URL:"网络层初始化错误,缺少 URL 参数",NETWORK_UNDEFINED_SERVER_NAME:"打包错误,未定义的 serverName",NETWORK_PACKAGE_UNDEFINED:"未定义的 packageConfig",NO_NETWORK:"未连接到网络",CONVERTOR_IRREGULAR_PARAMS:"不规范的参数名称",NOTICE_RUNLOOP_UNEXPECTED_CONDITION:"意料外的通知条件",NOTICE_RUNLOOP_OFFSET_LOST:"_syncOffset 丢失",GET_LONGPOLL_ID_FAILED:"获取 longpolling id 失败",UNCAUGHT_ERROR:"未经明确定义的错误",INVALID_OPERATION:"无效操作,如调用了未定义或者未实现的方法等",CANNOT_FIND_PROTOCOL:"无法找到协议",CANNOT_FIND_MODULE:"无法找到模块,请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-03-sns.html",SDK_IS_NOT_READY:"接口需要 SDK 处于 ready 状态后才能调用",LOGGING:"用户正在登录中",LOGIN_FAILED:"用户登录失败",KICKED_OUT_MULT_DEVICE:"用户多终端登录被踢出",KICKED_OUT_MULT_ACCOUNT:"用户多实例登录被踢出",KICKED_OUT_USERSIG_EXPIRED:"用户 userSig 过期被踢出",LOGGED_OUT:"用户已登出",OVER_FREQUENCY_LIMIT:"超出 SDK 频率控制",LONG_POLL_KICK_OUT:"检测到多个 web 实例登录,消息通道下线",OPEN_SERVICE_OVERLOAD_ERROR:"后台服务正忙,请稍后再试",MESSAGE_A2KEY_EXPIRED:"消息错误码:UserSig 或 A2 失效。",ACCOUNT_A2KEY_EXPIRED:"帐号错误码:UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",LONG_POLL_API_PARAM_ERROR:"longPoll API parameters error"},jo="networkRTT",Wo="messageE2EDelay",Yo="sendMessageC2C",$o="sendMessageGroup",zo="sendMessageGroupAV",Jo="sendMessageRichMedia",Xo="cosUpload",Qo="messageReceivedGroup",Zo="messageReceivedGroupAVPush",ea="messageReceivedGroupAVPull",ta=(a(Ut={},jo,2),a(Ut,Wo,3),a(Ut,Yo,4),a(Ut,$o,5),a(Ut,zo,6),a(Ut,Jo,7),a(Ut,Qo,8),a(Ut,Zo,9),a(Ut,ea,10),a(Ut,Xo,11),Ut),na={info:4,warning:5,error:6},oa={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},aa={login:4},sa=function(){function n(e){t(this,n),this.eventType=aa[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=ke()}return o(n,[{key:"updateTimeStamp",value:function(){this.timestamp=ke()}},{key:"start",value:function(e){return this._startts=e,this}},{key:"end",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._sentFlag){var n=ke();0===this.costTime&&(this.costTime=n-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(n)),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout((function(){e._sentFlag=!0,e._eventStatModule&&e._eventStatModule.pushIn(e)}),0)}}},{key:"setError",value:function(e,t,n){return e instanceof Error?(this._sentFlag||(this.setNetworkType(n),t?(e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message)):(this.setCode(Bo.NO_NETWORK),this.setMoreMessage(Ho.NO_NETWORK)),this.setLevel("error")),this):(we.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(t){return Je(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),je(t)?this.code=t:we.warn("SSOLogData.setCode value not a number, please check!",t,e(t))),this}},{key:"setMessage",value:function(e){return Je(e)||this._sentFlag||(je(e)&&(this.message=e.toString()),We(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return Je(e)||this._sentFlag||(this.level=na[e]),this}},{key:"setMoreMessage",value:function(e){return Pt(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){if(Je(e))we.warn("SSOLogData.setNetworkType value is undefined, please check!");else{var t=oa[e.toLowerCase()];Je(t)||(this.networkType=t)}return this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){this.uiPlatform=e}}],[{key:"bindEventStatModule",value:function(e){n.prototype._eventStatModule=e}}]),n}(),ra="sdkConstruct",ia="sdkReady",ca="login",ua="logout",la="kickedOut",da="registerPlugin",pa="kickOther",ga="wsConnect",_a="wsOnOpen",ha="wsOnClose",fa="wsOnError",ma="networkChange",Ma="getCosAuthKey",va="getCosPreSigUrl",ya="getSnapshotInfo",Ia="upload",Ea="sendMessage",Ta="sendMessageWithReceipt",Ca="getC2CRoamingMessages",Sa="getGroupRoamingMessages",Da="getReadReceipt",Na="getReadReceiptDetail",Aa="sendReadReceipt",ka="revokeMessage",Ra="deleteMessage",Oa="setC2CMessageRead",La="setGroupMessageRead",Ga="emptyMessageBody",Pa="getPeerReadTime",wa="uploadMergerMessage",ba="downloadMergerMessage",Ua="jsonParseError",Fa="messageE2EDelayException",qa="getConversationList",Va="getConversationProfile",Ka="deleteConversation",xa="pinConversation",Ba="getConversationListInStorage",Ha="syncConversationList",ja="setAllMessageRead",Wa="createGroup",Ya="applyJoinGroup",$a="quitGroup",za="searchGroupByID",Ja="changeGroupOwner",Xa="handleGroupApplication",Qa="handleGroupInvitation",Za="setMessageRemindType",es="dismissGroup",ts="updateGroupProfile",ns="getGroupList",os="getGroupProfile",as="getGroupListInStorage",ss="getGroupLastSequence",rs="getGroupMissingMessage",is="pagingGetGroupList",cs="getGroupSimplifiedInfo",us="joinWithoutAuth",ls="initGroupAttributes",ds="setGroupAttributes",ps="deleteGroupAttributes",gs="getGroupAttributes",_s="getGroupMemberList",hs="getGroupMemberProfile",fs="addGroupMember",ms="deleteGroupMember",Ms="setGroupMemberMuteTime",vs="setGroupMemberNameCard",ys="setGroupMemberRole",Is="setGroupMemberCustomField",Es="getGroupOnlineMemberCount",Ts="longPollingAVError",Cs="messageLoss",Ss="messageStacked",Ds="getUserProfile",Ns="updateMyProfile",As="getBlacklist",ks="addToBlacklist",Rs="removeFromBlacklist",Os="callbackFunctionError",Ls="fetchCloudControlConfig",Gs="pushedCloudControlConfig",Ps="fetchCommercialConfig",ws="pushedCommercialConfig",bs="error",Us="lastMessageNotExist",Fs=function(){function e(n){t(this,e),this.type=D.MSG_TEXT,this.content={text:n.text||""}}return o(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),qs=function(){function e(n){t(this,e),this._imageMemoryURL="",te?this.createImageDataASURLInWXMiniApp(n.file):this.createImageDataASURLInWeb(n.file),this._initImageInfoModel(),this.type=D.MSG_IMAGE,this._percent=0,this.content={imageFormat:n.imageFormat||be.UNKNOWN,uuid:n.uuid,imageInfoArray:[]},this.initImageInfoArray(n.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return o(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=ct(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=t.url||e._imageMemoryURL||e._defaultImage},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,n=null,o=null;t<=2;)o=Je(e)||Je(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(n=new this._ImageInfoModel(o)).setSizeType(t+1),n.setType(t),this.addImageInfo(n),t++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,n=this.content.imageInfoArray.length,o=0;o<n;o++)t=this.content.imageInfoArray[o],e[o].size&&(t.size=e[o].size),e[o].url&&t.setImageUrl(e[o].url),e[o].width&&(t.width=e[o].width),e[o].height&&(t.height=e[o].height)}},{key:"_autoFixUrl",value:function(){for(var e=this.content.imageInfoArray.length,t="",n="",o=["http","https"],a=null,s=0;s<e;s++)this.content.imageInfoArray[s].url&&""!==(a=this.content.imageInfoArray[s]).imageUrl&&(n=a.imageUrl.slice(0,a.imageUrl.indexOf("://")+1),t=a.imageUrl.slice(a.imageUrl.indexOf("://")+1),o.indexOf(n)<0&&(n="https:"),this.content.imageInfoArray[s].setImageUrl([n,t].join("")))}},{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=be[e.toUpperCase()]||be.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURLInWXMiniApp",value:function(e){e&&e.url&&(this._imageMemoryURL=e.url)}},{key:"replaceImageInfo",value:function(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}},{key:"addImageInfo",value:function(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=e[0],n=t.width,o=void 0===n?0:n,a=t.height,s=void 0===a?0:a;0!==o&&0!==s&&(At(e),Object.assign(e[2],Nt({originWidth:o,originHeight:s,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}]),e}(),Vs=function(){function e(n){t(this,e),this.type=D.MSG_FACE,this.content=n||null}return o(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),Ks=function(){function e(n){t(this,e),this.type=D.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:n.second,size:n.size,url:n.url,remoteAudioUrl:n.url||"",uuid:n.uuid}}return o(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=e}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),e}(),xs={from:!0,groupID:!0,groupName:!0,to:!0},Bs=function(){function e(n){t(this,e),this.type=D.MSG_GRP_TIP,this.content={},this._initContent(n)}return o(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"remarkInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;case"operatorInfo":break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[n]);break;case"onlineMemberInfo":break;case"memberNum":t.content[n]=e[n],t.content.memberCount=e[n];break;default:t.content[n]=e[n]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var o=t[n];xs[o]&&(this.content.groupProfile[o]=e[o])}}},{key:"_updateMemberList",value:function(e){Pt(this.content.memberList)?this.content.memberList=e:this.content.memberList.forEach((function(t){e.forEach((function(e){t.userID===e.userID&&Object.assign(t,e)}))}))}}]),e}(),Hs={from:!0,groupID:!0,groupName:!0,to:!0},js=function(){function e(n){t(this,e),this.type=D.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(n)}return o(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"memberInfoList":break;case"remarkInfo":t.content.handleMessage=e[n];break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;default:t.content[n]=e[n]}}))}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var o=t[n];Hs[o]&&("groupName"===o?this.content.groupProfile.name=e[o]:this.content.groupProfile[o]=e[o])}}}]),e}(),Ws=function(){function e(n){t(this,e),this.type=D.MSG_FILE,this._percent=0;var o=this._getFileInfo(n);this.content={downloadFlag:2,fileUrl:n.url||"",uuid:n.uuid,fileName:o.name||"",fileSize:o.size||0}}return o(e,[{key:"_getFileInfo",value:function(e){if(!Je(e.fileName)&&!Je(e.fileSize))return{size:e.fileSize,name:e.fileName};var t=e.file.files[0];if(Z){if(t.path&&-1!==t.path.indexOf(".")){var n=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase();t.type=n,t.name||(t.name="".concat(ct(999999),".").concat(n))}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}}},{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateFileUrl",value:function(e){this.content.fileUrl=e}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}]),e}(),Ys=function(){function e(n){t(this,e),this.type=D.MSG_CUSTOM,this.content={data:n.data||"",description:n.description||"",extension:n.extension||""}}return o(e,[{key:"setData",value:function(e){return this.content.data=e,this}},{key:"setDescription",value:function(e){return this.content.description=e,this}},{key:"setExtension",value:function(e){return this.content.extension=e,this}},{key:"sendable",value:function(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}]),e}(),$s=function(){function e(n){t(this,e),this.type=D.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:n.remoteVideoUrl||n.videoUrl||"",videoFormat:n.videoFormat,videoSecond:parseInt(n.videoSecond,10),videoSize:n.videoSize,videoUrl:n.videoUrl,videoDownloadFlag:2,videoUUID:n.videoUUID,thumbUUID:n.thumbUUID,thumbFormat:n.thumbFormat,thumbWidth:n.thumbWidth,snapshotWidth:n.thumbWidth,thumbHeight:n.thumbHeight,snapshotHeight:n.thumbHeight,thumbSize:n.thumbSize,snapshotSize:n.thumbSize,thumbDownloadFlag:2,thumbUrl:n.thumbUrl,snapshotUrl:n.thumbUrl}}return o(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=e)}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,n=e.snapshotWidth,o=e.snapshotHeight;Pt(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Pt(n)||(this.content.thumbWidth=this.content.snapshotWidth=Number(n)),Pt(o)||(this.content.thumbHeight=this.content.snapshotHeight=Number(o))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),e}(),zs=function(){function e(n){t(this,e),this.type=D.MSG_LOCATION;var o=n.description,a=n.longitude,s=n.latitude;this.content={description:o,longitude:a,latitude:s}}return o(e,[{key:"sendable",value:function(){return!0}}]),e}(),Js=function(){function e(n){if(t(this,e),this.from=n.from,this.messageSender=n.from,this.time=n.time,this.messageSequence=n.sequence,this.clientSequence=n.clientSequence||n.sequence,this.messageRandom=n.random,this.cloudCustomData=n.cloudCustomData||"",n.ID)this.nick=n.nick||"",this.avatar=n.avatar||"",this.messageBody=[{type:n.type,payload:n.payload}],n.conversationType.startsWith(D.CONV_C2C)?this.receiverUserID=n.to:n.conversationType.startsWith(D.CONV_GROUP)&&(this.receiverGroupID=n.to),this.messageReceiver=n.to;else{this.nick=n.nick||"",this.avatar=n.avatar||"",this.messageBody=[];var o=n.elements[0].type,a=n.elements[0].content;this._patchRichMediaPayload(o,a),o===D.MSG_MERGER?this.messageBody.push({type:o,payload:new Xs(a).content}):this.messageBody.push({type:o,payload:a}),n.groupID&&(this.receiverGroupID=n.groupID,this.messageReceiver=n.groupID),n.to&&(this.receiverUserID=n.to,this.messageReceiver=n.to)}}return o(e,[{key:"_patchRichMediaPayload",value:function(e,t){e===D.MSG_IMAGE?t.imageInfoArray.forEach((function(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===D.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===D.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===D.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}}]),e}(),Xs=function(){function e(n){if(t(this,e),this.type=D.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},n.downloadKey){var o=n.downloadKey,a=n.pbDownloadKey,s=n.title,r=n.abstractList,i=n.compatibleText,c=n.version;this.content.downloadKey=o,this.content.pbDownloadKey=a,this.content.title=s,this.content.abstractList=r,this.content.compatibleText=i,this.content.version=c||0}else if(Pt(n.messageList))1===n.layersOverLimit&&(this.content.layersOverLimit=!0);else{var u=n.messageList,l=n.title,d=n.abstractList,p=n.compatibleText,g=n.version,_=[];u.forEach((function(e){if(!Pt(e)){var t=new Js(e);_.push(t)}})),this.content.messageList=_,this.content.title=l,this.content.abstractList=d,this.content.compatibleText=p,this.content.version=g||0}we.debug("MergerElement.content:",this.content)}return o(e,[{key:"sendable",value:function(){return!Pt(this.content.messageList)||!Pt(this.content.downloadKey)}}]),e}(),Qs={1:D.MSG_PRIORITY_HIGH,2:D.MSG_PRIORITY_NORMAL,3:D.MSG_PRIORITY_LOW,4:D.MSG_PRIORITY_LOWEST},Zs=function(){function e(n){t(this,e),this.ID="",this.conversationID=n.conversationID||null,this.conversationType=n.conversationType||D.CONV_C2C,this.conversationSubType=n.conversationSubType,this.time=n.time||Math.ceil(Date.now()/1e3),this.sequence=n.sequence||0,this.clientSequence=n.clientSequence||n.sequence||0,this.random=n.random||0===n.random?n.random:ct(),this.priority=this._computePriority(n.priority),this.nick=n.nick||"",this.avatar=n.avatar||"",this.isPeerRead=!1,this.nameCard="",this._elements=[],this.isPlaceMessage=n.isPlaceMessage||0,this.isRevoked=2===n.isPlaceMessage||8===n.msgFlagBits,this.from=n.from||null,this.to=n.to||null,this.flow="",this.isSystemMessage=n.isSystemMessage||!1,this.protocol=n.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=n.status||Ft.SUCCESS,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=n.cloudCustomData||"",this.isDeleted=!1,this.isModified=!1,this._isExcludedFromUnreadCount=!(!n.messageControlInfo||1!==n.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!n.messageControlInfo||1!==n.messageControlInfo.excludedFromLastMessage),this.clientTime=n.clientTime||Oe()||0,this.senderTinyID=n.senderTinyID||n.tinyID||"",this.readReceiptInfo=n.readReceiptInfo||{readCount:void 0,unreadCount:void 0},this.needReadReceipt=!0===n.needReadReceipt||1===n.needReadReceipt,this.reInitialize(n.currentUser),this.extractGroupInfo(n.groupProfile||null),this.handleGroupAtInfo(n)}return o(e,[{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){if(null!==e){We(e.nick)&&(this.nick=e.nick),We(e.avatar)&&(this.avatar=e.avatar);var t=e.messageFromAccountExtraInformation;$e(t)&&We(t.nameCard)&&(this.nameCard=t.nameCard)}}},{key:"handleGroupAtInfo",value:function(e){var t=this;e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach((function(e){e!==D.MSG_AT_ALL?(t._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),t.atUserList.push(e)):(t._groupAtInfoList.push({groupAtAllFlag:1}),t.atUserList.push(D.MSG_AT_ALL))})),ze(e.groupAtInfo)&&e.groupAtInfo.forEach((function(e){0===e.groupAtAllFlag?t.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&t.atUserList.push(D.MSG_AT_ALL)}))}},{key:"getGroupAtInfoList",value:function(){return this._groupAtInfoList}},{key:"_initProxy",value:function(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}},{key:"reInitialize",value:function(e){e&&(this.status=this.from?Ft.SUCCESS:Ft.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}},{key:"isSendable",value:function(){return 0!==this._elements.length&&("function"!=typeof this._elements[0].sendable?(we.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===D.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return we.error("autoIncrementIndex(string: key) need key parameter"),!1;if(void 0===pt[e]){var t=new Date,n="3".concat(t.getHours()).slice(-2),o="0".concat(t.getMinutes()).slice(-2),a="0".concat(t.getSeconds()).slice(-2);pt[e]=parseInt([n,o,a,"0001"].join("")),n=null,o=null,a=null,we.log("autoIncrementIndex start index:".concat(pt[e]))}return pt[e]++}(e)),0===this.sequence&&this.conversationType===D.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(){this.from===D.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID="".concat(this.senderTinyID,"-").concat(this.clientTime,"-").concat(this.random)}},{key:"_initFlow",value:function(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}},{key:"_concatConversationID",value:function(e){var t=this.to,n="",o=this.conversationType;o!==D.CONV_SYSTEM?(n=o===D.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID="".concat(o).concat(n)):this.conversationID=D.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Fs||e instanceof qs||e instanceof Vs||e instanceof Ks||e instanceof Ws||e instanceof $s||e instanceof Bs||e instanceof js||e instanceof Ys||e instanceof zs||e instanceof Xs}},{key:"setElement",value:function(e){var t=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var n=function(e){if(e.type&&e.content)switch(e.type){case D.MSG_TEXT:t.setTextElement(e.content);break;case D.MSG_IMAGE:t.setImageElement(e.content);break;case D.MSG_AUDIO:t.setAudioElement(e.content);break;case D.MSG_FILE:t.setFileElement(e.content);break;case D.MSG_VIDEO:t.setVideoElement(e.content);break;case D.MSG_CUSTOM:t.setCustomElement(e.content);break;case D.MSG_LOCATION:t.setLocationElement(e.content);break;case D.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case D.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case D.MSG_FACE:t.setFaceElement(e.content);break;case D.MSG_MERGER:t.setMergerElement(e.content);break;default:we.warn(e.type,e.content,"no operation......")}};if(ze(e))for(var o=0;o<e.length;o++)n(e[o]);else n(e);this._initProxy()}},{key:"clearElement",value:function(){this._elements.length=0}},{key:"setTextElement",value:function(e){var t="string"==typeof e?e:e.text,n=new Fs({text:t});this._elements.push(n)}},{key:"setImageElement",value:function(e){var t=new qs(e);this._elements.push(t)}},{key:"setAudioElement",value:function(e){var t=new Ks(e);this._elements.push(t)}},{key:"setFileElement",value:function(e){var t=new Ws(e);this._elements.push(t)}},{key:"setVideoElement",value:function(e){var t=new $s(e);this._elements.push(t)}},{key:"setLocationElement",value:function(e){var t=new zs(e);this._elements.push(t)}},{key:"setCustomElement",value:function(e){var t=new Ys(e);this._elements.push(t)}},{key:"setGroupTipElement",value:function(e){var t={},n=e.operationType;Pt(e.memberInfoList)?e.operatorInfo&&(t=e.operatorInfo):n!==D.GRP_TIP_MBR_JOIN&&n!==D.GRP_TIP_MBR_KICKED_OUT&&n!==D.GRP_TIP_MBR_SET_ADMIN&&n!==D.GRP_TIP_MBR_CANCELED_ADMIN||(t=e.memberInfoList[0]);var o=t,a=o.nick,s=o.avatar;We(a)&&(this.nick=a),We(s)&&(this.avatar=s);var r=new Bs(e);this._elements.push(r)}},{key:"setGroupSystemNoticeElement",value:function(e){var t=new js(e);this._elements.push(t)}},{key:"setFaceElement",value:function(e){var t=new Vs(e);this._elements.push(t)}},{key:"setMergerElement",value:function(e){var t=new Xs(e);this._elements.push(t)}},{key:"setIsRead",value:function(e){this.isRead=e}},{key:"setRelayFlag",value:function(e){this._relayFlag=e}},{key:"getRelayFlag",value:function(){return this._relayFlag}},{key:"_computePriority",value:function(e){if(Je(e))return D.MSG_PRIORITY_NORMAL;if(We(e)&&-1!==Object.values(Qs).indexOf(e))return e;if(je(e)){var t=""+e;if(-1!==Object.keys(Qs).indexOf(t))return Qs[t]}return D.MSG_PRIORITY_NORMAL}},{key:"setNickAndAvatar",value:function(e){var t=e.nick,n=e.avatar;We(t)&&(this.nick=t),We(n)&&(this.avatar=n)}},{key:"setNameCard",value:function(e){We(e)&&(this.nameCard=e)}},{key:"elements",get:function(){return we.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}}]),e}(),er=function(e){return{code:0,data:e||{}}},tr="https://cloud.tencent.com/document/product/",nr="您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】 页面校验 UserSig。",or="UserSig 非法,请使用官网提供的 API 重新生成 UserSig(".concat(tr,"269/32688)。"),ar="#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement",sr={70001:"UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",70002:"UserSig 长度为0,请检查传入的 UserSig 是否正确。",70003:or,70005:or,70009:"UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig(".concat(tr,"269/32688)。"),70013:"请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。".concat(nr),70014:"请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。".concat(nr),70016:"密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥(".concat(tr,"269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。"),70020:"SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。",70050:"UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。".concat(nr),70051:"帐号被拉入黑名单。",70052:"UserSig 已经失效,请重新生成,再次尝试。",70107:"因安全原因被限制登录,请不要频繁登录。",70169:"请求的用户帐号不存在。",70114:"".concat("服务端内部超时,请稍后重试。"),70202:"".concat("服务端内部超时,请稍后重试。"),70206:"请求中批量数量不合法。",70402:"参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。",70403:"请求失败,需要 App 管理员权限。",70398:"帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引(".concat(tr,"269/32458)。"),70500:"".concat("服务端内部错误,请重试。"),71e3:"删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。",20001:"请求包非法。",20002:"UserSig 或 A2 失效。",20003:"消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。",20004:"网络异常,请重试。",20005:"".concat("服务端内部错误,请重试。"),20006:"触发发送".concat("单聊消息","之前回调,App 后台返回禁止下发该消息。"),20007:"发送".concat("单聊消息",",被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(").concat(tr,"269/38656)。"),20009:"消息发送双方互相不是好友,禁止发送(配置".concat("单聊消息","校验好友关系才会出现)。"),20010:"发送".concat("单聊消息",",自己不是对方的好友(单向关系),禁止发送。"),20011:"发送".concat("单聊消息",",对方不是自己的好友(单向关系),禁止发送。"),20012:"发送方被禁言,该条消息被禁止发送。",20016:"消息撤回超过了时间限制(默认2分钟)。",20018:"删除漫游内部错误。",90001:"JSON 格式解析失败,请检查请求包是否符合 JSON 规范。",90002:"".concat("JSON 格式请求包体","中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(").concat(tr,"269/2720").concat(ar,")。"),90003:"".concat("JSON 格式请求包体","中缺少 To_Account 字段或者 To_Account 帐号不存在。"),90005:"".concat("JSON 格式请求包体","中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。"),90006:"".concat("JSON 格式请求包体","中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。"),90007:"".concat("JSON 格式请求包体","中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。"),90008:"".concat("JSON 格式请求包体","中缺少 From_Account 字段或者 From_Account 帐号不存在。"),90009:"请求需要 App 管理员权限。",90010:"".concat("JSON 格式请求包体","不符合消息格式描述,请参考 TIMMsgElement 对象的定义(").concat(tr,"269/2720").concat(ar,")。"),90011:"批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。",90012:"To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。",90026:"消息离线存储时间错误(最多不能超过7天)。",90031:"".concat("JSON 格式请求包体","中 SyncOtherMachine 字段不是 Integer 类型。"),90044:"".concat("JSON 格式请求包体","中 MsgLifeTime 字段不是 Integer 类型。"),90048:"请求的用户帐号不存在。",90054:"撤回请求中的 MsgKey 不合法。",90994:"".concat("服务端内部错误,请重试。"),90995:"".concat("服务端内部错误,请重试。"),91e3:"".concat("服务端内部错误,请重试。"),90992:"".concat("服务端内部错误,请重试。","如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。"),93e3:"JSON 数据包超长,消息包体请不要超过8k。",91101:"Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。",10002:"".concat("服务端内部错误,请重试。"),10003:"请求中的接口名称错误,请核对接口名称并重试。",10004:"参数非法,请根据错误描述检查请求是否正确。",10005:"请求包体中携带的帐号数量过多。",10006:"操作频率限制,请尝试降低调用的频率。",10007:"操作权限不足,例如 Work ".concat("群组","中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。"),10008:"请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。",10009:"该群不允许群主主动退出。",10010:"".concat("群组","不存在,或者曾经存在过,但是目前已经被解散。"),10011:"解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。",10012:"发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。",10013:"被邀请加入的用户已经是群成员。",10014:"群已满员,无法将请求中的用户加入".concat("群组",",如果是批量加人,可以尝试减少加入用户的数量。"),10015:"找不到指定 ID 的".concat("群组","。"),10016:"App 后台通过第三方回调拒绝本次操作。",10017:"因被禁言而不能发送消息,请检查发送者是否被设置禁言。",10018:"应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。",10019:"请求的用户帐号不存在。",10021:"".concat("群组"," ID 已被使用,请选择其他的").concat("群组"," ID。"),10023:"发消息的频率超限,请延长两次发消息时间的间隔。",10024:"此邀请或者申请请求已经被处理。",10025:"".concat("群组"," ID 已被使用,并且操作者为群主,可以直接使用。"),10026:"该 SDKAppID 请求的命令字已被禁用。",10030:"请求撤回的消息不存在。",10031:"消息撤回超过了时间限制(默认2分钟)。",10032:"请求撤回的消息不支持撤回操作。",10033:"".concat("群组","类型不支持消息撤回操作。"),10034:"该消息类型不支持删除操作。",10035:"直播群和在线成员广播大群不支持删除消息。",10036:"直播群创建数量超过了限制,请参考价格说明(".concat(tr,"269/11673)购买预付费套餐“IM直播群”。"),10037:"单个用户可创建和加入的".concat("群组","数量超过了限制,请参考价格说明(").concat(tr,"269/11673)购买或升级预付费套餐“单人可创建与加入").concat("群组","数”。"),10038:"群成员数量超过限制,请参考价格说明(".concat(tr,"269/11673)购买或升级预付费套餐“扩展群人数上限”。"),10041:"该应用(SDKAppID)已配置不支持群消息撤回。",10050:"群属性 key 不存在",10056:"请在写入群属性前先使用 getGroupAttributes 接口更新本地群属性,避免冲突。",10059:"非旗舰版",10060:"群人数超过已读回执人数上限",10061:"在线消息不支持已读回执",10062:"找不到群消息的已读回执信息",30001:"请求参数错误,请根据错误描述检查请求参数",30002:"SDKAppID 不匹配",30003:"请求的用户帐号不存在",30004:"请求需要 App 管理员权限",30005:"关系链字段中包含敏感词",30006:"".concat("服务端内部错误,请重试。"),30007:"".concat("网络超时,请稍后重试. "),30008:"并发写导致写冲突,建议使用批量方式",30009:"后台禁止该用户发起加好友请求",30010:"自己的好友数已达系统上限",30011:"分组已达系统上限",30012:"未决数已达系统上限",30014:"对方的好友数已达系统上限",30515:"请求添加好友时,对方在自己的黑名单中,不允许加好友",30516:"请求添加好友时,对方的加好友验证方式是不允许任何人添加自己为好友",30525:"请求添加好友时,自己在对方的黑名单中,不允许加好友",30539:"等待对方同意",30540:"添加好友请求被安全策略打击,请勿频繁发起添加好友请求",31704:"与请求删除的帐号之间不存在好友关系",31707:"删除好友请求被安全策略打击,请勿频繁发起删除好友请求"},rr=function(e){i(o,e);var n=f(o);function o(e){var a;return t(this,o),(a=n.call(this)).code=e.code,a.message=sr[e.code]||e.message,a.data=e.data||{},a}return o}(p(Error)),ir=null,cr=function(e){ir=e},ur=function(e){return Promise.resolve(er(e))},lr=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof rr)return t&&null!==ir&&ir.emit(S.ERROR,e),Promise.reject(e);if(e instanceof Error){var n=new rr({code:Bo.UNCAUGHT_ERROR,message:e.message});return t&&null!==ir&&ir.emit(S.ERROR,n),Promise.reject(n)}if(Je(e)||Je(e.code)||Je(e.message))we.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if(je(e.code)&&We(e.message)){var o=new rr(e);return t&&null!==ir&&ir.emit(S.ERROR,o),Promise.reject(o)}we.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},dr=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="C2CModule",o}return o(a,[{key:"onNewC2CMessage",value:function(e){var t=e.dataList,n=e.isInstantMessage,o=e.C2CRemainingUnreadList,a=e.C2CPairUnreadList;we.debug("".concat(this._className,".onNewC2CMessage count:").concat(t.length," isInstantMessage:").concat(n));var s=this._newC2CMessageStoredAndSummary({dataList:t,C2CRemainingUnreadList:o,C2CPairUnreadList:a,isInstantMessage:n}),r=s.conversationOptionsList,i=s.messageList,c=s.isUnreadC2CMessage;(this.filterModifiedMessage(i),r.length>0)&&this.getModule(tn).onNewMessage({conversationOptionsList:r,isInstantMessage:n,isUnreadC2CMessage:c});var u=this.filterUnmodifiedMessage(i);n&&u.length>0&&this.emitOuterEvent(S.MESSAGE_RECEIVED,u),i.length=0}},{key:"_newC2CMessageStoredAndSummary",value:function(e){for(var t=e.dataList,n=e.C2CRemainingUnreadList,o=e.C2CPairUnreadList,a=e.isInstantMessage,s=null,r=[],i=[],c={},u=this.getModule(rn),l=this.getModule(mn),d=!1,p=0,g=t.length;p<g;p++){var _=t[p];_.currentUser=this.getMyUserID(),_.conversationType=D.CONV_C2C,_.isSystemMessage=!!_.isSystemMessage,(Je(_.nick)||Je(_.avatar))&&(d=!0,we.debug("".concat(this._className,"._newC2CMessageStoredAndSummary nick or avatar missing!"))),s=new Zs(_),_.elements=u.parseElements(_.elements,_.from),s.setElement(_.elements),s.setNickAndAvatar({nick:_.nick,avatar:_.avatar});var h=s.conversationID;if(a){var f=!1,m=this.getModule(tn);if(s.from!==this.getMyUserID()){var M=m.getLatestMessageSentByPeer(h);if(M){var v=M.nick,y=M.avatar;d?s.setNickAndAvatar({nick:v,avatar:y}):v===s.nick&&y===s.avatar||(f=!0)}}else{var I=m.getLatestMessageSentByMe(h);if(I){var E=I.nick,T=I.avatar;E===s.nick&&T===s.avatar||m.modifyMessageSentByMe({conversationID:h,latestNick:s.nick,latestAvatar:s.avatar})}}var C=1===t[p].isModified;if(m.isMessageSentByCurrentInstance(s)?s.isModified=C:C=!1,0===_.msgLifeTime)s._onlineOnlyFlag=!0,i.push(s);else{if(!m.pushIntoMessageList(i,s,C))continue;f&&(m.modifyMessageSentByPeer({conversationID:h,latestNick:s.nick,latestAvatar:s.avatar}),m.updateUserProfileSpecifiedKey({conversationID:h,nick:s.nick,avatar:s.avatar}))}a&&s.clientTime>0&&l.addMessageDelay(s.clientTime)}if(0!==_.msgLifeTime){if(!1===s._onlineOnlyFlag)if(Je(c[h])){var S=0;"in"===s.flow&&(s._isExcludedFromUnreadCount||(S=1)),c[h]=r.push({conversationID:h,unreadCount:S,type:s.conversationType,subType:s.conversationSubType,lastMessage:s._isExcludedFromLastMessage?"":s})-1}else{var N=c[h];r[N].type=s.conversationType,r[N].subType=s.conversationSubType,r[N].lastMessage=s._isExcludedFromLastMessage?"":s,"in"===s.flow&&(s._isExcludedFromUnreadCount||r[N].unreadCount++)}}else s._onlineOnlyFlag=!0}var A=!1;if(ze(o))for(var k=function(e,t){if(o[e].unreadCount>0){A=!0;var n=r.find((function(t){return t.conversationID==="C2C".concat(o[e].from)}));n?n.unreadCount=o[e].unreadCount:r.push({conversationID:"C2C".concat(o[e].from),unreadCount:o[e].unreadCount,type:D.CONV_C2C})}},R=0,O=o.length;R<O;R++)k(R);if(ze(n))for(var L=function(e,t){r.find((function(t){return t.conversationID==="C2C".concat(n[e].from)}))||r.push({conversationID:"C2C".concat(n[e].from),type:D.CONV_C2C,lastMsgTime:n[e].lastMsgTime})},G=0,P=n.length;G<P;G++)L(G);return{conversationOptionsList:r,messageList:i,isUnreadC2CMessage:A}}},{key:"onC2CMessageRevoked",value:function(e){var t=this;we.debug("".concat(this._className,".onC2CMessageRevoked count:").concat(e.dataList.length));var n=this.getModule(tn),o=[],a=null;e.dataList.forEach((function(e){if(e.c2cMessageRevokedNotify){var s=e.c2cMessageRevokedNotify.revokedInfos;Je(s)||s.forEach((function(e){var s=t.getMyUserID()===e.from?"".concat(D.CONV_C2C).concat(e.to):"".concat(D.CONV_C2C).concat(e.from);(a=n.revoke(s,e.sequence,e.random))&&o.push(a)}))}})),0!==o.length&&(n.onMessageRevoked(o),this.emitOuterEvent(S.MESSAGE_REVOKED,o))}},{key:"onC2CMessageReadReceipt",value:function(e){var t=this;e.dataList.forEach((function(e){if(!Pt(e.c2cMessageReadReceipt)){var n=e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach((function(e){var o=e.peerReadTime;we.debug("".concat(t._className,"._onC2CMessageReadReceipt to:").concat(n," peerReadTime:").concat(o));var a="".concat(D.CONV_C2C).concat(n),s=t.getModule(tn);s.recordPeerReadTime(a,o),s.updateMessageIsPeerReadProperty(a,o)}))}}))}},{key:"onC2CMessageReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){if(!Pt(e.c2cMessageReadNotice)){var n=t.getModule(tn);e.c2cMessageReadNotice.uinPairReadArray.forEach((function(e){var o=e.from,a=e.peerReadTime;we.debug("".concat(t._className,".onC2CMessageReadNotice from:").concat(o," lastReadTime:").concat(a));var s="".concat(D.CONV_C2C).concat(o);n.updateIsReadAfterReadReport({conversationID:s,lastMessageTime:a}),n.updateUnreadCount(s)}))}}))}},{key:"sendMessage",value:function(e,t){var n=this._createC2CMessagePack(e,t);return this.request(n)}},{key:"_createC2CMessagePack",value:function(e,t){var n=null;t&&(t.offlinePushInfo&&(n=t.offlinePushInfo),!0===t.onlineUserOnly&&(n?n.disablePush=!0:n={disablePush:!0}));var o="";We(e.cloudCustomData)&&e.cloudCustomData.length>0&&(o=e.cloudCustomData);var a=[];if($e(t)&&$e(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}return{protocolName:Dn,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:e.getElements(),cloudCustomData:o,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:this.isOnlineMessage(e,t)?0:void 0,nick:e.nick,avatar:e.avatar,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,clientTime:e.clientTime}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.request({protocolName:Gn,requestData:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}},{key:"deleteMessage",value:function(e){var t=e.to,n=e.keyList;return we.log("".concat(this._className,".deleteMessage toAccount:").concat(t," count:").concat(n.length)),this.request({protocolName:qn,requestData:{fromAccount:this.getMyUserID(),to:t,keyList:n}})}},{key:"setMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageTime,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(n," lastMessageTime:").concat(o)),je(o)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确"));var s=new sa(Oa);return s.setMessage("conversationID:".concat(n," lastMessageTime:").concat(o)),this.request({protocolName:Pn,requestData:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:n.replace("C2C",""),lastMessageTime:o,receipt:1}]}}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok"));var e=t.getModule(tn);return e.updateIsReadAfterReadReport({conversationID:n,lastMessageTime:o}),e.updateUnreadCount(n),er()})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.log("".concat(a," failed. error:"),e),lr(e)}))}},{key:"getRoamingMessage",value:function(e){var t=this,n="".concat(this._className,".getRoamingMessage"),o=e.peerAccount,a=e.conversationID,s=e.count,r=e.lastMessageTime,i=e.messageKey,c="peerAccount:".concat(o," count:").concat(s||15," lastMessageTime:").concat(r||0," messageKey:").concat(i);we.log("".concat(n," ").concat(c));var u=new sa(Ca);return this.request({protocolName:Un,requestData:{peerAccount:o,count:s||15,lastMessageTime:r||0,messageKey:i}}).then((function(e){var o=e.data,s=o.complete,r=o.messageList,i=o.messageKey,l=o.lastMessageTime;Je(r)?we.log("".concat(n," ok. complete:").concat(s," but messageList is undefined!")):we.log("".concat(n," ok. complete:").concat(s," count:").concat(r.length)),u.setNetworkType(t.getNetworkType()).setMessage("".concat(c," complete:").concat(s," length:").concat(r.length)).end();var d=t.getModule(tn);1===s&&d.setCompleted(a);var p=d.storeRoamingMessage(r,a);d.modifyMessageList(a),d.updateIsRead(a),d.updateRoamingMessageKeyAndTime(a,i,l);var g=d.getPeerReadTime(a);if(we.log("".concat(n," update isPeerRead property. conversationID:").concat(a," peerReadTime:").concat(g)),g)d.updateMessageIsPeerReadProperty(a,g);else{var _=a.replace(D.CONV_C2C,"");t.getRemotePeerReadTime([_]).then((function(){d.updateMessageIsPeerReadProperty(a,d.getPeerReadTime(a))}))}return p})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];u.setMessage(c).setError(e,o,a).end()})),we.warn("".concat(n," failed. error:"),e),lr(e)}))}},{key:"getRemotePeerReadTime",value:function(e){var t=this,n="".concat(this._className,".getRemotePeerReadTime");if(Pt(e))return we.warn("".concat(n," userIDList is empty!")),Promise.resolve();var o=new sa(Pa);return we.log("".concat(n," userIDList:").concat(e)),this.request({protocolName:Fn,requestData:{userIDList:e}}).then((function(a){var s=a.data.peerReadTimeList;we.log("".concat(n," ok. peerReadTimeList:").concat(s));for(var r="",i=t.getModule(tn),c=0;c<e.length;c++)r+="".concat(e[c],"-").concat(s[c]," "),s[c]>0&&i.recordPeerReadTime("C2C".concat(e[c]),s[c]);o.setNetworkType(t.getNetworkType()).setMessage(r).end()})).catch((function(e){t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.warn("".concat(n," failed. error:"),e)}))}}]),a}(vn),pr=function(){function e(n){t(this,e),this.list=new Map,this._className="MessageListHandler",this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._groupLocalLastMessageSequenceMap=new Map}return o(e,[{key:"getLocalOldestMessageByConversationID",value:function(e){if(!e)return null;if(!this.list.has(e))return null;var t=this.list.get(e).values();return t?t.next().value:null}},{key:"pushIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.conversationID,o=e.ID,a=!0;this.list.has(n)||this.list.set(n,new Map);var s=this.list.get(n).has(o);if(s){var r=this.list.get(n).get(o);if(!t||!0===r.isModified)return a=!1}return this.list.get(n).set(o,e),this._setLatestMessageSentByPeer(n,e),this._setLatestMessageSentByMe(n,e),this._setGroupLocalLastMessageSequence(n,e),a}},{key:"unshift",value:function(e){var t;if(ze(e)){if(e.length>0){t=e[0].conversationID;var n=e.length;this._unshiftMultipleMessages(e),this._setGroupLocalLastMessageSequence(t,e[n-1])}}else t=e.conversationID,this._unshiftSingleMessage(e),this._setGroupLocalLastMessageSequence(t,e);if(t&&t.startsWith(D.CONV_C2C)){var o=Array.from(this.list.get(t).values()),a=o.length;if(0===a)return;for(var s=a-1;s>=0;s--)if("out"===o[s].flow){this._setLatestMessageSentByMe(t,o[s]);break}for(var r=a-1;r>=0;r--)if("in"===o[r].flow){this._setLatestMessageSentByPeer(t,o[r]);break}}}},{key:"_unshiftSingleMessage",value:function(e){var t=e.conversationID,n=e.ID;if(!this.list.has(t))return this.list.set(t,new Map),void this.list.get(t).set(n,e);var o=Array.from(this.list.get(t));o.unshift([n,e]),this.list.set(t,new Map(o))}},{key:"_unshiftMultipleMessages",value:function(e){for(var t=e.length,n=[],o=e[0].conversationID,a=this.list.has(o)?Array.from(this.list.get(o)):[],s=0;s<t;s++)n.push([e[s].ID,e[s]]);this.list.set(o,new Map(n.concat(a)))}},{key:"remove",value:function(e){var t=e.conversationID,n=e.ID;this.list.has(t)&&this.list.get(t).delete(n)}},{key:"revoke",value:function(e,t,n){if(we.debug("revoke message",e,t,n),this.list.has(e)){var o,a=C(this.list.get(e));try{for(a.s();!(o=a.n()).done;){var s=m(o.value,2)[1];if(s.sequence===t&&!s.isRevoked&&(Je(n)||s.random===n))return s.isRevoked=!0,s}}catch(r){a.e(r)}finally{a.f()}}return null}},{key:"removeByConversationID",value:function(e){this.list.has(e)&&(this.list.delete(e),this._latestMessageSentByPeerMap.delete(e),this._latestMessageSentByMeMap.delete(e))}},{key:"findMessage",value:function(e){var t,n=null,o=C(this.list);try{for(o.s();!(t=o.n()).done;){var a=m(t.value,2)[1];a.has(e)&&(n=a.get(e))}}catch(s){o.e(s)}finally{o.f()}return n}},{key:"updateMessageIsPeerReadProperty",value:function(e,t){var n=[];if(this.list.has(e)){var o,a=C(this.list.get(e));try{for(a.s();!(o=a.n()).done;){var s=m(o.value,2)[1];s.time<=t&&!s.isPeerRead&&"out"===s.flow&&(s.isPeerRead=!0,n.push(s))}}catch(r){a.e(r)}finally{a.f()}we.log("".concat(this._className,".updateMessageIsPeerReadProperty conversationID:").concat(e," peerReadTime:").concat(t," count:").concat(n.length))}return n}},{key:"updateMessageIsModifiedProperty",value:function(e){var t=e.conversationID,n=e.ID;if(this.list.has(t)){var o=this.list.get(t).get(n);o&&(o.isModified=!0)}}},{key:"hasLocalMessageList",value:function(e){return this.list.has(e)}},{key:"getLocalMessageList",value:function(e){return this.hasLocalMessageList(e)?M(this.list.get(e).values()):[]}},{key:"hasLocalMessage",value:function(e,t){return!!this.hasLocalMessageList(e)&&this.list.get(e).has(t)}},{key:"getLocalMessage",value:function(e,t){return this.hasLocalMessage(e,t)?this.list.get(e).get(t):null}},{key:"getLocalLastMessage",value:function(e){var t=this.getLocalMessageList(e);return t[t.length-1]}},{key:"_setLatestMessageSentByPeer",value:function(e,t){e.startsWith(D.CONV_C2C)&&"in"===t.flow&&this._latestMessageSentByPeerMap.set(e,t)}},{key:"_setLatestMessageSentByMe",value:function(e,t){e.startsWith(D.CONV_C2C)&&"out"===t.flow&&this._latestMessageSentByMeMap.set(e,t)}},{key:"_setGroupLocalLastMessageSequence",value:function(e,t){e.startsWith(D.CONV_GROUP)&&this._groupLocalLastMessageSequenceMap.set(e,t.sequence)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._latestMessageSentByPeerMap.get(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._latestMessageSentByMeMap.get(e)}},{key:"getGroupLocalLastMessageSequence",value:function(e){return this._groupLocalLastMessageSequenceMap.get(e)||0}},{key:"modifyMessageSentByPeer",value:function(e){var t=e.conversationID,n=e.latestNick,o=e.latestAvatar,a=this.list.get(t);if(!Pt(a)){var s=Array.from(a.values()),r=s.length;if(0!==r){for(var i=null,c=0,u=!1,l=r-1;l>=0;l--)"in"===s[l].flow&&((i=s[l]).nick!==n&&(i.setNickAndAvatar({nick:n}),u=!0),i.avatar!==o&&(i.setNickAndAvatar({avatar:o}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByPeer conversationID:").concat(t," count:").concat(c))}}}},{key:"modifyMessageSentByMe",value:function(e){var t=e.conversationID,n=e.latestNick,o=e.latestAvatar,a=this.list.get(t);if(!Pt(a)){var s=Array.from(a.values()),r=s.length;if(0!==r){for(var i=null,c=0,u=!1,l=r-1;l>=0;l--)"out"===s[l].flow&&((i=s[l]).nick!==n&&(i.setNickAndAvatar({nick:n}),u=!0),i.avatar!==o&&(i.setNickAndAvatar({avatar:o}),u=!0),u&&(c+=1));we.log("".concat(this._className,".modifyMessageSentByMe conversationID:").concat(t," count:").concat(c))}}}},{key:"traversal",value:function(){if(0!==this.list.size&&-1===we.getLevel()){console.group("conversationID-messageCount");var e,t=C(this.list);try{for(t.s();!(e=t.n()).done;){var n=m(e.value,2),o=n[0],a=n[1];console.log("".concat(o,"-").concat(a.size))}}catch(s){t.e(s)}finally{t.f()}console.groupEnd()}}},{key:"reset",value:function(){this.list.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._groupLocalLastMessageSequenceMap.clear()}}]),e}(),gr="_a2KeyAndTinyIDUpdated",_r="_cloudConfigUpdated",hr="_profileUpdated";function fr(e){this.mixin(e)}fr.mixin=function(e){var t=e.prototype||e;t._isReady=!1,t.ready=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[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(){var e=this;this._isReady=!0,setTimeout((function(){var t=e._readyQueue;e._readyQueue=[],t&&t.length>0&&t.forEach((function(e){e.call(this)}),e)}),1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};var mr=["jpg","jpeg","gif","png","bmp","image","webp"],Mr=["mp4"],vr=1,yr=2,Ir=3,Er=255,Tr=function(){function e(n){var o=this;t(this,e),Pt(n)||(this.userID=n.userID||"",this.nick=n.nick||"",this.gender=n.gender||"",this.birthday=n.birthday||0,this.location=n.location||"",this.selfSignature=n.selfSignature||"",this.allowType=n.allowType||D.ALLOW_TYPE_ALLOW_ANY,this.language=n.language||0,this.avatar=n.avatar||"",this.messageSettings=n.messageSettings||0,this.adminForbidType=n.adminForbidType||D.FORBID_TYPE_NONE,this.level=n.level||0,this.role=n.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Pt(n.profileCustomField)||n.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return o(e,[{key:"validate",value:function(e){var t=!0,n="";if(Pt(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var o=e.profileCustomField.length,a=null,s=0;s<o;s++){if(a=e.profileCustomField[s],!We(a.key)||-1===a.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"自定义资料字段的前缀必须是 Tag_Profile_Custom"};if(!We(a.value))return{valid:!1,tips:"自定义资料字段的 value 必须是字符串"}}for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if("profileCustomField"===r)continue;if(Pt(e[r])&&!We(e[r])&&!je(e[r])){n="key:"+r+", invalid value:"+e[r],t=!1;continue}switch(r){case"nick":We(e[r])||(n="nick should be a string",t=!1),it(e[r])>500&&(n="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(it(e[r])," bytes"),t=!1);break;case"gender":dt(Fe,e.gender)||(n="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":je(e.birthday)||(n="birthday should be a number",t=!1);break;case"location":We(e.location)||(n="location should be a string",t=!1);break;case"selfSignature":We(e.selfSignature)||(n="selfSignature should be a string",t=!1);break;case"allowType":dt(Ve,e.allowType)||(n="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":je(e.language)||(n="language should be a number",t=!1);break;case"avatar":We(e.avatar)||(n="avatar should be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(n="messageSettings should be 0 or 1",t=!1);break;case"adminForbidType":dt(qe,e.adminForbidType)||(n="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":je(e.level)||(n="level should be a number",t=!1);break;case"role":je(e.role)||(n="role should be a number",t=!1);break;default:n="unknown key:"+r+" "+e[r],t=!1}}return{valid:t,tips:n}}}]),e}(),Cr=function e(n){t(this,e),this.value=n,this.next=null},Sr=function(){function e(n){t(this,e),this.MAX_LENGTH=n,this.pTail=null,this.pNodeToDel=null,this.map=new Map,we.debug("SinglyLinkedList init MAX_LENGTH:".concat(this.MAX_LENGTH))}return o(e,[{key:"set",value:function(e){var t=new Cr(e);if(this.map.size<this.MAX_LENGTH)null===this.pTail?(this.pTail=t,this.pNodeToDel=t):(this.pTail.next=t,this.pTail=t),this.map.set(e,1);else{var n=this.pNodeToDel;this.pNodeToDel=this.pNodeToDel.next,this.map.delete(n.value),n.next=null,n=null,this.pTail.next=t,this.pTail=t,this.map.set(e,1)}}},{key:"has",value:function(e){return this.map.has(e)}},{key:"delete",value:function(e){this.has(e)&&this.map.delete(e)}},{key:"tail",value:function(){return this.pTail}},{key:"size",value:function(){return this.map.size}},{key:"data",value:function(){return Array.from(this.map.keys())}},{key:"reset",value:function(){for(var e;null!==this.pNodeToDel;)e=this.pNodeToDel,this.pNodeToDel=this.pNodeToDel.next,e.next=null,e=null;this.pTail=null,this.map.clear()}}]),e}(),Dr=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers"],Nr=function(){function e(n){t(this,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.groupCustomField=[],this.muteAllMembers=void 0,this._initGroup(n)}return o(e,[{key:"_initGroup",value:function(e){for(var t in e)Dr.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),this[t]=e[t]):this.updateSelfInfo(e[t]))}},{key:"updateGroup",value:function(e){var t=this,n=JSON.parse(JSON.stringify(e));n.lastMsgTime&&(this.lastMessage.lastTime=n.lastMsgTime),Je(n.muteAllMembers)||("On"===n.muteAllMembers?n.muteAllMembers=!0:n.muteAllMembers=!1),n.groupCustomField&&ft(this.groupCustomField,n.groupCustomField),Je(n.memberNum)||(this.memberCount=n.memberNum),Je(n.maxMemberNum)||(this.maxMemberCount=n.maxMemberNum),st(this,n,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum"]),ze(n.members)&&n.members.length>0&&n.members.forEach((function(e){e.userID===t.selfInfo.userID&&st(t.selfInfo,e,["sequence"])}))}},{key:"updateSelfInfo",value:function(e){var t=e.nameCard,n=e.joinTime,o=e.role,a=e.messageRemindType,s=e.readedSequence,r=e.excludedUnreadSequenceList;st(this.selfInfo,{nameCard:t,joinTime:n,role:o,messageRemindType:a,readedSequence:s,excludedUnreadSequenceList:r},[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}},{key:"memberNum",set:function(e){},get:function(){return we.warn("!!!v2.8.0起弃用memberNum,请使用 memberCount"),this.memberCount}},{key:"maxMemberNum",set:function(e){},get:function(){return we.warn("!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount"),this.maxMemberCount}}]),e}(),Ar=function(e,t){if(Je(t))return"";switch(e){case D.MSG_TEXT:return t.text;case D.MSG_IMAGE:return"[图片]";case D.MSG_LOCATION:return"[位置]";case D.MSG_AUDIO:return"[语音]";case D.MSG_VIDEO:return"[视频]";case D.MSG_FILE:return"[文件]";case D.MSG_CUSTOM:return"[自定义消息]";case D.MSG_GRP_TIP:return"[群提示消息]";case D.MSG_GRP_SYS_NOTICE:return"[群系统通知]";case D.MSG_FACE:return"[动画表情]";case D.MSG_MERGER:return"[聊天记录]";default:return""}},kr=function(e){return Je(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:""}:e instanceof Zs?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Ar(e.type,e.payload),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||""}:r({},e,{messageForShow:Ar(e.type,e.payload)})},Rr=function(){function e(n){t(this,e),this.conversationID=n.conversationID||"",this.unreadCount=n.unreadCount||0,this.type=n.type||"",this.lastMessage=kr(n.lastMessage),n.lastMsgTime&&(this.lastMessage.lastTime=n.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=n.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=n.isPinned||!1,this.messageRemindType="",this._initProfile(n)}return o(e,[{key:"_initProfile",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"userProfile":t.userProfile=e.userProfile;break;case"groupProfile":t.groupProfile=e.groupProfile}})),Je(this.userProfile)&&this.type===D.CONV_C2C?this.userProfile=new Tr({userID:e.conversationID.replace("C2C","")}):Je(this.groupProfile)&&this.type===D.CONV_GROUP&&(this.groupProfile=new Nr({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,n=e.isFromGetConversations,o=e.isUnreadC2CMessage;Je(t)||(Mt(this.subType)?this.unreadCount=0:n&&this.type===D.CONV_GROUP||o&&this.type===D.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=kr(e)}},{key:"updateGroupAtInfoList",value:function(e){var t,n=(v(t=e.groupAtType)||y(t)||I(t)||T()).slice(0);-1!==n.indexOf(D.CONV_AT_ME)&&-1!==n.indexOf(D.CONV_AT_ALL)&&(n=[D.CONV_AT_ALL_AT_ME]);var o={from:e.from,groupID:e.groupID,messageSequence:e.sequence,atTypeArray:n,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(o),we.debug("Conversation.updateGroupAtInfoList conversationID:".concat(this.conversationID),this.groupAtInfoList)}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence,n=e.time;return this.type===D.CONV_C2C&&t===this.lastMessage.lastSequence&&n===this.lastMessage.lastTime||this.type===D.CONV_GROUP&&t===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}},{key:"toAccount",get:function(){return this.conversationID.startsWith(D.CONV_C2C)?this.conversationID.replace(D.CONV_C2C,""):this.conversationID.startsWith(D.CONV_GROUP)?this.conversationID.replace(D.CONV_GROUP,""):""}},{key:"subType",get:function(){return this.groupProfile?this.groupProfile.type:""}}]),e}(),Or=function(){function e(n){t(this,e),this._conversationModule=n,this._className="MessageRemindHandler",this._updateSequence=0}return o(e,[{key:"getC2CMessageRemindType",value:function(){var e=this,t="".concat(this._className,".getC2CMessageRemindType");return this._conversationModule.request({protocolName:bn,updateSequence:this._updateSequence}).then((function(n){we.log("".concat(t," ok"));var o=n.data,a=o.updateSequence,s=o.muteFlagList;e._updateSequence=a,e._patchC2CMessageRemindType(s)})).catch((function(e){we.error("".concat(t," failed. error:"),e)}))}},{key:"_patchC2CMessageRemindType",value:function(e){var t=this,n=0,o="";ze(e)&&e.length>0&&e.forEach((function(e){var a=e.userID,s=e.muteFlag;0===s?o=D.MSG_REMIND_ACPT_AND_NOTE:1===s?o=D.MSG_REMIND_DISCARD:2===s&&(o=D.MSG_REMIND_ACPT_NOT_NOTE),!0===t._conversationModule.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:o})&&(n+=1)})),we.log("".concat(this._className,"._patchC2CMessageRemindType count:").concat(n))}},{key:"set",value:function(e){return e.groupID?this._setGroupMessageRemindType(e):ze(e.userIDList)?this._setC2CMessageRemindType(e):void 0}},{key:"_setGroupMessageRemindType",value:function(e){var t=this,n="".concat(this._className,"._setGroupMessageRemindType"),o=e.groupID,a=e.messageRemindType,s="groupID:".concat(o," messageRemindType:").concat(a),r=new sa(Za);return r.setMessage(s),this._getModule(en).modifyGroupMemberInfo({groupID:o,messageRemindType:a,userID:this._conversationModule.getMyUserID()}).then((function(){r.setNetworkType(t._conversationModule.getNetworkType()).end(),we.log("".concat(n," ok. ").concat(s));var e=t._getModule(Qt).getLocalGroupProfile(o);return e&&(e.selfInfo.messageRemindType=a),t._conversationModule.patchMessageRemindType({ID:o,isC2CConversation:!1,messageRemindType:a})&&t._emitConversationUpdate(),er({group:e})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];r.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"_setC2CMessageRemindType",value:function(e){var t=this,n="".concat(this._className,"._setC2CMessageRemindType"),o=e.userIDList,a=e.messageRemindType,s=o.slice(0,30),r=0;a===D.MSG_REMIND_DISCARD?r=1:a===D.MSG_REMIND_ACPT_NOT_NOTE&&(r=2);var i="userIDList:".concat(s," messageRemindType:").concat(a),c=new sa(Za);return c.setMessage(i),this._conversationModule.request({protocolName:wn,requestData:{userIDList:s,muteFlag:r}}).then((function(e){c.setNetworkType(t._conversationModule.getNetworkType()).end();var o=e.data,r=o.updateSequence,i=o.errorList;t._updateSequence=r;var u=[],l=[];ze(i)&&i.forEach((function(e){u.push(e.userID),l.push({userID:e.userID,code:e.errorCode})}));var d=s.filter((function(e){return-1===u.indexOf(e)}));we.log("".concat(n," ok. successUserIDList:").concat(d," failureUserIDList:").concat(JSON.stringify(l)));var p=0;return d.forEach((function(e){t._conversationModule.patchMessageRemindType({ID:e,isC2CConversation:!0,messageRemindType:a})&&(p+=1)})),p>=1&&t._emitConversationUpdate(),s.length=u.length=0,ur({successUserIDList:d.map((function(e){return{userID:e}})),failureUserIDList:l})})).catch((function(e){return t._conversationModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"_getModule",value:function(e){return this._conversationModule.getModule(e)}},{key:"_emitConversationUpdate",value:function(){this._conversationModule.emitConversationUpdate(!0,!1)}},{key:"setUpdateSequence",value:function(e){this._updateSequence=e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateSequence=0}}]),e}(),Lr=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="ConversationModule",fr.mixin(_(o)),o._messageListHandler=new pr,o._messageRemindHandler=new Or(_(o)),o.singlyLinkedList=new Sr(100),o._pagingStatus=qt.NOT_START,o._pagingTimeStamp=0,o._pagingStartIndex=0,o._pagingPinnedTimeStamp=0,o._pagingPinnedStartIndex=0,o._conversationMap=new Map,o._tmpGroupList=[],o._tmpGroupAtTipsList=[],o._peerReadTimeMap=new Map,o._completedMap=new Map,o._roamingMessageKeyAndTimeMap=new Map,o._remoteGroupReadSequenceMap=new Map,o._initListeners(),o}return o(a,[{key:"_initListeners",value:function(){var e=this.getInnerEmitterInstance();e.on(gr,this._initLocalConversationList,this),e.on(hr,this._onProfileUpdated,this)}},{key:"onCheckTimer",value:function(e){e%60==0&&this._messageListHandler.traversal()}},{key:"_initLocalConversationList",value:function(){var e=this,t=new sa(Ba);we.log("".concat(this._className,"._initLocalConversationList."));var n="",o=this._getStorageConversationList();if(o){for(var a=o.length,s=0;s<a;s++){var r=o[s];if(r){if(r.conversationID==="".concat(D.CONV_C2C,"@TLS#ERROR")||r.conversationID==="".concat(D.CONV_C2C,"@TLS#NOT_FOUND"))continue;if(r.groupProfile){var i=r.groupProfile.type;if(Mt(i))continue}}this._conversationMap.set(o[s].conversationID,new Rr(o[s]))}this.emitConversationUpdate(!0,!1),n="count:".concat(a)}else n="count:0";t.setNetworkType(this.getNetworkType()).setMessage(n).end(),this.getModule(Xt)||this.triggerReady(),this.ready((function(){e._tmpGroupList.length>0&&(e.updateConversationGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)})),this._syncConversationList()}},{key:"onMessageSent",value:function(e){this._onSendOrReceiveMessage({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrReceiveMessage(e)}},{key:"_onSendOrReceiveMessage",value:function(e){var t=this,n=e.conversationOptionsList,o=e.isInstantMessage,a=void 0===o||o,s=e.isUnreadC2CMessage,r=void 0!==s&&s;this._isReady?0!==n.length&&(this._getC2CPeerReadTime(n),this._updateLocalConversationList({conversationOptionsList:n,isInstantMessage:a,isUnreadC2CMessage:r,isFromGetConversations:!1}),this._setStorageConversationList(),this.emitConversationUpdate()):this.ready((function(){t._onSendOrReceiveMessage(e)}))}},{key:"updateConversationGroupProfile",value:function(e){var t=this;ze(e)&&0===e.length||(0!==this._conversationMap.size?(e.forEach((function(e){var n="GROUP".concat(e.groupID);if(t._conversationMap.has(n)){var o=t._conversationMap.get(n);o.groupProfile=JSON.parse(JSON.stringify(e)),o.lastMessage.lastSequence<e.nextMessageSeq&&(o.lastMessage.lastSequence=e.nextMessageSeq-1),o.subType||(o.subType=e.type)}})),this.emitConversationUpdate(!0,!1)):this._tmpGroupList=e)}},{key:"_updateConversationUserProfile",value:function(e){var t=this;e.data.forEach((function(e){var n="C2C".concat(e.userID);t._conversationMap.has(n)&&(t._conversationMap.get(n).userProfile=e)})),this.emitConversationUpdate(!0,!1)}},{key:"onMessageRevoked",value:function(e){var t=this;if(0!==e.length){var n=null,o=!1;e.forEach((function(e){(n=t._conversationMap.get(e.conversationID))&&(n.reduceUnreadCount(),n.isLastMessageRevoked(e)&&(o=!0,n.setLastMessageRevoked(!0)))})),o&&this.emitConversationUpdate(!0,!1)}}},{key:"onMessageDeleted",value:function(e){if(0!==e.length){e.forEach((function(e){e.isDeleted=!0}));for(var t=e[0].conversationID,n=this._messageListHandler.getLocalMessageList(t),o={},a=n.length-1;a>=0;a--)if(!n[a].isDeleted){o=n[a];break}var s=this._conversationMap.get(t);if(s){var r=!1;s.lastMessage.lastSequence===o.sequence&&s.lastMessage.lastTime===o.time||(Pt(o)&&(o=void 0),s.updateLastMessage(o),r=!0,we.log("".concat(this._className,".onMessageDeleted. update conversationID:").concat(t," with lastMessage:"),s.lastMessage)),t.startsWith(D.CONV_C2C)&&this.updateUnreadCount(t),r&&this.emitConversationUpdate(!0,!1)}}}},{key:"onNewGroupAtTips",value:function(e){var t=this,n=e.dataList,o=null;n.forEach((function(e){e.groupAtTips?o=e.groupAtTips:e.elements&&(o=e.elements),o.__random=e.random,o.__sequence=e.clientSequence,t._tmpGroupAtTipsList.push(o)})),we.debug("".concat(this._className,".onNewGroupAtTips isReady:").concat(this._isReady),this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}},{key:"_handleGroupAtTipsList",value:function(){var e=this;if(0!==this._tmpGroupAtTipsList.length){var t=!1;this._tmpGroupAtTipsList.forEach((function(n){var o=n.groupID;if(n.from!==e.getMyUserID()){var a=e._conversationMap.get("".concat(D.CONV_GROUP).concat(o));a&&(a.updateGroupAtInfoList(n),t=!0)}})),t&&this.emitConversationUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}},{key:"_getC2CPeerReadTime",value:function(e){var t=this,n=[];if(e.forEach((function(e){t._conversationMap.has(e.conversationID)||e.type!==D.CONV_C2C||n.push(e.conversationID.replace(D.CONV_C2C,""))})),n.length>0){we.debug("".concat(this._className,"._getC2CPeerReadTime userIDList:").concat(n));var o=this.getModule(Xt);o&&o.getRemotePeerReadTime(n)}}},{key:"_getStorageConversationList",value:function(){return this.getModule(on).getItem("conversationMap")}},{key:"_setStorageConversationList",value:function(){var e=this.getLocalConversationList().slice(0,20).map((function(e){return{conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}}));this.getModule(on).setItem("conversationMap",e)}},{key:"emitConversationUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=M(this._conversationMap.values());if(t){var o=this.getModule(Qt);o&&o.updateGroupLastMessage(n)}e&&this.emitOuterEvent(S.CONVERSATION_LIST_UPDATED)}},{key:"getLocalConversationList",value:function(){return M(this._conversationMap.values())}},{key:"getLocalConversation",value:function(e){return this._conversationMap.get(e)}},{key:"_syncConversationList",value:function(){var e=this,t=new sa(Ha);return this._pagingStatus===qt.NOT_START&&this._conversationMap.clear(),this._pagingGetConversationList().then((function(n){return e._pagingStatus=qt.RESOLVED,e._setStorageConversationList(),e._handleC2CPeerReadTime(),e._patchConversationProperties(),t.setMessage(e._conversationMap.size).setNetworkType(e.getNetworkType()).end(),n})).catch((function(n){return e._pagingStatus=qt.REJECTED,t.setMessage(e._pagingTimeStamp),e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];t.setError(n,a,s).end()})),lr(n)}))}},{key:"_patchConversationProperties",value:function(){var e=this,t=Date.now(),n=this.checkAndPatchRemark(),o=this._messageRemindHandler.getC2CMessageRemindType(),a=this.getModule(Qt).getGroupList();Promise.all([n,o,a]).then((function(){var n=Date.now()-t;we.log("".concat(e._className,"._patchConversationProperties ok. cost ").concat(n," ms")),e.emitConversationUpdate(!0,!1)}))}},{key:"_pagingGetConversationList",value:function(){var e=this,t="".concat(this._className,"._pagingGetConversationList");return we.log("".concat(t," timeStamp:").concat(this._pagingTimeStamp," startIndex:").concat(this._pagingStartIndex)+" pinnedTimeStamp:".concat(this._pagingPinnedTimeStamp," pinnedStartIndex:").concat(this._pagingPinnedStartIndex)),this._pagingStatus=qt.PENDING,this.request({protocolName:Vn,requestData:{fromAccount:this.getMyUserID(),timeStamp:this._pagingTimeStamp,startIndex:this._pagingStartIndex,pinnedTimeStamp:this._pagingPinnedTimeStamp,pinnedStartIndex:this._pagingStartIndex,orderType:1}}).then((function(n){var o=n.data,a=o.completeFlag,s=o.conversations,r=void 0===s?[]:s,i=o.timeStamp,c=o.startIndex,u=o.pinnedTimeStamp,l=o.pinnedStartIndex;if(we.log("".concat(t," ok. completeFlag:").concat(a," count:").concat(r.length," isReady:").concat(e._isReady)),r.length>0){var d=e._getConversationOptions(r);e._updateLocalConversationList({conversationOptionsList:d,isFromGetConversations:!0}),e.isLoggedIn()&&e.emitConversationUpdate()}if(!e._isReady){if(!e.isLoggedIn())return ur();e.triggerReady()}return e._pagingTimeStamp=i,e._pagingStartIndex=c,e._pagingPinnedTimeStamp=u,e._pagingPinnedStartIndex=l,1!==a?e._pagingGetConversationList():(e._handleGroupAtTipsList(),ur())})).catch((function(n){throw e.isLoggedIn()&&(e._isReady||(we.warn("".concat(t," failed. error:"),n),e.triggerReady())),n}))}},{key:"_updateLocalConversationList",value:function(e){var t,n=e.isFromGetConversations,o=Date.now();t=this._getTmpConversationListMapping(e),this._conversationMap=new Map(this._sortConversationList([].concat(M(t.toBeUpdatedConversationList),M(this._conversationMap)))),n||this._updateUserOrGroupProfile(t.newConversationList),we.debug("".concat(this._className,"._updateLocalConversationList cost ").concat(Date.now()-o," ms"))}},{key:"_getTmpConversationListMapping",value:function(e){for(var t=e.conversationOptionsList,n=e.isFromGetConversations,o=e.isInstantMessage,a=e.isUnreadC2CMessage,s=void 0!==a&&a,r=[],i=[],c=this.getModule(Qt),u=this.getModule(Zt),l=0,d=t.length;l<d;l++){var p=new Rr(t[l]),g=p.conversationID;if(g!=="".concat(D.CONV_C2C,"@TLS#ERROR")&&g!=="".concat(D.CONV_C2C,"@TLS#NOT_FOUND"))if(this._conversationMap.has(g)){var _=this._conversationMap.get(g),h=["unreadCount","allowType","adminForbidType","payload","isPinned"];!1===o&&h.push("lastMessage");var f=t[l].lastMessage,m=!Je(f);m||this._onLastMessageNotExist(t[l]),Je(o)&&m&&null===_.lastMessage.payload&&(_.lastMessage.payload=f.payload),st(_,p,h,[null,void 0,"",0,NaN]),_.updateUnreadCount({nextUnreadCount:p.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:s}),o&&m&&(_.lastMessage.payload=f.payload,_.type===D.CONV_GROUP&&(_.lastMessage.nameCard=f.nameCard,_.lastMessage.nick=f.nick)),m&&_.lastMessage.cloudCustomData!==f.cloudCustomData&&(_.lastMessage.cloudCustomData=f.cloudCustomData||""),this._conversationMap.delete(g),r.push([g,_])}else{if(p.type===D.CONV_GROUP&&c){var M=p.groupProfile.groupID,v=c.getLocalGroupProfile(M);v&&(p.groupProfile=v,p.updateUnreadCount({nextUnreadCount:0}))}else if(p.type===D.CONV_C2C){var y=g.replace(D.CONV_C2C,"");u&&u.isMyFriend(y)&&(p.remark=u.getFriendRemark(y))}i.push(p),r.push([g,p])}}return{toBeUpdatedConversationList:r,newConversationList:i}}},{key:"_onLastMessageNotExist",value:function(e){new sa(Us).setMessage("".concat(JSON.stringify(e))).setNetworkType(this.getNetworkType()).end()}},{key:"_sortConversationList",value:function(e){var t=[],n=[];return e.forEach((function(e){!0===e[1].isPinned?t.push(e):n.push(e)})),t.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})).concat(n.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})))}},{key:"_sortConversationListAndEmitEvent",value:function(){this._conversationMap=new Map(this._sortConversationList(M(this._conversationMap))),this.emitConversationUpdate(!0,!1)}},{key:"_updateUserOrGroupProfile",value:function(e){var t=this;if(0!==e.length){var n=[],o=[],a=this.getModule(Jt),s=this.getModule(Qt);e.forEach((function(e){if(e.type===D.CONV_C2C)n.push(e.toAccount);else if(e.type===D.CONV_GROUP){var t=e.toAccount;s.hasLocalGroup(t)?e.groupProfile=s.getLocalGroupProfile(t):o.push(t)}})),we.log("".concat(this._className,"._updateUserOrGroupProfile c2cUserIDList:").concat(n," groupIDList:").concat(o)),n.length>0&&a.getUserProfile({userIDList:n}).then((function(e){var n=e.data;ze(n)?n.forEach((function(e){t._conversationMap.get("C2C".concat(e.userID)).userProfile=e})):t._conversationMap.get("C2C".concat(n.userID)).userProfile=n})),o.length>0&&s.getGroupProfileAdvance({groupIDList:o,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var n="GROUP".concat(e.groupID);if(t._conversationMap.has(n)){var o=t._conversationMap.get(n);st(o.groupProfile,e,[],[null,void 0,"",0,NaN]),!o.subType&&e.type&&(o.subType=e.type)}}))}))}}},{key:"_getConversationOptions",value:function(e){var t=this,n=[],o=e.filter((function(e){var t=e.lastMsg;return $e(t)})).filter((function(e){var t=e.type,n=e.userID;return 1===t&&"@TLS#NOT_FOUND"!==n&&"@TLS#ERROR"!==n||2===t})).map((function(e){if(1===e.type){var o={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return n.push(o),{conversationID:"C2C".concat(e.userID),type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:""},userProfile:new Tr(o),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,messageRemindType:""}}return{conversationID:"GROUP".concat(e.groupID),type:"GROUP",lastMessage:r({lastTime:e.time,lastSequence:e.messageReadSeq+e.unreadCount,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow},t._patchTypeAndPayload(e),{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||""}),groupProfile:new Nr({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0,isPinned:1===e.isPinned,messageRemindType:""}}));n.length>0&&this.getModule(Jt).onConversationsProfileUpdated(n);return o}},{key:"_patchTypeAndPayload",value:function(e){var t=e.lastMsg,n=t.event,o=void 0===n?void 0:n,a=t.elements,s=void 0===a?[]:a,i=t.groupTips,c=void 0===i?{}:i;if(!Je(o)&&!Pt(c)){var u=new Zs(c);u.setElement({type:D.MSG_GRP_TIP,content:r({},c.elements,{groupProfile:c.groupProfile})});var l=JSON.parse(JSON.stringify(u.payload));return u=null,{type:D.MSG_GRP_TIP,payload:l}}return{type:s[0]?s[0].type:null,payload:s[0]?s[0].content:null}}},{key:"getLocalMessageList",value:function(e){return this._messageListHandler.getLocalMessageList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof Zs&&this._messageListHandler.remove(e)}},{key:"onConversationDeleted",value:function(e){var t=this;we.log("".concat(this._className,".onConversationDeleted")),ze(e)&&e.forEach((function(e){var n=e.type,o=e.userID,a=e.groupID,s="";1===n?s="".concat(D.CONV_C2C).concat(o):2===n&&(s="".concat(D.CONV_GROUP).concat(a)),t.deleteLocalConversation(s)}))}},{key:"onConversationPinned",value:function(e){var t=this;if(ze(e)){var n=!1;e.forEach((function(e){var o,a=e.type,s=e.userID,r=e.groupID;1===a?o=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(o=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),o&&(we.log("".concat(t._className,".onConversationPinned conversationID:").concat(o.conversationID," isPinned:").concat(o.isPinned)),o.isPinned||(o.isPinned=!0,n=!0))})),n&&this._sortConversationListAndEmitEvent()}}},{key:"onConversationUnpinned",value:function(e){var t=this;if(ze(e)){var n=!1;e.forEach((function(e){var o,a=e.type,s=e.userID,r=e.groupID;1===a?o=t.getLocalConversation("".concat(D.CONV_C2C).concat(s)):2===a&&(o=t.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),o&&(we.log("".concat(t._className,".onConversationUnpinned conversationID:").concat(o.conversationID," isPinned:").concat(o.isPinned)),o.isPinned&&(o.isPinned=!1,n=!0))})),n&&this._sortConversationListAndEmitEvent()}}},{key:"getMessageList",value:function(e){var t=this,n=e.conversationID,o=e.nextReqMessageID,a=e.count,s="".concat(this._className,".getMessageList"),r=this.getLocalConversation(n),i="";if(r&&r.groupProfile&&(i=r.groupProfile.type),Mt(i))return we.log("".concat(s," not available in avchatroom. conversationID:").concat(n)),ur({messageList:[],nextReqMessageID:"",isCompleted:!0});(Je(a)||a>15)&&(a=15);var c=this._computeLeftCount({conversationID:n,nextReqMessageID:o});return we.log("".concat(s," conversationID:").concat(n," leftCount:").concat(c," count:").concat(a," nextReqMessageID:").concat(o)),this._needGetHistory({conversationID:n,leftCount:c,count:a})?this.getHistoryMessages({conversationID:n,nextReqMessageID:o,count:20}).then((function(){return c=t._computeLeftCount({conversationID:n,nextReqMessageID:o}),er(t._computeResult({conversationID:n,nextReqMessageID:o,count:a,leftCount:c}))})):(we.log("".concat(s,".getMessageList get message list from memory")),this.modifyMessageList(n),ur(this._computeResult({conversationID:n,nextReqMessageID:o,count:a,leftCount:c})))}},{key:"_computeLeftCount",value:function(e){var t=e.conversationID,n=e.nextReqMessageID;return n?this._messageListHandler.getLocalMessageList(t).findIndex((function(e){return e.ID===n})):this._getMessageListSize(t)}},{key:"_getMessageListSize",value:function(e){return this._messageListHandler.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,n=e.leftCount,o=e.count,a=this.getLocalConversation(t),s="";return a&&a.groupProfile&&(s=a.groupProfile.type),!Et(t)&&!Mt(s)&&(n<o&&!this._completedMap.has(t))}},{key:"_computeResult",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,o=e.count,a=e.leftCount,s=this._computeMessageList({conversationID:t,nextReqMessageID:n,count:o}),r=this._computeIsCompleted({conversationID:t,leftCount:a,count:o}),i=this._computeNextReqMessageID({messageList:s,isCompleted:r,conversationID:t}),c="".concat(this._className,"._computeResult. conversationID:").concat(t);return we.log("".concat(c," leftCount:").concat(a," count:").concat(o," nextReqMessageID:").concat(i," isCompleted:").concat(r)),{messageList:s,nextReqMessageID:i,isCompleted:r}}},{key:"_computeMessageList",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,o=e.count,a=this._messageListHandler.getLocalMessageList(t),s=this._computeIndexEnd({nextReqMessageID:n,messageList:a}),r=this._computeIndexStart({indexEnd:s,count:o});return a.slice(r,s)}},{key:"_computeNextReqMessageID",value:function(e){var t=e.messageList,n=e.isCompleted,o=e.conversationID;if(!n)return 0===t.length?"":t[0].ID;var a=this._messageListHandler.getLocalMessageList(o);return 0===a.length?"":a[0].ID}},{key:"_computeIndexEnd",value:function(e){var t=e.messageList,n=void 0===t?[]:t,o=e.nextReqMessageID;return o?n.findIndex((function(e){return e.ID===o})):n.length}},{key:"_computeIndexStart",value:function(e){var t=e.indexEnd,n=e.count;return t>n?t-n:0}},{key:"_computeIsCompleted",value:function(e){var t=e.conversationID;return!!(e.leftCount<=e.count&&this._completedMap.has(t))}},{key:"getHistoryMessages",value:function(e){var t=e.conversationID,n=e.nextReqMessageID;if(t===D.CONV_SYSTEM)return ur();e.count?e.count>20&&(e.count=20):e.count=15;var o=this._messageListHandler.getLocalOldestMessageByConversationID(t);o||((o={}).time=0,o.sequence=0,0===t.indexOf(D.CONV_C2C)?(o.to=t.replace(D.CONV_C2C,""),o.conversationType=D.CONV_C2C):0===t.indexOf(D.CONV_GROUP)&&(o.to=t.replace(D.CONV_GROUP,""),o.conversationType=D.CONV_GROUP));var a="",s=null,r=this._roamingMessageKeyAndTimeMap.has(t);switch(o.conversationType){case D.CONV_C2C:return a=t.replace(D.CONV_C2C,""),(s=this.getModule(Xt))?s.getRoamingMessage({conversationID:e.conversationID,peerAccount:a,count:e.count,lastMessageTime:r?this._roamingMessageKeyAndTimeMap.get(t).lastMessageTime:0,messageKey:r?this._roamingMessageKeyAndTimeMap.get(t).messageKey:""}):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE});case D.CONV_GROUP:return(s=this.getModule(Qt))?s.getRoamingMessage({conversationID:e.conversationID,groupID:o.to,count:e.count,sequence:n&&!1===o._onlineOnlyFlag?o.sequence-1:o.sequence}):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE});default:return ur()}}},{key:"patchConversationLastMessage",value:function(e){var t=this.getLocalConversation(e);if(t){var n=t.lastMessage,o=n.messageForShow,a=n.payload;if(Pt(o)||Pt(a)){var s=this._messageListHandler.getLocalMessageList(e);if(0===s.length)return;var r=s[s.length-1];we.log("".concat(this._className,".patchConversationLastMessage conversationID:").concat(e," payload:"),r.payload),t.updateLastMessage(r)}}}},{key:"storeRoamingMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=t.startsWith(D.CONV_C2C)?D.CONV_C2C:D.CONV_GROUP,o=null,a=[],s=0,i=e.length,c=null,u=n===D.CONV_GROUP,l=this.getModule(rn),d=function(){s=u?e.length-1:0,i=u?0:e.length},p=function(){u?--s:++s},g=function(){return u?s>=i:s<i};for(d();g();p())if(u&&1===e[s].sequence&&this.setCompleted(t),1!==e[s].isPlaceMessage)if((o=new Zs(e[s])).to=e[s].to,o.isSystemMessage=!!e[s].isSystemMessage,o.conversationType=n,4===e[s].event?c={type:D.MSG_GRP_TIP,content:r({},e[s].elements,{groupProfile:e[s].groupProfile})}:(e[s].elements=l.parseElements(e[s].elements,e[s].from),c=e[s].elements),u||o.setNickAndAvatar({nick:e[s].nick,avatar:e[s].avatar}),Pt(c)){var _=new sa(Ga);_.setMessage("from:".concat(o.from," to:").concat(o.to," sequence:").concat(o.sequence," event:").concat(e[s].event)),_.setNetworkType(this.getNetworkType()).setLevel("warning").end()}else o.setElement(c),o.reInitialize(this.getMyUserID()),a.push(o);return this._messageListHandler.unshift(a),d=p=g=null,a}},{key:"findMessage",value:function(e){return this._messageListHandler.findMessage(e)}},{key:"setMessageRead",value:function(e){var t=e.conversationID,n=(e.messageID,this.getLocalConversation(t));if(we.log("".concat(this._className,".setMessageRead conversationID:").concat(t," unreadCount:").concat(n?n.unreadCount:0)),!n)return ur();if(n.type!==D.CONV_GROUP||Pt(n.groupAtInfoList)||this.deleteGroupAtTips(t),0===n.unreadCount)return ur();var o=this._messageListHandler.getLocalLastMessage(t),a=n.lastMessage.lastTime;o&&a<o.time&&(a=o.time);var s=n.lastMessage.lastSequence;o&&s<o.sequence&&(s=o.sequence);var r=null;switch(n.type){case D.CONV_C2C:return(r=this.getModule(Xt))?r.setMessageRead({conversationID:t,lastMessageTime:a}):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE});case D.CONV_GROUP:return(r=this._moduleManager.getModule(Qt))?r.setMessageRead({conversationID:t,lastMessageSeq:s}):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE});case D.CONV_SYSTEM:return n.unreadCount=0,this.emitConversationUpdate(!0,!1),ur();default:return ur()}}},{key:"setAllMessageRead",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n="".concat(this._className,".setAllMessageRead");t.scope||(t.scope=D.READ_ALL_MSG),we.log("".concat(n," options:"),t);var o=this._createSetAllMessageReadPack(t);if(0===o.readAllC2CMessage&&0===o.groupMessageReadInfoList.length)return ur();var a=new sa(ja);return this.request({protocolName:so,requestData:o}).then((function(n){var o=n.data,s=e._handleAllMessageRead(o);return a.setMessage("scope:".concat(t.scope," failureGroups:").concat(JSON.stringify(s))).setNetworkType(e.getNetworkType()).end(),ur()})).catch((function(t){return e.probeNetwork().then((function(e){var n=m(e,2),o=n[0],s=n[1];a.setError(t,o,s).end()})),we.warn("".concat(n," failed. error:"),t),lr({code:t&&t.code?t.code:Bo.MESSAGE_UNREAD_ALL_FAIL,message:t&&t.message?t.message:Ho.MESSAGE_UNREAD_ALL_FAIL})}))}},{key:"_getConversationLastMessageSequence",value:function(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID),n=e.lastMessage.lastSequence;return t&&n<t.sequence&&(n=t.sequence),n}},{key:"_getConversationLastMessageTime",value:function(e){var t=this._messageListHandler.getLocalLastMessage(e.conversationID),n=e.lastMessage.lastTime;return t&&n<t.time&&(n=t.time),n}},{key:"_createSetAllMessageReadPack",value:function(e){var t,n={readAllC2CMessage:0,groupMessageReadInfoList:[]},o=e.scope,a=C(this._conversationMap);try{for(a.s();!(t=a.n()).done;){var s=m(t.value,2)[1];if(s.unreadCount>0)if(s.type===D.CONV_C2C&&0===n.readAllC2CMessage){if(o===D.READ_ALL_MSG)n.readAllC2CMessage=1;else if(o===D.READ_ALL_C2C_MSG){n.readAllC2CMessage=1;break}}else if(s.type===D.CONV_GROUP&&(o===D.READ_ALL_GROUP_MSG||o===D.READ_ALL_MSG)){var r=this._getConversationLastMessageSequence(s);n.groupMessageReadInfoList.push({groupID:s.groupProfile.groupID,messageSequence:r})}}}catch(i){a.e(i)}finally{a.f()}return n}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMessageRead(e)}},{key:"_handleAllMessageRead",value:function(e){var t=e.groupMessageReadInfoList,n=e.readAllC2CMessage,o=this._parseGroupReadInfo(t);return this._updateAllConversationUnreadCount({readAllC2CMessage:n})>=1&&this.emitConversationUpdate(!0,!1),o}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var n=0,o=e.length;n<o;n++){var a=e[n],s=a.groupID,r=a.sequence,i=a.retCode,c=a.lastMessageSeq;Je(i)?this._remoteGroupReadSequenceMap.set(s,c):(this._remoteGroupReadSequenceMap.set(s,r),0!==i&&t.push("".concat(s,"-").concat(r,"-").concat(i)))}return t}},{key:"_updateAllConversationUnreadCount",value:function(e){var t,n=e.readAllC2CMessage,o=0,a=C(this._conversationMap);try{for(a.s();!(t=a.n()).done;){var s=m(t.value,2),r=s[0],i=s[1];if(i.unreadCount>=1){if(1===n&&i.type===D.CONV_C2C){var c=this._getConversationLastMessageTime(i);this.updateIsReadAfterReadReport({conversationID:r,lastMessageTime:c})}else if(i.type===D.CONV_GROUP){var u=r.replace(D.CONV_GROUP,"");if(this._remoteGroupReadSequenceMap.has(u)){var l=this._remoteGroupReadSequenceMap.get(u),d=this._getConversationLastMessageSequence(i);this.updateIsReadAfterReadReport({conversationID:r,remoteReadSequence:l}),d>=l&&this._remoteGroupReadSequenceMap.delete(u)}}this.updateUnreadCount(r,!1)&&(o+=1)}}}catch(p){a.e(p)}finally{a.f()}return o}},{key:"isRemoteRead",value:function(e){var t=e.conversationID,n=e.sequence,o=t.replace(D.CONV_GROUP,""),a=!1;if(this._remoteGroupReadSequenceMap.has(o)){var s=this._remoteGroupReadSequenceMap.get(o);n<=s&&(a=!0,we.log("".concat(this._className,".isRemoteRead conversationID:").concat(t," messageSequence:").concat(n," remoteReadSequence:").concat(s))),n>=s+10&&this._remoteGroupReadSequenceMap.delete(o)}return a}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,n=e.lastMessageSeq,o=e.lastMessageTime,a=this._messageListHandler.getLocalMessageList(t);if(0!==a.length)for(var s,r=a.length-1;r>=0;r--)if(s=a[r],!(o&&s.time>o||n&&s.sequence>n)){if("in"===s.flow&&s.isRead)break;s.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!1,o=this.getLocalConversation(e),a=this._messageListHandler.getLocalMessageList(e);if(o){var s=o.unreadCount,r=a.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;return s!==r&&(o.unreadCount=r,n=!0,we.log("".concat(this._className,".updateUnreadCount from ").concat(s," to ").concat(r,", conversationID:").concat(e)),!0===t&&this.emitConversationUpdate(!0,!1)),n}}},{key:"updateReadReceiptInfo",value:function(e,t){var n=this;if(!Pt(t)){var o=[],a="".concat(D.CONV_GROUP).concat(e);t.forEach((function(t){var s=t.tinyID,r=t.clientTime,i=t.random,c=t.readCount,u=t.unreadCount,l="".concat(s,"-").concat(r,"-").concat(i),d=n._messageListHandler.getLocalMessage(a,l),p={groupID:e,messageID:l,readCount:0,unreadCount:0};d&&(je(c)&&(d.readReceiptInfo.readCount=c,p.readCount=c),je(u)&&(d.readReceiptInfo.unreadCount=u,p.unreadCount=u),o.push(p))})),o.length>0&&this.emitOuterEvent(S.MESSAGE_READ_RECEIPT_RECEIVED,o)}}},{key:"recomputeGroupUnreadCount",value:function(e){var t=e.conversationID,n=e.count,o=this.getLocalConversation(t);if(o){var a=o.unreadCount,s=a-n;s<0&&(s=0),o.unreadCount=s,we.log("".concat(this._className,".recomputeGroupUnreadCount from ").concat(a," to ").concat(s,", conversationID:").concat(t))}}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),n=this.getLocalMessageList(e);if(t&&0!==n.length&&!Et(t.type)){for(var o=[],a=0,s=n.length;a<s;a++)"in"!==n[a].flow?"out"!==n[a].flow||n[a].isRead||n[a].setIsRead(!0):o.push(n[a]);var r=0;if(t.type===D.CONV_C2C){var i=o.slice(-t.unreadCount).filter((function(e){return e.isRevoked})).length;r=o.length-t.unreadCount-i}else r=o.length-t.unreadCount;for(var c=0;c<r&&!o[c].isRead;c++)o[c].setIsRead(!0)}}},{key:"deleteGroupAtTips",value:function(e){var t="".concat(this._className,".deleteGroupAtTips");we.log("".concat(t));var n=this._conversationMap.get(e);if(!n)return Promise.resolve();var o=n.groupAtInfoList;if(0===o.length)return Promise.resolve();var a=this.getMyUserID();return this.request({protocolName:Hn,requestData:{messageListToDelete:o.map((function(e){return{from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:e.groupID}}))}}).then((function(){return we.log("".concat(t," ok. count:").concat(o.length)),n.clearGroupAtInfoList(),Promise.resolve()})).catch((function(e){return we.error("".concat(t," failed. error:"),e),lr(e)}))}},{key:"appendToMessageList",value:function(e){this._messageListHandler.pushIn(e)}},{key:"setMessageRandom",value:function(e){this.singlyLinkedList.set(e.random)}},{key:"deleteMessageRandom",value:function(e){this.singlyLinkedList.delete(e.random)}},{key:"pushIntoMessageList",value:function(e,t,n){return!(!this._messageListHandler.pushIn(t,n)||this._isMessageFromCurrentInstance(t)&&!n)&&(e.push(t),!0)}},{key:"_isMessageFromCurrentInstance",value:function(e){return this.singlyLinkedList.has(e.random)}},{key:"revoke",value:function(e,t,n){return this._messageListHandler.revoke(e,t,n)}},{key:"getPeerReadTime",value:function(e){return this._peerReadTimeMap.get(e)}},{key:"recordPeerReadTime",value:function(e,t){this._peerReadTimeMap.has(e)?this._peerReadTimeMap.get(e)<t&&this._peerReadTimeMap.set(e,t):this._peerReadTimeMap.set(e,t)}},{key:"updateMessageIsPeerReadProperty",value:function(e,t){if(e.startsWith(D.CONV_C2C)&&t>0){var n=this._messageListHandler.updateMessageIsPeerReadProperty(e,t);n.length>0&&this.emitOuterEvent(S.MESSAGE_READ_BY_PEER,n)}}},{key:"updateMessageIsModifiedProperty",value:function(e){this._messageListHandler.updateMessageIsModifiedProperty(e)}},{key:"setCompleted",value:function(e){we.log("".concat(this._className,".setCompleted. conversationID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMessageKeyAndTime",value:function(e,t,n){this._roamingMessageKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:n})}},{key:"getConversationList",value:function(e){var t=this,n="".concat(this._className,".getConversationList"),o="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._conversationMap.size,", options:").concat(e);if(we.log("".concat(n,". ").concat(o)),this._pagingStatus===qt.REJECTED){var a=new sa(qa);return a.setMessage(o),this._syncConversationList().then((function(){a.setNetworkType(t.getNetworkType()).end();var n=t._getConversationList(e);return er({conversationList:n})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],s=n[1];a.setError(e,o,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}if(0===this._conversationMap.size){var s=new sa(qa);return s.setMessage(o),this._syncConversationList().then((function(){s.setNetworkType(t.getNetworkType()).end();var n=t._getConversationList(e);return er({conversationList:n})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}var r=this._getConversationList(e);return we.log("".concat(n,". returned conversation count:").concat(r.length)),ur({conversationList:r})}},{key:"_getConversationList",value:function(e){var t=this;if(Je(e))return this.getLocalConversationList();if(ze(e)){var n=[];return e.forEach((function(e){if(t._conversationMap.has(e)){var o=t.getLocalConversation(e);n.push(o)}})),n}}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=C(this._conversationMap);try{for(t.s();!(e=t.n()).done;){var n=m(e.value,2),o=n[0],a=n[1];a.type===D.CONV_C2C&&(we.debug("".concat(this._className,"._handleC2CPeerReadTime conversationID:").concat(o," peerReadTime:").concat(a.peerReadTime)),this.recordPeerReadTime(o,a.peerReadTime))}}catch(s){t.e(s)}finally{t.f()}}},{key:"getConversationProfile",value:function(e){var t,n=this;if((t=this._conversationMap.has(e)?this._conversationMap.get(e):new Rr({conversationID:e,type:e.slice(0,3)===D.CONV_C2C?D.CONV_C2C:D.CONV_GROUP}))._isInfoCompleted||t.type===D.CONV_SYSTEM)return ur({conversation:t});var o=new sa(Va),a="".concat(this._className,".getConversationProfile");return we.log("".concat(a,". conversationID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._updateUserOrGroupProfileCompletely(t).then((function(s){o.setNetworkType(n.getNetworkType()).setMessage("conversationID:".concat(e," unreadCount:").concat(s.data.conversation.unreadCount)).end();var r=n.getModule(Zt);if(r&&t.type===D.CONV_C2C){var i=e.replace(D.CONV_C2C,"");if(r.isMyFriend(i)){var c=r.getFriendRemark(i);t.remark!==c&&(t.remark=c,we.log("".concat(a,". conversationID:").concat(e," patch remark:").concat(t.remark)))}}return we.log("".concat(a," ok. conversationID:").concat(e)),s})).catch((function(t){return n.probeNetwork().then((function(n){var a=m(n,2),s=a[0],r=a[1];o.setError(t,s,r).setMessage("conversationID:".concat(e)).end()})),we.error("".concat(a," failed. error:"),t),lr(t)}))}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var t=this;return e.type===D.CONV_C2C?this.getModule(Jt).getUserProfile({userIDList:[e.toAccount]}).then((function(n){var o=n.data;return 0===o.length?lr(new rr({code:Bo.USER_OR_GROUP_NOT_FOUND,message:Ho.USER_OR_GROUP_NOT_FOUND})):(e.userProfile=o[0],e._isInfoCompleted=!0,t._unshiftConversation(e),ur({conversation:e}))})):this.getModule(Qt).getGroupProfile({groupID:e.toAccount}).then((function(n){return e.groupProfile=n.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),ur({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof Rr&&!this._conversationMap.has(e.conversationID)&&(this._conversationMap=new Map([[e.conversationID,e]].concat(M(this._conversationMap))),this._setStorageConversationList(),this.emitConversationUpdate(!0,!1))}},{key:"_onProfileUpdated",value:function(e){var t=this;e.data.forEach((function(e){var n=e.userID;if(n===t.getMyUserID())t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar});else{var o=t._conversationMap.get("".concat(D.CONV_C2C).concat(n));o&&(o.userProfile=e)}}))}},{key:"deleteConversation",value:function(e){var t=this,n={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0};if(!this._conversationMap.has(e)){var o=new rr({code:Bo.CONVERSATION_NOT_FOUND,message:Ho.CONVERSATION_NOT_FOUND});return lr(o)}switch(this._conversationMap.get(e).type){case D.CONV_C2C:n.type=1,n.toAccount=e.replace(D.CONV_C2C,"");break;case D.CONV_GROUP:n.type=2,n.toGroupID=e.replace(D.CONV_GROUP,"");break;case D.CONV_SYSTEM:return this.getModule(Qt).deleteGroupSystemNotice({messageList:this._messageListHandler.getLocalMessageList(e)}),this.deleteLocalConversation(e),ur({conversationID:e});default:var a=new rr({code:Bo.CONVERSATION_UN_RECORDED_TYPE,message:Ho.CONVERSATION_UN_RECORDED_TYPE});return lr(a)}var s=new sa(Ka);s.setMessage("conversationID:".concat(e));var r="".concat(this._className,".deleteConversation");return we.log("".concat(r,". conversationID:").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.request({protocolName:xn,requestData:n})})).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(r," ok")),t.deleteLocalConversation(e),ur({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.error("".concat(r," failed. error:"),e),lr(e)}))}},{key:"pinConversation",value:function(e){var t=this,n=e.conversationID,o=e.isPinned;if(!this._conversationMap.has(n))return lr({code:Bo.CONVERSATION_NOT_FOUND,message:Ho.CONVERSATION_NOT_FOUND});var a=this.getLocalConversation(n);if(a.isPinned===o)return ur({conversationID:n});var s=new sa(xa);s.setMessage("conversationID:".concat(n," isPinned:").concat(o));var r="".concat(this._className,".pinConversation");we.log("".concat(r,". conversationID:").concat(n," isPinned:").concat(o));var i=null;return yt(n)?i={type:1,toAccount:n.replace(D.CONV_C2C,"")}:It(n)&&(i={type:2,groupID:n.replace(D.CONV_GROUP,"")}),this.request({protocolName:Bn,requestData:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[i]}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(r," ok")),a.isPinned!==o&&(a.isPinned=o,t._sortConversationListAndEmitEvent()),er({conversationID:n})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.error("".concat(r," failed. error:"),e),lr(e)}))}},{key:"setMessageRemindType",value:function(e){return this._messageRemindHandler.set(e)}},{key:"patchMessageRemindType",value:function(e){var t=e.ID,n=e.isC2CConversation,o=e.messageRemindType,a=!1,s=this.getLocalConversation(n?"".concat(D.CONV_C2C).concat(t):"".concat(D.CONV_GROUP).concat(t));return s&&s.messageRemindType!==o&&(s.messageRemindType=o,a=!0),a}},{key:"onC2CMessageRemindTypeSynced",value:function(e){var t=this;we.debug("".concat(this._className,".onC2CMessageRemindTypeSynced options:"),e),e.dataList.forEach((function(e){if(!Pt(e.muteNotificationsSync)){var n,o=e.muteNotificationsSync,a=o.to,s=o.updateSequence,r=o.muteFlag;t._messageRemindHandler.setUpdateSequence(s),0===r?n=D.MSG_REMIND_ACPT_AND_NOTE:1===r?n=D.MSG_REMIND_DISCARD:2===r&&(n=D.MSG_REMIND_ACPT_NOT_NOTE);var i=0;t.patchMessageRemindType({ID:a,isC2CConversation:!0,messageRemindType:n})&&(i+=1),we.log("".concat(t._className,".onC2CMessageRemindTypeSynced updateCount:").concat(i)),i>=1&&t.emitConversationUpdate(!0,!1)}}))}},{key:"deleteLocalConversation",value:function(e){var t=this._conversationMap.has(e);we.log("".concat(this._className,".deleteLocalConversation conversationID:").concat(e," has:").concat(t)),t&&(this._conversationMap.delete(e),this._roamingMessageKeyAndTimeMap.delete(e),this._setStorageConversationList(),this._messageListHandler.removeByConversationID(e),this._completedMap.delete(e),this.emitConversationUpdate(!0,!1))}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._messageListHandler.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:"modifyMessageList",value:function(e){if(e.startsWith(D.CONV_C2C)&&this._conversationMap.has(e)){var t=this._conversationMap.get(e),n=Date.now();this._messageListHandler.modifyMessageSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var o=this.getModule(Jt).getNickAndAvatarByUserID(this.getMyUserID());this._messageListHandler.modifyMessageSentByMe({conversationID:e,latestNick:o.nick,latestAvatar:o.avatar}),we.log("".concat(this._className,".modifyMessageList conversationID:").concat(e," cost ").concat(Date.now()-n," ms"))}}},{key:"updateUserProfileSpecifiedKey",value:function(e){we.log("".concat(this._className,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,n=e.nick,o=e.avatar;if(this._conversationMap.has(t)){var a=this._conversationMap.get(t).userProfile;We(n)&&a.nick!==n&&(a.nick=n),We(o)&&a.avatar!==o&&(a.avatar=o),this.emitConversationUpdate(!0,!1)}}},{key:"_onMyProfileModified",value:function(e){var t=this,n=this.getLocalConversationList(),o=Date.now();n.forEach((function(n){t.modifyMessageSentByMe(r({conversationID:n.conversationID},e))})),we.log("".concat(this._className,"._onMyProfileModified. modify all messages sent by me, cost ").concat(Date.now()-o," ms"))}},{key:"modifyMessageSentByMe",value:function(e){this._messageListHandler.modifyMessageSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._messageListHandler.getLatestMessageSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._messageListHandler.modifyMessageSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._messageListHandler.getLatestMessageSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._messageListHandler.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:"getGroupLocalLastMessageSequence",value:function(e){return this._messageListHandler.getGroupLocalLastMessageSequence(e)}},{key:"checkAndPatchRemark",value:function(){var e=Promise.resolve();if(0===this._conversationMap.size)return e;var t=this.getModule(Zt);if(!t)return e;var n=M(this._conversationMap.values()).filter((function(e){return e.type===D.CONV_C2C}));if(0===n.length)return e;var o=0;return n.forEach((function(e){var n=e.conversationID.replace(D.CONV_C2C,"");if(t.isMyFriend(n)){var a=t.getFriendRemark(n);e.remark!==a&&(e.remark=a,o+=1)}})),we.log("".concat(this._className,".checkAndPatchRemark. c2c conversation count:").concat(n.length,", patched count:").concat(o)),e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._pagingStatus=qt.NOT_START,this._messageListHandler.reset(),this._messageRemindHandler.reset(),this._roamingMessageKeyAndTimeMap.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.resetReady()}}]),a}(vn),Gr=function(){function e(n){t(this,e),this._groupModule=n,this._className="GroupTipsHandler",this._cachedGroupTipsMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4}return o(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupTipsMap.size>0&&this._checkCachedGroupTips()}},{key:"_checkCachedGroupTips",value:function(){var e=this;this._cachedGroupTipsMap.forEach((function(t,n){var o=e._checkCountMap.get(n),a=e._groupModule.hasLocalGroup(n);we.log("".concat(e._className,"._checkCachedGroupTips groupID:").concat(n," hasLocalGroup:").concat(a," checkCount:").concat(o)),a?(e._notifyCachedGroupTips(n),e._checkCountMap.delete(n),e._groupModule.deleteUnjoinedAVChatRoom(n)):o>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupTips(n),e._checkCountMap.delete(n)):(o++,e._checkCountMap.set(n,o))}))}},{key:"onNewGroupTips",value:function(e){we.debug("".concat(this._className,".onReceiveGroupTips count:").concat(e.dataList.length));var t=this.newGroupTipsStoredAndSummary(e),n=t.eventDataList,o=t.result,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),n.length>0)&&(this._groupModule.getModule(tn).onNewMessage({conversationOptionsList:n,isInstantMessage:!0}),this._groupModule.updateNextMessageSeq(n));o.length>0&&(this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,o),this.handleMessageList(o))}},{key:"newGroupTipsStoredAndSummary",value:function(e){for(var t=e.event,n=e.dataList,o=null,a=[],s=[],i={},c=[],u=0,l=n.length;u<l;u++){var d=n[u],p=d.groupProfile.groupID,g=this._groupModule.hasLocalGroup(p);if(g||!this._groupModule.isUnjoinedAVChatRoom(p))if(g)if(this._groupModule.isMessageFromOrToAVChatroom(p)){var _=ht(d);_.event=t,c.push(_)}else{d.currentUser=this._groupModule.getMyUserID(),d.conversationType=D.CONV_GROUP,(o=new Zs(d)).setElement({type:D.MSG_GRP_TIP,content:r({},d.elements,{groupProfile:d.groupProfile})}),o.isSystemMessage=!1;var h=this._groupModule.getModule(tn),f=o,m=f.conversationID,M=f.sequence;if(6===t)o._onlineOnlyFlag=!0,s.push(o);else if(!h.pushIntoNoticeResult(s,o))continue;if(6!==t||!h.getLocalConversation(m)){if(6!==t)this._groupModule.getModule(mn).addMessageSequence({key:Qo,message:o});var v=h.isRemoteRead({conversationID:m,sequence:M});if(Je(i[m]))i[m]=a.push({conversationID:m,unreadCount:"in"!==o.flow||o._onlineOnlyFlag||v?0:1,type:o.conversationType,subType:o.conversationSubType,lastMessage:o})-1;else{var y=i[m];a[y].type=o.conversationType,a[y].subType=o.conversationSubType,a[y].lastMessage=o,"in"!==o.flow||o._onlineOnlyFlag||v||a[y].unreadCount++}}}else this._cacheGroupTipsAndProbe({groupID:p,event:t,item:d})}return{eventDataList:a,result:s,AVChatRoomMessageList:c}}},{key:"handleMessageList",value:function(e){var t=this;e.forEach((function(e){switch(e.payload.operationType){case 1:t._onNewMemberComeIn(e);break;case 2:t._onMemberQuit(e);break;case 3:t._onMemberKickedOut(e);break;case 4:t._onMemberSetAdmin(e);break;case 5:t._onMemberCancelledAdmin(e);break;case 6:t._onGroupProfileModified(e);break;case 7:t._onMemberInfoModified(e);break;default:we.warn("".concat(t._className,".handleMessageList unknown operationType:").concat(e.payload.operationType))}}))}},{key:"_onNewMemberComeIn",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,a=this._groupModule.getLocalGroupProfile(o);a&&je(n)&&a.memberCount!==n&&(a.memberCount=n,this._updateConversationGroupProfile(a))}},{key:"_onMemberQuit",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,a=this._groupModule.getLocalGroupProfile(o);a&&je(n)&&a.memberCount!==n&&(a.memberCount=n,this._updateConversationGroupProfile(a)),this._groupModule.getModule(en).deleteLocalGroupMembers(o,e.payload.userIDList)}},{key:"_onMemberKickedOut",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,a=this._groupModule.getLocalGroupProfile(o);a&&je(n)&&a.memberCount!==n&&(a.memberCount=n,this._updateConversationGroupProfile(a)),this._groupModule.getModule(en).deleteLocalGroupMembers(o,e.payload.userIDList)}},{key:"_updateConversationGroupProfile",value:function(e){this._groupModule.getModule(tn).updateConversationGroupProfile([e])}},{key:"_onMemberSetAdmin",value:function(e){var t=e.payload.groupProfile.groupID,n=e.payload.userIDList,o=this._groupModule.getModule(en);n.forEach((function(e){var n=o.getLocalGroupMemberInfo(t,e);n&&n.updateRole(D.GRP_MBR_ROLE_ADMIN)}))}},{key:"_onMemberCancelledAdmin",value:function(e){var t=e.payload.groupProfile.groupID,n=e.payload.userIDList,o=this._groupModule.getModule(en);n.forEach((function(e){var n=o.getLocalGroupMemberInfo(t,e);n&&n.updateRole(D.GRP_MBR_ROLE_MEMBER)}))}},{key:"_onGroupProfileModified",value:function(e){var t=this,n=e.payload,o=n.newGroupProfile,a=n.groupProfile.groupID,s=this._groupModule.getLocalGroupProfile(a);Object.keys(o).forEach((function(e){switch(e){case"ownerID":t._ownerChanged(s,o);break;default:s[e]=o[e]}})),this._groupModule.emitGroupListUpdate(!0,!0)}},{key:"_ownerChanged",value:function(e,t){var n=e.groupID,o=this._groupModule.getLocalGroupProfile(n),a=this._groupModule.getMyUserID();if(a===t.ownerID){o.updateGroup({selfInfo:{role:D.GRP_MBR_ROLE_OWNER}});var s=this._groupModule.getModule(en),r=s.getLocalGroupMemberInfo(n,a),i=this._groupModule.getLocalGroupProfile(n).ownerID,c=s.getLocalGroupMemberInfo(n,i);r&&r.updateRole(D.GRP_MBR_ROLE_OWNER),c&&c.updateRole(D.GRP_MBR_ROLE_MEMBER)}}},{key:"_onMemberInfoModified",value:function(e){var t=e.payload.groupProfile.groupID,n=this._groupModule.getModule(en);e.payload.memberList.forEach((function(e){var o=n.getLocalGroupMemberInfo(t,e.userID);o&&je(e.muteTime)&&o.updateMuteUntil(e.muteTime)}))}},{key:"_cacheGroupTips",value:function(e,t){this._cachedGroupTipsMap.has(e)||this._cachedGroupTipsMap.set(e,[]),this._cachedGroupTipsMap.get(e).push(t)}},{key:"_deleteCachedGroupTips",value:function(e){this._cachedGroupTipsMap.has(e)&&this._cachedGroupTipsMap.delete(e)}},{key:"_notifyCachedGroupTips",value:function(e){var t=this,n=this._cachedGroupTipsMap.get(e)||[];n.forEach((function(e){t.onNewGroupTips(e)})),this._deleteCachedGroupTips(e),we.log("".concat(this._className,"._notifyCachedGroupTips groupID:").concat(e," count:").concat(n.length))}},{key:"_cacheGroupTipsAndProbe",value:function(e){var t=this,n=e.groupID,o=e.event,a=e.item;this._cacheGroupTips(n,{event:o,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(n).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(n)?t._notifyCachedGroupTips(n):t._groupModule.setUnjoinedAVChatRoom(n):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupTips(n))})),this._checkCountMap.has(n)||this._checkCountMap.set(n,0),we.log("".concat(this._className,"._cacheGroupTipsAndProbe groupID:").concat(n))}},{key:"reset",value:function(){this._cachedGroupTipsMap.clear(),this._checkCountMap.clear()}}]),e}(),Pr=function(){function e(n){t(this,e),this._groupModule=n,this._className="CommonGroupHandler",this.tempConversationList=null,this._cachedGroupMessageMap=new Map,this._checkCountMap=new Map,this.MAX_CHECK_COUNT=4,n.getInnerEmitterInstance().once(gr,this._initGroupList,this)}return o(e,[{key:"onCheckTimer",value:function(e){e%1==0&&this._cachedGroupMessageMap.size>0&&this._checkCachedGroupMessage()}},{key:"_checkCachedGroupMessage",value:function(){var e=this;this._cachedGroupMessageMap.forEach((function(t,n){var o=e._checkCountMap.get(n),a=e._groupModule.hasLocalGroup(n);we.log("".concat(e._className,"._checkCachedGroupMessage groupID:").concat(n," hasLocalGroup:").concat(a," checkCount:").concat(o)),a?(e._notifyCachedGroupMessage(n),e._checkCountMap.delete(n),e._groupModule.deleteUnjoinedAVChatRoom(n)):o>=e.MAX_CHECK_COUNT?(e._deleteCachedGroupMessage(n),e._checkCountMap.delete(n)):(o++,e._checkCountMap.set(n,o))}))}},{key:"_initGroupList",value:function(){var e=this;we.log("".concat(this._className,"._initGroupList"));var t=new sa(as),n=this._groupModule.getStorageGroupList();if(ze(n)&&n.length>0){n.forEach((function(t){e._groupModule.initGroupMap(t)})),this._groupModule.emitGroupListUpdate(!0,!1);var o=this._groupModule.getLocalGroupList().length;t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:".concat(o)).end()}else t.setNetworkType(this._groupModule.getNetworkType()).setMessage("group count:0").end();we.log("".concat(this._className,"._initGroupList ok"))}},{key:"handleUpdateGroupLastMessage",value:function(e){var t="".concat(this._className,".handleUpdateGroupLastMessage");if(we.debug("".concat(t," conversation count:").concat(e.length,", local group count:").concat(this._groupModule.getLocalGroupList().length)),0!==this._groupModule.getGroupMap().size){for(var n,o,a,s=!1,r=0,i=e.length;r<i;r++)(n=e[r]).type===D.CONV_GROUP&&(o=n.conversationID.split(/^GROUP/)[1],(a=this._groupModule.getLocalGroupProfile(o))&&(a.lastMessage=n.lastMessage,s=!0));s&&(this._groupModule.sortLocalGroupList(),this._groupModule.emitGroupListUpdate(!0,!1))}else this.tempConversationList=e}},{key:"onNewGroupMessage",value:function(e){we.debug("".concat(this._className,".onNewGroupMessage count:").concat(e.dataList.length));var t=this._newGroupMessageStoredAndSummary(e),n=t.conversationOptionsList,o=t.messageList,a=t.AVChatRoomMessageList;(a.length>0&&this._groupModule.onAVChatRoomMessage(a),this._groupModule.filterModifiedMessage(o),n.length>0)&&(this._groupModule.getModule(tn).onNewMessage({conversationOptionsList:n,isInstantMessage:!0}),this._groupModule.updateNextMessageSeq(n));var s=this._groupModule.filterUnmodifiedMessage(o);s.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,s),o.length=0}},{key:"_newGroupMessageStoredAndSummary",value:function(e){var t=e.dataList,n=e.event,o=e.isInstantMessage,a=null,s=[],r=[],i=[],c={},u=D.CONV_GROUP,l=this._groupModule.getModule(rn),d=this._groupModule.getModule(mn),p=t.length;p>1&&t.sort((function(e,t){return e.sequence-t.sequence}));for(var g=0;g<p;g++){var _=t[g],h=_.groupProfile.groupID,f=this._groupModule.hasLocalGroup(h);if(f||!this._groupModule.isUnjoinedAVChatRoom(h))if(f)if(this._groupModule.isMessageFromOrToAVChatroom(h)){var m=ht(_);m.event=n,i.push(m)}else{_.currentUser=this._groupModule.getMyUserID(),_.conversationType=u,_.isSystemMessage=!!_.isSystemMessage,a=new Zs(_),_.elements=l.parseElements(_.elements,_.from),a.setElement(_.elements);var M=1===t[g].isModified,v=this._groupModule.getModule(tn);if(v.isMessageSentByCurrentInstance(a)?a.isModified=M:M=!1,1===_.onlineOnlyFlag)a._onlineOnlyFlag=!0,r.push(a);else{if(!v.pushIntoMessageList(r,a,M))continue;d.addMessageSequence({key:Qo,message:a}),o&&a.clientTime>0&&d.addMessageDelay(a.clientTime);var y=a,I=y.conversationID,E=y.sequence,T=v.isRemoteRead({conversationID:I,sequence:E});if(Je(c[I])){var C=0;"in"===a.flow&&(a._isExcludedFromUnreadCount||T||(C=1)),c[I]=s.push({conversationID:I,unreadCount:C,type:a.conversationType,subType:a.conversationSubType,lastMessage:a._isExcludedFromLastMessage?"":a})-1}else{var S=c[I];s[S].type=a.conversationType,s[S].subType=a.conversationSubType,s[S].lastMessage=a._isExcludedFromLastMessage?"":a,"in"===a.flow&&(a._isExcludedFromUnreadCount||T||s[S].unreadCount++)}}}else this._cacheGroupMessageAndProbe({groupID:h,event:n,item:_})}return{conversationOptionsList:s,messageList:r,AVChatRoomMessageList:i}}},{key:"onGroupMessageRevoked",value:function(e){we.debug("".concat(this._className,".onGroupMessageRevoked nums:").concat(e.dataList.length));var t=this._groupModule.getModule(tn),n=[],o=null;e.dataList.forEach((function(e){var a=e.elements.revokedInfos;Je(a)||a.forEach((function(e){(o=t.revoke("GROUP".concat(e.groupID),e.sequence,e.random))&&n.push(o)}))})),0!==n.length&&(t.onMessageRevoked(n),this._groupModule.emitOuterEvent(S.MESSAGE_REVOKED,n))}},{key:"_groupListTreeShaking",value:function(e){for(var t=new Map(M(this._groupModule.getGroupMap())),n=0,o=e.length;n<o;n++)t.delete(e[n].groupID);this._groupModule.hasJoinedAVChatRoom()&&this._groupModule.getJoinedAVChatRoom().forEach((function(e){t.delete(e)}));for(var a=M(t.keys()),s=0,r=a.length;s<r;s++)this._groupModule.deleteGroup(a[s])}},{key:"getGroupList",value:function(e){var t=this,n="".concat(this._className,".getGroupList"),o=new sa(ns);we.log("".concat(n));var a={introduction:"Introduction",notification:"Notification",createTime:"CreateTime",ownerID:"Owner_Account",lastInfoTime:"LastInfoTime",memberNum:"MemberNum",maxMemberNum:"MaxMemberNum",joinOption:"ApplyJoinOption",muteAllMembers:"ShutUpAllMember"},s=["Type","Name","FaceUrl","NextMsgSeq","LastMsgTime"],r=[];return e&&e.groupProfileFilter&&e.groupProfileFilter.forEach((function(e){a[e]&&s.push(a[e])})),this._pagingGetGroupList({limit:50,offset:0,groupBaseInfoFilter:s,groupList:r}).then((function(){we.log("".concat(n," ok. count:").concat(r.length)),t._groupListTreeShaking(r),t._groupModule.updateGroupMap(r);var e=t._groupModule.getLocalGroupList().length;return o.setNetworkType(t._groupModule.getNetworkType()).setMessage("remote count:".concat(r.length,", after tree shaking, local count:").concat(e)).end(),t.tempConversationList&&(we.log("".concat(n," update last message with tempConversationList, count:").concat(t.tempConversationList.length)),t.handleUpdateGroupLastMessage({data:t.tempConversationList}),t.tempConversationList=null),t._groupModule.emitGroupListUpdate(),t._groupModule.patchGroupMessageRemindType(),t._groupModule.recomputeUnreadCount(),er({groupList:t._groupModule.getLocalGroupList()})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"_pagingGetGroupList",value:function(e){var t=this,n="".concat(this._className,"._pagingGetGroupList"),o=e.isCommunityRelay,a=void 0!==o&&o,s=e.limit,r=e.offset,i=e.groupBaseInfoFilter,c=e.groupList,u=new sa(is);return this._groupModule.request({protocolName:jn,requestData:{type:a?D.GRP_COMMUNITY:void 0,memberAccount:this._groupModule.getMyUserID(),limit:s,offset:r,responseFilter:{groupBaseInfoFilter:i,selfInfoFilter:["Role","JoinTime","MsgFlag","MsgSeq"]}}}).then((function(e){var o=e.data,l=o.groups,d=void 0===l?[]:l,p=o.totalCount;c.push.apply(c,M(d));var g=r+s,_=!(p>g),h="offset:".concat(r," totalCount:").concat(p," isCompleted:").concat(_," ")+"currentCount:".concat(c.length," isCommunityRelay:").concat(a);return u.setNetworkType(t._groupModule.getNetworkType()).setMessage("".concat(h)).end(),a||_?!a&&_?(we.log("".concat(n," start to get community list")),r=0,t._pagingGetGroupList({limit:s,offset:r,groupBaseInfoFilter:i,groupList:c,isCommunityRelay:!0})):a&&!_?(r=g,t._pagingGetGroupList({limit:s,offset:r,groupBaseInfoFilter:i,groupList:c,isCommunityRelay:!0})):(we.log("".concat(n," ok. totalCount:").concat(c.length)),er({groupList:c})):(r=g,t._pagingGetGroupList({limit:s,offset:r,groupBaseInfoFilter:i,groupList:c}))})).catch((function(e){return 11e3!==e.code&&t._groupModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],s=n[1];u.setMessage("isCommunityRelay:".concat(a)).setError(e,o,s).end()})),a?(11e3===e.code&&(u=null,we.log("".concat(n," ok. community unavailable"))),ur({groupList:c})):lr(e)}))}},{key:"_cacheGroupMessage",value:function(e,t){this._cachedGroupMessageMap.has(e)||this._cachedGroupMessageMap.set(e,[]),this._cachedGroupMessageMap.get(e).push(t)}},{key:"_deleteCachedGroupMessage",value:function(e){this._cachedGroupMessageMap.has(e)&&this._cachedGroupMessageMap.delete(e)}},{key:"_notifyCachedGroupMessage",value:function(e){var t=this,n=this._cachedGroupMessageMap.get(e)||[];n.forEach((function(e){t.onNewGroupMessage(e)})),this._deleteCachedGroupMessage(e),we.log("".concat(this._className,"._notifyCachedGroupMessage groupID:").concat(e," count:").concat(n.length))}},{key:"_cacheGroupMessageAndProbe",value:function(e){var t=this,n=e.groupID,o=e.event,a=e.item;this._cacheGroupMessage(n,{event:o,dataList:[a]}),this._groupModule.getGroupSimplifiedInfo(n).then((function(e){e.type===D.GRP_AVCHATROOM?t._groupModule.hasLocalGroup(n)?t._notifyCachedGroupMessage(n):t._groupModule.setUnjoinedAVChatRoom(n):(t._groupModule.updateGroupMap([e]),t._notifyCachedGroupMessage(n))})),this._checkCountMap.has(n)||this._checkCountMap.set(n,0),we.log("".concat(this._className,"._cacheGroupMessageAndProbe groupID:").concat(n))}},{key:"reset",value:function(){this._cachedGroupMessageMap.clear(),this._checkCountMap.clear(),this._groupModule.getInnerEmitterInstance().once(gr,this._initGroupList,this)}}]),e}(),wr={1:"init",2:"modify",3:"clear",4:"delete"},br=function(){function e(n){t(this,e),this._groupModule=n,this._className="GroupAttributesHandler",this._groupAttributesMap=new Map,this.CACHE_EXPIRE_TIME=3e4,this._groupModule.getInnerEmitterInstance().on(_r,this._onCloudConfigUpdated,this)}return o(e,[{key:"_onCloudConfigUpdated",value:function(){var e=this._groupModule.getCloudConfig("grp_attr_cache_time");Je(e)||(this.CACHE_EXPIRE_TIME=Number(e))}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesMap.forEach((function(e){e.localMainSequence=0}))}},{key:"onGroupAttributesUpdated",value:function(e){var t=this,n=e.groupID,o=e.groupAttributeOption,a=o.mainSequence,s=o.hasChangedAttributeInfo,r=o.groupAttributeList,i=void 0===r?[]:r,c=o.operationType;if(we.log("".concat(this._className,".onGroupAttributesUpdated. hasChangedAttributeInfo:").concat(s," operationType:").concat(c)),!Je(c)){if(1===s){if(4===c){var u=[];i.forEach((function(e){u.push(e.key)})),i=M(u),u=null}return this._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:a,groupAttributeList:i,operationType:wr[c]}),void this._emitGroupAttributesUpdated(n)}if(this._groupAttributesMap.has(n)){var l=this._groupAttributesMap.get(n).avChatRoomKey;this._getGroupAttributes({groupID:n,avChatRoomKey:l}).then((function(){t._emitGroupAttributesUpdated(n)}))}}}},{key:"initGroupAttributesCache",value:function(e){var t=e.groupID,n=e.avChatRoomKey;this._groupAttributesMap.set(t,{lastUpdateTime:0,localMainSequence:0,remoteMainSequence:0,attributes:new Map,avChatRoomKey:n}),we.log("".concat(this._className,".initGroupAttributesCache groupID:").concat(t," avChatRoomKey:").concat(n))}},{key:"initGroupAttributes",value:function(e){var t=this,n=e.groupID,o=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:n,funcName:"initGroupAttributes"});if(!0!==a)return lr(a);var s=this._groupAttributesMap.get(n),r=s.remoteMainSequence,i=s.avChatRoomKey,c=new sa(ls);return c.setMessage("groupID:".concat(n," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(o))),this._groupModule.request({protocolName:mo,requestData:{groupID:n,avChatRoomKey:i,mainSequence:r,groupAttributeList:this._transformGroupAttributes(o)}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=o[e.key]})),t._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:s,groupAttributeList:r,operationType:"init"}),c.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".initGroupAttributes ok. groupID:").concat(n)),er({groupAttributes:o})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),lr(e)}))}},{key:"setGroupAttributes",value:function(e){var t=this,n=e.groupID,o=e.groupAttributes,a=this._checkCachedGroupAttributes({groupID:n,funcName:"setGroupAttributes"});if(!0!==a)return lr(a);var s=this._groupAttributesMap.get(n),r=s.remoteMainSequence,i=s.avChatRoomKey,c=s.attributes,u=this._transformGroupAttributes(o);u.forEach((function(e){var t=e.key;e.sequence=0,c.has(t)&&(e.sequence=c.get(t).sequence)}));var l=new sa(ds);return l.setMessage("groupID:".concat(n," mainSequence:").concat(r," groupAttributes:").concat(JSON.stringify(o))),this._groupModule.request({protocolName:Mo,requestData:{groupID:n,avChatRoomKey:i,mainSequence:r,groupAttributeList:u}}).then((function(e){var a=e.data,s=a.mainSequence,r=M(a.groupAttributeList);return r.forEach((function(e){e.value=o[e.key]})),t._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:s,groupAttributeList:r,operationType:"modify"}),l.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".setGroupAttributes ok. groupID:").concat(n)),er({groupAttributes:o})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];l.setError(e,o,a).end()})),lr(e)}))}},{key:"deleteGroupAttributes",value:function(e){var t=this,n=e.groupID,o=e.keyList,a=void 0===o?[]:o,s=this._checkCachedGroupAttributes({groupID:n,funcName:"deleteGroupAttributes"});if(!0!==s)return lr(s);var r=this._groupAttributesMap.get(n),i=r.remoteMainSequence,c=r.avChatRoomKey,u=r.attributes,l=M(u.keys()),d=yo,p="clear",g={groupID:n,avChatRoomKey:c,mainSequence:i};if(a.length>0){var _=[];l=[],d=vo,p="delete",a.forEach((function(e){var t=0;u.has(e)&&(t=u.get(e).sequence,l.push(e)),_.push({key:e,sequence:t})})),g.groupAttributeList=_}var h=new sa(ps);return h.setMessage("groupID:".concat(n," mainSequence:").concat(i," keyList:").concat(a," protocolName:").concat(d)),this._groupModule.request({protocolName:d,requestData:g}).then((function(e){var o=e.data.mainSequence;return t._refreshCachedGroupAttributes({groupID:n,remoteMainSequence:o,groupAttributeList:a,operationType:p}),h.setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".deleteGroupAttributes ok. groupID:").concat(n)),er({keyList:l})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];h.setError(e,o,a).end()})),lr(e)}))}},{key:"getGroupAttributes",value:function(e){var t=this,n=e.groupID,o=this._checkCachedGroupAttributes({groupID:n,funcName:"getGroupAttributes"});if(!0!==o)return lr(o);var a=this._groupAttributesMap.get(n),s=a.avChatRoomKey,r=a.lastUpdateTime,i=a.localMainSequence,c=a.remoteMainSequence,u=new sa(gs);if(u.setMessage("groupID:".concat(n," localMainSequence:").concat(i," remoteMainSequence:").concat(c," keyList:").concat(e.keyList)),Date.now()-r>=this.CACHE_EXPIRE_TIME||i<c)return this._getGroupAttributes({groupID:n,avChatRoomKey:s}).then((function(o){u.setMoreMessage("get attributes from remote. count:".concat(o.length)).setNetworkType(t._groupModule.getNetworkType()).end(),we.log("".concat(t._className,".getGroupAttributes from remote. groupID:").concat(n));var a=t._getLocalGroupAttributes(e);return er({groupAttributes:a})})).catch((function(e){return t._groupModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),lr(e)}));u.setMoreMessage("get attributes from cache").setNetworkType(this._groupModule.getNetworkType()).end(),we.log("".concat(this._className,".getGroupAttributes from cache. groupID:").concat(n));var l=this._getLocalGroupAttributes(e);return ur({groupAttributes:l})}},{key:"_getGroupAttributes",value:function(e){var t=this;return this._groupModule.request({protocolName:Io,requestData:r({},e)}).then((function(n){var o=n.data,a=o.mainSequence,s=o.groupAttributeList,r=M(s);return Je(a)||t._refreshCachedGroupAttributes({groupID:e.groupID,remoteMainSequence:a,groupAttributeList:r,operationType:"get"}),we.log("".concat(t._className,"._getGroupAttributes ok. groupID:").concat(e.groupID)),s})).catch((function(e){return lr(e)}))}},{key:"_getLocalGroupAttributes",value:function(e){var t=e.groupID,n=e.keyList,o=void 0===n?[]:n,a={};if(!this._groupAttributesMap.has(t))return a;var s=this._groupAttributesMap.get(t).attributes;if(o.length>0)o.forEach((function(e){s.has(e)&&(a[e]=s.get(e).value)}));else{var r,i=C(s.keys());try{for(i.s();!(r=i.n()).done;){var c=r.value;a[c]=s.get(c).value}}catch(u){i.e(u)}finally{i.f()}}return a}},{key:"_refreshCachedGroupAttributes",value:function(e){var t=e.groupID,n=e.remoteMainSequence,o=e.groupAttributeList,a=e.operationType;if(this._groupAttributesMap.has(t)){var s=this._groupAttributesMap.get(t),r=s.localMainSequence;if("get"===a||n-r==1)s.remoteMainSequence=n,s.localMainSequence=n,s.lastUpdateTime=Date.now(),this._updateCachedAttributes({groupAttributes:s,groupAttributeList:o,operationType:a});else{if(r===n)return;s.remoteMainSequence=n}this._groupAttributesMap.set(t,s);var i="operationType:".concat(a," localMainSequence:").concat(r," remoteMainSequence:").concat(n);we.log("".concat(this._className,"._refreshCachedGroupAttributes. ").concat(i))}}},{key:"_updateCachedAttributes",value:function(e){var t=e.groupAttributes,n=e.groupAttributeList,o=e.operationType;"clear"!==o?"delete"!==o?("init"===o&&t.attributes.clear(),n.forEach((function(e){var n=e.key,o=e.value,a=e.sequence;t.attributes.set(n,{value:o,sequence:a})}))):n.forEach((function(e){t.attributes.delete(e)})):t.attributes.clear()}},{key:"_checkCachedGroupAttributes",value:function(e){var t=e.groupID,n=e.funcName;if(this._groupModule.hasLocalGroup(t)&&this._groupModule.getLocalGroupProfile(t).type!==D.GRP_AVCHATROOM){return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat("非直播群不能使用群属性 API")),new rr({code:Bo.CANNOT_USE_GRP_ATTR_NOT_AVCHATROOM,message:"非直播群不能使用群属性 API"})}var o=this._groupAttributesMap.get(t);if(Je(o)){var a="如果 groupID:".concat(t," 是直播群,使用 ").concat(n," 前先使用 joinGroup 接口申请加入群组,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(this._className,"._checkCachedGroupAttributes. ").concat(a)),new rr({code:Bo.CANNOT_USE_GRP_ATTR_AVCHATROOM_UNJOIN,message:a})}return!0}},{key:"_transformGroupAttributes",value:function(e){var t=[];return Object.keys(e).forEach((function(n){t.push({key:n,value:e[n]})})),t}},{key:"_emitGroupAttributesUpdated",value:function(e){var t=this._getLocalGroupAttributes({groupID:e});this._groupModule.emitOuterEvent(S.GROUP_ATTRIBUTES_UPDATED,{groupID:e,groupAttributes:t})}},{key:"reset",value:function(){this._groupAttributesMap.clear(),this.CACHE_EXPIRE_TIME=3e4}}]),e}(),Ur=function(){function e(n){t(this,e);var o=n.manager,a=n.groupID,s=n.onInit,r=n.onSuccess,i=n.onFail;this._className="Polling",this._manager=o,this._groupModule=o._groupModule,this._onInit=s,this._onSuccess=r,this._onFail=i,this._groupID=a,this._timeoutID=-1,this._isRunning=!1,this._protocolName=go}return o(e,[{key:"start",value:function(){var e=this._groupModule.isLoggedIn();e||(this._protocolName=_o),we.log("".concat(this._className,".start pollingInterval:").concat(this._manager.getPollingInterval()," isLoggedIn:").concat(e)),this._isRunning=!0,this._request()}},{key:"isRunning",value:function(){return this._isRunning}},{key:"_request",value:function(){var e=this,t=this._onInit(this._groupID);this._groupModule.request({protocolName:this._protocolName,requestData:t}).then((function(t){e._onSuccess(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.getPollingInterval()))})).catch((function(t){e._onFail(e._groupID,t),e.isRunning()&&(clearTimeout(e._timeoutID),e._timeoutID=setTimeout(e._request.bind(e),e._manager.MAX_POLLING_INTERVAL))}))}},{key:"stop",value:function(){we.log("".concat(this._className,".stop")),this._timeoutID>0&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}]),e}(),Fr={3:!0,4:!0,5:!0,6:!0},qr=function(){function e(n){t(this,e),this._groupModule=n,this._className="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this.sequencesLinkedList=new Sr(100),this.messageIDLinkedList=new Sr(100),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60,this.DEFAULT_POLLING_INTERVAL=300,this.MAX_POLLING_INTERVAL=2e3,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL}return o(e,[{key:"hasJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0?M(this._joinedGroupMap.keys()):null}},{key:"_updateRequestData",value:function(e){return r({},this._pollingRequestInfoMap.get(e))}},{key:"_handleSuccess",value:function(e,t){var n=t.data,o=n.key,a=n.nextSeq,s=n.rspMsgList;if(0!==n.errorCode){var r=this._pollingRequestInfoMap.get(e),i=new sa(Ts),c=r?"".concat(r.key,"-").concat(r.startSeq):"requestInfo is undefined";i.setMessage("".concat(e,"-").concat(c,"-").concat(t.errorInfo)).setCode(t.errorCode).setNetworkType(this._groupModule.getNetworkType()).end(!0)}else{if(!this.checkJoinedAVChatRoomByID(e))return;We(o)&&je(a)&&this._pollingRequestInfoMap.set(e,{key:o,startSeq:a}),ze(s)&&s.length>0&&(s.forEach((function(e){e.to=e.groupID})),this.onMessage(s))}}},{key:"_handleFailure",value:function(e,t){}},{key:"onMessage",value:function(e){if(ze(e)&&0!==e.length){var t=null,n=[],o=this._getModule(tn),a=this._getModule(mn),s=e.length;s>1&&e.sort((function(e,t){return e.sequence-t.sequence}));for(var r=this._getModule(nn),i=0;i<s;i++)if(Fr[e[i].event]){this.receivedMessageCount+=1,t=this.packMessage(e[i],e[i].event);var c=1===e[i].isModified,u=1===e[i].isHistoryMessage;if((r.isUnlimitedAVChatRoom()||!this.sequencesLinkedList.has(t.sequence))&&!this.messageIDLinkedList.has(t.ID)){var l=t.conversationID;if(this.receivedMessageCount%40==0&&this._getModule(gn).detectMessageLoss(l,this.sequencesLinkedList.data()),null!==this.sequencesLinkedList.tail()){var d=this.sequencesLinkedList.tail().value,p=t.sequence-d;p>1&&p<=20?this._getModule(gn).onMessageMaybeLost(l,d+1,p-1):p<-1&&p>=-20&&this._getModule(gn).onMessageMaybeLost(l,t.sequence+1,Math.abs(p)-1)}this.sequencesLinkedList.set(t.sequence),this.messageIDLinkedList.set(t.ID);var g=!1;if(this._isMessageSentByCurrentInstance(t)?c&&(g=!0,t.isModified=c,o.updateMessageIsModifiedProperty(t)):g=!0,g){if(t.conversationType,D.CONV_SYSTEM,!u&&t.conversationType!==D.CONV_SYSTEM){var _=t.conversationID.replace(D.CONV_GROUP,"");this._pollingInstanceMap.has(_)?a.addMessageSequence({key:ea,message:t}):(t.type!==D.MSG_GRP_TIP&&t.clientTime>0&&a.addMessageDelay(t.clientTime),a.addMessageSequence({key:Zo,message:t}))}n.push(t)}}}else we.warn("".concat(this._className,".onMessage 未处理的 event 类型: ").concat(e[i].event));if(0!==n.length){this._groupModule.filterModifiedMessage(n);var h=this.packConversationOption(n);if(h.length>0)this._getModule(tn).onNewMessage({conversationOptionsList:h,isInstantMessage:!0});we.debug("".concat(this._className,".onMessage count:").concat(n.length)),this._checkMessageStacked(n);var f=this._groupModule.filterUnmodifiedMessage(n);f.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,f),n.length=0}}}},{key:"_checkMessageStacked",value:function(e){var t=e.length;t>=100&&(we.warn("".concat(this._className,"._checkMessageStacked 直播群消息堆积数:").concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5&&(new sa(Ss).setNetworkType(this._groupModule.getNetworkType()).setMessage("count:".concat(t," groupID:").concat(M(this._joinedGroupMap.keys()))).setLevel("warning").end(),this._reportMessageStackedCount+=1))}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this._getModule(tn).isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,t){e.currentUser=this._groupModule.getMyUserID(),e.conversationType=5===t?D.CONV_SYSTEM:D.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var n=new Zs(e),o=this.packElements(e,t);return n.setElement(o),n}},{key:"packElements",value:function(e,t){return 4===t||6===t?(this._updateMemberCountByGroupTips(e),this._onGroupAttributesUpdated(e),{type:D.MSG_GRP_TIP,content:r({},e.elements,{groupProfile:e.groupProfile})}):5===t?{type:D.MSG_GRP_SYS_NOTICE,content:r({},e.elements,{groupProfile:e.groupProfile})}:this._getModule(rn).parseElements(e.elements,e.from)}},{key:"packConversationOption",value:function(e){for(var t=new Map,n=0;n<e.length;n++){var o=e[n],a=o.conversationID;if(t.has(a)){var s=t.get(a);s.lastMessage=o,"in"===o.flow&&s.unreadCount++}else t.set(a,{conversationID:o.conversationID,unreadCount:"out"===o.flow?0:1,type:o.conversationType,subType:o.conversationSubType,lastMessage:o})}return M(t.values())}},{key:"_updateMemberCountByGroupTips",value:function(e){var t=e.groupProfile.groupID,n=e.elements.onlineMemberInfo,o=void 0===n?void 0:n;if(!Pt(o)){var a=o.onlineMemberNum,s=void 0===a?0:a,r=o.expireTime,i=void 0===r?this.DEFAULT_EXPIRE_TIME:r,c=this._onlineMemberCountMap.get(t)||{},u=Date.now();Pt(c)?Object.assign(c,{lastReqTime:0,lastSyncTime:0,latestUpdateTime:u,memberCount:s,expireTime:i}):(c.latestUpdateTime=u,c.memberCount=s),we.debug("".concat(this._className,"._updateMemberCountByGroupTips info:"),c),this._onlineMemberCountMap.set(t,c)}}},{key:"start",value:function(e){if(this._pollingInstanceMap.has(e)){var t=this._pollingInstanceMap.get(e);t.isRunning()||t.start()}else{var n=new Ur({manager:this,groupID:e,onInit:this._updateRequestData.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});n.start(),this._pollingInstanceMap.set(e,n),we.log("".concat(this._className,".start groupID:").concat(e))}}},{key:"handleJoinResult",value:function(e){var t=this;return this._preCheck().then((function(){var n=e.longPollingKey,o=e.group,a=o.groupID;return t._joinedGroupMap.set(a,o),t._groupModule.updateGroupMap([o]),t._groupModule.deleteUnjoinedAVChatRoom(a),t._groupModule.emitGroupListUpdate(!0,!1),Je(n)?ur({status:Ke,group:o}):Promise.resolve()}))}},{key:"startRunLoop",value:function(e){var t=this;return this.handleJoinResult(e).then((function(){var n=e.longPollingKey,o=e.group,a=o.groupID;return t._pollingRequestInfoMap.set(a,{key:n,startSeq:0}),t.start(a),t._groupModule.isLoggedIn()?ur({status:Ke,group:o}):ur({status:Ke})}))}},{key:"_preCheck",value:function(){if(this._getModule(nn).isUnlimitedAVChatRoom())return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();var e=m(this._joinedGroupMap.entries().next().value,2),t=e[0],n=e[1];if(this._groupModule.isLoggedIn()){if(!(n.selfInfo.role===D.GRP_MBR_ROLE_OWNER||n.ownerID===this._groupModule.getMyUserID()))return this._groupModule.quitGroup(t);this._groupModule.deleteLocalGroupAndConversation(t)}else this._groupModule.deleteLocalGroupAndConversation(t);return this.reset(t),Promise.resolve()}},{key:"joinWithoutAuth",value:function(e){var t=this,n=e.groupID,o="".concat(this._className,".joinWithoutAuth"),a=new sa(us);return this._groupModule.request({protocolName:Xn,requestData:e}).then((function(e){var s=e.data.longPollingKey;if(t._groupModule.probeNetwork().then((function(e){var t=m(e,2),o=(t[0],t[1]);a.setNetworkType(o).setMessage("groupID:".concat(n," longPollingKey:").concat(s)).end(!0)})),Je(s))return lr(new rr({code:Bo.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN,message:Ho.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN}));we.log("".concat(o," ok. groupID:").concat(n)),t._getModule(tn).setCompleted("".concat(D.CONV_GROUP).concat(n));var r=new Nr({groupID:n});return t.startRunLoop({group:r,longPollingKey:s}),er({status:Ke})})).catch((function(e){return we.error("".concat(o," failed. groupID:").concat(n," error:"),e),t._groupModule.probeNetwork().then((function(t){var o=m(t,2),s=o[0],r=o[1];a.setError(e,s,r).setMessage("groupID:".concat(n)).end(!0)})),lr(e)})).finally((function(){t._groupModule.getModule(an).reportAtOnce()}))}},{key:"getGroupOnlineMemberCount",value:function(e){var t=this._onlineMemberCountMap.get(e)||{},n=Date.now();return Pt(t)||n-t.lastSyncTime>1e3*t.expireTime&&n-t.latestUpdateTime>1e4&&n-t.lastReqTime>3e3?(t.lastReqTime=n,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then((function(e){return er({memberCount:e.memberCount})})).catch((function(e){return lr(e)}))):ur({memberCount:t.memberCount})}},{key:"_getGroupOnlineMemberCount",value:function(e){var t=this,n="".concat(this._className,"._getGroupOnlineMemberCount");return this._groupModule.request({protocolName:ho,requestData:{groupID:e}}).then((function(o){var a=t._onlineMemberCountMap.get(e)||{},s=o.data,r=s.onlineMemberNum,i=void 0===r?0:r,c=s.expireTime,u=void 0===c?t.DEFAULT_EXPIRE_TIME:c;we.log("".concat(n," ok. groupID:").concat(e," memberCount:").concat(i," expireTime:").concat(u));var l=Date.now();return Pt(a)&&(a.lastReqTime=l),t._onlineMemberCountMap.set(e,Object.assign(a,{lastSyncTime:l,latestUpdateTime:l,memberCount:i,expireTime:u})),{memberCount:i}})).catch((function(o){return we.warn("".concat(n," failed. error:"),o),new sa(Es).setCode(o.code).setMessage("groupID:".concat(e," error:").concat(JSON.stringify(o))).setNetworkType(t._groupModule.getNetworkType()).end(),Promise.reject(o)}))}},{key:"_onGroupAttributesUpdated",value:function(e){var t=e.groupProfile.groupID,n=e.elements,o=n.operationType,a=n.newGroupProfile;if(6===o){var s=(void 0===a?void 0:a).groupAttributeOption;Pt(s)||this._groupModule.onGroupAttributesUpdated({groupID:t,groupAttributeOption:s})}}},{key:"_getModule",value:function(e){return this._groupModule.getModule(e)}},{key:"setPollingInterval",value:function(e){Je(e)||je(e)||(this._pollingInterval=parseInt(e,10),we.log("".concat(this._className,".setPollingInterval value:").concat(this._pollingInterval)))}},{key:"getPollingInterval",value:function(){return this._pollingInterval}},{key:"reset",value:function(e){if(e){we.log("".concat(this._className,".reset groupID:").concat(e));var t=this._pollingInstanceMap.get(e);t&&t.stop(),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e)}else{we.log("".concat(this._className,".reset all"));var n,o=C(this._pollingInstanceMap.values());try{for(o.s();!(n=o.n()).done;){n.value.stop()}}catch(a){o.e(a)}finally{o.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear()}this.sequencesLinkedList.reset(),this.messageIDLinkedList.reset(),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._pollingInterval=this.DEFAULT_POLLING_INTERVAL}}]),e}(),Vr=1,Kr=15,xr=function(){function e(n){t(this,e),this._groupModule=n,this._className="GroupSystemNoticeHandler",this.pendencyMap=new Map}return o(e,[{key:"onNewGroupSystemNotice",value:function(e){var t=e.dataList,n=e.isSyncingEnded,o=e.isInstantMessage;we.debug("".concat(this._className,".onReceiveSystemNotice count:").concat(t.length));var a=this.newSystemNoticeStoredAndSummary({notifiesList:t,isInstantMessage:o}),s=a.eventDataList,r=a.result;s.length>0&&(this._groupModule.getModule(tn).onNewMessage({conversationOptionsList:s,isInstantMessage:o}),this._onReceivedGroupSystemNotice({result:r,isInstantMessage:o}));o?r.length>0&&this._groupModule.emitOuterEvent(S.MESSAGE_RECEIVED,r):!0===n&&this._clearGroupSystemNotice()}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var t=e.notifiesList,n=e.isInstantMessage,o=null,a=t.length,s=0,i=[],c={conversationID:D.CONV_SYSTEM,unreadCount:0,type:D.CONV_SYSTEM,subType:null,lastMessage:null};for(s=0;s<a;s++){var u=t[s];if(u.elements.operationType!==Kr)u.currentUser=this._groupModule.getMyUserID(),u.conversationType=D.CONV_SYSTEM,u.conversationID=D.CONV_SYSTEM,(o=new Zs(u)).setElement({type:D.MSG_GRP_SYS_NOTICE,content:r({},u.elements,{groupProfile:u.groupProfile})}),o.isSystemMessage=!0,(1===o.sequence&&1===o.random||2===o.sequence&&2===o.random)&&(o.sequence=ct(),o.random=ct(),o.generateMessageID(),we.log("".concat(this._className,".newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID:").concat(o.ID))),this._groupModule.getModule(tn).pushIntoNoticeResult(i,o)&&(n?c.unreadCount++:o.setIsRead(!0),c.subType=o.conversationSubType)}return c.lastMessage=i[i.length-1],{eventDataList:i.length>0?[c]:[],result:i}}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(t){t.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var n=e._groupModule.getModule(tn).getLocalMessageList(D.CONV_SYSTEM),o=[];n.forEach((function(t){var n=t.payload,a=n.operatorID,s=n.operationType,r=n.groupProfile;if(s===Vr){var i="".concat(a,"_").concat(r.groupID,"_").concat(r.to),c=e.pendencyMap.get(i);c&&je(c.handled)&&0!==c.handled&&o.push(t)}})),e.deleteGroupSystemNotice({messageList:o})}))}},{key:"deleteGroupSystemNotice",value:function(e){var t=this,n="".concat(this._className,".deleteGroupSystemNotice");return ze(e.messageList)&&0!==e.messageList.length?(we.log("".concat(n)+e.messageList.map((function(e){return e.ID}))),this._groupModule.request({protocolName:po,requestData:{messageListToDelete:e.messageList.map((function(e){return{from:D.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){we.log("".concat(n," ok"));var o=t._groupModule.getModule(tn);return e.messageList.forEach((function(e){o.deleteLocalMessage(e)})),er()})).catch((function(e){return we.error("".concat(n," error:"),e),lr(e)}))):ur()}},{key:"getPendencyList",value:function(e){var t=this;return this._groupModule.request({protocolName:lo,requestData:{startTime:e&&e.startTime?e.startTime:0,limit:e&&e.limit?e.limit:10,handleAccount:this._groupModule.getMyUserID()}}).then((function(e){var n=e.data.pendencyList;return 0!==e.data.nextStartTime?t.getPendencyList({startTime:e.data.nextStartTime}).then((function(e){return[].concat(M(n),M(e))})):n}))}},{key:"_onReceivedGroupSystemNotice",value:function(e){var t=this,n=e.result;e.isInstantMessage&&n.forEach((function(e){switch(e.payload.operationType){case 1:break;case 2:t._onApplyGroupRequestAgreed(e);break;case 3:break;case 4:t._onMemberKicked(e);break;case 5:t._onGroupDismissed(e);break;case 6:break;case 7:t._onInviteGroup(e);break;case 8:t._onQuitGroup(e);break;case 9:t._onSetManager(e);break;case 10:t._onDeleteManager(e)}}))}},{key:"_onApplyGroupRequestAgreed",value:function(e){var t=this,n=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n)||this._groupModule.getGroupProfile({groupID:n}).then((function(e){var n=e.data.group;n&&(t._groupModule.updateGroupMap([n]),t._groupModule.emitGroupListUpdate())}))}},{key:"_onMemberKicked",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onGroupDismissed",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t);var n=this._groupModule._AVChatRoomHandler;n&&n.checkJoinedAVChatRoomByID(t)&&n.reset(t)}},{key:"_onInviteGroup",value:function(e){var t=this,n=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(n)||this._groupModule.getGroupProfile({groupID:n}).then((function(e){var n=e.data.group;n&&(t._groupModule.updateGroupMap([n]),t._groupModule.emitGroupListUpdate())}))}},{key:"_onQuitGroup",value:function(e){var t=e.payload.groupProfile.groupID;this._groupModule.hasLocalGroup(t)&&this._groupModule.deleteLocalGroupAndConversation(t)}},{key:"_onSetManager",value:function(e){var t=e.payload.groupProfile,n=t.to,o=t.groupID,a=this._groupModule.getModule(en).getLocalGroupMemberInfo(o,n);a&&a.updateRole(D.GRP_MBR_ROLE_ADMIN)}},{key:"_onDeleteManager",value:function(e){var t=e.payload.groupProfile,n=t.to,o=t.groupID,a=this._groupModule.getModule(en).getLocalGroupMemberInfo(o,n);a&&a.updateRole(D.GRP_MBR_ROLE_MEMBER)}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),e}(),Br=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="GroupModule",o._commonGroupHandler=null,o._AVChatRoomHandler=null,o._groupSystemNoticeHandler=null,o._commonGroupHandler=new Pr(_(o)),o._groupAttributesHandler=new br(_(o)),o._AVChatRoomHandler=new qr(_(o)),o._groupTipsHandler=new Gr(_(o)),o._groupSystemNoticeHandler=new xr(_(o)),o.groupMap=new Map,o._unjoinedAVChatRoomList=new Map,o._receiptDetailCompleteMap=new Map,o.getInnerEmitterInstance().on(_r,o._onCloudConfigUpdated,_(o)),o}return o(a,[{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("polling_interval");this._AVChatRoomHandler&&this._AVChatRoomHandler.setPollingInterval(e)}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&(this._commonGroupHandler.onCheckTimer(e),this._groupTipsHandler.onCheckTimer(e))}},{key:"guardForAVChatRoom",value:function(e){var t=this;if(e.conversationType===D.CONV_GROUP){var n=e.to;return this.hasLocalGroup(n)?ur():this.getGroupProfile({groupID:n}).then((function(o){var a=o.data.group.type;if(we.log("".concat(t._className,".guardForAVChatRoom. groupID:").concat(n," type:").concat(a)),a===D.GRP_AVCHATROOM){var s="userId:".concat(e.from," 未加入群 groupID:").concat(n,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#joinGroup");return we.warn("".concat(t._className,".guardForAVChatRoom sendMessage not allowed. ").concat(s)),lr(new rr({code:Bo.MESSAGE_SEND_FAIL,message:s,data:{message:e}}))}return ur()}))}return ur()}},{key:"checkJoinedAVChatRoomByID",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"onNewGroupMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onNewGroupMessage(e)}},{key:"updateNextMessageSeq",value:function(e){var t=this;ze(e)&&e.forEach((function(e){var n=e.conversationID.replace(D.CONV_GROUP,"");t.groupMap.has(n)&&(t.groupMap.get(n).nextMessageSeq=e.lastMessage.sequence+1)}))}},{key:"onNewGroupTips",value:function(e){this._groupTipsHandler&&this._groupTipsHandler.onNewGroupTips(e)}},{key:"onGroupMessageRevoked",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.onGroupMessageRevoked(e)}},{key:"onNewGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.onNewGroupSystemNotice(e)}},{key:"onGroupMessageReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){var n=e.elements.groupMessageReadNotice;if(!Je(n)){var o=t.getModule(tn);n.forEach((function(e){var n=e.groupID,a=e.lastMessageSeq;we.debug("".concat(t._className,".onGroupMessageReadNotice groupID:").concat(n," lastMessageSeq:").concat(a));var s="".concat(D.CONV_GROUP).concat(n);o.updateIsReadAfterReadReport({conversationID:s,lastMessageSeq:a}),o.updateUnreadCount(s)}))}}))}},{key:"onReadReceiptList",value:function(e){var t=this;we.debug("".concat(this._className,".onReadReceiptList options:"),JSON.stringify(e)),e.dataList.forEach((function(e){var n=e.groupProfile,o=e.elements,a=n.groupID,s=t.getModule(tn),r=o.readReceiptList;s.updateReadReceiptInfo(a,r)}))}},{key:"deleteGroupSystemNotice",value:function(e){this._groupSystemNoticeHandler&&this._groupSystemNoticeHandler.deleteGroupSystemNotice(e)}},{key:"initGroupMap",value:function(e){this.groupMap.set(e.groupID,new Nr(e))}},{key:"deleteGroup",value:function(e){this.groupMap.delete(e)}},{key:"updateGroupMap",value:function(e){var t=this;e.forEach((function(e){t.groupMap.has(e.groupID)?t.groupMap.get(e.groupID).updateGroup(e):t.groupMap.set(e.groupID,new Nr(e))}));var n,o=this.getMyUserID(),a=C(this.groupMap);try{for(a.s();!(n=a.n()).done;){m(n.value,2)[1].selfInfo.userID=o}}catch(s){a.e(s)}finally{a.f()}this._setStorageGroupList()}},{key:"getStorageGroupList",value:function(){return this.getModule(on).getItem("groupMap")}},{key:"_setStorageGroupList",value:function(){var e=this.getLocalGroupList().filter((function(e){var t=e.type;return!Mt(t)})).slice(0,20).map((function(e){return{groupID:e.groupID,name:e.name,avatar:e.avatar,type:e.type}}));this.getModule(on).setItem("groupMap",e)}},{key:"getGroupMap",value:function(){return this.groupMap}},{key:"getLocalGroupList",value:function(){return M(this.groupMap.values())}},{key:"getLocalGroupProfile",value:function(e){return this.groupMap.get(e)}},{key:"sortLocalGroupList",value:function(){var e=M(this.groupMap).filter((function(e){var t=m(e,2);t[0];return!Pt(t[1].lastMessage)}));e.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),this.groupMap=new Map(M(e))}},{key:"updateGroupLastMessage",value:function(e){this._commonGroupHandler&&this._commonGroupHandler.handleUpdateGroupLastMessage(e)}},{key:"emitGroupListUpdate",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getLocalGroupList();if(e&&this.emitOuterEvent(S.GROUP_LIST_UPDATED),t){var o=JSON.parse(JSON.stringify(n)),a=this.getModule(tn);a.updateConversationGroupProfile(o)}}},{key:"patchGroupMessageRemindType",value:function(){var e=this.getLocalGroupList(),t=this.getModule(tn),n=0;e.forEach((function(e){!0===t.patchMessageRemindType({ID:e.groupID,isC2CConversation:!1,messageRemindType:e.selfInfo.messageRemindType})&&(n+=1)})),we.log("".concat(this._className,".patchGroupMessageRemindType count:").concat(n))}},{key:"recomputeUnreadCount",value:function(){var e=this.getLocalGroupList(),t=this.getModule(tn);e.forEach((function(e){var n=e.groupID,o=e.selfInfo,a=o.excludedUnreadSequenceList,s=o.readedSequence;if(ze(a)){var r=0;a.forEach((function(t){t>=s&&t<=e.nextMessageSeq-1&&(r+=1)})),r>=1&&t.recomputeGroupUnreadCount({conversationID:"".concat(D.CONV_GROUP).concat(n),count:r})}}))}},{key:"getMyNameCardByGroupID",value:function(e){var t=this.getLocalGroupProfile(e);return t?t.selfInfo.nameCard:""}},{key:"getGroupList",value:function(e){return this._commonGroupHandler?this._commonGroupHandler.getGroupList(e):ur()}},{key:"getGroupProfile",value:function(e){var t=this,n=new sa(os),o="".concat(this._className,".getGroupProfile"),a=e.groupID,s=e.groupCustomFieldFilter;we.log("".concat(o," groupID:").concat(a));var r={groupIDList:[a],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:s,memberInfoFilter:["Role","JoinTime","MsgSeq","MsgFlag","NameCard"]}};return this.getGroupProfileAdvance(r).then((function(e){var s,r=e.data,i=r.successGroupList,c=r.failureGroupList;return we.log("".concat(o," ok")),c.length>0?lr(c[0]):(Mt(i[0].type)&&!t.hasLocalGroup(a)?s=new Nr(i[0]):(t.updateGroupMap(i),s=t.getLocalGroupProfile(a)),t.getModule(tn).updateConversationGroupProfile([s]),n.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(a," type:").concat(s.type," muteAllMembers:").concat(s.muteAllMembers," ownerID:").concat(s.ownerID)).end(),er({group:s}))})).catch((function(a){return t.probeNetwork().then((function(t){var o=m(t,2),s=o[0],r=o[1];n.setError(a,s,r).setMessage("groupID:".concat(e.groupID)).end()})),we.error("".concat(o," failed. error:"),a),lr(a)}))}},{key:"getGroupProfileAdvance",value:function(e){var t=this,n="".concat(this._className,".getGroupProfileAdvance"),o=e.groupIDList;ze(o)&&o.length>50&&(we.warn("".concat(n," 获取群资料的数量不能超过50个")),o.length=50);var a=[],s=[];o.forEach((function(e){vt({groupID:e})?s.push(e):a.push(e)}));var i=[];if(a.length>0){var c=this._getGroupProfileAdvance(r({},e,{groupIDList:a}));i.push(c)}if(s.length>0){var u=this._getGroupProfileAdvance(r({},e,{groupIDList:s,relayFlag:a.length>0}));i.push(u)}return Promise.all(i).then((function(e){var t=[],n=[];return e.forEach((function(e){t.push.apply(t,M(e.successGroupList)),n.push.apply(n,M(e.failureGroupList))})),er({successGroupList:t,failureGroupList:n})})).catch((function(e){return we.error("".concat(t._className,"._getGroupProfileAdvance failed. error:"),e),lr(e)}))}},{key:"_getGroupProfileAdvance",value:function(e){var t=this,n=e.relayFlag,o=void 0!==n&&n,a=g(e,["relayFlag"]);return this.request({protocolName:Wn,requestData:a}).then((function(e){we.log("".concat(t._className,"._getGroupProfileAdvance ok."));var n=e.data.groups;return{successGroupList:n.filter((function(e){return Je(e.errorCode)||0===e.errorCode})),failureGroupList:n.filter((function(e){return e.errorCode&&0!==e.errorCode})).map((function(e){return new rr({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}))}})).catch((function(t){return o&&vt({groupID:e.groupIDList[0]})?{successGroupList:[],failureGroupList:[]}:lr(t)}))}},{key:"createGroup",value:function(e){var t=this,n="".concat(this._className,".createGroup"),o=e.type,a=e.groupID;if(!["Public","Private","ChatRoom","AVChatRoom","Community"].includes(o))return lr({code:Bo.ILLEGAL_GROUP_TYPE,message:Ho.ILLEGAL_GROUP_TYPE});if(!vt({type:o})&&!Pt(a)&&vt({groupID:a}))return lr({code:Bo.ILLEGAL_GROUP_ID,message:Ho.ILLEGAL_GROUP_ID});if(Mt(o)&&!Je(e.memberList)&&e.memberList.length>0&&(we.warn("".concat(n," 创建 AVChatRoom 时不能添加群成员,自动忽略该字段")),e.memberList=void 0),mt(o)||Je(e.joinOption)||(we.warn("".concat(n," 创建 Work/Meeting/AVChatRoom/Community 群时不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),vt({type:o})&&!Pt(a)&&!vt({groupID:a}))return lr({code:Bo.ILLEGAL_GROUP_ID,message:Ho.ILLEGAL_GROUP_ID});var s=new sa(Wa);we.log("".concat(n," options:"),e);var i=[];return this.request({protocolName:Yn,requestData:r({},e,{ownerID:this.getMyUserID(),webPushFlag:1})}).then((function(o){var a=o.data,c=a.groupID,u=a.overLimitUserIDList,l=void 0===u?[]:u;if(i=l,s.setNetworkType(t.getNetworkType()).setMessage("groupType:".concat(e.type," groupID:").concat(c," overLimitUserIDList=").concat(l)).end(),we.log("".concat(n," ok groupID:").concat(c," overLimitUserIDList:"),l),e.type===D.GRP_AVCHATROOM)return t.getGroupProfile({groupID:c});Pt(e.memberList)||Pt(l)||(e.memberList=e.memberList.filter((function(e){return-1===l.indexOf(e.userID)}))),t.updateGroupMap([r({},e,{groupID:c})]);var d=t.getModule(zt),p=d.createCustomMessage({to:c,conversationType:D.CONV_GROUP,payload:{data:"group_create",extension:"".concat(t.getMyUserID(),"创建群组")}});return d.sendMessageInstance(p),t.emitGroupListUpdate(),t.getGroupProfile({groupID:c})})).then((function(e){var t=e.data.group,n=t.selfInfo,o=n.nameCard,a=n.joinTime;return t.updateSelfInfo({nameCard:o,joinTime:a,messageRemindType:D.MSG_REMIND_ACPT_AND_NOTE,role:D.GRP_MBR_ROLE_OWNER}),er({group:t,overLimitUserIDList:i})})).catch((function(o){return s.setMessage("groupType:".concat(e.type)),t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],a=t[1];s.setError(o,n,a).end()})),we.error("".concat(n," failed. error:"),o),lr(o)}))}},{key:"dismissGroup",value:function(e){var t=this,n="".concat(this._className,".dismissGroup");if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===D.GRP_WORK)return lr(new rr({code:Bo.CANNOT_DISMISS_WORK,message:Ho.CANNOT_DISMISS_WORK}));var o=new sa(es);return o.setMessage("groupID:".concat(e)),we.log("".concat(n," groupID:").concat(e)),this.request({protocolName:$n,requestData:{groupID:e}}).then((function(){return o.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),t.deleteLocalGroupAndConversation(e),t.checkJoinedAVChatRoomByID(e)&&t._AVChatRoomHandler.reset(e),er({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"updateGroupProfile",value:function(e){var t=this,n="".concat(this._className,".updateGroupProfile");!this.hasLocalGroup(e.groupID)||mt(this.getLocalGroupProfile(e.groupID).type)||Je(e.joinOption)||(we.warn("".concat(n," Work/Meeting/AVChatRoom/Community 群不能设置字段 joinOption,自动忽略该字段")),e.joinOption=void 0),Je(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var o=new sa(ts);return o.setMessage(JSON.stringify(e)),we.log("".concat(n," groupID:").concat(e.groupID)),this.request({protocolName:zn,requestData:e}).then((function(){(o.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),t.hasLocalGroup(e.groupID))&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList());return er({group:t.groupMap.get(e.groupID)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.log("".concat(n," failed. error:"),e),lr(e)}))}},{key:"joinGroup",value:function(e){var t=this,n=e.groupID,o=e.type,a="".concat(this._className,".joinGroup");if(o===D.GRP_WORK){var s=new rr({code:Bo.CANNOT_JOIN_WORK,message:Ho.CANNOT_JOIN_WORK});return lr(s)}if(this.deleteUnjoinedAVChatRoom(n),this.hasLocalGroup(n)){if(!this.isLoggedIn())return ur({status:D.JOIN_STATUS_ALREADY_IN_GROUP});var r=new sa(Ya);return this.getGroupProfile({groupID:n}).then((function(){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(n," joinedStatus:").concat(D.JOIN_STATUS_ALREADY_IN_GROUP)).end(),ur({status:D.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(o){return r.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(n," unjoined")).end(),we.warn("".concat(a," ").concat(n," was unjoined, now join!")),t.groupMap.delete(n),t.applyJoinGroup(e)}))}return we.log("".concat(a," groupID:").concat(n)),this.isLoggedIn()?this.applyJoinGroup(e):this._AVChatRoomHandler.joinWithoutAuth(e)}},{key:"applyJoinGroup",value:function(e){var t=this,n="".concat(this._className,".applyJoinGroup"),o=e.groupID,a=new sa(Ya),s=r({},e),i=this.canIUse(B.AVCHATROOM_HISTORY_MSG);return i&&(s.historyMessageFlag=1),this.request({protocolName:Jn,requestData:s}).then((function(e){var s=e.data,r=s.joinedStatus,c=s.longPollingKey,u=s.avChatRoomFlag,l=s.avChatRoomKey,d=s.messageList,p="groupID:".concat(o," joinedStatus:").concat(r," longPollingKey:").concat(c)+" avChatRoomFlag:".concat(u," canGetAVChatRoomHistoryMessage:").concat(i);switch(a.setNetworkType(t.getNetworkType()).setMessage("".concat(p)).end(),we.log("".concat(n," ok. ").concat(p)),r){case xe:return er({status:xe});case Ke:return t.getGroupProfile({groupID:o}).then((function(e){var n,a=e.data.group,s={status:Ke,group:a};return 1===u?(t.getModule(tn).setCompleted("".concat(D.CONV_GROUP).concat(o)),t._groupAttributesHandler.initGroupAttributesCache({groupID:o,avChatRoomKey:l}),(n=Je(c)?t._AVChatRoomHandler.handleJoinResult({group:a}):t._AVChatRoomHandler.startRunLoop({longPollingKey:c,group:a})).then((function(){t._onAVChatRoomHistoryMessage(d)})),n):(t.emitGroupListUpdate(!0,!1),er(s))}));default:var g=new rr({code:Bo.JOIN_GROUP_FAIL,message:Ho.JOIN_GROUP_FAIL});return we.error("".concat(n," error:"),g),lr(g)}})).catch((function(o){return a.setMessage("groupID:".concat(e.groupID)),t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],s=t[1];a.setError(o,n,s).end()})),we.error("".concat(n," error:"),o),lr(o)}))}},{key:"quitGroup",value:function(e){var t=this,n="".concat(this._className,".quitGroup");we.log("".concat(n," groupID:").concat(e));var o=this.checkJoinedAVChatRoomByID(e);if(!o&&!this.hasLocalGroup(e)){var a=new rr({code:Bo.MEMBER_NOT_IN_GROUP,message:Ho.MEMBER_NOT_IN_GROUP});return lr(a)}if(o&&!this.isLoggedIn())return we.log("".concat(n," anonymously ok. groupID:").concat(e)),this.deleteLocalGroupAndConversation(e),this._AVChatRoomHandler.reset(e),ur({groupID:e});var s=new sa($a);return s.setMessage("groupID:".concat(e)),this.request({protocolName:Qn,requestData:{groupID:e}}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),o&&t._AVChatRoomHandler.reset(e),t.deleteLocalGroupAndConversation(e),er({groupID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"searchGroupByID",value:function(e){var t=this,n="".concat(this._className,".searchGroupByID"),o={groupIDList:[e]},a=new sa(za);return a.setMessage("groupID:".concat(e)),we.log("".concat(n," groupID:").concat(e)),this.request({protocolName:Zn,requestData:o}).then((function(e){var o=e.data.groupProfile;if(0!==o[0].errorCode)throw new rr({code:o[0].errorCode,message:o[0].errorInfo});return a.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),er({group:new Nr(o[0])})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],s=n[1];a.setError(e,o,s).end()})),we.warn("".concat(n," failed. error:"),e),lr(e)}))}},{key:"changeGroupOwner",value:function(e){var t=this,n="".concat(this._className,".changeGroupOwner");if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===D.GRP_AVCHATROOM)return lr(new rr({code:Bo.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:Ho.CANNOT_CHANGE_OWNER_IN_AVCHATROOM}));if(e.newOwnerID===this.getMyUserID())return lr(new rr({code:Bo.CANNOT_CHANGE_OWNER_TO_SELF,message:Ho.CANNOT_CHANGE_OWNER_TO_SELF}));var o=new sa(Ja);return o.setMessage("groupID:".concat(e.groupID," newOwnerID:").concat(e.newOwnerID)),we.log("".concat(n," groupID:").concat(e.groupID)),this.request({protocolName:eo,requestData:e}).then((function(){o.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok"));var a=e.groupID,s=e.newOwnerID;t.groupMap.get(a).ownerID=s;var r=t.getModule(en).getLocalGroupMemberList(a);if(r instanceof Map){var i=r.get(t.getMyUserID());Je(i)||(i.updateRole("Member"),t.groupMap.get(a).selfInfo.role="Member");var c=r.get(s);Je(c)||c.updateRole("Owner")}return t.emitGroupListUpdate(!0,!1),er({group:t.groupMap.get(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"handleGroupApplication",value:function(e){var t=this,n="".concat(this._className,".handleGroupApplication"),o=e.message.payload,a=o.groupProfile.groupID,s=o.authentication,i=o.messageKey,c=o.operatorID,u=new sa(Xa);return u.setMessage("groupID:".concat(a)),we.log("".concat(n," groupID:").concat(a)),this.request({protocolName:to,requestData:r({},e,{applicant:c,groupID:a,authentication:s,messageKey:i})}).then((function(){return u.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),t._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),er({group:t.getLocalGroupProfile(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];u.setError(e,o,a).end()})),we.error("".concat(n," failed. error"),e),lr(e)}))}},{key:"handleGroupInvitation",value:function(e){var t=this,n="".concat(this._className,".handleGroupInvitation"),o=e.message.payload,a=o.groupProfile.groupID,s=o.authentication,i=o.messageKey,c=o.operatorID,u=e.handleAction,l=new sa(Qa);return l.setMessage("groupID:".concat(a," inviter:").concat(c," handleAction:").concat(u)),we.log("".concat(n," groupID:").concat(a," inviter:").concat(c," handleAction:").concat(u)),this.request({protocolName:no,requestData:r({},e,{inviter:c,groupID:a,authentication:s,messageKey:i})}).then((function(){return l.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),t._groupSystemNoticeHandler.deleteGroupSystemNotice({messageList:[e.message]}),er({group:t.getLocalGroupProfile(a)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];l.setError(e,o,a).end()})),we.error("".concat(n," failed. error"),e),lr(e)}))}},{key:"getGroupOnlineMemberCount",value:function(e){return this._AVChatRoomHandler?this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this._AVChatRoomHandler.getGroupOnlineMemberCount(e):ur({memberCount:0}):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"hasLocalGroup",value:function(e){return this.groupMap.has(e)}},{key:"deleteLocalGroupAndConversation",value:function(e){this._deleteLocalGroup(e),this.getModule(tn).deleteLocalConversation("GROUP".concat(e)),this.emitGroupListUpdate(!0,!1)}},{key:"_deleteLocalGroup",value:function(e){this.groupMap.delete(e),this.getModule(en).deleteGroupMemberList(e),this._setStorageGroupList()}},{key:"sendMessage",value:function(e,t){var n=this.createGroupMessagePack(e,t);return this.request(n)}},{key:"createGroupMessagePack",value:function(e,t){var n=null;t&&t.offlinePushInfo&&(n=t.offlinePushInfo);var o="";We(e.cloudCustomData)&&e.cloudCustomData.length>0&&(o=e.cloudCustomData);var a=[];if($e(t)&&$e(t.messageControlInfo)){var s=t.messageControlInfo,r=s.excludedFromUnreadCount,i=s.excludedFromLastMessage;!0===r&&a.push("NoUnread"),!0===i&&a.push("NoLastMsg")}var c=e.getGroupAtInfoList();return{protocolName:Nn,tjgID:this.generateTjgID(e),requestData:{fromAccount:this.getMyUserID(),groupID:e.to,msgBody:e.getElements(),cloudCustomData:o,random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:e.type!==D.MSG_TEXT||Pt(c)?void 0:c,onlineOnlyFlag:this.isOnlineMessage(e,t)?1:0,clientTime:e.clientTime,offlinePushInfo:n?{pushFlag:!0===n.disablePush?1:0,title:n.title||"",desc:n.description||"",ext:n.extension||"",apnsInfo:{badgeMode:!0===n.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:n.androidOPPOChannelID||""}}:void 0,messageControlInfo:a,needReadReceipt:!0!==e.needReadReceipt||this.isMessageFromOrToAVChatroom(e.to)?0:1}}}},{key:"revokeMessage",value:function(e){return this.request({protocolName:oo,requestData:{groupID:e.to,msgSeqList:[{msgSeq:e.sequence}]}})}},{key:"deleteMessage",value:function(e){var t=e.to,n=e.keyList;return we.log("".concat(this._className,".deleteMessage groupID:").concat(t," count:").concat(n.length)),this.request({protocolName:fo,requestData:{groupID:t,deleter:this.getMyUserID(),keyList:n}})}},{key:"getRoamingMessage",value:function(e){var t=this,n="".concat(this._className,".getRoamingMessage"),o=new sa(Sa),a=0;return this._computeLastSequence(e).then((function(o){return a=o,we.log("".concat(n," groupID:").concat(e.groupID," lastSequence:").concat(a)),t.request({protocolName:ro,requestData:{groupID:e.groupID,count:21,sequence:a}})})).then((function(s){var r=s.data,i=r.messageList,c=r.complete;Je(i)?we.log("".concat(n," ok. complete:").concat(c," but messageList is undefined!")):we.log("".concat(n," ok. complete:").concat(c," count:").concat(i.length)),o.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e.groupID," lastSequence:").concat(a," complete:").concat(c," count:").concat(i?i.length:"undefined")).end();var u="GROUP".concat(e.groupID),l=t.getModule(tn);if(2===c||Pt(i))return l.setCompleted(u),[];var d=l.storeRoamingMessage(i,u);return l.updateIsRead(u),l.patchConversationLastMessage(u),d})).catch((function(s){return t.probeNetwork().then((function(t){var n=m(t,2),r=n[0],i=n[1];o.setError(s,r,i).setMessage("groupID:".concat(e.groupID," lastSequence:").concat(a)).end()})),we.warn("".concat(n," failed. error:"),s),lr(s)}))}},{key:"_getGroupIDOfMessage",value:function(e){return e.conversationID.replace(D.CONV_GROUP,"")}},{key:"getReadReceiptList",value:function(e){var t=this,n="".concat(this._className,".getReadReceiptList"),o=this._getGroupIDOfMessage(e[0]),a=this.getMyUserID(),s=e.filter((function(e){return e.from===a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(we.log("".concat(n," groupID:").concat(o," sequenceList:").concat(JSON.stringify(s))),0===s.length)return ur({messageList:e});var r=new sa(Da);return r.setMessage("groupID:".concat(o)),this.request({protocolName:io,requestData:{groupID:o,sequenceList:s}}).then((function(t){r.end(),we.log("".concat(n," ok"));var o=t.data.readReceiptList;return ze(o)&&o.forEach((function(t){e.forEach((function(e){0===t.code&&t.sequence===e.sequence&&(e.readReceiptInfo.readCount=t.readCount,e.readReceiptInfo.unreadCount=t.unreadCount)}))})),er({messageList:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];r.setError(e,o,a).end()})),we.warn("".concat(n," failed. error:"),e),lr(e)}))}},{key:"sendReadReceipt",value:function(e){var t=this,n=this._getGroupIDOfMessage(e[0]),o=new sa(Aa);o.setMessage("groupID:".concat(n));var a=this.getMyUserID(),s=e.filter((function(e){return e.from!==a&&!0===e.needReadReceipt})).map((function(e){return{sequence:e.sequence}}));if(0===s.length)return lr({code:Bo.READ_RECEIPT_SEQUENCE_LIST_EMPTY,message:Ho.READ_RECEIPT_SEQUENCE_LIST_EMPTY});var r="".concat(this._className,".sendReadReceipt");return we.log("".concat(r,". sequenceList:").concat(JSON.stringify(s))),this.request({protocolName:co,requestData:{groupID:n,sequenceList:s}}).then((function(e){return o.end(),we.log("".concat(r," ok")),er()})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.warn("".concat(r," failed. error:"),e),lr(e)}))}},{key:"getReadReceiptDetail",value:function(e){var t=this,n=e.message,o=e.filter,a=e.cursor,s=e.count,r=this._getGroupIDOfMessage(n),i=n.ID,c=n.sequence,u="".concat(this._className,".getReadReceiptDetail"),l=this._receiptDetailCompleteMap.get(i)||!1,d=0!==o&&1!==o?0:o,p=We(a)?a:"",g=!je(s)||s<=0||s>=100?100:s,_="groupID:".concat(r," sequence:").concat(c," cursor:").concat(p," filter:").concat(d," completeFlag:").concat(l);we.log("".concat(u," ").concat(_));var h={cursor:"",isCompleted:!1,messageID:i,unreadUserIDList:[],readUserIDList:[]};if(!0===l)return h.isCompleted=!0,ur(h);var f=new sa(Na);return f.setMessage(_),this.request({protocolName:uo,requestData:{groupID:r,sequence:c,flag:d,cursor:p,count:g}}).then((function(e){f.end();var n=e.data,o=n.cursor,a=n.isCompleted,s=n.unreadUserIDList,r=n.readUserIDList;return h.cursor=o,1===a&&(h.isCompleted=!0,t._receiptDetailCompleteMap.set(i,!0)),0===d?h.readUserIDList=r.map((function(e){return e.userID})):1===d&&(h.unreadUserIDList=s.map((function(e){return e.userID}))),we.log("".concat(u," ok")),er(h)})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];f.setError(e,o,a).end()})),we.warn("".concat(u," failed. error:"),e),lr(e)}))}},{key:"setMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageSeq,a="".concat(this._className,".setMessageRead");we.log("".concat(a," conversationID:").concat(n," lastMessageSeq:").concat(o)),je(o)||we.warn("".concat(a," 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确"));var s=new sa(La);return s.setMessage("".concat(n,"-").concat(o)),this.request({protocolName:ao,requestData:{groupID:n.replace(D.CONV_GROUP,""),messageReadSeq:o}}).then((function(){s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(a," ok."));var e=t.getModule(tn);return e.updateIsReadAfterReadReport({conversationID:n,lastMessageSeq:o}),e.updateUnreadCount(n),er()})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.log("".concat(a," failed. error:"),e),lr(e)}))}},{key:"_computeLastSequence",value:function(e){return e.sequence>0?Promise.resolve(e.sequence):this.getGroupLastSequence(e.groupID)}},{key:"getGroupLastSequence",value:function(e){var t=this,n="".concat(this._className,".getGroupLastSequence"),o=new sa(ss),a=0,s="";if(this.hasLocalGroup(e)){var r=this.getLocalGroupProfile(e),i=r.lastMessage;if(i.lastSequence>0&&!1===i.onlineOnlyFlag)return a=i.lastSequence,s="got lastSequence:".concat(a," from local group profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(n," ").concat(s)),o.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);if(r.nextMessageSeq>1)return a=r.nextMessageSeq-1,s="got lastSequence:".concat(a," from local group profile[nextMessageSeq]. groupID:").concat(e),we.log("".concat(n," ").concat(s)),o.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a)}var c="GROUP".concat(e),u=this.getModule(tn).getLocalConversation(c);if(u&&u.lastMessage.lastSequence&&!1===u.lastMessage.onlineOnlyFlag)return a=u.lastMessage.lastSequence,s="got lastSequence:".concat(a," from local conversation profile[lastMessage.lastSequence]. groupID:").concat(e),we.log("".concat(n," ").concat(s)),o.setNetworkType(this.getNetworkType()).setMessage("".concat(s)).end(),Promise.resolve(a);var l={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(l).then((function(r){var i=r.data.successGroupList;return Pt(i)?we.log("".concat(n," successGroupList is empty. groupID:").concat(e)):(a=i[0].nextMessageSeq-1,s="got lastSequence:".concat(a," from getGroupProfileAdvance. groupID:").concat(e),we.log("".concat(n," ").concat(s))),o.setNetworkType(t.getNetworkType()).setMessage("".concat(s)).end(),a})).catch((function(a){return t.probeNetwork().then((function(t){var n=m(t,2),s=n[0],r=n[1];o.setError(a,s,r).setMessage("get lastSequence failed from getGroupProfileAdvance. groupID:".concat(e)).end()})),we.warn("".concat(n," failed. error:"),a),lr(a)}))}},{key:"isMessageFromOrToAVChatroom",value:function(e){return!!this._AVChatRoomHandler&&this._AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"hasJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.hasJoinedAVChatRoom():0}},{key:"getJoinedAVChatRoom",value:function(){return this._AVChatRoomHandler?this._AVChatRoomHandler.getJoinedAVChatRoom():[]}},{key:"isOnlineMessage",value:function(e,t){return!(!this._canIUseOnlineOnlyFlag(e)||!t||!0!==t.onlineUserOnly)}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var t=this.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==D.CONV_GROUP}},{key:"_onAVChatRoomHistoryMessage",value:function(e){if(!Pt(e)){we.log("".concat(this._className,"._onAVChatRoomHistoryMessage count:").concat(e.length));var t=[];e.forEach((function(e){t.push(r({},e,{isHistoryMessage:1}))})),this.onAVChatRoomMessage(t)}}},{key:"onAVChatRoomMessage",value:function(e){this._AVChatRoomHandler&&this._AVChatRoomHandler.onMessage(e)}},{key:"getGroupSimplifiedInfo",value:function(e){var t=this,n=new sa(cs),o={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["Type","Name"]}};return this.getGroupProfileAdvance(o).then((function(o){var a=o.data.successGroupList;return n.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e," type:").concat(a[0].type)).end(),a[0]})).catch((function(o){t.probeNetwork().then((function(t){var a=m(t,2),s=a[0],r=a[1];n.setError(o,s,r).setMessage("groupID:".concat(e)).end()}))}))}},{key:"setUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.set(e,1)}},{key:"deleteUnjoinedAVChatRoom",value:function(e){this._unjoinedAVChatRoomList.has(e)&&this._unjoinedAVChatRoomList.delete(e)}},{key:"isUnjoinedAVChatRoom",value:function(e){return this._unjoinedAVChatRoomList.has(e)}},{key:"onGroupAttributesUpdated",value:function(e){this._groupAttributesHandler&&this._groupAttributesHandler.onGroupAttributesUpdated(e)}},{key:"updateLocalMainSequenceOnReconnected",value:function(){this._groupAttributesHandler&&this._groupAttributesHandler.updateLocalMainSequenceOnReconnected()}},{key:"initGroupAttributes",value:function(e){return this._groupAttributesHandler.initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._groupAttributesHandler.setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._groupAttributesHandler.deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._groupAttributesHandler.getGroupAttributes(e)}},{key:"reset",value:function(){this.groupMap.clear(),this._unjoinedAVChatRoomList.clear(),this._receiptDetailCompleteMap.clear(),this._commonGroupHandler.reset(),this._groupSystemNoticeHandler.reset(),this._groupTipsHandler.reset(),this._AVChatRoomHandler&&this._AVChatRoomHandler.reset()}}]),a}(vn),Hr=function(){function e(n){t(this,e),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(n)}return o(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&ft(this.memberCustomField,e.memberCustomField),st(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){Je(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){Je(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&ft(this.memberCustomField,e)}}]),e}(),jr=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="GroupMemberModule",o.groupMemberListMap=new Map,o.getInnerEmitterInstance().on(hr,o._onProfileUpdated,_(o)),o}return o(a,[{key:"_onProfileUpdated",value:function(e){for(var t=this,n=e.data,o=function(e){var o=n[e];t.groupMemberListMap.forEach((function(e){e.has(o.userID)&&e.get(o.userID).updateMember({nick:o.nick,avatar:o.avatar})}))},a=0;a<n.length;a++)o(a)}},{key:"deleteGroupMemberList",value:function(e){this.groupMemberListMap.delete(e)}},{key:"getGroupMemberList",value:function(e){var t=this,n=e.groupID,o=e.offset,a=void 0===o?0:o,s=e.count,r=void 0===s?15:s,i="".concat(this._className,".getGroupMemberList"),c=new sa(_s);we.log("".concat(i," groupID:").concat(n," offset:").concat(a," count:").concat(r));var u=0,l={groupID:n,limit:r>100?100:r};vt({groupID:n})?l.next="".concat(a):(l.offset=a,u=a+1);var d=[];return this.request({protocolName:Eo,requestData:l}).then((function(e){var o=e.data,a=o.members,s=o.memberNum,r=o.next,i=void 0===r?void 0:r;if(Je(i)||(u=Pt(i)?0:i),!ze(a)||0===a.length)return u=0,Promise.resolve([]);var c=t.getModule(Qt);return c.hasLocalGroup(n)&&(c.getLocalGroupProfile(n).memberNum=s),d=t._updateLocalGroupMemberMap(n,a),t.getModule(Jt).getUserProfile({userIDList:a.map((function(e){return e.userID})),tagList:[Ue.NICK,Ue.AVATAR]})})).then((function(e){var o=e.data;if(!ze(o)||0===o.length)return ur({memberList:[],offset:u});var a=o.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(n,a),c.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(n," offset:").concat(u," count:").concat(r)).end(),we.log("".concat(i," ok.")),er({memberList:d,offset:u})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),we.error("".concat(i," failed. error:"),e),lr(e)}))}},{key:"getGroupMemberProfile",value:function(e){var t=this,n="".concat(this._className,".getGroupMemberProfile"),o=new sa(hs);o.setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)),we.log("".concat(n," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var a=e.groupID,s=e.userIDList;return this._getGroupMemberProfileAdvance(r({},e,{userIDList:s})).then((function(e){var n=e.data.members;return ze(n)&&0!==n.length?(t._updateLocalGroupMemberMap(a,n),t.getModule(Jt).getUserProfile({userIDList:n.map((function(e){return e.userID})),tagList:[Ue.NICK,Ue.AVATAR]})):ur([])})).then((function(e){var n=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));t._updateLocalGroupMemberMap(a,n);var r=s.filter((function(e){return t.hasLocalGroupMember(a,e)})).map((function(e){return t.getLocalGroupMemberInfo(a,e)}));return o.setNetworkType(t.getNetworkType()).end(),er({memberList:r})}))}},{key:"addGroupMember",value:function(e){var t=this,n="".concat(this._className,".addGroupMember"),o=e.groupID,a=this.getModule(Qt).getLocalGroupProfile(o),s=a.type,r=new sa(fs);if(r.setMessage("groupID:".concat(o," groupType:").concat(s)),Mt(s)){var i=new rr({code:Bo.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:Ho.CANNOT_ADD_MEMBER_IN_AVCHATROOM});return r.setCode(Bo.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setError(Ho.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setNetworkType(this.getNetworkType()).end(),lr(i)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),we.log("".concat(n," groupID:").concat(o)),this.request({protocolName:Co,requestData:e}).then((function(o){var s=o.data.members;we.log("".concat(n," ok"));var i=s.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),c=s.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),u=s.filter((function(e){return 2===e.result})).map((function(e){return e.userID})),l=s.filter((function(e){return 4===e.result})).map((function(e){return e.userID})),d="groupID:".concat(e.groupID,", ")+"successUserIDList:".concat(i,", ")+"failureUserIDList:".concat(c,", ")+"existedUserIDList:".concat(u,", ")+"overLimitUserIDList:".concat(l);return r.setNetworkType(t.getNetworkType()).setMoreMessage(d).end(),0===i.length?er({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l}):(a.memberCount+=i.length,t._updateConversationGroupProfile(a),er({successUserIDList:i,failureUserIDList:c,existedUserIDList:u,overLimitUserIDList:l,group:a}))})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];r.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"deleteGroupMember",value:function(e){var t=this,n="".concat(this._className,".deleteGroupMember"),o=e.groupID,a=e.userIDList,s=new sa(ms),r="groupID:".concat(o," ").concat(a.length>5?"userIDList.length:".concat(a.length):"userIDList:".concat(a));s.setMessage(r),we.log("".concat(n," groupID:").concat(o," userIDList:"),a);var i=this.getModule(Qt).getLocalGroupProfile(o);return Mt(i.type)?lr(new rr({code:Bo.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:Ho.CANNOT_KICK_MEMBER_IN_AVCHATROOM})):this.request({protocolName:So,requestData:e}).then((function(){return s.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),i.memberCount-=1,t._updateConversationGroupProfile(i),t.deleteLocalGroupMembers(o,a),er({group:i,userIDList:a})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"_updateConversationGroupProfile",value:function(e){this.getModule(tn).updateConversationGroupProfile([e])}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,n=e.groupID,o=e.userID,a=e.muteTime,s="".concat(this._className,".setGroupMemberMuteTime");if(o===this.getMyUserID())return lr(new rr({code:Bo.CANNOT_MUTE_SELF,message:Ho.CANNOT_MUTE_SELF}));we.log("".concat(s," groupID:").concat(n," userID:").concat(o));var r=new sa(Ms);return r.setMessage("groupID:".concat(n," userID:").concat(o," muteTime:").concat(a)),this.modifyGroupMemberInfo({groupID:n,userID:o,muteTime:a}).then((function(e){r.setNetworkType(t.getNetworkType()).end(),we.log("".concat(s," ok"));var o=t.getModule(Qt);return er({group:o.getLocalGroupProfile(n),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];r.setError(e,o,a).end()})),we.error("".concat(s," failed. error:"),e),lr(e)}))}},{key:"setGroupMemberRole",value:function(e){var t=this,n="".concat(this._className,".setGroupMemberRole"),o=e.groupID,a=e.userID,s=e.role,r=this.getModule(Qt).getLocalGroupProfile(o);if(r.selfInfo.role!==D.GRP_MBR_ROLE_OWNER)return lr({code:Bo.NOT_OWNER,message:Ho.NOT_OWNER});if([D.GRP_WORK,D.GRP_AVCHATROOM].includes(r.type))return lr({code:Bo.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:Ho.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM});var i=[D.GRP_MBR_ROLE_ADMIN,D.GRP_MBR_ROLE_MEMBER];if(vt({groupID:o})&&i.push(D.GRP_MBR_ROLE_CUSTOM),i.indexOf(s)<0)return lr({code:Bo.INVALID_MEMBER_ROLE,message:Ho.INVALID_MEMBER_ROLE});if(a===this.getMyUserID())return lr({code:Bo.CANNOT_SET_SELF_MEMBER_ROLE,message:Ho.CANNOT_SET_SELF_MEMBER_ROLE});var c=new sa(ys);return c.setMessage("groupID:".concat(o," userID:").concat(a," role:").concat(s)),we.log("".concat(n," groupID:").concat(o," userID:").concat(a)),this.modifyGroupMemberInfo({groupID:o,userID:a,role:s}).then((function(e){return c.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok")),er({group:r,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,n="".concat(this._className,".setGroupMemberNameCard"),o=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.nameCard;we.log("".concat(n," groupID:").concat(o," userID:").concat(s));var i=new sa(vs);return i.setMessage("groupID:".concat(o," userID:").concat(s," nameCard:").concat(r)),this.modifyGroupMemberInfo({groupID:o,userID:s,nameCard:r}).then((function(e){we.log("".concat(n," ok")),i.setNetworkType(t.getNetworkType()).end();var a=t.getModule(Qt).getLocalGroupProfile(o);return s===t.getMyUserID()&&a&&a.setSelfNameCard(r),er({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];i.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,n="".concat(this._className,".setGroupMemberCustomField"),o=e.groupID,a=e.userID,s=void 0===a?this.getMyUserID():a,r=e.memberCustomField;we.log("".concat(n," groupID:").concat(o," userID:").concat(s));var i=new sa(Is);return i.setMessage("groupID:".concat(o," userID:").concat(s," memberCustomField:").concat(JSON.stringify(r))),this.modifyGroupMemberInfo({groupID:o,userID:s,memberCustomField:r}).then((function(e){i.setNetworkType(t.getNetworkType()).end(),we.log("".concat(n," ok"));var a=t.getModule(Qt).getLocalGroupProfile(o);return er({group:a,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];i.setError(e,o,a).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"modifyGroupMemberInfo",value:function(e){var t=this,n=e.groupID,o=e.userID;return this.request({protocolName:Do,requestData:e}).then((function(){if(t.hasLocalGroupMember(n,o)){var a=t.getLocalGroupMemberInfo(n,o);return Je(e.muteTime)||a.updateMuteUntil(e.muteTime),Je(e.role)||a.updateRole(e.role),Je(e.nameCard)||a.updateNameCard(e.nameCard),Je(e.memberCustomField)||a.updateMemberCustomField(e.memberCustomField),a}return t.getGroupMemberProfile({groupID:n,userIDList:[o]}).then((function(e){return m(e.data.memberList,1)[0]}))}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({protocolName:To,requestData:r({},e,{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var n=this;return ze(t)&&0!==t.length?t.map((function(t){return n.hasLocalGroupMember(e,t.userID)?n.getLocalGroupMemberInfo(e,t.userID).updateMember(t):n.setLocalGroupMember(e,new Hr(t)),n.getLocalGroupMemberInfo(e,t.userID)})):[]}},{key:"deleteLocalGroupMembers",value:function(e,t){var n=this.groupMemberListMap.get(e);n&&t.forEach((function(e){n.delete(e)}))}},{key:"getLocalGroupMemberInfo",value:function(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}},{key:"setLocalGroupMember",value:function(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{var n=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,n)}}},{key:"getLocalGroupMemberList",value:function(e){return this.groupMemberListMap.get(e)}},{key:"hasLocalGroupMember",value:function(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}},{key:"hasLocalGroupMemberMap",value:function(e){return this.groupMemberListMap.has(e)}},{key:"reset",value:function(){this.groupMemberListMap.clear()}}]),a}(vn),Wr=function(){function e(n){t(this,e),this._userModule=n,this._className="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}return o(e,[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,n=e.userIDList;e.fromAccount=this._userModule.getMyAccount(),n.length>100&&(we.warn("".concat(this._className,".getUserProfile 获取用户资料人数不能超过100人")),n.length=100);for(var o,a=[],s=[],r=0,i=n.length;r<i;r++)o=n[r],this._userModule.isMyFriend(o)&&this._containsAccount(o)?s.push(this._getProfileFromMap(o)):a.push(o);if(0===a.length)return ur(s);e.toAccount=a;var c=e.bFromGetMyProfile||!1,u=[];e.toAccount.forEach((function(e){u.push({toAccount:e,standardSequence:0,customSequence:0})})),e.userItem=u;var l=new sa(Ds);return l.setMessage(n.length>5?"userIDList.length:".concat(n.length):"userIDList:".concat(n)),this._userModule.request({protocolName:An,requestData:e}).then((function(e){l.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(t._className,".getUserProfile ok"));var n=t._handleResponse(e).concat(s);return er(c?n[0]:n)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];l.setError(e,o,a).end()})),we.error("".concat(t._className,".getUserProfile failed. error:"),e),lr(e)}))}},{key:"getMyProfile",value:function(){var e=this._userModule.getMyAccount();if(we.log("".concat(this._className,".getMyProfile myAccount:").concat(e)),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return we.debug("".concat(this._className,".getMyProfile from cache, myProfile:")+JSON.stringify(t)),ur(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,n,o=at.now(),a=e.data.userProfileItem,s=[],r=0,i=a.length;r<i;r++)"@TLS#NOT_FOUND"!==a[r].to&&""!==a[r].to&&(t=a[r].to,n=this._updateMap(t,this._getLatestProfileFromResponse(t,a[r].profileItem)),s.push(n));return we.log("".concat(this._className,"._handleResponse cost ").concat(at.now()-o," ms")),s}},{key:"_getLatestProfileFromResponse",value:function(e,t){var n={};if(n.userID=e,n.profileCustomField=[],!Pt(t))for(var o=0,a=t.length;o<a;o++)if(t[o].tag.indexOf("Tag_Profile_Custom")>-1)n.profileCustomField.push({key:t[o].tag,value:t[o].value});else switch(t[o].tag){case Ue.NICK:n.nick=t[o].value;break;case Ue.GENDER:n.gender=t[o].value;break;case Ue.BIRTHDAY:n.birthday=t[o].value;break;case Ue.LOCATION:n.location=t[o].value;break;case Ue.SELFSIGNATURE:n.selfSignature=t[o].value;break;case Ue.ALLOWTYPE:n.allowType=t[o].value;break;case Ue.LANGUAGE:n.language=t[o].value;break;case Ue.AVATAR:n.avatar=t[o].value;break;case Ue.MESSAGESETTINGS:n.messageSettings=t[o].value;break;case Ue.ADMINFORBIDTYPE:n.adminForbidType=t[o].value;break;case Ue.LEVEL:n.level=t[o].value;break;case Ue.ROLE:n.role=t[o].value;break;default:we.warn("".concat(this._className,"._handleResponse unknown tag:"),t[o].tag,t[o].value)}return n}},{key:"updateMyProfile",value:function(e){var t=this,n="".concat(this._className,".updateMyProfile"),o=new sa(Ns);o.setMessage(JSON.stringify(e));var a=(new Tr).validate(e);if(!a.valid)return o.setCode(Bo.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("".concat(n," info:").concat(a.tips)).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(n," info:").concat(a.tips,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),lr({code:Bo.UPDATE_PROFILE_INVALID_PARAM,message:Ho.UPDATE_PROFILE_INVALID_PARAM});var s=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&("profileCustomField"===r?e.profileCustomField.forEach((function(e){s.push({tag:e.key,value:e.value})})):s.push({tag:Ue[r.toUpperCase()],value:e[r]}));return 0===s.length?(o.setCode(Bo.UPDATE_PROFILE_NO_KEY).setMoreMessage(Ho.UPDATE_PROFILE_NO_KEY).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(n," info:").concat(Ho.UPDATE_PROFILE_NO_KEY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#updateMyProfile")),lr({code:Bo.UPDATE_PROFILE_NO_KEY,message:Ho.UPDATE_PROFILE_NO_KEY})):this._userModule.request({protocolName:kn,requestData:{fromAccount:this._userModule.getMyAccount(),profileItem:s}}).then((function(a){o.setNetworkType(t._userModule.getNetworkType()).end(),we.info("".concat(n," ok"));var s=t._updateMap(t._userModule.getMyAccount(),e);return t._userModule.emitOuterEvent(S.PROFILE_UPDATED,[s]),ur(s)})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!Pt(t)){var n,o,a=t.length;we.debug("".concat(this._className,".onProfileModified count:").concat(a," dataList:"),e.dataList);for(var s=[],r=0;r<a;r++)n=t[r].userID,o=this._updateMap(n,this._getLatestProfileFromResponse(n,t[r].profileList)),s.push(o);s.length>0&&(this._userModule.emitInnerEvent(hr,s),this._userModule.emitOuterEvent(S.PROFILE_UPDATED,s))}}},{key:"_fillMap",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),n=0,o=e.length;n<o;n++)t-e[n].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[n].userID,e[n]);we.log("".concat(this._className,"._fillMap from cache, map.size:").concat(this.accountProfileMap.size))}}},{key:"_updateMap",value:function(e,t){var n,o=Date.now();return this._containsAccount(e)?(n=this._getProfileFromMap(e),t.profileCustomField&&ft(n.profileCustomField,t.profileCustomField),st(n,t,["profileCustomField"]),n.lastUpdatedTime=o):(n=new Tr(t),(this._userModule.isMyFriend(e)||e===this._userModule.getMyAccount())&&(n.lastUpdatedTime=o,this.accountProfileMap.set(e,n))),this._flushMap(e===this._userModule.getMyAccount()),n}},{key:"_flushMap",value:function(e){var t=M(this.accountProfileMap.values()),n=this._userModule.getStorageModule();we.debug("".concat(this._className,"._flushMap length:").concat(t.length," flushAtOnce:").concat(e)),n.setItem(this.TAG,t,e)}},{key:"_containsAccount",value:function(e){return this.accountProfileMap.has(e)}},{key:"_getProfileFromMap",value:function(e){return this.accountProfileMap.get(e)}},{key:"_getCachedProfiles",value:function(){var e=this._userModule.getStorageModule().getItem(this.TAG);return Pt(e)?[]:e}},{key:"onConversationsProfileUpdated",value:function(e){for(var t,n,o,a=[],s=0,r=e.length;s<r;s++)n=(t=e[s]).userID,this._userModule.isMyFriend(n)||(this._containsAccount(n)?(o=this._getProfileFromMap(n),st(o,t)>0&&a.push(n)):a.push(t.userID));0!==a.length&&(we.info("".concat(this._className,".onConversationsProfileUpdated toAccountList:").concat(a)),this.getUserProfile({userIDList:a}))}},{key:"getNickAndAvatarByUserID",value:function(e){if(this._containsAccount(e)){var t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),e}(),Yr=function e(n){t(this,e),Pt||(this.userID=n.userID||"",this.timeStamp=n.timeStamp||0)},$r=function(){function e(n){t(this,e),this._userModule=n,this._className="BlacklistHandler",this._blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.currentSequence=0}return o(e,[{key:"getLocalBlacklist",value:function(){return M(this._blacklistMap.keys())}},{key:"getBlacklist",value:function(){var e=this,t="".concat(this._className,".getBlacklist"),n={fromAccount:this._userModule.getMyAccount(),maxLimited:this.maxLimited,startIndex:0,lastSequence:this.currentSequence},o=new sa(As);return this._userModule.request({protocolName:Rn,requestData:n}).then((function(n){var a=n.data,s=a.blackListItem,r=a.currentSequence,i=Pt(s)?0:s.length;o.setNetworkType(e._userModule.getNetworkType()).setMessage("blackList count:".concat(i)).end(),we.info("".concat(t," ok")),e.currentSequence=r,e._handleResponse(s,!0),e._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(e._blacklistMap.keys()))})).catch((function(n){return e._userModule.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];o.setError(n,a,s).end()})),we.error("".concat(t," failed. error:"),n),lr(n)}))}},{key:"addBlacklist",value:function(e){var t=this,n="".concat(this._className,".addBlacklist"),o=new sa(ks);if(!ze(e.userIDList))return o.setCode(Bo.ADD_BLACKLIST_INVALID_PARAM).setMessage(Ho.ADD_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(n," options.userIDList 必需是数组")),lr({code:Bo.ADD_BLACKLIST_INVALID_PARAM,message:Ho.ADD_BLACKLIST_INVALID_PARAM});var a=this._userModule.getMyAccount();return 1===e.userIDList.length&&e.userIDList[0]===a?(o.setCode(Bo.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(Ho.CANNOT_ADD_SELF_TO_BLACKLIST).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(n," 不能把自己拉黑")),lr({code:Bo.CANNOT_ADD_SELF_TO_BLACKLIST,message:Ho.CANNOT_ADD_SELF_TO_BLACKLIST})):(e.userIDList.includes(a)&&(e.userIDList=e.userIDList.filter((function(e){return e!==a})),we.warn("".concat(n," 不能把自己拉黑,已过滤"))),e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList,this._userModule.request({protocolName:On,requestData:e}).then((function(a){return o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(n," ok")),t._handleResponse(a.resultItem,!0),er(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)})))}},{key:"_handleResponse",value:function(e,t){if(!Pt(e))for(var n,o,a,s=0,r=e.length;s<r;s++)o=e[s].to,a=e[s].resultCode,(Je(a)||0===a)&&(t?((n=this._blacklistMap.has(o)?this._blacklistMap.get(o):new Yr).userID=o,!Pt(e[s].addBlackTimeStamp)&&(n.timeStamp=e[s].addBlackTimeStamp),this._blacklistMap.set(o,n)):this._blacklistMap.has(o)&&(n=this._blacklistMap.get(o),this._blacklistMap.delete(o)));we.log("".concat(this._className,"._handleResponse total:").concat(this._blacklistMap.size," bAdd:").concat(t))}},{key:"deleteBlacklist",value:function(e){var t=this,n="".concat(this._className,".deleteBlacklist"),o=new sa(Rs);return ze(e.userIDList)?(e.fromAccount=this._userModule.getMyAccount(),e.toAccount=e.userIDList,this._userModule.request({protocolName:Ln,requestData:e}).then((function(a){return o.setNetworkType(t._userModule.getNetworkType()).setMessage(e.userIDList.length>5?"userIDList.length:".concat(e.userIDList.length):"userIDList:".concat(e.userIDList)).end(),we.info("".concat(n," ok")),t._handleResponse(a.data.resultItem,!1),er(M(t._blacklistMap.keys()))})).catch((function(e){return t._userModule.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),we.error("".concat(n," failed. error:"),e),lr(e)}))):(o.setCode(Bo.DEL_BLACKLIST_INVALID_PARAM).setMessage(Ho.DEL_BLACKLIST_INVALID_PARAM).setNetworkType(this._userModule.getNetworkType()).end(),we.error("".concat(n," options.userIDList 必需是数组")),lr({code:Bo.DEL_BLACKLIST_INVALID_PARAM,message:Ho.DEL_BLACKLIST_INVALID_PARAM}))}},{key:"onAccountDeleted",value:function(e){for(var t,n=[],o=0,a=e.length;o<a;o++)t=e[o],this._blacklistMap.has(t)&&(this._blacklistMap.delete(t),n.push(t));n.length>0&&(we.log("".concat(this._className,".onAccountDeleted count:").concat(n.length," userIDList:"),n),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"onAccountAdded",value:function(e){for(var t,n=[],o=0,a=e.length;o<a;o++)t=e[o],this._blacklistMap.has(t)||(this._blacklistMap.set(t,new Yr({userID:t})),n.push(t));n.length>0&&(we.log("".concat(this._className,".onAccountAdded count:").concat(n.length," userIDList:"),n),this._userModule.emitOuterEvent(S.BLACKLIST_UPDATED,M(this._blacklistMap.keys())))}},{key:"reset",value:function(){this._blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.currentSequence=0}}]),e}(),zr=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="UserModule",o._profileHandler=new Wr(_(o)),o._blacklistHandler=new $r(_(o)),o.getInnerEmitterInstance().on(gr,o.onContextUpdated,_(o)),o}return o(a,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){var t=e.dataList;if(!Pt(t)){var n=[];t.forEach((function(e){e.blackListDelAccount&&n.push.apply(n,M(e.blackListDelAccount))})),n.length>0&&this._blacklistHandler.onAccountDeleted(n);var o=[];t.forEach((function(e){e.blackListAddAccount&&o.push.apply(o,M(e.blackListAddAccount))})),o.length>0&&this._blacklistHandler.onAccountAdded(o)}}},{key:"onConversationsProfileUpdated",value:function(e){this._profileHandler.onConversationsProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.getModule(on)}},{key:"isMyFriend",value:function(e){var t=this.getModule(Zt);return!!t&&t.isMyFriend(e)}},{key:"getUserProfile",value:function(e){return this._profileHandler.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._profileHandler.updateMyProfile(e)}},{key:"getNickAndAvatarByUserID",value:function(e){return this._profileHandler.getNickAndAvatarByUserID(e)}},{key:"getLocalBlacklist",value:function(){var e=this._blacklistHandler.getLocalBlacklist();return ur(e)}},{key:"addBlacklist",value:function(e){return this._blacklistHandler.addBlacklist(e)}},{key:"deleteBlacklist",value:function(e){return this._blacklistHandler.deleteBlacklist(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._profileHandler.reset(),this._blacklistHandler.reset()}}]),a}(vn),Jr=function(){function e(n,o){t(this,e),this._moduleManager=n,this._isLoggedIn=!1,this._SDKAppID=o.SDKAppID,this._userID=o.userID||"",this._userSig=o.userSig||"",this._version="2.18.0",this._a2Key="",this._tinyID="",this._contentType="json",this._unlimitedAVChatRoom=o.unlimitedAVChatRoom,this._scene=o.scene||"",this._oversea=o.oversea,this._instanceID=o.instanceID,this._statusInstanceID=0,this._isDevMode=o.devMode,this._proxyServer=o.proxyServer}return o(e,[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isSingaporeSite",value:function(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7}},{key:"isKoreaSite",value:function(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7}},{key:"isGermanySite",value:function(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7}},{key:"isIndiaSite",value:function(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserID",value:function(e){this._userID=e}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getScene",value:function(){return this._isTUIKit()?"tuikit":this._scene}},{key:"getInstanceID",value:function(){return this._instanceID}},{key:"getStatusInstanceID",value:function(){return this._statusInstanceID}},{key:"setStatusInstanceID",value:function(e){this._statusInstanceID=e}},{key:"getVersion",value:function(){return this._version}},{key:"getA2Key",value:function(){return this._a2Key}},{key:"setA2Key",value:function(e){this._a2Key=e}},{key:"getContentType",value:function(){return this._contentType}},{key:"getProxyServer",value:function(){return this._proxyServer}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,n=!1,o=!1,a=[];te&&(a=Object.keys(oe)),ne&&(a=ee?Object.keys(uni):Object.keys(window));for(var s=0,r=a.length;s<r;s++)if(a[s].toLowerCase().includes("uikit")){e=!0;break}if(a=null,te&&Qe(getApp)){var i=getApp().globalData;$e(i)&&!0===i.isTUIKit&&(t=!0)}!0===this._moduleManager.getModule(on).getStorageSync("TIM_".concat(this._SDKAppID,"_isTUIKit"))&&(n=!0);var c=null;if($&&"undefined"==typeof uni&&__wxConfig&&(c=__wxConfig.pages),z&&"undefined"==typeof uni&&__qqConfig&&(c=__qqConfig.pages),ze(c)&&c.length>0){for(var u=0,l=c.length;u<l;u++)if(c[u].toLowerCase().includes("tui")){o=!0;break}c=null}return e||t||n||o}},{key:"reset",value:function(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._statusInstanceID=0}}]),e}(),Xr=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="SignModule",o._helloInterval=120,o._lastLoginTs=0,o._lastWsHelloTs=0,fr.mixin(_(o)),o}return o(a,[{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}},{key:"login",value:function(e){if(this.isLoggedIn()){var t="您已经登录账号".concat(e.userID,"!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。");return we.warn(t),ur({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return we.warn("您正在尝试登录账号".concat(e.userID,"!请勿重复登录。")),lr({code:Bo.REPEAT_LOGIN,message:Ho.REPEAT_LOGIN});we.log("".concat(this._className,".login userID:").concat(e.userID));var n=this._checkLoginInfo(e);if(0!==n.code)return lr(n);var o=this.getModule(nn),a=e.userID,s=e.userSig;return o.setUserID(a),o.setUserSig(s),this.getModule(dn).updateProtocolConfig(),this._login()}},{key:"_login",value:function(){var e=this,t=this.getModule(nn),n=t.getScene(),o=new sa(ca);return o.setMessage("".concat(n)).setMoreMessage("identifier:".concat(this.getMyUserID())),ee?"tuikit"===n?o.setUIPlatform(4):o.setUIPlatform(3):te?"tuikit"===n?o.setUIPlatform(12):o.setUIPlatform(11):ne&&("tuikit"===n?o.setUIPlatform(14):o.setUIPlatform(13)),this._lastLoginTs=Date.now(),this.request({protocolName:yn}).then((function(a){e._lastLoginTs=0;var s=Date.now(),r=null,i=a.data,c=i.a2Key,u=i.tinyID,l=i.helloInterval,d=i.instanceID,p=i.timeStamp;we.log("".concat(e._className,".login ok. scene:").concat(n," helloInterval:").concat(l," instanceID:").concat(d," timeStamp:").concat(p));var g=1e3*p,_=s-o.getStartTs(),h=g+parseInt(_/2)-s,f=o.getStartTs()+h;if(o.start(f),function(e,t){Ae=t;var n=new Date;n.setTime(e),we.info("baseTime from server: ".concat(n," offset: ").concat(Ae))}(g,h),!u)throw r=new rr({code:Bo.NO_TINYID,message:Ho.NO_TINYID}),o.setError(r,!0,e.getNetworkType()).end(),r;if(!c)throw r=new rr({code:Bo.NO_A2KEY,message:Ho.NO_A2KEY}),o.setError(r,!0,e.getNetworkType()).end(),r;return o.setNetworkType(e.getNetworkType()).setMoreMessage("helloInterval:".concat(l," instanceID:").concat(d," offset:").concat(h)).end(),t.setA2Key(c),t.setTinyID(u),t.setStatusInstanceID(d),e.getModule(dn).updateProtocolConfig(),e.emitInnerEvent(gr),e._helloInterval=l,e.triggerReady(),e._fetchCloudControlConfig(),a})).catch((function(t){return e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end(!0)})),e._moduleManager.setNotReadyReason(Bo.LOGIN_FAILED),we.error("".concat(e._className,".login failed. error:"),t),e._lastLoginTs=0,e._moduleManager.onLoginFailed(),lr(t)}))}},{key:"logout",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!this.isLoggedIn())return lr({code:Bo.USER_NOT_LOGGED_IN,message:Ho.USER_NOT_LOGGED_IN});var n=new sa(ua);return n.setNetworkType(this.getNetworkType()).setMessage("identifier:".concat(this.getMyUserID())).end(!0),we.info("".concat(this._className,".logout type:").concat(t)),0===t&&this._moduleManager.setNotReadyReason(Bo.LOGGED_OUT),this.request({protocolName:In,requestData:{type:t}}).then((function(){return e.resetReady(),ur({})})).catch((function(t){return we.error("".concat(e._className,"._logout error:"),t),e.resetReady(),ur({})}))}},{key:"_fetchCloudControlConfig",value:function(){this.getModule(_n).fetchConfig()}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.request({protocolName:En}).catch((function(t){we.warn("".concat(e._className,"._hello error:"),t)}))}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0,n="";return Pt(this.getModule(nn).getSDKAppID())?(t=Bo.NO_SDKAPPID,n=Ho.NO_SDKAPPID):Pt(e.userID)?(t=Bo.NO_IDENTIFIER,n=Ho.NO_IDENTIFIER):Pt(e.userSig)&&(t=Bo.NO_USERSIG,n=Ho.NO_USERSIG),{code:t,message:n}}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new sa(la).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_ACCOUNT}),t._moduleManager.setNotReadyReason(Bo.KICKED_OUT_MULT_ACCOUNT),t._moduleManager.reset()}))}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new sa(la).setNetworkType(this.getNetworkType()).setMessage("type:".concat(D.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),we.warn("".concat(this._className,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_MULT_DEVICE}),t._moduleManager.setNotReadyReason(Bo.KICKED_OUT_MULT_DEVICE),t._moduleManager.reset()}))}},{key:"onUserSigExpired",value:function(){new sa(la).setNetworkType(this.getNetworkType()).setMessage(D.KICKED_OUT_USERSIG_EXPIRED).end(!0),we.warn("".concat(this._className,".onUserSigExpired: userSig 签名过期被踢下线")),0!==this.getModule(nn).getStatusInstanceID()&&(this.emitOuterEvent(S.KICKED_OUT,{type:D.KICKED_OUT_USERSIG_EXPIRED}),this._moduleManager.setNotReadyReason(Bo.KICKED_OUT_USERSIG_EXPIRED),this._moduleManager.reset())}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0}}]),a}(vn);function Qr(){return null}var Zr=function(){function e(n){t(this,e),this._moduleManager=n,this._className="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}return o(e,[{key:"_errorTolerantHandle",value:function(){te||!Je(window)&&!Je(window.localStorage)||(this.getItem=Qr,this.setItem=Qr,this.removeItem=Qr,this.clear=Qr)}},{key:"onCheckTimer",value:function(e){if(e%20==0){if(0===this._storageQueue.size)return;this._doFlush()}}},{key:"_doFlush",value:function(){try{var e,t=C(this._storageQueue);try{for(t.s();!(e=t.n()).done;){var n=m(e.value,2),o=n[0],a=n[1];this._setStorageSync(this._getKey(o),a)}}catch(s){t.e(s)}finally{t.f()}this._storageQueue.clear()}catch(r){we.warn("".concat(this._className,"._doFlush error:"),r)}}},{key:"_getPrefix",value:function(){var e=this._moduleManager.getModule(nn);return"TIM_".concat(e.getSDKAppID(),"_").concat(e.getUserID(),"_")}},{key:"_getKey",value:function(e){return"".concat(this._getPrefix()).concat(e)}},{key:"getItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;return this.getStorageSync(n)}catch(o){return we.warn("".concat(this._className,".getItem error:"),o),{}}}},{key:"setItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(n){var a=o?this._getKey(e):e;this._setStorageSync(a,t)}else this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{te?oe.clearStorageSync():localStorage&&localStorage.clear()}catch(e){we.warn("".concat(this._className,".clear error:"),e)}}},{key:"removeItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;this._removeStorageSync(n)}catch(o){we.warn("".concat(this._className,".removeItem error:"),o)}}},{key:"getSize",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var o={size:0,limitSize:5242880,unit:n};if(Object.defineProperty(o,"leftSize",{enumerable:!0,get:function(){return o.limitSize-o.size}}),te&&(o.limitSize=1024*oe.getStorageInfoSync().limitSize),e)o.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(te){var a=oe.getStorageInfoSync(),s=a.keys;s.forEach((function(e){o.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length}))}else if(localStorage)for(var r in localStorage)localStorage.hasOwnProperty(r)&&(o.size+=localStorage.getItem(r).length+r.length);return this._convertUnit(o)}catch(i){we.warn("".concat(this._className," error:"),i)}}},{key:"_convertUnit",value:function(e){var t={},n=e.unit;for(var o in t.unit=n,e)"number"==typeof e[o]&&("kb"===n.toLowerCase()?t[o]=Math.round(e[o]/1024):"mb"===n.toLowerCase()?t[o]=Math.round(e[o]/1024/1024):t[o]=e[o]);return t}},{key:"_setStorageSync",value:function(e,t){te?Q?my.setStorageSync({key:e,data:t}):oe.setStorageSync(e,t):localStorage&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return te?Q?my.getStorageSync({key:e}).data:oe.getStorageSync(e):localStorage?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){te?Q?my.removeStorageSync({key:e}):oe.removeStorageSync(e):localStorage&&localStorage.removeItem(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._doFlush()}}]),e}(),ei=function(){function e(n){t(this,e),this._className="SSOLogBody",this._report=[]}return o(e,[{key:"pushIn",value:function(e){we.debug("".concat(this._className,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;ze(e)&&0!==e.length&&(we.debug("".concat(this._className,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,M(e)))}},{key:"getLogsNumInMemory",value:function(){return this._report.length}},{key:"isEmpty",value:function(){return 0===this._report.length}},{key:"_reset",value:function(){this._report.length=0,this._report=[]}},{key:"getLogsInMemory",value:function(){var e=this._report.slice();return this._reset(),e}}]),e}(),ti=function(e){var t=e.getModule(nn);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:ke()}},ni=function(e){i(a,e);var n=f(a);function a(e){var o;t(this,a),(o=n.call(this,e))._className="EventStatModule",o.TAG="im-ssolog-event",o._reportBody=new ei,o.MIN_THRESHOLD=20,o.MAX_THRESHOLD=100,o.WAITING_TIME=6e4,o.REPORT_LEVEL=[4,5,6],o.REPORT_SDKAPPID_BLACKLIST=[],o.REPORT_TINYID_WHITELIST=[],o._lastReportTime=Date.now();var s=o.getInnerEmitterInstance();return s.on(gr,o._onLoginSuccess,_(o)),s.on(_r,o._onCloudConfigUpdated,_(o)),o}return o(a,[{key:"reportAtOnce",value:function(){we.debug("".concat(this._className,".reportAtOnce")),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.getModule(on),n=t.getItem(this.TAG,!1);!Pt(n)&&Qe(n.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess get ssolog in storage, count:").concat(n.length)),n.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),n=this.getCloudConfig("evt_rpt_level"),o=this.getCloudConfig("evt_rpt_sdkappid_bl"),a=this.getCloudConfig("evt_rpt_tinyid_wl");Je(e)||(this.MIN_THRESHOLD=Number(e)),Je(t)||(this.WAITING_TIME=Number(t)),Je(n)||(this.REPORT_LEVEL=n.split(",").map((function(e){return Number(e)}))),Je(o)||(this.REPORT_SDKAPPID_BLACKLIST=o.split(",").map((function(e){return Number(e)}))),Je(a)||(this.REPORT_TINYID_WHITELIST=a.split(","))}},{key:"pushIn",value:function(e){e instanceof sa&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}},{key:"onCheckTimer",value:function(){Date.now()<this._lastReportTime+this.WAITING_TIME||this._reportBody.isEmpty()||this._report()}},{key:"_filterLogs",value:function(e){var t=this,n=this.getModule(nn),o=n.getSDKAppID(),a=n.getTinyID();return Ot(this.REPORT_SDKAPPID_BLACKLIST,o)&&!Lt(this.REPORT_TINYID_WHITELIST,a)?[]:e.filter((function(e){return t.REPORT_LEVEL.includes(e.level)}))}},{key:"_report",value:function(){var e=this;if(!this._reportBody.isEmpty()){var t=this._reportBody.getLogsInMemory(),n=this._filterLogs(t);if(0!==n.length){var o={header:ti(this),event:n};this.request({protocolName:Ro,requestData:r({},o)}).then((function(){e._lastReportTime=Date.now()})).catch((function(n){we.warn("".concat(e._className,".report failed. networkType:").concat(e.getNetworkType()," error:"),n),e._reportBody.backfill(t),e._reportBody.getLogsNumInMemory()>e.MAX_THRESHOLD&&e._flushAtOnce()}))}else this._lastReportTime=Date.now()}}},{key:"_flushAtOnce",value:function(){var e=this.getModule(on),t=e.getItem(this.TAG,!1),n=this._reportBody.getLogsInMemory();if(Pt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1);else{var o=n.concat(t);o.length>this.MAX_THRESHOLD&&(o=o.slice(0,this.MAX_THRESHOLD)),we.log("".concat(this._className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1)}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}]),a}(vn),oi="none",ai="online",si=function(){function e(n){t(this,e),this._moduleManager=n,this._networkType="",this._className="NetMonitorModule",this.MAX_WAIT_TIME=3e3,this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null}return o(e,[{key:"start",value:function(){var e=this;te?(oe.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===oi?we.warn("".concat(e._className,".start no network, please check!")):we.info("".concat(e._className,".start networkType:").concat(t.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),oe.onNetworkStatusChange(this._mpNetworkStatusCallback)):(this._networkType=ai,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window&&(window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback)))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:ai})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:oi})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,n=e.networkType,o=!1;t?(we.info("".concat(this._className,"._onNetworkStatusChange previousNetworkType:").concat(this._networkType," currentNetworkType:").concat(n)),this._networkType!==n&&(o=!0,this._moduleManager.getModule(pn).reConnect(!0))):this._networkType!==n&&(o=!0,we.warn("".concat(this._className,"._onNetworkStatusChange no network, please check!")));o&&(new sa(ma).setMessage("isConnected:".concat(t," previousNetworkType:").concat(this._networkType," networkType:").concat(n)).end(),this._networkType=n)}},{key:"probe",value:function(){var e=this;return new Promise((function(t,n){if(te)oe.getNetworkType({success:function(n){e._networkType=n.networkType,n.networkType===oi?(we.warn("".concat(e._className,".probe no network, please check!")),t([!1,n.networkType])):(we.info("".concat(e._className,".probe networkType:").concat(n.networkType)),t([!0,n.networkType]))}});else if(window&&window.fetch)fetch("".concat(gt(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())).then((function(e){e.ok?t([!0,ai]):t([!1,oi])})).catch((function(e){t([!1,oi])}));else{var o=new XMLHttpRequest,a=setTimeout((function(){we.warn("".concat(e._className,".probe fetch timeout. Probably no network, please check!")),o.abort(),e._networkType=oi,t([!1,oi])}),e.MAX_WAIT_TIME);o.onreadystatechange=function(){4===o.readyState&&(clearTimeout(a),200===o.status||304===o.status||514===o.status?(this._networkType=ai,t([!0,ai])):(we.warn("".concat(this.className,".probe fetch status:").concat(o.status,". Probably no network, please check!")),this._networkType=oi,t([!1,oi])))},o.open("GET","".concat(gt(),"//web.sdk.qcloud.com/im/assets/speed.xml?random=").concat(Math.random())),o.send()}}))}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),te?null!==this._mpNetworkStatusCallback&&(oe.offNetworkStatusChange&&(Z||J?oe.offNetworkStatusChange(this._mpNetworkStatusCallback):oe.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))}}]),e}(),ri=k((function(e){var t=Object.prototype.hasOwnProperty,n="~";function o(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,o,s,r){if("function"!=typeof o)throw new TypeError("The listener must be a function");var i=new a(o,s||e,r),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function i(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,o,a=[];if(0===this._eventsCount)return a;for(o in e=this._events)t.call(e,o)&&a.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},i.prototype.listeners=function(e){var t=n?n+e:e,o=this._events[t];if(!o)return[];if(o.fn)return[o.fn];for(var a=0,s=o.length,r=new Array(s);a<s;a++)r[a]=o[a].fn;return r},i.prototype.listenerCount=function(e){var t=n?n+e:e,o=this._events[t];return o?o.fn?1:o.length:0},i.prototype.emit=function(e,t,o,a,s,r){var i=n?n+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,o),!0;case 4:return l.fn.call(l.context,t,o,a),!0;case 5:return l.fn.call(l.context,t,o,a,s),!0;case 6:return l.fn.call(l.context,t,o,a,s,r),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var p,g=l.length;for(u=0;u<g;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,o);break;case 4:l[u].fn.call(l[u].context,t,o,a);break;default:if(!c)for(p=1,c=new Array(d-1);p<d;p++)c[p-1]=arguments[p];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,o,a){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return r(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||a&&!i.once||o&&i.context!==o||r(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||a&&!i[c].once||o&&i[c].context!==o)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:r(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&r(this,t)):(this._events=new o,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i})),ii=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="BigDataChannelModule",o.FILETYPE={SOUND:2106,FILE:2107,VIDEO:2113},o._bdh_download_server="grouptalk.c2c.qq.com",o._BDHBizID=10001,o._authKey="",o._expireTime=0,o.getInnerEmitterInstance().on(gr,o._getAuthKey,_(o)),o}return o(a,[{key:"_getAuthKey",value:function(){var e=this;this.request({protocolName:Sn}).then((function(t){t.data.authKey&&(e._authKey=t.data.authKey,e._expireTime=parseInt(t.data.expireTime))}))}},{key:"_isFromOlderVersion",value:function(e){return!(!e.content||2===e.content.downloadFlag)}},{key:"parseElements",value:function(e,t){if(!ze(e)||!t)return[];for(var n=[],o=null,a=0;a<e.length;a++)o=e[a],this._needParse(o)?n.push(this._parseElement(o,t)):n.push(e[a]);return n}},{key:"_needParse",value:function(e){return!e.cloudCustomData&&!(!this._isFromOlderVersion(e)||e.type!==D.MSG_AUDIO&&e.type!==D.MSG_FILE&&e.type!==D.MSG_VIDEO)}},{key:"_parseElement",value:function(e,t){switch(e.type){case D.MSG_AUDIO:return this._parseAudioElement(e,t);case D.MSG_FILE:return this._parseFileElement(e,t);case D.MSG_VIDEO:return this._parseVideoElement(e,t)}}},{key:"_parseAudioElement",value:function(e,t){return e.content.url=this._genAudioUrl(e.content.uuid,t),e}},{key:"_parseFileElement",value:function(e,t){return e.content.url=this._genFileUrl(e.content.uuid,t,e.content.fileName),e}},{key:"_parseVideoElement",value:function(e,t){return e.content.url=this._genVideoUrl(e.content.uuid,t),e}},{key:"_genAudioUrl",value:function(e,t){if(""===this._authKey)return we.warn("".concat(this._className,"._genAudioUrl no authKey!")),"";var n=this.getModule(nn).getSDKAppID();return"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(n,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.SOUND,"&openid=").concat(t,"&ver=0")}},{key:"_genFileUrl",value:function(e,t,n){if(""===this._authKey)return we.warn("".concat(this._className,"._genFileUrl no authKey!")),"";n||(n="".concat(Math.floor(1e5*Math.random()),"-").concat(Date.now()));var o=this.getModule(nn).getSDKAppID();return"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(o,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.FILE,"&openid=").concat(t,"&ver=0&filename=").concat(encodeURIComponent(n))}},{key:"_genVideoUrl",value:function(e,t){if(""===this._authKey)return we.warn("".concat(this._className,"._genVideoUrl no authKey!")),"";var n=this.getModule(nn).getSDKAppID();return"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(n,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.VIDEO,"&openid=").concat(t,"&ver=0")}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._authKey="",this.expireTime=0}}]),a}(vn),ci=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="UploadModule",o.TIMUploadPlugin=null,o.timUploadPlugin=null,o.COSSDK=null,o._cosUploadMethod=null,o.expiredTimeLimit=600,o.appid=0,o.bucketName="",o.ciUrl="",o.directory="",o.downloadUrl="",o.uploadUrl="",o.region="ap-shanghai",o.cos=null,o.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},o.uploadFileType="",o.duration=900,o.tryCount=0,o.getInnerEmitterInstance().on(gr,o._init,_(o)),o}return o(a,[{key:"_init",value:function(){var e="".concat(this._className,"._init"),t=this.getModule(un);if(this.TIMUploadPlugin=t.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin)this._initUploaderMethod();else{var n=te?"cos-wx-sdk":"cos-js-sdk";this.COSSDK=t.getPlugin(n),this.COSSDK?(this._getAuthorizationKey(),we.warn("".concat(e," v2.9.2起推荐使用 tim-upload-plugin 代替 ").concat(n,",上传更快更安全。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin"))):we.warn("".concat(e," 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin"))}}},{key:"_getAuthorizationKey",value:function(){var e=this,t=new sa(Ma),n=Math.ceil(Date.now()/1e3);this.request({protocolName:No,requestData:{duration:this.expiredTimeLimit}}).then((function(o){var a=o.data;we.log("".concat(e._className,"._getAuthorizationKey ok. data:"),a);var s=a.expiredTime-n;t.setMessage("requestId:".concat(a.requestId," requestTime:").concat(n," expiredTime:").concat(a.expiredTime," diff:").concat(s,"s")).setNetworkType(e.getNetworkType()).end(),!te&&a.region&&(e.region=a.region),e.appid=a.appid,e.bucketName=a.bucketName,e.ciUrl=a.ciUrl,e.directory=a.directory,e.downloadUrl=a.downloadUrl,e.uploadUrl=a.uploadUrl,e.cosOptions={secretId:a.secretId,secretKey:a.secretKey,sessionToken:a.sessionToken,expiredTime:a.expiredTime},we.log("".concat(e._className,"._getAuthorizationKey ok. region:").concat(e.region," bucketName:").concat(e.bucketName)),e._initUploaderMethod()})).catch((function(n){e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];t.setError(n,a,s).end()})),we.warn("".concat(e._className,"._getAuthorizationKey failed. error:"),n)}))}},{key:"_getCosPreSigUrl",value:function(e){var t=this,n="".concat(this._className,"._getCosPreSigUrl"),o=Math.ceil(Date.now()/1e3),a=new sa(va);return this.request({protocolName:Ao,requestData:{fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration}}).then((function(e){t.tryCount=0;var s=e.data||{},r=s.expiredTime-o;return we.log("".concat(n," ok. data:"),s),a.setMessage("requestId:".concat(s.requestId," expiredTime:").concat(s.expiredTime," diff:").concat(r,"s")).setNetworkType(t.getNetworkType()).end(),s})).catch((function(o){return-1===o.code&&(o.code=Bo.COS_GET_SIG_FAIL),t.probeNetwork().then((function(e){var t=m(e,2),n=t[0],s=t[1];a.setError(o,n,s).end()})),we.warn("".concat(n," failed. error:"),o),t.tryCount<1?(t.tryCount++,t._getCosPreSigUrl(e)):(t.tryCount=0,lr({code:Bo.COS_GET_SIG_FAIL,message:Ho.COS_GET_SIG_FAIL}))}))}},{key:"_initUploaderMethod",value:function(){var e=this;if(this.TIMUploadPlugin)return this.timUploadPlugin=new this.TIMUploadPlugin,void(this._cosUploadMethod=function(t,n){e.timUploadPlugin.uploadFile(t,n)});this.appid&&(this.cos=te?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=te?function(t,n){e.cos.postObject(t,n)}:function(t,n){e.cos.uploadFiles(t,n)})}},{key:"onCheckTimer",value:function(e){this.COSSDK&&(this.TIMUploadPlugin||this.isLoggedIn()&&e%60==0&&Math.ceil(Date.now()/1e3)>=this.cosOptions.expiredTime-120&&this._getAuthorizationKey())}},{key:"_getAuthorization",value:function(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}},{key:"upload",value:function(e){if(!0===e.getRelayFlag())return Promise.resolve();var t=this.getModule(mn);switch(e.type){case D.MSG_IMAGE:return t.addTotalCount(Xo),this._uploadImage(e);case D.MSG_FILE:return t.addTotalCount(Xo),this._uploadFile(e);case D.MSG_AUDIO:return t.addTotalCount(Xo),this._uploadAudio(e);case D.MSG_VIDEO:return t.addTotalCount(Xo),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var t=this.getModule(zt),n=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadImage({file:o.payload.file,to:o.to,onProgress:function(e){if(n.updatePercent(e),Qe(o.onProgress))try{o.onProgress(e)}catch(t){return lr({code:Bo.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:Ho.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(t){var o=t.location,a=t.fileType,s=t.fileSize,i=t.width,c=t.height,u=_t(o);n.updateImageFormat(a);var l=Nt({originUrl:u,originWidth:i,originHeight:c,min:198}),d=Nt({originUrl:u,originWidth:i,originHeight:c,min:720});return n.updateImageInfoArray([{size:s,url:u,width:i,height:c},r({},d),r({},l)]),e}))}},{key:"_uploadFile",value:function(e){var t=this.getModule(zt),n=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadFile({file:o.payload.file,to:o.to,onProgress:function(e){if(n.updatePercent(e),Qe(o.onProgress))try{o.onProgress(e)}catch(t){return lr({code:Bo.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:Ho.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(t){var o=t.location,a=_t(o);return n.updateFileUrl(a),e}))}},{key:"_uploadAudio",value:function(e){var t=this.getModule(zt),n=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadAudio({file:o.payload.file,to:o.to,onProgress:function(e){if(n.updatePercent(e),Qe(o.onProgress))try{o.onProgress(e)}catch(t){return lr({code:Bo.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:Ho.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(t){var o=t.location,a=_t(o);return n.updateAudioUrl(a),e}))}},{key:"_uploadVideo",value:function(e){var t=this.getModule(zt),n=e.getElements()[0],o=t.getMessageOption(e.clientSequence);return this.doUploadVideo({file:o.payload.file,to:o.to,onProgress:function(e){if(n.updatePercent(e),Qe(o.onProgress))try{o.onProgress(e)}catch(t){return lr({code:Bo.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:Ho.MESSAGE_ONPROGRESS_FUNCTION_ERROR})}}}).then((function(t){var o=t.location,a=t.snapshotInfo,s=_t(o);return n.updateVideoUrl(s),Pt(a)||n.updateSnapshotInfo(a),e}))}},{key:"doUploadImage",value:function(e){if(!e.file)return lr({code:Bo.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:Ho.MESSAGE_IMAGE_SELECT_FILE_FIRST});var t=this._checkImageType(e.file);if(!0!==t)return t;var n=this._checkImageSize(e.file);if(!0!==n)return n;var o=null;return this._setUploadFileType(vr),this.uploadByCOS(e).then((function(e){return o=e,Ct("https://".concat(e.location))})).then((function(e){return o.width=e.width,o.height=e.height,Promise.resolve(o)}))}},{key:"_checkImageType",value:function(e){var t="";return t=te?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),mr.indexOf(t.toLowerCase())>=0||lr({code:Bo.MESSAGE_IMAGE_TYPES_LIMIT,message:Ho.MESSAGE_IMAGE_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=te?e.size:e.files[0].size)?lr({code:Bo.MESSAGE_FILE_IS_EMPTY,message:"".concat(Ho.MESSAGE_FILE_IS_EMPTY)}):t<20971520||lr({code:Bo.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat(Ho.MESSAGE_IMAGE_SIZE_LIMIT)})}},{key:"doUploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?lr(t={code:Bo.MESSAGE_FILE_SIZE_LIMIT,message:Ho.MESSAGE_FILE_SIZE_LIMIT}):0===e.file.files[0].size?(t={code:Bo.MESSAGE_FILE_IS_EMPTY,message:"".concat(Ho.MESSAGE_FILE_IS_EMPTY)},lr(t)):(this._setUploadFileType(Er),this.uploadByCOS(e)):lr(t={code:Bo.MESSAGE_FILE_SELECT_FILE_FIRST,message:Ho.MESSAGE_FILE_SELECT_FILE_FIRST})}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>104857600?lr({code:Bo.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat(Ho.MESSAGE_VIDEO_SIZE_LIMIT)}):0===e.file.videoFile.size?lr({code:Bo.MESSAGE_FILE_IS_EMPTY,message:"".concat(Ho.MESSAGE_FILE_IS_EMPTY)}):-1===Mr.indexOf(e.file.videoFile.type)?lr({code:Bo.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat(Ho.MESSAGE_VIDEO_TYPES_LIMIT)}):(this._setUploadFileType(yr),te?this.handleVideoUpload({file:e.file.videoFile,onProgress:e.onProgress}):ne?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(n,o){t.uploadByCOS(e).then((function(e){n(e)})).catch((function(){t.uploadByCOS(e).then((function(e){n(e)})).catch((function(){o(new rr({code:Bo.MESSAGE_VIDEO_UPLOAD_FAIL,message:Ho.MESSAGE_VIDEO_UPLOAD_FAIL}))}))}))}))}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>20971520?lr(new rr({code:Bo.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat(Ho.MESSAGE_AUDIO_SIZE_LIMIT)})):0===e.file.size?lr(new rr({code:Bo.MESSAGE_FILE_IS_EMPTY,message:"".concat(Ho.MESSAGE_FILE_IS_EMPTY)})):(this._setUploadFileType(Ir),this.uploadByCOS(e)):lr(new rr({code:Bo.MESSAGE_AUDIO_UPLOAD_FAIL,message:Ho.MESSAGE_AUDIO_UPLOAD_FAIL}))}},{key:"uploadByCOS",value:function(e){var t=this,n="".concat(this._className,".uploadByCOS");if(!Qe(this._cosUploadMethod))return we.warn("".concat(n," 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html#registerPlugin")),lr({code:Bo.COS_UNDETECTED,message:Ho.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);var o=new sa(Ia),a=Date.now(),s=this._getFile(e);return new Promise((function(r,i){var c=te?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),u=t;t._cosUploadMethod(c,(function(e,c){var l=Object.create(null);if(c){if(e||ze(c.files)&&c.files[0].error){var d=new rr({code:Bo.MESSAGE_FILE_UPLOAD_FAIL,message:Ho.MESSAGE_FILE_UPLOAD_FAIL});return o.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(n," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&(we.warn("".concat(n," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),void i(d)}l.fileName=s.name,l.fileSize=s.size,l.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),l.location=te?c.Location:c.files[0].data.Location;var p=Date.now()-a,g=u._formatFileSize(s.size),_=u._formatSpeed(1e3*s.size/p),h="size:".concat(g," time:").concat(p,"ms speed:").concat(_);we.log("".concat(n," success. name:").concat(s.name," ").concat(h)),r(l);var f=t.getModule(mn);return f.addCost(Xo,p),f.addFileSize(Xo,s.size),void o.setNetworkType(t.getNetworkType()).setMessage(h).end()}var m=new rr({code:Bo.MESSAGE_FILE_UPLOAD_FAIL,message:Ho.MESSAGE_FILE_UPLOAD_FAIL});o.setError(m,!0,u.getNetworkType()).end(),we.warn("".concat(n," failed. error:"),e),403===e.statusCode&&(we.warn("".concat(n," failed. cos AccessKeyId was invalid, regain auth key!")),t._getAuthorizationKey()),i(m)}))}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,n="".concat(this._className,"._uploadWithPreSigUrl"),o=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((function(e){return new Promise((function(a,s){var r=new sa(Ia),i=e.requestSnapshotUrl,c=void 0===i?void 0:i,u=g(e,["requestSnapshotUrl"]),l=Date.now();t._cosUploadMethod(u,(function(e,i){var u=Object.create(null);if(e||403===i.statusCode){var d=new rr({code:Bo.MESSAGE_FILE_UPLOAD_FAIL,message:Ho.MESSAGE_FILE_UPLOAD_FAIL});return r.setError(d,!0,t.getNetworkType()).end(),we.log("".concat(n," failed, error:"),e),void s(d)}var p=i.data.location||"";0!==p.indexOf("https://")&&0!==p.indexOf("http://")||(p=p.split("//")[1]),u.fileName=o.name,u.fileSize=o.size,u.fileType=o.type.slice(o.type.indexOf("/")+1).toLowerCase(),u.location=p;var g=Date.now()-l,_=t._formatFileSize(o.size),h=t._formatSpeed(1e3*o.size/g),f="size:".concat(_,",time:").concat(g,"ms,speed:").concat(h," res:").concat(JSON.stringify(i.data));we.log("".concat(n," success name:").concat(o.name,",").concat(f)),r.setNetworkType(t.getNetworkType()).setMessage(f).end();var m=t.getModule(mn);if(m.addCost(Xo,g),m.addFileSize(Xo,o.size),!Pt(c))return t._getSnapshotInfoByUrl(c).then((function(e){u.snapshotInfo=e,a(u)}));a(u)}))}))}))}},{key:"_getFile",value:function(e){var t=null;return te?t=Z&&ze(e.file.files)?e.file.files[0]:e.file:ne&&(t=e.file.files[0]),t}},{key:"_formatFileSize",value:function(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}},{key:"_formatSpeed",value:function(e){return e<=1048576?Rt(e/1024,1)+"KB/s":Rt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=e.file.files[0].name,n=t.slice(t.lastIndexOf(".")),o=this._genFileName("".concat(ct(999999)).concat(n));return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(o),Body:e.file.files[0]}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(n){we.warn("onProgress callback error:",n)}},onFileFinish:function(e,t,n){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),n=this._genFileName(t.name),o=t.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),FilePath:o,onProgress:function(t){if(we.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(n){we.warn("onProgress callback error:",n)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t=this,n="",o="",a=0;if(te){var s=this._getFile(e);n=this._genFileName(s.name),o=s.url,a=1}else{var r=e.file.files[0].name,i=r.slice(r.lastIndexOf("."));n=this._genFileName("".concat(ct(999999)).concat(i)),o=e.file.files[0],a=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:n,uploadMethod:a,duration:this.duration}).then((function(a){var s=a.uploadUrl,r=a.downloadUrl,i=a.requestSnapshotUrl,c=void 0===i?void 0:i;return{url:s,fileType:t.uploadFileType,fileName:n,resources:o,downloadUrl:r,requestSnapshotUrl:c,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(n){we.warn("onProgress callback error:",n),we.error(n)}}}}))}},{key:"_genFileName",value:function(e){return"".concat(St(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e){var t=this,n=new sa(ya);return this.request({protocolName:ko,requestData:{platform:this.getPlatform(),coverName:this._genFileName(ct(99999)),requestSnapshotUrl:e}}).then((function(e){var t=(e.data||{}).snapshotUrl;return n.setMessage("snapshotUrl:".concat(t)).end(),Pt(t)?{}:Ct(t).then((function(e){return{snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((function(e){return we.warn("".concat(t._className,"._getSnapshotInfoByUrl failed. error:"),e),n.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(vn),ui=function(){function e(n){t(this,e),this._className="MergerMessageHandler",this._messageModule=n}return o(e,[{key:"uploadMergerMessage",value:function(e,t){var n=this;we.debug("".concat(this._className,".uploadMergerMessage message:"),e,"messageBytes:".concat(t));var o=e.payload.messageList,a=o.length,s=new sa(wa);return this._messageModule.request({protocolName:bo,requestData:{messageList:o}}).then((function(e){we.debug("".concat(n._className,".uploadMergerMessage ok. response:"),e.data);var o=e.data,r=o.pbDownloadKey,i=o.downloadKey,c={pbDownloadKey:r,downloadKey:i,messageNumber:a};return s.setNetworkType(n._messageModule.getNetworkType()).setMessage("".concat(a,"-").concat(t,"-").concat(i)).end(),c})).catch((function(e){throw we.warn("".concat(n._className,".uploadMergerMessage failed. error:"),e),n._messageModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];s.setError(e,o,a).end()})),e}))}},{key:"downloadMergerMessage",value:function(e){var t=this;we.debug("".concat(this._className,".downloadMergerMessage message:"),e);var n=e.payload.downloadKey,o=new sa(ba);return o.setMessage("downloadKey:".concat(n)),this._messageModule.request({protocolName:Uo,requestData:{downloadKey:n}}).then((function(n){if(we.debug("".concat(t._className,".downloadMergerMessage ok. response:"),n.data),Qe(e.clearElement)){var a=e.payload,s=(a.downloadKey,a.pbDownloadKey,a.messageList,g(a,["downloadKey","pbDownloadKey","messageList"]));e.clearElement(),e.setElement({type:e.type,content:r({messageList:n.data.messageList},s)})}else{var i=[];n.data.messageList.forEach((function(e){if(!Pt(e)){var t=new Js(e);i.push(t)}})),e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return o.setNetworkType(t._messageModule.getNetworkType()).end(),e})).catch((function(e){throw we.warn("".concat(t._className,".downloadMergerMessage failed. key:").concat(n," error:"),e),t._messageModule.probeNetwork().then((function(t){var n=m(t,2),a=n[0],s=n[1];o.setError(e,a,s).end()})),e}))}},{key:"createMergerMessagePack",value:function(e,t,n){return e.conversationType===D.CONV_C2C?this._createC2CMergerMessagePack(e,t,n):this._createGroupMergerMessagePack(e,t,n)}},{key:"_createC2CMergerMessagePack",value:function(e,t,n){var o=null;t&&(t.offlinePushInfo&&(o=t.offlinePushInfo),!0===t.onlineUserOnly&&(o?o.disablePush=!0:o={disablePush:!0}));var a="";We(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=n.pbDownloadKey,r=n.downloadKey,i=n.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(Xt);return{protocolName:Dn,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],cloudCustomData:a,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:p&&p.isOnlineMessage(e,t)?0:void 0,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,n){var o=null;t&&t.offlinePushInfo&&(o=t.offlinePushInfo);var a="";We(e.cloudCustomData)&&e.cloudCustomData.length>0&&(a=e.cloudCustomData);var s=n.pbDownloadKey,r=n.downloadKey,i=n.messageNumber,c=e.payload,u=c.title,l=c.abstractList,d=c.compatibleText,p=this._messageModule.getModule(Qt);return{protocolName:Nn,tjgID:this._messageModule.generateTjgID(e),requestData:{fromAccount:this._messageModule.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:u,abstractList:l,compatibleText:d,messageNumber:i}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:a,onlineOnlyFlag:p&&p.isOnlineMessage(e,t)?1:0,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0,clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||p.isMessageFromOrToAVChatroom(e.to)?0:1}}}}]),e}(),li={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MESSAGE_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},di=[Bo.MESSAGE_ONPROGRESS_FUNCTION_ERROR,Bo.MESSAGE_IMAGE_SELECT_FILE_FIRST,Bo.MESSAGE_IMAGE_TYPES_LIMIT,Bo.MESSAGE_FILE_IS_EMPTY,Bo.MESSAGE_IMAGE_SIZE_LIMIT,Bo.MESSAGE_FILE_SELECT_FILE_FIRST,Bo.MESSAGE_FILE_SIZE_LIMIT,Bo.MESSAGE_VIDEO_SIZE_LIMIT,Bo.MESSAGE_VIDEO_TYPES_LIMIT,Bo.MESSAGE_AUDIO_UPLOAD_FAIL,Bo.MESSAGE_AUDIO_SIZE_LIMIT,Bo.COS_UNDETECTED];var pi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="MessageModule",o._messageOptionsMap=new Map,o._mergerMessageHandler=new ui(_(o)),o}return o(a,[{key:"createTextMessage",value:function(e){var t=e.to,n=e.payload.atUserList,o=void 0===n?[]:n;if(vt({groupID:t})&&o.includes(D.MSG_AT_ALL))return lr({code:Bo.MESSAGE_AT_TYPE_INVALID,message:Ho.MESSAGE_AT_TYPE_INVALID});var a=this.getMyUserID();e.currentUser=a,e.senderTinyID=this.getMyTinyID();var s=new Zs(e),r="string"==typeof e.payload?e.payload:e.payload.text,i=new Fs({text:r}),c=this._getNickAndAvatarByUserID(a);return s.setElement(i),s.setNickAndAvatar(c),s.setNameCard(this._getNameCardByGroupID(s)),s}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new Zs(e);if(te){var o=e.payload.file;if(He(o))return void we.warn("小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");var a=o.tempFilePaths[0],s={url:a,name:a.slice(a.lastIndexOf("/")+1),size:o.tempFiles&&o.tempFiles[0].size||1,type:a.slice(a.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}else if(ne)if(He(e.payload.file)){var r=e.payload.file;e.payload.file={files:[r]}}else if($e(e.payload.file)&&"undefined"!=typeof uni){var i=e.payload.file.tempFiles[0];e.payload.file={files:[i]}}var c=new qs({imageFormat:be.UNKNOWN,uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(t);return n.setElement(c),n.setNickAndAvatar(u),n.setNameCard(this._getNameCardByGroupID(n)),this._messageOptionsMap.set(n.clientSequence,e),n}},{key:"createAudioMessage",value:function(e){if(te){var t=e.payload.file;if(te){var n={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=n}var o=this.getMyUserID();e.currentUser=o,e.senderTinyID=this.getMyTinyID();var a=new Zs(e),s=new Ks({second:Math.floor(t.duration/1e3),size:t.fileSize,url:t.tempFilePath,uuid:this._generateUUID()}),r=this._getNickAndAvatarByUserID(o);return a.setElement(s),a.setNickAndAvatar(r),a.setNameCard(this._getNameCardByGroupID(a)),this._messageOptionsMap.set(a.clientSequence,e),a}we.warn("createAudioMessage 目前只支持小程序环境下发语音消息")}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="https://web.sdk.qcloud.com/im/assets/images/transparent.png",e.payload.file.thumbSize=1668;var n={};if(te){if(Q)return void we.warn("createVideoMessage 不支持在支付宝小程序环境下使用");if(He(e.payload.file))return void we.warn("小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");var o=e.payload.file;n.url=o.tempFilePath,n.name=o.tempFilePath.slice(o.tempFilePath.lastIndexOf("/")+1),n.size=o.size,n.second=o.duration,n.type=o.tempFilePath.slice(o.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(ne){if(He(e.payload.file)){var a=e.payload.file;e.payload.file.files=[a]}else if($e(e.payload.file)&&"undefined"!=typeof uni){var s=e.payload.file.tempFile;e.payload.file.files=[s]}var r=e.payload.file;n.url=window.URL.createObjectURL(r.files[0]),n.name=r.files[0].name,n.size=r.files[0].size,n.second=r.files[0].duration||0,n.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=n;var i=new Zs(e),c=new $s({videoFormat:n.type,videoSecond:Rt(n.second,0),videoSize:n.size,remoteVideoUrl:"",videoUrl:n.url,videoUUID:this._generateUUID(),thumbUUID:this._generateUUID(),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()}),u=this._getNickAndAvatarByUserID(t);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new Zs(e),o=new Ys({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),a=this._getNickAndAvatarByUserID(t);return n.setElement(o),n.setNickAndAvatar(a),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createFaceMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new Zs(e),o=new Vs(e.payload),a=this._getNickAndAvatarByUserID(t);return n.setElement(o),n.setNickAndAvatar(a),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createMergerMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=this._getNickAndAvatarByUserID(t),o=new Zs(e),a=new Xs(e.payload);return o.setElement(a),o.setNickAndAvatar(n),o.setNameCard(this._getNameCardByGroupID(o)),o.setRelayFlag(!0),o}},{key:"createForwardMessage",value:function(e){var t=e.to,n=e.conversationType,o=e.priority,a=e.payload,s=e.needReadReceipt,r=this.getMyUserID(),i=this._getNickAndAvatarByUserID(r);if(a.type===D.MSG_GRP_TIP)return lr(new rr({code:Bo.MESSAGE_FORWARD_TYPE_INVALID,message:Ho.MESSAGE_FORWARD_TYPE_INVALID}));var c={to:t,conversationType:n,conversationID:"".concat(n).concat(t),priority:o,isPlaceMessage:0,status:Ft.UNSEND,currentUser:r,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:s},u=new Zs(c);return u.setElement(a.getElements()[0]),u.setNickAndAvatar(i),u.setNameCard(this._getNameCardByGroupID(a)),u.setRelayFlag(!0),u}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if(!te||Z){if(ne||Z)if(He(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}else if($e(e.payload.file)&&"undefined"!=typeof uni){var n=e.payload.file,o=n.tempFiles,a=n.files,s=null;ze(o)?s=o[0]:ze(a)&&(s=a[0]),e.payload.file={files:[s]}}var r=this.getMyUserID();e.currentUser=r,e.senderTinyID=this.getMyTinyID();var i=new Zs(e),c=new Ws({uuid:this._generateUUID(),file:e.payload.file}),u=this._getNickAndAvatarByUserID(r);return i.setElement(c),i.setNickAndAvatar(u),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}we.warn("小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new Zs(e),o=new zs(e.payload),a=this._getNickAndAvatarByUserID(t);return n.setElement(o),n.setNickAndAvatar(a),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"_onCannotFindModule",value:function(){return lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var n,o=this,a=null;switch(e.conversationType){case D.CONV_C2C:if(!(a=this.getModule(Xt)))return this._onCannotFindModule();break;case D.CONV_GROUP:if(!(a=this.getModule(Qt)))return this._onCannotFindModule();if(vt({groupID:e.to})&&!Je(t)&&!Je(t.messageControlInfo))return lr({code:Bo.MESSAGE_CONTROL_INFO_FAIL,message:Ho.MESSAGE_CONTROL_INFO_FAIL});break;default:return lr({code:Bo.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:Ho.MESSAGE_SEND_INVALID_CONVERSATION_TYPE})}var s=this.getModule(cn),r=this.getModule(Qt);return s.upload(e).then((function(){o._getSendMessageSpecifiedKey(e)===Jo&&o.getModule(mn).addSuccessCount(Xo);return r.guardForAVChatRoom(e).then((function(){if(!e.isSendable())return lr({code:Bo.MESSAGE_FILE_URL_IS_EMPTY,message:Ho.MESSAGE_FILE_URL_IS_EMPTY});o._addSendMessageTotalCount(e),n=Date.now();var s=function(e){var t="utf-8";ne&&document&&(t=document.charset.toLowerCase());var n,o,a=0;if(o=e.length,"utf-8"===t||"utf8"===t)for(var s=0;s<o;s++)(n=e.codePointAt(s))<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:(a+=4,s++);else if("utf-16"===t||"utf16"===t)for(var r=0;r<o;r++)(n=e.codePointAt(r))<=65535?a+=2:(a+=4,r++);else a=e.replace(/[^\x00-\xff]/g,"aa").length;return a}(JSON.stringify(e));return e.type===D.MSG_MERGER&&s>7e3?o._mergerMessageHandler.uploadMergerMessage(e,s).then((function(n){var a=o._mergerMessageHandler.createMergerMessagePack(e,t,n);return o.request(a)})):(o.getModule(tn).setMessageRandom(e),e.conversationType===D.CONV_C2C||e.conversationType===D.CONV_GROUP?a.sendMessage(e,t):void 0)})).then((function(s){var r=s.data,i=r.time,c=r.sequence,u=r.readReceiptCode;je(u)&&0!==u&&(new sa(Ta).setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(c," readReceiptCode:").concat(u)).end(),we.warn("".concat(o._className,".sendMessageInstance readReceiptCode:").concat(u," message:").concat(sr[u])));o._addSendMessageSuccessCount(e,n),o._messageOptionsMap.delete(e.clientSequence);var l=o.getModule(tn);e.status=Ft.SUCCESS,e.time=i;var d=!1;if(e.conversationType===D.CONV_GROUP)e.sequence=c;else if(e.conversationType===D.CONV_C2C){var p=l.getLatestMessageSentByMe(e.conversationID);if(p){var g=p.nick,_=p.avatar;g===e.nick&&_===e.avatar||(d=!0)}}if(l.appendToMessageList(e),d&&l.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),a.isOnlineMessage(e,t))e._onlineOnlyFlag=!0;else{var h=e;$e(t)&&$e(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,h=""),!0===t.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0)),l.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:e.conversationType,subType:e.conversationSubType,lastMessage:h}]})}return e.getRelayFlag()||"TIMImageElem"!==e.type||At(e.payload.imageInfoArray),er({message:e})}))})).catch((function(t){return o._onSendMessageFailed(e,t)}))}},{key:"_onSendMessageFailed",value:function(e,t){e.status=Ft.FAIL,this.getModule(tn).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);var n=new sa(Ea);return n.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),this.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];n.setError(t,a,s).end()})),we.error("".concat(this._className,"._onSendMessageFailed error:"),t),lr(new rr({code:t&&t.code?t.code:Bo.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:Ho.MESSAGE_SEND_FAIL,data:{message:e}}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if([D.MSG_IMAGE,D.MSG_AUDIO,D.MSG_VIDEO,D.MSG_FILE].includes(e.type))return Jo;if(e.conversationType===D.CONV_C2C)return Yo;if(e.conversationType===D.CONV_GROUP){var t=this.getModule(Qt).getLocalGroupProfile(e.to);if(!t)return;var n=t.type;return Mt(n)?zo:$o}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this._getSendMessageSpecifiedKey(e);t&&this.getModule(mn).addTotalCount(t)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var n=Math.abs(Date.now()-t),o=this._getSendMessageSpecifiedKey(e);if(o){var a=this.getModule(mn);a.addSuccessCount(o),a.addCost(o,n)}}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){var n,o,a=t.code,s=void 0===a?-1:a,r=this.getModule(mn),i=this._getSendMessageSpecifiedKey(e);i===Jo&&(n=s,o=!1,di.includes(n)&&(o=!0),o)?r.addFailedCountOfUserSide(Xo):function(e){var t=!1;return Object.values(li).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}(s)&&i&&r.addFailedCountOfUserSide(i)}},{key:"resendMessage",value:function(e){return e.isResend=!0,e.status=Ft.UNSEND,e.random=ct(),e.clientTime=Oe(),e.generateMessageID(),this.sendMessageInstance(e)}},{key:"revokeMessage",value:function(e){var t=this,n=null;if(e.conversationType===D.CONV_C2C){if(!(n=this.getModule(Xt)))return this._onCannotFindModule()}else if(e.conversationType===D.CONV_GROUP&&!(n=this.getModule(Qt)))return this._onCannotFindModule();var o=new sa(ka);return o.setMessage("tjg_id:".concat(this.generateTjgID(e)," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to)),n.revokeMessage(e).then((function(n){var a=n.data.recallRetList;if(!Pt(a)&&0!==a[0].retCode){var s=new rr({code:a[0].retCode,message:sr[a[0].retCode]||Ho.MESSAGE_REVOKE_FAIL,data:{message:e}});return o.setCode(s.code).setMoreMessage(s.message).end(),lr(s)}return we.info("".concat(t._className,".revokeMessage ok. ID:").concat(e.ID)),e.isRevoked=!0,o.end(),t.getModule(tn).onMessageRevoked([e]),er({message:e})})).catch((function(n){t.probeNetwork().then((function(e){var t=m(e,2),a=t[0],s=t[1];o.setError(n,a,s).end()}));var a=new rr({code:n&&n.code?n.code:Bo.MESSAGE_REVOKE_FAIL,message:n&&n.message?n.message:Ho.MESSAGE_REVOKE_FAIL,data:{message:e}});return we.warn("".concat(t._className,".revokeMessage failed. error:"),n),lr(a)}))}},{key:"deleteMessage",value:function(e){var t=this,n=null,o=e[0],a=o.conversationID,s="",r=[],i=[];if(o.conversationType===D.CONV_C2C?(n=this.getModule(Xt),s=a.replace(D.CONV_C2C,""),e.forEach((function(e){e&&e.status===Ft.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),i.push(e))}))):o.conversationType===D.CONV_GROUP&&(n=this.getModule(Qt),s=a.replace(D.CONV_GROUP,""),e.forEach((function(e){e&&e.status===Ft.SUCCESS&&e.conversationID===a&&(e._onlineOnlyFlag||r.push("".concat(e.sequence)),i.push(e))}))),!n)return this._onCannotFindModule();if(0===r.length)return this._onMessageDeleted(i);r.length>30&&(r=r.slice(0,30),i=i.slice(0,30));var c=new sa(Ra);return c.setMessage("to:".concat(s," count:").concat(r.length)),n.deleteMessage({to:s,keyList:r}).then((function(e){return c.end(),we.info("".concat(t._className,".deleteMessage ok")),t._onMessageDeleted(i)})).catch((function(e){t.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];c.setError(e,o,a).end()})),we.warn("".concat(t._className,".deleteMessage failed. error:"),e);var n=new rr({code:e&&e.code?e.code:Bo.MESSAGE_DELETE_FAIL,message:e&&e.message?e.message:Ho.MESSAGE_DELETE_FAIL});return lr(n)}))}},{key:"_onMessageDeleted",value:function(e){return this.getModule(tn).onMessageDeleted(e),ur({messageList:e})}},{key:"_generateUUID",value:function(){var e=this.getModule(nn);return"".concat(e.getSDKAppID(),"-").concat(e.getUserID(),"-").concat(function(){for(var e="",t=32;t>0;--t)e+=ut[Math.floor(Math.random()*lt)];return e}())}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.getModule(Jt).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===D.CONV_GROUP){var t=this.getModule(Qt);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._messageOptionsMap.clear()}}]),a}(vn),gi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="PluginModule",o.plugins={},o}return o(a,[{key:"registerPlugin",value:function(e){var t=this;Object.keys(e).forEach((function(n){t.plugins[n]=e[n]})),new sa(da).setMessage("key=".concat(Object.keys(e))).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(vn),_i=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="SyncUnreadMessageModule",o._cookie="",o._onlineSyncFlag=!1,o.getInnerEmitterInstance().on(gr,o._onLoginSuccess,_(o)),o}return o(a,[{key:"_onLoginSuccess",value:function(e){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,n=e.cookie,o=e.syncFlag,a=e.isOnlineSync;we.log("".concat(this._className,"._startSync cookie:").concat(n," syncFlag:").concat(o," isOnlineSync:").concat(a)),this.request({protocolName:Cn,requestData:{cookie:n,syncFlag:o,isOnlineSync:a}}).then((function(e){var n=e.data,o=n.cookie,a=n.syncFlag,s=n.eventArray,r=n.messageList,i=n.C2CRemainingUnreadList,c=n.C2CPairUnreadList;if(t._cookie=o,Pt(o));else if(0===a||1===a){if(s)t.getModule(dn).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!1}});t.getModule(Xt).onNewC2CMessage({dataList:r,isInstantMessage:!1,C2CRemainingUnreadList:i,C2CPairUnreadList:c}),t._startSync({cookie:o,syncFlag:a,isOnlineSync:0})}else if(2===a){if(s)t.getModule(dn).onMessage({head:{},body:{eventArray:s,isInstantMessage:t._onlineSyncFlag,isSyncingEnded:!0}});t.getModule(Xt).onNewC2CMessage({dataList:r,isInstantMessage:t._onlineSyncFlag,C2CRemainingUnreadList:i,C2CPairUnreadList:c})}})).catch((function(e){we.error("".concat(t._className,"._startSync failed. error:"),e)}))}},{key:"startOnlineSync",value:function(){we.log("".concat(this._className,".startOnlineSync")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"startSyncOnReconnected",value:function(){we.log("".concat(this._className,".startSyncOnReconnected.")),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}]),a}(vn),hi={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"},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:"hasChangedAttributeInfo",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"},ignoreKeyWord:["C2C","ID","USP"]};function fi(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);var n;return 0===(e=Array.isArray(e)?e.map((function(e){return e.trim()})).filter((function(e){return e.length})).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=mi(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),n=e,t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n)}var mi=function(e){for(var t=!1,n=!1,o=!1,a=0;a<e.length;a++){var s=e[a];t&&/[a-zA-Z]/.test(s)&&s.toUpperCase()===s?(e=e.slice(0,a)+"-"+e.slice(a),t=!1,o=n,n=!0,a++):n&&o&&/[a-zA-Z]/.test(s)&&s.toLowerCase()===s?(e=e.slice(0,a-1)+"-"+e.slice(a-1),o=n,n=!1,t=!0):(t=s.toLowerCase()===s&&s.toUpperCase()!==s,o=n,n=s.toUpperCase()===s&&s.toLowerCase()!==s)}return e};function Mi(e,t){var n=0;return function e(t,o){if(++n>100)return n--,t;if(ze(t)){var a=t.map((function(t){return Ye(t)?e(t,o):t}));return n--,a}if(Ye(t)){var s=(r=t,i=function(e,t){if(!nt(t))return!1;if((a=t)!==fi(a))for(var n=0;n<hi.ignoreKeyWord.length&&!t.includes(hi.ignoreKeyWord[n]);n++);var a;return Je(o[t])?function(e){return"OPPOChannelID"===e?e:e[0].toUpperCase()+fi(e).slice(1)}(t):o[t]},c=Object.create(null),Object.keys(r).forEach((function(e){var t=i(r[e],e);t&&(c[t]=r[e])})),c);return s=Tt(s,(function(t,n){return ze(t)||Ye(t)?e(t,o):t})),n--,s}var r,i,c}(e,t)}function vi(e,t){if(ze(e))return e.map((function(e){return Ye(e)?vi(e,t):e}));if(Ye(e)){var n=(o=e,a=function(e,n){return Je(t[n])?fi(n):t[n]},s={},Object.keys(o).forEach((function(e){s[a(o[e],e)]=o[e]})),s);return n=Tt(n,(function(e){return ze(e)||Ye(e)?vi(e,t):e}))}var o,a,s}var yi=String.fromCharCode,Ii=function(e){var t=0|e.charCodeAt(0);if(55296<=t)if(t<56320){var n=0|e.charCodeAt(1);if(56320<=n&&n<=57343){if((t=(t<<10)+n-56613888|0)>65535)return yi(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?yi(192|t>>>6,128|63&t):yi(224|t>>>12,128|t>>>6&63,128|63&t)},Ei=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,Ii),n=0|t.length,o=new Uint8Array(n),a=0;a<n;a=a+1|0)o[a]=0|t.charCodeAt(a);return o},Ti=function(e){for(var t=new Uint8Array(e),n="",o=0,a=t.length;o<a;){var s=t[o],r=0,i=0;if(s<=127?(r=0,i=255&s):s<=223?(r=1,i=31&s):s<=239?(r=2,i=15&s):s<=244&&(r=3,i=7&s),a-o-r>0)for(var c=0;c<r;)i=i<<6|63&(s=t[o+c+1]),c+=1;else i=65533,r=a-o;n+=String.fromCodePoint(i),o+=r+1}return n},Ci=function(){function e(n){t(this,e),this._handler=n;var o=n.getURL();if(this._socket=null,this._workerSocket=null,this._id=ct(),this._handler.getIsWorkerEnabled()){var a=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"}));this._workerSocket=new Worker(a);var s=this;this._workerSocket.onmessage=function(e){var t=e.data,n=t.callback,o=t.e;"onOpen"===n?s._onOpen():"onClose"===n?s._onClose(o):"onError"===n?s._onError(o):"onMessage"===n&&s._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:o})}else te?Q?(oe.connectSocket({url:o,header:{"content-type":"application/json"}}),oe.onSocketClose(this._onClose.bind(this)),oe.onSocketOpen(this._onOpen.bind(this)),oe.onSocketMessage(this._onMessage.bind(this)),oe.onSocketError(this._onError.bind(this))):(this._socket=oe.connectSocket({url:o,header:{"content-type":"application/json"},complete:function(){}}),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))):ne&&(this._socket=new WebSocket(o),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=n.canIUseBinaryFrame()}return o(e,[{key:"getID",value:function(){return this._id}},{key:"_onOpen",value:function(){this._handler.onOpen({id:this._id})}},{key:"_onClose",value:function(e){this._handler.onClose({id:this._id,e:e})}},{key:"_onMessage",value:function(e){this._handler.onMessage({data:this._canIUseBinaryFrame?Ti(e.data):e.data})}},{key:"_onError",value:function(e){this._handler.onError({id:this._id,e:e})}},{key:"setIsWorkerEnabled",value:function(e){this._isWorkerEnabled=!0}},{key:"close",value:function(e){if(this._workerSocket&&(this._workerSocket.postMessage({cmd:"stop",code:e}),this._workerSocket.terminate(),this._workerSocket=null),Q)return oe.offSocketClose(),oe.offSocketMessage(),oe.offSocketOpen(),oe.offSocketError(),void oe.closeSocket();this._socket&&(te?(this._socket.onClose((function(){})),this._socket.onOpen((function(){})),this._socket.onMessage((function(){})),this._socket.onError((function(){}))):ne&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),X?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}},{key:"send",value:function(e){if(this._workerSocket)this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?Ei(e.data).buffer:e.data});else{if(Q)return void oe.sendSocketMessage({data:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}});this._socket&&(te?this._socket.send({data:this._canIUseBinaryFrame?Ei(e.data).buffer:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}}):ne&&this._socket.send(this._canIUseBinaryFrame?Ei(e.data).buffer:e.data))}}}]),e}(),Si=4e3,Di=4001,Ni="connected",Ai="connecting",ki="disconnected",Ri=function(){function e(n){t(this,e),this._channelModule=n,this._className="SocketHandler",this._promiseMap=new Map,this._readyState=ki,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=ct(),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()}return o(e,[{key:"_setWebsocketHost",value:function(){var e=this._channelModule.getModule(nn),t=b;this._channelModule.isOversea()&&(t=U),e.isSingaporeSite()?t=F:e.isKoreaSite()?t=q:e.isGermanySite()?t=V:e.isIndiaSite()&&(t=K),x.HOST.setCurrent(t)}},{key:"_initConnection",value:function(){Je(x.HOST.CURRENT.BACKUP)||""===this._url?this._url=x.HOST.CURRENT.DEFAULT:this._url===x.HOST.CURRENT.DEFAULT?this._url=x.HOST.CURRENT.BACKUP:this._url===x.HOST.CURRENT.BACKUP&&(this._url=x.HOST.CURRENT.DEFAULT);var e=this._channelModule.getModule(nn).getProxyServer();Pt(e)||(this._url=e),this._connect(),this._nextPingTs=0}},{key:"onCheckTimer",value:function(e){e%1==0&&this._checkPromiseMap()}},{key:"_checkPromiseMap",value:function(){var e=this;0!==this._promiseMap.size&&this._promiseMap.forEach((function(t,n){var o=t.reject,a=t.timestamp;Date.now()-a>=15e3&&(we.log("".concat(e._className,"._checkPromiseMap request timeout, delete requestID:").concat(n)),e._promiseMap.delete(n),o(new rr({code:Bo.NETWORK_TIMEOUT,message:Ho.NETWORK_TIMEOUT})),e._channelModule.onRequestTimeout(n))}))}},{key:"onOpen",value:function(e){this._onOpenTs=Date.now();var t=e.id;this._socketID=t;var n=Date.now()-this._startTs;we.log("".concat(this._className,"._onOpen cost ").concat(n," ms. socketID:").concat(t)),new sa(_a).setMessage(n).setCostTime(n).setMoreMessage("socketID:".concat(t)).end(),e.id===this._socketID&&(this._readyState=Ni,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._channelModule.onReconnected(),this._reConnectFlag=!1),this._channelModule.onOpen())}},{key:"onClose",value:function(e){var t=new sa(ha),n=e.id,o=e.e,a="sourceSocketID:".concat(n," currentSocketID:").concat(this._socketID," code:").concat(o.code," reason:").concat(o.reason),s=0;0!==this._onOpenTs&&(s=Date.now()-this._onOpenTs),t.setMessage(s).setCostTime(s).setMoreMessage(a).setCode(o.code).end(),we.log("".concat(this._className,"._onClose ").concat(a," onlineTime:").concat(s)),n===this._socketID&&(this._readyState=ki,s<1e3?this._channelModule.onReconnectFailed():this._channelModule.onClose())}},{key:"onError",value:function(e){var t=e.id,n=e.e,o="sourceSocketID:".concat(t," currentSocketID:").concat(this._socketID);new sa(fa).setMessage(n.errMsg||rt(n)).setMoreMessage(o).setLevel("error").end(),we.warn("".concat(this._className,"._onError"),n,o),t===this._socketID&&(this._readyState="",this._channelModule.onError())}},{key:"onMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(u){new sa(Ua).setMessage(e.data).end()}if(t&&t.head){var n=this._getRequestIDFromHead(t.head),o=kt(t.head),a=vi(t.body,this._getResponseKeyMap(o));if(we.debug("".concat(this._className,".onMessage ret:").concat(JSON.stringify(a)," requestID:").concat(n," has:").concat(this._promiseMap.has(n))),this._setNextPingTs(),this._promiseMap.has(n)){var s=this._promiseMap.get(n),r=s.resolve,i=s.reject,c=s.timestamp;return this._promiseMap.delete(n),this._calcRTT(c),void(a.errorCode&&0!==a.errorCode?(this._channelModule.onErrorCodeNotZero(a),i(new rr({code:a.errorCode,message:a.errorInfo||""}))):r(er(a)))}this._channelModule.onMessage({head:t.head,body:a})}}},{key:"_calcRTT",value:function(e){var t=Date.now()-e;this._channelModule.getModule(mn).addRTT(t)}},{key:"_connect",value:function(){this._startTs=Date.now(),this._onOpenTs=0,this._socket=new Ci(this),this._socketID=this._socket.getID(),this._readyState=Ai,we.log("".concat(this._className,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL())),new sa(ga).setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end()}},{key:"getURL",value:function(){var e=this._channelModule.getModule(nn);e.isDevMode()&&(this._canIUseBinaryFrame=!1);var t=Dt();(Q||$&&"windows"===t||Z)&&(this._canIUseBinaryFrame=!1);var n=-1;"ios"===t?n=de||-1:"android"===t&&(n=ge||-1);var o=this._channelModule.getPlatform(),a=e.getSDKAppID(),s=e.getInstanceID();return this._canIUseBinaryFrame?"".concat(this._url,"/binfo?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(o,"&host=").concat(t,"&version=").concat(n):"".concat(this._url,"/info?sdkappid=").concat(a,"&instanceid=").concat(s,"&random=").concat(this._getRandom(),"&platform=").concat(o,"&host=").concat(t,"&version=").concat(n)}},{key:"_closeConnection",value:function(e){we.log("".concat(this._className,"._closeConnection")),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=ki)}},{key:"_resend",value:function(){var e=this;if(we.log("".concat(this._className,"._resend reConnectFlag:").concat(this._reConnectFlag),"promiseMap.size:".concat(this._promiseMap.size," simpleRequestMap.size:").concat(this._simpleRequestMap.size)),this._promiseMap.size>0&&this._promiseMap.forEach((function(t,n){var o=t.uplinkData,a=t.resolve,s=t.reject;e._promiseMap.set(n,{resolve:a,reject:s,timestamp:Date.now(),uplinkData:o}),e._execute(n,o)})),this._simpleRequestMap.size>0){var t,n=C(this._simpleRequestMap);try{for(n.s();!(t=n.n()).done;){var o=m(t.value,2),a=o[0],s=o[1];this._execute(a,s)}}catch(r){n.e(r)}finally{n.f()}this._simpleRequestMap.clear()}}},{key:"send",value:function(e){var t=this;e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var n=g(e,["keyMap"]),o=this._getRequestIDFromHead(e.head),a=JSON.stringify(n);return new Promise((function(e,s){(t._promiseMap.set(o,{resolve:e,reject:s,timestamp:Date.now(),uplinkData:a}),we.debug("".concat(t._className,".send uplinkData:").concat(JSON.stringify(n)," requestID:").concat(o," readyState:").concat(t._readyState)),t._readyState!==Ni)?t._reConnect():(t._execute(o,a),t._channelModule.getModule(mn).addRequestCount())}))}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);e.keyMap;var t=g(e,["keyMap"]),n=this._getRequestIDFromHead(e.head),o=JSON.stringify(t);this._readyState!==Ni?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(n,o):we.log("".concat(this._className,".simplySend. simpleRequestMap is full, drop request!")),this._reConnect()):this._execute(n,o)}},{key:"_execute",value:function(e,t){this._socket.send({data:t,fail:te?this._onSendFail.bind(this):void 0,requestID:e})}},{key:"_onSendFail",value:function(e){we.log("".concat(this._className,"._onSendFail requestID:").concat(e))}},{key:"_getSequence",value:function(){var e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=ct()),e}},{key:"_getRequestIDFromHead",value:function(e){return e.servcmd+e.seq}},{key:"_getResponseKeyMap",value:function(e){var t=this._channelModule.getKeyMap(e);return r({},hi.response,{},t.response)}},{key:"_reConnect",value:function(){this._readyState!==Ni&&this._readyState!==Ai&&this.forcedReconnect()}},{key:"forcedReconnect",value:function(){var e=this;we.log("".concat(this._className,".forcedReconnect count:").concat(this._reConnectCount," readyState:").concat(this._readyState)),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(Di),this._initConnection()):(this._reConnectCount=0,this._channelModule.probeNetwork().then((function(t){var n=m(t,2),o=n[0];n[1];o?(we.warn("".concat(e._className,".forcedReconnect disconnected from wsserver but network is ok, continue...")),e._closeConnection(Di),e._initConnection()):e._channelModule.onReconnectFailed()})))}},{key:"getReconnectFlag",value:function(){return this._reConnectFlag}},{key:"_setNextPingTs",value:function(){this._nextPingTs=Date.now()+1e4}},{key:"getNextPingTs",value:function(){return this._nextPingTs}},{key:"isConnected",value:function(){return this._readyState===Ni}},{key:"canIUseBinaryFrame",value:function(){return this._canIUseBinaryFrame}},{key:"setIsWorkerEnabled",value:function(e){we.log("".concat(this._className,".setIsWorkerEnabled flag:").concat(e)),this._isWorkerEnabled=e}},{key:"getIsWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ee}},{key:"_getRandom",value:function(){return 0===this._random&&(this._random=Math.random()),this._random}},{key:"_resetRandom",value:function(){this._random=0}},{key:"close",value:function(){we.log("".concat(this._className,".close")),this._closeConnection(Si),this._promiseMap.clear(),this._startSequence=ct(),this._readyState=ki,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}]),e}(),Oi=function(e){i(a,e);var n=f(a);function a(e){var o;if(t(this,a),(o=n.call(this,e))._className="ChannelModule",o._socketHandler=new Ri(_(o)),o._probing=!1,o._isAppShowing=!0,o._previousState=D.NET_STATE_CONNECTED,te&&"function"==typeof oe.onAppShow&&"function"==typeof oe.onAppHide){var s=o._onAppHide.bind(_(o)),r=o._onAppShow.bind(_(o));"function"==typeof oe.offAppHide&&oe.offAppHide(s),"function"==typeof oe.offAppShow&&oe.offAppShow(r),oe.onAppHide(s),oe.onAppShow(r)}return o._timerForNotLoggedIn=-1,o._timerForNotLoggedIn=setInterval(o.onCheckTimer.bind(_(o)),1e3),o._fatalErrorFlag=!1,o}return o(a,[{key:"onCheckTimer",value:function(e){this._socketHandler&&(this.isLoggedIn()?(this._timerForNotLoggedIn>0&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}},{key:"onErrorCodeNotZero",value:function(e){this.getModule(dn).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.getModule(dn).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==D.NET_STATE_CONNECTED&&e.head.servcmd.includes(Ro)?(this.reConnect(),this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=x.HOST.CURRENT.STAT;return new Promise((function(n,o){var a="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),s=JSON.stringify(e.body),r="application/x-www-form-urlencoded;charset=UTF-8";if(te)oe.request({url:a,data:s,method:"POST",timeout:3e3,header:{"content-type":r},success:function(){n()},fail:function(){o(new rr({code:Bo.NETWORK_ERROR,message:Ho.NETWORK_ERROR}))}});else{var i=new XMLHttpRequest,c=setTimeout((function(){i.abort(),o(new rr({code:Bo.NETWORK_TIMEOUT,message:Ho.NETWORK_TIMEOUT}))}),3e3);i.onreadystatechange=function(){4===i.readyState&&(clearTimeout(c),200===i.status||304===i.status?n():o(new rr({code:Bo.NETWORK_ERROR,message:Ho.NETWORK_ERROR})))},i.open("POST",a,!0),i.setRequestHeader("Content-type",r),i.send(s)}}))}},{key:"simplySend",value:function(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}},{key:"onOpen",value:function(){this._ping()}},{key:"onClose",value:function(){this._socketHandler&&(this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED));this.reConnect()}},{key:"onError",value:function(){te&&we.error("".concat(this._className,".onError 从v2.11.2起,SDK 支持了 WebSocket,如您未添加相关受信域名,请先添加!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html"))}},{key:"getKeyMap",value:function(e){return this.getModule(dn).getKeyMap(e)}},{key:"_onAppHide",value:function(){this._isAppShowing=!1}},{key:"_onAppShow",value:function(){this._isAppShowing=!0}},{key:"onRequestTimeout",value:function(e){}},{key:"onReconnected",value:function(){we.log("".concat(this._className,".onReconnected")),this.getModule(dn).onReconnected(),this._emitNetStateChangeEvent(D.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){we.log("".concat(this._className,".onReconnectFailed")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"reConnect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!1;this._socketHandler&&(t=this._socketHandler.getReconnectFlag());var n="forcedFlag:".concat(e," fatalErrorFlag:").concat(this._fatalErrorFlag," previousState:").concat(this._previousState," reconnectFlag:").concat(t);if(we.log("".concat(this._className,".reConnect ").concat(n)),!this._fatalErrorFlag&&this._socketHandler){if(!0===e)this._socketHandler.forcedReconnect();else{if(this._previousState===D.NET_STATE_CONNECTING&&t)return;this._socketHandler.forcedReconnect()}this._emitNetStateChangeEvent(D.NET_STATE_CONNECTING)}}},{key:"_emitNetStateChangeEvent",value:function(e){this._previousState!==e&&(we.log("".concat(this._className,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),this._previousState=e,this.emitOuterEvent(S.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e=this;if(!0!==this._probing){this._probing=!0;var t=this.getModule(dn).getProtocolData({protocolName:Oo});this.send(t).then((function(){e._probing=!1})).catch((function(t){if(we.warn("".concat(e._className,"._ping failed. error:"),t),e._probing=!1,t&&60002===t.code)return new sa(bs).setMessage("code:".concat(t.code," message:").concat(t.message)).setNetworkType(e.getModule(sn).getNetworkType()).end(),e._fatalErrorFlag=!0,void e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED);e.probeNetwork().then((function(t){var n=m(t,2),o=n[0],a=n[1];we.log("".concat(e._className,"._ping failed. probe network, isAppShowing:").concat(e._isAppShowing," online:").concat(o," networkType:").concat(a)),o?e.reConnect():e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}))}))}}},{key:"_checkNextPing",value:function(){this._socketHandler&&(this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping())}},{key:"dealloc",value:function(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),this._timerForNotLoggedIn>-1&&clearInterval(this._timerForNotLoggedIn)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._previousState=D.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3)}}]),a}(vn),Li=function(){function n(e){t(this,n),this._className="ProtocolHandler",this._sessionModule=e,this._configMap=new Map,this._fillConfigMap()}return o(n,[{key:"_fillConfigMap",value:function(){this._configMap.clear();var e=this._sessionModule.genCommonHead(),t=this._sessionModule.genCosSpecifiedHead(),n=this._sessionModule.genSSOReportHead();this._configMap.set(yn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_STATUS,".").concat(x.CMD.LOGIN)}),body:{state:"Online"},keyMap:{response:{InstId:"instanceID",HelloInterval:"helloInterval"}}}}(e)),this._configMap.set(In,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_STATUS,".").concat(x.CMD.LOGOUT)}),body:{type:0},keyMap:{request:{type:"wslogout_type"}}}}(e)),this._configMap.set(En,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_STATUS,".").concat(x.CMD.HELLO)}),body:{},keyMap:{response:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Tn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.STAT_SERVICE,".").concat(x.CMD.KICK_OTHER)}),body:{}}}(e)),this._configMap.set(No,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_COS_SIGN,".").concat(x.CMD.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(t)),this._configMap.set(Ao,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.CUSTOM_UPLOAD,".").concat(x.CMD.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{request:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},response:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(t)),this._configMap.set(ko,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.CUSTOM_UPLOAD,".").concat(x.CMD.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{request:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},response:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(t)),this._configMap.set(Vo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_CONFIG_MANAGER,".").concat(x.CMD.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{request:{SDKAppID:"uint32_sdkappid"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Ko,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_CONFIG_MANAGER,".").concat(x.CMD.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._configMap.set(Fo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_CONFIG_MANAGER,".").concat(x.CMD.FETCH_CLOUD_CONTROL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{request:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(qo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_CONFIG_MANAGER,".").concat(x.CMD.PUSHED_CLOUD_CONTROL_CONFIG)}),body:{},keyMap:{response:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._configMap.set(xo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OVERLOAD_PUSH,".").concat(x.CMD.OVERLOAD_NOTIFY)}),body:{},keyMap:{response:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._configMap.set(Cn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.GET_MESSAGES)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0},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:"groupID",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._configMap.set(Sn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.BIG_DATA_HALLWAY_AUTH_KEY)}),body:{}}}(e)),this._configMap.set(Dn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.SEND_MESSAGE)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},messageControlInfo:void 0,clientTime:void 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"}}}}(e)),this._configMap.set(Nn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.SEND_GROUP_MESSAGE)}),body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt: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"},response:{MsgTime:"time",MsgSeq:"sequence"}}}}(e)),this._configMap.set(Gn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.REVOKE_C2C_MESSAGE)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{request:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._configMap.set(oo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.REVOKE_GROUP_MESSAGE)}),body:{groupID:"",msgSeqList:void 0},keyMap:{request:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}(e)),this._configMap.set(Un,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.GET_C2C_ROAM_MESSAGES)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1},keyMap:{request:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg"},response:{LastMsgTime:"lastMessageTime"}}}}(e)),this._configMap.set(ro,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_GROUP_ROAM_MESSAGES)}),body:{withRecalledMsg:1,groupID:"",count:15,sequence:""},keyMap:{request:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(Pn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.SET_C2C_MESSAGE_READ)}),body:{C2CMsgReaded:void 0},keyMap:{request:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._configMap.set(wn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{request:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._configMap.set(bn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{updateSequence:0},keyMap:{response:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._configMap.set(ao,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.SET_GROUP_MESSAGE_READ)}),body:{groupID:void 0,messageReadSeq:void 0},keyMap:{request:{messageReadSeq:"MsgReadedSeq"}}}}(e)),this._configMap.set(so,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.SET_ALL_MESSAGE_READ)}),body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{request:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},response:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}}(e)),this._configMap.set(qn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.DELETE_C2C_MESSAGE)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{request:{keyList:"MsgKeyList"}}}}(e)),this._configMap.set(fo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.DELETE_GROUP_MESSAGE)}),body:{groupID:"",deleter:"",keyList:void 0},keyMap:{request:{deleter:"Deleter_Account",keyList:"Seqs"}}}}(e)),this._configMap.set(io,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequence:"MsgSeq"}}}}(e)),this._configMap.set(co,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.SEND_READ_RECEIPT)}),body:{groupID:"",sequenceList:void 0},keyMap:{request:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}}(e)),this._configMap.set(uo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_READ_RECEIPT_DETAIL)}),body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{request:{sequence:"MsgSeq",count:"Num"},response:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}}(e)),this._configMap.set(Fn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.GET_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}(e)),this._configMap.set(Kn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.RECENT_CONTACT,".").concat(x.CMD.GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,count:0},keyMap:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}}(e)),this._configMap.set(Vn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.RECENT_CONTACT,".").concat(x.CMD.PAGING_GET_CONVERSATION_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:4,assistFlag:15},keyMap:{request:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex"}}}}(e)),this._configMap.set(xn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.RECENT_CONTACT,".").concat(x.CMD.DELETE_CONVERSATION)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0,clearHistoryMessage:1},keyMap:{request:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble"}}}}(e)),this._configMap.set(Bn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.RECENT_CONTACT,".").concat(x.CMD.PIN_CONVERSATION)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{request:{itemList:"RecentContactItem"}}}}(e)),this._configMap.set(Hn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.DELETE_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(An,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.PROFILE,".").concat(x.CMD.PORTRAIT_GET)}),body:{fromAccount:"",userItem:[]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(kn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.PROFILE,".").concat(x.CMD.PORTRAIT_SET)}),body:{fromAccount:"",profileItem:[{tag:Ue.NICK,value:""},{tag:Ue.GENDER,value:""},{tag:Ue.ALLOWTYPE,value:""},{tag:Ue.AVATAR,value:""}]},keyMap:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._configMap.set(Rn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.FRIEND,".").concat(x.CMD.GET_BLACKLIST)}),body:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0},keyMap:{response:{CurruentSequence:"currentSequence"}}}}(e)),this._configMap.set(On,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.FRIEND,".").concat(x.CMD.ADD_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(Ln,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.FRIEND,".").concat(x.CMD.DELETE_BLACKLIST)}),body:{fromAccount:"",toAccount:[]}}}(e)),this._configMap.set(jn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_JOINED_GROUPS)}),body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0}},keyMap:{request:{memberAccount:"Member_Account"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",NoUnreadSeqList:"excludedUnreadSequenceList",MsgSeq:"readedSequence"}}}}(e)),this._configMap.set(Wn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_GROUP_INFO)}),body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{request:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(Yn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.CREATE_GROUP)}),body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"FaceUrl"},keyMap:{request:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData"},response:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}}(e)),this._configMap.set($n,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.DESTROY_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(zn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.MODIFY_GROUP_INFO)}),body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0},keyMap:{request:{maxMemberNum:"MaxMemberCount",groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl"},response:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(Jn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{request:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},response:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}}(e)),this._configMap.set(Xn,function(e){e.a2,e.tinyid;return{head:r({},g(e,["a2","tinyid"]),{servcmd:"".concat(x.NAME.BIG_GROUP_NO_AUTH,".").concat(x.CMD.APPLY_JOIN_GROUP)}),body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{request:{applyMessage:"ApplyMsg"},response:{HugeGroupFlag:"avChatRoomFlag"}}}}(e)),this._configMap.set(Qn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.QUIT_GROUP)}),body:{groupID:void 0}}}(e)),this._configMap.set(Zn,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.SEARCH_GROUP_BY_ID)}),body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption"]}},keyMap:{response:{ApplyJoinOption:"joinOption"}}}}(e)),this._configMap.set(eo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.CHANGE_GROUP_OWNER)}),body:{groupID:void 0,newOwnerID:void 0},keyMap:{request:{newOwnerID:"NewOwner_Account"}}}}(e)),this._configMap.set(to,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.HANDLE_APPLY_JOIN_GROUP)}),body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(no,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.HANDLE_GROUP_INVITATION)}),body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{request:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}}(e)),this._configMap.set(lo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_GROUP_APPLICATION)}),body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{request:{handleAccount:"Handle_Account"}}}}(e)),this._configMap.set(po,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.DELETE_GROUP_SYSTEM_MESSAGE)}),body:{messageListToDelete:void 0},keyMap:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._configMap.set(go,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.BIG_GROUP_LONG_POLLING,".").concat(x.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(_o,function(e){e.a2,e.tinyid;return{head:r({},g(e,["a2","tinyid"]),{servcmd:"".concat(x.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,".").concat(x.CMD.AVCHATROOM_LONG_POLL)}),body:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMap:{request:{USP:"USP"},response:{ToGroupId:"groupID"}}}}(e)),this._configMap.set(ho,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_ONLINE_MEMBER_NUM)}),body:{groupID:void 0}}}(e)),this._configMap.set(mo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.SET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(Mo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.MODIFY_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key",value:"value"}}}}(e)),this._configMap.set(vo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.DELETE_GROUP_ATTRIBUTES)}),body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{request:{key:"key"}}}}(e)),this._configMap.set(yo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.CLEAR_GROUP_ATTRIBUTES)}),body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}}(e)),this._configMap.set(Io,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP_ATTR,".").concat(x.CMD.GET_GROUP_ATTRIBUTES)}),body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{request:{avChatRoomKey:"Key",groupType:"GroupType"}}}}(e)),this._configMap.set(Eo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_GROUP_MEMBER_LIST)}),body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:["Role","NameCard","ShutUpUntil","JoinTime"],memberCustomFieldFilter:void 0},keyMap:{request:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}}(e)),this._configMap.set(To,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.GET_GROUP_MEMBER_INFO)}),body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{request:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},response:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}}(e)),this._configMap.set(Co,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.ADD_GROUP_MEMBER)}),body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{request:{userID:"Member_Account",userIDList:"MemberList"},response:{MemberList:"members"}}}}(e)),this._configMap.set(So,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.DELETE_GROUP_MEMBER)}),body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{request:{userIDList:"MemberToDel_Account"}}}}(e)),this._configMap.set(Do,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.GROUP,".").concat(x.CMD.MODIFY_GROUP_MEMBER_INFO)}),body:{groupID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{request:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}}(e)),this._configMap.set(Ro,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_STAT,".").concat(x.CMD.TIM_WEB_REPORT_V2)}),body:{header:{},event:[],quality:[]},keyMap:{request:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}}(n)),this._configMap.set(Oo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.HEARTBEAT,".").concat(x.CMD.ALIVE)}),body:{}}}(e)),this._configMap.set(Lo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_PUSH,".").concat(x.CMD.MESSAGE_PUSH)}),body:{},keyMap:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",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"}}}}(e)),this._configMap.set(Go,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_PUSH,".").concat(x.CMD.MULTI_MESSAGE_PUSH)}),body:{},keyMap:{response:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}}(e)),this._configMap.set(Po,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.OPEN_IM,".").concat(x.CMD.MESSAGE_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{request:{sessionData:"SessionData"}}}}(e)),this._configMap.set(wo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_OPEN_STATUS,".").concat(x.CMD.STATUS_FORCEOFFLINE)}),body:{},keyMap:{response:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._configMap.set(Uo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_LONG_MESSAGE,".").concat(x.CMD.DOWNLOAD_MERGER_MESSAGE)}),body:{downloadKey:""},keyMap:{response:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}}(e)),this._configMap.set(bo,function(e){return{head:r({},e,{servcmd:"".concat(x.NAME.IM_LONG_MESSAGE,".").concat(x.CMD.UPLOAD_MERGER_MESSAGE)}),body:{messageList:[]},keyMap:{request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}}(e))}},{key:"has",value:function(e){return this._configMap.has(e)}},{key:"get",value:function(e){return this._configMap.get(e)}},{key:"update",value:function(){this._fillConfigMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(we.warn("".concat(this._className,".getKeyMap unknown protocolName:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.protocolName,n=e.requestData,o=this.get(t),a=null;if(n){var s=this._simpleDeepCopy(o),r=this._updateService(n,s),i=r.body,c=Object.create(null);for(var u in i)if(Object.prototype.hasOwnProperty.call(i,u)){if(c[u]=i[u],void 0===n[u])continue;c[u]=n[u]}r.body=c,a=this._getUplinkData(r)}else a=this._getUplinkData(o);return a}},{key:"_getUplinkData",value:function(e){var t=this._requestDataCleaner(e),n=kt(t.head),o=Mi(t.body,this._getRequestKeyMap(n));return t.body=o,t}},{key:"_updateService",value:function(e,t){var n=kt(t.head);if(t.head.servcmd.includes(x.NAME.GROUP)){var o=e.type,a=e.groupID,s=void 0===a?void 0:a,r=e.groupIDList,i=void 0===r?[]:r;Je(s)&&(s=i[0]||""),vt({type:o,groupID:s})&&(t.head.servcmd="".concat(x.NAME.GROUP_COMMUNITY,".").concat(n))}return t}},{key:"_getRequestKeyMap",value:function(e){var t=this.getKeyMap(e);return r({},hi.request,{},t.request)}},{key:"_requestDataCleaner",value:function(t){var n=Array.isArray(t)?[]:Object.create(null);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&nt(o)&&null!==t[o]&&void 0!==t[o]&&("object"!==e(t[o])?n[o]=t[o]:n[o]=this._requestDataCleaner.bind(this)(t[o]));return n}},{key:"_simpleDeepCopy",value:function(e){for(var t,n=Object.keys(e),o={},a=0,s=n.length;a<s;a++)t=n[a],ze(e[t])?o[t]=Array.from(e[t]):Ye(e[t])?o[t]=this._simpleDeepCopy(e[t]):o[t]=e[t];return o}}]),n}(),Gi=[Po],Pi=function(){function e(n){t(this,e),this._sessionModule=n,this._className="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("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._keys=M(this._eventHandlerMap.keys())}return o(e,[{key:"_c2cMessageArrayHandler",value:function(e){var t=this._sessionModule.getModule(Xt);if(t){if(e.dataList.forEach((function(e){if(1===e.isSyncMessage){var t=e.from;e.from=e.to,e.to=t}})),1===e.needSync)this._sessionModule.getModule(ln).startOnlineSync();t.onNewC2CMessage({dataList:e.dataList,isInstantMessage:!0})}}},{key:"_groupMessageArrayHandler",value:function(e){var t=this._sessionModule.getModule(Qt);t&&t.onNewGroupMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}},{key:"_groupTipsHandler",value:function(e){var t=this._sessionModule.getModule(Qt);if(t){var n=e.event,o=e.dataList,a=e.isInstantMessage,s=void 0===a||a,r=e.isSyncingEnded;switch(n){case 4:case 6:t.onNewGroupTips({event:n,dataList:o});break;case 5:o.forEach((function(e){ze(e.elements.revokedInfos)?t.onGroupMessageRevoked({dataList:o}):ze(e.elements.groupMessageReadNotice)?t.onGroupMessageReadNotice({dataList:o}):ze(e.elements.readReceiptList)?t.onReadReceiptList({dataList:o}):t.onNewGroupSystemNotice({dataList:o,isInstantMessage:s,isSyncingEnded:r})}));break;case 12:this._sessionModule.getModule(tn).onNewGroupAtTips({dataList:o});break;default:we.log("".concat(this._className,"._groupTipsHandler unknown event:").concat(n," dataList:"),o)}}}},{key:"_C2CNotifyMessageArrayHandler",value:function(e){var t=this,n=e.dataList;if(ze(n)){var o=this._sessionModule.getModule(Xt);n.forEach((function(e){if($e(e))if(e.hasOwnProperty("kickoutMsgNotify")){var a=e.kickoutMsgNotify,s=a.kickType,r=a.newInstanceInfo,i=void 0===r?{}:r;1===s?t._sessionModule.onMultipleAccountKickedOut(i):2===s&&t._sessionModule.onMultipleDeviceKickedOut(i)}else if(e.hasOwnProperty("c2cMessageRevokedNotify"))o&&o.onC2CMessageRevoked({dataList:n});else if(e.hasOwnProperty("c2cMessageReadReceipt"))o&&o.onC2CMessageReadReceipt({dataList:n});else if(e.hasOwnProperty("c2cMessageReadNotice"))o&&o.onC2CMessageReadNotice({dataList:n});else if(e.hasOwnProperty("muteNotificationsSync")){t._sessionModule.getModule(tn).onC2CMessageRemindTypeSynced({dataList:n})}}))}}},{key:"_profileHandler",value:function(e){this._sessionModule.getModule(Jt).onProfileModified({dataList:e.dataList});var t=this._sessionModule.getModule(Zt);t&&t.onFriendProfileModified({dataList:e.dataList})}},{key:"_relationChainHandler",value:function(e){this._sessionModule.getModule(Jt).onRelationChainModified({dataList:e.dataList});var t=this._sessionModule.getModule(Zt);t&&t.onRelationChainModified({dataList:e.dataList})}},{key:"_recentContactHandler",value:function(e){var t=e.dataList;if(ze(t)){var n=this._sessionModule.getModule(tn);n&&t.forEach((function(e){var t=e.pushType,o=e.recentContactTopItem,a=e.recentContactDeleteItem;1===t?n.onConversationDeleted(a.recentContactList):2===t?n.onConversationPinned(o.recentContactList):3===t&&n.onConversationUnpinned(o.recentContactList)}))}}},{key:"_allMessageReadHandler",value:function(e){var t=e.dataList,n=this._sessionModule.getModule(tn);n&&n.onPushedAllMessageRead(t)}},{key:"onMessage",value:function(e){var t=this,n=e.body;if(this._filterMessageFromIMOpenPush(e)){var o=n.eventArray,a=n.isInstantMessage,s=n.isSyncingEnded,r=n.needSync;if(ze(o))for(var i=null,c=null,u=0,l=0,d=o.length;l<d;l++){u=(i=o[l]).event;var p=Object.keys(i).find((function(e){return-1!==t._keys.indexOf(e)}));p?(c=14!==u?i[p]:{readAllC2CMessage:i[p],groupMessageReadInfoList:i.groupMessageReadNotice||[]},this._eventHandlerMap.get(p)({event:u,dataList:c,isInstantMessage:a,isSyncingEnded:s,needSync:r})):we.log("".concat(this._className,".onMessage unknown eventItem:").concat(i))}}}},{key:"_filterMessageFromIMOpenPush",value:function(e){var t=e.head,n=e.body,o=t.servcmd,a=!1;if(Je(o)||(a=o.includes(x.NAME.IM_CONFIG_MANAGER)||o.includes(x.NAME.OVERLOAD_PUSH)||o.includes(x.NAME.STAT_SERVICE)),!a)return!0;if(o.includes(x.CMD.PUSHED_CLOUD_CONTROL_CONFIG))this._sessionModule.getModule(_n).onPushedCloudControlConfig(n);else if(o.includes(x.CMD.PUSHED_COMMERCIAL_CONFIG)){this._sessionModule.getModule(Mn).onPushedConfig(n)}else if(o.includes(x.CMD.OVERLOAD_NOTIFY))this._sessionModule.onPushedServerOverload(n);else if(o.includes(x.CMD.KICK_OTHER)){var s=Date.now();this._sessionModule.reLoginOnKickOther();var r=new sa(pa),i=this._sessionModule.getModule($t).getLastWsHelloTs(),c=s-i;r.setMessage("last wshello time:".concat(i," diff:").concat(c,"ms")).setNetworkType(this._sessionModule.getNetworkType()).end()}return!1}}]),e}(),wi=[{cmd:x.CMD.GET_GROUP_INFO,interval:1,count:20},{cmd:x.CMD.SET_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:x.CMD.MODIFY_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:x.CMD.DELETE_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:x.CMD.CLEAR_GROUP_ATTRIBUTES,interval:5,count:10},{cmd:x.CMD.GET_GROUP_ATTRIBUTES,interval:5,count:20},{cmd:x.CMD.SET_ALL_MESSAGE_READ,interval:1,count:1}],bi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="SessionModule",o._platform=o.getPlatform(),o._protocolHandler=new Li(_(o)),o._messageDispatcher=new Pi(_(o)),o._commandFrequencyLimitMap=new Map,o._commandRequestInfoMap=new Map,o._serverOverloadInfoMap=new Map,o._init(),o.getInnerEmitterInstance().on(_r,o._onCloudConfigUpdated,_(o)),o}return o(a,[{key:"_init",value:function(){this._updateCommandFrequencyLimitMap(wi)}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("cmd_frequency_limit");Je(e)||(e=JSON.parse(e),this._updateCommandFrequencyLimitMap(e))}},{key:"_updateCommandFrequencyLimitMap",value:function(e){var t=this;e.forEach((function(e){t._commandFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})}))}},{key:"updateProtocolConfig",value:function(){this._protocolHandler.update()}},{key:"request",value:function(e){we.debug("".concat(this._className,".request options:"),e);var t=e.protocolName,n=e.tjgID;if(!this._protocolHandler.has(t))return we.warn("".concat(this._className,".request unknown protocol:").concat(t)),lr({code:Bo.CANNOT_FIND_PROTOCOL,message:Ho.CANNOT_FIND_PROTOCOL});var o=this.getProtocolData(e),a=o.head.servcmd;if(this._isFrequencyOverLimit(a))return lr({code:Bo.OVER_FREQUENCY_LIMIT,message:Ho.OVER_FREQUENCY_LIMIT});if(this._isServerOverload(a))return lr({code:Bo.OPEN_SERVICE_OVERLOAD_ERROR,message:Ho.OPEN_SERVICE_OVERLOAD_ERROR});Pt(n)||(o.head.tjgID=n);var s=this.getModule(pn);return Gi.includes(t)?s.simplySend(o):s.send(o)}},{key:"getKeyMap",value:function(e){return this._protocolHandler.getKeyMap(e)}},{key:"genCommonHead",value:function(){var e=this.getModule(nn);return{ver:"v4",platform:this._platform,websdkappid:w,websdkversion:P,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:51,tjgID:""}}},{key:"genCosSpecifiedHead",value:function(){var e=this.getModule(nn);return{ver:"v4",platform:this._platform,websdkappid:w,websdkversion:P,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:51}}},{key:"genSSOReportHead",value:function(){var e=this.getModule(nn);return{ver:"v4",platform:this._platform,websdkappid:w,websdkversion:P,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:51}}},{key:"getProtocolData",value:function(e){return this._protocolHandler.getProtocolData(e)}},{key:"onErrorCodeNotZero",value:function(e){var t=e.errorCode;if(t===Bo.HELLO_ANSWER_KICKED_OUT){var n=e.kickType,o=e.newInstanceInfo,a=void 0===o?{}:o;1===n?this.onMultipleAccountKickedOut(a):2===n&&this.onMultipleDeviceKickedOut(a)}t!==Bo.MESSAGE_A2KEY_EXPIRED&&t!==Bo.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.getModule(pn).reConnect())}},{key:"onMessage",value:function(e){var t=e.body,n=t.needAck,o=void 0===n?0:n,a=t.sessionData;1===o&&this._sendACK(a),this._messageDispatcher.onMessage(e)}},{key:"onReconnected",value:function(){this._reLoginOnReconnected()}},{key:"reLoginOnKickOther",value:function(){we.log("".concat(this._className,".reLoginOnKickOther")),this._reLogin()}},{key:"_reLoginOnReconnected",value:function(){we.log("".concat(this._className,"._reLoginOnReconnected")),this._reLogin()}},{key:"_reLogin",value:function(){var e=this;this.isLoggedIn()&&this.request({protocolName:yn}).then((function(t){var n=t.data.instanceID;e.getModule(nn).setStatusInstanceID(n),we.log("".concat(e._className,"._reLogin ok. start to sync unread messages")),e.getModule(ln).startSyncOnReconnected(),e.getModule(fn).startPull(),e.getModule(Qt).updateLocalMainSequenceOnReconnected()}))}},{key:"onMultipleAccountKickedOut",value:function(e){this.getModule($t).onMultipleAccountKickedOut(e)}},{key:"onMultipleDeviceKickedOut",value:function(e){this.getModule($t).onMultipleDeviceKickedOut(e)}},{key:"_onUserSigExpired",value:function(){this.getModule($t).onUserSigExpired()}},{key:"_sendACK",value:function(e){this.request({protocolName:Po,requestData:{sessionData:e}})}},{key:"_isFrequencyOverLimit",value:function(e){var t=e.split(".")[1];if(!this._commandFrequencyLimitMap.has(t))return!1;if(!this._commandRequestInfoMap.has(t))return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;var n=this._commandFrequencyLimitMap.get(t),o=n.count,a=n.interval,s=this._commandRequestInfoMap.get(t),r=s.startTime,i=s.requestCount;if(Date.now()-r>1e3*a)return this._commandRequestInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;i+=1,this._commandRequestInfoMap.set(t,{startTime:r,requestCount:i});var c=!1;return i>o&&(c=!0),c}},{key:"_isServerOverload",value:function(e){if(!this._serverOverloadInfoMap.has(e))return!1;var t=this._serverOverloadInfoMap.get(e),n=t.overloadTime,o=t.waitingTime,a=!1;return Date.now()-n<=1e3*o?a=!0:(this._serverOverloadInfoMap.delete(e),a=!1),a}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand,n=e.waitingTime;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:n}),we.warn("".concat(this._className,".onPushedServerOverload waitingTime:").concat(n,"s"))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._updateCommandFrequencyLimitMap(wi),this._commandRequestInfoMap.clear(),this._serverOverloadInfoMap.clear()}}]),a}(vn),Ui=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="MessageLossDetectionModule",o._maybeLostSequencesMap=new Map,o}return o(a,[{key:"onMessageMaybeLost",value:function(e,t,n){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);for(var o=this._maybeLostSequencesMap.get(e),a=0;a<n;a++)o.push(t+a);we.debug("".concat(this._className,".onMessageMaybeLost. maybeLostSequences:").concat(o))}},{key:"detectMessageLoss",value:function(e,t){var n=this._maybeLostSequencesMap.get(e);if(!Pt(n)&&!Pt(t)){var o=t.filter((function(e){return-1!==n.indexOf(e)}));if(we.debug("".concat(this._className,".detectMessageLoss. matchedSequences:").concat(o)),n.length===o.length)we.info("".concat(this._className,".detectMessageLoss no message loss. conversationID:").concat(e));else{var a,s=n.filter((function(e){return-1===o.indexOf(e)})),r=s.length;r<=5?a=e+"-"+s.join("-"):(s.sort((function(e,t){return e-t})),a=e+" start:"+s[0]+" end:"+s[r-1]+" count:"+r),new sa(Cs).setMessage(a).setNetworkType(this.getNetworkType()).setLevel("warning").end(),we.warn("".concat(this._className,".detectMessageLoss message loss detected. conversationID:").concat(e," lostSequences:").concat(s))}n.length=0}}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._maybeLostSequencesMap.clear()}}]),a}(vn),Fi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="CloudControlModule",o._cloudConfig=new Map,o._expiredTime=0,o._version=0,o._isFetching=!1,o}return o(a,[{key:"getCloudConfig",value:function(e){return Je(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}},{key:"_canFetchConfig",value:function(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetchConfig();if(we.log("".concat(this._className,".fetchConfig canFetchConfig:").concat(t)),t){var n=new sa(Ls),o=this.getModule(nn).getSDKAppID();this._isFetching=!0,this.request({protocolName:Fo,requestData:{SDKAppID:o,version:this._version}}).then((function(t){e._isFetching=!1,n.setMessage("version:".concat(e._version," newVersion:").concat(t.data.version," config:").concat(t.data.cloudControlConfig)).setNetworkType(e.getNetworkType()).end(),we.log("".concat(e._className,".fetchConfig ok")),e._parseCloudControlConfig(t.data)})).catch((function(t){e._isFetching=!1,e.probeNetwork().then((function(e){var o=m(e,2),a=o[0],s=o[1];n.setError(t,a,s).end()})),we.log("".concat(e._className,".fetchConfig failed. error:"),t),e._setExpiredTimeOnResponseError(12e4)}))}}},{key:"onPushedCloudControlConfig",value:function(e){we.log("".concat(this._className,".onPushedCloudControlConfig")),new sa(Gs).setNetworkType(this.getNetworkType()).setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parseCloudControlConfig(e)}},{key:"onCheckTimer",value:function(e){this._canFetchConfig()&&this.fetchConfig()}},{key:"_parseCloudControlConfig",value:function(e){var t=this,n="".concat(this._className,"._parseCloudControlConfig"),o=e.errorCode,a=e.errorMessage,s=e.cloudControlConfig,r=e.version,i=e.expiredTime;if(0===o){if(this._version!==r){var c=null;try{c=JSON.parse(s)}catch(u){we.error("".concat(n," JSON parse error:").concat(s))}c&&(this._cloudConfig.clear(),Object.keys(c).forEach((function(e){t._cloudConfig.set(e,c[e])})),this._version=r,this.emitInnerEvent(_r))}this._expiredTime=Date.now()+1e3*i}else Je(o)?(we.log("".concat(n," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(n," errorCode:").concat(o," errorMessage:").concat(a)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}]),a}(vn),qi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="PullGroupMessageModule",o._remoteLastMessageSequenceMap=new Map,o.PULL_LIMIT_COUNT=15,o}return o(a,[{key:"startPull",value:function(){var e=this,t=this._getNeedPullConversationList();this._getRemoteLastMessageSequenceList().then((function(){var n=e.getModule(tn);t.forEach((function(t){var o=t.conversationID,a=o.replace(D.CONV_GROUP,""),s=n.getGroupLocalLastMessageSequence(o),r=e._remoteLastMessageSequenceMap.get(a)||0,i=r-s;we.log("".concat(e._className,".startPull groupID:").concat(a," localLastMessageSequence:").concat(s," ")+"remoteLastMessageSequence:".concat(r," diff:").concat(i)),s>0&&i>=1&&i<300&&e._pullMissingMessage({groupID:a,localLastMessageSequence:s,remoteLastMessageSequence:r,diff:i})}))}))}},{key:"_getNeedPullConversationList",value:function(){return this.getModule(tn).getLocalConversationList().filter((function(e){return e.type===D.CONV_GROUP&&e.groupProfile.type!==D.GRP_AVCHATROOM}))}},{key:"_getRemoteLastMessageSequenceList",value:function(){var e=this;return this.getModule(Qt).getGroupList().then((function(t){for(var n=t.data.groupList,o=void 0===n?[]:n,a=0;a<o.length;a++){var s=o[a],r=s.groupID,i=s.nextMessageSeq;if(s.type!==D.GRP_AVCHATROOM){var c=i-1;e._remoteLastMessageSequenceMap.set(r,c)}}}))}},{key:"_pullMissingMessage",value:function(e){var t=this,n=e.localLastMessageSequence,o=e.remoteLastMessageSequence,a=e.diff;e.count=a>this.PULL_LIMIT_COUNT?this.PULL_LIMIT_COUNT:a,e.sequence=a>this.PULL_LIMIT_COUNT?n+this.PULL_LIMIT_COUNT:n+a,this._getGroupMissingMessage(e).then((function(s){s.length>0&&(s[0].sequence+1<=o&&(e.localLastMessageSequence=n+t.PULL_LIMIT_COUNT,e.diff=a-t.PULL_LIMIT_COUNT,t._pullMissingMessage(e)),t.getModule(Qt).onNewGroupMessage({dataList:s,isInstantMessage:!1}))}))}},{key:"_getGroupMissingMessage",value:function(e){var t=this,n=new sa(rs);return this.request({protocolName:ro,requestData:{groupID:e.groupID,count:e.count,sequence:e.sequence}}).then((function(o){var a=o.data.messageList,s=void 0===a?[]:a;return n.setNetworkType(t.getNetworkType()).setMessage("groupID:".concat(e.groupID," count:").concat(e.count," sequence:").concat(e.sequence," messageList length:").concat(s.length)).end(),s})).catch((function(e){t.probeNetwork().then((function(t){var o=m(t,2),a=o[0],s=o[1];n.setError(e,a,s).end()}))}))}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._remoteLastMessageSequenceMap.clear()}}]),a}(vn),Vi=function(){function e(){t(this,e),this._className="AvgE2EDelay",this._e2eDelayArray=[]}return o(e,[{key:"addMessageDelay",value:function(e){var t=Oe()-e;t>=0&&this._e2eDelayArray.push(t)}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var n=0;return e.forEach((function(e){n+=e})),Rt(n/t,1)}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,n=e.min,o=e.max;return t.filter((function(e){return n<=e&&e<o})).length}},{key:"_calcPercent",value:function(e,t){var n=Rt(e/t*100,2);return n>100&&(n=100),n}},{key:"_checkE2EDelayException",value:function(e,t){var n=e.filter((function(e){return e>t}));if(n.length>0){var o=n.length,a=Math.min.apply(Math,M(n)),s=Math.max.apply(Math,M(n)),r=this._calcAvg(n,o),i=Rt(o/e.length*100,2);if(i>50)new sa(Fa).setMessage("message e2e delay exception. count:".concat(o," min:").concat(a," max:").concat(s," avg:").concat(r," percent:").concat(i)).setLevel("warning").end()}}},{key:"getStatResult",value:function(){var e=this._e2eDelayArray.length;if(0===e)return null;var t=M(this._e2eDelayArray),n=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),o=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),a=this._calcPercent(n,e),s=this._calcPercent(o,e),r=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:n,percentOfCountLessThan1Second:a,countLessThan3Second:o,percentOfCountLessThan3Second:s,avgDelay:r}}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),e}(),Ki=function(){function e(){t(this,e),this._className="AvgRTT",this._requestCount=0,this._rttArray=[]}return o(e,[{key:"addRequestCount",value:function(){this._requestCount+=1}},{key:"addRTT",value:function(e){this._rttArray.push(e)}},{key:"_calcTotalCount",value:function(){return this._requestCount}},{key:"_calcRTTCount",value:function(e){return e.length}},{key:"_calcSuccessRateOfRequest",value:function(e,t){if(0===t)return 0;var n=Rt(e/t*100,2);return n>100&&(n=100),n}},{key:"_calcAvg",value:function(e,t){if(0===t)return 0;var n=0;return e.forEach((function(e){n+=e})),parseInt(n/t)}},{key:"_calcMax",value:function(){return Math.max.apply(Math,M(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,M(this._rttArray))}},{key:"getStatResult",value:function(){var e=this._calcTotalCount(),t=M(this._rttArray);if(0===e)return null;var n=this._calcRTTCount(t),o=this._calcSuccessRateOfRequest(n,e),a=this._calcAvg(t,n);return we.log("".concat(this._className,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(a)),this.reset(),{totalCount:e,rttCount:n,successRateOfRequest:o,avgRTT:a}}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),e}(),xi=function(){function e(){t(this,e),this._map=new Map}return o(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}))}},{key:"addTotalCount",value:function(e){return!(Je(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}},{key:"addSuccessCount",value:function(e){return!(Je(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}},{key:"addFailedCountOfUserSide",value:function(e){return!(Je(e)||!this._map.has(e))&&(this._map.get(e).failedCountOfUserSide+=1,!0)}},{key:"addCost",value:function(e,t){return!(Je(e)||!this._map.has(e))&&(this._map.get(e).costArray.push(t),!0)}},{key:"addFileSize",value:function(e,t){return!(Je(e)||!this._map.has(e))&&(this._map.get(e).fileSizeArray.push(t),!0)}},{key:"_calcSuccessRateOfBusiness",value:function(e){if(Je(e)||!this._map.has(e))return-1;var t=this._map.get(e),n=Rt(t.successCount/t.totalCount*100,2);return n>100&&(n=100),n}},{key:"_calcSuccessRateOfPlatform",value:function(e){if(Je(e)||!this._map.has(e))return-1;var t=this._map.get(e),n=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return(n=Rt(n,2))>100&&(n=100),n}},{key:"_calcTotalCount",value:function(e){return Je(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return Je(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){if(Je(e)||!this._map.has(e))return-1;var t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return Je(e)||!this._map.has(e)?-1:e===Xo?this._calcAvgSpeed(e):this._calcAvgCost(e)}},{key:"_calcAvgCost",value:function(e){var t=this._map.get(e).costArray.length;if(0===t)return 0;var n=0;return this._map.get(e).costArray.forEach((function(e){n+=e})),parseInt(n/t)}},{key:"_calcAvgSpeed",value:function(e){var t=0,n=0;return this._map.get(e).costArray.forEach((function(e){t+=e})),this._map.get(e).fileSizeArray.forEach((function(e){n+=e})),parseInt(1e3*n/t)}},{key:"getStatResult",value:function(e){var t=this._calcTotalCount(e);if(0===t)return null;var n=this._calcSuccessCountOfBusiness(e),o=this._calcSuccessRateOfBusiness(e),a=this._calcSuccessCountOfPlatform(e),s=this._calcSuccessRateOfPlatform(e),r=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:n,successRateOfBusiness:o,successCountOfPlatform:a,successRateOfPlatform:s,avgValue:r}}},{key:"reset",value:function(e){Je(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),e}(),Bi=function(){function e(){t(this,e),this._lastMap=new Map,this._currentMap=new Map}return o(e,[{key:"initMap",value:function(e){var t=this;e.forEach((function(e){t._lastMap.set(e,new Map),t._currentMap.set(e,new Map)}))}},{key:"addMessageSequence",value:function(e){var t=e.key,n=e.message;if(Je(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var o=n.conversationID,a=n.sequence,s=o.replace(D.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(s)){var r=this._lastMap.get(t).get(s),i=r.length-1;a>r[0]&&a<r[i]?(r.push(a),r.sort(),this._lastMap.get(t).set(s,r)):this._addCurrentMap(e)}else this._addCurrentMap(e);return!0}},{key:"_addCurrentMap",value:function(e){var t=e.key,n=e.message,o=n.conversationID,a=n.sequence,s=o.replace(D.CONV_GROUP,"");this._currentMap.get(t).has(s)||this._currentMap.get(t).set(s,[]),this._currentMap.get(t).get(s).push(a)}},{key:"_copyData",value:function(e){if(!Je(e)){this._lastMap.set(e,new Map);var t,n=this._lastMap.get(e),o=C(this._currentMap.get(e));try{for(o.s();!(t=o.n()).done;){var a=m(t.value,2),s=a[0],r=a[1];n.set(s,r)}}catch(i){o.e(i)}finally{o.f()}n=null,this._currentMap.set(e,new Map)}}},{key:"getStatResult",value:function(e){if(Je(this._currentMap.get(e))||Je(this._lastMap.get(e)))return null;if(0===this._lastMap.get(e).size)return this._copyData(e),null;var t=0,n=0;if(this._lastMap.get(e).forEach((function(e,o){var a=M(e.values()),s=a.length,r=a[s-1]-a[0]+1;t+=r,n+=s})),0===t)return null;var o=Rt(n/t*100,2);return o>100&&(o=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:n,successRateOfMessageReceived:o}}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),e}(),Hi=function(e){i(a,e);var n=f(a);function a(e){var o;t(this,a),(o=n.call(this,e))._className="QualityStatModule",o.TAG="im-ssolog-quality-stat",o.reportIndex=0,o.wholePeriod=!1,o._qualityItems=[jo,Wo,Yo,$o,zo,Jo,Xo,Qo,Zo,ea],o._messageSentItems=[Yo,$o,zo,Jo,Xo],o._messageReceivedItems=[Qo,Zo,ea],o.REPORT_INTERVAL=120,o.REPORT_SDKAPPID_BLACKLIST=[],o.REPORT_TINYID_WHITELIST=[],o._statInfoArr=[],o._avgRTT=new Ki,o._avgE2EDelay=new Vi,o._rateMessageSent=new xi,o._rateMessageReceived=new Bi;var s=o.getInnerEmitterInstance();return s.on(gr,o._onLoginSuccess,_(o)),s.on(_r,o._onCloudConfigUpdated,_(o)),o}return o(a,[{key:"_onLoginSuccess",value:function(){var e=this;this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var t=this.getModule(on),n=t.getItem(this.TAG,!1);!Pt(n)&&Qe(n.forEach)&&(we.log("".concat(this._className,"._onLoginSuccess.get quality stat log in storage, nums=").concat(n.length)),n.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),n=this.getCloudConfig("q_rpt_tinyid_wl");Je(e)||(this.REPORT_INTERVAL=Number(e)),Je(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((function(e){return Number(e)}))),Je(n)||(this.REPORT_TINYID_WHITELIST=n.split(","))}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}},{key:"addRequestCount",value:function(){this._avgRTT.addRequestCount()}},{key:"addRTT",value:function(e){this._avgRTT.addRTT(e)}},{key:"addMessageDelay",value:function(e){this._avgE2EDelay.addMessageDelay(e)}},{key:"addTotalCount",value:function(e){this._rateMessageSent.addTotalCount(e)||we.warn("".concat(this._className,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||we.warn("".concat(this._className,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||we.warn("".concat(this._className,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||we.warn("".concat(this._className,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||we.warn("".concat(this._className,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||we.warn("".concat(this._className,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var t={},n=oa[this.getNetworkType()];Je(n)&&(n=8);var o={qualityType:ta[e],timestamp:ke(),networkType:n,extension:""};switch(e){case jo:t=this._avgRTT.getStatResult();break;case Wo:t=this._avgE2EDelay.getStatResult();break;case Yo:case $o:case zo:case Jo:case Xo:t=this._rateMessageSent.getStatResult(e);break;case Qo:case Zo:case ea:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:r({},o,{},t)}},{key:"_report",value:function(e){var t=this,n=[],o=null;Je(e)?this._qualityItems.forEach((function(e){null!==(o=t._getQualityItem(e))&&(o.reportIndex=t.reportIndex,o.wholePeriod=t.wholePeriod,n.push(o))})):null!==(o=this._getQualityItem(e))&&(o.reportIndex=this.reportIndex,o.wholePeriod=this.wholePeriod,n.push(o)),we.debug("".concat(this._className,"._report"),n),this._statInfoArr.length>0&&(n=n.concat(this._statInfoArr),this._statInfoArr=[]);var a=this.getModule(nn),s=a.getSDKAppID(),r=a.getTinyID();Ot(this.REPORT_SDKAPPID_BLACKLIST,s)&&!Lt(this.REPORT_TINYID_WHITELIST,r)&&(n=[]),n.length>0&&this._doReport(n)}},{key:"_doReport",value:function(e){var t=this,n={header:ti(this),quality:e};this.request({protocolName:Ro,requestData:r({},n)}).then((function(){t.reportIndex++,t.wholePeriod=!1})).catch((function(n){we.warn("".concat(t._className,"._doReport, online:").concat(t.getNetworkType()," error:"),n),t._statInfoArr=t._statInfoArr.concat(e),t._flushAtOnce()}))}},{key:"_flushAtOnce",value:function(){var e=this.getModule(on),t=e.getItem(this.TAG,!1),n=this._statInfoArr;if(Pt(t))we.log("".concat(this._className,"._flushAtOnce count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1);else{var o=n.concat(t);o.length>10&&(o=o.slice(0,10)),we.log("".concat(this.className,"._flushAtOnce count:").concat(o.length)),e.setItem(this.TAG,o,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){we.log("".concat(this._className,".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()}}]),a}(vn),ji=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="WorkerTimerModule",o._isWorkerEnabled=!0,o._workerTimer=null,o._init(),o.getInnerEmitterInstance().on(_r,o._onCloudConfigUpdated,_(o)),o}return o(a,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ee}},{key:"startWorkerTimer",value:function(){we.log("".concat(this._className,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){we.log("".concat(this._className,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){if(Ee){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) } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);var t=this;this._workerTimer.onmessage=function(){t._moduleManager.onCheckTimer()}}}},{key:"_onCloudConfigUpdated",value:function(){var e=this.getCloudConfig("enable_worker");we.log("".concat(this._className,"._onCloudConfigUpdated enableWorker:").concat(e)),"1"===e?!this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._moduleManager.onWorkerTimerEnabled()):this._isWorkerEnabled&&Ee&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._moduleManager.onWorkerTimerDisabled())}},{key:"terminate",value:function(){we.log("".concat(this._className,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset"))}}]),a}(vn),Wi=function(){function e(){t(this,e),this._className="PurchasedFeatureHandler",this._purchasedFeatureMap=new Map}return o(e,[{key:"isValidPurchaseBits",value:function(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"parsePurchaseBits",value:function(e){var t="".concat(this._className,".parsePurchaseBits");if(this.isValidPurchaseBits(e)){this._purchasedFeatureMap.clear();for(var n=Object.values(B),o=null,a=e.length-1,s=0;a>=0;a--,s++)o=s<32?new O(0,Math.pow(2,s)).toString():new O(Math.pow(2,s-32),0).toString(),-1!==n.indexOf(o)&&("1"===e[a]?this._purchasedFeatureMap.set(o,!0):this._purchasedFeatureMap.set(o,!1))}else we.warn("".concat(t," invalid purchase bits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._purchasedFeatureMap.get(e)}},{key:"clear",value:function(){this._purchasedFeatureMap.clear()}}]),e}(),Yi=function(e){i(a,e);var n=f(a);function a(e){var o;return t(this,a),(o=n.call(this,e))._className="CommercialConfigModule",o._expiredTime=0,o._isFetching=!1,o._purchasedFeatureHandler=new Wi,o}return o(a,[{key:"_canFetch",value:function(){return this.isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"fetchConfig",value:function(){var e=this,t=this._canFetch(),n="".concat(this._className,".fetchConfig");if(we.log("".concat(n," canFetch:").concat(t)),t){var o=new sa(Ps);o.setNetworkType(this.getNetworkType());var a=this.getModule(nn).getSDKAppID();this._isFetching=!0,this.request({protocolName:Vo,requestData:{SDKAppID:a}}).then((function(t){o.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),we.log("".concat(n," ok.")),e._parseConfig(t.data),e._isFetching=!1})).catch((function(t){e.probeNetwork().then((function(e){var n=m(e,2),a=n[0],s=n[1];o.setError(t,a,s).end()})),e._isFetching=!1}))}}},{key:"onPushedConfig",value:function(e){var t="".concat(this._className,".onPushedConfig");we.log("".concat(t)),new sa(ws).setNetworkType(this.getNetworkType()).setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._className,"._parseConfig"),n=e.errorCode,o=e.errorMessage,a=e.purchaseBits,s=e.expiredTime;0===n?(this._purchasedFeatureHandler.parsePurchaseBits(a),this._expiredTime=Date.now()+1e3*s):Je(n)?(we.log("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(we.error("".concat(t," errorCode:").concat(n," errorMessage:").concat(o)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"hasPurchasedFeature",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),a}(vn),$i=function(){function e(n){t(this,e);var o=new sa(ra);this._className="ModuleManager",this._isReady=!1,this._reason=Bo.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(nn,new Jr(this,n)),this._moduleMap.set(Mn,new Yi(this)),this._moduleMap.set(_n,new Fi(this)),this._moduleMap.set(hn,new ji(this)),this._moduleMap.set(mn,new Hi(this)),this._moduleMap.set(pn,new Oi(this)),this._moduleMap.set(dn,new bi(this)),this._moduleMap.set($t,new Xr(this)),this._moduleMap.set(zt,new pi(this)),this._moduleMap.set(Jt,new zr(this)),this._moduleMap.set(Xt,new dr(this)),this._moduleMap.set(tn,new Lr(this)),this._moduleMap.set(Qt,new Br(this)),this._moduleMap.set(en,new jr(this)),this._moduleMap.set(on,new Zr(this)),this._moduleMap.set(an,new ni(this)),this._moduleMap.set(sn,new si(this)),this._moduleMap.set(rn,new ii(this)),this._moduleMap.set(cn,new ci(this)),this._moduleMap.set(un,new gi(this)),this._moduleMap.set(ln,new _i(this)),this._moduleMap.set(gn,new Ui(this)),this._moduleMap.set(fn,new qi(this)),this._eventThrottleMap=new Map;var a=n.instanceID,s=n.oversea,r=n.SDKAppID,i="instanceID:".concat(a," SDKAppID:").concat(r," host:").concat(Dt()," oversea:").concat(s," inBrowser:").concat(ne," inMiniApp:").concat(te)+" workerAvailable:".concat(Ee," UserAgent:").concat(se);sa.bindEventStatModule(this._moduleMap.get(an)),o.setMessage("".concat(i," ").concat(function(){var e="";if(te)try{var t=oe.getSystemInfoSync(),n=t.model,o=t.version,a=t.system,s=t.platform,r=t.SDKVersion;e="model:".concat(n," version:").concat(o," system:").concat(a," platform:").concat(s," SDKVersion:").concat(r)}catch(i){e=""}return e}())).end(),we.info("SDK ".concat(i)),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}return o(e,[{key:"_startTimer",value:function(){var e=this._moduleMap.get(hn),t=e.isWorkerEnabled();we.log("".concat(this._className,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){we.log("".concat(this._className,"._startMainThreadTimer")),this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3))}},{key:"stopTimer",value:function(){var e=this._moduleMap.get(hn),t=e.isWorkerEnabled();we.log("".concat(this._className,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){we.log("".concat(this._className,"._stopMainThreadTimer")),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){we.log("".concat(this._className,"._stopMainThreadSocket"));var e=this._moduleMap.get(pn);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){we.log("".concat(this._className,"._startMainThreadSocket"));var e=this._moduleMap.get(pn);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){we.log("".concat(this._className,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){we.log("".concat(this._className,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var n=m(e.value,2)[1];n.onCheckTimer&&n.onCheckTimer(this._checkCount)}}catch(o){t.e(o)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._moduleMap.get($t),this._moduleMap.get(tn)],this._readyList.forEach((function(t){t.ready((function(){return e._onModuleReady()}))}))}},{key:"_onModuleReady",value:function(){var e=!0;if(this._readyList.forEach((function(t){t.isReady()||(e=!1)})),e&&!this._isReady){this._isReady=!0,this._outerEmitter.emit(S.SDK_READY);var t=Date.now()-this._startLoginTs;we.warn("SDK is ready. cost ".concat(t," ms")),this._startLoginTs=Date.now();var n=this._moduleMap.get(sn).getNetworkType(),o=this._ssoLogForReady.getStartTs()+Ae;this._ssoLogForReady.setNetworkType(n).setMessage(t).start(o).end()}}},{key:"login",value:function(){0===this._startLoginTs&&(Re(),this._startLoginTs=Date.now(),this._startTimer(),this._moduleMap.get(sn).start(),this._ssoLogForReady=new sa(ia),this._reason=Bo.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOuterEmitterInstance",value:function(){return null===this._outerEmitter&&(this._outerEmitter=new ri,cr(this._outerEmitter),this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(e,t){var n=this;if(e===S.CONVERSATION_LIST_UPDATED||e===S.FRIEND_LIST_UPDATED||e===S.GROUP_LIST_UPDATED)if(this._eventThrottleMap.has(e)){var o=Date.now(),a=this._eventThrottleMap.get(e);o-a.last<1e3?(a.timeoutID&&clearTimeout(a.timeoutID),a.timeoutID=setTimeout((function(){a.last=o,n._outerEmitter._emit.apply(n._outerEmitter,[e,{name:e,data:n._getEventData(e)}])}),500)):(a.last=o,this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._outerEmitter._emit.apply(this._outerEmitter,[e,{name:e,data:arguments[1]}])}.bind(this)),this._outerEmitter}},{key:"_getEventData",value:function(e){return e===S.CONVERSATION_LIST_UPDATED?this._moduleMap.get(tn).getLocalConversationList():e===S.FRIEND_LIST_UPDATED?this._moduleMap.get(Zt).getLocalFriendList(!1):e===S.GROUP_LIST_UPDATED?this._moduleMap.get(Qt).getLocalGroupList():void 0}},{key:"getInnerEmitterInstance",value:function(){return null===this._innerEmitter&&(this._innerEmitter=new ri,this._innerEmitter._emit=this._innerEmitter.emit,this._innerEmitter.emit=function(e,t){var n;$e(arguments[1])&&arguments[1].data?(we.warn("inner eventData has data property, please check!"),n=[e,{name:arguments[0],data:arguments[1].data}]):n=[e,{name:arguments[0],data:arguments[1]}],this._innerEmitter._emit.apply(this._innerEmitter,n)}.bind(this)),this._innerEmitter}},{key:"hasModule",value:function(e){return this._moduleMap.has(e)}},{key:"getModule",value:function(e){return this._moduleMap.get(e)}},{key:"isReady",value:function(){return this._isReady}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"onError",value:function(e){we.warn("Oops! code:".concat(e.code," message:").concat(e.message)),new sa(bs).setMessage("code:".concat(e.code," message:").concat(e.message)).setNetworkType(this.getModule(sn).getNetworkType()).setLevel("error").end(),this.getOuterEmitterInstance().emit(S.ERROR,e)}},{key:"reset",value:function(){we.log("".concat(this._className,".reset")),Re();var e,t=C(this._moduleMap);try{for(t.s();!(e=t.n()).done;){var n=m(e.value,2)[1];n.reset&&n.reset()}}catch(r){t.e(r)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._outerEmitter.emit(S.SDK_NOT_READY);var o,a=C(this._eventThrottleMap);try{for(a.s();!(o=a.n()).done;){var s=m(o.value,2)[1];s.timeoutID&&clearTimeout(s.timeoutID)}}catch(r){a.e(r)}finally{a.f()}this._eventThrottleMap.clear()}}]),e}(),zi=function(){function e(){t(this,e),this._funcMap=new Map}return o(e,[{key:"defense",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;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);var o=null;return this._funcMap.get(e).has(t)?o=this._funcMap.get(e).get(t):(o=this._pack(e,t,n),this._funcMap.get(e).set(t,o)),o}},{key:"defenseOnce",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return"function"!=typeof t?null:this._pack(e,t,n)}},{key:"find",value:function(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):(we.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(we.log("SafetyCallback.find: 找不到 eventName-".concat(e," 对应的 func")),null)}},{key:"delete",value:function(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)))}},{key:"_pack",value:function(e,t,n){return function(){try{t.apply(n,Array.from(arguments))}catch(r){var o=Object.values(S).indexOf(e);if(-1!==o){var a=Object.keys(S)[o];we.warn("接入侧事件 TIM.EVENT.".concat(a," 对应的回调函数逻辑存在问题,请检查!"),r)}var s=new sa(Os);s.setMessage("eventName:".concat(e)).setMoreMessage(r.message).end()}}}}]),e}(),Ji=function(){function e(n){t(this,e);var o={SDKAppID:n.SDKAppID,unlimitedAVChatRoom:n.unlimitedAVChatRoom||!1,scene:n.scene||"",oversea:n.oversea||!1,instanceID:St(),devMode:n.devMode||!1,proxyServer:n.proxyServer||void 0};this._moduleManager=new $i(o),this._safetyCallbackFactory=new zi}return o(e,[{key:"onError",value:function(e){this._moduleManager.onError(e)}},{key:"login",value:function(e){return this._moduleManager.login(),this._moduleManager.getModule($t).login(e)}},{key:"logout",value:function(){var e=this;return this._moduleManager.getModule($t).logout().then((function(t){return e._moduleManager.reset(),t}))}},{key:"isReady",value:function(){return this._moduleManager.isReady()}},{key:"getNotReadyReason",value:function(){return this._moduleManager.getNotReadyReason()}},{key:"destroy",value:function(){var e=this;return this.logout().finally((function(){e._moduleManager.stopTimer(),e._moduleManager.getModule(hn).terminate(),e._moduleManager.getModule(pn).dealloc();var t=e._moduleManager.getOuterEmitterInstance(),n=e._moduleManager.getModule(nn);t.emit(S.SDK_DESTROY,{SDKAppID:n.getSDKAppID()})}))}},{key:"on",value:function(e,t,n){e===S.GROUP_SYSTEM_NOTICE_RECEIVED&&we.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://web.sdk.qcloud.com/im/doc/zh-cn/Message.html#.GroupSystemNoticePayload"),we.debug("on","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().on(e,this._safetyCallbackFactory.defense(e,t,n),n)}},{key:"once",value:function(e,t,n){we.debug("once","eventName:".concat(e)),this._moduleManager.getOuterEmitterInstance().once(e,this._safetyCallbackFactory.defenseOnce(e,t,n),n||this)}},{key:"off",value:function(e,t,n,o){we.debug("off","eventName:".concat(e));var a=this._safetyCallbackFactory.find(e,t);null!==a&&(this._moduleManager.getOuterEmitterInstance().off(e,a,n,o),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._moduleManager.getModule(un).registerPlugin(e)}},{key:"setLogLevel",value:function(e){if(e<=0){console.log([""," ________ ______ __ __ __ __ ________ _______","| \\| \\| \\ / \\| \\ _ | \\| \\| \\"," \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\"," | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$"," | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$"," | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\"," | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$"," | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$"," \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$","",""].join("\n")),console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc","color:#006eff"),console.log("%c从v2.11.2起,SDK 支持了 WebSocket,小程序需要添加受信域名!升级指引: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-02-upgradeguideline.html","color:#ff0000");console.log(["","参考以下文档,会更快解决问题哦!(#^.^#)\n","SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n","SDK 接口文档: https://web.sdk.qcloud.com/im/doc/zh-cn/SDK.html\n","常见问题: https://web.sdk.qcloud.com/im/doc/zh-cn/tutorial-01-faq.html\n","反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n","如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"))}we.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._moduleManager.getModule(zt).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._moduleManager.getModule(zt).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._moduleManager.getModule(zt).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._moduleManager.getModule(zt).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._moduleManager.getModule(zt).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._moduleManager.getModule(zt).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._moduleManager.getModule(zt).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._moduleManager.getModule(zt).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._moduleManager.getModule(zt).createLocationMessage(e)}},{key:"createMergerMessage",value:function(e){return this._moduleManager.getModule(zt).createMergerMessage(e)}},{key:"downloadMergerMessage",value:function(e){return e.type!==D.MSG_MERGER?lr(new rr({code:Bo.MESSAGE_MERGER_TYPE_INVALID,message:Ho.MESSAGE_MERGER_TYPE_INVALID})):Pt(e.payload.downloadKey)?lr(new rr({code:Bo.MESSAGE_MERGER_KEY_INVALID,message:Ho.MESSAGE_MERGER_KEY_INVALID})):this._moduleManager.getModule(zt).downloadMergerMessage(e).catch((function(e){return lr(new rr({code:Bo.MESSAGE_MERGER_DOWNLOAD_FAIL,message:Ho.MESSAGE_MERGER_DOWNLOAD_FAIL}))}))}},{key:"createForwardMessage",value:function(e){return this._moduleManager.getModule(zt).createForwardMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof Zs?this._moduleManager.getModule(zt).sendMessageInstance(e,t):lr(new rr({code:Bo.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:Ho.MESSAGE_SEND_NEED_MESSAGE_INSTANCE}))}},{key:"callExperimentalAPI",value:function(e,t){return"handleGroupInvitation"===e?this._moduleManager.getModule(Qt).handleGroupInvitation(t):lr(new rr({code:Bo.INVALID_OPERATION,message:Ho.INVALID_OPERATION}))}},{key:"revokeMessage",value:function(e){return this._moduleManager.getModule(zt).revokeMessage(e)}},{key:"resendMessage",value:function(e){return this._moduleManager.getModule(zt).resendMessage(e)}},{key:"deleteMessage",value:function(e){return this._moduleManager.getModule(zt).deleteMessage(e)}},{key:"getMessageList",value:function(e){return this._moduleManager.getModule(tn).getMessageList(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._moduleManager.getModule(Qt).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._moduleManager.getModule(Qt).getReadReceiptList(e)}},{key:"getGroupMessageReadMemberList",value:function(e){return this._moduleManager.getModule(Qt).getReadReceiptDetail(e)}},{key:"findMessage",value:function(e){return this._moduleManager.getModule(tn).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._moduleManager.getModule(tn).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._moduleManager.getModule(tn).getConversationList(e)}},{key:"getConversationProfile",value:function(e){return this._moduleManager.getModule(tn).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._moduleManager.getModule(tn).deleteConversation(e)}},{key:"pinConversation",value:function(e){return this._moduleManager.getModule(tn).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._moduleManager.getModule(tn).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._moduleManager.getModule(tn).setMessageRemindType(e)}},{key:"getMyProfile",value:function(){return this._moduleManager.getModule(Jt).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._moduleManager.getModule(Jt).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._moduleManager.getModule(Jt).updateMyProfile(e)}},{key:"getBlacklist",value:function(){return this._moduleManager.getModule(Jt).getLocalBlacklist()}},{key:"addToBlacklist",value:function(e){return this._moduleManager.getModule(Jt).addBlacklist(e)}},{key:"removeFromBlacklist",value:function(e){return this._moduleManager.getModule(Jt).deleteBlacklist(e)}},{key:"getFriendList",value:function(){var e=this._moduleManager.getModule(Zt);return e?e.getLocalFriendList():lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"addFriend",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.addFriend(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"deleteFriend",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.deleteFriend(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"checkFriend",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.checkFriend(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"getFriendProfile",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.getFriendProfile(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"updateFriend",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.updateFriend(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"getFriendApplicationList",value:function(){var e=this._moduleManager.getModule(Zt);return e?e.getLocalFriendApplicationList():lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"acceptFriendApplication",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.acceptFriendApplication(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"refuseFriendApplication",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.refuseFriendApplication(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"deleteFriendApplication",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.deleteFriendApplication(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"setFriendApplicationRead",value:function(){var e=this._moduleManager.getModule(Zt);return e?e.setFriendApplicationRead():lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"getFriendGroupList",value:function(){var e=this._moduleManager.getModule(Zt);return e?e.getLocalFriendGroupList():lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"createFriendGroup",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.createFriendGroup(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"deleteFriendGroup",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.deleteFriendGroup(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"addToFriendGroup",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.addToFriendGroup(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"removeFromFriendGroup",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.removeFromFriendGroup(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"renameFriendGroup",value:function(e){var t=this._moduleManager.getModule(Zt);return t?t.renameFriendGroup(e):lr({code:Bo.CANNOT_FIND_MODULE,message:Ho.CANNOT_FIND_MODULE})}},{key:"getGroupList",value:function(e){return this._moduleManager.getModule(Qt).getGroupList(e)}},{key:"getGroupProfile",value:function(e){return this._moduleManager.getModule(Qt).getGroupProfile(e)}},{key:"createGroup",value:function(e){return this._moduleManager.getModule(Qt).createGroup(e)}},{key:"dismissGroup",value:function(e){return this._moduleManager.getModule(Qt).dismissGroup(e)}},{key:"updateGroupProfile",value:function(e){return this._moduleManager.getModule(Qt).updateGroupProfile(e)}},{key:"joinGroup",value:function(e){return this._moduleManager.getModule(Qt).joinGroup(e)}},{key:"quitGroup",value:function(e){return this._moduleManager.getModule(Qt).quitGroup(e)}},{key:"searchGroupByID",value:function(e){return this._moduleManager.getModule(Qt).searchGroupByID(e)}},{key:"getGroupOnlineMemberCount",value:function(e){return this._moduleManager.getModule(Qt).getGroupOnlineMemberCount(e)}},{key:"changeGroupOwner",value:function(e){return this._moduleManager.getModule(Qt).changeGroupOwner(e)}},{key:"handleGroupApplication",value:function(e){return this._moduleManager.getModule(Qt).handleGroupApplication(e)}},{key:"initGroupAttributes",value:function(e){return this._moduleManager.getModule(Qt).initGroupAttributes(e)}},{key:"setGroupAttributes",value:function(e){return this._moduleManager.getModule(Qt).setGroupAttributes(e)}},{key:"deleteGroupAttributes",value:function(e){return this._moduleManager.getModule(Qt).deleteGroupAttributes(e)}},{key:"getGroupAttributes",value:function(e){return this._moduleManager.getModule(Qt).getGroupAttributes(e)}},{key:"getGroupMemberList",value:function(e){return this._moduleManager.getModule(en).getGroupMemberList(e)}},{key:"getGroupMemberProfile",value:function(e){return this._moduleManager.getModule(en).getGroupMemberProfile(e)}},{key:"addGroupMember",value:function(e){return this._moduleManager.getModule(en).addGroupMember(e)}},{key:"deleteGroupMember",value:function(e){return this._moduleManager.getModule(en).deleteGroupMember(e)}},{key:"setGroupMemberMuteTime",value:function(e){return this._moduleManager.getModule(en).setGroupMemberMuteTime(e)}},{key:"setGroupMemberRole",value:function(e){return this._moduleManager.getModule(en).setGroupMemberRole(e)}},{key:"setGroupMemberNameCard",value:function(e){return this._moduleManager.getModule(en).setGroupMemberNameCard(e)}},{key:"setGroupMemberCustomField",value:function(e){return this._moduleManager.getModule(en).setGroupMemberCustomField(e)}}]),e}(),Xi={login:"login",logout:"logout",destroy:"destroy",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin",getGroupOnlineMemberCount:"getGroupOnlineMemberCount"};function Qi(e,t){if(e.isReady()||void 0!==Xi[t])return!0;var n=e.getNotReadyReason(),o="";Object.getOwnPropertyNames(Bo).forEach((function(e){Bo[e]===n&&(o=Ho[e])}));var a={code:n,message:"".concat(o,"导致 sdk not ready。").concat(t," ").concat(Ho.SDK_IS_NOT_READY,",请参考 https://web.sdk.qcloud.com/im/doc/zh-cn/module-EVENT.html#.SDK_READY")};return e.onError(a),a}var Zi={},ec={};return ec.create=function(e){var t=0;if(je(e.SDKAppID))t=e.SDKAppID;else if(we.warn("TIM.create SDKAppID 的类型应该为 Number,请修改!"),t=parseInt(e.SDKAppID),isNaN(t))return we.error("TIM.create failed. 解析 SDKAppID 失败,请检查传参!"),null;if(t&&Zi[t])return Zi[t];we.log("TIM.create");var n=new Ji(r({},e,{SDKAppID:t}));n.on(S.SDK_DESTROY,(function(e){Zi[e.data.SDKAppID]=null,delete Zi[e.data.SDKAppID]}));var o=function(e){var t=Object.create(null);return Object.keys(Yt).forEach((function(n){if(e[n]){var o=Yt[n],a=new N;t[o]=function(){var t=Array.from(arguments);return a.use((function(t,o){var a=Qi(e,n);return!0===a?o():lr(a)})).use((function(e,t){if(!0===wt(e,Wt[n],o))return t()})).use((function(t,o){return e[n].apply(e,t)})),a.run(t)}}})),t}(n);return Zi[t]=o,we.log("TIM.create ok"),o},ec.TYPES=D,ec.EVENT=S,ec.VERSION="2.18.0",we.log("TIM.VERSION: ".concat(ec.VERSION)),ec}));
|