@tencentcloud/ai-desk-customer-vue 1.7.5 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e from"tim-upload-plugin";function t(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(e);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(n[s[i]]=e[s[i]])}return n}function n(e,t,n,s){return new(n||(n=Promise))((function(i,a){function o(e){try{c(s.next(e))}catch(e){a(e)}}function r(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,r)}c((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,o,r,c,u,l,d,h,g,p={exports:{}},f=i(p.exports=function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}function t(e){if(Array.isArray(e))return e}function n(e,t,n){return t=l(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,h()?Reflect.construct(t,n||[],l(e).constructor):t.apply(e,n))}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t,n){if(h())return Reflect.construct.apply(null,arguments);var s=[null];s.push.apply(s,t);var i=new(e.bind.apply(e,s));return n&&m(i,n.prototype),i}function o(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,M(s.key),s)}}function r(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var s=0,i=function(){};return{s:i,n:function(){return s>=e.length?{done:!0}:{done:!1,value:e[s++]}},e:function(e){throw e},f:i}}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 a,o=!0,r=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){r=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(r)throw a}}}}function u(e,t,n){return(t=M(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function g(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function p(){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 f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t){if(null==e)return{};var n,s,i=function(e,t){if(null==e)return{};var n={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;n[s]=e[s]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)n=a[s],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function y(e,n){return t(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var s,i,a,o,r=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(s=a.call(n)).done)&&(r.push(s.value),r.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return r}}(e,n)||T(e,n)||p()}function I(t){return function(t){if(Array.isArray(t))return e(t)}(t)||g(t)||T(t)||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 M(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function C(e){return(C="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})(e)}function T(t,n){if(t){if("string"==typeof t)return e(t,n);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?e(t,n):void 0}}function S(e){var t="function"==typeof Map?new Map:void 0;return(S=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;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,n)}function n(){return a(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)})(e)}var E="3.6.3-0202",k={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",ROOM_CUSTOM_DATA_RECEIVED:"onRoomCustomDataReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",MESSAGE_REACTIONS_UPDATED:"onMessageReactionsUpdated",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",TOTAL_UNREAD_MESSAGE_COUNT_UPDATED:"onTotalUnreadMessageCountUpdated",CONVERSATION_GROUP_LIST_UPDATED:"onConversationGroupListUpdated",CONVERSATION_IN_GROUP_UPDATED:"onConversationInGroupUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",GROUP_COUNTER_UPDATED:"onGroupCounterUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",USER_STATUS_UPDATED:"onUserStatusUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",MY_FOLLOWERS_LIST_UPDATED:"onMyFollowersListUpdated",MY_FOLLOWING_LIST_UPDATED:"onMyFollowingListUpdated",MUTUAL_FOLLOWERS_LIST_UPDATED:"onMutualFollowersListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",ALL_RECEIVE_MESSAGE_OPT_UPDATED:"onAllReceiveMessageOptUpdated",SERVER_CONFIG_UPDATED:"onServerConfigUpdated",PINNED_GROUP_MESSAGE_UPDATED:"onPinnedGroupMessageUpdated"},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_STREAM:"TIMStreamElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"},O=r((function e(){i(this,e),this.cache=[],this.options=null}),[{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()}}]),R=r((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i(this,e),this.high=t,this.low=n}),[{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}}]),A={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},N={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},L="1.7.3",U=537048168,P="CHINA",w="OVERSEA",b="SINGAPORE",G="KOREA",F="GERMANY",x="IND",V="JPN",q="USA",K="INDONESIA",H={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:P;this.CURRENT=A.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic",STREAM_MESSAGE:"StreamMsg"}},j={SEARCH_GRP_SNS:new R(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new R(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new R(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new R(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new R(0,Math.pow(2,6)).toString(),USER_STATUS:new R(0,Math.pow(2,7)).toString(),CONV_MARK:new R(0,Math.pow(2,9)).toString(),CONV_GROUP:new R(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new R(0,Math.pow(2,11)).toString(),MSG_EXT:new R(0,Math.pow(2,13)).toString(),GRP_COUNTER:new R(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new R(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new R(Math.pow(2,7)).toString(),PLUGIN_CS:new R(Math.pow(2,8)).toString(),PLUGIN_PUSH:new R(Math.pow(2,9)).toString(),PLUGIN_BOT:new R(Math.pow(2,10)).toString(),MSG_REACTION:new R(Math.pow(2,16)).toString(),FOLLOW:new R(Math.pow(2,20)).toString()},B="web.sdk.qcloud.com",Y="web.sdk.cloud.tencent.cn",W="web.sdk.tencent.cn";H.HOST.setCurrent(P);var z,$,J,X,Z="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),Q="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||Z,ee=Q&&"function"==typeof wx.createGamePortal,te="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),ne="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),se="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),ie="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),ae="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,oe="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,re=Q&&"object"===C(wx.miniapp),ce="undefined"!=typeof uni,ue=Q||te||ne||se||ie||oe||ae,le="undefined"==typeof window&&!ue&&void 0!==s&&void 0!==s.NativeScriptGlobals,de=void 0!==s&&(void 0!==s.nativeModuleProxy||void 0!==s.ReactNative),he="undefined"!=typeof uni?!ue:"undefined"!=typeof window&&!ue&&!de,ge=te?qq:ne?tt:se?swan:ie?my:Q?wx:oe?uni:ae?jd:{},pe=he&&window&&window.navigator&&window.navigator.userAgent||"",fe=/(micromessenger|webbrowser)/i.test(pe),_e=(z="WEB",fe?z="WEB":te?z="QQ_MP":ne?z="TT_MP":se?z="BAIDU_MP":ie?z="ALI_MP":Q?z=re?"DONUT_NATIVE_APP":"WX_MP":oe?z="UNI_NATIVE_APP":le?z="NS_NATIVE_APP":de&&(z="RN_NATIVE_APP"),N[z]),ve=/iPad/i.test(pe),me=/iPhone/i.test(pe)&&!ve,ye=/iPod/i.test(pe),Ie=me||ve||ye,Me=($=pe.match(/OS (\d+)_/i))&&$[1]?$[1]:null,Ce=/Android/i.test(pe),Te=function(){var e=pe.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}(),Se=/Edge/i.test(pe),Ee=!Se&&/Chrome/i.test(pe),ke=/MSIE/.test(pe)||pe.indexOf("Trident")>-1&&pe.indexOf("rv:11.0")>-1,De=function(){var e=/MSIE\s(\d+)\.\d/.exec(pe),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(pe)&&/rv:11.0/.test(pe)&&(t=11),t}(),Oe=/Safari/i.test(pe)&&!Ee&&!Ce&&!Se,Re=/Windows/i.test(pe),Ae=/MAC OS X/i.test(pe),Ne=he&&"undefined"!=typeof Worker&&!ke,Le=he&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,Ue=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;var e=window.navigator.standalone;return!(!Ie||e||Oe)}();J="undefined"!=typeof console?console:void 0!==s&&s.console?s.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Pe=function(){},we=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],be=we.length;be--;)X=we[be],console[X]||(J[X]=Pe);var Ge=J,Fe=0,xe=function(){return(new Date).getTime()+Fe},Ve=function(){Fe=0},qe=function(){return Math.floor(xe()/1e3)},Ke=0;function He(){return Xt()?"%c AIDesk-Chat %c":"AIDesk-Chat"}function je(){var e,t=((e=new Date).setTime(xe()),e);return 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 Be={arguments2String:function(e){var t="";if(1===e.length)t=e[0];else for(var n=0,s=e.length;n<s;n++){if(pt(e[n]))try{t+=_t(e[n])?JSON.stringify(e[n],["message","code"]):JSON.stringify(e[n])}catch(e){t+=e?e.message:"";break}else t+=e[n];t+=" "}return t},_exec:function(e,t){Xt()?Ge[e](He(),"background:#1c66e5; padding:1px; border-radius:3px; color: #fff","background:transparent",je(),t):Ge[e]("".concat(He()," ").concat(je()," ").concat(t))},d:function(){if(Ke<=-1){var e=this.arguments2String(arguments);this._exec("debug",e)}},l:function(){if(Ke<=0){var e=this.arguments2String(arguments);this._exec("log",e)}},log:function(){if(Ke<=0){var e=this.arguments2String(arguments);this._exec("log",e)}},i:function(){if(Ke<=1){var e=this.arguments2String(arguments);this._exec("info",e)}},w:function(){if(Ke<=2){var e=this.arguments2String(arguments);this._exec("warn",e)}},e:function(){if(Ke<=3){var e=this.arguments2String(arguments);this._exec("error",e)}},setLevel:function(e){e<4&&this._exec("log","set level from "+Ke+" to "+e),Ke=e},getLevel:function(){return Ke}},Ye={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},We="Tag_Profile_IM_",ze={NICK:"".concat(We,"Nick"),GENDER:"".concat(We,"Gender"),BIRTHDAY:"".concat(We,"BirthDay"),LOCATION:"".concat(We,"Location"),SELFSIGNATURE:"".concat(We,"SelfSignature"),ALLOWTYPE:"".concat(We,"AllowType"),LANGUAGE:"".concat(We,"Language"),AVATAR:"".concat(We,"Image"),MESSAGESETTINGS:"".concat(We,"MsgSettings"),ADMINFORBIDTYPE:"".concat(We,"AdminForbidType"),LEVEL:"".concat(We,"Level"),ROLE:"".concat(We,"Role")},$e="Gender_Type_",Je={UNKNOWN:"".concat($e,"Unknown"),FEMALE:"".concat($e,"Female"),MALE:"".concat($e,"Male")},Xe={NONE:"".concat("AdminForbid_Type_","None"),SEND_OUT:"".concat("AdminForbid_Type_","SendOut")},Ze={NEED_CONFIRM:"".concat("AllowType_Type_","NeedConfirm"),ALLOW_ANY:"".concat("AllowType_Type_","AllowAny"),DENY_ANY:"".concat("AllowType_Type_","DenyAny")},Qe="@TGS#_",et="@TOPIC#_",nt=Object.prototype.hasOwnProperty;function st(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(dt(e)){for(var t in e)if(nt.call(e,t))return!1;return!0}return!!(at(e)||ot(e)||rt(e))&&0===e.size}var it=["url"],at=function(e){return"map"===mt(e)},ot=function(e){return"set"===mt(e)},rt=function(e){return"file"===mt(e)},ct=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"===C(e)&&e.constructor===Number)},ut=function(e){return"string"==typeof e},lt=function(e){return null!==e&&"object"===C(e)},dt=function(e){if("object"!==C(e)||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var n=t;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n},ht=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===mt(e)},gt=function(e){return void 0===e},pt=function(e){return ht(e)||lt(e)},ft=function(e){return"function"==typeof e},_t=function(e){return e instanceof Error},vt=function(e){return"filelist"===mt(e)},mt=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},yt=function(e){if("string"!=typeof e)return!1;var t=e[0];return!/[^a-zA-Z0-9]/.test(t)};Date.now||(Date.now=function(){return(new Date).getTime()});var It=function(e,t,n,s){if(!pt(e)||!pt(t))return 0;for(var i,a=0,o=Object.keys(t),r=0,c=o.length;r<c;r++)if(i=o[r],!(gt(t[i])||n&&n.includes(i)))if(pt(e[i])&&pt(t[i]))a+=It(e[i],t[i],n,s);else{if(s&&s.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=t[i],a+=1)}return a},Mt=function(e,t){var n,s=new Map,i=c(e.entries());try{for(i.s();!(n=i.n()).done;){var a=y(n.value,2),o=a[0],r=a[1];r&&s.set(o,t?JSON.stringify(r):JSON.parse(JSON.stringify(r)))}}catch(e){i.e(e)}finally{i.f()}return s},Ct=function(e){if(0===e.length)return 0;for(var t=0,n=0,s="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)n+=e[t++].charCodeAt[t]<=255?1:!1===s?3:2;return n},Tt=function(e){var t=e||99999999;return Math.round(Math.random()*t)},St="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Et=St.length,kt=function(e,t){for(var n in e)if(e[n]===t)return!0;return!1},Dt={},Ot=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function Rt(e,t){if(!ht(e)||!ht(t))return!1;var n=!1;return t.forEach((function(t){var s=t.key,i=t.value,a=e.find((function(e){return e.key===s}));a?a.value!==i&&(a.value=i,n=!0):(e.push({key:s,value:i}),n=!0)})),n}function At(e){if(dt(e)&&dt(e.webhookInfo)){var t=[];if(e.webhookInfo.disableCloudMessagePreHook&&t.push("ForbidBeforeSendMsgCallback"),e.webhookInfo.disableCloudMessagePostHook&&t.push("ForbidAfterSendMsgCallback"),0!==t.length)return t}}var Nt=function(e){return e===D.GRP_AVCHATROOM},Lt=function(e){var t=e.type,n=e.groupID;return t===D.GRP_COMMUNITY||"".concat(n).startsWith(Qe)&&!"".concat(n).includes(et)},Ut=function(e){return"".concat(e).startsWith(Qe)&&"".concat(e).includes(et)},Pt=function(e){return ut(e)&&e.slice(0,3)===D.CONV_C2C},wt=function(e){return ut(e)&&e.slice(0,5)===D.CONV_GROUP},bt=function(e){return ut(e)&&e===D.CONV_SYSTEM};function Gt(e,t){var n={};return Object.keys(e).forEach((function(s){n[s]=t(e[s],s)})),n}function Ft(e){return de?Promise.resolve({width:0,height:0}):ue?new Promise((function(t,n){ge.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})})):ke&&9===De?Promise.resolve({width:0,height:0}):new Promise((function(t,n){var s=new Image;s.onload=function(){t({width:this.width,height:this.height}),s=null},s.onerror=function(){t({width:0,height:0}),s=null},s.src=e}))}function xt(){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 Vt(){var e="unknown";if(Ae&&(e="mac"),Re&&(e="windows"),Ie&&(e="ios"),Ce&&(e="android"),ue)try{var t=ge.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(e){}return e}function qt(e,t){e=e.split("."),t=t.split(".");for(var n=Math.max(e.length,t.length);e.length<n;)e.push("0");for(;t.length<n;)t.push("0");for(var s=0;s<n;s++){var i=parseInt(e[s]),a=parseInt(t[s]);if(i>a)return 1;if(i<a)return-1}return 0}function Kt(e){var t=e.originUrl,n=void 0===t?void 0:t,s=e.originWidth,i=e.originHeight,a=e.min,o=void 0===a?198:a,r=parseInt(s),c=parseInt(i),u={url:void 0,width:0,height:0};if((r<=c?r:c)<=o)u.url=n,u.width=r,u.height=c;else{c<=r?(u.width=Math.ceil(r*o/c),u.height=o):(u.width=o,u.height=Math.ceil(c*o/r));var l=n&&n.indexOf("?")>-1?"".concat(n,"&"):"".concat(n,"?");u.url="".concat(l,198===o?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")}return gt(n)?(u.url,v(u,it)):u}function Ht(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 jt(e){var t=e.servcmd;return t.slice(t.indexOf(".")+1)}function Bt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function Yt(e,t){return e.includes(t)}function Wt(e,t){return e.includes(t)}function zt(e){return e.split(et)[0]}var $t=function(e,t,n){if(gt(t))return"";switch(e){case D.MSG_TEXT:return t.text;case D.MSG_IMAGE:return n?"[Image]":"[图片]";case D.MSG_LOCATION:return n?"[Location]":"[位置]";case D.MSG_AUDIO:return n?"[Voice]":"[语音]";case D.MSG_VIDEO:return n?"[Video]":"[视频]";case D.MSG_FILE:return n?"[File]":"[文件]";case D.MSG_CUSTOM:return n?"[Custom Messages]":"[自定义消息]";case D.MSG_GRP_TIP:return n?"[Group Notification]":"[群提示消息]";case D.MSG_GRP_SYS_NOTICE:return n?"[Group System Message]":"[群系统通知]";case D.MSG_FACE:return n?"[Animated Sticker]":"[动画表情]";case D.MSG_MERGER:return n?"[Chat Record]":"[聊天记录]";case D.MSG_STREAM:return n?"[Stream Message]":"[流式消息]";default:return""}};function Jt(e){var t=[];if(!ut(e))return t;var n=e.length;if(0===n)return t;for(var s=n-1;s>=0;s--)"1"===e[s]&&t.push(Math.pow(2,n-s-1));return t}function Xt(){return!ke&&!ue}function Zt(e){if(ht(e)&&0!==e.length){var t=0;return e.forEach((function(e){t+=e})),t.toFixed(0)}}function Qt(e){if(ht(e)&&0!==e.length){var t=0;return e.forEach((function(e){t+=e})),(t/e.length).toFixed(0)}}function en(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=Date.now();return t?n?"".concat(s-e," ms"):"".concat(Math.round((s-e)/1e3)," s"):n?s-e:Math.round((s-e)/1e3)}function tn(e){var t=!1;return e&&e>1&&(t=!0),t}function nn(e,t,n){if(void 0===t)return!0;var s=!0;if(dt(t))Object.keys(t).forEach((function(i){var a=1===e.length?e[0][i]:void 0;s=!!sn(a,t[i],n,i)&&s}));else if(ht(t))for(var i=0;i<t.length;i++)s=!!sn(e[i],t[i],n,t[i].name)&&s;if(s)return s;throw new Error("Params validate failed.")}function sn(e,t,n,s){if(void 0===t)return!0;var i=!0;if(t.required&&st(e)&&(Be.e("[".concat(n,'] Missing required params: "').concat(s,'".')),i=!1),!st(e)){var a=mt(e),o=t.type.toLowerCase();a!==o&&("asyncfunction"===a&&"function"===o||(Be.e("[".concat(n,'] Invalid params: type check failed for "').concat(s,'". Expected ').concat(t.type,".")),i=!1))}return t.validator&&!t.validator(e,n,s)&&(Be.e("[".concat(n,'] Invalid params: custom validator check failed for "').concat(s,'".')),i=!1),i}var an="unSend",on="success",rn="fail",cn="notStart",un="pending",ln="resolved",dn="rejected",hn=function(e){if(!e)return!1;if(Pt(e)||wt(e)||bt(e))return!0;var t=wn("InvalidConversationID",e);return t&&Be.w(t),!1},gn=function(e){""!==e.desc&&""!==wn("API_REFER")&&Be.w("[".concat(e.api,"] | ").concat(e.paramName," | ").concat(e.desc,", ").concat(wn("API_REFER")).concat(e.api))},pn=function(){return wn("StringRequiredLog")},fn=function(e){return wn("NonEmptyStringRequiredLog",e)},_n=function(){return wn("NumberRequiredLog")},vn=function(){return wn("UndefinedNotAllowedLog")},mn=function(){return wn("FileRequiredLog")},yn=function(){return wn("FunctionRequiredLog")},In=function(){return wn("ArrayRequiredLog")},Mn=function(){return wn("NonEmptyArrayLog")},Cn=function(){return wn("CallbackMissingLog")},Tn=function(){return wn("PositiveIntegerRequiredLog")},Sn=function(e,t){return wn("StringNotLongerThanLog",e,t)},En=function(e,t){return wn("NumberLessThanLog",e,t)},kn=function(){return wn("PlainObjectRequiredLog")},Dn=function(){return wn("NonEmptyContentRequiredLog")},On=function(){return wn("FileNotSelectedLog")},Rn=function(){return wn("MessageInstanceRequiredLog")},An=function(){return wn("NonAnonymousFunctionLog")},Nn={type:"String",required:!0},Ln={type:"Array",required:!0},Un={type:"Object",required:!0},Pn={type:"Boolean",required:!0},wn=null,bn={hookGetAPITips:function(e){wn=e},login:{userID:Nn,userSig:Nn},on:[{name:"eventName",type:"String",validator:function(e,t,n){return"string"==typeof e&&0!==e.length||(gn({api:t,paramName:n,desc:fn(n)}),!1)}},{name:"handler",type:"Function",validator:function(e,t,n){return"function"!=typeof e?(gn({api:t,paramName:n,desc:yn()}),!1):(""===e.name&&gn({api:t,paramName:n,desc:An()}),!0)}}],off:[{name:"eventName",type:"String",validator:function(e,t,n){return"string"==typeof e&&0!==e.length||(gn({api:t,paramName:n,desc:fn(n)}),!1)}},{name:"handler",type:"Function",validator:function(e,t,n){return"function"!=typeof e?(gn({api:t,paramName:n,desc:yn()}),!1):(""===e.name&&gn({api:t,paramName:n,desc:An()}),!0)}}],sendMessage:[_({name:"message"},Un)],getMessageList:{conversationID:_(_({},Nn),{},{validator:function(e){return hn(e)}}),nextReqMessageID:{type:"String"},count:{type:"Number",validator:function(e,t,n){return!(!gt(e)&&!/^[1-9][0-9]*$/.test(e)&&(gn({api:t,paramName:n,desc:Tn()}),1))}}},getMessageListHopping:{conversationID:_(_({},Nn),{},{validator:function(e){return hn(e)}}),sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:function(e,t,n){return!(!gt(e)&&0!==e&&1!==e&&(gn({api:t,paramName:n,desc:wn("0Or1RequiredLog")}),1))}},count:{type:"Number",validator:function(e,t,n){return!(!gt(e)&&!/^[1-9][0-9]*$/.test(e)&&(gn({api:t,paramName:n,desc:Tn}),1))}}},setMessageRead:{conversationID:_(_({},Nn),{},{validator:function(e){return hn(e)}})},setAllMessageRead:{scope:{type:"String",required:!1,validator:function(e,t,n){return!e||-1!==[D.READ_ALL_C2C_MSG,D.READ_ALL_GROUP_MSG,D.READ_ALL_MSG].indexOf(e)||(gn({api:t,paramName:n,desc:wn("ValidScopeRequired")}),!1)}}},getConversationProfile:[_(_({name:"conversationID"},Nn),{},{validator:function(e){return hn(e)}})],clearHistoryMessage:[_(_({name:"conversationID"},Nn),{},{validator:function(e){return hn(e)}})],pinConversation:{conversationID:_(_({},Nn),{},{validator:function(e){return hn(e)}}),isPinned:_({},Pn)},setConversationDraft:{conversationID:_(_({},Nn),{},{validator:function(e){return hn(e)}}),draftText:{type:"String",validator:function(e,t,n){return!!ut(e)||(gn({api:t,paramName:n,desc:pn()}),!1)}}},setConversationCustomData:{conversationIDList:_({},Ln),customData:{type:"String",validator:function(e,t,n){return ut(e)?!(e.length>256&&(gn({api:t,paramName:n,desc:Sn(n,256)}),1)):(gn({api:t,paramName:n,desc:pn()}),!1)}}},markConversation:{conversationIDList:_({},Ln),markType:{type:"number",validator:function(e,t,n){return ct(e)?e<=0?(gn({api:t,paramName:n,desc:(s=n,i=0,wn("NumberGreaterThanLog",s,i))}),!1):!(e>=Math.pow(2,64)&&(gn({api:t,paramName:n,desc:En(n,"Math.pow(2,64)")}),1)):(gn({api:t,paramName:n,desc:_n()}),!1);var s,i}},enableMark:_({},Pn)},createTextMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return dt(e)?ut(e.text)?0!==e.text.length||(gn({api:t,paramName:"payload.text",desc:Dn()}),!1):(gn({api:t,paramName:"payload.text",desc:pn()}),!1):(gn({api:t,paramName:n,desc:kn()}),!1)}})},createTextAtMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return dt(e)?ut(e.text)?0===e.text.length?(gn({api:t,paramName:"payload.text",desc:Dn()}),!1):!(e.atUserList&&!ht(e.atUserList)&&(gn({api:t,paramName:"payload.atUserList",desc:In()}),1)):(gn({api:t,paramName:"payload.text",desc:pn()}),!1):(gn({api:t,paramName:n,desc:kn()}),!1)}})},createCustomMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return dt(e)?e.data&&!ut(e.data)?(gn({api:t,paramName:"payload.data",desc:pn()}),!1):e.description&&!ut(e.description)?(gn({api:t,paramName:"payload.description",desc:pn()}),!1):!(e.extension&&!ut(e.extension)&&(gn({api:t,paramName:"payload.extension",desc:pn()}),1)):(gn({api:t,paramName:"payload",desc:kn()}),!1)}})},createImageMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){if(!dt(e))return gn({api:t,paramName:n,desc:kn()}),!1;if(gt(e.file))return gn({api:t,paramName:"payload.file",desc:vn()}),!1;if(he){if(!(e.file instanceof HTMLInputElement||rt(e.file)))return dt(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(gn({api:t,paramName:"payload.file",desc:On()}),!1):(gn({api:t,paramName:"payload.file",desc:mn()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return gn({api:t,paramName:"payload.file",desc:On()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e,t,n){return gt(e)&&gn({api:t,paramName:n,desc:Cn()}),!0}}})},createAudioMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return!!dt(e)||(gn({api:t,paramName:n,desc:kn()}),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return gt(e)&&gn({api:t,paramName:n,desc:Cn()}),!0}}},createVideoMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){if(!dt(e))return gn({api:t,paramName:n,desc:kn()}),!1;if(gt(e.file))return gn({api:t,paramName:"payload.file",desc:vn()}),!1;if(he){if(!(e.file instanceof HTMLInputElement||rt(e.file)))return dt(e.file)&&"undefined"!=typeof uni?!!rt(e.file.tempFile)||(gn({api:t,paramName:"payload.file",desc:On()}),!1):(gn({api:t,paramName:"payload.file",desc:mn()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return gn({api:t,paramName:"payload.file",desc:On()}),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return gt(e)&&gn({api:t,paramName:n,desc:Cn()}),!0}}},createFaceMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return dt(e)?ct(e.index)?!!ut(e.data)||(gn({api:t,paramName:"payload.data",desc:pn()}),!1):(gn({api:t,paramName:"payload.index",desc:_n()}),!1):(gn({api:t,paramName:n,desc:kn()}),!1)}})},createFileMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){if(!dt(e))return gn({api:t,paramName:n,desc:kn()}),!1;if(gt(e.file))return gn({api:t,paramName:"payload.file",desc:vn()}),!1;if(he){if(!(e.file instanceof HTMLInputElement||rt(e.file)))return dt(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(gn({api:t,paramName:"payload.file",desc:On()}),!1):(gn({api:t,paramName:"payload.file",desc:mn()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return gn({api:t,paramName:"payload.file",desc:On()}),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return gt(e)&&gn({api:t,paramName:n,desc:Cn()}),!0}}},createLocationMessage:{to:Nn,conversationType:Nn,payload:_(_({},Un),{},{validator:function(e,t,n){return dt(e)?ut(e.description)?ct(e.longitude)?!!ct(e.latitude)||(gn({api:t,paramName:"payload.latitude",desc:_n()}),!1):(gn({api:t,paramName:"payload.longitude",desc:_n()}),!1):(gn({api:t,paramName:"payload.description",desc:pn()}),!1):(gn({api:t,paramName:n,desc:kn()}),!1)}})},revokeMessage:[_(_({name:"message"},Un),{},{validator:function(e,t,n){return st(e)?(gn({api:t,paramName:n,desc:Rn()}),!1):e.conversationType===D.CONV_SYSTEM?(gn({api:t,paramName:n,desc:wn("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(gn({api:t,paramName:n,desc:wn("MessageRevokedLog")}),!1)}})],deleteMessage:[_(_({name:"messageList"},Ln),{},{validator:function(e,t,n){return!st(e)||(gn({api:t,paramName:n,desc:Mn()}),!1)}})],translateText:{sourceTextList:Ln,sourceLanguage:Nn,targetLanguage:Nn},convertVoiceToText:{message:_(_({},Un),{},{validator:function(e,t,n){return st(e)?(gn({api:t,paramName:n,desc:Rn()}),!1):e.type===D.MSG_AUDIO&&e.status===on||(gn({api:t,paramName:n,desc:wn("AudioMessageRequiredLog")}),!1)}})},modifyMessage:[_(_({name:"message"},Un),{},{validator:function(e,t,n){return st(e)?(gn({api:t,paramName:n,desc:Rn()}),!1):e.conversationType===D.CONV_SYSTEM?(gn({api:t,paramName:n,desc:wn("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(gn({api:t,paramName:n,desc:wn("OnlineMessageNotSupportLog")}),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e,t,n){return ht(e)?(0===e.length&&gn({api:t,paramName:n,desc:Mn()}),!0):(gn({api:t,paramName:n,desc:In()}),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e,t,n){return!!gt(e)||!!ht(e)||(gn({api:t,paramName:n,desc:In()}),!1)}}},setSelfStatus:{customStatus:{type:"String",validator:function(e,t,n){return!!ut(e)||(gn({api:t,paramName:n,desc:pn()}),!1)}}},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e,t,n){return ht(e)?0!==e.length||(gn({api:t,paramName:n,desc:Mn()}),!1):(gn({api:t,paramName:n,desc:In()}),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e,t,n){return ht(e)?0!==e.length||(gn({api:t,paramName:n,desc:Mn()}),!1):(gn({api:t,paramName:n,desc:In()}),!1)}}]},Gn={login:1,logout:1,getLoginUser:1,getServerTime:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,isReady:1,createTextMessage:1,createTextAtMessage:1,createImageMessage:1,createAudioMessage:1,createVideoMessage:1,createCustomMessage:1,createFaceMessage:1,createFileMessage:1,createLocationMessage:1,createMergerMessage:1,downloadMergerMessage:1,createForwardMessage:1,sendMessage:1,resendMessage:1,revokeMessage:1,deleteMessage:1,translateText:1,convertVoiceToText:1,modifyMessage:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,setConversationDraft:1,pinConversation:1,getTotalUnreadMessageCount:1,setConversationCustomData:1,markConversation:1,createConversationGroup:1,getConversationGroupList:1,deleteConversationGroup:1,renameConversationGroup:1,addConversationsToGroup:1,deleteConversationsFromGroup:1,clearHistoryMessage:1,setMessageRemindType:1,setAllReceiveMessageOpt:1,getAllReceiveMessageOpt:1,getMyProfile:1,getUserProfile:1,updateMyProfile:1,setSelfStatus:1,getUserStatus:1,subscribeUserStatus:1,unsubscribeUserStatus:1,callExperimentalAPI:1},Fn=1,xn=2,Vn=3,qn=4,Kn=6,Hn=7,jn=8,Bn=10,Yn=11,Wn=12,zn=13,$n=14,Jn=15,Xn=17,Zn=18,Qn=19,es=20,ts=21,ns=23,ss=24,is=25,as=26,os=27,rs=30,cs=31,us=32,ls=33,ds=34,hs=35,gs=37,ps=function(e){return{code:0,data:e||{}}},fs=function(e){function t(e){var s;i(this,t),s=n(this,t);var a=e.code,o=e.message,r=e.data;return s.code=a,o?s.message=o:s._getErrMsg&&(s.message=s._getErrMsg(s.code)),s.data=r||{},s}return d(t,e),r(t)}(S(Error)),_s={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_F_IS_EMPTY:2108,MSG_ONPROGRESS_ERR:2109,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,VOICE_TO_TEXT_FAIL:2118,UNSUPPORTED_VOICE_FORMAT:2119,MSG_I_SELECT_F_FIRST:2251,MSG_I_TYPES_LIMIT:2252,MSG_I_SIZE_LIMIT:2253,MSG_A_UPLOAD_FAIL:2300,MSG_A_SIZE_LIMIT:2301,MSG_V_UPLOAD_FAIL:2350,MSG_V_SIZE_LIMIT:2351,MSG_V_TYPES_LIMIT:2352,MSG_F_UPLOAD_FAIL:2400,MSG_F_SELECT_F_FIRST:2401,MSG_F_SIZE_LIMIT:2402,MSG_F_URL_IS_EMPTY:2403,MSG_MERGER_TYPE_INVALID:2450,MSG_MERGER_KEY_INVALID:2451,MSG_MERGER_DOWNLOAD_FAIL:2452,MSG_FORWARD_TYPE_INVALID:2453,MSG_FORWARD_INVALID_ELEMENTS:2454,MSG_MODIFY_CONFLICT:2480,MSG_MODIFY_DISABLED_IN_AV:2481,CONV_NOT_FOUND:2500,USER_OR_GRP_NOT_FOUND:2501,CONV_UN_RECORDED_TYPE:2502,INVALID_CONV_ID:2503,ILLEGAL_GRP_TYPE:2600,ILLEGAL_GRP_ID:2602,CANNOT_FIND_GRP:2603,CANNOT_CHANGE_OWNER_IN_AV:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,MEMBER_NOT_IN_GRP:2623,JOIN_GRP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AV:2661,CANNOT_JOIN_NON_AV_WITHOUT_LOGIN:2662,NOT_OWNER:2681,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,BAN_DURATION_INVALID:2686,OPERATION_NOT_SUPPORTED_IN_AV:2687,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GRP_EXISTED:2710,FRIEND_GRP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,INVALID_TRTC_CMD:2995,OVER_FREQUENCY_LIMIT:2996,NO_PROTOCOL:2997,NO_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,NO_USE:3122,PROFANITY_FOUND:3123,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022,SIGNALING_INVALID_INVITE_ID:8010,SIGNALING_NO_PERMISSION:8011,SIGNALING_ALREADY_EXISTS:8012,INVALID_CANCEL_MESSAGE:8020},vs=null,ms=function(e){vs=e},ys=function(e){return Promise.resolve(ps(e))},Is=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e instanceof fs)return t&&null!==vs&&vs.emit(k.ERROR,e),Promise.reject(e);if(e instanceof Error){var n=new fs({code:_s.UNCAUGHT_ERROR});return t&&null!==vs&&vs.emit(k.ERROR,n),Promise.reject(n)}if(gt(e)||gt(e.code))return Promise.reject(new fs({code:_s.UNCAUGHT_ERROR}));var s=new fs(e);return t&&null!==vs&&vs.emit(k.ERROR,s),Promise.reject(s)},Ms=r((function e(t){i(this,e),this._m=t,this._n=""}),[{key:"isLoggedIn",value:function(){return this._m.get(Wn).isLoggedIn()}},{key:"isOversea",value:function(){return this._m.get(Wn).isOversea()}},{key:"isPrivateNetWork",value:function(){var e=this._m.get(Wn);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}},{key:"getFileDownloadProxy",value:function(){return this._m.get(Wn).getFileDownloadProxy()}},{key:"getDownloadFileAuthKey",value:function(){return this._m.get(Wn).getDownloadFileAuthKey()}},{key:"getMyUserID",value:function(){return this._m.get(Wn).getUserID()}},{key:"getMyTinyID",value:function(){return this._m.get(Wn).getTinyID()}},{key:"getSDKAppID",value:function(){return this._m.get(Wn).getSDKAppID()}},{key:"isIntl",value:function(){return this._m.get(Wn).isIntl()}},{key:"isUsingChatCore",value:function(){return this._m.get(Wn).isUsingChatCore()}},{key:"isDevMode",value:function(){return this._m.get(Wn).isDevMode()}},{key:"get",value:function(e){return this._m.get(e)}},{key:"getPlatform",value:function(){return _e}},{key:"getCloudConfig",value:function(e){return this._m.get(ns).getCloudConfig(e)}},{key:"emitOEvt",value:function(e,t){this._m.getOEmitInst().emit(e,t)}},{key:"emitIEvt",value:function(e,t){this._m.getIEmitInst().emit(e,t)}},{key:"getIEmitInst",value:function(){return this._m.getIEmitInst()}},{key:"req",value:function(e){return this._m.get(es).req(e)}},{key:"canIUse",value:function(e){return this._m.get(os).canIUse(e)}},{key:"getErrMsg",value:function(e,t,n){return this._m.getErrMsg(e,t,n)}},{key:"warn",value:function(e,t,n){var s=this.getErrMsg(e,t,n);s&&Be.w(s)}},{key:"noUse",value:function(e){var t=_s.NO_USE;return Is({code:t,message:this.getErrMsg(t,e)})}}]),Cs={LOGIN:"wslogin",LOGOUT:"wslogout",HELLO:"wshello",KICK_OTHER:"KickOther",SYNC_UNREAD_MSG:"getmsg",SEND_C2C_MSG:"sendmsg",GET_USER_PROFILE:"portrait_get_all",UPDATE_MY_PROFILE:"portrait_set",REVOKE_C2C_MSG:"msgwithdraw",SET_C2C_MSG_READ:"msgreaded",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_C2C_ROAMING_MSG:"getroammsg",GET_C2C_PEER_READ_TIME:"get_peer_read_time",DEL_C2C_MSG:"delete_c2c_msg_ramble",MODIFY_C2C_MSG:"modify_c2c_msg",MODIFY_C2C_MSG_EXT:"set_key_values",GET_C2C_MSG_EXT:"get_key_values",PAGING_GET_CONV_LIST:"page_get",DEL_CONV:"batch_delete",CLEAR_HISTORY_MSG:"clear_msg",PIN_CONV:"top",DEL_GROUP_AT_TIPS:"deletemsg",SET_CONV_CUSTOM_DATA:"set_conv_custom_data",MARK_CONV:"mark_contact",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",SIMPLE_COS_PRE_SIG:"simple_sig",GET_IMAGE_INFO:"get_imageinfo",GET_IP:"get_final_ip",VIDEO_COVER:"video_cover",SSO_STAT:"tim_web_report_v2",PING:"alive",MSG_PUSH:"msg_push",MSG_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",FETCH_CLOUD_CTRL_CONFIG:"fetch_config",PUSHED_CLOUD_CTRL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",OVERLOAD_NOTIFY:"notify2",SET_SELF_STATUS:"ws_set_custom_status",GET_USER_STATUS:"ws_get_user_status",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",PUSH_REPORT:"uniapp_sdk_report",TRANSLATE_TEXT:"ws_batch_trans_text",VOICE_TO_TEXT:"ws_sentence_recognition",SET_ALL_RECEIVE_MSG_OPT:"ws_set_do_not_disturb",GET_ALL_RECEIVE_MSG_OPT:"ws_get_do_not_disturb",STREAM_GET_STREAM:"GetStreamHttp",STREAM_CHUNK_ACK:"AckHttp",STREAM_PUSH_CHUNKS:"PushStreamHttp"},Ts="networkRTT",Ss="messageE2EDelay",Es="sendMessageC2C",ks="sendMessageGroup",Ds="sendMessageGroupAV",Os="sendMessageRichMedia",Rs="cosUpload",As="messageReceivedGroup",Ns="messageReceivedGroupAVPush",Ls="messageReceivedGroupAVPull",Us=u(u(u(u(u(u(u(u(u(u({},Ts,2),Ss,3),Es,4),ks,5),Ds,6),Os,7),As,8),Ns,9),Ls,10),Rs,11),Ps={info:4,warning:5,error:6},ws={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},bs={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16,tui_key_features:16},Gs=function(){function e(t){i(this,e),this._n="SSOLogData",this.eventType=bs[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=xe()}return r(e,[{key:"updateTimeStamp",value:function(){this.timestamp=xe()}},{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){if(this._netMonitorModule){var n=this._netMonitorModule.getNetworkType();this.setNetworkType(n)}var s=xe();0===this.costTime&&(this.costTime=s-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(s)),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){if(!(e instanceof Error))return Be.w("".concat(this._n,".setError value not instanceof Error, please check!")),this;if(this._sentFlag)return this;var t=!0;if(this._netMonitorModule&&(t=this._netMonitorModule.isOnline()),t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{var n=_s.NO_NETWORK;this.setCode(n)}return this.setLevel("error"),this}},{key:"setCode",value:function(e){return gt(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),ct(e)?this.code=e:Be.w("".concat(this._n,".setCode value not a number, please check!"),e,C(e))),this}},{key:"setMessage",value:function(e){return gt(e)||this._sentFlag||(ct(e)&&(this.message=e.toString()),ut(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return gt(e)||this._sentFlag||(this.level=Ps[e]),this}},{key:"setMoreMessage",value:function(e){return st(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){if(gt(e))Be.w("".concat(this._n,".setNetworkType value is undefined, please check!"));else{var t=ws[e.toLowerCase()];gt(t)||(this.networkType=t)}return this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){return this.uiPlatform=e,this}},{key:"setExtension",value:function(e){return this.extension=e,this}},{key:"setEventType",value:function(e){return this.eventType=e,this}}],[{key:"bindEventStatModule",value:function(t){e.prototype._eventStatModule=t}},{key:"bindNetMonitorModule",value:function(t){e.prototype._netMonitorModule=t}}])}(),Fs=r((function e(t){i(this,e),this.type=D.MSG_TEXT,this.content={text:t.text||""}}),[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]);function xs(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(!e)return e;var i=e;return t&&(e.startsWith("http://")?i=e.replace(/^http:\/\/[^/]+/,t):e.startsWith("https://")&&(i=e.replace(/^https:\/\/[^/]+/,t))),n&&-1===i.indexOf("authKey=")&&Ks(i,s)&&(i=i.indexOf("?")>-1?"".concat(i,"&authKey=").concat(n):"".concat(i,"?authKey=").concat(n)),i}function Vs(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],s=t[0].content?t[0].content:t[0].payload;if(e===D.MSG_IMAGE)s.imageInfoArray.forEach((function(e){Ks(e.imageUrl,n)&&(e.imageUrl=qs(e.imageUrl))}));else if(e===D.MSG_VIDEO)Ks(s.snapshotUrl,n)&&(s.snapshotUrl=qs(s.snapshotUrl),s.thumbUrl=qs(s.thumbUrl)),Ks(s.remoteVideoUrl,n)&&(s.remoteVideoUrl=qs(s.remoteVideoUrl));else if(e===D.MSG_AUDIO)Ks(s.remoteAudioUrl,n)&&(s.remoteAudioUrl=qs(s.remoteAudioUrl));else if(e===D.MSG_FILE)Ks(s.fileUrl,n)&&(s.fileUrl=qs(s.fileUrl));else if(e===D.MSG_MERGER){var i=t[0].content||t[0].payload,a=i.downloadKey,o=void 0===a?"":a,r=i.messageList,c=void 0===r?[]:r;st(o)&&c.forEach((function(e){Vs(e.messageBody[0].type,e.messageBody,n)}))}return t}function qs(e){if(!e)return e;if(-1===e.indexOf("authKey="))return e;for(var t=e.split("?"),n=t[1].split("&"),s=0,i=0;i<n.length;i++)if(n[i].indexOf("authKey=")>-1){s=i;break}return n.splice(s,1),n.length>0?"".concat(t[0],"?").concat(n.join("&")):t[0]}function Ks(e,t){var n=!1;if(e){var s=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),i=s&&s[2]||"";if(i.includes("rich-dev"))return!0;for(var a=0;a<t.length;a++)if(i.endsWith(t[a])){n=!0;break}}return n}var Hs=r((function e(t,n,s,a){i(this,e),this._imageMemoryURL="",this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,ue||de?this.createImageDataASURL(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=D.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||Ye.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._autoFixUrl()}),[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=Tt(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.imageUrl||t.url||"",this.url=xs(t.url||e._imageMemoryURL,e._fileDownloadProxy,e._authKey,e._fileDNList)},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(t){t&&(this.imageUrl=xs(t,e._fileDownloadProxy,e._authKey,e._fileDNList))},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,n=null,s=null;t<=2;)s=gt(e)||gt(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(n=new this._ImageInfoModel(s)).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,s=0;s<n;s++)t=this.content.imageInfoArray[s],e[s].size&&(t.size=e[s].size),e[s].url&&t.setImageUrl(e[s].url),e[s].width&&(t.width=e[s].width),e[s].height&&(t.height=e[s].height)}},{key:"_autoFixUrl",value:function(){for(var e=this.content.imageInfoArray.length,t="",n="",s=["http","https"],i=null,a=0;a<e;a++)this.content.imageInfoArray[a].url&&""!==(i=this.content.imageInfoArray[a]).imageUrl&&(n=i.imageUrl.slice(0,i.imageUrl.indexOf("://")+1),t=i.imageUrl.slice(i.imageUrl.indexOf("://")+1),s.indexOf(n)<0&&(n="https:"),this.content.imageInfoArray[a].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=Ye[e.toUpperCase()]||Ye.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURL",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,s=void 0===n?0:n,i=t.height,a=void 0===i?0:i;0!==s&&0!==a&&(Ht(e),Object.assign(e[2],Kt({originWidth:s,originHeight:a,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size}}]),js=r((function e(t){i(this,e),this.type=D.MSG_FACE,this.content=t||null}),[{key:"sendable",value:function(){return null!==this.content}}]),Bs=r((function e(t,n,s,a){i(this,e),this.type=D.MSG_AUDIO,this._percent=0,this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,this.content={downloadFlag:2,second:t.second,size:t.size,url:xs(t.url,this._fileDownloadProxy,this._authKey,this._fileDNList),remoteAudioUrl:xs(t.url||"",this._fileDownloadProxy,this._authKey,this._fileDNList),uuid:t.uuid}}),[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=xs(e,this._fileDownloadProxy,this._authKey,this._fileDNList)}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),Ys={from:!0,groupID:!0,groupName:!0,to:!0},Ws=r((function e(t){i(this,e),this.type=D.MSG_GRP_TIP,this.content={},this._initContent(t)}),[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"remarkInfo":case"memberExtraInfo":case"onlineMemberInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;case"operatorInfo":t.content.operatorInfo={},t._initOperatorInfo(e[n]);break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[n]);break;case"memberNum":t.content[n]=e[n],t.content.memberCount=e[n];break;case"newGroupProfile":t.content.newGroupProfile={},t._initNewGroupProfile(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 s=t[n];Ys[s]&&(this.content.groupProfile[s]=e[s])}}},{key:"_initOperatorInfo",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var s=t[n];this.content.operatorInfo[s]=e[s]}}},{key:"_updateMemberList",value:function(e){st(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)}))}))}},{key:"_initNewGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var s=t[n];this.content.newGroupProfile[s]="muteAllMembers"!==s?e[s]:1===e[s]}}}]),zs={from:!0,groupID:!0,groupName:!0,to:!0,groupType:!0},$s=r((function e(t){i(this,e),this.type=D.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}),[{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 s=t[n];zs[s]&&("groupName"===s?this.content.groupProfile.name=e[s]:this.content.groupProfile[s]=e[s])}}}]),Js=r((function e(t,n,s,a){i(this,e),this.type=D.MSG_FILE,this._percent=0;var o=this._getFileInfo(t);this.content={downloadFlag:2,fileUrl:xs(t.url||t.fileUrl,n,s,a)||"",uuid:t.uuid,fileName:o.name||"",fileSize:o.size||0}}),[{key:"_getFileInfo",value:function(e){if(!gt(e.fileName)&&!gt(e.fileSize))return{size:e.fileSize,name:e.fileName};var t=e.file.files[0];if(oe){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(Tt(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}}]),Xs=r((function e(t){i(this,e),this.type=D.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}}),[{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}}]),Zs=r((function e(t,n,s,a){i(this,e),this.type=D.MSG_VIDEO,this._percent=0,this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,this.content={remoteVideoUrl:xs(t.remoteVideoUrl||t.videoUrl||"",this._fileDownloadProxy,this._authKey,this._fileDNList),videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:xs(t.videoUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,snapshotWidth:t.thumbWidth,thumbHeight:t.thumbHeight,snapshotHeight:t.thumbHeight,thumbSize:t.thumbSize,snapshotSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:xs(t.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),snapshotUrl:xs(t.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList)}}),[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=xs(e,this._fileDownloadProxy,this._authKey,this._fileDNList))}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,n=e.snapshotWidth,s=e.snapshotHeight;st(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),st(n)||(this.content.thumbWidth=this.content.snapshotWidth=Number(n)),st(s)||(this.content.thumbHeight=this.content.snapshotHeight=Number(s))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),Qs=r((function e(t){i(this,e),this.type=D.MSG_LOCATION;var n=t.description,s=t.longitude,a=t.latitude;this.content={description:n,longitude:s,latitude:a}}),[{key:"sendable",value:function(){return!0}}]),ei=r((function e(t,n,s,a){if(i(this,e),this.from=t.from,this.messageSender=t.from,this.time=t.time,this.messageSequence=t.sequence,this.clientSequence=t.clientSequence||t.sequence,this.messageRandom=t.random,this.cloudCustomData=t.cloudCustomData||"",this.clientTime=t.clientTime||void 0,t.ID)this.ID=t.ID||"",this.nick=t.nick||"",this.avatar=t.avatar||"",t.messageBody?this.messageBody=JSON.parse(JSON.stringify(t.messageBody)):this.messageBody=[{type:t.type,payload:t.payload}],t.conversationType?t.conversationType.startsWith(D.CONV_C2C)?this.receiverUserID=t.to:t.conversationType.startsWith(D.CONV_GROUP)&&(this.receiverGroupID=t.to):t.receiverGroupID?this.receiverGroupID=t.receiverGroupID:t.receiverUserID&&(this.receiverUserID=t.receiverUserID),this.messageReceiver=t.to||t.messageReceiver;else{this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[];var o=t.elements[0].type,r=t.elements[0].content;this._patchRichMediaPayload(o,r),this._updateRichMediaDownloadUrl(o,r,n,s,a),o===D.MSG_MERGER?this.messageBody.push({type:o,payload:new ti(r,n,s,a).content}):this.messageBody.push({type:o,payload:r}),t.groupID&&(this.receiverGroupID=t.groupID,this.messageReceiver=t.groupID),t.to&&(this.receiverUserID=t.to,this.messageReceiver=t.to),this.ID="".concat(t.tinyID,"-").concat(t.clientTime,"-").concat(t.random)}}),[{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)}},{key:"_updateRichMediaDownloadUrl",value:function(e,t,n,s,i){(n||s)&&(e===D.MSG_IMAGE?t.imageInfoArray.forEach((function(e){e.imageUrl=xs(e.imageUrl,n,s,i),e.url=xs(e.url,n,s,i)})):e===D.MSG_VIDEO?(t.remoteVideoUrl=xs(t.remoteVideoUrl,n,s,i),t.videoUrl=xs(t.videoUrl,n,s,i),t.thumbUrl=xs(t.thumbUrl,n,s,i),t.snapshotUrl=xs(t.thumbUrl,n,s,i),t.snapshotHeight=t.thumbHeight,t.snapshotWidth=t.thumbWidth):e===D.MSG_AUDIO?(t.remoteAudioUrl=xs(t.remoteAudioUrl,n,s,i),t.url=xs(t.url,n,s,i)):e===D.MSG_FILE&&(t.fileUrl=xs(t.fileUrl,n,s,i)))}}]),ti=r((function e(t,n,s,a){if(i(this,e),this.type=D.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},t.downloadKey){var o=t.downloadKey,r=t.pbDownloadKey,c=t.title,u=t.abstractList,l=t.compatibleText,d=t.version;this.content.downloadKey=o,this.content.pbDownloadKey=r,this.content.title=c,this.content.abstractList=u,this.content.compatibleText=l,this.content.version=d||0}else if(st(t.messageList))1===t.layersOverLimit&&(this.content.layersOverLimit=!0);else{var h=t.messageList,g=t.title,p=t.abstractList,f=t.compatibleText,_=t.version,v=[];h.forEach((function(e){if(!st(e)){var t=new ei(e,n,s,a);v.push(t)}})),this.content.messageList=v,this.content.title=g,this.content.abstractList=p,this.content.compatibleText=f,this.content.version=_||0}}),[{key:"sendable",value:function(){return!st(this.content.messageList)||!st(this.content.downloadKey)}}]),ni=0,si=1,ii=0,ai=r((function e(t){i(this,e),this.type=D.MSG_STREAM,this._chunks=[],this._lastIndex=0;var n=t.streamMessageID,s=t.compatibleText,a=t.markdown,o=t.binaryData,r=t.errorCode,c=void 0===r?0:r,u=t.errorMessage,l=void 0===u?"":u,d=t.isStreamEnded,h=void 0!==d&&d;this.content={streamMessageID:n,compatibleText:s,markdown:a||"",binaryData:o,errorCode:c,errorMessage:l,isStreamEnded:h},this.stopReason=0}),[{key:"updateChunks",value:function(e){if(e&&0!==e.length){var t=e.sort((function(e,t){return e.index-t.index})),n=this._getMaxRevokedChunkIndex(t);n>=0&&(this._chunks=[],this._lastIndex=n,this._updateContent());var s=this._getValidChunks(t);if(0!==s.length&&(this._mergeAndSortChunks(s),this._chunks.length>0)){var i=this._chunks[this._chunks.length-1];this._lastIndex=i.index,this._updateContent(),this.content.isStreamEnded=i.isLast}}}},{key:"_getMaxRevokedChunkIndex",value:function(e){for(var t,n=-1,s=0,i=e.length;s<i;s++)(t=e[s]).eventType===si&&t.index>n&&(n=t.index);return n}},{key:"_updateContent",value:function(){this.content=_(_({},this.content),{},{markdown:this._chunks.map((function(e){return e.markdown})).join("")});var e=this._chunks.map((function(e){return e.binaryData})).filter((function(e){return!!e&&e.length>0}));if(0===e.length)this.content.binaryData=new Uint8Array(0);else if(1===e.length)this.content.binaryData=e[0];else{var t,n=e.reduce((function(e,t){return e+t.length}),0),s=new Uint8Array(n),i=0,a=c(e);try{for(a.s();!(t=a.n()).done;){var o=t.value;s.set(o,i),i+=o.length}}catch(e){a.e(e)}finally{a.f()}this.content.binaryData=s}}},{key:"_mergeAndSortChunks",value:function(e){var t=new Map;this._chunks.forEach((function(e){t.set(e.index,e)})),e.forEach((function(e){t.set(e.index,e)})),this._chunks=Array.from(t.values()).sort((function(e,t){return e.index-t.index}))}},{key:"getLastIndex",value:function(){return this._lastIndex}},{key:"_getValidChunks",value:function(e){var t=this,n=e.filter((function(e){return e.eventType===ni&&e.index>t._lastIndex}));if(0===n.length)return[];var s,i=[],a=this._lastIndex+1,o=c(n);try{for(o.s();!(s=o.n()).done;){var r=s.value;r.index===a&&(i.push(r),a++)}}catch(e){o.e(e)}finally{o.f()}return i}}]),oi={1:D.MSG_PRIORITY_HIGH,2:D.MSG_PRIORITY_NORMAL,3:D.MSG_PRIORITY_LOW,4:D.MSG_PRIORITY_LOWEST},ri=r((function e(t){i(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||D.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||0===t.random?t.random:Tt(),this.priority=this._computePriority(t.priority),this.nick=t.nick||"",this.avatar=t.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=tn(t.checkResult),this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||on,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=t.cloudCustomData||"",this.isDeleted=!1,this.isModified=!!t.messageVersion,this._isExcludedFromUnreadCount=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromLastMessage),this.clientTime=t.clientTime||qe()||0,this.senderTinyID=t.senderTinyID||t.tinyID||"",this.readReceiptInfo=t.readReceiptInfo||{readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},this.needReadReceipt=!0===t.needReadReceipt||1===t.needReadReceipt,this.version=t.messageVersion||0,this.isBroadcastMessage=t.isBroadcastMessage||!1,this._receiverList=t.receiverList||void 0,this.isSupportExtension=!0===t.isSupportExtension||1===t.isSupportExtension,this._cmConfigID=t.customModerationConfigurationID,this.revoker=t.revokerInfo&&t.revokerInfo.revoker||"",this.revokerInfo=t.revokerInfo||{userID:"",nick:"",avatar:""},this.revokeReason=t.revokeReason||"",this.pinnerInfo=t.pinnerInfo||null,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null),this.handleGroupAtInfo(t),this.initC2CReadReceiptInfo(t)}),[{key:"elements",get:function(){return this._elements}},{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){if(null!==e){ut(e.nick)&&(this.nick=e.nick),ut(e.avatar)&&(this.avatar=e.avatar);var t=e.messageFromAccountExtraInformation;dt(t)&&ut(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))})),ht(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?on:an,!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&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&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!1;if(void 0===Dt[e]){var t=new Date,n="3".concat(t.getHours()).slice(-2),s="0".concat(t.getMinutes()).slice(-2),i="0".concat(t.getSeconds()).slice(-2);Dt[e]=parseInt([n,s,i,"0001"].join("")),n=null,s=null,i=null,Be.l("autoIncrementIndex start index:".concat(Dt[e]))}return Dt[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="",s=this.conversationType;s!==D.CONV_SYSTEM?(n=s===D.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID=n?"".concat(s).concat(n):null):this.conversationID=D.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Fs||e instanceof Hs||e instanceof js||e instanceof Bs||e instanceof Js||e instanceof Zs||e instanceof Ws||e instanceof $s||e instanceof Xs||e instanceof Qs||e instanceof ti||e instanceof ai}},{key:"setElement",value:function(e,t,n,s){var i=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var a=function(e){if(e.type&&e.content)switch(e.type){case D.MSG_TEXT:i.setTextElement(e.content);break;case D.MSG_IMAGE:i.setImageElement(e.content,t,n,s);break;case D.MSG_AUDIO:i.setAudioElement(e.content,t,n,s);break;case D.MSG_FILE:i.setFileElement(e.content,t,n,s);break;case D.MSG_VIDEO:i.setVideoElement(e.content,t,n,s);break;case D.MSG_CUSTOM:i.setCustomElement(e.content);break;case D.MSG_LOCATION:i.setLocationElement(e.content);break;case D.MSG_GRP_TIP:i.setGroupTipElement(e.content);break;case D.MSG_GRP_SYS_NOTICE:i.setGroupSystemNoticeElement(e.content);break;case D.MSG_FACE:i.setFaceElement(e.content);break;case D.MSG_MERGER:i.setMergerElement(e.content,t,n,s);break;case D.MSG_STREAM:i.setStreamElement(e.content)}};if(ht(e))for(var o=0;o<e.length;o++)a(e[o]);else a(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,t,n,s){var i=new Hs(e,t,n,s);this._elements.push(i)}},{key:"setAudioElement",value:function(e,t,n,s){var i=new Bs(e,t,n,s);this._elements.push(i)}},{key:"setFileElement",value:function(e,t,n,s){var i=new Js(e,t,n,s);this._elements.push(i)}},{key:"setVideoElement",value:function(e,t,n,s){var i=new Zs(e,t,n,s);this._elements.push(i)}},{key:"setLocationElement",value:function(e){var t=new Qs(e);this._elements.push(t)}},{key:"setCustomElement",value:function(e){var t=new Xs(e);this._elements.push(t)}},{key:"setGroupTipElement",value:function(e){var t={},n=e.operationType;if(st(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]),!st(e.memberExtraInfo)){var s=e.memberExtraInfo.reason;e.msgMemberInfo.forEach((function(e){e.reason=s}))}var i=t,a=i.nick,o=i.avatar;ut(a)&&(this.nick=a),ut(o)&&(this.avatar=o);var r=new Ws(e);this._elements.push(r)}},{key:"setGroupSystemNoticeElement",value:function(e){var t=new $s(e);this._elements.push(t)}},{key:"setFaceElement",value:function(e){var t=new js(e);this._elements.push(t)}},{key:"setMergerElement",value:function(e,t,n,s){var i=new ti(e,t,n,s);this._elements.push(i)}},{key:"setStreamElement",value:function(e){var t=new ai(e);this._elements.push(t)}},{key:"setIsRead",value:function(e){this.isRead=e}},{key:"setRelayFlag",value:function(e){this._relayFlag=e}},{key:"_computePriority",value:function(e){if(gt(e))return D.MSG_PRIORITY_NORMAL;if(ut(e)&&-1!==Object.values(oi).indexOf(e))return e;if(ct(e)){var t=""+e;if(-1!==Object.keys(oi).indexOf(t))return oi[t]}return D.MSG_PRIORITY_NORMAL}},{key:"setNickAndAvatar",value:function(e){var t=e.nick,n=e.avatar;ut(t)&&(this.nick=t),ut(n)&&(this.avatar=n)}},{key:"setNameCard",value:function(e){ut(e)&&(this.nameCard=e)}},{key:"initC2CReadReceiptInfo",value:function(e){var t=e.readReceiptSentByPeer,n=void 0===t?void 0:t,s=e.timestamp,i=void 0===s?0:s;this.conversationType===D.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===n,this.readReceiptInfo.timestamp=i)}}]),ci=["sound","FCMChannelID"],ui=["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"],li={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},di={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function hi(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var s=t[n],i=s.range,a=s.defaultValue;e[n]=i.includes(e[n])?e[n]:a}return e}function gi(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function pi(e){var t=e.androidInfo,n=void 0===t?{}:t,s=e.androidOPPOChannelID,i=void 0===s?"":s,a=n.OPPOChannelID||i,o=hi(n,li),r=o.sound,c=void 0===r?"":r,u=o.FCMChannelID,l=void 0===u?"":u;return _(_({},v(o,ci)),{},{Sound:gi(c),OPPOChannelID:a,GoogleChannelID:l})}function fi(e){var t=e.apnsInfo,n=void 0===t?{}:t,s=e.ignoreIOSBadge,i=void 0!==s&&s,a=e.disableVoipPush,o=hi(n,di),r=o.ignoreIOSBadge,c=o.disableVoipPush,u=o.enableIOSBackgroundNotification,l=v(o,ui),d=!0===r||!0===i?1:0,h=void 0;return gt(a)||(h=!1===a?1:0),gt(c)||(h=!1===c?1:0),_(_({},l),{},{badgeMode:d,isVoipPush:h,contentAvailable:u?1:0})}function _i(e){if(dt(e))return{pushFlag:!0===e.disablePush?1:0,title:e.title||"",desc:e.description||"",ext:e.extension||"",apnsInfo:fi(e),androidInfo:pi(e)}}var vi=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="C2CModule",s._msgFromUnreadDBMap=new Map,s._noticeFromUnreadDBList=[],s}return d(t,e),r(t,[{key:"onNewMessage",value:function(e){var t=e.dataList,n=e.isInstantMessage,s=e.C2CRemainingUnreadList,i=e.C2CPairUnreadList,a=e.isSyncingEnded;n||Be.l("".concat(this._n,".onNewMessage C2CPairUnreadList:"),i,"C2CRemainingUnreadList:",s);var o=this._assembly({dataList:t,C2CRemainingUnreadList:s,C2CPairUnreadList:i,isInstantMessage:n}),r=o.conversationOptionsList,c=o.messageList,u=o.isUnreadC2CMessage,l=function(e){return st(e)?[]:e.filter((function(e){return!0===e.isModified}))}(c);l.length>0&&this.emitOEvt(k.MESSAGE_MODIFIED,l),this.get(Yn).onNewMessage({conversationOptionsList:r,isInstantMessage:n,isUnreadC2CMessage:u,isSyncingEnded:a});var d=function(e){return st(e)?[]:e.filter((function(e){return!1===e.isModified}))}(c);n&&d.length>0&&this.emitOEvt(k.MESSAGE_RECEIVED,d),c.length=0}},{key:"_assembly",value:function(e){for(var t=e.dataList,n=e.C2CRemainingUnreadList,s=e.C2CPairUnreadList,i=e.isInstantMessage,a=null,o=[],r=[],c={},u=this.get(as),l=!1,d=this.get(Yn),h=this.get(qn),g=this.get(Xn),p=this.getFileDownloadProxy(),f=this.getDownloadFileAuthKey(),_=g.getFileDNList(),v=0,m=t.length;v<m;v++)if(this._isC2CNotice(t[v]))this._noticeFromUnreadDBList.push(t[v].eventArray[0].c2CNotifyMsgArray[0]);else{var y=t[v];y.currentUser=this.getMyUserID(),y.conversationType=D.CONV_C2C,y.isSystemMessage=!!y.isSystemMessage,(gt(y.nick)||gt(y.avatar))&&(l=!0),(a=new ri(y)).setElement(y.elements,p,f,_),a.setNickAndAvatar({nick:y.nick,avatar:y.avatar});var I=a.conversationID;if(i){if(this._msgFromUnreadDBMap.get(a.ID))continue;var M=!1;if(a.from!==this.getMyUserID()){var C=d.getLatestMessageSentByPeer(I);if(C){var T=C.nick,S=C.avatar;l?a.setNickAndAvatar({nick:T,avatar:S}):T===a.nick&&S===a.avatar||(M=!0)}}else{var E=d.getLatestMessageSentByMe(I);if(E){var k=E.nick,O=E.avatar;k===a.nick&&O===a.avatar||(d.modifyMessageSentByMe({conversationID:I,latestNick:a.nick,latestAvatar:a.avatar}),h.mockOnNickAvatarModified(a.nick,a.avatar))}}var R=1===t[v].isModified;if(d.isMessageSentByCurrentInstance(a)?a.isModified=R:R=!1,0===y.msgLifeTime)a._onlineOnlyFlag=!0,d.isMessageSentByCurrentInstance(a)||r.push(a);else{if(!d.pushIntoMessageList(r,a,R))continue;M&&(d.modifyMessageSentByPeer({conversationID:I,latestNick:a.nick,latestAvatar:a.avatar}),d.updateUserProfileSpecifiedKey({conversationID:I,nick:a.nick,avatar:a.avatar}))}i&&a.clientTime>0&&u.addMessageDelay(a.clientTime)}else this._msgFromUnreadDBMap.set(a.ID,a);if(0!==y.msgLifeTime){if(!1===a._onlineOnlyFlag){var A=d.getLastMessageTime(I);if(ct(A)&&a.time<A)continue;if(i)if(gt(c[I])){var N=0;"in"===a.flow&&(a._isExcludedFromUnreadCount||(N=1)),c[I]=o.push({conversationID:I,unreadCount:N,type:a.conversationType,subType:a.conversationSubType,lastMessage:a._isExcludedFromLastMessage?"":a})-1}else{var L=c[I];o[L].type=a.conversationType,o[L].subType=a.conversationSubType,o[L].lastMessage=a._isExcludedFromLastMessage?"":a,"in"===a.flow&&(a._isExcludedFromUnreadCount||o[L].unreadCount++)}}}else a._onlineOnlyFlag=!0}this._handleNoticeFromUnreadDB();var U=!1;if(ht(s)&&s.length>0)for(var P=function(e){if(s[e].from===D.CONV_SYSTEM)return 1;U=!0;var t=o.find((function(t){return t.conversationID==="".concat(D.CONV_C2C).concat(s[e].from)}));t?t.unreadCount=s[e].unreadCount:o.push({conversationID:"".concat(D.CONV_C2C).concat(s[e].from),unreadCount:s[e].unreadCount,type:D.CONV_C2C})},w=0,b=s.length;w<b;w++)P(w);if(ht(n))for(var G=function(e){o.find((function(t){return t.conversationID==="".concat(D.CONV_C2C).concat(n[e].from)}))||o.push({conversationID:"".concat(D.CONV_C2C).concat(n[e].from),type:D.CONV_C2C,lastMsgTime:n[e].lastMsgTime})},F=0,x=n.length;F<x;F++)G(F);return{conversationOptionsList:o,messageList:r,isUnreadC2CMessage:U}}},{key:"getMessageListFromUnreadDB",value:function(){return I(this._msgFromUnreadDBMap.values())}},{key:"_isC2CNotice",value:function(e){var t=e.eventArray;return!(!ht(t)||10!==t[0].event)}},{key:"_handleNoticeFromUnreadDB",value:function(){var e=this._noticeFromUnreadDBList.length;if(0!==e){Be.l("".concat(this._n,"._handleNoticeFromUnreadDB count:").concat(e));var t=[];this._noticeFromUnreadDBList.forEach((function(e){e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)})),this.onMsgRevoked({dataList:t}),this._noticeFromUnreadDBList.length=0,t.length=0}}},{key:"onMsgRevoked",value:function(e,t){var n=this,s=this.get(Yn),i=[],a=null;e.dataList.forEach((function(e){if(e.c2cMessageRevokedNotify){var t=e.c2cMessageRevokedNotify.revokedInfos;gt(t)||t.forEach((function(e){var t=n.getMyUserID()===e.from?"".concat(D.CONV_C2C).concat(e.to):"".concat(D.CONV_C2C).concat(e.from);a=s.revoke(t,e.sequence,e.random);var o,r=e.revokerInfo&&e.revokerInfo.revoker,c=e.revokerInfo&&e.revokerInfo.reason||"";a?o=a:(o={conversationID:t,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(o.ID="".concat(e.tinyID,"-").concat(e.clientTime,"-").concat(e.random)),e.time&&(o.time=e.time)),o&&(o.revoker=r,o.revokeReason=c,o.revokerInfo={userID:r,nick:"",avatar:""},i.push(o))}))}})),0!==i.length&&(Be.l("".concat(this._n,".onMsgRevoked count:").concat(i.length," updateUnreadCount:").concat(t)),s.onMessageRevoked(i,t),s.updateRevokerInfo(i).then((function(e){n.emitOEvt(k.MESSAGE_REVOKED,e)})))}},{key:"onMsgReadReceipt",value:function(e){var t=this;e.dataList.forEach((function(e){if(!st(e.c2cMessageReadReceipt)){var n=e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach((function(e){var s=e.peerReadTime;Be.l("".concat(t._n,".onMsgReadReceipt to:").concat(n," peerReadTime:").concat(s));var i="".concat(D.CONV_C2C).concat(n),a=t.get(Yn);a.recordPeerReadTime(i,s),a.updateMsgIsPeerReadProp(i,s)}))}}))}},{key:"onMsgReadNotice",value:function(e){var t=this;e.dataList.forEach((function(e){if(!st(e.c2cMessageReadNotice)){var n=t.get(Yn);e.c2cMessageReadNotice.uinPairReadArray.forEach((function(e){var s=e.from,i=e.peerReadTime;Be.l("".concat(t._n,".onMsgReadNotice from:").concat(s," lastReadTime:").concat(i));var a="".concat(D.CONV_C2C).concat(s);n.updateIsReadAfterReadReport({conversationID:a,lastMessageTime:i}),n.updateUnreadCount(a)}))}}))}},{key:"onMsgModified",value:function(e){Be.l("".concat(this._n,".onMsgModified options:"),e);var t=this.get(Yn);e.dataList.forEach((function(e){t.onMessageModified(_(_({},e),{},{conversationType:D.CONV_C2C}))}))}},{key:"onReadReceiptList",value:function(e){Be.l("".concat(this._n,".onReadReceiptList options:"),e),this.get(Yn).updateReadReceiptInfo(e.dataList)}},{key:"sendMessage",value:function(e,t){var n=this._createC2CMessagePack(e,t);return this.req(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 s="";ut(e.cloudCustomData)&&e.cloudCustomData.length>0&&(s=e.cloudCustomData);var i=[];if(dt(t)&&dt(t.messageControlInfo)){var a=t.messageControlInfo,o=a.excludedFromUnreadCount,r=a.excludedFromLastMessage,c=a.excludedFromContentModeration;!0===o&&i.push("NoUnread"),!0===r&&i.push("NoLastMsg"),!0===c&&i.push("NoMsgCheck")}var u=this.isOnlineMessage(e,t)?0:void 0,l=JSON.parse(JSON.stringify(e.getElements())),d=this.get(Xn).getFileDNList();return{P:Cs.SEND_C2C_MSG,data:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:Vs(e.type,l,d),cloudCustomData:s,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:u,nick:e.nick,avatar:e.avatar,offlinePushInfo:_i(n),messageControlInfo:0!==u?i:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0,cmConfigID:e._cmConfigID,forbidCallbackControl:At(t)}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.req({P:Cs.REVOKE_C2C_MSG,data:{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 Be.l("".concat(this._n,".deleteMessage toAccount:").concat(t," count:").concat(n.length)),this.req({P:Cs.DEL_C2C_MSG,data:{fromAccount:this.getMyUserID(),to:t,keyList:n}})}},{key:"modifyRemoteMessage",value:function(e){var t=e.from,n=e.to,s=e.version,i=void 0===s?0:s,a=e.sequence,o=e.random,r=e.time,c=e.payload,u=e.type,l=e.cloudCustomData,d=e._elements,h=void 0;return function(e){return e===D.MSG_TEXT||e===D.MSG_CUSTOM||e===D.MSG_LOCATION||e===D.MSG_FACE}(u)&&(d.length>1&&d.splice(0,1,{type:u,content:c}),h=d),this.req({P:Cs.MODIFY_C2C_MSG,data:{from:t,to:n,version:i,sequence:a,random:o,time:r,elements:h,cloudCustomData:l}})}},{key:"setMessageRead",value:function(e){var t=this,n=e.conversationID,s=e.lastMessageTime,i="".concat(this._n,".").concat("setMessageRead"),a="convID:".concat(n," lastMessageTime:").concat(s);Be.l("".concat(i," ").concat(a)),ct(s)||this.warn("DoNotModifyLastTime");var o=new Gs("setMessageRead");return o.setMessage(a),this.req({P:Cs.SET_C2C_MSG_READ,data:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:n.replace("C2C",""),lastMessageTime:s,receipt:1}]}}}).then((function(){o.end(),Be.l("".concat(i," ok"));var e=t.get(Yn);return e.updateIsReadAfterReadReport({conversationID:n,lastMessageTime:s}),e.updateUnreadCount(n),ps()})).catch((function(e){return o.setError(e).end(),Be.l("".concat(i," failed. error:"),e),Is(e)}))}},{key:"getRoamingMessage",value:function(e){var t=this,n="".concat(this._n,".").concat("getRoamingMessage"),s=e.peerAccount,i=e.conversationID,a=e.count,o=e.lastMessageTime,r=e.messageKey,c="peerAccount:".concat(s," count:").concat(a||15," lastMessageTime:").concat(o||0," messageKey:").concat(r);Be.l("".concat(n," ").concat(c));var u=new Gs("getRoamingMessage");return this.req({P:Cs.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:a||15,lastMessageTime:o||0,messageKey:r}}).then((function(e){var s=e.data,a=s.complete,o=s.messageList,r=s.messageKey,l=s.lastMessageTime;gt(o)?Be.l("".concat(n," ok. complete:").concat(a," but messageList is undefined!")):Be.l("".concat(n," ok. complete:").concat(a," count:").concat(o.length)),u.setMessage("".concat(c," complete:").concat(a," length:").concat(o.length)).end();var d=t.get(Yn),h=1===a;h&&d.setCompleted(i);var g=[],p=d.onRoamingMessage(o,i,!0,g);d.modifyMessageList(i),d.updateIsRead(i),d.updateRoamingMsgKeyAndTime(i,r,l);var f="";if(p.length>0)f=p[0].ID;else{var _=d.getLocalOldestMessage(i);_&&(f=_.ID)}var v=d.getPeerReadTime(i);if(Be.l("".concat(n," update isPeerRead property. convID:").concat(i," peerReadTime:").concat(v)),!v){var m=i.replace(D.CONV_C2C,"");return t.getRemotePeerReadTime([m]).then((function(){return d.updateMsgIsPeerReadProp(i,d.getPeerReadTime(i)),Be.l("".concat(n," nextReqID:").concat(f," storedMsgCount:").concat(p.length)),{nextReqID:f,storedMessageList:p,assembledMessageList:g,isPullingCompleted:h}}))}return d.updateMsgIsPeerReadProp(i,v),Be.l("".concat(n," nextReqID:").concat(f," storedMsgCount:").concat(p.length)),{nextReqID:f,storedMessageList:p,assembledMessageList:g,isPullingCompleted:h}})).catch((function(e){return u.setMessage(c).setError(e).end(),Be.w("".concat(n," failed. error:"),e),Is(e)}))}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,n="".concat(this._n,".").concat("getRoamingMessagesHopping"),s=e.peerAccount,i=e.time,a=void 0===i?0:i,o=e.count,r=e.direction,c="".concat(D.CONV_C2C).concat(s),u="peerAccount:".concat(s," count:").concat(o," time:").concat(a," direction:").concat(r);Be.l("".concat(n," ").concat(u));var l=new Gs("getRoamingMessagesHopping");return this.req({P:Cs.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:o+1,lastMessageTime:a,direction:r}}).then((function(e){var s=e.data,i=s.complete,a=s.messageList,o=void 0===a?[]:a,d=s.lastMessageTime,h="complete:".concat(i," count:").concat(o.length);Be.l("".concat(n," ok. ").concat(h)),l.setMessage("".concat(u," ").concat(h)).end(),1!==i&&(1===r?o.pop():o.shift());var g=t.get(Yn),p=g.onRoamingMessage(o,c,!1);t._modifyMessageList(c,p);var f=t._computeResult({complete:i,lastMessageTime:d,resultList:p});g.storeHoppingMessageList(f.messageList);var _=g.getPeerReadTime(c);if(Be.l("".concat(n," update isPeerRead property. convID:").concat(c," peerReadTime:").concat(_)),_)g.updateMsgIsPeerReadProp(c,_);else{var v=c.replace(D.CONV_C2C,"");t.getRemotePeerReadTime([v]).then((function(){g.updateMsgIsPeerReadProp(c,g.getPeerReadTime(c))}))}return ps(f)})).catch((function(e){return l.setMessage(u).setError(e).end(),Be.w("".concat(n," failed. error:"),e),Is(e)}))}},{key:"_computeResult",value:function(e){var t=e.complete,n=void 0===t?0:t,s=e.lastMessageTime,i=e.resultList,a={messageList:I(void 0===i?[]:i),isCompleted:!1,nextMessageTime:""};return 1===n?(a.isCompleted=!0,a):(a.nextMessageTime=s,a)}},{key:"_modifyMessageList",value:function(e,t){var n=this.get(Yn).getLocalConversation(e);if(n)for(var s=n.userProfile.nick,i=n.userProfile.avatar,a=this.get(qn).getNickAndAvatarByUserID(this.getMyUserID()),o=a.nick,r=a.avatar,c=t.length-1;c>=0;c--){var u=t[c];"in"===u.flow&&(u.nick!==s&&u.setNickAndAvatar({nick:s}),u.avatar!==i&&u.setNickAndAvatar({avatar:i})),"out"===u.flow&&(u.nick!==o&&u.setNickAndAvatar({nick:o}),u.avatar!==r&&u.setNickAndAvatar({avatar:r}))}}},{key:"getRemotePeerReadTime",value:function(e){var t=this,n="".concat(this._n,".").concat("getRemotePeerReadTime");if(st(e))return Promise.resolve();var s=new Gs("getRemotePeerReadTime");return Be.l("".concat(n," userIDList:").concat(e)),this.req({P:Cs.GET_C2C_PEER_READ_TIME,data:{userIDList:e}}).then((function(i){var a=i.data.peerReadTimeList;Be.l("".concat(n," ok. peerReadTimeList:").concat(a));for(var o="",r=t.get(Yn),c=0;c<e.length;c++)o+="".concat(e[c],"-").concat(a[c]," "),a[c]>0&&r.recordPeerReadTime("".concat(D.CONV_C2C).concat(e[c]),a[c]);s.setMessage(o).end()})).catch((function(e){s.setError(e).end(),Be.w("".concat(n," failed. error:"),e)}))}},{key:"sendReadReceipt",value:function(e){var t=e[0].conversationID.replace(D.CONV_C2C,""),n=new Gs("sendReadReceipt");n.setMessage("peerAccount:".concat(t));var s=this.getMyUserID(),i=e.filter((function(e){return e.from!==s&&!0===e.needReadReceipt})).map((function(e){return{fromAccount:e.from,toAccount:e.to,sequence:e.sequence,random:e.random,time:e.time,clientTime:e.clientTime}}));if(0===i.length)return Is({code:_s.READ_RECEIPT_MSG_LIST_EMPTY});var a="".concat(this._n,".").concat("sendReadReceipt");return Be.l("".concat(a,". peerAccount:").concat(t," length:").concat(i.length)),this.req({P:Cs.SEND_C2C_READ_RECEIPT,data:{peerAccount:t,messageInfoList:i}}).then((function(e){return n.end(),Be.l("".concat(a," ok")),ps()})).catch((function(e){return n.setError(e).end(),Be.w("".concat(a," failed. error:"),e),Is(e)}))}},{key:"getReadReceiptList",value:function(e){var t=e[0].conversationID.replace(D.CONV_C2C,"");return Be.l("".concat(this._n,".getReadReceiptList peerAccount:").concat(t," msgCount:").concat(e.length)),ys({messageList:e})}},{key:"getMessageExtensions",value:function(e,t){return Be.l("".concat(this._n,".getMessageExtensions startSequence:").concat(t)),this.req({P:Cs.GET_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}},{key:"modifyMsgExts",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Be.l("".concat(this._n,".modifyMsgExts operateType:").concat(n)),this.req({P:Cs.MODIFY_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),extensionList:t,operateType:n}})}},{key:"getMessageKey",value:function(e){var t=e.clientSequence,n=e.random,s=e.time;return"".concat(t,"_").concat(n,"_").concat(s)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._msgFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0}}])}(Ms),mi={A2KEY_AND_TINYID_UPDATED:"_inner".concat(1),CLOUD_CONFIG:"_inner".concat(2),PROFILE_UPDATED:"_inner".concat(3),CONV_SYNC_COMPLETED:"_inner".concat(4),C2C_UNREAD_HANDLE_COMPLETED:"_inner".concat(5)},yi=r((function e(t){i(this,e),this._convM=t,this._map=new Map,this._n="MsgListHandler",this._latestMsgSentByPeerMap=new Map,this._latestMsgSentByMeMap=new Map,this._hoppingMsgMap=new Map,this.TOPIC_MSG_LIMIT=1e3,this._convM.getIEmitInst().on(mi.CLOUD_CONFIG,this._onCloudConfig,this)}),[{key:"_onCloudConfig",value:function(){var e=this._convM.getCloudConfig("topic_msg_limit");gt(e)||(this.TOPIC_MSG_LIMIT=Number(e)),Be.l("".concat(this._n,"._onCloudConfig topicMsgLimit:").concat(this.TOPIC_MSG_LIMIT))}},{key:"onCheckTimer",value:function(e){if(e%20==0&&this._map.size>0){var t,n=c(this._map);try{for(n.s();!(t=n.n()).done;){var s=y(t.value,2),i=s[0],a=s[1];i.includes(et)&&a.size>=this.TOPIC_MSG_LIMIT&&this._convM.clearMemMsg(i,!0)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"pushIn",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.conversationID,s=!0;this._map.has(n)||this._map.set(n,new Map);var i=this._getUniqueIDOfMsg(e);if(this._map.get(n).has(i)){var a=this._map.get(n).get(i);if(!t||!0===a.isModified)return!1}return this._map.get(n).set(i,e),this._setLatestMsgSentByPeer(n,e),this._setLatestMsgSentByMe(n,e),s}},{key:"unshift",value:function(e,t){var n;if(ht(e)?e.length>0&&(n=e[0].conversationID,this._unshiftMultipleMsgs(e,t)):(n=e.conversationID,this._unshiftSingleMsg(e,t)),n){var s=Array.from(this._map.get(n).values()),i=s.length;if(0===i)return;for(var a=i-1;a>=0;a--)if("out"===s[a].flow){this._setLatestMsgSentByMe(n,s[a]);break}if(n.startsWith(D.CONV_C2C))for(var o=i-1;o>=0;o--)if("in"===s[o].flow){this._setLatestMsgSentByPeer(n,s[o]);break}}}},{key:"_unshiftSingleMsg",value:function(e,t){var n=e.conversationID,s=this._getUniqueIDOfMsg(e);if(!this._map.has(n))return this._map.set(n,new Map),this._map.get(n).set(s,e),void t.push(e);var i=this._map.get(n),a=Array.from(i);i.has(s)||(a.unshift([s,e]),this._map.set(n,new Map(a)),t.push(e))}},{key:"_unshiftMultipleMsgs",value:function(e,t){for(var n=e.length,s=[],i=e[0].conversationID,a=this._map.get(i),o=this._map.has(i)?Array.from(a):[],r=0;r<n;r++){var c=this._getUniqueIDOfMsg(e[r]);a&&a.has(c)||(s.push([c,e[r]]),t.push(e[r]))}this._map.set(i,new Map(s.concat(o)))}},{key:"remove",value:function(e){var t=e.conversationID,n=this._getUniqueIDOfMsg(e);this._map.has(t)&&this._map.get(t).delete(n)}},{key:"revoke",value:function(e,t,n){if(this._map.has(e)){var s=this._map.get(e);return this._updateMsgIsRevoked(s,t,n)}if(this._hoppingMsgMap.has(e)){var i=this._hoppingMsgMap.get(e);return this._updateMsgIsRevoked(i,t,n)}return null}},{key:"_updateMsgIsRevoked",value:function(e,t,n){var s,i=c(e);try{for(i.s();!(s=i.n()).done;){var a=y(s.value,2)[1];if(a.sequence===t&&(gt(n)||a.random===n))return a.isRevoked||(a.isRevoked=!0),a}}catch(e){i.e(e)}finally{i.f()}}},{key:"removeByConvID",value:function(e){var t=this._map.has(e);Be.l("".concat(this._n,".removeByConvID convID:").concat(e," has:").concat(t)),t&&(this._map.delete(e),this._latestMsgSentByPeerMap.delete(e),this._latestMsgSentByMeMap.delete(e))}},{key:"findMessage",value:function(e){var t=null;return(t=this._findMsg(e,this._map))||(t=this._findMsg(e,this._hoppingMsgMap)),t}},{key:"_findMsg",value:function(e,t){var n,s=null,i=c(t);try{for(i.s();!(n=i.n()).done;)for(var a=I(y(n.value,2)[1].values()),o=a.length,r=0;r<o;r++)if(a[r].ID===e){s=a[r];break}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"updateMsgIsPeerReadProp",value:function(e,t){var n=[];if(this._map.has(e)){var s=this._map.get(e);n=this._updateMsgIsPeerReadProp(s,t)}else if(this._hoppingMsgMap.has(e)){var i=this._hoppingMsgMap.get(e);n=this._updateMsgIsPeerReadProp(i,t)}return Be.l("".concat(this._n,".updateMsgIsPeerReadProp convID:").concat(e," peerReadTime:").concat(t," count:").concat(n.length)),n}},{key:"_updateMsgIsPeerReadProp",value:function(e,t){var n,s=[],i=c(e);try{for(i.s();!(n=i.n()).done;){var a=y(n.value,2)[1];a.time<=t&&!a.isPeerRead&&"out"===a.flow&&(a.isPeerRead=!0,s.push(a))}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"updateMsgIsModifiedProp",value:function(e){var t=e.conversationID;if(this._map.has(t)){var n=this._getUniqueIDOfMsg(e),s=this._map.get(t).get(n);s&&(s.isModified=!0)}}},{key:"hasLocalMsgList",value:function(e){return this._map.has(e)}},{key:"getLocalMsgList",value:function(e){return this.hasLocalMsgList(e)?I(this._map.get(e).values()):[]}},{key:"getLocalMaxSeq",value:function(e){if(!this.hasLocalMsgList(e))return 0;var t=I(this._map.get(e).values()).map((function(e){return e.sequence}));return Math.max.apply(Math,I(t))}},{key:"getLocalMaxTime",value:function(e){if(!this.hasLocalMsgList(e))return 0;var t=I(this._map.get(e).values()).map((function(e){return e.time}));return Math.max.apply(Math,I(t))}},{key:"hasLocalMsg",value:function(e,t){for(var n=!1,s=this.getLocalMsgList(e),i=s.length,a=0;a<i;a++)s[a].ID===t&&(n=!0);return n}},{key:"getLocalMsg",value:function(e,t){for(var n=null,s=this.getLocalMsgList(e),i=s.length,a=0;a<i;a++)if(s[a].ID===t){n=s[a];break}return n}},{key:"getLocalLastMsg",value:function(e){for(var t=this.getLocalMsgList(e),n=void 0,s=t.length-1;s>=0;s--)if(t[s].status===on){n=t[s];break}return n}},{key:"getLocalSecondLastMsg",value:function(e){var t=this.getLocalMsgList(e);return t[t.length-2]}},{key:"getLocalOldestMsg",value:function(e){return this.getLocalMsgList(e)[0]}},{key:"_setLatestMsgSentByPeer",value:function(e,t){e.startsWith(D.CONV_C2C)&&"in"===t.flow&&this._latestMsgSentByPeerMap.set(e,t)}},{key:"_setLatestMsgSentByMe",value:function(e,t){"out"===t.flow&&this._latestMsgSentByMeMap.set(e,t)}},{key:"getLatestMsgSentByPeer",value:function(e){return this._latestMsgSentByPeerMap.get(e)}},{key:"getLatestMsgSentByMe",value:function(e){return this._latestMsgSentByMeMap.get(e)}},{key:"modifyMsgSentByPeer",value:function(e){var t=e.conversationID,n=e.latestNick,s=e.latestAvatar,i=this._map.get(t);if(!st(i)){var a=Array.from(i.values()),o=a.length;if(0!==o){for(var r=null,c=0,u=!1,l=o-1;l>=0;l--)"in"===a[l].flow&&((r=a[l]).nick!==n&&(r.setNickAndAvatar({nick:n}),u=!0),r.avatar!==s&&(r.setNickAndAvatar({avatar:s}),u=!0),u&&(c+=1));Be.l("".concat(this._n,".modifyMsgSentByPeer convID:").concat(t," count:").concat(c))}}}},{key:"modifyMsgSentByMe",value:function(e){var t=e.conversationID,n=e.latestNick,s=e.latestAvatar,i=this._map.get(t);if(!st(i)){var a=Array.from(i.values()),o=a.length;if(0!==o){for(var r=null,c=0,u=!1,l=o-1;l>=0;l--)"out"===a[l].flow&&((r=a[l]).nick!==n&&(r.setNickAndAvatar({nick:n}),u=!0),r.avatar!==s&&(r.setNickAndAvatar({avatar:s}),u=!0),u&&(c+=1));Be.l("".concat(this._n,".modifyMsgSentByMe convID:").concat(t," count:").concat(c))}}}},{key:"getTopicConvIDList",value:function(e){return I(this._map.keys()).filter((function(t){return t.startsWith("".concat(D.CONV_GROUP).concat(e))}))}},{key:"onMsgModified",value:function(e,t){if(!this._map.has(e)&&!this._hoppingMsgMap.has(e))return{isUpdated:!1,message:null};var n="".concat(this._n,".onMsgModified"),s=this._getUniqueIDOfMsg(t),i=this._getTargetMsg(e,s),a=!!i;if(Be.l("".concat(n," convID:").concat(e," uniqueID:").concat(s," has:").concat(a)),a){var o=t.messageVersion,r=t.elements,c=t.cloudCustomData,u=t.checkResult;return Be.l("".concat(n," localVersion:").concat(i.version," remoteVersion:").concat(o)),i.version<o?(i.version=o,i._elements=JSON.parse(JSON.stringify(r)),i.payload=i._elements[0].content,i.type=i._elements[0].type,i.cloudCustomData=c,i.isModified=!0,i.hasRiskContent=tn(u),{isUpdated:!0,message:i}):{isUpdated:!1,message:i}}return{isUpdated:!1,message:null}}},{key:"_getUniqueIDOfMsg",value:function(e){var t=e.from,n=e.to,s=e.random,i=e.sequence,a=e.time;return"".concat(t,"-").concat(n,"-").concat(s,"-").concat(i,"-").concat(a)}},{key:"_getTargetMsg",value:function(e,t){if(this._map.has(e))return this._map.get(e).get(t);var n=void 0;if(this._hoppingMsgMap.has(e))for(var s=I(this._hoppingMsgMap.get(e).values()),i=0;i<s.length;i++)if(this._getUniqueIDOfMsg(s[i])===t){n=s[i];break}return n}},{key:"storeHoppingMsgList",value:function(e){if(0!==e.length){var t=e[0].conversationID,n=e.length;this._hoppingMsgMap.has(t)||this._hoppingMsgMap.set(t,new Map);for(var s=this._hoppingMsgMap.get(t),i=0;i<n;i++){var a=e[i];s.has(a.ID)||s.set(a.ID,a)}}}},{key:"getHoppingMsg",value:function(e,t){if(this._hoppingMsgMap.has(e))return this._hoppingMsgMap.get(e).get(t)}},{key:"findMsgBySeq",value:function(e,t){var n=[];return this._map.has(e)&&n.push.apply(n,I(this._map.get(e).values())),this._hoppingMsgMap.has(e)&&n.push.apply(n,I(this._hoppingMsgMap.get(e).values())),n.find((function(e){return e.sequence===t}))}},{key:"reset",value:function(){this._map.clear(),this._latestMsgSentByPeerMap.clear(),this._latestMsgSentByMeMap.clear(),this._hoppingMsgMap.clear()}}]);function Ii(e){this.mixin(e)}Ii.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 Mi=["jpg","jpeg","gif","png","bmp","image","webp"],Ci=["mp4","quicktime","mov","video"],Ti=1,Si=2,Ei=3,ki=255,Di=r((function e(t){var n=this;i(this,e),st(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||D.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||D.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],st(t.profileCustomField)||t.profileCustomField.forEach((function(e){n.profileCustomField.push({key:e.key,value:e.value})})))}),[{key:"validate",value:function(e){var t=!0,n="";if(st(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var s=e.profileCustomField.length,i=null,a=0;a<s;a++){if(i=e.profileCustomField[a],!ut(i.key)||-1===i.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!ut(i.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if("profileCustomField"===o)continue;if(st(e[o])&&!ut(e[o])&&!ct(e[o])){n="key:"+o+", invalid value:"+e[o],t=!1;continue}switch(o){case"nick":ut(e[o])||(n="nick must be a string",t=!1),Ct(e[o])>500&&(n="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(Ct(e[o])," bytes"),t=!1);break;case"gender":kt(Je,e.gender)||(n="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":ct(e.birthday)||(n="birthday must be a number",t=!1);break;case"location":ut(e.location)||(n="location must be a string",t=!1);break;case"selfSignature":ut(e.selfSignature)||(n="selfSignature must be a string",t=!1);break;case"allowType":kt(Ze,e.allowType)||(n="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":ct(e.language)||(n="language must be a number",t=!1);break;case"avatar":ut(e.avatar)||(n="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(n="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":kt(Xe,e.adminForbidType)||(n="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":ct(e.level)||(n="level must be a number",t=!1);break;case"role":ct(e.role)||(n="role must be a number",t=!1);break;default:n="unknown key:"+o+" "+e[o],t=!1}}return{valid:t,tips:n}}}]),Oi=r((function e(t){i(this,e),this.MAX_LENGTH=t,this.map=new Map}),[{key:"set",value:function(e){if(this.map.size>=this.MAX_LENGTH){var t=this.map.entries().next().value[0];this.map.delete(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:"reset",value:function(){this.map.clear()}}]),Ri=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"],Ai=r((function e(t){i(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.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(t)}),[{key:"memberNum",get:function(){return this.memberCount},set:function(e){}},{key:"maxMemberNum",get:function(){return this.maxMemberCount},set:function(e){}},{key:"_initGroup",value:function(e){for(var t in e)Ri.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}},{key:"updateGroup",value:function(e){var t=this;e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);var n=JSON.parse(JSON.stringify(e));n.lastMsgTime&&(this.lastMessage.lastTime=n.lastMsgTime),gt(n.muteAllMembers)||("On"===n.muteAllMembers?n.muteAllMembers=!0:n.muteAllMembers=!1),n.groupCustomField&&Rt(this.groupCustomField,n.groupCustomField),gt(n.memberNum)||(this.memberCount=n.memberNum),gt(n.maxMemberNum)||(this.maxMemberCount=n.maxMemberNum),gt(n.isSupportTopic)||(this.isSupportTopic=ct(n.isSupportTopic)?1===n.isSupportTopic:n.isSupportTopic),It(this,n,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),ht(n.members)&&n.members.length>0&&n.members.forEach((function(e){e.userID===t.selfInfo.userID&&It(t.selfInfo,e,["sequence"])}))}},{key:"updateSelfInfo",value:function(e){var t={nameCard:e.nameCard,joinTime:e.joinTime,role:e.role,messageRemindType:e.messageRemindType,readedSequence:e.readedSequence,excludedUnreadSequenceList:e.excludedUnreadSequenceList};It(this.selfInfo,_({},t),[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),Ni=function(e,t,n){return gt(e)?{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:n&&e.ID||e instanceof ri?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:$t(e.type,e.payload,t),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1,revoker:e.revoker||null}:_(_({},e),{},{messageForShow:$t(e.type,e.payload,t)})},Li=r((function e(t,n){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=Ni(t.lastMessage,n,s),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this.groupAtInfoList=[],this.remark=t.remark||"",this.isPinned=t.isPinned||!1,this.messageRemindType=t.messageRemindType,this.markList=t.markList||[],this.customData=t.customData||"",this.conversationGroupList=t.conversationGroupList||[],this.draftText=t.draftText||"",this._initProfile(t),this.subType=this.groupProfile?this.groupProfile.type:""}),[{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:"_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}})),gt(this.userProfile)&&this.type===D.CONV_C2C?this.userProfile=new Di({userID:e.conversationID.replace("C2C","")}):gt(this.groupProfile)&&this.type===D.CONV_GROUP&&(this.groupProfile=new Ai({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,n=e.isFromGetConversations,s=e.isUnreadC2CMessage;gt(t)||(Nt(this.subType)?this.unreadCount=0:n&&this.type===D.CONV_GROUP||n&&this.type===D.CONV_TOPIC||s&&this.type===D.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=Ni(e)}},{key:"updateGroupAtInfoList",value:function(e){if(!this._isNeedMergeGroupAtInfo(e)){var n,s=(t(n=e.groupAtType)||g(n)||T(n)||p()).slice(0);-1!==s.indexOf(D.CONV_AT_ME)&&-1!==s.indexOf(D.CONV_AT_ALL)&&(s=[D.CONV_AT_ALL_AT_ME]);var i={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:s,__random:e.__random,__sequence:e.__sequence};this.groupAtInfoList.push(i)}}},{key:"_isNeedMergeGroupAtInfo",value:function(e){var t=e.groupID,n=e.sequence;if(!Lt({groupID:t}))return!1;var s=!1;return this.groupAtInfoList.forEach((function(t){t.messageSequence===n&&(t.atTypeArray.indexOf(D.CONV_AT_ME)>-1&&e.groupAtType.indexOf(D.CONV_AT_ALL)>-1&&(t.atTypeArray=[D.CONV_AT_ALL_AT_ME]),t.atTypeArray.indexOf(D.CONV_AT_ALL)>-1&&e.groupAtType.indexOf(D.CONV_AT_ME)>-1&&(t.atTypeArray=[D.CONV_AT_ALL_AT_ME],t.__random=e.__random,t.__sequence=e.__sequence),s=!0)})),s}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}},{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:"setLastMessageRevoker",value:function(e){this.lastMessage.revoker=e}},{key:"setDraftText",value:function(e){this.draftText=e}}]),Ui=u(u(u({},D.MSG_REMIND_ACPT_AND_NOTE,0),D.MSG_REMIND_DISCARD,1),D.MSG_REMIND_ACPT_NOT_NOTE,2),Pi=r((function e(t){i(this,e),this._convM=t,this._n="MsgRemindHandler"}),[{key:"onAllRcvMsgOptNotify",value:function(e){var t=this._handleResult(e);this._convM.emitOEvt(k.ALL_RECEIVE_MESSAGE_OPT_UPDATED,t)}},{key:"getC2CMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".getC2CMsgRemindType");return this._convM.req({P:Cs.GET_C2C_PEER_MUTE_NOTIFICATIONS,data:{toAccount:this._convM.getMyUserID(),userIDList:e}}).then((function(s){Be.l("".concat(n," ok. userIDList:").concat(e));var i=s.data.muteFlagList;t._convM.onC2CMsgRemindTypeFetched(i)})).catch((function(e){Be.e("".concat(n," failed. error:"),e)}))}},{key:"set",value:function(e){return e.groupID?this._setGroupMsgRemindType(e):ht(e.userIDList)?this._setC2CMsgRemindType(e):void 0}},{key:"_setGroupMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".").concat("_setGroupMsgRemindType"),s=e.groupID,i=e.messageRemindType,a="groupID:".concat(s," messageRemindType:").concat(i),o=new Gs("_setGroupMsgRemindType");o.setMessage(a);var r=this._get(Hn);return r?r.modifyGroupMemberInfo({groupID:s,messageRemindType:i,userID:this._convM.getMyUserID()}).then((function(){o.end(),Be.l("".concat(n," ok. ").concat(a));var s=t.onGroupMsgRemindTypeUpdated(e);return t._convM.onTotalUnreadCountUpdate(),ps(s)})).catch((function(e){return o.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)})):Is({code:_s.NO_MODULE})}},{key:"onGroupMsgRemindTypeUpdated",value:function(e){var t=e.groupID,n=e.messageRemindType;Be.l("".concat(this._n,".onGroupMsgRemindTypeUpdated groupID:").concat(t," messageRemindType:").concat(n));var s=this._get(Hn).getLocalGroupProfile(t);if(s&&(s.selfInfo.messageRemindType=n),Ut(t)){var i=t,a=zt(i),o=this._get(Bn).getLocalTopic(a,i);return o&&o.updateSelfInfo({messageRemindType:n})&&this._convM.emitOEvt(k.TOPIC_UPDATED,{groupID:a,topic:o}),{topic:o}}return this._convM.patchMsgRemindType({ID:t,isC2CConversation:!1,messageRemindType:n})&&this._emitConvUpdate(),{group:s}}},{key:"_setC2CMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".").concat("_setC2CMsgRemindType"),s=e.userIDList,i=e.messageRemindType,a=s.slice(0,30),o=Ui[i]||0,r="userIDList:".concat(a," messageRemindType:").concat(i),c=new Gs("_setC2CMsgRemindType");return c.setMessage(r),this._convM.req({P:Cs.SET_C2C_PEER_MUTE_NOTIFICATIONS,data:{userIDList:a,muteFlag:o}}).then((function(e){c.end();var s=e.data.errorList,o=[],u=[];ht(s)&&s.forEach((function(e){o.push(e.userID),u.push({userID:e.userID,code:e.errorCode})}));var l=a.filter((function(e){return-1===o.indexOf(e)}));Be.l("".concat(n," ok. ").concat(r," successUserIDList:").concat(l," failureUserIDList:").concat(JSON.stringify(u)));var d=0;return l.forEach((function(e){t._convM.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(d+=1)})),d>=1&&t._emitConvUpdate(),a.length=o.length=0,t._convM.onTotalUnreadCountUpdate(),ys({successUserIDList:l.map((function(e){return{userID:e}})),failureUserIDList:u})})).catch((function(e){return c.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"_get",value:function(e){return this._convM.get(e)}},{key:"_emitConvUpdate",value:function(){this._convM.emitConvUpdate(!0,!1)}},{key:"setAllRcvMsgOpt",value:function(e){var t="".concat(this._n,".").concat("setAllRcvMsgOpt"),n=e.messageRemindType,s=void 0===n?D.MSG_REMIND_ACPT_NOT_NOTE:n,i=e.isRepeated,a=void 0===i||i,o=this._calcStartAndEndTime(e),r=o.startTime,c=void 0===r?0:r,u=o.endTime,l=void 0===u?0:u,d=JSON.stringify(e),h=new Gs("setAllRcvMsgOpt");return h.setMessage(d),Be.l("".concat(t," options:").concat(d)),this._convM.req({P:Cs.SET_ALL_RECEIVE_MSG_OPT,data:{messageRemindType:Ui[s],startTime:c,endTime:l,isRepeated:a?1:0}}).then((function(e){return h.end(),Be.l("".concat(t," ok.")),ps(e)})).catch((function(e){return h.setError(e).end(),Be.e("".concat(t," failed. error:"),e),Is(e)}))}},{key:"_calcStartAndEndTime",value:function(e){var t=e.startHour,n=void 0===t?0:t,s=e.startMinute,i=void 0===s?0:s,a=e.startSecond,o=void 0===a?0:a,r=e.duration,c=void 0===r?0:r,u=e.isRepeated,l=void 0===u||u,d=new Date,h=d.getFullYear(),g=d.getMonth(),p=d.getDate(),f=Math.round(new Date(h,g,p,n,i,o).getTime()/1e3),_=f+c;return l&&c>=86400&&(_=f+86400),{startTime:f,endTime:_}}},{key:"getAllRcvMsgOpt",value:function(){var e=this,t="".concat(this._n,".").concat("getAllRcvMsgOpt"),n=new Gs("getAllRcvMsgOpt");return this._convM.req({P:Cs.GET_ALL_RECEIVE_MSG_OPT,data:{toAccount:this._convM.getMyUserID()}}).then((function(s){var i=s.data;n.setMessage(JSON.stringify(i)).end(),Be.l("".concat(t," ok. data:").concat(JSON.stringify(i)));var a=e._handleResult(i);return ps(a)})).catch((function(e){return n.setError(e).end(),Be.e("".concat(t," failed. error:"),e),Is(e)}))}},{key:"_handleResult",value:function(e){var t=e.messageRemindType,n=e.startTime,s=e.endTime,i=e.isRepeated,a=D.MSG_REMIND_ACPT_AND_NOTE;return 1===t&&(a=D.MSG_REMIND_DISCARD),2===t&&(a=D.MSG_REMIND_ACPT_NOT_NOTE),{messageRemindType:a,startTime:n,endTime:s,isRepeated:1===i}}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}]),wi=r((function e(t){i(this,e),this._convM=t,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=cn}),[{key:"setConvCustomData",value:function(e){var t=this,n="".concat(this._n,".").concat("setConvCustomData"),s=e.conversationIDList,i=e.customData;Be.l("".concat(n," options:"),e);var a=new Gs("setConvCustomData");a.setMessage(JSON.stringify(e));var o={fromAccount:this._getMyUserID(),itemList:[]},r=[],c=[];return s.forEach((function(e){if(!t._hasLocalConv(e))return t._onConvNotFound(c,e),!0;if(!Pt(e)&&!wt(e))return t._onConvIDInvalid(c,e),!0;var n={operationType:2,contactItem:void 0,customMark:i};Pt(e)?n.contactItem={type:1,toAccount:e.replace(D.CONV_C2C,"")}:wt(e)&&(n.contactItem={type:2,groupID:e.replace(D.CONV_GROUP,"")}),o.itemList.push(n)})),c.length===s.length?ys({successConversationIDList:r,failureConversationIDList:c}):this._convM.req({P:Cs.SET_CONV_CUSTOM_DATA,data:o}).then((function(e){a.end(),Be.l("".concat(n," ok"));var s=e.data.resultItem;if(ht(s)){var o,u,l=!1;s.forEach((function(e){o=t._concatConvID(e.contactItem),0===e.resultCode?(r.push(o),(u=t._getLocalConv(o))&&u.customData!==i&&(u.customData=i,l=!0)):c.push({conversationID:o,code:e.resultCode,message:e.resultInfo})})),!0===l&&t._emitConvUpdate()}return ps({successConversationIDList:r,failureConversationIDList:c})})).catch((function(e){return a.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"markConv",value:function(e){var t=this;if(!this._convM.canIUse(j.CONV_MARK))return this._convM.noUse("markConv");var n="".concat(this._n,".").concat("markConv"),s=e.conversationIDList,i=e.markType,a=e.enableMark;Be.l("".concat(n," options:"),e);var o=new Gs("markConv");o.setMessage(JSON.stringify(e));var r=void 0,c=void 0,u=this._getFlagBit(i);!0===a?c=[u]:r=[u];var l={fromAccount:this._getMyUserID(),itemList:[]},d=[],h=[];return s.forEach((function(e){if(!t._hasLocalConv(e))return t._onConvNotFound(h,e),!0;if(!Pt(e)&&!wt(e))return t._onConvIDInvalid(h,e),!0;var n={operationType:1,contactItem:void 0,clearMark:r,setMark:c};Pt(e)?n.contactItem={type:1,toAccount:e.replace(D.CONV_C2C,"")}:wt(e)&&(n.contactItem={type:2,groupID:e.replace(D.CONV_GROUP,"")}),l.itemList.push(n)})),h.length===s.length?ys({successConversationIDList:d,failureConversationIDList:h}):this._convM.req({P:Cs.MARK_CONV,data:l}).then((function(e){o.end(),Be.l("".concat(n," ok"));var s=e.data.resultItem;if(ht(s)){var r,c,u=!1;s.forEach((function(e){if(r=t._concatConvID(e.contactItem),0===e.resultCode){if(d.push(r),c=t._getLocalConv(r)){var n=c.markList.indexOf(i);!0===a?-1===n&&(c.markList.push(i),u=!0):-1!==n&&(c.markList.splice(n,1),u=!0)}}else h.push({conversationID:r,code:e.resultCode,message:e.resultInfo})})),!0===u&&t._emitConvUpdate()}return ps({successConversationIDList:d,failureConversationIDList:h})})).catch((function(e){return o.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"getLocalConvGroupList",value:function(){var e=this;return Be.l("".concat(this._n,".getLocalConvGroupList pagingStatus:").concat(this._pagingStatus)),this._pagingStatus===dn?this.getRemoteConvGroupList().then((function(){return ps(I(e._convGroupMap.values()))})):ys(I(this._convGroupMap.values()))}},{key:"searchConvGroupAndMark",value:function(e,t){var n=this,s="".concat(this._n,".searchConvGroupAndMark"),i=[];return e.forEach((function(e){1===t?i.push({type:1,toAccount:e}):2===t&&i.push({type:2,groupID:e})})),Be.l("".concat(s," type:").concat(t," list:"),e),this._convM.req({P:Cs.SEARCH_CONV_GRP_MARK,data:{fromAccount:this._getMyUserID(),contactItem:i}}).then((function(e){var t=e.data,i=t.contactItem,a=t.groupItem;Be.l("".concat(s," ok. contactItem:"),i,"groupItem:",a),n._fillConvGroupMap(a),n._handleContactItem(i),n._emitConvUpdate()})).catch((function(e){Be.w("".concat(s," failed. error:"),e)}))}},{key:"_fillConvGroupMap",value:function(e){var t=this;ht(e)&&e.forEach((function(e){var n=e.convGroupID,s=e.groupName;t._convGroupMap.set(n,s)}))}},{key:"_handleContactItem",value:function(e){var t,n,s=this;ht(e)&&e.forEach((function(e){var i=[],a=e.standardMark,o=e.customData,r=e.convGroupIDList;ht(r)&&r.forEach((function(e){s._convGroupMap.has(e)&&i.push(s._convGroupMap.get(e))})),n=s._concatConvID(e),(t=s._getLocalConv(n))&&(t.markList=Jt(a),t.customData=o||"",t.conversationGroupList=[].concat(i))}))}},{key:"getRemoteConvGroupList",value:function(){var e=this,t="".concat(this._n,".getRemoteConvGroupList");return this._pagingStatus=un,this._convM.req({P:Cs.GET_CONV_GRP_LIST,data:{fromAccount:this._getMyUserID(),startIndex:this._startIndex}}).then((function(n){var s=n.data,i=s.completeFlag,a=s.contactItem,o=s.nextStartIndex,r=void 0===o?0:o,c=s.groupItem;if(e._startIndex=r,Be.l("".concat(t," completeFlag:").concat(i," nextStartIndex:").concat(r,", groupItem:"),c,"contactItem:",a),e._fillConvGroupMap(c),e._handleContactItem(a),0===i)return e.getRemoteConvGroupList();1===i&&(e._pagingStatus=ln,e._emitConvUpdate(),e._emitConvGroupListUpdate())})).catch((function(n){e._pagingStatus=dn,Be.w("".concat(t," failed. error:"),n)}))}},{key:"createConvGroup",value:function(e){var t=this;if(!this._convM.canIUse(j.CONV_GROUP))return this._convM.noUse("createConvGroup");var n="".concat(this._n,".").concat("createConvGroup");Be.l("".concat(n," options:"),e);var s=new Gs("createConvGroup");s.setMessage(JSON.stringify(e));var i=e.groupName,a=e.conversationIDList,o={fromAccount:this._getMyUserID(),itemList:[{groupName:i,contactItem:[]}]},r=[],c=[];return a.forEach((function(e){return t._hasLocalConv(e)?Pt(e)||wt(e)?void(Pt(e)?o.itemList[0].contactItem.push({type:1,toAccount:e.replace(D.CONV_C2C,"")}):wt(e)&&o.itemList[0].contactItem.push({type:2,groupID:e.replace(D.CONV_GROUP,"")})):(t._onConvIDInvalid(c,e),!0):(t._onConvNotFound(c,e),!0)})),c.length===a.length?ys({successConversationIDList:r,failureConversationIDList:c}):this._convM.req({P:Cs.CREATE_CONV_GRP,data:o}).then((function(e){s.end(),Be.l("".concat(n," ok"));var a=e.data.groupResultItem[0],o=a.groupItem,u=a.resultItem;if(dt(o)&&(t._convGroupMap.set(o.convGroupID,o.groupName),t._emitConvGroupListUpdate()),ht(u)){var l,d,h=!1;u.forEach((function(e){l=t._concatConvID(e.contactItem),0===e.resultCode?(r.push(l),(d=t._getLocalConv(l))&&-1===d.conversationGroupList.indexOf(i)&&(d.conversationGroupList.push(i),h=!0)):c.push({conversationID:l,code:e.resultCode,message:e.resultInfo})})),!0===h&&(t._emitConvUpdate(),t._emitConvGroupListUpdate())}return ps({successConversationIDList:r,failureConversationIDList:c})})).catch((function(e){return s.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"deleteConvGroup",value:function(e){var t=this;if(!this._convM.canIUse(j.CONV_GROUP))return this._convM.noUse("deleteConvGroup");var n="".concat(this._n,".").concat("deleteConvGroup");Be.l("".concat(n," groupName:").concat(e));var s=new Gs("deleteConvGroup");return s.setMessage(e),this._convM.req({P:Cs.DEL_CONV_GRP,data:{fromAccount:this._getMyUserID(),groupName:[e]}}).then((function(i){s.end(),Be.l("".concat(n," ok"));var a=i.data.groupItem;if(ht(a)){var o=!1;a.forEach((function(e){t._convGroupMap.has(e.convGroupID)&&(t._convGroupMap.delete(e.convGroupID),o=!0)})),!0===o&&t._emitConvGroupListUpdate()}t._eraseFromConversationGroupList([e])})).catch((function(e){return s.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"renameConvGroup",value:function(e){var t=this;if(!this._convM.canIUse(j.CONV_GROUP))return this._convM.noUse("renameConvGroup");var n="".concat(this._n,".").concat("renameConvGroup");Be.l("".concat(n," options:"),e);var s=new Gs("renameConvGroup");s.setMessage(JSON.stringify(e));var i=e.oldName,a=e.newName;return this._convM.req({P:Cs.RENAME_CONV_GRP,data:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:i,newName:a}}}).then((function(e){s.end(),Be.l("".concat(n," ok"));var o=e.data.updateGroupResult.convGroupID;t._convGroupMap.set(o,a),t._emitConvGroupListUpdate();var r,c,u=t._convM.getLocalConvList(),l=!1;u.forEach((function(e){r=e.conversationGroupList,-1!==(c=r.indexOf(i))&&(r.splice(c,1,a),l=!0)})),!0===l&&t._emitConvUpdate()})).catch((function(e){return s.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"addConvsToGroup",value:function(e){var t=this;if(!this._convM.canIUse(j.CONV_GROUP))return this._convM.noUse("addConvsToGroup");var n="".concat(this._n,".").concat("addConvsToGroup");Be.l("".concat(n," options:"),e);var s=new Gs("addConvsToGroup");s.setMessage(JSON.stringify(e));var i=e.conversationIDList,a=e.groupName,o={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:a,updateItem:[]}},r=[],c=[];return i.forEach((function(e){return t._hasLocalConv(e)?Pt(e)||wt(e)?void(Pt(e)?o.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(D.CONV_C2C,"")}}):wt(e)&&o.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(D.CONV_GROUP,"")}})):(t._onConvIDInvalid(c,e),!0):(t._onConvNotFound(c,e),!0)})),c.length===i.length?ys({successConversationIDList:r,failureConversationIDList:c}):this._convM.req({P:Cs.ADD_CONV_TO_GRP,data:o}).then((function(e){s.end(),Be.l("".concat(n," ok"));var i=e.data.updateGroupResult.contactResultItem;if(ht(i)){var o,u,l=!1;i.forEach((function(e){o=t._concatConvID(e.contactItem),0===e.resultCode?(u=t._getLocalConv(o))&&-1===u.conversationGroupList.indexOf(a)&&(u.conversationGroupList.push(a),r.push(o),l=!0):c.push({conversationID:o,code:e.resultCode,message:e.resultInfo})})),!0===l&&(t._emitConvUpdate(),t._emitConvInGroupUpdate(a))}return ps({successConversationIDList:r,failureConversationIDList:c})})).catch((function(e){return s.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"deleteConvsFromGroup",value:function(e){var t=this,n="deleteConvsFromGroup";if(!this._convM.canIUse(j.CONV_GROUP))return this._convM.noUse(n);var s="".concat(this._n,".").concat(n);Be.l("".concat(s," options:"),e);var i=new Gs(n);i.setMessage(JSON.stringify(e));var a=e.conversationIDList,o=e.groupName,r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:o,updateItem:[]}},c=[],u=[];return a.forEach((function(e){return t._hasLocalConv(e)?Pt(e)||wt(e)?void(Pt(e)?r.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(D.CONV_C2C,"")}}):wt(e)&&r.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(D.CONV_GROUP,"")}})):(t._onConvIDInvalid(u,e),!0):(t._onConvNotFound(u,e),!0)})),u.length===a.length?ys({successConversationIDList:c,failureConversationIDList:u}):this._convM.req({P:Cs.DEL_CONV_FROM_GRP,data:r}).then((function(e){i.end(),Be.l("".concat(s," ok"));var n=e.data.updateGroupResult.contactResultItem;if(ht(n)){var a,r,l=!1;n.forEach((function(e){if(a=t._concatConvID(e.contactItem),0===e.resultCode){if(r=t._getLocalConv(a)){var n=r.conversationGroupList.indexOf(o);-1!==n&&(r.conversationGroupList.splice(n,1),c.push(a),l=!0)}}else u.push({conversationID:a,code:e.resultCode,message:e.resultInfo})})),!0===l&&(t._emitConvUpdate(),t._emitConvInGroupUpdate(o))}return ps({successConversationIDList:c,failureConversationIDList:u})})).catch((function(e){return i.setError(e).end(),Be.e("".concat(s," failed. error:"),e),Is(e)}))}},{key:"onConvMarkUpdated",value:function(e){var t=this;if(!st(e)){var n,s;Be.l("".concat(this._n,".onConvMarkUpdated markItemList:"),e);var i=!1;e.forEach((function(e){var a=e.recentContactItem,o=e.optType,r=e.standardMark,c=e.customMark;if(n=t._concatConvID(a),s=t._getLocalConv(n))if(1===o)i=t._diffStandardMark(s,r);else if(2===o)i=t._diffCustomMark(s,c);else if(3===o){var u=t._diffStandardMark(s,r),l=t._diffCustomMark(s,c);i=u||l}})),!0===i&&this._emitConvUpdate()}}},{key:"_diffStandardMark",value:function(e,t){var n=Jt(t),s=!1;return!0!==function(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(var n=0,s=e.length;n<s;n++)if(e[n]!==t[n])return!1;return!0}(e.markList,n)&&(e.markList=n,s=!0),s}},{key:"_diffCustomMark",value:function(e,t){var n=!1;return e.customData!==t&&void 0!==t&&(e.customData=t,n=!0),n}},{key:"onConvGroupCreated",value:function(e){var t=this;Be.l("".concat(this._n,".onConvGroupCreated resultList:"),e);var n=!1,s=!1;ht(e)&&(e.forEach((function(e){var i=e.msgGroupItem,a=i.groupID,o=i.groupName;t._convGroupMap.get(a)!==o&&(t._convGroupMap.set(a,o),s=!0);var r,c,u=e.msgRecentContactItem;ht(u)&&u.forEach((function(e){r=t._concatConvID(e),(c=t._getLocalConv(r))&&-1===c.conversationGroupList.indexOf(o)&&(c.conversationGroupList.push(o),n=!0)}))})),!0===n&&this._emitConvUpdate(),!0===s&&this._emitConvGroupListUpdate())}},{key:"onConvGroupDeleted",value:function(e){var t=this;Be.l("".concat(this._n,".onConvGroupDeleted groupItemList:"),e);var n=[];if(ht(e)){var s=!1;e.forEach((function(e){var i=e.groupID,a=e.groupName;t._convGroupMap.has(i)&&(t._convGroupMap.delete(i),s=!0,n.push(a))})),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(n)}},{key:"_eraseFromConversationGroupList",value:function(e){st(e)||(this._convM.getLocalConvList().forEach((function(t){t.conversationGroupList=t.conversationGroupList.filter((function(t){return!e.includes(t)}))})),this._emitConvUpdate())}},{key:"onConvGroupNameUpdated",value:function(e){Be.l("".concat(this._n,".onConvGroupNameUpdated options:"),e);var t=e.groupID,n=e.groupName,s=e.oldGroupName;if(this._convGroupMap.get(t)!==n){this._convGroupMap.set(t,n),this._emitConvGroupListUpdate();var i,a,o=this._convM.getLocalConvList(),r=!1;o.forEach((function(e){i=e.conversationGroupList,-1!==(a=i.indexOf(s))&&(i.splice(a,1,n),r=!0)})),!0===r&&this._emitConvUpdate()}}},{key:"onConvInGroupUpdated",value:function(e){var t=this;Be.l("".concat(this._n,".onConvInGroupUpdated options:"),e);var n=e.oldGroupName,s=e.recentContactUpdateGroupItem;if(ht(s)){var i,a,o,r=!1;s.forEach((function(e){var s=e.contactOptType,c=e.recentContactItem;i=t._concatConvID(c),(a=t._getLocalConv(i))&&(o=a.conversationGroupList.indexOf(n),1===s?-1===o&&(a.conversationGroupList.push(n),r=!0):2===s&&-1!==o&&(a.conversationGroupList.splice(o,1),r=!0))})),!0===r&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(n))}}},{key:"onConvAddedToOrDeletedFromGroup",value:function(e){var t=this;Be.l("".concat(this._n,".onConvAddedToOrDeletedFromGroup options:"),e);var n=e.msgRecentContactItem,s=e.msgRecentContactUpdateContactItem,i=this._concatConvID(n),a=this._getLocalConv(i);if(a&&ht(s)){var o,r=!1;s.forEach((function(e){var n=e.groupOptType,s=e.recentContactGroupItem.groupName;o=a.conversationGroupList.indexOf(s),1===n?-1===o&&(a.conversationGroupList.push(s),r=!0):2===n&&-1!==o&&(a.conversationGroupList.splice(o,1),r=!0),!0===r&&t._emitConvInGroupUpdate(s)})),!0===r&&this._emitConvUpdate()}}},{key:"onConvGroupListSynced",value:function(e){ht(e)&&0!==e.length&&(Be.l("".concat(this._n,".onConvGroupListSynced groupItem:"),e),this._fillConvGroupMap(e))}},{key:"getConvGroupListByID",value:function(e){var t=this;if(!st(e)){var n=[];return e.forEach((function(e){t._convGroupMap.has(e)&&n.push(t._convGroupMap.get(e))})),n}}},{key:"_onConvNotFound",value:function(e,t){e.push({conversationID:t,code:_s.CONV_NOT_FOUND,message:this._convM.getErrMsg(_s.CONV_NOT_FOUND)})}},{key:"_onConvIDInvalid",value:function(e,t){e.push({conversationID:t,code:_s.INVALID_CONV_ID,message:this._convM.getErrMsg(_s.INVALID_CONV_ID)})}},{key:"_getFlagBit",value:function(e){for(var t=e.toString(2),n=t.length,s=n-1;s>=0;s--)if("1"===t[s])return n-s-1}},{key:"_concatConvID",value:function(e){var t,n=e.type,s=e.to,i=e.groupID,a=e.userID;return 1===n?gt(a)?gt(s)||(t="".concat(D.CONV_C2C).concat(s)):t="".concat(D.CONV_C2C).concat(a):2===n&&(t="".concat(D.CONV_GROUP).concat(i)),t}},{key:"_getMyUserID",value:function(){return this._convM.getMyUserID()}},{key:"_getLocalConv",value:function(e){return this._convM.getLocalConversation(e)}},{key:"_hasLocalConv",value:function(e){return this._convM.hasLocalConversation(e)}},{key:"_emitConvUpdate",value:function(){this._convM.emitConvUpdate(!0,!1)}},{key:"_emitConvGroupListUpdate",value:function(){this._convM.emitOEvt(k.CONVERSATION_GROUP_LIST_UPDATED,I(this._convGroupMap.values()))}},{key:"_emitConvInGroupUpdate",value:function(e){var t={groupName:e,conversationList:[]},n=this._convM.getLocalConvList();t.conversationList=n.filter((function(t){return t.conversationGroupList.includes(e)})),this._convM.emitOEvt(k.CONVERSATION_IN_GROUP_UPDATED,t)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=cn}}]),bi=r((function e(t){i(this,e);var n=t.eventType,s=t.index,a=t.markdown,o=t.isLast,r=t.binaryData;this.eventType=n,this.index=s,this.markdown=a,this.isLast=o,this.binaryData=r})),Gi=r((function e(t){i(this,e),this._n="StreamMessageHandler",this._convM=t,this._messageMap=new Map,this._retryCountMap=new Map}),[{key:"getStreamMessageInHistory",value:function(e){var t=this;e.length>0&&e.forEach((function(e){if(e.type===D.MSG_STREAM){var n=e._elements[0],s=n.content||{},i=s.streamMessageID,a=s.markdown,o=s.binaryData;i&&(Be.l("".concat(t._n,".getStreamMessageInHistory streamMessageID:").concat(i," markdown.length:").concat(a.length)),st(a)&&st(o)?(t._messageMap.set(i,e),t._getStreamMessage(e)):n.content.isStreamEnded=!0)}}))}},{key:"onPushedChunks",value:function(e){var t=e.chunks,n=e.streamMessageID,s=e.stopReason,i=this._messageMap.get(n);if(i&&t&&0!==t.length){var a=i._elements[0];if(this._containsExpectedChunk(a,t)){var o=t.map((function(e){return new bi(e)}));a.updateChunks(o),i.payload=_({},a.content),this._convM.emitOEvt(k.MESSAGE_MODIFIED,[i]),this._sendAck(n,a.getLastIndex());var r=i.conversationID,c=i.sequence,u=this._convM.getLocalConversation(r);if(u){var l=u.lastMessage;l.lastSequence===c&&a.content.isStreamEnded&&(Be.l("".concat(this._n,".onPushedChunks convID:").concat(r," lastMessage updated. sequence:").concat(c)),l.type=a.type,l.payload=_({},a.content),l.messageForShow=l.payload.markdown,this._convM.emitConvUpdate(!0,!1))}a.content.isStreamEnded&&(this._messageMap.delete(n),a.stopReason=s||!ii)}}}},{key:"_sendAck",value:function(e,t){this._convM.req({P:Cs.STREAM_CHUNK_ACK,data:{streamMessageID:e,ackIndex:t}})}},{key:"_containsExpectedChunk",value:function(e,t){for(var n=e.getLastIndex()+1,s=!1,i=0;i<t.length;i++)if(t[i].index===n){s=!0;break}return s}},{key:"getStreamMessageBeforeEmit",value:function(e){var t=this;e.length>0&&e.forEach((function(e){if(e.type===D.MSG_STREAM){var n=e._elements[0].content||{},s=n.streamMessageID,i=n.isStreamEnded;Be.l("".concat(t._n,".getStreamMessageBeforeEmit streamMessageID:").concat(s," isStreamEnded:").concat(i)),s&&!i&&(t._messageMap.set(s,e),t._getStreamMessage(e))}}))}},{key:"_getStreamMessage",value:function(e){var t=this,n=(e._elements[0].content||{}).streamMessageID,s=e.from,i=e.to;this._convM.req({P:Cs.STREAM_GET_STREAM,data:{streamMessageID:n,from:s,to:i,ackIndex:0}}).then((function(e){Be.l("".concat(t._n,"._getStreamMessage success. streamMessageID:").concat(n))})).catch((function(s){if(Be.l("".concat(t._n,"._getStreamMessage failed. streamMessageID:").concat(n," error:"),s),t._shouldRetry(n)){var i=t._retryCountMap.get(n)||0;t._retryCountMap.set(n,i+1),t._getStreamMessage(e)}}))}},{key:"_shouldRetry",value:function(e){return!this._retryCountMap.has(e)||this._retryCountMap.get(e)<=4}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._messageMap.clear(),this._retryCountMap.clear()}}]),Fi=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="ConvModule",Ii.mixin(s),s._msgListHandler=new yi(s),s._msgRemindHandler=new Pi(s),s._convGroupHandler=new wi(s),s._streamMessageHandler=new Gi(s),s._sll=new Oi(100),s._pagingStatus=cn,s._pagingTs=0,s._pagingStartIdx=0,s._pagingPinnedTs=0,s._pagingPinnedStartIdx=0,s._pagingConvIDMap=new Map,s._convIDFromUnreadDBMap=new Map,s._convMap=new Map,s._tmpGroupList=[],s._tmpGroupAtTipsList=[],s._peerReadTimeMap=new Map,s._completedMap=new Map,s._roamingMsgKeyAndTimeMap=new Map,s._remoteGroupReadSeqMap=new Map,s._convTotalUnreadCount=0,s._pagingGetCostList=[],s._convMapForDiff=new Map,s._partialUpdatedConvMap=new Map,s._everClearedMap=new Map,s._bPullOnInvite=!0,s._initListeners(),s}return d(t,e),r(t,[{key:"_initListeners",value:function(){var e=this.getIEmitInst();e.on(mi.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(mi.PROFILE_UPDATED,this._onProfileUpdated,this),e.on(mi.CLOUD_CONFIG,this._onCloudConfig,this)}},{key:"_init",value:function(){var e=this;Be.l("".concat(this._n,"._init"));var t=this.get(zn).getItem("conversationMap"),n=this.isIntl(),s=this.isUsingChatCore();if(t){for(var i=t.length,a=0;a<i;a++){var o=t[a];if(o){if(this._isNonExistentAccount(o.conversationID))continue;if(o.groupProfile&&Nt(o.groupProfile.type))continue}this._convMap.set(o.conversationID,new Li(t[a],n,s))}this.emitConvUpdate(!0,!1)}this.ready((function(){e._tmpGroupList.length>0&&(e.updateConvGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)})),this.syncConvList()}},{key:"_isNonExistentAccount",value:function(e){var t;return e.startsWith(D.CONV_C2C)&&(t=e.replace(D.CONV_C2C,"")),"@TLS#ERROR"===t||"@TLS#NOT_FOUND"===t}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&this._msgListHandler.onCheckTimer(e)}},{key:"onMessageSent",value:function(e){this._onSendOrRcvMsg({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrRcvMsg(e)}},{key:"_onSendOrRcvMsg",value:function(e){var t=this,n=e.conversationOptionsList,s=e.isInstantMessage,i=void 0===s||s,a=e.isUnreadC2CMessage,o=void 0!==a&&a,r=e.updateUnreadCount,c=void 0===r||r,u=e.isSyncingEnded,l=void 0!==u&&u;this._isReady?0!==n.length?(!0===i&&this._checkNewConv(n),this._updateLocalConvList({conversationOptionsList:n,isInstantMessage:i,isUnreadC2CMessage:o,isFromGetConversations:!1,updateUnreadCount:c}),i||(this._convIDFromUnreadDBMap=new Map([].concat(I(this._convIDFromUnreadDBMap),I(n.map((function(e){return[e.conversationID,1]}))))),this._diffAndDeleteConv(),l&&this.emitIEvt(mi.C2C_UNREAD_HANDLE_COMPLETED)),n.filter((function(e){return!t._isConvNeedShow(e.conversationID)})).length>0||this.emitConvUpdate()):l&&this.emitIEvt(mi.C2C_UNREAD_HANDLE_COMPLETED):this.ready((function(){t._onSendOrRcvMsg(e)}))}},{key:"updateConvGroupProfile",value:function(e){var t=this;if(!ht(e)||0!==e.length)if(0!==this._convMap.size){var n=!1;e.forEach((function(e){var s="".concat(D.CONV_GROUP).concat(e.groupID);if(t._convMap.has(s)){n=!0;var i=t._convMap.get(s);i.groupProfile=JSON.parse(JSON.stringify(e)),i.lastMessage.lastSequence<e.nextMessageSeq&&(i.lastMessage.lastSequence=e.nextMessageSeq-1),i.subType||(i.subType=e.type)}})),n&&this.emitConvUpdate(!0,!1)}else this._tmpGroupList=e}},{key:"onMessageRevoked",value:function(e,t){var n=this;if(0!==e.length){var s=null,i=!1,a=[];e.forEach((function(e){(s=n._convMap.get(e.conversationID))&&(t&&s.reduceUnreadCount()&&(i=s.type!==D.CONV_TOPIC),s.type===D.CONV_TOPIC?a.push(e):s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))}));var o=this.get(Bn);o&&o.onMessageRevoked(a),i&&(this.emitConvUpdate(!0,!1),this._updateGroupLastMessage(e[0]))}}},{key:"_updateGroupLastMessage",value:function(e){var t=e.conversationID;if(t.startsWith(D.CONV_GROUP)){var n=this._convMap.get(t),s=this.get(Hn);s&&s.updateGroupLastMessage([n])}}},{key:"updateRevokerInfo",value:function(e){for(var t=new Set,n=0;n<e.length;n++){var s=e[n].revoker;t.add(s)}var i=I(t),a=this.get(qn);return new Promise((function(t){a.getUserProfile({userIDList:i}).then((function(n){var s=n.data;if(!ht(s)||0===s.length)return t(e);var i,a={},o=c(s);try{for(o.s();!(i=o.n()).done;){var r=i.value,u=r.userID,l=r.nick,d=r.avatar;a[u]={nick:l,avatar:d}}}catch(e){o.e(e)}finally{o.f()}e.forEach((function(e){var t=e.revoker;a[t]&&(e.revokerInfo.nick=a[t].nick||"",e.revokerInfo.avatar=a[t].avatar||"")})),t(e)})).catch((function(){t(e)}))}))}},{key:"isLastMessageRevoked",value:function(e){var t=!1,n=e.conversationID,s=e.sequence,i=e.time,a=this._convMap.get(n);return a&&(t=a.type===D.CONV_TOPIC?this.get(Bn).isLastMessageRevoked({topicID:n.replace(D.CONV_GROUP,""),sequence:s}):a.isLastMessageRevoked({sequence:s,time:i})),Be.l("".concat(this._n,".isLastMessageRevoked options:"),e,"ret:".concat(t)),t}},{key:"onMessageDeleted",value:function(e){var t=this;if(0!==e.length){var n=null;e.forEach((function(e){(n=t._msgListHandler.getLocalMsg(e.conversationID,e.ID))&&(n.isDeleted=!0),e!==n&&(e.isDeleted=!0)}));for(var s=e[0].conversationID,i=this._msgListHandler.getLocalMsgList(s),a={},o=i.length-1;o>=0;o--)if(!i[o].isDeleted){a=i[o];break}var r=this._convMap.get(s);if(r){var c=!1;r.lastMessage.lastSequence===a.sequence&&r.lastMessage.lastTime===a.time||(st(a)&&(a=void 0),r.updateLastMessage(a),r.type!==D.CONV_TOPIC&&(c=!0),Be.l("".concat(this._n,".onMessageDeleted. update convID:").concat(s," with lastMessage:"),r.lastMessage)),s.startsWith(D.CONV_C2C)&&this.updateUnreadCount(s),c&&this.emitConvUpdate(!0,!1)}}}},{key:"onMessageModified",value:function(e){var t="".concat(this._n,".onMessageModified"),n=e.conversationType,s=e.from,i=e.to,a=e.time,o=e.sequence,r=e.elements,c=e.cloudCustomData,u=e.messageVersion,l=this.getMyUserID(),d="".concat(n).concat(i);i===l&&n===D.CONV_C2C&&(d="".concat(n).concat(s));var h=this._msgListHandler.onMsgModified(d,e),g=h.isUpdated,p=h.message;!0===g&&this.emitOEvt(k.MESSAGE_MODIFIED,[p]);var f=this._isTopicConv(d);if(null===p?Be.l("".concat(t," message is null! options:"),e):Be.l("".concat(t," isUpdated:").concat(g," isTopicMessage:").concat(f," from:").concat(s," to:").concat(i," sequence:").concat(p.sequence," time:").concat(p.time)),f)this.get(Bn).onMessageModified(e);else{var _=this._convMap.get(d);if(_){var v=_.lastMessage;v&&v.lastTime===a&&v.lastSequence===o&&v.version!==u&&(Be.l("".concat(t," convID:").concat(d," lastMessage updated")),v.type=r[0].type,v.payload=r[0].content,v.messageForShow=$t(v.type,v.payload,this.isIntl()),v.cloudCustomData=c,v.version=u,this.emitConvUpdate(!0,!1))}}return p}},{key:"onNewGroupAtTips",value:function(e){var t=this,n=e.dataList,s=null;n.forEach((function(e){e.groupAtTips?s=e.groupAtTips:e.elements?s=_(_({},e.elements),{},{sync:!0}):e.groupAtType&&(s=_(_({},e),{},{sync:!0})),s.__random=e.random,s.__sequence=e.clientSequence,t._tmpGroupAtTipsList.push(s)})),Be.l("".concat(this._n,".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 s=n.groupID,i=n.from,a=n.topicID,o=void 0===a?void 0:a,r=n.sync,c=void 0!==r&&r;if(i!==e.getMyUserID())if(gt(o)){var u=e._convMap.get("".concat(D.CONV_GROUP).concat(s));u&&(u.updateGroupAtInfoList(n),t=!0)}else{var l=e._convMap.get("".concat(D.CONV_GROUP).concat(o));l&&(l.updateGroupAtInfoList(n),e.get(Bn).onAtInfoUpdated({topicID:o,groupAtInfoList:l.groupAtInfoList})),st(l)&&c&&(e.updateTopicConversation([{conversationID:"".concat(D.CONV_GROUP).concat(o),type:D.CONV_TOPIC}]),e._convMap.get("".concat(D.CONV_GROUP).concat(o)).updateGroupAtInfoList(n))}})),t&&this.emitConvUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}},{key:"_checkNewConv",value:function(e){var t=this,n=[],s=[];e.forEach((function(e){t._convMap.has(e.conversationID)||(e.type===D.CONV_C2C?n.push(e.conversationID.replace(D.CONV_C2C,"")):e.type===D.CONV_GROUP&&s.push(e.conversationID.replace(D.CONV_GROUP,"")))})),n.length>0&&(this._onNewC2CConv(n),n=null),s.length>0&&(this._onNewGroupConv(s),s=null)}},{key:"_onNewC2CConv",value:function(e){var t=this.get(Kn);return Promise.all([t.getRemotePeerReadTime(e),this._msgRemindHandler.getC2CMsgRemindType(e)])}},{key:"_onNewGroupConv",value:function(e){var t=this.get(Hn);return t?Promise.all([t.getMsgRemindType(e)]):Promise.resolve()}},{key:"_setStorageConvList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getLocalConvList().filter((function(e){return e.type===D.CONV_C2C||e.type===D.CONV_GROUP&&e.lastMessage.type!==D.MSG_GRP_TIP})).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.get(zn).setItem("conversationMap",t,e)}},{key:"emitConvUpdate",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.getLocalConvList();if(t){var s=this.get(Hn);s&&s.updateGroupLastMessage(n)}e&&(this.get(Wn).isPartialUpdatedConvs()?(this._diffConvMap(this._convMapForDiff,this._convMap),this._partialUpdatedConvMap.size>0&&(this.emitOEvt(k.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate(),this._convMapForDiff.clear(),this._convMapForDiff=Mt(this._convMap,!0)),0===this._convMapForDiff.size&&(this._convMapForDiff=Mt(this._convMap,!0))):(this.emitOEvt(k.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate()))}},{key:"_diffConvMap",value:function(e,t){var n,s=c(t);try{for(s.s();!(n=s.n()).done;){var i=y(n.value,2),a=i[0],o=i[1];e.has(a)&&JSON.stringify(o)===e.get(a)||this._partialUpdatedConvMap.set(a,o)}}catch(e){s.e(e)}finally{s.f()}}},{key:"getPartialUpdatedConvs",value:function(){var e=I(Mt(this._partialUpdatedConvMap,!1).values());return this._partialUpdatedConvMap.clear(),e}},{key:"getLocalConvList",value:function(){var e=this;return I(this._convMap.values()).filter((function(t){return e._isConvNeedShow(t.conversationID)}))}},{key:"getLocalConversation",value:function(e){return this._convMap.get(e)}},{key:"hasLocalConversation",value:function(e){return this._convMap.has(e)}},{key:"getLocalOldestMessage",value:function(e){return this._msgListHandler.getLocalOldestMsg(e)}},{key:"syncConvList",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n="syncConvList",s=new Gs(n);return this._pagingStatus===cn&&this._convMap.clear(),this._pagingGetConvList(t).then((function(t){var i=Qt(e._pagingGetCostList),a=Zt(e._pagingGetCostList);e._pagingGetCostList.length=0,e._pagingStatus=ln,e._diffAndDeleteConv(),e.emitConvUpdate(!0,!1),e._setStorageConvList(),e._handleC2CPeerReadTime(),e.emitIEvt(mi.CONV_SYNC_COMPLETED);var o="count:".concat(e._convMap.size," sum:").concat(a," avg:").concat(i);return Be.l("".concat(e._n,".").concat(n,". ").concat(o)),s.setMessage(o).end(),t})).catch((function(t){return e._pagingStatus=dn,s.setMessage(e._pagingTs).setError(t).end(),Is(t)}))}},{key:"_diffAndDeleteConv",value:function(){var e=this;if(this._isSyncCompleted()){var t=[];this._convMap.forEach((function(n,s){!e._pagingConvIDMap.has(s)&&e._convIDFromUnreadDBMap.has(s)&&(e._convMap.delete(s),t.push(s))})),Be.l("".concat(this._n,"._diffAndDeleteConv list:").concat(t)),t=null}}},{key:"_pagingGetConvList",value:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n="".concat(this._n,"._pagingGetConvList");Be.l("".concat(n," incrementalPullFlag:").concat(t," ts:").concat(this._pagingTs," startIdx:").concat(this._pagingStartIdx)+" pinnedTs:".concat(this._pagingPinnedTs," pinnedStartIdx:").concat(this._pagingPinnedStartIdx));var s=Date.now();return this._pagingStatus=un,this.req({P:Cs.PAGING_GET_CONV_LIST,data:{fromAccount:this.getMyUserID(),timeStamp:t?this._pagingTs:0,startIndex:t?this._pagingStartIdx:0,pinnedTimeStamp:t?this._pagingPinnedTs:0,pinnedStartIndex:t?this._pagingPinnedStartIdx:0,orderType:1}}).then((function(t){var i=t.data,a=i.completeFlag,o=i.conversations,r=void 0===o?[]:o,c=i.timeStamp,u=i.startIndex,l=i.pinnedTimeStamp,d=i.pinnedStartIndex,h=i.groupItem;if(e._pagingGetCostList.push(en(s,!1)),Be.l("".concat(n," ok. completeFlag:").concat(a," count:").concat(r.length," cost:").concat(en(s))),e._convGroupHandler.onConvGroupListSynced(h),r.length>0){var g=e._getConvOptions(r);e._pagingConvIDMap=new Map([].concat(I(e._pagingConvIDMap),I(g.map((function(e){return[e.conversationID,1]}))))),e._updateLocalConvList({conversationOptionsList:g,isFromGetConversations:!0,updateUnreadCount:!0}),e.isLoggedIn()&&e.emitConvUpdate()}if(!e._isReady){if(!e.isLoggedIn())return ys();e.triggerReady()}return e._pagingTs=c,e._pagingStartIdx=u,e._pagingPinnedTs=l,e._pagingPinnedStartIdx=d,1!==a?e._pagingGetConvList():(e._handleGroupAtTipsList(),ys())})).catch((function(t){throw e.isLoggedIn()&&(e._isReady||(Be.w("".concat(n," failed. error:"),t),e.triggerReady())),t}))}},{key:"_updateLocalConvList",value:function(e){var t=e.isFromGetConversations,n=Date.now(),s=this._getTmpConvListMapping(e).newConvList;this._convMap=new Map(this._sortConvList(I(this._convMap))),t||this._updateUserOrGroupProfile(s),Be.l("".concat(this._n,"._updateLocalConvList cost:").concat(en(n)))}},{key:"_getTmpConvListMapping",value:function(e){for(var t=e.conversationOptionsList,n=e.isFromGetConversations,s=e.isInstantMessage,i=e.isUnreadC2CMessage,a=void 0!==i&&i,o=e.updateUnreadCount,r=[],c=[],u=this.get(Hn),l=this.get(jn),d=this.isIntl(),h=this.isUsingChatCore(),g=0,p=t.length;g<p;g++){var f=new Li(t[g],d,h),_=f.conversationID,v=f.type;if(!this._isNonExistentAccount(_)){if(this._convMap.has(_)){var m=this._convMap.get(_);if(n&&v!==D.CONV_TOPIC){this._convMap.set(_,f),v===D.CONV_C2C?f.unreadCount=m.unreadCount:v===D.CONV_GROUP&&(f.groupProfile=JSON.parse(JSON.stringify(m.groupProfile)));continue}var y=["unreadCount","allowType","adminForbidType","payload","groupProfile"];!1===s&&y.push("lastMessage"),"boolean"==typeof s&&y.push("isPinned");var I=t[g].lastMessage,M=!gt(I);M||t[g].type===D.CONV_TOPIC||this._onLastMsgNotExist(t[g]),gt(s)&&M&&null===m.lastMessage.payload&&(m.lastMessage.payload=I.payload),st(m.lastMessage.revoker)||(m.lastMessage.revoker=null),It(m,f,y,[null,void 0,"",0,NaN]),!0===o&&m.updateUnreadCount({nextUnreadCount:f.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:a}),s&&M&&(I.payload&&(m.lastMessage.payload=I.payload),m.type===D.CONV_GROUP&&(m.lastMessage.nameCard=I.nameCard,m.lastMessage.nick=I.nick)),M&&m.lastMessage.cloudCustomData!==I.cloudCustomData&&(m.lastMessage.cloudCustomData=I.cloudCustomData||"")}else{if(v===D.CONV_GROUP&&u){var C=f.groupProfile.groupID,T=u.getLocalGroupProfile(C);T&&(f.groupProfile=T,!0===o&&f.updateUnreadCount({nextUnreadCount:0}))}else if(v===D.CONV_C2C){var S=_.replace(D.CONV_C2C,"");l&&l.isMyFriend(S)&&(f.remark=l.getFriendRemark(S))}r.push(f),this._convMap.set(_,f)}this._convMap.get(_).type===D.CONV_TOPIC&&c.push(this._convMap.get(_))}}for(var E=this.get(Bn),k=0,O=c.length;k<O;k++){var R=c[k],A=R.conversationID,N=R.groupAtInfoList;st(N)||E.onAtInfoUpdated({topicID:A.replace(D.CONV_GROUP,""),groupAtInfoList:N})}return{newConvList:r}}},{key:"_onLastMsgNotExist",value:function(e){new Gs("lastMsgNotExist").setMessage(JSON.stringify(e)).end()}},{key:"_sortConvList",value:function(e){var t=[],n=[],s=[],i=[];return e.forEach((function(e){!0===e[1].isPinned?st(e[1].lastMessage.lastTime)?n.push(e):t.push(e):st(e[1].lastMessage.lastTime)?i.push(e):s.push(e)})),t.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})).concat(n).concat(s.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime}))).concat(i)}},{key:"_sortConvListAndEmitEvent",value:function(){this._convMap=new Map(this._sortConvList(I(this._convMap))),this.emitConvUpdate(!0,!1)}},{key:"_updateUserOrGroupProfile",value:function(e){var t=this;if(0!==e.length){var n=[],s=[],i=this.get(qn),a=this.get(Hn);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.push(t)}})),Be.l("".concat(this._n,"._updateUserOrGroupProfile userIDList:").concat(n," groupIDList:").concat(s)),n.length>0&&i.getUserProfile({userIDList:n}).then((function(e){var n=e.data;ht(n)?n.forEach((function(e){t._doUpdateUserProfile("".concat(D.CONV_C2C).concat(e.userID),e)})):t._doUpdateUserProfile("".concat(D.CONV_C2C).concat(n.userID),n)})),s.length>0&&a.getGroupProfileAdvance({groupIDList:s,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){var n=e.data.successGroupList,s=!1;n.forEach((function(e){var n="".concat(D.CONV_GROUP).concat(e.groupID);if(t._convMap.has(n)){var i=t._convMap.get(n);It(i.groupProfile,e,[],[null,void 0,"",0,NaN]),!i.subType&&e.type&&(i.subType=e.type),s=!0}})),s&&t.emitConvUpdate()}))}}},{key:"_doUpdateUserProfile",value:function(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t,this.emitConvUpdate())}},{key:"_getConvOptions",value:function(e){var t=this,n=[],s=e.filter((function(e){var n=e.type,s=e.userID;return 1===n&&!t._isNonExistentAccount(s)||2===n})),i=this.getMyUserID(),a=s.map((function(e){if(gt(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type){var s={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar};return n.push(s),{conversationID:"".concat(D.CONV_C2C).concat(e.userID),type:D.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?t._amendLayersOverLimitProp(e.lastMsg.elements[0].content,e.lastMsg.elements[0].type):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===i&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},unreadCount:0,userProfile:new Di(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Jt(e.standardMark),conversationGroupList:t._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:t._transMsgRemindType(e.messageRemindType)}}return{conversationID:"".concat(D.CONV_GROUP).concat(e.groupID),type:D.CONV_GROUP,lastMessage:_(_({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},t._patchTypeAndPayload(e)),{},{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||"",revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null}),groupProfile:new Ai({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq}),unreadCount:t._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Jt(e.standardMark),conversationGroupList:t._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:t._transMsgRemindType(e.messageRemindType)}}));return n.length>0&&this.get(qn).onConvProfileUpdated(n),a}},{key:"_transMsgRemindType",value:function(e){var t="";return 0===e?t=D.MSG_REMIND_ACPT_AND_NOTE:1===e?t=D.MSG_REMIND_DISCARD:2===e?t=D.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=D.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}},{key:"_computeGroupUnreadCount",value:function(e){var t=e.unreadCount,n=void 0===t?0:t,s=e.noUnreadCount,i=n-(void 0===s?0:s);return i>0?i:0}},{key:"_patchTypeAndPayload",value:function(e){var t=e.lastMsg,n=t.event,s=void 0===n?void 0:n,i=t.elements,a=void 0===i?[]:i,o=t.groupTips,r=void 0===o?{}:o;if(!gt(s)&&!st(r)){var c=new ri(r);c.setElement({type:D.MSG_GRP_TIP,content:_(_({},r.elements),{},{groupProfile:r.groupProfile})});var u=JSON.parse(JSON.stringify(c.payload));return c=null,{type:D.MSG_GRP_TIP,payload:u}}return{type:a[0]?a[0].type:null,payload:a[0]?this._amendLayersOverLimitProp(a[0].content,a[0].type):null}}},{key:"_amendLayersOverLimitProp",value:function(e,t){var n=this.getFileDownloadProxy(),s=this.getDownloadFileAuthKey(),i=this.get(Xn).getFileDNList(),a=e.layersOverLimit,o=null;return t===D.MSG_IMAGE&&(o=new Hs(e,n,s,i)),t===D.MSG_VIDEO&&(o=new Zs(e,n,s,i)),t===D.MSG_SOUND&&(o=new Bs(e,n,s,i)),t===D.MSG_FILE&&((o=new Js(e,n,s,i)).content.url=void 0),0===a?e.layersOverLimit=!1:1===a&&(e.layersOverLimit=!0),o&&Object.assign(e,o.content),e}},{key:"getLocalMessageList",value:function(e){return this._msgListHandler.getLocalMsgList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof ri&&this._msgListHandler.remove(e)}},{key:"onConvDeleted",value:function(e){if(ht(e)){var t=e.map((function(e){var t=e.type,n=e.userID,s=e.groupID;return 1===t?"".concat(D.CONV_C2C).concat(n):2===t?"".concat(D.CONV_GROUP).concat(s):void 0}));Be.l("".concat(this._n,".onConvDeleted convIDList:").concat(t)),this.deleteLocalConvList(t)}}},{key:"onConvPinnedStatus",value:function(e,t){var n=this;if(ht(e)){var s=!1;e.forEach((function(e){var i,a=e.type,o=e.userID,r=e.groupID;1===a?i=n.getLocalConversation("".concat(D.CONV_C2C).concat(o)):2===a&&(i=n.getLocalConversation("".concat(D.CONV_GROUP).concat(r))),i&&(Be.l("".concat(n._n,".onConvPinnedStatus convID:").concat(i.conversationID," localPinned:").concat(i.isPinned," remotePinned:").concat(t)),t?i.isPinned||(i.isPinned=!0,s=!0):i.isPinned&&(i.isPinned=!1,s=!0))})),s&&this._sortConvListAndEmitEvent()}}},{key:"getMessageList",value:function(e){var t=this,n=e.conversationID,s=e.nextReqMessageID,i=e.count,a="".concat(this._n,".getMessageList"),o=this.getLocalConversation(n),r="";if(o&&o.groupProfile&&(r=o.groupProfile.type),Nt(r))return Be.l("".concat(a," not available in ").concat(r,". convID:").concat(n)),ys({messageList:[],nextReqMessageID:"",isCompleted:!0});(gt(i)||i>15)&&(i=15),s||this._isMeInCommunity(n)||this.clearMemMsg(n);var c=this._computeRemainingCount({conversationID:n,nextReqMessageID:s}),u=this._completedMap.has(n);if(Be.l("".concat(a," convID:").concat(n," isEverCleared:").concat(this._isEverCleared(n)," nextReqMessageID:").concat(s)+" remainingCount:".concat(c," count:").concat(i," isCompleted:").concat(u)),this._needGetHistory({conversationID:n,remainingCount:c,count:i}))return this.getHistoryMessages({conversationID:n,nextReqMessageID:s,count:20}).then((function(e){var s=e.nextReqID,i=e.storedMessageList,o=e.assembledMessageList,r=e.isPullingCompleted,u=t._completedMap.has(n),l=i;c>0&&(l=t._msgListHandler.getLocalMsgList(n).slice(0,i.length+c));var d={nextReqMessageID:void 0,messageList:void 0,isCompleted:void 0};t._isEverCleared(n)?(d.nextReqMessageID=s,d.messageList=o,d.isCompleted=r):(d.nextReqMessageID=u?"":s,d.messageList=l,d.isCompleted=u),t.getStreamMessageInHistory(d.messageList);var h=d.messageList.filter((function(e){return e.isRevoked}))||[],g=d.messageList.map((function(e){return e.sequence}));return Be.l("".concat(a," ret.nextReqMessageID:").concat(d.nextReqMessageID," ret.isCompleted:").concat(d.isCompleted," sequenceList:"),g),ht(h)&&0!==h.length?t.updateRevokerInfo(h).then((function(e){return e.forEach((function(e){var t=e.revokerInfo;d.messageList=d.messageList.map((function(n){return n.ID===e.ID&&t&&(n.revokeReason=t.reason||"",n.revokerInfo={userID:t.revoker||n.revoker,nick:t.nick,avatar:t.avatar}),n}))})),ps(d)})):ps(d)}));this.modifyMessageList(n);var l=this._getMsgListFromMem({conversationID:n,nextReqMessageID:s,count:i});return ys(l)}},{key:"_isEverCleared",value:function(e){return this._everClearedMap.has(e)}},{key:"_getMsgListFromMem",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,s=e.count,i="".concat(this._n,"._getMsgListFromMem"),a=this._msgListHandler.getLocalMsgList(t),o=a.length,r=Pt(t),c=0,u={isCompleted:!1,nextReqMessageID:"",messageList:[]};n?(c=r?a.findIndex((function(e){return e.ID===n})):a.findIndex((function(e){return e.sequence+""===n})))>s?(u.messageList=a.slice(c-s,c),u.nextReqMessageID=r?a[c-s].ID:a[c-s].sequence+""):(u.messageList=a.slice(0,c),u.isCompleted=!0):o>s?(c=o-s,u.messageList=a.slice(c,o),u.nextReqMessageID=r?a[c].ID:a[c].sequence+""):(u.messageList=a.slice(0,o),u.isCompleted=!0);var l=u.messageList.map((function(e){return e.sequence}));return Be.l("".concat(i," convID:").concat(t)+" ret.nextReqMessageID:".concat(u.nextReqMessageID," ret.isCompleted:").concat(u.isCompleted," sequenceList:").concat(l)),u}},{key:"getMessageListHopping",value:function(e){var t=e.conversationID,n=e.sequence,s=e.time,i=e.count,a=e.direction,o=void 0===a?0:a;if((gt(i)||i>15)&&(i=15),t.startsWith(D.CONV_C2C)){var r=this.get(Kn),c=t.replace(D.CONV_C2C,"");return r.getRoamingMessagesHopping({peerAccount:c,time:s,count:i,direction:o})}if(t.startsWith(D.CONV_GROUP)){var u=this.get(Hn),l=t.replace(D.CONV_GROUP,"");return u.getRoamingMessagesHopping({groupID:l,sequence:n,count:i,direction:o})}}},{key:"_computeRemainingCount",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,s=this._msgListHandler.getLocalMsgList(t),i=s.length;if(Be.l("".concat(this._n,"._computeRemainingCount convID:").concat(t," nextReqMessageID:").concat(n," length:").concat(i)),!n)return i;var a=0;return Pt(t)?a=s.findIndex((function(e){return e.ID===n})):wt(t)&&(a=-1!==n.indexOf("-")?s.findIndex((function(e){return e.ID===n})):s.findIndex((function(e){return e.sequence+""===n}))),-1===a&&(a=0),a}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,n=e.remainingCount,s=e.count,i=this.getLocalConversation(t),a="";if(i&&i.groupProfile&&(a=i.groupProfile.type),bt(t)||Nt(a))return!1;if(this._isEverCleared(t))return!0;var o=n<=s&&!this._completedMap.has(t);return Be.l("".concat(this._n,"._needGetHistory convID:").concat(t," ret:").concat(o)),o}},{key:"_isTopicConv",value:function(e){var t=e.replace(D.CONV_GROUP,"");return Ut(t)}},{key:"getHistoryMessages",value:function(e){var t=e.conversationID,n=e.count,s=e.nextReqMessageID;if(t===D.CONV_SYSTEM)return ys();var i=15;n>20&&(i=20);var a=null;if(Pt(t)){var o=0,r="",c=!1,u=this._roamingMsgKeyAndTimeMap.has(t);if(s)if(c=!0,u)o=this._roamingMsgKeyAndTimeMap.get(t).lastMessageTime,r=this._roamingMsgKeyAndTimeMap.get(t).messageKey;else{var l=this._msgListHandler.findMessage(s);l&&(o=l.time,Be.l("".concat(this._n,".getHistoryMessages convID:").concat(t," isRelayInfoExisted:").concat(u," lastMessageTime:").concat(o)))}return(a=this.get(Kn)).getRoamingMessage({conversationID:t,peerAccount:t.replace(D.CONV_C2C,""),count:i,lastMessageTime:c?o:0,messageKey:c?r:""})}if(wt(t)){if(!(a=this.get(Hn)))return Is({code:_s.NO_MODULE});var d=t.replace(D.CONV_GROUP,""),h=null;this._convMap.has(t)&&!Ut(d)&&(h=this._convMap.get(t).lastMessage);var g=0;return s?g=Number(s):h&&(g=h.lastSequence),a.getRoamingMessage({conversationID:t,groupID:d,count:i,sequence:g})}return ys()}},{key:"patchConvLastMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.getLocalConversation(e);if(n){var s=n.lastMessage,i=s.messageForShow,a=s.payload;if(st(i)||st(a)||t){var o=this._msgListHandler.getLocalMsgList(e);if(0===o.length)return;var r=o[o.length-1];Be.l("".concat(this._n,".patchConvLastMessage bForceUpdate:").concat(t," convID:").concat(e," payload:"),r.payload),n.updateLastMessage(r)}}}},{key:"onRoamingMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,s=(arguments.length>1?arguments[1]:void 0).startsWith(D.CONV_C2C)?D.CONV_C2C:D.CONV_GROUP,i=null,a=[],o=[],r=0,c=e.length,u=null,l=s===D.CONV_GROUP,d=this.getFileDownloadProxy(),h=this.getDownloadFileAuthKey(),g=ht(n),p=this.get(Xn).getFileDNList(),f=function(){r=l?e.length-1:0,c=l?0:e.length},v=function(){l?--r:++r},m=function(){return l?r>=c:r<c};for(f();m();v())if(1!==e[r].isPlaceMessage)if((i=new ri(e[r])).to=e[r].to,s!==D.CONV_GROUP||gt(e[r].topicID)||(i.to=e[r].topicID),i.isSystemMessage=!!e[r].isSystemMessage,i.conversationType=s,u=4===e[r].event?{type:D.MSG_GRP_TIP,content:_(_({},e[r].elements),{},{groupProfile:e[r].groupProfile})}:e[r].elements,l||i.setNickAndAvatar({nick:e[r].nick,avatar:e[r].avatar}),st(u)){var y=new Gs("emptyMessageBody");y.setMessage("from:".concat(i.from," to:").concat(i.to," sequence:").concat(i.sequence," event:").concat(e[r].event)),y.setLevel("warning").end()}else i.setElement(u,d,h,p),i.reInitialize(this.getMyUserID()),a.push(i),g&&n.push(i);return f=v=m=null,t?(this._msgListHandler.unshift(a,o),a=null,o):(o=null,a)}},{key:"findMessage",value:function(e){return this._msgListHandler.findMessage(e)}},{key:"_isMeInCommunity",value:function(e){var t=!0;if(this._isTopicConv(e)){var n=zt(e.replace(D.CONV_GROUP,""));this.get(Hn).hasLocalGroup(n)||(t=!1,Be.l("".concat(this._n,"._isMeInCommunity groupID:").concat(n," ret:").concat(t)))}return t}},{key:"deleteTopicRoamingInfo",value:function(e){var t=this;Lt({groupID:e})&&this._msgListHandler.getTopicConvIDList(e).forEach((function(e){t.clearMemMsg(e)}))}},{key:"deleteGroupRoamingInfo",value:function(e){var t="".concat(D.CONV_GROUP).concat(e);this._msgListHandler.getLocalMsgList(t).length>0&&this.clearMemMsg(t)}},{key:"setMessageRead",value:function(e){var t=e.conversationID,n=this.getLocalConversation(t),s="".concat(this._n,".setMessageRead");if(Be.l("".concat(s," convID:").concat(t," unreadCount:").concat(n?n.unreadCount:0)),!n)return ys();if(n.type!==D.CONV_GROUP&&n.type!==D.CONV_TOPIC||st(n.groupAtInfoList)||this.deleteGroupAtTips(t),0===n.unreadCount)return ys();var i=this._msgListHandler.getLocalLastMsg(t),a=n.lastMessage.lastTime,o=this._msgListHandler.getLocalMaxTime(t);a<o&&(Be.l("".concat(s," update lastMessageTime from ").concat(a," to ").concat(o)),a=o);var r=this._msgListHandler.getLocalMaxSeq(t),c=n.lastMessage.lastSequence;if(c<r&&(Be.l("".concat(s," update lastMessageSeq from ").concat(c," to ").concat(r)),c=r),n.type===D.CONV_TOPIC&&gt(i)){var u=this.get(Bn),l=t.replace(D.CONV_GROUP,""),d=zt(l),h=u.getLocalTopic(d,l);h&&(c=h.nextMessageSeq-1)}var g=null;switch(n.type){case D.CONV_C2C:return(g=this.get(Kn))?g.setMessageRead({conversationID:t,lastMessageTime:a}):Is({code:_s.NO_MODULE});case D.CONV_GROUP:case D.CONV_TOPIC:return(g=this.get(Hn))?g.setMessageRead({conversationID:t,lastMessageSeq:c}):Is({code:_s.NO_MODULE});case D.CONV_SYSTEM:return n.unreadCount=0,this.emitConvUpdate(!0,!1),ys();default:return ys()}}},{key:"setAllMessageRead",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n="setAllMessageRead",s="".concat(this._n,".").concat(n);t.scope||(t.scope=D.READ_ALL_MSG),Be.l("".concat(s," options:"),t);var i=this._createSetAllMessageReadPack(t);if(0===i.readAllC2CMessage&&0===i.groupMessageReadInfoList.length)return ys();var a=new Gs(n);return this.req({P:Cs.SET_ALL_MSG_READ,data:i}).then((function(n){var s=n.data,i=e._handleAllMsgRead(s);return a.setMessage("scope:".concat(t.scope," failureGroups:").concat(JSON.stringify(i))).end(),ys()})).catch((function(e){return a.setError(e).end(),Be.w("".concat(s," failed. error:"),e),Is({code:e&&e.code?e.code:_s.MSG_UNREAD_ALL_FAIL,message:e&&e.message?e.message:void 0})}))}},{key:"setConvCustomData",value:function(e){return this._convGroupHandler.setConvCustomData(e)}},{key:"markConv",value:function(e){return this._convGroupHandler.markConv(e)}},{key:"getConvGroupList",value:function(){return this._convGroupHandler.getLocalConvGroupList()}},{key:"createConvGroup",value:function(e){return this._convGroupHandler.createConvGroup(e)}},{key:"deleteConvGroup",value:function(e){return this._convGroupHandler.deleteConvGroup(e)}},{key:"renameConvGroup",value:function(e){return this._convGroupHandler.renameConvGroup(e)}},{key:"addConvsToGroup",value:function(e){return this._convGroupHandler.addConvsToGroup(e)}},{key:"deleteConvsFromGroup",value:function(e){return this._convGroupHandler.deleteConvsFromGroup(e)}},{key:"onConvMarkUpdated",value:function(e){this._convGroupHandler.onConvMarkUpdated(e)}},{key:"onConvGroupCreated",value:function(e){this._convGroupHandler.onConvGroupCreated(e)}},{key:"onConvGroupDeleted",value:function(e){this._convGroupHandler.onConvGroupDeleted(e)}},{key:"onConvGroupNameUpdated",value:function(e){this._convGroupHandler.onConvGroupNameUpdated(e)}},{key:"onConvInGroupUpdated",value:function(e){this._convGroupHandler.onConvInGroupUpdated(e)}},{key:"onConvAddedToOrDeletedFromGroup",value:function(e){this._convGroupHandler.onConvAddedToOrDeletedFromGroup(e)}},{key:"_getConvLastMessageSeq",value:function(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID),n=e.lastMessage.lastSequence;return t&&n<t.sequence&&(n=t.sequence),n}},{key:"_getConvLastMessageTime",value:function(e){var t=this._msgListHandler.getLocalLastMsg(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:[]},s=e.scope,i=c(this._convMap);try{for(i.s();!(t=i.n()).done;){var a=y(t.value,2)[1];if(a.unreadCount>0)if(a.type===D.CONV_C2C&&0===n.readAllC2CMessage){if(s===D.READ_ALL_MSG)n.readAllC2CMessage=1;else if(s===D.READ_ALL_C2C_MSG){n.readAllC2CMessage=1;break}}else if(a.type===D.CONV_GROUP&&(s===D.READ_ALL_GROUP_MSG||s===D.READ_ALL_MSG)){var o=this._getConvLastMessageSeq(a);n.groupMessageReadInfoList.push({groupID:a.groupProfile.groupID,messageSequence:o})}}}catch(e){i.e(e)}finally{i.f()}return n}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMsgRead(e)}},{key:"_handleAllMsgRead",value:function(e){var t=e.groupMessageReadInfoList,n=e.readAllC2CMessage,s=this._parseGroupReadInfo(t);return this._updateAllConvUnreadCount({readAllC2CMessage:n})>=1&&this.emitConvUpdate(!0,!1),s}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var n=0,s=e.length;n<s;n++){var i=e[n],a=i.groupID,o=i.sequence,r=i.retCode,c=i.lastMessageSeq;gt(r)?this._remoteGroupReadSeqMap.set(a,c):(this._remoteGroupReadSeqMap.set(a,o),0!==r&&t.push("".concat(a,"-").concat(o,"-").concat(r)))}return t}},{key:"_updateAllConvUnreadCount",value:function(e){var t,n=e.readAllC2CMessage,s=0,i=c(this._convMap);try{for(i.s();!(t=i.n()).done;){var a=y(t.value,2),o=a[0],r=a[1];if(r.unreadCount>=1){if(1===n&&r.type===D.CONV_C2C){var u=this._getConvLastMessageTime(r);this.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:u})}else if(r.type===D.CONV_GROUP){var l=o.replace(D.CONV_GROUP,"");if(this._remoteGroupReadSeqMap.has(l)){var d=this._remoteGroupReadSeqMap.get(l),h=this._getConvLastMessageSeq(r);this.updateIsReadAfterReadReport({conversationID:o,remoteReadSequence:d}),h>=d&&this._remoteGroupReadSeqMap.delete(l)}}this.updateUnreadCount(o,!1)&&(s+=1)}}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"isRemoteRead",value:function(e){var t=e.conversationID,n=e.sequence,s=t.replace(D.CONV_GROUP,""),i=!1;if(this._remoteGroupReadSeqMap.has(s)){var a=this._remoteGroupReadSeqMap.get(s);n<=a&&(i=!0,Be.l("".concat(this._n,".isRemoteRead convID:").concat(t," msgSeq:").concat(n," remoteReadSeq:").concat(a))),n>=a+10&&this._remoteGroupReadSeqMap.delete(s)}return i}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,n=e.lastMessageSeq,s=e.lastMessageTime,i=this._msgListHandler.getLocalMsgList(t);if(0!==i.length)for(var a,o=i.length-1;o>=0;o--)if(a=i[o],!(s&&a.time>s||n&&a.sequence>n)){if("in"===a.flow&&a.isRead)break;a.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=!1,s=this.getLocalConversation(e),i=this._msgListHandler.getLocalMsgList(e);if(s){var a=s.unreadCount,o=i.filter((function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted})).length;if(a!==o&&(s.unreadCount=o,n=!0,Be.l("".concat(this._n,".updateUnreadCount from ").concat(a," to ").concat(o,", convID:").concat(e)),!0===t&&this.emitConvUpdate(!0,!1)),n&&s.type===D.CONV_TOPIC){var r=s.unreadCount,c=this.get(Bn),u=e.replace(D.CONV_GROUP,"");c.onUnreadCountUpdatedFromConv(u,r)}return n}}},{key:"clearGroupAtInfoList",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getLocalConversation(e);if(n&&n.groupAtInfoList.length>0){if(n.clearGroupAtInfoList(),Be.l("".concat(this._n,".clearGroupAtInfoList convID:").concat(e)),n.type===D.CONV_TOPIC){var s=n.groupAtInfoList,i=this.get(Bn),a=e.replace(D.CONV_GROUP,"");i.onAtInfoUpdated({topicID:a,groupAtInfoList:s})}!0===t&&this.emitConvUpdate(!0,!1)}}},{key:"updateReadReceiptInfo",value:function(e){var t=this,n=e.userID,s=void 0===n?void 0:n,i=e.groupID,a=void 0===i?void 0:i,o=e.readReceiptList,r=e.timestamp,c=void 0===r?0:r;if(!st(o)){var u=[];if(gt(s)){if(!gt(a)){var l="".concat(D.CONV_GROUP).concat(a);o.forEach((function(e){var n=e.tinyID,s=e.clientTime,i=e.random,o=e.readCount,r=e.unreadCount,c="".concat(n,"-").concat(s,"-").concat(i),d=t._msgListHandler.getLocalMsg(l,c)||t._msgListHandler.getHoppingMsg(l,c),h={groupID:a,messageID:c,readCount:0,unreadCount:0};d&&(ct(o)&&(d.readReceiptInfo.readCount=o,h.readCount=o),ct(r)&&(d.readReceiptInfo.unreadCount=r,h.unreadCount=r),u.push(h))}))}}else{var d="".concat(D.CONV_C2C).concat(s);o.forEach((function(e){var n=e.tinyID,i=e.clientTime,a=e.random,o="".concat(n,"-").concat(i,"-").concat(a),r=t._msgListHandler.getLocalMsg(d,o)||t._msgListHandler.getHoppingMsg(d,o);if(r&&!r.readReceiptInfo.isPeerRead){r.readReceiptInfo.isPeerRead=!0,r.readReceiptInfo.timestamp=c;var l={userID:s,messageID:o,isPeerRead:!0,timestamp:c};u.push(l)}}))}u.length>0&&this.emitOEvt(k.MESSAGE_READ_RECEIPT_RECEIVED,u)}}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),n=this.getLocalMessageList(e);if(t&&0!==n.length&&!bt(t.type)){for(var s=[],i=0,a=n.length;i<a;i++)"in"!==n[i].flow?"out"!==n[i].flow||n[i].isRead||n[i].setIsRead(!0):s.push(n[i]);var o=0;if(t.type===D.CONV_C2C){var r=s.slice(-t.unreadCount).filter((function(e){return e.isRevoked})).length;o=s.length-t.unreadCount-r}else o=s.length-t.unreadCount;for(var c=0;c<o&&!s[c].isRead;c++)s[c].setIsRead(!0)}}},{key:"deleteGroupAtTips",value:function(e){var t=this,n="".concat(this._n,".deleteGroupAtTips");Be.l("".concat(n));var s=this._convMap.get(e);if(!s)return Promise.resolve();var i=s.groupAtInfoList;if(0===i.length)return Promise.resolve();var a=void 0;e.startsWith(D.CONV_GROUP)&&(a=e.replace(D.CONV_GROUP,""));var o=I(i);if((Lt({groupID:a})||Ut(a))&&0===(o=i.filter((function(e){return!e.atTypeArray.includes(D.CONV_AT_ALL)}))).length)return this.clearGroupAtInfoList(e,!1),Promise.resolve();var r=this.getMyUserID();return this.req({P:Cs.DEL_GROUP_AT_TIPS,data:{messageListToDelete:o.map((function(e){return{from:e.from,to:r,messageSeq:e.__sequence,messageRandom:e.__random,groupID:gt(e.topicID)?e.groupID:e.topicID}}))}}).then((function(){return Be.l("".concat(n," ok. count:").concat(i.length)),t.clearGroupAtInfoList(e,!1),Promise.resolve()})).catch((function(e){return Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"appendToMessageList",value:function(e){return this._msgListHandler.pushIn(e)}},{key:"setMessageRandom",value:function(e){this._sll.set(e.random)}},{key:"deleteMessageRandom",value:function(e){this._sll.delete(e.random)}},{key:"pushIntoMessageList",value:function(e,t,n){return!(!this._msgListHandler.pushIn(t,n)||this._sll.has(t.random)&&!n||(e.push(t),0))}},{key:"revoke",value:function(e,t,n){return this._msgListHandler.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:"updateMsgIsPeerReadProp",value:function(e,t){if(e.startsWith(D.CONV_C2C)&&t>0){var n=this._msgListHandler.updateMsgIsPeerReadProp(e,t);if(n.length>0&&this.emitOEvt(k.MESSAGE_READ_BY_PEER,n),this._convMap.has(e)){var s=this._convMap.get(e).lastMessage;st(s)||s.fromAccount===this.getMyUserID()&&s.lastTime<=t&&!s.isPeerRead&&(s.isPeerRead=!0,this.emitConvUpdate(!0,!1))}}}},{key:"updateMsgIsModifiedProp",value:function(e){this._msgListHandler.updateMsgIsModifiedProp(e)}},{key:"setCompleted",value:function(e){Be.l("".concat(this._n,".setCompleted convID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMsgKeyAndTime",value:function(e,t,n){this._roamingMsgKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:n})}},{key:"getConvList",value:function(e){var t=this,n="".concat(this._n,".").concat("getConvList"),s="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._convMap.size,", options:").concat(JSON.stringify(e));if(Be.l("".concat(n,". ").concat(s)),this._pagingStatus===dn){var i=new Gs("getConvList");return i.setMessage(s),this.syncConvList().then((function(){i.end();var n=t._getConvList(e);return ps({conversationList:n,isSyncCompleted:t._isSyncCompleted()})})).catch((function(e){return i.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}var a=this._getConvList(e);return Be.l("".concat(n,". returned conversation count:").concat(a.length)),ys({conversationList:a,isSyncCompleted:this._isSyncCompleted()})}},{key:"_getConvList",value:function(e){var t=this;if(gt(e))return this.getLocalConvList();if(ht(e))return 0===e.length?[]:this.getLocalConvList().filter((function(t){return e.includes(t.conversationID)}));if(dt(e)){var n=e.type,s=e.markType,i=e.groupName,a=e.hasUnreadCount,o=e.hasGroupAtInfo;return this.getLocalConvList().filter((function(e){return t._filterType(e,n)&&t._filterMarkType(e,s)&&t._filterGroupName(e,i)&&t._filterUnreadCount(e,a)&&t._filterGroupAtInfo(e,o)}))}return[]}},{key:"_filterType",value:function(e,t){return t!==D.CONV_C2C&&t!==D.CONV_GROUP||e.type===t}},{key:"_filterGroupName",value:function(e,t){return!ut(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}},{key:"_filterMarkType",value:function(e,t){return!ct(t)||(0===t?0===e.markList.length:e.markList.includes(t))}},{key:"_filterUnreadCount",value:function(e,t){var n=!0;return!0===t?n=e.unreadCount>=1:!1===t&&(n=0===e.unreadCount),n}},{key:"_filterGroupAtInfo",value:function(e,t){var n=!0;return!0===t?n=e.groupAtInfoList.length>=1:!1===t&&(n=0===e.groupAtInfoList.length),n}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=c(this._convMap);try{for(t.s();!(e=t.n()).done;){var n=y(e.value,2),s=n[0],i=n[1];i.type===D.CONV_C2C&&this.recordPeerReadTime(s,i.peerReadTime)}}catch(e){t.e(e)}finally{t.f()}}},{key:"_isPagingGetGroupListCompleted",value:function(){var e=this.get(Hn);return!e||e.isPagingGetCompleted()}},{key:"_getLocalGroupCount",value:function(){var e=this.get(Hn);return e?e.getLocalGroupList().length:0}},{key:"_hasLocalGroup",value:function(e){var t=this.get(Hn);return!!t&&t.hasLocalGroup(e.replace(D.CONV_GROUP,""))}},{key:"getConversationProfile",value:function(e){var t,n=this,s=!1;if(this._convMap.has(e)?t=this._convMap.get(e):(t=new Li({conversationID:e,type:Pt(e)?D.CONV_C2C:D.CONV_GROUP},this.isIntl(),this.isUsingChatCore()),s=!0),t._isInfoCompleted||t.type===D.CONV_SYSTEM)return ys({conversation:t});if(wt(e)){if(!this.get(Hn))return Is({code:_s.NO_MODULE});if(!this._hasLocalGroup(e))return ys({conversation:t})}var i="".concat(this._n,".").concat("getConversationProfile"),a=new Gs("getConversationProfile");return Be.l("".concat(i,". convID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._getUserOrGroupProfile(t).then((function(o){a.setMessage("convID:".concat(e," unreadCount:").concat(o.data.conversation.unreadCount)).end();var r=n.get(jn);if(r&&t.type===D.CONV_C2C){var c=e.replace(D.CONV_C2C,"");if(r.isMyFriend(c)){var u=r.getFriendRemark(c);t.remark!==u&&(t.remark=u,Be.l("".concat(i,". convID:").concat(e," patch remark:").concat(t.remark)))}}if(Be.l("".concat(i," ok. isNewConv:").concat(s," convID:").concat(e)),s){if(t.type===D.CONV_C2C)return n._onNewC2CConv([e.replace(D.CONV_C2C,"")]).then((function(){return ys({conversation:t})}));if(t.type===D.CONV_GROUP)return n._onNewGroupConv([e.replace(D.CONV_GROUP,"")]).then((function(){return ys({conversation:t})}))}return o})).catch((function(t){return a.setError(t).setMessage("convID:".concat(e)).end(),Be.e("".concat(i," failed. error:"),t),Is(t)}))}},{key:"_getUserOrGroupProfile",value:function(e){var t=this;return e.type===D.CONV_C2C?this.get(qn).getUserProfile({userIDList:[e.toAccount]}).then((function(n){var s=n.data;return 0===s.length?Is({code:_s.USER_OR_GRP_NOT_FOUND}):(e.userProfile=s[0],e._isInfoCompleted=!0,t._insertConvAfterTopmost(e),ys({conversation:e}))})):this.get(Hn).getGroupProfile({groupID:e.toAccount}).then((function(n){return e.groupProfile=n.data.group,e._isInfoCompleted=!0,t._insertConvAfterTopmost(e),ys({conversation:e})}))}},{key:"_insertConvAfterTopmost",value:function(e){if(e instanceof Li&&!this._convMap.has(e.conversationID)){var t=I(this._convMap),n=t.findIndex((function(e){return!1===e[1].isPinned}));t.splice(n,0,[e.conversationID,e]),this._convMap=new Map(t),this._setStorageConvList(),this.emitConvUpdate(!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 s=t._convMap.get("".concat(D.CONV_C2C).concat(n));s&&(s.userProfile=e)}}))}},{key:"_onCloudConfig",value:function(e){"0"===this.getCloudConfig("pull_on_invite")&&(this._bPullOnInvite=!1),Be.l("".concat(this._n,"._onCloudConfig bPullOnInvite:").concat(this._bPullOnInvite))}},{key:"disableMsgPullOnInvite",value:function(){this._bPullOnInvite=!1}},{key:"_isSyncCompleted",value:function(){return this._pagingStatus===ln}},{key:"_errorLog",value:function(e,t,n,s){var i=new Error("Params validate failed."),a="".concat(this.getErrMsg("API_REFER")).concat(e);throw Be.w("[".concat(e,"] | ").concat(t," | ").concat(this.getErrMsg(n,s),", ").concat(a)),Be.e("[".concat(e,"] Invalid ").concat(t,": type check failed for ").concat(t,".")),i}},{key:"_isValidConvID",value:function(e){return Pt(e)||wt(e)||bt(e)}},{key:"deleteConversation",value:function(e){var t=this,n="deleteConversation";return ut(e)||lt(e)||this._errorLog(n,"options","StringOrObjectRequiredLog"),ut(e)?(this._isValidConvID(e)||this._errorLog(n,"options","InvalidConversationID",e),Be.l("".concat(this._n,".").concat(n," convID:").concat(e)),this.deleteConvList({conversationIDList:[e],flag:1})):(ht(e.conversationIDList)||this._errorLog(n,"conversationIDList","ArrayRequiredLog"),0===e.conversationIDList.length&&this._errorLog(n,"conversationIDList","NonEmptyArrayLog"),e.conversationIDList.forEach((function(e){t._isValidConvID(e)||t._errorLog(n,"conversationIDList","InvalidConversationID",e)})),"clearHistoryMessage"in e&&"boolean"!=typeof e.clearHistoryMessage&&this._errorLog(n,"clearHistoryMessage","BooleanRequiredLog"),e.conversationIDList.length>100&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConvList(e))}},{key:"deleteConvList",value:function(e){var t=e.conversationIDList,n=void 0===t?[]:t,s=e.clearHistoryMessage,i=void 0===s||s,a=e.flag,o=void 0===a?0:a,r="".concat(this._n,".").concat("deleteConvList"),c="convIDList:".concat(n," clearHistoryMessage:").concat(i);Be.l("".concat(r," ").concat(c));var u=new Gs("deleteConvList");return u.setMessage(c),Promise.all([this.rmLocalOnlyConvList(n),this.rmLocalAndRemoteConvList(n,i)]).then((function(e){u.end();var t=[].concat(I(e[0]),I(e[1]));return 0===t.length?Is(new fs({code:_s.CONV_NOT_FOUND})):(Be.l("".concat(r," ok")),ys(1===o?{conversationID:t[0]}:{conversationIDList:t}))})).catch((function(e){return u.setError(e).end(),Be.e("".concat(r," failed. error:"),e),Is(e)}))}},{key:"rmLocalOnlyConvList",value:function(e){var t=this;return e.filter((function(e){if(!t._convMap.has(e))return!1;var n=t.getLocalConversation(e).type;return n!==D.CONV_GROUP||t._hasLocalGroup(e)?n===D.CONV_SYSTEM&&(t.get(Hn).deleteGroupSystemNotice({messageList:t._msgListHandler.getLocalMsgList(e)}),t.deleteLocalConv(e),!0):(t.deleteLocalConv(e),!0)}))}},{key:"rmLocalAndRemoteConvList",value:function(e,t){var n=this,s={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:t?1:0};return e.forEach((function(e){if(n._convMap.has(e)){var t=n.getLocalConversation(e).type;t===D.CONV_C2C?s.conversationList.push({toAccount:e.replace(t,""),type:1}):t===D.CONV_GROUP&&n._hasLocalGroup(e)&&s.conversationList.push({toGroupID:e.replace(t,""),type:2})}})),0===s.conversationList.length?[]:this.req({P:Cs.DEL_CONV,data:s}).then((function(e){var t=[];return e.data.resultList.length>0&&e.data.resultList.map((function(e){if(0===e.code){var n=1===e.type?"".concat(D.CONV_C2C).concat(e.to):"".concat(D.CONV_GROUP).concat(e.groupID);t.push(n)}})),n.deleteLocalConvList(t),t}))}},{key:"setConvDraft",value:function(e){var t=e.conversationID,n=e.draftText,s="".concat(this._n,".").concat("setConvDraft");if(Be.l("".concat(s," convID:").concat(t," draftText:").concat(n)),!this._convMap.has(t))return Is({code:_s.CONV_NOT_FOUND});var i=this._convMap.get(t);return i.setDraftText(n),this.emitConvUpdate(),ys({code:0,conversation:i})}},{key:"clearHistoryMessage",value:function(e){var t=this,n={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._convMap.has(e))return Is({code:_s.CONV_NOT_FOUND});var s=this._convMap.get(e).type;if(s===D.CONV_C2C)n.type=1,n.toAccount=e.replace(D.CONV_C2C,"");else{if(s!==D.CONV_GROUP)return s===D.CONV_SYSTEM?(this.get(Hn).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(e)}),ys({conversationID:e})):Is({code:_s.CONV_UN_RECORDED_TYPE});n.type=2,n.toGroupID=e.replace(D.CONV_GROUP,"")}var i="".concat(this._n,".").concat("clearHistoryMessage"),a=new Gs("clearHistoryMessage");return a.setMessage("convID:".concat(e)),Be.l("".concat(i,". convID:").concat(e)),this.setMessageRead({conversationID:e}).then((function(){return t.req({P:Cs.CLEAR_HISTORY_MSG,data:n})})).then((function(){a.end(),Be.l("".concat(i," ok")),t.clearMemMsg(e);var n=t.getLocalConversation(e);return n&&(n.updateLastMessage(),t._sortConvListAndEmitEvent()),ys({conversationID:e})})).catch((function(e){return a.setError(e).end(),Be.e("".concat(i," failed. error:"),e),Is(e)}))}},{key:"pinConversation",value:function(e){var t=this,n=e.conversationID,s=e.isPinned,i=this.getLocalConversation(n);if(i&&i.isPinned===s)return ys({conversationID:n});if(bt(n))return i&&(i.isPinned=s),this._sortConvListAndEmitEvent(),ys({conversationID:n});var a=null;if(Pt(n)?a={type:1,toAccount:n.replace(D.CONV_C2C,"")}:wt(n)&&(a={type:2,groupID:n.replace(D.CONV_GROUP,"")}),null===a)return Is({code:_s.INVALID_CONV_ID});var o="".concat(this._n,".").concat("pinConversation"),r="convID:".concat(n," isPinned:").concat(s),c=new Gs("pinConversation");return c.setMessage(r),Be.l("".concat(o,". ").concat(r)),this.req({P:Cs.PIN_CONV,data:{fromAccount:this.getMyUserID(),operationType:!0===s?1:2,itemList:[a]}}).then((function(){return c.end(),Be.l("".concat(o," ok")),i?i.isPinned!==s&&(i.isPinned=s):t._convMap.set(n,new Li({conversationID:n,type:Pt(n)?D.CONV_C2C:D.CONV_GROUP,isPinned:s},t.isIntl(),t.isUsingChatCore())),t._sortConvListAndEmitEvent(),ps({conversationID:n})})).catch((function(e){return c.setError(e).end(),Be.e("".concat(o," failed. error:"),e),Is(e)}))}},{key:"setMessageRemindType",value:function(e){return this._msgRemindHandler.set(e)}},{key:"patchMsgRemindType",value:function(e){var t=e.ID,n=e.isC2CConversation,s=e.messageRemindType,i=!1,a=this.getLocalConversation(n?"".concat(D.CONV_C2C).concat(t):"".concat(D.CONV_GROUP).concat(t));return a&&a.messageRemindType!==s&&(a.messageRemindType=s,i=!0),Be.l("".concat(this._n,".patchMsgRemindType options:"),e,"ret:".concat(i)),i}},{key:"onC2CMsgRemindTypeFetched",value:function(e){var t=this;if(ht(e)&&e.length>0){var n=0;e.forEach((function(e){var s=e.userID,i=e.muteFlag,a=t._transMsgRemindType(i);!0===t.patchMsgRemindType({ID:s,isC2CConversation:!0,messageRemindType:a})&&(n+=1)})),Be.l("".concat(this._n,".onC2CMsgRemindTypeFetched updateCount:").concat(n)),n>=1&&this.emitConvUpdate(!0,!1)}}},{key:"onC2CMsgRemindTypeSynced",value:function(e){var t=this,n="".concat(this._n,".onC2CMsgRemindTypeSynced");e.dataList.forEach((function(e){if(!st(e.muteNotificationsSync)){var s=e.muteNotificationsSync,i=s.to,a=s.muteFlag,o=t._transMsgRemindType(a),r=0;t.patchMsgRemindType({ID:i,isC2CConversation:!0,messageRemindType:o})&&(r+=1),Be.l("".concat(n," updateCount:").concat(r)),r>=1&&t.emitConvUpdate(!0,!1)}}))}},{key:"onGroupMsgRemindTypeUpdated",value:function(e){this._msgRemindHandler.onGroupMsgRemindTypeUpdated(e)}},{key:"deleteLocalConv",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this._convMap.has(e);if(Be.l("".concat(this._n,".deleteLocalConv convID:").concat(e," has:").concat(n)),n&&(this._convMap.delete(e),this._convMapForDiff.delete(e),this.clearMemMsg(e),this._setStorageConvList(!0),t)){var s=!this._isTopicConv(e);this.emitConvUpdate(s,!1)}}},{key:"pullMsgOnInvite",value:function(e){var t=this,n=this.get(Hn);if(n){var s="".concat(this._n,".pullMsgOnInvite");if(Be.l("".concat(s," flag:").concat(this._bPullOnInvite)),this._bPullOnInvite){var i=this.getLocalLastMessage(e),a=this.getLocalSecondLastMessage(e),o=1,r=1;i&&(o=i.sequence),a&&(r=a.sequence);var c=n.getGroupRemoteLastSeq(e.replace(D.CONV_GROUP,""));Be.l("".concat(s," convID:").concat(e," localLastSeq:").concat(o," localSecondLastSeq:").concat(r," remoteLastSeq:").concat(c)),this.clearMemMsg(e),o-r>1?this._recursiveGetMsgList([],e,!1,o,r):c-o>1&&this._recursiveGetMsgList([],e,!0,c,o)}else this.getMessageList({conversationID:e,count:1}).then((function(n){var i=t.hasLocalConversation(e);Be.l("".concat(s," convID:").concat(e," has:").concat(i)),i?t.patchConvLastMessage(e,!0):t.getConversationProfile(e).then((function(){t.patchConvLastMessage(e,!0)}))}))}}},{key:"_recursiveGetMsgList",value:function(e,t,n,s,i,a){var o=this;this.getMessageList({conversationID:t,nextReqMessageID:a}).then((function(a){var r=a.data,c=r.messageList,u=r.isCompleted,l=r.nextReqMessageID,d=c.filter((function(e){return n?e.sequence>i&&e.sequence<=s:e.sequence>i&&e.sequence<s}));e.unshift.apply(e,I(d)),u?o._emitMsgReceived(t,e):c.length>0&&c[0].sequence>i&&e.length<60?o._recursiveGetMsgList(e,t,n,s,i,l):o._emitMsgReceived(t,e)}))}},{key:"_emitMsgReceived",value:function(e,t){var n=this;if(t.length>0){var s=t.filter((function(e,t,n){return t===n.findIndex((function(t){return t.sequence===e.sequence}))})),i=this.hasLocalConversation(e),a=s.map((function(e){return e.sequence}));Be.l("".concat(this._n,"._emitMsgReceived convID:").concat(e," has:").concat(i," count:").concat(a.length," sequenceList:"),a),this.emitOEvt(k.MESSAGE_RECEIVED,s),i?this.patchConvLastMessage(e,!0):this.getConversationProfile(e).then((function(){n.patchConvLastMessage(e,!0)}))}}},{key:"deleteLocalConvList",value:function(e){var t=this,n=!1;e.forEach((function(e){t._convMap.has(e)&&(t.deleteLocalConv(e,!1),n=!0)})),Be.l("".concat(this._n,".deleteLocalConvList convID:").concat(e," isConvIDExisted:").concat(n)),n&&this.emitConvUpdate(!0,!1)}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._msgListHandler.hasLocalMsg(e.conversationID,e.ID)&&!this._sll.has(e.random))}},{key:"modifyMessageList",value:function(e){if(e.startsWith(D.CONV_C2C)&&this._convMap.has(e)){var t=this._convMap.get(e),n=Date.now();this._msgListHandler.modifyMsgSentByPeer({conversationID:e,latestNick:t.userProfile.nick,latestAvatar:t.userProfile.avatar});var s=this.get(qn).getNickAndAvatarByUserID(this.getMyUserID());this._msgListHandler.modifyMsgSentByMe({conversationID:e,latestNick:s.nick,latestAvatar:s.avatar}),Be.l("".concat(this._n,".modifyMessageList convID:").concat(e," cost:").concat(en(n)))}}},{key:"updateUserProfileSpecifiedKey",value:function(e){Be.l("".concat(this._n,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,n=e.nick,s=e.avatar;if(this._convMap.has(t)){var i=this._convMap.get(t).userProfile;ut(n)&&i.nick!==n&&(i.nick=n),ut(s)&&i.avatar!==s&&(i.avatar=s),this.emitConvUpdate(!0,!1)}}},{key:"_onMyProfileModified",value:function(e){var t=this,n=this.getLocalConvList(),s=Date.now();n.forEach((function(n){t.modifyMessageSentByMe(_({conversationID:n.conversationID},e))})),Be.l("".concat(this._n,"._onMyProfileModified. modify all messages sent by me, cost:").concat(en(s)))}},{key:"modifyMessageSentByMe",value:function(e){this._msgListHandler.modifyMsgSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._msgListHandler.getLatestMsgSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._msgListHandler.modifyMsgSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._msgListHandler.getLatestMsgSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._msgListHandler.pushIn(t)||this._sll.has(t.random)||(e.push(t),0))}},{key:"getLocalLastMessage",value:function(e){return this._msgListHandler.getLocalLastMsg(e)}},{key:"getLocalSecondLastMessage",value:function(e){return this._msgListHandler.getLocalSecondLastMsg(e)}},{key:"checkAndPatchRemark",value:function(){var e=this.get(jn);if(0!==this._convMap.size&&e){var t=I(this._convMap.values()).filter((function(e){return e.type===D.CONV_C2C}));if(0!==t.length){var n=0;t.forEach((function(t){var s=t.conversationID.replace(D.CONV_C2C,"");if(e.isMyFriend(s)){var i=e.getFriendRemark(s);t.remark!==i&&(t.remark=i,n+=1)}})),Be.l("".concat(this._n,".checkAndPatchRemark. c2cConvCount:").concat(t.length," patchedCount:").concat(n)),n>0&&this.emitConvUpdate(!0,!1)}}}},{key:"updateTopicConversation",value:function(e){this._updateLocalConvList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}},{key:"sendReadReceipt",value:function(e){var t=e[0],n=null;return t.conversationType===D.CONV_C2C?n=this._m.get(Kn):t.conversationType===D.CONV_GROUP&&(n=this._m.get(Hn)),n?n.sendReadReceipt(e):Is({code:_s.NO_MODULE})}},{key:"getReadReceiptList",value:function(e){var t=e[0],n=null;return t.conversationType===D.CONV_C2C?n=this._m.get(Kn):t.conversationType===D.CONV_GROUP&&(n=this._m.get(Hn)),n?n.getReadReceiptList(e):Is({code:_s.NO_MODULE})}},{key:"getLastMessageTime",value:function(e){var t=this.getLocalConversation(e);return t?t.lastMessage.lastTime:0}},{key:"getTotalUnreadCount",value:function(){var e=this.getLocalConvList(),t=0;return e.forEach((function(e){e.type!==D.CONV_SYSTEM&&(""!==e.messageRemindType&&e.messageRemindType!==D.MSG_REMIND_ACPT_AND_NOTE||(t+=e.unreadCount))})),t}},{key:"onTotalUnreadCountUpdate",value:function(){var e=this.getTotalUnreadCount();this._convTotalUnreadCount!==e&&(Be.l("".concat(this._n,".onTotalUnreadCountUpdate from ").concat(this._convTotalUnreadCount," to ").concat(e)),this._convTotalUnreadCount=e,this.emitOEvt(k.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}},{key:"_isConvNeedShow",value:function(e){var t=this.getLocalConversation(e);if(gt(t))return!0;var n=t.type===D.CONV_TOPIC,s=t.type===D.CONV_GROUP&&t.groupProfile.type===D.GRP_ROOM,i=t.type===D.CONV_GROUP&&t.groupProfile.type===D.GRP_LIVE;return!(n||s||i)}},{key:"setAllRcvMsgOpt",value:function(e){return this._msgRemindHandler.setAllRcvMsgOpt(e)}},{key:"getAllRcvMsgOpt",value:function(){return this._msgRemindHandler.getAllRcvMsgOpt()}},{key:"onAllRcvMsgOptNotify",value:function(e){this._msgRemindHandler.onAllRcvMsgOptNotify(e)}},{key:"clearUnreadCount",value:function(e){var t=this.getLocalConversation(e);t&&t.unreadCount>0&&(t.unreadCount=0,this.emitConvUpdate(!0,!1))}},{key:"storeHoppingMessageList",value:function(e){this._msgListHandler.storeHoppingMsgList(e),this.getStreamMessageInHistory(e)}},{key:"clearMemMsg",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Be.l("".concat(this._n,".clearMemMsg convID:").concat(e," isOverLimit:").concat(t)),this._msgListHandler.removeByConvID(e),this._completedMap.delete(e),this._roamingMsgKeyAndTimeMap.delete(e),this._everClearedMap.set(e,1)}},{key:"findMsgBySeq",value:function(e,t){return this._msgListHandler.findMsgBySeq(e,t)}},{key:"onPushedChunks",value:function(e){this._streamMessageHandler.onPushedChunks(e)}},{key:"getStreamMessageInHistory",value:function(e){this._streamMessageHandler.getStreamMessageInHistory(e)}},{key:"getStreamMessageBeforeEmit",value:function(e){this._streamMessageHandler.getStreamMessageBeforeEmit(e)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._setStorageConvList(!0),this._pagingStatus=cn,this._msgListHandler.reset(),this._msgRemindHandler.reset(),this._roamingMsgKeyAndTimeMap.clear(),this._sll.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._convMap.clear(),this._pagingTs=0,this._pagingStartIdx=0,this._pagingPinnedTs=0,this._pagingPinnedStartIdx=0,this._remoteGroupReadSeqMap.clear(),this._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this._convMapForDiff.clear(),this._partialUpdatedConvMap.clear(),this._everClearedMap.clear(),this._bPullOnInvite=!0,this._convGroupHandler.reset(),this._streamMessageHandler.reset(),this.resetReady()}}])}(Ms),xi=r((function e(t){i(this,e),this._userM=t,this._n="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}),[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,n="".concat(this._n,".").concat("getUserProfile"),s=e.userIDList;e.fromAccount=this._userM.getMyAccount(),s.length>100&&(Be.w("".concat(n," ").concat("the length of userIDList cannot exceed ".concat(100))),s.length=100);for(var i,a=[],o=[],r=0,c=s.length;r<c;r++)i=s[r],this._userM.isMyFriend(i)&&this._contains(i)?o.push(this._getProfileFromMap(i)):a.push(i);if(0===a.length)return ys(o);e.toAccount=a;var u=e.bFromGetMyProfile||!1,l=[];e.toAccount.forEach((function(e){l.push({toAccount:e,standardSequence:0,customSequence:0})})),e.userItem=l;var d=new Gs("getUserProfile");return d.setMessage(s.length>5?"userIDList.length:".concat(s.length):"userIDList:".concat(s)),this._userM.req({P:Cs.GET_USER_PROFILE,data:e}).then((function(e){d.end(),Be.i("".concat(n," ok"));var s=t._handleResponse(e).concat(o);return ps(u?s[0]:s)})).catch((function(e){return d.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"getMyProfile",value:function(){var e=this._userM.getMyAccount(),t="".concat(this._n,".getMyProfile");if(Be.l("".concat(t," myAccount:").concat(e)),this._fill(),this._contains(e)){var n=this._getProfileFromMap(e);return Be.d("".concat(t," from cache, myProfile:").concat(JSON.stringify(n))),ys(n)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){var t=e.data.userProfileItem;if(!ht(t))return[];for(var n=[],s=Date.now(),i=0,a=t.length;i<a;i++){var o=t[i],r=o.to,c=o.profileItem;if("@TLS#NOT_FOUND"!==r&&""!==r){var u=this._update(r,this._getLatestProfileFromResponse(r,c)).latestProfile;n.push(u)}}return Be.l("".concat(this._n,"._handleResponse cost:").concat(en(s))),n}},{key:"_getLatestProfileFromResponse",value:function(e,t){var n={userID:e,profileCustomField:[]};if(!st(t))for(var s=0,i=t.length;s<i;s++)if(t[s].tag.indexOf("Tag_Profile_Custom")>-1)n.profileCustomField.push({key:t[s].tag,value:t[s].value});else switch(t[s].tag){case ze.NICK:n.nick=t[s].value;break;case ze.GENDER:n.gender=t[s].value;break;case ze.BIRTHDAY:n.birthday=t[s].value;break;case ze.LOCATION:n.location=t[s].value;break;case ze.SELFSIGNATURE:n.selfSignature=t[s].value;break;case ze.ALLOWTYPE:n.allowType=t[s].value;break;case ze.LANGUAGE:n.language=t[s].value;break;case ze.AVATAR:n.avatar=t[s].value;break;case ze.MESSAGESETTINGS:n.messageSettings=t[s].value;break;case ze.ADMINFORBIDTYPE:n.adminForbidType=t[s].value;break;case ze.LEVEL:n.level=t[s].value;break;case ze.ROLE:n.role=t[s].value;break;default:Be.w("".concat(this._n,"._getLatestProfileFromResponse unknown tag:"),t[s].tag,t[s].value)}return n}},{key:"updateMyProfile",value:function(e){var t=this,n="".concat(this._n,".").concat("updateMyProfile");if(e.nick&&!1===this._userM.filterProfanity("nick",e))return Is({code:_s.PROFANITY_FOUND});if(e.selfSignature&&!1===this._userM.filterProfanity("selfSignature",e))return Is({code:_s.PROFANITY_FOUND});var s=new Gs("updateMyProfile");s.setMessage(JSON.stringify(e));var i=(new Di).validate(e);if(!i.valid)return s.setCode(_s.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:".concat(i.tips)).end(),Be.e("".concat(n," info:").concat(i.tips)),Is({code:_s.UPDATE_PROFILE_INVALID_PARAM});var a=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&("profileCustomField"===o?e.profileCustomField.forEach((function(e){a.push({tag:e.key,value:e.value})})):a.push({tag:ze[o.toUpperCase()],value:e[o]}));if(0===a.length){var r=new fs({code:_s.UPDATE_PROFILE_NO_KEY});return s.setError(r).end(),Be.e("".concat(n," failed. error:"),r),Is(r)}var c=this._userM.getMyAccount();return this._userM.req({P:Cs.UPDATE_MY_PROFILE,data:{fromAccount:c,profileItem:a}}).then((function(i){s.end(),Be.i("".concat(n," ok"));var a=t._update(c,e),o=a.isProfileUpdated,r=a.latestProfile;return!0===o&&t._userM.emitOEvt(k.PROFILE_UPDATED,[r]),ys(r)})).catch((function(e){return s.setError(e).end(),Be.e("".concat(n," failed. error:"),e),Is(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!st(t)){var n,s=t.length;Be.d("".concat(this._n,".onProfileModified count:").concat(s," dataList:"),e.dataList);for(var i=[],a=0;a<s;a++){n=t[a].userID;var o=this._update(n,this._getLatestProfileFromResponse(n,t[a].profileList)),r=o.isProfileUpdated,c=o.latestProfile;!0===r&&i.push(c)}i.length>0&&(this._userM.emitIEvt(mi.PROFILE_UPDATED,i),this._userM.emitOEvt(k.PROFILE_UPDATED,i))}}},{key:"_fill",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),n=0,s=e.length;n<s;n++)t-e[n].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[n].userID,e[n]);Be.l("".concat(this._n,"._fill from cache, size:").concat(this.accountProfileMap.size))}}},{key:"_update",value:function(e,t){var n,s=!1,i=Date.now();return this._contains(e)?(n=this._getProfileFromMap(e),t.profileCustomField&&!0===Rt(n.profileCustomField,t.profileCustomField)&&(n.lastUpdatedTime=i,s=!0),It(n,t,["profileCustomField"])>0&&(n.lastUpdatedTime=i,s=!0)):(n=new Di(t),(this._userM.isMyFriend(e)||e===this._userM.getMyAccount())&&(n.lastUpdatedTime=i,s=!0,this.accountProfileMap.set(e,n))),this._flush(e===this._userM.getMyAccount()),!0===s&&Be.l("".concat(this._n,"._update account:").concat(e," isUpdated:").concat(s)),{isProfileUpdated:s,latestProfile:n}}},{key:"_flush",value:function(e){var t=I(this.accountProfileMap.values()),n=this._userM.getStorageModule();Be.d("".concat(this._n,"._flush length:").concat(t.length," flushAtOnce:").concat(e)),n.setItem(this.TAG,t,e)}},{key:"_contains",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._userM.getStorageModule().getItem(this.TAG);return st(e)?[]:e}},{key:"onConvProfileUpdated",value:function(e){for(var t,n,s,i=[],a=0,o=e.length;a<o;a++)n=(t=e[a]).userID,this._userM.isMyFriend(n)&&(this._contains(n)?(s=this._getProfileFromMap(n),It(s,t)>0&&i.push(n)):i.push(t.userID));0!==i.length&&(Be.l("".concat(this._n,".onConvProfileUpdated toAccountList:").concat(i)),this.getUserProfile({userIDList:i}))}},{key:"getNickAndAvatarByUserID",value:function(e){if(this._contains(e)){var t=this._getProfileFromMap(e);return{nick:t.nick,avatar:t.avatar}}return{nick:"",avatar:""}}},{key:"getUserNickAndAvatar",value:function(e){var t=this,n=I(new Set(e));Be.l("".concat(this._n,".getUserNickAndAvatar userIDList.length:").concat(e.length," uniqueUserIDList.length:").concat(n.length));var s=[];if(0===e.length)return Promise.resolve(s);var i=this._createUserIDListGroup(n),a=[];return i.forEach((function(e){a.push(t.getUserProfile({userIDList:e}))})),Promise.all(a).then((function(e){return e.forEach((function(e){var t=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));s.push.apply(s,I(t))})),s}))}},{key:"_createUserIDListGroup",value:function(e){for(var t=[],n=0;n<e.length;)t.push(e.slice(n,n+=100));return t}},{key:"reset",value:function(){this._flush(!0),this.accountProfileMap.clear()}}]),Vi=function(e){var t=String(e).replace(/[=]+$/,""),n="";if(t.length%4==1)return"";for(var s,i,a=0,o=0;i=t.charAt(o++);~i&&(s=a%4?64*s+i:i,a++%4)?n+=String.fromCharCode(255&s>>(-2*a&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);try{return decodeURIComponent(escape(n))}catch(e){return""}},qi=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="UserModule",s._profileHandler=new xi(s),s.getIEmitInst().on(mi.A2KEY_AND_TINYID_UPDATED,s.onContextUpdated,s),s}return d(t,e),r(t,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile()}},{key:"mockOnNickAvatarModified",value:function(e,t){Be.l("".concat(this._n,"._mockOnNickAvatarModified nick:").concat(e," avatar:").concat(t)),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:ze.NICK,value:e},{tag:ze.AVATAR,value:t}]}]})}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){}},{key:"onConvProfileUpdated",value:function(e){this._profileHandler.onConvProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyNick",value:function(){return this._profileHandler.getNickAndAvatarByUserID(this.getMyUserID()).nick}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.get(zn)}},{key:"filterProfanity",value:function(e,t){}},{key:"isMyFriend",value:function(e){var t=this.get(jn);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:"getUserNickAndAvatar",value:function(e){return this._profileHandler.getUserNickAndAvatar(e)}},{key:"getLocalBlacklist",value:function(){}},{key:"addBlacklist",value:function(e){}},{key:"deleteBlacklist",value:function(e){}},{key:"onUserStatusUpdated",value:function(e){}},{key:"setSelfStatus",value:function(e){}},{key:"getUserStatus",value:function(e){}},{key:"subscribeUserStatus",value:function(e){}},{key:"unsubscribeUserStatus",value:function(e){}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._profileHandler.reset()}}])}(Ms),Ki=r((function e(t,n){i(this,e),this._m=t,this._isLoggedIn=!1,this._SDKAppID=n.SDKAppID,this._userID=n.userID||"",this._userSig=n.userSig||"",this._version=E,this._a2Key="",this._tinyID="",this._customStatus="",this._contentType="json",this._unlimitedAVChatRoom=n.unlimitedAVChatRoom,this._scene=n.scene||"",this._oversea=n.oversea,this._instanceID=n.instanceID,this._statusInstanceID=0,this._isDevMode=n.devMode,this._isTestEnv=n.testEnv,this._proxyServer=n.proxyServer,this._fileUploadProxy=n.fileUploadProxy,this._fileDownloadProxy=n.fileDownloadProxy,this._applicationID=0,this._isPartialUpdatedConvs=n.partialUpdatedConversations,this._isIndependentDomainDisabled=n.disableIndependentDomain,this._isUsingChatCore=!1,this._uiPlatform=0,this._authKey="",this._customLoginInfo=""}),[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isPrivateNetWork",value:function(){return this._proxyServer}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isTestEnv",value:function(){return this._isTestEnv}},{key:"isPartialUpdatedConvs",value:function(){return this._isPartialUpdatedConvs}},{key:"isIndependentDomainDisabled",value:function(){return this._isIndependentDomainDisabled}},{key:"isSingaporeSite",value:function(){return this._SDKAppID>=2e7&&this._SDKAppID<3e7||this._SDKAppID>=172e7&&this._SDKAppID<173e7}},{key:"isKoreaSite",value:function(){return this._SDKAppID>=3e7&&this._SDKAppID<4e7||this._SDKAppID>=173e7&&this._SDKAppID<174e7}},{key:"isGermanySite",value:function(){return this._SDKAppID>=4e7&&this._SDKAppID<5e7||this._SDKAppID>=174e7&&this._SDKAppID<175e7}},{key:"isIndiaSite",value:function(){return this._SDKAppID>=5e7&&this._SDKAppID<6e7||this._SDKAppID>=175e7&&this._SDKAppID<176e7}},{key:"isJapanSite",value:function(){return this._SDKAppID>=6e7&&this._SDKAppID<7e7||this._SDKAppID>=176e7&&this._SDKAppID<177e7}},{key:"isUSASite",value:function(){return this._SDKAppID>=7e7&&this._SDKAppID<8e7||this._SDKAppID>=177e7&&this._SDKAppID<178e7}},{key:"isIndonesiaSite",value:function(){return this._SDKAppID>=8e7&&this._SDKAppID<9e7||this._SDKAppID>=178e7&&this._SDKAppID<179e7}},{key:"isIntl",value:function(){return 0===(e=this._SDKAppID)||e>=2e7&&e<9e7||e>=172e7&&e<179e7;var e}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"isUsingChatCore",value:function(){return this._isUsingChatCore}},{key:"setUsingChatCore",value:function(e){this._isUsingChatCore=e}},{key:"getUIPlatform",value:function(){return this._uiPlatform}},{key:"setUIPlatform",value:function(e){this._uiPlatform=e}},{key:"setUserID",value:function(e){this._userID=e}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setCustomStatus",value:function(e){this._customStatus=e}},{key:"getCustomStatus",value:function(){return this._customStatus}},{key:"getScene",value:function(){return Le?window.tencent_cloud_im_csig_flutter_for_web_25F_cy: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:"getFileUploadProxy",value:function(){return this._fileUploadProxy}},{key:"getFileDownloadProxy",value:function(){return this._fileDownloadProxy}},{key:"setApplicationID",value:function(e){this._applicationID=e}},{key:"getApplicationID",value:function(){return this._applicationID}},{key:"setDowloadFileAuthKey",value:function(e){this._authKey=e}},{key:"getDownloadFileAuthKey",value:function(){return this._authKey}},{key:"setCustomLoginInfo",value:function(e){this._customLoginInfo=e}},{key:"getCustomLoginInfo",value:function(){return this._customLoginInfo}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,n=!1,s=!1,i=[];ue&&(i=Object.keys(ge)),he&&(i=ce?Object.keys(uni):Object.keys(window));for(var a=0,o=i.length;a<o;a++)if(i[a].toLowerCase().includes("uikit")){e=!0;break}if(i=null,ue&&!ft(ge.createGamePortal)&&ft(getApp)&&!gt(getApp())){var r=getApp().globalData;dt(r)&&!0===r.isTUIKit&&(t=!0)}!0===this._m.get(zn).getStorageSync("TIM_".concat(this._SDKAppID,"_isTUIKit"))&&(n=!0);var c=null;if(Q&&!ne&&"undefined"==typeof uni&&__wxConfig&&(c=__wxConfig.pages),te&&"undefined"==typeof uni&&__qqConfig&&(c=__qqConfig.pages),ht(c)&&c.length>0){for(var u=0,l=c.length;u<l;u++)if(c[u].toLowerCase().includes("tui")){s=!0;break}c=null}return e||t||n||s}},{key:"reset",value:function(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}]),Hi={"k-vue2-pc":1,"k-vue2-h5":2,"k-vue2-h5-uni":3,"k-vue2-app-uni":4,"k-vue2-mp-uni":5,"k-vue2-pc-uni":6,"k-vue3-pc":7,"k-vue3-h5":8,"k-vue3-h5-uni":9,"k-vue3-app-uni":10,"k-vue3-mp-uni":11,"k-vue3-pc-uni":12,"k-rn":13},ji=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="SignModule",s._helloInterval=120,s._lastLoginTs=0,s._lastWsHelloTs=0,s._isWebUniapp=0,Ii.mixin(s),s}return d(t,e),r(t,[{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}},{key:"login",value:function(e){var t="";if(this.isLoggedIn()){var n=this.getMyUserID();return(t=this.getErrMsg("RepeatLogin",n))&&Be.w(t),ys({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.warn("LoggingIn",e.userID),Is({code:_s.REPEAT_LOGIN});Be.l("".concat(this._n,".login userID:").concat(e.userID));var s=this._checkLoginInfo(e);if(0!==s.code)return Is(s);var i=this.get(Wn),a=e.userID,o=e.userSig;return i.setUserID(a),i.setUserSig(o),this.get(es).updateProtocolConfig(),this._login()}},{key:"_login",value:function(){var e=this,t=this.get(Wn),n=t.getScene(),s=n;n&&n.startsWith("k-")&&(s=Hi[n],n="tuikit");var i=new Gs("login");i.setMessage("".concat(s)).setMoreMessage("identifier:".concat(this.getMyUserID()));var a=0;"aidesk-uikit-engine"===n?a=1e3:"aidesk-customer-uni-vue2"===n?a=1001:"aidesk-customer-uni-vue3"===n?a=1002:"aidesk-customer-uni-mp"===n?a=1003:"aidesk-customer-web-vue2"===n?a=1004:"aidesk-customer-web-vue3"===n?a=1005:"aidesk-agent-list-vue2"===n?a=1006:"aidesk-agent-list-vue3"===n?a=1007:"test-window"===n||"aidesk-workstation"===n?a=1008:"aidesk-no-dev-required"===n&&(a=1009),i.setUIPlatform(a),t.setUIPlatform(a);var o="".concat(this._n,"._login");return this._lastLoginTs=Date.now(),this.req({P:Cs.LOGIN,data:{deviceBrand:0,isWebUniapp:this._isWebUniapp,customInfo:t.getCustomLoginInfo()}}).then((function(s){e._lastLoginTs=0;var a=Date.now(),r=null,c=s.data,u=c.a2Key,l=c.tinyID,d=c.helloInterval,h=c.instanceID,g=c.timeStamp,p=c.customStatus,f=void 0===p?"":p,_=c.purchaseBits,v=c.authKey,m=void 0===v?"":v,y=1e3*g,I=a-i.getStartTs(),M=y+parseInt(I/2)-a,C=i.getStartTs()+M;if(i.start(C),function(e,t){Fe=t;var n=new Date;n.setTime(e),Be.i("baseTime from server:".concat(n," offset:").concat(Fe))}(y,M),!l)throw r=new fs({code:_s.NO_TINYID}),i.setError(r).end(),r;if(!u)throw r=new fs({code:_s.NO_A2KEY}),i.setError(r).end(),r;var T=e.get(ts).getSocketID(),S=Vi(f),E="socketID:".concat(T," scene:").concat(n," helloInterval:").concat(d," instanceID:").concat(h," timeStamp:").concat(g)+" offset:".concat(M," customStatus:").concat(S," isWebUniapp:").concat(e._isWebUniapp);Be.l("".concat(o," ok. ").concat(E));var k="",D="";if(Q&&ft(ge.getAccountInfoSync)){var O=ge.getAccountInfoSync().miniProgram;O&&(k=O.appId,D=O.envVersion)}return i.setMoreMessage("".concat(E," href:").concat(he?window.location.href:""," mpAppId:").concat(k," envVersion:").concat(D," authKey:").concat(m)).end(),t.setA2Key(u),t.setTinyID(l),t.setStatusInstanceID(h),t.setCustomStatus(S),t.setDowloadFileAuthKey(m),_&&e.get(os).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:_}),e.get(es).updateProtocolConfig(),e.emitIEvt(mi.A2KEY_AND_TINYID_UPDATED),e._helloInterval=d,e.triggerReady(),e._fetchCloudControlConfig(),s})).catch((function(t){return i.setError(t).end(!0),e._m.setNotReadyReason(_s.LOGIN_FAILED),Be.e("".concat(o," failed. error:"),t),e._lastLoginTs=0,e._m.onLoginFailed(),Is(t)}))}},{key:"logout",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n="".concat(this._n,".logout"),s=this.isLoggedIn();return Be.i("".concat(n," type:").concat(t," isLoggedIn:").concat(s," isWebUniapp:").concat(this._isWebUniapp)),s?(new Gs("logout").setMessage("identifier:".concat(this.getMyUserID())).end(!0),0===t&&this._m.setNotReadyReason(_s.LOGGED_OUT),this.req({P:Cs.LOGOUT,data:{type:t,isWebUniapp:this._isWebUniapp}}).then((function(){return e.resetReady(),ys({})})).catch((function(t){return Be.e("".concat(n," error:"),t),e.resetReady(),ys({})}))):Is({code:_s.USER_NOT_LOGGED_IN})}},{key:"getLoginUser",value:function(){return this.isLoggedIn()?this.getMyUserID():""}},{key:"_fetchCloudControlConfig",value:function(){this.get(ns).fetchConfig()}},{key:"_getStatusInstanceID",value:function(){return uni.getStorageSync("timUniAppInstanceID")||0}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.req({P:Cs.HELLO,data:{isWebUniapp:this._isWebUniapp}}).catch((function(t){Be.w("".concat(e._n,"._hello error:"),t)}))}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0;return st(this.get(Wn).getSDKAppID())?t=_s.NO_SDKAPPID:st(e.userID)?t=_s.NO_IDENTIFIER:st(e.userSig)&&(t=_s.NO_USERSIG),{code:t}}},{key:"_isReactUIKit",value:function(){return he&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new Gs("kickedOut").setMessage("type:".concat(D.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Be.w("".concat(this._n,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOEvt(k.KICKED_OUT,{type:D.KICKED_OUT_MULT_ACCOUNT}),t._m.setNotReadyReason(_s.KICKED_OUT_MULT_ACCOUNT),t._m.reset()}))}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new Gs("kickedOut").setMessage("type:".concat(D.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Be.w("".concat(this._n,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then((function(){t.emitOEvt(k.KICKED_OUT,{type:D.KICKED_OUT_MULT_DEVICE}),t._m.setNotReadyReason(_s.KICKED_OUT_MULT_DEVICE),t._m.reset()}))}},{key:"onUserSigExpired",value:function(){new Gs("kickedOut").setMessage(D.KICKED_OUT_USERSIG_EXPIRED).end(!0),Be.w("".concat(this._n,".onUserSigExpired userID:").concat(this.getMyUserID())),0!==this.get(Wn).getStatusInstanceID()&&(this.emitOEvt(k.KICKED_OUT,{type:D.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(_s.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}},{key:"onRestApiKickedOut",value:function(e){new Gs("kickedOut").setMessage("type:".concat(D.KICKED_OUT_REST_API," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Be.w("".concat(this._n,".onRestApiKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),0!==this.get(Wn).getStatusInstanceID()&&(this.emitOEvt(k.KICKED_OUT,{type:D.KICKED_OUT_REST_API}),this._m.setNotReadyReason(_s.KICKED_OUT_REST_API),this._m.reset(),this.get(ts).onRestApiKickedOut())}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}])}(Ms);function Bi(){return null}var Yi=r((function e(t){i(this,e),this._m=t,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}),[{key:"_errorTolerantHandle",value:function(){ue||"undefined"!=typeof window&&this._canIUseCookies()||(this.getItem=Bi,this.setItem=Bi,this.removeItem=Bi,this.clear=Bi)}},{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=y(e.value,2),s=n[0],i=n[1];this._setStorageSync(this._getKey(s),i)}}catch(e){t.e(e)}finally{t.f()}this._storageQueue.clear()}catch(e){Be.w("".concat(this._n,"._doFlush error:"),e)}}},{key:"_getPrefix",value:function(){var e=this._m.get(Wn);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(e){return Be.w("".concat(this._n,".getItem error:"),e),{}}}},{key:"setItem",value:function(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]){var n=arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?e:this._getKey(e);this._setStorageSync(n,t)}else this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{ue?ge.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){Be.w("".concat(this._n,".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(e){Be.w("".concat(this._n,".removeItem error:"),e)}}},{key:"getSize",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var s={size:0,limitSize:5242880,unit:n};if(Object.defineProperty(s,"leftSize",{enumerable:!0,get:function(){return s.limitSize-s.size}}),ue&&(s.limitSize=1024*ge.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(ue)ge.getStorageInfoSync().keys.forEach((function(e){s.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length}));else if(this._canIUseCookies())for(var i in localStorage)localStorage.hasOwnProperty(i)&&(s.size+=localStorage.getItem(i).length+i.length);return this._convertUnit(s)}catch(e){Be.w("".concat(this._n," error:"),e)}}},{key:"_convertUnit",value:function(e){var t={},n=e.unit;for(var s in t.unit=n,e)"number"==typeof e[s]&&("kb"===n.toLowerCase()?t[s]=Math.round(e[s]/1024):"mb"===n.toLowerCase()?t[s]=Math.round(e[s]/1024/1024):t[s]=e[s]);return t}},{key:"_setStorageSync",value:function(e,t){ue?ie?my.setStorageSync({key:e,data:t}):ge.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return ue?ie?my.getStorageSync({key:e}).data:ge.getStorageSync(e):this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){ue?ie?my.removeStorageSync({key:e}):ge.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}},{key:"_canIUseCookies",value:function(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._doFlush()}}]),Wi=r((function e(t){i(this,e),this._n="SSOLogBody",this._report=[]}),[{key:"pushIn",value:function(e){Be.d("".concat(this._n,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;ht(e)&&0!==e.length&&(Be.d("".concat(this._n,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,I(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}}]),zi=function(e){var t=e.get(Wn);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:xe()}},$i=function(e){function t(e){var s;i(this,t),(s=n(this,t,[e]))._n="EventStatModule",s.TAG="im-ssolog-event",s._reportBody=new Wi,s.MIN_THRESHOLD=20,s.MAX_THRESHOLD=100,s.WAITING_TIME=6e4,s.REPORT_LEVEL=[4,5,6],s.REPORT_SDKAPPID_BLACKLIST=[],s.REPORT_TINYID_WHITELIST=[],s._lastReportTime=Date.now();var a=s.getIEmitInst();return a.on(mi.A2KEY_AND_TINYID_UPDATED,s._onLoginSuccess,s),a.on(mi.CLOUD_CONFIG,s._onCloudConfig,s),s}return d(t,e),r(t,[{key:"reportAtOnce",value:function(){this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.get(zn),n=t.getItem(this.TAG,!1);!st(n)&&ft(n.forEach)&&(Be.l("".concat(this._n,"._onLoginSuccess. logs count:").concat(n.length)),n.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),n=this.getCloudConfig("evt_rpt_level"),s=this.getCloudConfig("evt_rpt_sdkappid_bl"),i=this.getCloudConfig("evt_rpt_tinyid_wl");gt(e)||(this.MIN_THRESHOLD=Number(e)),gt(t)||(this.WAITING_TIME=Number(t)),gt(n)||(this.REPORT_LEVEL=n.split(",").map((function(e){return Number(e)}))),gt(s)||(this.REPORT_SDKAPPID_BLACKLIST=s.split(",").map((function(e){return Number(e)}))),gt(i)||(this.REPORT_TINYID_WHITELIST=i.split(","))}},{key:"pushIn",value:function(e){e instanceof Gs&&(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.get(Wn),s=n.getSDKAppID(),i=n.getTinyID();return Yt(this.REPORT_SDKAPPID_BLACKLIST,s)&&!Wt(this.REPORT_TINYID_WHITELIST,i)?[]: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 s={header:zi(this),event:n};this.req({P:Cs.SSO_STAT,data:_({},s)}).then((function(){e._lastReportTime=Date.now()})).catch((function(n){Be.w("".concat(e._n,"._report failed. error:"),n),e._lastReportTime=Date.now(),e._reportBody.backfill(t),e._reportBody.getLogsNumInMemory()>e.MAX_THRESHOLD&&e._flushAtOnce()}))}else this._lastReportTime=Date.now()}}},{key:"_flushAtOnce",value:function(){var e=this.get(zn),t=e.getItem(this.TAG,!1),n=this._reportBody.getLogsInMemory(),s="".concat(this._n,"._flushAtOnce");if(st(t))Be.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1);else{var i=n.concat(t);i.length>this.MAX_THRESHOLD&&(i=i.slice(0,this.MAX_THRESHOLD)),Be.l("".concat(s," count:").concat(i.length)),e.setItem(this.TAG,i,!0,!1)}}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}])}(Ms),Ji="none",Xi="online",Zi=r((function e(t){i(this,e),this._m=t,this._networkType=Xi,this._n="NetMonitorModule",this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null,this._removeListener=null,this._m.getIEmitInst().on(mi.A2KEY_AND_TINYID_UPDATED,this._startRN,this)}),[{key:"_startRN",value:function(){var e=this;if(de){var t=this._m.get(Zn).getPlugin("chat-network-monitor");t&&(this._removeListener=t.addEventListener((function(t){var n=t.isConnected,s=void 0!==n&&n,i=t.type;e._networkType!==i&&e._onNetworkStatusChange({isConnected:s,networkType:i})})))}}},{key:"start",value:function(){var e=this,t="".concat(this._n,".start");ue?(ge.getNetworkType({success:function(n){e._networkType=n.networkType||n.subtype||"",n.networkType===Ji?Be.w("".concat(t," no network, please check!")):Be.i("".concat(t," networkType:").concat(n.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),ge.onNetworkStatusChange(this._mpNetworkStatusCallback)):he&&(this._networkType=Xi,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:Xi})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:Ji})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,n=e.networkType,s="".concat(this._n,"._onNetworkStatusChange"),i=!1,a="previous:".concat(this._networkType," current:").concat(n);t?(Be.i("".concat(s," ").concat(a)),this._networkType!==n&&(i=!0,this._networkType=n,this._m.get(ts).reConnect(!0))):this._networkType!==n&&(i=!0,this._networkType=n,Be.w("".concat(s," no network, please check!")),this._m.get(ts).offline()),i&&new Gs("networkChange").setMessage("isConnected:".concat(t," ").concat(a)).end()}},{key:"isOnline",value:function(){return this._networkType!==Ji}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),ue?null!==this._mpNetworkStatusCallback&&(ge.offNetworkStatusChange&&ge.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null):he?(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null)):de&&this._removeListener&&(this._removeListener(),this._removeListener=null)}}]);function Qi(e,t){return e(t={exports:{}},t.exports),t.exports}var ea=Qi((function(e){var t=Object.prototype.hasOwnProperty,n="~";function s(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,s,a,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");var r=new i(s,a||e,o),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],r]:e._events[c].push(r):(e._events[c]=r,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function r(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),r.prototype.eventNames=function(){var e,s,i=[];if(0===this._eventsCount)return i;for(s in e=this._events)t.call(e,s)&&i.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},r.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var i=0,a=s.length,o=new Array(a);i<a;i++)o[i]=s[i].fn;return o},r.prototype.listenerCount=function(e){var t=n?n+e:e,s=this._events[t];return s?s.fn?1:s.length:0},r.prototype.emit=function(e,t,s,i,a,o){var r=n?n+e:e;if(!this._events[r])return!1;var c,u,l=this._events[r],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,s),!0;case 4:return l.fn.call(l.context,t,s,i),!0;case 5:return l.fn.call(l.context,t,s,i,a),!0;case 6:return l.fn.call(l.context,t,s,i,a,o),!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 h,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,s);break;case 4:l[u].fn.call(l[u].context,t,s,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},r.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},r.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},r.prototype.removeListener=function(e,t,s,i){var a=n?n+e:e;if(!this._events[a])return this;if(!t)return o(this,a),this;var r=this._events[a];if(r.fn)r.fn!==t||i&&!r.once||s&&r.context!==s||o(this,a);else{for(var c=0,u=[],l=r.length;c<l;c++)(r[c].fn!==t||i&&!r[c].once||s&&r[c].context!==s)&&u.push(r[c]);u.length?this._events[a]=1===u.length?u[0]:u:o(this,a)}return this},r.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new s,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=n,r.EventEmitter=r,e.exports=r})),ta=["rich.my-imcloud.com","imrich.qcloud.com"],na=["existFlag"],sa=9999,ia=1e4,aa=function(e){function t(e){var s;i(this,t),(s=n(this,t,[e]))._n="UploadModule",s.TIMUploadPlugin=null,s.timUploadPlugin=null,s.COSSDK=null,s._cosUploadMethod=null,s.expiredTimeLimit=600,s.appid=0,s.bucketName="",s.ciUrl="",s.directory="",s.downloadUrl="",s.uploadUrl="",s.region="ap-shanghai",s.cos=null,s.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},s.uploadFileType="",s.duration=900,s.tryCount=0,s.UPLOAD_SIZE_LIMIT={A:20971520,F:104857600,I:20971520,V:104857600},s.isSimpleCos=!s.isPrivateNetWork(),s._fileDownloadProxy="",s._authKey="",s._fileDNList=ta;var a=s.getIEmitInst();return a.on(mi.A2KEY_AND_TINYID_UPDATED,s._init,s),a.on(mi.CLOUD_CONFIG,s._onCloudConfig,s),s}return d(t,e),r(t,[{key:"_init",value:function(){this._fileDownloadProxy=this.getFileDownloadProxy(),this._authKey=this.getDownloadFileAuthKey();var e=this.get(Zn);if(this.TIMUploadPlugin=e.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin)this._initUploaderMethod();else{var t=ue?"cos-wx-sdk":"cos-js-sdk";this.COSSDK=e.getPlugin(t),this.COSSDK?(this._getAuthorizationKey(),this.warn("CosReplacement",t)):this.warn("PluginUndetected")}}},{key:"_onCloudConfig",value:function(){var e=this,t="".concat(this._n,"._onCloudConfig"),n=this.getCloudConfig("upload_size_limit"),s=this.getCloudConfig("simple_cos"),i=this.getCloudConfig("file_dn_list");if(Be.l("".concat(t," uploadSizeLimit:").concat(n," simpleCos:").concat(s)),!gt(n))try{var a=JSON.parse(n);this.UPLOAD_SIZE_LIMIT={A:a.a?1048576*parseInt(a.a):this.UPLOAD_SIZE_LIMIT.A,F:a.f?1048576*parseInt(a.f):this.UPLOAD_SIZE_LIMIT.F,I:a.i?1048576*parseInt(a.i):this.UPLOAD_SIZE_LIMIT.I,V:a.v?1048576*parseInt(a.v):this.UPLOAD_SIZE_LIMIT.V}}catch(e){}if(gt(s)||(this.isSimpleCos="1"===s),!gt(i))try{JSON.parse(i).forEach((function(t){e._fileDNList.includes(t)||e._fileDNList.push(t)}))}catch(e){}}},{key:"_getAuthorizationKey",value:function(){var e=this,t="".concat(this._n,".").concat("_getAuthorizationKey"),n=new Gs("_getAuthorizationKey"),s=Math.ceil(Date.now()/1e3);this.req({P:Cs.COS_SIGN,data:{duration:this.expiredTimeLimit}}).then((function(i){var a=i.data;Be.l("".concat(t," ok. data:"),a);var o=a.expiredTime-s;n.setMessage("requestId:".concat(a.requestId," requestTime:").concat(s," expiredTime:").concat(a.expiredTime," diff:").concat(o,"s")).end(),!ue&&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},Be.l("".concat(t," ok. region:").concat(e.region," bucketName:").concat(e.bucketName)),e._initUploaderMethod()})).catch((function(e){n.setError(e).end(),Be.w("".concat(t," failed. error:"),e)}))}},{key:"_getCosPreSigUrl",value:function(e){var t=this,n="".concat(this._n,".").concat("_getCosPreSigUrl"),s=Math.ceil(Date.now()/1e3),i=new Gs("_getCosPreSigUrl"),a={uploadMethod:e.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:e.userID,conversationType:e.conversationType,uploadConfig:[{fileID:1,fileType:e.fileType,fileName:e.fileName}]},o=Cs.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(a={fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration},o=Cs.COS_PRE_SIG),this.req({P:o,data:a}).then((function(e){t.tryCount=0;var a=e.data||{};Be.l("".concat(n," ok. isSimpleCos:").concat(t.isSimpleCos," data:"),a);var o="";if(t.isSimpleCos){var r=a.preSig[0],c=r.uploadUrl,u=r.fileKey;o="uploadIP:".concat(a.uploadIP," uploadUrl:").concat(c," fileKey:").concat(u," cost:").concat(en(s))}else o="requestId:".concat(a.requestId," expiredTime:").concat(a.expiredTime," diff:").concat(a.expiredTime-s,"s");return i.setMessage(o).end(),a})).catch((function(s){return-1===s.code&&(s.code=_s.COS_GET_SIG_FAIL),i.setError(s).end(),Be.w("".concat(n," failed. error:"),s),t.tryCount<1?(t.tryCount++,t._getCosPreSigUrl(e)):(t.tryCount=0,Is({code:_s.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=ue?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=ue?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:"getFileDNList",value:function(){return this._fileDNList}},{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._relayFlag)return Promise.resolve();var t=this.get(as);switch(e.type){case D.MSG_IMAGE:return t.addTotalCount(Rs),this._uploadImage(e);case D.MSG_FILE:return t.addTotalCount(Rs),this._uploadFile(e);case D.MSG_AUDIO:return t.addTotalCount(Rs),this._uploadAudio(e);case D.MSG_VIDEO:return t.addTotalCount(Rs),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var t=this,n=this.get(xn),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadImage({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),ft(i.onProgress))try{i.onProgress(e)}catch(e){return Is({code:_s.MSG_ONPROGRESS_ERR})}}}).then((function(n){var i=n.location,a=n.fileType,o=n.fileSize,r=n.width,c=n.height,u=n.smallImageUrl,l=n.smallImageWidth,d=n.smallImageHeight,h=n.largeImageUrl,g=n.largeImageWidth,p=n.largeImageHeight,f=n.imageInfoArray,v=t.isPrivateNetWork()?i:Ot(i);s.updateImageFormat(a);var m,y,I={size:o,url:v,width:r,height:c};if(f&&f.length>0)for(var M=0;M<f.length;M++){var C=f[M];1===C.type?m=C:2===C.type?y=C:I=_(_({},I),C)}else u&&h?(m={url:u,width:l,height:d},y={url:h,width:g,height:p}):(m=Kt({originUrl:v,originWidth:r,originHeight:c,min:198}),y=Kt({originUrl:v,originWidth:r,originHeight:c,min:720}));return s.updateImageInfoArray([_({},I),_({},y),_({},m)]),e}))}},{key:"_uploadFile",value:function(e){var t=this,n=this.get(xn),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadFile({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),ft(i.onProgress))try{i.onProgress(e)}catch(e){return Is({code:_s.MSG_ONPROGRESS_ERR})}}}).then((function(n){var i=n.location,a=i;return t.isPrivateNetWork()||(a=xs(a=Ot(i),t._fileDownloadProxy,t._authKey,t._fileDNList)),s.updateFileUrl(a),e}))}},{key:"_uploadAudio",value:function(e){var t=this,n=this.get(xn),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadAudio({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),ft(i.onProgress))try{i.onProgress(e)}catch(e){return Is({code:_s.MSG_ONPROGRESS_ERR})}}}).then((function(n){var i=n.location,a=t.isPrivateNetWork()?i:Ot(i);return s.updateAudioUrl(a),e}))}},{key:"_uploadVideo",value:function(e){var t=this,n=this.get(xn),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadVideo({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),ft(i.onProgress))try{i.onProgress(e)}catch(e){return Is({code:_s.MSG_ONPROGRESS_ERR})}}}).then((function(n){var i=n.location,a=n.snapshotInfo,o=t.isPrivateNetWork()?i:Ot(i);return s.updateVideoUrl(o),st(a)||s.updateSnapshotInfo(a),e}))}},{key:"_checkSizeError",value:function(e){var t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),Is({code:_s["MSG_".concat(e,"_SIZE_LIMIT")],message:this.getErrMsg("UploadSizeLimit",t,"".concat(this.UPLOAD_SIZE_LIMIT[e]/1048576,"MB"))})}},{key:"doUploadImage",value:function(e){var t=this;if(!e.file||this._isEmptyFileList(e.file.files))return Is({code:_s.MSG_I_SELECT_F_FIRST});var n=this._checkImageType(e.file);if(!0!==n)return n;var s=this._checkImageSize(e.file);if(!0!==s)return s;var i=null;return this._setUploadFileType(Ti),this.uploadByCOS(e).then((function(n){if(i=n,t.isPrivateNetWork())return Ft(n.location);if(ht(i.imageInfoArray)){var s=i.imageInfoArray.find((function(e){return 3===e.type}));if(s)return s}if(de)return{width:e.file.width,height:e.file.height};var a=Ot(n.location);return t.COSSDK?Ft(a):Ft(a=xs(a,t._fileDownloadProxy,t._authKey,t._fileDNList))})).then((function(e){return i.width=e.width,i.height=e.height,Promise.resolve(i)}))}},{key:"_checkImageType",value:function(e){var t="";return t=ue?e.url.slice(e.url.lastIndexOf(".")+1):de?e.type.split("/")[1]:e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),Mi.indexOf(t.toLowerCase())>=0||Is({code:_s.MSG_I_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=ue||de?e.size:e.files[0].size)?Is({code:_s.MSG_F_IS_EMPTY}):t<this.UPLOAD_SIZE_LIMIT.I||this._checkSizeError("I")}},{key:"doUploadFile",value:function(e){return!e.file||this._isEmptyFileList(e.file.files)?Is({code:_s.MSG_F_SELECT_F_FIRST}):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?Is({code:_s.MSG_F_IS_EMPTY}):(this._setUploadFileType(ki),this.uploadByCOS(e))}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?Is({code:_s.MSG_F_IS_EMPTY}):-1===Ci.indexOf(e.file.videoFile.type)?Is({code:_s.MSG_V_TYPES_LIMIT}):(this._setUploadFileType(Si),ue||de?this.handleVideoUpload(_(_({},e),{},{file:e.file.videoFile})):he?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(n,s){t.uploadByCOS(e).then((function(e){n(e)})).catch((function(){t.uploadByCOS(e).then((function(e){n(e)})).catch((function(){s(new fs({code:_s.MSG_V_UPLOAD_FAIL}))}))}))}))}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?Is({code:_s.MSG_F_IS_EMPTY}):(this._setUploadFileType(Ei),this.uploadByCOS(e)):Is({code:_s.MSG_A_UPLOAD_FAIL})}},{key:"uploadByCOS",value:function(e){var t=this;if(!ft(this._cosUploadMethod))return this.warn("PluginUndetected"),Is({code:_s.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);var n=new Gs("upload"),s="".concat(this._n,".uploadByCOS"),i=Date.now(),a=this._getFile(e);return new Promise((function(o,r){var c=ue?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),u=t;t._cosUploadMethod(c,(function(e,c){var l=Object.create(null);if(c){if(e||ht(c.files)&&c.files[0].error){var d=new fs({code:_s.MSG_F_UPLOAD_FAIL});return n.setError(d).end(),Be.l("".concat(s," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&t._getAuthorizationKey(),void r(d)}l.fileName=a.name,l.fileSize=a.size,l.fileType=a.type.slice(a.type.indexOf("/")+1).toLowerCase(),l.location=ue?c.Location:c.files[0].data.Location;var h=Date.now()-i,g=u._formatFileSize(a.size),p=u._formatSpeed(1e3*a.size/h),f="size:".concat(g," time:").concat(h,"ms speed:").concat(p);Be.l("".concat(s," success. name:").concat(a.name," ").concat(f)),o(l);var _=t.get(as);return _.addCost(Rs,h),_.addFileSize(Rs,a.size),void n.setMessage(f).end()}var v=new fs({code:_s.MSG_F_UPLOAD_FAIL});n.setError(v).end(),Be.w("".concat(s," failed. error:"),e),403===e.statusCode&&t._getAuthorizationKey(),r(v)}))}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,n="".concat(this._n,"._uploadWithPreSigUrl"),s=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((function(e){return new Promise((function(i,a){var o=new Gs("upload"),r=e.existFlag,c=v(e,na),u=Date.now();1!==r?t._cosUploadMethod(c,(function(r,c){if(r||403===c.statusCode){var l="".concat(gt(r)?"":JSON.stringify(r)," ").concat(gt(c)?"":JSON.stringify(c));o.setMessage(l).end();var d={HttpStatusCode:sa,CostTime:en(u,!1),error:r,url:e.url};return c.data&&c.data.uploadIP&&(d.uploadIP=c.data.uploadIP),t._uploadSSOLog(d),Be.l("".concat(n," failed, error:").concat(l)),void a(new fs({code:_s.MSG_F_UPLOAD_FAIL}))}t._handleUploadSuccessResult({ssoLog:o,startTs:u,file:s,uploadOptions:e,uploadResult:c},i)})):t._handleUploadSuccessResult({ssoLog:o,startTs:u,file:s,uploadOptions:e,uploadResult:{data:{location:c.downloadUrl,statusCode:200}}},i)}))}))}},{key:"_handleUploadSuccessResult",value:function(e,t){var n=e.ssoLog,s=e.startTs,i=e.file,a=e.uploadOptions,o=a.existFlag,r=a.fileType,c=a.url,u=a.downloadUrl,l=a.requestSnapshotUrl,d=a.thumbUrl,h=a.largeUrl,g=a.imageInfoArray,p=void 0===g?[]:g,f=e.uploadResult,_=Object.create(null),v=f.data.location||"";this.isPrivateNetWork()||0!==v.indexOf("https://")&&0!==v.indexOf("http://")||(v=v.split("//")[1]),_.fileName=i.name,_.fileSize=i.size,_.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),_.location=v;var m=en(s,!1),y=this._formatFileSize(i.size),I=this._formatSpeed(1e3*i.size/(m||1)),M="exist:".concat(o," fileType:").concat(r," bytes:").concat(i.size," size:").concat(y," time:").concat(m,"ms speed:").concat(I," res:").concat(JSON.stringify(f));Be.l("".concat(this._n,"._uploadWithPreSigUrl ok. name:").concat(i.name," ").concat(M)),n.setMessage(M).end();var C={HttpStatusCode:f.statusCode,FileSize:i.size,CostTime:m,url:c};f.data&&f.data.uploadIP&&(C.uploadIP=f.data.uploadIP),this._uploadSSOLog(C);var T=this.get(as);if(T.addCost(Rs,m),T.addFileSize(Rs,i.size),1===o){if(p.length>0)return _.imageInfoArray=p,void t(_);if(l)return this._getSnapshotInfoByUrl(l,_).then((function(){t(_)}))}var S=[];if(d&&h&&S.push.apply(S,[this._getSmallImageInfoByUrl(d,_),this._getLargeImageInfoByUrl(h,_)]),this.isSimpleCos&&r===Ti&&!this.isPrivateNetWork()&&(S.push(this._getImageInfoArray(u,_)),f.data.uploadIP&&S.push(this._getDownloadIP(u.split("//")[1].split("/")[0],_))),l&&S.push(this._getSnapshotInfoByUrl(l,_)),S.length>0)return Promise.all(S).then((function(){t(_)}));t(_)}},{key:"_getDownloadIP",value:function(e,t){var n="".concat(this._n,"._getDownloadIP"),s=Date.now();return this.req({P:Cs.GET_IP,data:{domainName:e}}).then((function(e){if(e.data&&e.data.ip){Be.l("".concat(n," ok. downloadIP:").concat(e.data.ip," cost:").concat(en(s)));var i=t.location.split("/");i[0]=e.data.ip,t.location=i.join("/")}})).catch((function(e){}))}},{key:"_getImageInfoArray",value:function(e,t){var n=this,s="".concat(this._n,"._getImageInfoArray"),i=Date.now();return this.req({P:Cs.GET_IMAGE_INFO,data:{imageUrl:e}}).then((function(e){var n=e.data||{};return Be.l("".concat(s," ok. data: ").concat(JSON.stringify(n)," cost:").concat(en(i))),t.imageInfoArray=n.imageInfoArray,n})).catch((function(s){t.imageInfoArray=void 0,n._uploadSSOLog({HttpStatusCode:ia,CostTime:en(i,!1),url:e})}))}},{key:"_uploadSSOLog",value:function(e){if(this.isSimpleCos){var t=new Gs;t.setEventType(18),e.error&&t.setError(new fs(e.error));var n="HttpStatusCode:".concat(e.HttpStatusCode,"|CosRequestId:").concat(e.CosRequestId||"","|")+"FileAlreadyExist:".concat(e.FileAlreadyExist||0,"|FileSize:").concat(e.FileSize||0,"|CostTime:").concat(e.CostTime);e.uploadIP&&(n+="|FinalIP:".concat(e.uploadIP)),t.setMessage("OK").setMoreMessage(e.url).setExtension(n).end()}}},{key:"_getRawOrUploadProxyUrl",value:function(e){var t=this.get(Wn).getFileUploadProxy(),n=e;return t&&(n=e.replace(/^https:\/\/[^/]+/,t)),n}},{key:"_getFile",value:function(e){return ht(e.file.files)||vt(e.file.files)?e.file.files[0]:e.file}},{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?Bt(e/1024,1)+"KB/s":Bt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=this._getFile(e),n=t.name,s=n.slice(n.lastIndexOf(".")),i=this._genFileName("".concat(Tt(999999)).concat(s));return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(i),Body:t}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(e){Be.w("onProgress callback error:",e)}},onFileFinish:function(e,t,n){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),n=this._genFileName(t.name),s=t.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),FilePath:s,onProgress:function(t){if(Be.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(e){Be.w("onProgress callback error:",e)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t=this,n=e.customFileName,s="",i=0,a=this._getFile(e);if(ue||de){if(gt(n))if(e.message.type===D.MSG_FILE||e.message.type===D.MSG_VIDEO){var o=a.name,r=o.slice(o.lastIndexOf("."));n=this._genFileName("".concat(Tt(999999)).concat(r))}else n=this._genFileName(a.name);s=a.url,i=1}else{if(gt(n)){var c=a.name,u=c.slice(c.lastIndexOf("."));n=this._genFileName("".concat(Tt(999999)).concat(u))}s=a,i=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:n,uploadMethod:i,duration:this.duration,userID:e.message.from,conversationType:Pt(e.message.conversationID)?1:2}).then((function(i){var a=t.isSimpleCos?i.preSig[0]:i,o=a.uploadUrl,r=a.downloadUrl,c=a.requestSnapshotUrl,u=void 0===c?void 0:c,l=a.thumbUrl,d=a.largeUrl,h=a.fileKey,g=a.existFlag,p=void 0===g?0:g,f=a.imageInfoArray,_=void 0===f?void 0:f,v=i.uploadIP,m=void 0===v?"":v;return{url:t._getRawOrUploadProxyUrl(o),fileType:t.uploadFileType,fileName:n,resources:s,downloadUrl:r,requestSnapshotUrl:u,thumbUrl:l,largeUrl:d,fileKey:h,existFlag:p,imageInfoArray:_,uploadIP:!t.isPrivateNetWork()&&m,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(e){Be.w("onProgress callback error:",e),Be.e(e)}}}}))}},{key:"_genFileName",value:function(e){return"".concat(xt(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e,t){var n=this,s="_getSnapshotInfoByUrl",i=new Gs(s);return this.req({P:Cs.VIDEO_COVER,data:{platform:this.getPlatform(),coverName:this._genFileName(Tt(99999)),requestSnapshotUrl:e}}).then((function(e){var a=(e.data||{}).snapshotUrl;if(Be.l("".concat(n._n,".").concat(s," ok. snapshotUrl:").concat(a)),i.setMessage("snapshotUrl:".concat(a)).end(),st(a))return{};var o=xs(a,n._fileDownloadProxy,n._authKey,n._fileDNList);return Ft(o).then((function(e){t.snapshotInfo={snapshotUrl:o,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((function(e){return Be.w("".concat(n._n,".").concat(s," failed. error:"),e),i.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}}))}},{key:"_getSmallImageInfoByUrl",value:function(e,t){return Ft(xs(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then((function(n){t.smallImageUrl=e,t.smallImageWidth=n.width,t.smallImageHeight=n.height}))}},{key:"_getLargeImageInfoByUrl",value:function(e,t){return Ft(xs(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then((function(n){t.largeImageUrl=e,t.largeImageWidth=n.width,t.largeImageHeight=n.height}))}},{key:"_isEmptyFileList",value:function(e){return!(!vt(e)||0!==e.length)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}])}(Ms),oa=["downloadKey","pbDownloadKey","messageList"],ra=r((function e(t){i(this,e),this._n="MergerMessageHandler",this._msgM=t}),[{key:"uploadMergerMessage",value:function(e,t){var n="".concat(this._n,".").concat("uploadMergerMessage");Be.d("".concat(n," message:"),e,"messageBytes:".concat(t));var s=JSON.parse(JSON.stringify(e.payload)).messageList,i=s.length,a=this._msgM.get(Xn).getFileDNList(),o=new Gs("uploadMergerMessage");return s.forEach((function(e){Vs(e.messageBody[0].type,e.messageBody,a)})),this._msgM.req({P:Cs.UPLOAD_MERGER_MSG,data:{messageList:s}}).then((function(e){Be.d("".concat(n," ok. response:"),e.data);var s=e.data,a=s.pbDownloadKey,r=s.downloadKey,c={pbDownloadKey:a,downloadKey:r,messageNumber:i};return o.setMessage("".concat(i,"-").concat(t,"-").concat(r)).end(),c})).catch((function(e){throw Be.w("".concat(n," failed. error:"),e),o.setError(e).end(),e}))}},{key:"downloadMergerMessage",value:function(e){var t=this,n="".concat(this._n,".").concat("downloadMergerMessage");Be.d("".concat(n," message:"),e);var s=e.payload.downloadKey,i=this._msgM.getFileDownloadProxy(),a=this._msgM.getDownloadFileAuthKey(),o=new Gs("downloadMergerMessage");return o.setMessage("downloadKey:".concat(s)),this._msgM.req({P:Cs.DOWNLOAD_MERGER_MSG,data:{downloadKey:s}}).then((function(s){Be.d("".concat(n," ok. response:"),s.data);var r=t._msgM.get(Xn).getFileDNList();if(ft(e.clearElement)){var c=e.payload;c.downloadKey,c.pbDownloadKey,c.messageList;var u=v(c,oa);e.clearElement(),e.setElement({type:e.type,content:_({messageList:s.data.messageList},u)},i,a,r)}else{var l=[];s.data.messageList.forEach((function(e){if(!st(e)){var t=new ei(e,i,a,r);l.push(t)}})),e.payload.messageList=l,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return o.end(),e})).catch((function(e){throw Be.w("".concat(n," failed. key:").concat(s," error:"),e),o.setError(e).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 s=null;t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly&&(s?s.disablePush=!0:s={disablePush:!0}));var i=[];if(dt(t)&&dt(t.messageControlInfo)){var a=t.messageControlInfo,o=a.excludedFromUnreadCount,r=a.excludedFromLastMessage,c=a.excludedFromContentModeration;!0===o&&i.push("NoUnread"),!0===r&&i.push("NoLastMsg"),!0===c&&i.push("NoMsgCheck")}var u="";ut(e.cloudCustomData)&&e.cloudCustomData.length>0&&(u=e.cloudCustomData);var l=n.pbDownloadKey,d=n.downloadKey,h=n.messageNumber,g=e.payload,p=g.title,f=g.abstractList,_=g.compatibleText,v=this._msgM.get(Kn),m=v&&v.isOnlineMessage(e,t)?0:void 0;return{P:Cs.SEND_C2C_MSG,data:{fromAccount:this._msgM.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:l,downloadKey:d,title:p,abstractList:f,compatibleText:_,messageNumber:h}}],cloudCustomData:u,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:m,offlinePushInfo:_i(s),messageControlInfo:0!==m?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,n){var s=null;t&&t.offlinePushInfo&&(s=t.offlinePushInfo);var i=[];if(dt(t)&&dt(t.messageControlInfo)){var a=t.messageControlInfo,o=a.excludedFromUnreadCount,r=a.excludedFromLastMessage,c=a.excludedFromContentModeration;!0===o&&i.push("NoUnread"),!0===r&&i.push("NoLastMsg"),!0===c&&i.push("NoMsgCheck")}var u="";ut(e.cloudCustomData)&&e.cloudCustomData.length>0&&(u=e.cloudCustomData);var l=n.pbDownloadKey,d=n.downloadKey,h=n.messageNumber,g=e.payload,p=g.title,f=g.abstractList,_=g.compatibleText,v=this._msgM.get(Hn),m=v&&v.isOnlineMessage(e,t)?1:0;return{P:Cs.SEND_GRP_MSG,data:{fromAccount:this._msgM.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:l,downloadKey:d,title:p,abstractList:f,compatibleText:_,messageNumber:h}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:u,onlineOnlyFlag:m,offlinePushInfo:_i(s),clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||v.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0===m?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}]),ca={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},ua=[_s.MSG_ONPROGRESS_ERR,_s.MSG_I_SELECT_F_FIRST,_s.MSG_I_TYPES_LIMIT,_s.MSG_F_IS_EMPTY,_s.MSG_I_SIZE_LIMIT,_s.MSG_F_SELECT_F_FIRST,_s.MSG_F_SIZE_LIMIT,_s.MSG_V_SIZE_LIMIT,_s.MSG_V_TYPES_LIMIT,_s.MSG_A_UPLOAD_FAIL,_s.MSG_A_SIZE_LIMIT,_s.COS_UNDETECTED],la=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="MessageModule",s._messageOptionsMap=new Map,s._mergerMessageHandler=new ra(s),s}return d(t,e),r(t,[{key:"createTextMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new ri(e),s=ut(e.payload)?e.payload:e.payload.text,i=new Fs({text:s}),a=this._getNickAndAvatarByUserID(t);return n.setElement(i),n.setNickAndAvatar(a),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new ri(e);if(ue){var s=e.payload.file;if(rt(s))return void this.warn("FileUnsupportedInMP","createImageMessage");var i=s.tempFiles[0].path||s.tempFiles[0].tempFilePath,a={url:i,name:i.slice(i.lastIndexOf("/")+1),size:s.tempFiles&&s.tempFiles[0].size||1,type:i.slice(i.lastIndexOf(".")+1).toLowerCase()};e.payload.file=a}else if(de){var o=e.payload.file,r={url:o.uri,name:o.fileName,size:o.fileSize||1,type:o.type,width:o.width,height:o.height};e.payload.file=r}else if(he)if(rt(e.payload.file)){var c=e.payload.file;e.payload.file={files:[c]}}else if(dt(e.payload.file)&&"undefined"!=typeof uni){var u=e.payload.file.tempFiles[0];e.payload.file={files:[u]}}var l=this.get(Xn).getFileDNList(),d=new Hs({imageFormat:Ye.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),l),h=this._getNickAndAvatarByUserID(t);return n.setElement(d),n.setNickAndAvatar(h),n.setNameCard(this._getNameCardByGroupID(n)),this._messageOptionsMap.set(n.clientSequence,e),n}},{key:"createAudioMessage",value:function(e){var t=e.payload.file;if(ue){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}if(de){var s={url:t.uri,name:t.uri.slice(t.uri.lastIndexOf("/")+1),size:t.fileSize||1,second:Math.floor(t.duration/1e3),type:t.uri.slice(t.uri.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s,st(t.uri)&&this.warn("VoiceFileInRN")}var i=this.getMyUserID();e.currentUser=i,e.senderTinyID=this.getMyTinyID();var a=this.get(Xn).getFileDNList(),o=new ri(e),r=new Bs({second:Math.floor(t.duration/1e3),size:t.fileSize||t.size||1,url:t.tempFilePath||t.uri,uuid:this._generateUUID(e.payload.file)},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),a),c=this._getNickAndAvatarByUserID(i);return o.setElement(r),o.setNickAndAvatar(c),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,e),o}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="",e.payload.file.thumbSize=0;var n={};if(ue){if(rt(e.payload.file))return void this.warn("FileUnsupportedInMP","createVideoMessage");var s=e.payload.file;ht(s.tempFiles)&&(s=s.tempFiles[0]),n.url=s.tempFilePath,n.name=s.tempFilePath.slice(s.tempFilePath.lastIndexOf("/")+1),n.size=s.size||1,n.second=s.duration||0,n.type=s.tempFilePath.slice(s.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(de){var i=e.payload.file;n.url=i.uri,n.name=i.fileName,n.size=i.fileSize||1,n.second=i.duration||0,n.type=i.type.split("/")[1]}else if(he){if(rt(e.payload.file)){var a=e.payload.file;e.payload.file.files=[a]}else if(dt(e.payload.file)&&"undefined"!=typeof uni){var o=e.payload.file.tempFile;e.payload.file.files=[o]}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||1,n.second=r.files[0].duration||0,n.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=n;var c=this.get(Xn).getFileDNList(),u=new ri(e),l=new Zs({videoFormat:n.type,videoSecond:Bt(n.second,0),videoSize:n.size,remoteVideoUrl:"",videoUrl:n.url,videoUUID:this._generateUUID(e.payload.file.videoFile),thumbUUID:this._generateUUID(e.payload.file.videoFile,"jpg"),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:"jpg"},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),c),d=this._getNickAndAvatarByUserID(t);return u.setElement(l),u.setNickAndAvatar(d),u.setNameCard(this._getNameCardByGroupID(u)),this._messageOptionsMap.set(u.clientSequence,e),u}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new ri(e),s=new Xs({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),i=this._getNickAndAvatarByUserID(t);return n.setElement(s),n.setNickAndAvatar(i),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 ri(e),s=new js(e.payload),i=this._getNickAndAvatarByUserID(t);return n.setElement(s),n.setNickAndAvatar(i),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),s=new ri(e),i=new ti(e.payload);return s.setElement(i),s.setNickAndAvatar(n),s.setNameCard(this._getNameCardByGroupID(s)),s.setRelayFlag(!0),s}},{key:"createForwardMessage",value:function(e){var t=e.to,n=e.conversationType,s=e.priority,i=e.payload,a=e.needReadReceipt,o=e.receiverList;if(!ht(i._elements))return Is({code:_s.MSG_FORWARD_INVALID_ELEMENTS});var r=this.getMyUserID(),c=this._getNickAndAvatarByUserID(r);if(i.type===D.MSG_GRP_TIP)return Is({code:_s.MSG_FORWARD_TYPE_INVALID});var u={to:t,conversationType:n,conversationID:"".concat(n).concat(t),priority:s,isPlaceMessage:0,status:an,currentUser:r,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||i.cloudCustomData||"",needReadReceipt:a,receiverList:o,isSupportExtension:e.isSupportExtension||!1},l=new ri(u);return l.setElement(i._elements[0]),l.setNickAndAvatar(c),l.setNameCard(this._getNameCardByGroupID(i)),l.setRelayFlag(!0),l}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if(ue){if(!Q&&!te&&!oe)return;var t=ge.getSystemInfoSync().SDKVersion;if(Q&&qt(t,"2.5.0")<0)return void this.warn("WXChooseMessageFile");if(te&&qt(t,"1.18.0")<0)return void this.warn("QQChooseMessageFile")}if(he||oe){if(rt(e.payload.file)){var n=e.payload.file;e.payload.file={files:[n]}}else if(dt(e.payload.file)&&"undefined"!=typeof uni){var s=e.payload.file,i=s.tempFiles,a=s.files,o=null;ht(i)?o=i[0]:ht(a)&&(o=a[0]),e.payload.file={files:[o]}}}else if(Q||te){var r=e.payload.file.tempFiles,c=_(_({},r[0]),{},{url:r[0].path});e.payload.file={files:[c]}}else if(de){var u=e.payload.file,l=_(_({},u),{},{url:u.uri});e.payload.file={files:[l]}}var d=this.getMyUserID();e.currentUser=d,e.senderTinyID=this.getMyTinyID();var h=new ri(e),g=new Js({uuid:this._generateUUID(e.payload.file),file:e.payload.file}),p=this._getNickAndAvatarByUserID(d);return h.setElement(g),h.setNickAndAvatar(p),h.setNameCard(this._getNameCardByGroupID(h)),this._messageOptionsMap.set(h.clientSequence,e),h}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID();var n=new ri(e),s=new Qs(e.payload),i=this._getNickAndAvatarByUserID(t);return n.setElement(s),n.setNickAndAvatar(i),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"_onNoModule",value:function(){return Is({code:_s.NO_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var n=this,s=null;if(e.conversationType===D.CONV_C2C)s=this.get(Kn);else{if(e.conversationType!==D.CONV_GROUP)return Is({code:_s.MSG_INVALID_CONV_TYPE});s=this.get(Hn)}if(!s)return this._onNoModule();var i,a="".concat(this._n,".sendMessageInstance"),o=this.get(Yn),r=s.isOnlineMessage(e,t);return this.get(Xn).upload(e).then((function(){return n._getSendMessageSpecifiedKey(e)===Os&&n.get(as).addSuccessCount(Rs),n._guardForGroup(e).then((function(){if(!e.isSendable())return Is({code:_s.MSG_F_URL_IS_EMPTY});n._addSendMessageTotalCount(e),i=Date.now();var a=function(e){var t="utf-8";he&&document&&(t=document.charset.toLowerCase());var n,s,i=0;if(s=e.length,"utf-8"===t||"utf8"===t)for(var a=0;a<s;a++)(n=e.codePointAt(a))<=127?i+=1:n<=2047?i+=2:n<=65535?i+=3:(i+=4,a++);else if("utf-16"===t||"utf16"===t)for(var o=0;o<s;o++)(n=e.codePointAt(o))<=65535?i+=2:(i+=4,o++);else i=e.replace(/[^\x00-\xff]/g,"aa").length;return i}(JSON.stringify(e));return e.type===D.MSG_MERGER&&a>11264?n._mergerMessageHandler.uploadMergerMessage(e,a).then((function(s){var i=n._mergerMessageHandler.createMergerMessagePack(e,t,s);return n.req(i)})):(o.setMessageRandom(e),s.sendMessage(e,t))})).then((function(s){var c=s.data,u=c.time,l=c.sequence,d=c.readReceiptCode,h=c.messageDropReason;if(ct(d)&&0!==d&&(new Gs("sendMessageWithReceipt").setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(l," readReceiptCode:").concat(d)).end(),Be.w("".concat(a," readReceiptCode:").concat(d," message:").concat(n.getErrMsg(d)))),h){var g=new Gs("messageDropReason"),p="from:".concat(e.from," to:").concat(e.to," sequence:").concat(l," messageDropReason:").concat(h);g.setMessage(p).end(),Be.w("".concat(a," ").concat(p))}if(n._addSendMessageSuccessCount(e,i),n._messageOptionsMap.delete(e.clientSequence),!0===e.isResend){var f=o.findMessage(e.ID);f&&(Be.l("".concat(a," resend ok. ID:").concat(f.ID)),o.deleteLocalMessage(f))}e.status=on,e.time=u;var _=!1;if(e.conversationType===D.CONV_GROUP)e.sequence=l;else if(e.conversationType===D.CONV_C2C){var v=o.getLatestMessageSentByMe(e.conversationID);if(v){var m=v.nick,y=v.avatar;m===e.nick&&y===e.avatar||(_=!0)}}if(_&&o.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),!0===r)e._onlineOnlyFlag=!0;else{o.appendToMessageList(e);var I=e;dt(t)&&dt(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,I=""),!0===t.messageControlInfo.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0));var M=e.conversationType;Ut(e.to)&&(M=D.CONV_TOPIC,n.get(Bn).onMessageSent({groupID:zt(e.to),topicID:e.to,lastMessage:I})),o.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:M,subType:e.conversationSubType,lastMessage:I}]})}return e._relayFlag||"TIMImageElem"!==e.type||Ht(e.payload.imageInfoArray),ps({message:e})}))})).catch((function(t){return n._onSendMessageFailed(e,t,r)}))}},{key:"_guardForGroup",value:function(e){if(e.conversationType!==D.CONV_GROUP)return Promise.resolve();var t=this.get(Hn);if(!t)return this._onNoModule();if(Lt({groupID:e.to})){var n=t.getLocalGroupProfile(e.to);if(n&&n.isSupportTopic)return Is({code:_s.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return t.guardForAVChatRoom(e)}},{key:"_onSendMessageFailed",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s="".concat(this._n,"._onSendMessageFailed");e.status=rn,80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0);var i=this.get(Yn);i.deleteMessageRandom(e);var a=t.code>=10100&&t.code<=10200||t.code>=120001&&t.code<=13e4;n||a||!0===i.appendToMessageList(e)&&Be.l("".concat(s," message stored, ID:").concat(e.ID)),this._addSendMessageFailCountOnUser(e,t);var o=new Gs("sendMessage"),r="head.seq:".concat(t.data.headSeq," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to);if(he){if("connection"in navigator){var c=navigator.connection;r+=" downlink:".concat(c.downlink," effectiveType:").concat(c.effectiveType," rtt:").concat(c.rtt)}if("memory"in window.performance){var u=window.performance.memory;r+=" usedJSHeapSize:".concat(u.usedJSHeapSize," totalJSHeapSize:").concat(u.totalJSHeapSize," jsHeapSizeLimit:").concat(u.jsHeapSizeLimit)}}return o.setMessage(r).setError(t).end(),Be.e("".concat(s," ").concat(r," error:"),t),Is(new fs({code:t&&t.code?t.code:_s.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,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 Os;if(e.conversationType===D.CONV_C2C)return Es;if(e.conversationType===D.CONV_GROUP){var t=this.get(Hn);if(!t)return;var n=t.getLocalGroupProfile(e.to);if(!n)return;var s=n.type;return Nt(s)?Ds:ks}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this._getSendMessageSpecifiedKey(e);t&&this.get(as).addTotalCount(t)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var n=this._getSendMessageSpecifiedKey(e);if(n){var s=this.get(as);s.addSuccessCount(n),s.addCost(n,en(t,!1))}}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){var n,s,i=t.code,a=void 0===i?-1:i,o=this.get(as),r=this._getSendMessageSpecifiedKey(e);r===Os&&(n=a,s=!1,ua.includes(n)&&(s=!0),s)?o.addFailedCountOfUserSide(Rs):function(e){var t=!1;return Object.values(ca).includes(e)&&(t=!0),(e>=120001&&e<=13e4||e>=10100&&e<=10200)&&(t=!0),t}(a)&&r&&o.addFailedCountOfUserSide(r)}},{key:"resendMessage",value:function(e,t){return e.isResend=!0,e.status=an,this.sendMessageInstance(e,t)}},{key:"revokeMessage",value:function(e){var t=this,n=null;if(e.conversationType===D.CONV_C2C?n=this.get(Kn):e.conversationType===D.CONV_GROUP&&(n=this.get(Hn)),!n)return this._onNoModule();var s=new Gs("revokeMessage");s.setMessage("type:".concat(e.type," from:").concat(e.from," to:").concat(e.to));var i="".concat(this._n,".").concat("revokeMessage");return n.revokeMessage(e).then((function(n){var a=n.data.recallRetList;if(!st(a)&&0!==a[0].retCode){var o=new fs({code:a[0].retCode,data:{message:e}});return s.setCode(o.code).setMoreMessage(o.message).end(),Is(o)}return Be.i("".concat(i," ok. ID:").concat(e.ID)),e.isRevoked=!0,s.end(),t.get(Yn).onMessageRevoked([e]),ps({message:e})})).catch((function(t){s.setError(t).end();var n=new fs({code:t&&t.code?t.code:_s.MSG_REVOKE_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}});return Be.w("".concat(i," failed. error:"),t),Is(n)}))}},{key:"deleteMessage",value:function(e){var t=this,n=null,s=e[0],i=s.conversationID,a="",o=[],r=[];if(s.conversationType===D.CONV_C2C)n=this.get(Kn),a=i.replace(D.CONV_C2C,""),e.forEach((function(e){e&&e.status===on&&e.conversationID===i&&(e._onlineOnlyFlag||o.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),r.push(e))}));else if(s.conversationType===D.CONV_GROUP)n=this.get(Hn),a=i.replace(D.CONV_GROUP,""),e.forEach((function(e){e&&e.status===on&&e.conversationID===i&&(e._onlineOnlyFlag||o.push("".concat(e.sequence)),r.push(e))}));else if(s.conversationType===D.CONV_SYSTEM)return Is({code:_s.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!n)return this._onNoModule();if(0===o.length)return this._onMessageDeleted(r);o.length>30&&(o=o.slice(0,30),r=r.slice(0,30));var c=new Gs("deleteMessage");c.setMessage("to:".concat(a," count:").concat(o.length));var u="".concat(this._n,".").concat("deleteMessage");return n.deleteMessage({to:a,keyList:o}).then((function(e){return c.end(),Be.i("".concat(u," ok")),t._onMessageDeleted(r)})).catch((function(e){c.setError(e).end(),Be.w("".concat(u," failed. error:"),e);var t=new fs({code:e&&e.code?e.code:_s.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0});return Is(t)}))}},{key:"_onMessageDeleted",value:function(e){return this.get(Yn).onMessageDeleted(e),ys({messageList:e})}},{key:"translateText",value:function(e){var t="".concat(this._n,".").concat("translateText"),n=e.sourceTextList,s=e.sourceLanguage,i=e.targetLanguage,a=new Gs("translateText");return a.setMessage("sourceLanguage:".concat(s," targetLanguage:").concat(i)),this.req({P:Cs.TRANSLATE_TEXT,data:{sourceTextList:n,source:s||"auto",target:i,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then((function(e){var n=e.data,s=n.error,i=n.requestID,o=n.translatedTextList;if(0===s.code)return a.end(),Be.i("".concat(t," ok. requestID:").concat(i)),ps({translatedTextList:o});throw _(_({},s),{},{requestID:i})})).catch((function(e){return a.setCode(e.code).setMoreMessage(e.requestID).end(),Be.w("".concat(t," failed. error:"),e),Is({code:e.code||_s.TRANSLATE_TEXT_FAIL,message:e.message})}))}},{key:"convertVoiceToText",value:function(e){var t=e.message,n=e.language,s=t.payload.url;t.from===this.getMyUserID()&&"out"===t.flow&&(s=t.payload.remoteAudioUrl);var i=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/;if(!i.test(s))return Is({code:_s.UNSUPPORTED_VOICE_FORMAT});var a=i.exec(s)[1]||"mp3",o="16k_zh-PY";n?"zh (cmn-Hans-CN)"===n?o="16k_zh":"en-US"===n?o="16k_en":"yue-Hant-HK"===n?o="16k_yue":"ja-JP"===n&&(o="16k_ja"):o="16k_zh-PY";var r="serviceType:".concat(o," url:").concat(s),c="".concat(this._n,".").concat("convertVoiceToText");Be.i("".concat(c," ").concat(r));var u=new Gs("convertVoiceToText");return u.setMessage(r),this.req({P:Cs.VOICE_TO_TEXT,data:{url:s,language:o,SDKAppID:this.getSDKAppID(),format:a}}).then((function(e){var t=e.data,n=t.error,s=t.requestID,i=t.result;if(0===n.code)return u.end(),Be.i("".concat(c," ok. requestID:").concat(s)),ps({result:i});throw _(_({},n),{},{requestID:s})})).catch((function(e){return u.setCode(e.code).setMoreMessage(e.requestID||"").end(),Be.w("".concat(c," failed. error:"),e),Is({code:_s.VOICE_TO_TEXT_FAIL})}))}},{key:"modifyRemoteMessage",value:function(e){var t=this,n=null,s=e.conversationType,i=e.to;if(s===D.CONV_C2C)n=this.get(Kn);else if(s===D.CONV_GROUP){if(!(n=this.get(Hn)))return this._onNoModule();if(n.isMessageFromOrToAVChatroom(i))return Is({code:_s.MSG_MODIFY_DISABLED_IN_AV,data:{message:e}})}var a=new Gs("modifyMessage");a.setMessage("to:".concat(i));var o="".concat(this._n,".modifyRemoteMessage");return n.modifyRemoteMessage(e).then((function(n){a.end(),Be.i("".concat(o," ok"));var s=t._onModifyRemoteMessageResp(e,n.data);return ps({message:s})})).catch((function(n){if(a.setCode(n.code).setMoreMessage(n.message).end(),Be.w("".concat(o," failed. error:"),n),20027===n.code){var s=t._onModifyRemoteMessageResp(e,n.data);return Is({code:_s.MSG_MODIFY_CONFLICT,data:{message:s}})}return Is({code:n.code,message:n.message,data:{message:e}})}))}},{key:"_onModifyRemoteMessageResp",value:function(e,t){Be.d("".concat(this._n,"._onModifyRemoteMessageResp options:"),t);var n=e.conversationType,s=e.from,i=e.to,a=e.random,o=e.sequence,r=e.time,c=t.elements,u=t.messageVersion,l=t.cloudCustomData,d=void 0===l?"":l;return this.get(Yn).onMessageModified({conversationType:n,from:s,to:i,time:r,random:a,sequence:o,elements:c,cloudCustomData:d,messageVersion:u})}},{key:"_generateUUID",value:function(e,t){var n=this.get(Wn),s="".concat(n.getSDKAppID(),"-").concat(n.getUserID(),"-").concat(function(){for(var e="",t=32;t>0;--t)e+=St[Math.floor(Math.random()*Et)];return e}());if(t)return"".concat(s,".").concat(t);var i=e;ht(e.files)&&(i=e.files[0]);var a=i.name||i.value||i.url||i.tempFilePath,o=a&&a.slice(a.lastIndexOf(".")+1);return o&&(s="".concat(s,".").concat(o)),s}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.get(qn).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===D.CONV_GROUP){var t=this.get(Hn);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._messageOptionsMap.clear()}}])}(Ms),da=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="PluginModule",s.plugins={},s}return d(t,e),r(t,[{key:"registerPlugin",value:function(e){var t=this,n="0";Object.keys(e).forEach((function(s){t.plugins[s]=e[s],"tim-upload-plugin"===s&&"function"==typeof e[s].getVersion&&(n=e[s].getVersion())})),new Gs("registerPlugin").setMessage("".concat(Object.keys(e))).setMoreMessage("version:".concat(n)).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){}}])}(Ms),ha=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="SyncUnreadMsgModule",s._cookie="",s._onlineSyncFlag=!1,s.getIEmitInst().on(mi.A2KEY_AND_TINYID_UPDATED,s._init,s),s}return d(t,e),r(t,[{key:"_init",value:function(){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,n=e.cookie,s=e.syncFlag,i=e.isOnlineSync,a="".concat(this._n,"._startSync");Be.l("".concat(a," options:"),e);var o=new Gs("syncUnread");o.setMessage(JSON.stringify(e)),this.req({P:Cs.SYNC_UNREAD_MSG,data:{cookie:n,syncFlag:s,isOnlineSync:i}}).then((function(e){var n=e.data,s=n.cookie,i=n.syncFlag,r="$cookie:".concat(s," syncFlag:").concat(i);Be.l("".concat(a," ok. ").concat(r)),t._cookie=s,o.setMoreMessage(r).end(),st(s)||(0===i||1===i?(t._dispatch(_(_({},e.data),{},{isSyncingEnded:!1})),t._startSync({cookie:s,syncFlag:i,isOnlineSync:0})):2===i&&t._dispatch(_(_({},e.data),{},{isSyncingEnded:!0})))})).catch((function(e){o.setError(e).end(),Be.e("".concat(a," failed. error:"),e)}))}},{key:"_dispatch",value:function(e){e.eventArray&&this.get(es).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}}),this.get(Kn).onNewMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded})}},{key:"syncOnNeed",value:function(){Be.l("".concat(this._n,".syncOnNeed cookie:").concat(this._cookie)),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"syncOnReconnected",value:function(){Be.l("".concat(this._n,".syncOnReconnected cookie:").concat(this._cookie)),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}])}(Ms),ga={req:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic",isWebUniapp:"is_web_uniapp",isSupportExtension:"SupportMessageExtension",messageSequence:"MsgSeq",messageKey:"MsgKey",startSequence:"startSeq",simplifiedMessage:"DownsizeFlag",isRelayMessage:"IsRelayMsg",reactionID:"Reaction",messageSequenceList:"MsgSeqList",messageKeyList:"MsgKeyList",cmConfigID:"CustomModerationConfigID",streamMessageID:"StreamMsgID",ackIndex:"AckIndex"},res:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"isWithChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified",ApplyJoinOption:"joinOption",MsgFlag:"messageRemindType",AtInfoList:"groupAtInfoList",AtFlagList:"groupAtType",AtMsgSeq:"sequence",BanDuration:"duration",BanDescription:"reason",NotVisible:"invisible",BytesTag:"tag",BytesValue:"value",RptBytesValue:"value",LatestSeq:"globalSequence",ClearSeq:"clearSequence",SupportMessageExtension:"isSupportExtension",ExtensionList:"extensions",GroupCounter:"counterList",Revoker_Account:"revoker",MsgExtensionNotify:"messageExtensionNotify",ExtensionC2cMsgInfo:"messageInfo",ExtensionGroupMsgInfo:"messageInfo",MsgOptType:"operateType",SetKVInfo:"operateResultList",DeleteKVInfo:"operateResultList",ClearKVInfo:"operateResultList",MsgKeyValue:"extensions",ClearMsgSeq:"clearSequence",MsgLastSeq:"globalSequence",InviteJoinOption:"inviteOption",MemberList_Account:"inviteeList",MsgMemberExtraInfoList:"inviteeInfoList",E:"event",GInf:"groupProfile",MCT:"clientTime",MR:"random",MP:"priority",MTS:"time",GId:"groupID",MS:"sequence",CCD:"cloudCustomData",F_Account:"from",F_Hd:"avatar",F_NN:"nick",GN:"groupName",GT:"groupType",IsSys:"isSystemMessage",OpInf:"operatorInfo",Img:"avatar",NN:"nick",OnlineInf:"onlineMemberInfo",ET:"expireTime",Num:"onlineMemberNum",Opt:"operationType",O_Account:"operatorID",RT:"operationType",UDF:"userDefinedField",L_Account:"userIDList",IsPlaceMsg:"isPlaceMessage",MsgCheckResult:"checkResult",Results:"resultList",Reaction:"reactionID",Reaction_Account:"userIDList",MsgReactionNotifyList:"messageReactionNotifyList",MsgReactionNotify:"messageReactionNotify",MsgReactionSummary:"reactionList",C2CMsgInfo:"C2CMessageInfo",GroupMsgInfo:"groupMessageInfo",int32_err_code:"errorCode",str_err_msg:"errorMsg",MsgDropReason:"messageDropReason",ReactedByMe:"reactedByMyself",Level:"messageRemindType",PeerReadTime:"timestamp",NoUnreadSeqList:"excludedUnreadSequenceList",NewMsg:"topicLatestMessage",PinnedMsg:"pinnedMessage",SdkGroupMessageId:"unPinnedMessageInfo",StreamID:"streamMessageID",StreamMsgID:"streamMessageID"},ignoreKeyWord:["C2C","ID","USP"]};function pa(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");var n;return t=Object.assign({pascalCase:!1},t),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=fa(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 fa=function(e){for(var t=!1,n=!1,s=!1,i=0;i<e.length;i++){var a=e[i];t&&/[a-zA-Z]/.test(a)&&a.toUpperCase()===a?(e=e.slice(0,i)+"-"+e.slice(i),t=!1,s=n,n=!0,i++):n&&s&&/[a-zA-Z]/.test(a)&&a.toLowerCase()===a?(e=e.slice(0,i-1)+"-"+e.slice(i-1),s=n,n=!1,t=!0):(t=a.toLowerCase()===a&&a.toUpperCase()!==a,s=n,n=a.toUpperCase()===a&&a.toLowerCase()!==a)}return e};function _a(e,t){var n=0;return function e(t,s){if(++n>100)return n--,t;if(ht(t)){var i=t.map((function(t){return lt(t)?e(t,s):t}));return n--,i}if(lt(t)){var a=(o=t,r=function(e,t){if(!yt(t))return!1;if((i=t)!==pa(i))for(var n=0;n<ga.ignoreKeyWord.length&&!t.includes(ga.ignoreKeyWord[n]);n++);var i;return gt(s[t])?function(e){return e[0].toUpperCase()+pa(e).slice(1)}(t):s[t]},c=Object.create(null),Object.keys(o).forEach((function(e){var t=r(o[e],e);t&&(c[t]=o[e])})),c);return a=Gt(a,(function(t,n){return ht(t)||lt(t)?e(t,s):t})),n--,a}var o,r,c}(e,t)}function va(e,t){if(ht(e))return e.map((function(e){return lt(e)?va(e,t):e}));if(lt(e)){var n=(s=e,i=function(e,n){return gt(t[n])?pa(n):t[n]},a={},Object.keys(s).forEach((function(e){a[i(s[e],e)]=s[e]})),a);return Gt(n,(function(e){return ht(e)||lt(e)?va(e,t):e}))}var s,i,a}for(var ma=String.fromCharCode,ya=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 ma(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?ma(192|t>>>6,128|63&t):ma(224|t>>>12,128|t>>>6&63,128|63&t)},Ia=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,ya),n=0|t.length,s=new Uint8Array(n),i=0;i<n;i=i+1|0)s[i]=0|t.charCodeAt(i);return s},Ma=r((function e(t){var n=this;i(this,e),this._handler=t;var s=t.getURL();if(this._socket=null,this._workerSocket=null,this._id=Tt(),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", extensions: _socket.extensions }); }; _socket.onclose = function(e) { postMessage({ callback: "onClose", 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 o=this;this._workerSocket.onmessage=function(e){var t=e.data,n=t.callback,s=t.e,i=t.extensions;"onOpen"===n?o._onOpen(i):"onClose"===n?o._onClose(s):"onError"===n?o._onError(s):"onMessage"===n&&o._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:s})}else if(ue){var r={"content-type":"application/json"};ie?(ge.connectSocket({url:s,header:r}),ge.onSocketClose(this._onClose.bind(this)),ge.onSocketOpen(this._onOpen.bind(this)),ge.onSocketMessage(this._onMessage.bind(this)),ge.onSocketError(this._onError.bind(this))):ne?this._socket=ge.connectSocket({url:s,header:r,success:function(){n._bindEventsInMini()},fail:function(e){n._onFail({code:e.errNo,reason:e.errMsg})}}):(this._socket=ge.connectSocket({url:s,header:r,complete:function(){}}),this._bindEventsInMini())}else this._socket=new WebSocket(s),this._socket.binaryType="arraybuffer",this._socket.onopen=this._onOpen.bind(this,this._socket.extensions),this._socket.onmessage=this._onMessage.bind(this),this._socket.onclose=this._onClose.bind(this),this._socket.onerror=this._onError.bind(this);this._canIUseBinaryFrame=t.canIUseBinaryFrame()}),[{key:"getID",value:function(){return this._id}},{key:"getClient",value:function(){return this._socket}},{key:"_bindEventsInMini",value:function(){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))}},{key:"_onOpen",value:function(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}},{key:"_onClose",value:function(e){this._handler.onClose({id:this._id,e:e})}},{key:"_onFail",value:function(e){this._handler.onFail({id:this._id,e:e})}},{key:"_onMessage",value:function(e){var t;t=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):function(e){for(var t=new Uint8Array(e),n="",s=0,i=t.length;s<i;){var a=t[s],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),i-s-o>0)for(var c=0;c<o;)r=r<<6|63&(a=t[s+c+1]),c+=1;else r=65533,o=i-s;n+=String.fromCodePoint(r),s+=o+1}return n}(e.data):e.data,this._handler.onMessage({data:t})}},{key:"_isAppCompressedData",value:function(e){var t=new Uint8Array(e);return 67===t[0]&&79===t[1]&&77===t[2]&&80===t[3]}},{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),ie)return ge.offSocketClose(),ge.offSocketMessage(),ge.offSocketOpen(),ge.offSocketError(),void ge.closeSocket();this._socket&&(ue?(this._socket.onClose((function(){})),this._socket.onOpen((function(){})),this._socket.onMessage((function(){})),this._socket.onError((function(){}))):(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),se?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?Ia(e.data).buffer:e.data});else{if(ie)return void ge.sendSocketMessage({data:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}});this._socket&&(ue?this._socket.send({data:this._canIUseBinaryFrame?Ia(e.data).buffer:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket.send(this._canIUseBinaryFrame?Ia(e.data):e.data))}}}]),Ca=4e3,Ta=4001,Sa=["keyMap"],Ea=["keyMap"],ka="connected",Da="connecting",Oa="disconnected",Ra=r((function e(t){i(this,e),this._chM=t,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=Oa,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=Tt(),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._currentSite=P,this._setWebsocketHost(),this._initConnection(),this._addAppVisibilityListener()}),[{key:"_addAppVisibilityListener",value:function(){var e=this;ne&&ge.onAppShow((function(){Be.l("".concat(e._n,"._addAppVisibilityListener onAppShow readyState:").concat(e._readyState)),e._readyState===Oa&&e._initConnection()}))}},{key:"_setWebsocketHost",value:function(){var e=this._chM.get(Wn);this._currentSite=P,this._chM.isOversea()&&(this._currentSite=w),e.isSingaporeSite()?this._currentSite=b:e.isKoreaSite()?this._currentSite=G:e.isGermanySite()?this._currentSite=F:e.isIndiaSite()?this._currentSite=x:e.isJapanSite()?this._currentSite=V:e.isUSASite()?this._currentSite=q:e.isIndonesiaSite()&&(this._currentSite=K),H.HOST.setCurrent(this._currentSite)}},{key:"_initConnection",value:function(){var e=this._chM.get(Wn).getSDKAppID()+"",t=this._chM.get(Wn).isIndependentDomainDisabled();gt(H.HOST.CURRENT.BACKUP)?this._url=H.HOST.CURRENT.DEFAULT:""===this._url?this._url=t?H.HOST.CURRENT.DEFAULT:H.HOST.CURRENT.DEFAULT0.replace("*",e):this._url.indexOf(e)>-1?this._url=H.HOST.CURRENT.DEFAULT:this._url===H.HOST.CURRENT.DEFAULT?this._url=H.HOST.CURRENT.IPV6:this._url===H.HOST.CURRENT.IPV6?this._url=he?this._genRandomDomain():H.HOST.CURRENT.BACKUP:this._isWebBackupUrl(this._url)||this._url===H.HOST.CURRENT.BACKUP?this._canIUseBackupCN()?this._url=H.HOST.CURRENT.BACKUP_CN:this._canIUseAnyCast()?this._url=H.HOST.CURRENT.ANYCAST:this._url=H.HOST.CURRENT.DEFAULT:this._url===H.HOST.CURRENT.BACKUP_CN?this._url=this._canIUseAnyCast()?H.HOST.CURRENT.ANYCAST:H.HOST.CURRENT.DEFAULT:this._url===H.HOST.CURRENT.ANYCAST&&(H.HOST.CURRENT.ANYCAST="",this._url=H.HOST.CURRENT.DEFAULT);var n=this._chM.get(Wn),s=n.getProxyServer();st(s)||(this._url=s),n.isTestEnv()&&(this._url=A.TEST[this._currentSite].DEFAULT),this._connect(),this._nextPingTs=0}},{key:"_genRandomDomain",value:function(){var e=Math.floor(10001*Math.random())+1e4;return H.HOST.CURRENT.BACKUP_WEB.replace("*",e)}},{key:"_isWebBackupUrl",value:function(e){return e.includes("my-cpaas.com")}},{key:"_canIUseAnyCast",value:function(){return he&&H.HOST.CURRENT.ANYCAST}},{key:"_canIUseBackupCN",value:function(){return H.HOST.CURRENT.BACKUP_CN}},{key:"onCheckTimer",value:function(e){e%1==0&&(this._checkPromiseMap(),this._checkNativeAppWS())}},{key:"_checkPromiseMap",value:function(){var e=this;0!==this._promiseMap.size&&this._promiseMap.forEach((function(t,n){var s=t.reject,i=t.timestamp,a=t.headSeq,o=15e3;-1!==n.indexOf(Cs.LOGIN)?o=9e4:-1!==n.indexOf(Cs.PING)&&(o=3e3),Date.now()-i>=o&&(Be.l("".concat(e._n,"._checkPromiseMap request timeout, delete requestID:").concat(n)),e._promiseMap.delete(n),s(new fs({code:_s.NETWORK_TIMEOUT,data:{headSeq:a}})),e._chM.onRequestTimeout())}))}},{key:"_checkNativeAppWS",value:function(){oe&&!this.isConnected()&&this._reConnect()}},{key:"onOpen",value:function(e){if(this._readyState!==Oa){this._onOpenTs=Date.now();var t=e.id,n=e.res;this._socketID=t;var s=en(this._startTs,!1),i="socketID:".concat(t," res:").concat(n);Be.l("".concat(this._n,"._onOpen cost:").concat(s," ms. ").concat(i)),new Gs("wsOnOpen").setMessage(s).setCostTime(s).setMoreMessage(i).end(),this._readyState=ka,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._chM.onReconnected(),this._reConnectFlag=!1),this._chM.onOpen()}}},{key:"onClose",value:function(e){var t=new Gs("wsOnClose"),n=e.id,s=e.e,i="sourceSocketID:".concat(n," currentSocketID:").concat(this._socketID," code:").concat(s.code," reason:").concat(s.reason),a=0;0!==this._onOpenTs&&(a=Date.now()-this._onOpenTs),t.setMessage(a).setCostTime(a).setMoreMessage(i).setCode(s.code).end(!0),Be.l("".concat(this._n,"._onClose ").concat(i," onlineTime:").concat(a)),n===this._socketID&&(ie&&!0===this._reConnectFlag&&n===this._socketID&&0===a||(this._readyState=Oa,a<1e3?this._chM.onReconnectFailed():this._chM.onClose()))}},{key:"onError",value:function(e){var t,n=e.id,s=e.e,i="sourceSocketID:".concat(n," currentSocketID:").concat(this._socketID);new Gs("wsOnError").setMessage(s.errMsg||(t=s,JSON.stringify(t,["message","code"]))).setMoreMessage(i).setLevel("error").end(!0),Be.w("".concat(this._n,"._onError"),s,i),n===this._socketID&&(this._readyState=Oa,this._chM.onError())}},{key:"onFail",value:function(e){this._readyState=Oa;var t=e.id,n=e.e,s="currentSocketID:".concat(t," code:").concat(n.code," reason:").concat(n.reason);new Gs("wsOnFail").setMessage(s).setCode(n.code).end(!0),Be.l("".concat(this._n,"._onFail ").concat(s))}},{key:"onMessage",value:function(e){var t;try{t=JSON.parse(e.data)}catch(t){new Gs("jsonParseError").setMessage(e.data).end()}if(t&&t.head){var n=this._getRequestIDFromHead(t.head),s=t.body;if(!this._chM.get(rs).isTRTCCommand(n)){var i=jt(t.head);s=va(t.body,this._getResKeyMap(i))}if(Be.d("".concat(this._n,".onMessage ret:").concat(JSON.stringify(s)," requestID:").concat(n," has:").concat(this._promiseMap.has(n))),this._setNextPingTs(),this._promiseMap.has(n)){var a=this._promiseMap.get(n),o=a.resolve,r=a.reject,c=a.timestamp,u=a.headSeq;return this._promiseMap.delete(n),this._calcRTT(c),void(s.errorCode&&0!==s.errorCode?(this._chM.onErrorCodeNotZero(s),r(new fs({code:s.errorCode,message:s.errorInfo||"",data:n.includes(Cs.MODIFY_C2C_MSG)||n.includes(Cs.MODIFY_GRP_MSG)?{elements:s.elements,messageVersion:s.messageVersion,cloudCustomData:s.cloudCustomData,headSeq:u}:{headSeq:u}}))):o(ps(s)))}this._chM.onMessage({head:t.head,body:s})}}},{key:"_calcRTT",value:function(e){var t=Date.now()-e;this._chM.get(as).addRTT(t)}},{key:"_connect",value:function(){if(this._readyState!==Da&&this._readyState!==ka){if(this._startTs=Date.now(),this._onOpenTs=0,this._readyState=Da,this._socket=new Ma(this),this._socketID=this._socket.getID(),ne){var e=this._socket.getClient().readyState;if(gt(e))return void(this._readyState=Oa)}new Gs("wsConnect").setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end(),Be.l("".concat(this._n,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL()))}}},{key:"getURL",value:function(){this._chM.isDevMode()&&(this._canIUseBinaryFrame=!1);var e=Vt();if((ie||Q&&"windows"===e)&&(this._canIUseBinaryFrame=!1),oe){var t=ge.getSystemInfoSync().uniRuntimeVersion,n=void 0===t?"":t,s=function(e){var t=y(e.split(".").map(Number),3),n=t[0],s=void 0===n?0:n,i=t[1],a=void 0===i?0:i,o=t[2];return s>2||!(s<2)&&(a>2||!(a<2)&&(void 0===o?0:o)>=6)}(n);Be.l("".concat(this._n,".getURL uniRuntimeVersion:").concat(n," isUniRuntimeVersionGte226:").concat(s)),s||(this._canIUseBinaryFrame=!1)}var i=-1;"ios"===e?i=Me||-1:"android"===e&&(i=Te||-1);var a=this._chM.get(Wn),o=this._chM.getPlatform(),r=a.getSDKAppID(),c=a.getInstanceID(),u="sdkappid=".concat(r,"&instanceid=").concat(c,"&random=").concat(this._getRandom(),"&platform=").concat(o,"&host=").concat(e)+"&version=".concat(i,"&sdkversion=").concat(E);return ee&&(u+="&isminigame=1"),this._chM.canIUseInflate()&&(u+="&compress=gzip"),this._canIUseBinaryFrame?"".concat(this._url,"/binfo?").concat(u):"".concat(this._url,"/info?").concat(u)}},{key:"_closeConnection",value:function(e){Be.l("".concat(this._n,"._closeConnection socketID:").concat(this._socketID)),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=Oa)}},{key:"_resend",value:function(){var e=this;if(Be.l("".concat(this._n,"._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 s=t.uplinkData,i=t.resolve,a=t.reject;-1!==n.indexOf(Cs.AV_POLLING)?e._promiseMap.delete(n):(e._promiseMap.set(n,{resolve:i,reject:a,timestamp:Date.now(),uplinkData:s}),e._execute(n,s))})),this._simpleRequestMap.size>0){var t,n=c(this._simpleRequestMap);try{for(n.s();!(t=n.n()).done;){var s=y(t.value,2),i=s[0],a=s[1];this._execute(i,a)}}catch(e){n.e(e)}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.head.cs=this._calcCheckSum(e.head.servcmd,e.body),e.keyMap;var n=v(e,Sa),s=this._getRequestIDFromHead(e.head),i=JSON.stringify(n);return new Promise((function(a,o){t._promiseMap.set(s,{resolve:a,reject:o,timestamp:Date.now(),uplinkData:i,headSeq:e.head.seq}),Be.d("".concat(t._n,".send uplinkData:").concat(JSON.stringify(n)," requestID:").concat(s," readyState:").concat(t._readyState)),t._readyState!==ka?t._reConnect():(t._execute(s,i),t._chM.get(as).addRequestCount())}))}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3),e.keyMap;var t=v(e,Ea),n=this._getRequestIDFromHead(e.head),s=JSON.stringify(t);this._readyState!==ka?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(n,s):Be.l("".concat(this._n,".simplySend. simpleRequestMap is full, drop request!")),this._reConnect()):this._execute(n,s)}},{key:"_execute",value:function(e,t){this._socket.send({data:t,fail:ue?this._onSendFail.bind(this):void 0,requestID:e})}},{key:"_onSendFail",value:function(e){Be.l("".concat(this._n,"._onSendFail requestID:").concat(e)),this._chM.onSendFail()}},{key:"_getSequence",value:function(){var e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=Tt()),e}},{key:"_getRequestIDFromHead",value:function(e){return e.servcmd+e.seq}},{key:"_getResKeyMap",value:function(e){var t=this._chM.getKeyMap(e);return _(_({},ga.res),t.res)}},{key:"_reConnect",value:function(){this._readyState!==ka&&this._readyState!==Da&&this.forcedReconnect()}},{key:"forcedReconnect",value:function(){var e="".concat(this._n,".forcedReconnect");Be.l("".concat(e," count:").concat(this._reConnectCount," readyState:").concat(this._readyState)),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(Ta),this._initConnection()):(this._reConnectCount=0,this._chM.get(Jn).isOnline()?(Be.w("".concat(e," disconnected from wsserver but network is ok, continue...")),this._closeConnection(Ta),this._initConnection()):this._chM.onReconnectFailed())}},{key:"getReconnectFlag",value:function(){return this._reConnectFlag}},{key:"_setNextPingTs",value:function(){this._nextPingTs=oe?Date.now()+5e3:Date.now()+1e4}},{key:"getNextPingTs",value:function(){return this._nextPingTs}},{key:"isConnected",value:function(){return this._readyState===ka}},{key:"canIUseBinaryFrame",value:function(){return this._canIUseBinaryFrame}},{key:"getSocketID",value:function(){return this._socketID}},{key:"inflate",value:function(e){if(this._chM.canIUseInflate())return this._chM.get(gs).inflate(e)}},{key:"setIsWorkerEnabled",value:function(e){Be.l("".concat(this._n,".setIsWorkerEnabled flag:").concat(e)),this._isWorkerEnabled=e}},{key:"getIsWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ne}},{key:"_getRandom",value:function(){return 0===this._random&&(this._random=Math.random()),this._random}},{key:"_resetRandom",value:function(){this._random=0}},{key:"_calcCheckSum",value:function(e,t){if(-1!==e.indexOf(Cs.PING)||-1!==e.indexOf(Cs.LOGIN)||-1!==e.indexOf(Cs.LOGOUT)||-1!==e.indexOf(Cs.AV_POLLING)||-1!==e.indexOf(Cs.AV_NOAUTH_POLLING))return 0;for(var n=Ia(JSON.stringify(t)),s=4294967295,i=0,a=n.length;i<a;i++){s^=n[i];for(var o=0;o<8;o++)1&~s?s>>>=1:s=s>>>1^3988292384}return(4294967295^s)>>>0}},{key:"close",value:function(){Be.l("".concat(this._n,".close")),this._closeConnection(Ca),this._promiseMap.clear(),this._startSequence=Tt(),this._readyState=Oa,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}]),Aa=function(e,t,n){return new Promise((function(s,i){var a="application/x-www-form-urlencoded;charset=UTF-8";if(ue)ge.request({url:t,data:n,method:e,timeout:3e3,header:{"content-type":a},success:function(e){e&&e.data&&e.data.NetCheckInfo&&Be.l("".concat("getconninfo ok in"," miniapp. ret:"),e.data),s()},fail:function(){i(new fs({code:_s.NETWORK_ERROR}))}});else{var o=new XMLHttpRequest,r=setTimeout((function(){o.abort(),i(new fs({code:_s.NETWORK_TIMEOUT}))}),3e3);o.onreadystatechange=function(){4===o.readyState&&(r&&clearTimeout(r),200===o.status||304===o.status?(o.responseText&&o.responseText.indexOf("NetCheckInfo")>-1&&Be.l("".concat("getconninfo ok in"," web. ret:"),JSON.parse(o.responseText)),s()):i(new fs({code:_s.NETWORK_ERROR})))},o.open(e,t,!0),o.setRequestHeader("Content-type",a),n?o.send(n):o.send()}}))},Na=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="ChannelModule",s._socketHandler=new Ra(s),s._probing=!1,s._isAppShowing=!0,s._previousState=D.NET_STATE_CONNECTED,s._timerForNotLoggedIn=-1,s._timerForNotLoggedIn=setInterval(s.onCheckTimer.bind(s),1e3),s._fatalErrorFlag=!1,s._disconnectedTS=0,s._lastDiagnoseTS=0,s}return d(t,e),r(t,[{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.get(es).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.get(es).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==D.NET_STATE_CONNECTED&&e.head.servcmd.includes(Cs.SSO_STAT)?(this.reConnect(),this.isPrivateNetWork()?Promise.resolve():this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=H.HOST.CURRENT.STAT,n="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),s=JSON.stringify(e.body);return Aa("POST",n,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(){ue&&!oe&&this.warn("DomainNameInMP"),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"getKeyMap",value:function(e){return this.get(es).getKeyMap(e)}},{key:"onRequestTimeout",value:function(){Date.now()-this._lastDiagnoseTS>=3e4&&this.diagnose()}},{key:"onSendFail",value:function(){this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"onReconnected",value:function(){Be.l("".concat(this._n,".onReconnected cost:").concat(en(this._disconnectedTS,!0,!0))),this._m.restartTimer(),this.get(es).onReconnected(en(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(D.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){Be.l("".concat(this._n,".onReconnectFailed")),this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"offline",value:function(){this._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED)}},{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(Be.l("".concat(this._n,".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&&(Be.l("".concat(this._n,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),e===D.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now(),this.diagnose()),this._previousState=e,this.emitOEvt(k.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e=this;if(!0!==this._probing){this._probing=!0;var t=this.get(es).getProtocolData({P:Cs.PING});this.send(t).then((function(){e._probing=!1})).catch((function(t){e._probing=!1;var n=e.get(Jn).isOnline();if(Be.w("".concat(e._n,"._ping failed. bOnline:").concat(n," error:"),t),t&&60002===t.code)return new Gs("error").setMessage("code:".concat(t.code," message:").concat(t.message)).end(),e._fatalErrorFlag=!0,void e._emitNetStateChangeEvent(D.NET_STATE_DISCONNECTED);n?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:"onRestApiKickedOut",value:function(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}},{key:"canIUseInflate",value:function(){return this._m.canIUseInflate()}},{key:"getSocketID",value:function(){if(this._socketHandler)return this._socketHandler.getSocketID()}},{key:"diagnose",value:function(){this.isPrivateNetWork()||(this._lastDiagnoseTS=Date.now(),this._diagnoseBySSO(),this._diagnoseByCDN())}},{key:"_diagnoseBySSO",value:function(){var e=this,t=this._socketHandler.getURL(),n=t.split("/")[2];if(n.startsWith("ws")){var s=t.slice(t.indexOf("info?")+5),i="https://".concat(n,"/v3/netcheck/getconninfo?").concat(s,"&reqtime=").concat(Date.now());Aa("GET",i).catch((function(t){Be.w("".concat(e._n,"._diagnoseBySSO failed. error:"),t)}))}}},{key:"_diagnoseByCDN",value:function(){var e=this,t=this._socketHandler.getURL(),n=t.slice(t.indexOf("info?")+5),s="https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?".concat(n,"&reqtime=").concat(Date.now());Aa("GET",s).catch((function(t){Be.w("".concat(e._n,"._diagnoseByCDN failed. error:"),t)}))}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._previousState=D.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0,this._lastDiagnoseTS=0}}])}(Ms),La=r((function e(t){i(this,e),this._n="PHandler",this._sessionM=t,this._map=new Map,this._fillMap()}),[{key:"_fillMap",value:function(){this._map.clear();var e=this._sessionM.genCommonHead(),t=this._sessionM.genCosSpecifiedHead(),n=this._sessionM.genSSOReportHead();this._map.set(Cs.LOGIN,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.LOGIN)}),body:{state:"Online",isWebUniapp:0,deviceBrand:0,customInfo:""},keyMap:{req:{deviceBrand:"InstType"},res:{InstId:"instanceID",HelloInterval:"helloInterval",RichMsgAuthKey:"authKey"}}}}(e)),this._map.set(Cs.LOGOUT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.LOGOUT)}),body:{type:0,isWebUniapp:0},keyMap:{req:{type:"wslogout_type"}}}}(e)),this._map.set(Cs.HELLO,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.HELLO)}),body:{isWebUniapp:0},keyMap:{res:{NewInstInfo:"newInstanceInfo"}}}}(e)),this._map.set(Cs.KICK_OTHER,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.STAT_SERVICE,".").concat(Cs.KICK_OTHER)}),body:{}}}(e)),this._map.set(Cs.COS_SIGN,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_COS_SIGN,".").concat(Cs.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{req:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},res:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}}(t)),this._map.set(Cs.COS_PRE_SIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(Cs.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{req:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},res:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}}(t)),this._map.set(Cs.SIMPLE_COS_PRE_SIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(Cs.SIMPLE_COS_PRE_SIG)}),body:{uploadMethod:0,platform:2,SDKAppID:0,userID:"",conversationType:1,uploadConfig:[{fileID:1,fileType:1,fileName:""}]},keyMap:{req:{platform:"uint32_platform",SDKAppID:"uint32_sdkappid",userID:"str_user_id",uploadMethod:"uint32_upload_method",conversationType:"uint32_scene",uploadConfig:"rpt_upload_object",fileID:"uint32_file_id",fileType:"uint32_file_type",fileName:"str_file_name"},res:{str_final_ip:"uploadIP",rpt_pre_sig:"preSig",uint32_file_id:"fileID",uint32_exist_flag:"existFlag",str_download_url:"downloadUrl",str_upload_url:"uploadUrl",str_snapshot_url:"requestSnapshotUrl",str_file_key:"fileKey",rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}}(t)),this._map.set(Cs.GET_IMAGE_INFO,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(Cs.GET_IMAGE_INFO)}),body:{imageUrl:""},keyMap:{req:{imageUrl:"str_image_url"},res:{rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}}(t)),this._map.set(Cs.GET_IP,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(Cs.GET_IP)}),body:{domainName:""},keyMap:{req:{domainName:"str_domain"},res:{str_final_ip:"ip"}}}}(t)),this._map.set(Cs.VIDEO_COVER,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.CUSTOM_UPLOAD,".").concat(Cs.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{req:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},res:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}}(t)),this._map.set(Cs.FETCH_COMMERCIAL_CONFIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(Cs.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{req:{SDKAppID:"uint32_sdkappid"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._map.set(Cs.PUSHED_COMMERCIAL_CONFIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(Cs.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}}(e)),this._map.set(Cs.FETCH_CLOUD_CTRL_CONFIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(Cs.FETCH_CLOUD_CTRL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{req:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._map.set(Cs.PUSHED_CLOUD_CTRL_CONFIG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_CONFIG_MANAGER,".").concat(Cs.PUSHED_CLOUD_CTRL_CONFIG)}),body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}}(e)),this._map.set(Cs.OVERLOAD_NOTIFY,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OVERLOAD_PUSH,".").concat(Cs.OVERLOAD_NOTIFY)}),body:{},keyMap:{res:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}}(e)),this._map.set(Cs.SYNC_UNREAD_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.SYNC_UNREAD_MSG)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0,needSignaling:1,needCachedMsg:1},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},res:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"to",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}}(e)),this._map.set(Cs.SEND_C2C_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.SEND_C2C_MSG)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{sound:"",badgeMode:0,isVoipPush:void 0,image:"",interruptionLevel:"active",contentAvailable:0},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension:0,isRelayMessage:0,cmConfigID:void 0,forbidCallbackControl:void 0},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt",GoogleChannelID:"GoogleChannelID",XiaoMiChannelID:"XiaoMiChannelID",OPPOChannelID:"OPPOChannelID",OPPOCategory:"OPPOCategory",VIVOClassification:"VIVOClassification",VIVOCategory:"VIVOCategory",HonorImportance:"HonorImportance",MeizuNotifyType:"MeiZuNoticeMsgType"}}}}(e)),this._map.set(Cs.REVOKE_C2C_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.REVOKE_C2C_MSG)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{req:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}}(e)),this._map.set(Cs.GET_C2C_ROAMING_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.GET_C2C_ROAMING_MSG)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{req:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},res:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer"}}}}(e)),this._map.set(Cs.MODIFY_C2C_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.MODIFY_C2C_MSG)}),body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{req:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}}(e)),this._map.set(Cs.SET_C2C_MSG_READ,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.SET_C2C_MSG_READ)}),body:{C2CMsgReaded:void 0},keyMap:{req:{lastMessageTime:"LastedMsgTime"}}}}(e)),this._map.set(Cs.SET_C2C_PEER_MUTE_NOTIFICATIONS,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{req:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}}(e)),this._map.set(Cs.GET_C2C_PEER_MUTE_NOTIFICATIONS,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{toAccount:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Peer_Account"},res:{MuteNotificationsList:"muteFlagList"}}}}(e)),this._map.set(Cs.DEL_C2C_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.DEL_C2C_MSG)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{req:{keyList:"MsgKeyList"}}}}(e)),this._map.set(Cs.TRANSLATE_TEXT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_TRANSLATE,".").concat(Cs.TRANSLATE_TEXT)}),body:{sourceTextList:void 0,SDKAppID:0,from:0,source:"",target:""},keyMap:{req:{sourceTextList:"SourceText",SDKAppID:"SdkAppId",from:"FromAccount"},res:{TargetText:"translatedTextList",RequestId:"requestID",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._map.set(Cs.VOICE_TO_TEXT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_SPEECH,".").concat(Cs.VOICE_TO_TEXT)}),body:{url:"",SDKAppID:0,format:"",sourceType:0,language:""},keyMap:{req:{url:"BytesUrl",SDKAppID:"Uint32Sdkappid",format:"BytesVoiceFormat",sourceType:"Uint64SourceType",language:"BytesEngServiceType"},res:{BytesRequestid:"requestID",BytesResult:"result",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}}(e)),this._map.set(Cs.SEND_C2C_READ_RECEIPT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.SEND_C2C_READ_RECEIPT)}),body:{peerAccount:"",messageInfoList:void 0},keyMap:{req:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}}(e)),this._map.set(Cs.MODIFY_C2C_MSG_EXT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM_MSG_EXT,".").concat(Cs.MODIFY_C2C_MSG_EXT)}),body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}}(e)),this._map.set(Cs.GET_C2C_MSG_EXT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM_MSG_EXT,".").concat(Cs.GET_C2C_MSG_EXT)}),body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}}(e)),this._map.set(Cs.GET_C2C_PEER_READ_TIME,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.GET_C2C_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{req:{userIDList:"To_Account"},res:{ReadTime:"peerReadTimeList"}}}}(e)),this._map.set(Cs.PAGING_GET_CONV_LIST,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.PAGING_GET_CONV_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:15,assistFlag:31},keyMap:{req:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},res:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex",GroupId:"convGroupID",C2cRemark:"friendRemark",MsgRecvOption:"messageRemindType",GroupIgnoredUnreadSeqCount:"noUnreadCount",GroupNextMsgSeq:"nextMessageSeq"}}}}(e)),this._map.set(Cs.DEL_CONV,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.DEL_CONV)}),body:{fromAccount:"",conversationList:void 0,clearHistoryMessage:void 0},keyMap:{req:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble",conversationList:"ContactItem"},res:{ResultItem:"resultList",ToGroupid:"groupID",ResultCode:"code",ResultInfo:"info"}}}}(e)),this._map.set(Cs.CLEAR_HISTORY_MSG,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.CLEAR_HISTORY_MSG)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{req:{toGroupID:"ToGroupid"}}}}(e)),this._map.set(Cs.PIN_CONV,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.PIN_CONV)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{req:{itemList:"RecentContactItem"}}}}(e)),this._map.set(Cs.DEL_GROUP_AT_TIPS,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.DEL_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}}(e)),this._map.set(Cs.SET_CONV_CUSTOM_DATA,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.MARK_CONV)}),body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._map.set(Cs.MARK_CONV,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.RECENT_CONTACT,".").concat(Cs.MARK_CONV)}),body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}}(e)),this._map.set(Cs.GET_USER_PROFILE,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(Cs.GET_USER_PROFILE)}),body:{fromAccount:"",userItem:[]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._map.set(Cs.UPDATE_MY_PROFILE,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.PROFILE,".").concat(Cs.UPDATE_MY_PROFILE)}),body:{fromAccount:"",profileItem:[{tag:ze.NICK,value:""},{tag:ze.GENDER,value:""},{tag:ze.ALLOWTYPE,value:""},{tag:ze.AVATAR,value:""}]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}}(e)),this._map.set(Cs.SET_SELF_STATUS,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.SET_SELF_STATUS)}),body:{customStatus:""}}}(e)),this._map.set(Cs.SSO_STAT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STAT,".").concat(Cs.SSO_STAT)}),body:{header:{},event:[],quality:[]},keyMap:{req:{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._map.set(Cs.PING,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.HEARTBEAT,".").concat(Cs.PING)}),body:{}}}(e)),this._map.set(Cs.MSG_PUSH,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_PUSH,".").concat(Cs.MSG_PUSH)}),body:{},keyMap:{res:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt",Status:"statusType"}}}}(e)),this._map.set(Cs.MSG_PUSH_ACK,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OPEN_IM,".").concat(Cs.MSG_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{req:{sessionData:"SessionData"}}}}(e)),this._map.set(Cs.STATUS_FORCE_OFFLINE,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.STATUS_FORCE_OFFLINE)}),body:{},keyMap:{res:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}}(e)),this._map.set(Cs.SET_TOKEN,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.SET_TOKEN)}),body:{tokenID:"",pushMsg:0,sdkAppID:0,businessID:"",deviceBrand:"",deviceToken:"",isTpns:0,isWebUniapp:0,notificationStatus:0,deviceModel:"",systemVersion:"",pushVersion:""},keyMap:{req:{tokenID:"TokenID",pushMsg:"PushMsg",sdkAppID:"EnterVersion",businessID:"BusiID",deviceBrand:"InstType",deviceToken:"VarToken",isTpns:"IsTpns",notificationStatus:"NotificationStatus",deviceModel:"DeviceModel",systemVersion:"SystemVersion",pushVersion:"PushPluginVersion"}}}}(e)),this._map.set(Cs.STAT_FOREGROUND,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.STAT_FOREGROUND)}),body:{isWebUniapp:0}}}(e)),this._map.set(Cs.STAT_BACKGROUND,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_OPEN_STATUS,".").concat(Cs.STAT_BACKGROUND)}),body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{req:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}}(e)),this._map.set(Cs.PUSH_REPORT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.OFFLINE_PUSH_REPORT,".").concat(Cs.PUSH_REPORT)}),body:{eventList:[]},keyMap:{req:{eventList:"UinappPushEvents",type:"EventType",time:"EventTime",pushId:"ClickExt"}}}}(e)),this._map.set(Cs.SET_ALL_RECEIVE_MSG_OPT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_MSG_LOGIC,".").concat(Cs.SET_ALL_RECEIVE_MSG_OPT)}),body:{startTime:0,endTime:0,isRepeated:0,messageRemindType:0},keyMap:{req:{messageRemindType:"Level"}}}}(e)),this._map.set(Cs.GET_ALL_RECEIVE_MSG_OPT,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.IM_MSG_LOGIC,".").concat(Cs.GET_ALL_RECEIVE_MSG_OPT)}),body:{toAccount:void 0}}}(e)),this._map.set(Cs.STREAM_GET_STREAM,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.STREAM_MESSAGE,".").concat(Cs.STREAM_GET_STREAM)}),body:{from:"",to:"",streamMessageID:"",ackIndex:0},keyMap:{}}}(e)),this._map.set(Cs.STREAM_CHUNK_ACK,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.STREAM_MESSAGE,".").concat(Cs.STREAM_CHUNK_ACK)}),body:{streamMessageID:"",ackIndex:0},keyMap:{}}}(e)),this._map.set(Cs.STREAM_PUSH_CHUNKS,function(e){return{head:_(_({},e),{},{servcmd:"".concat(H.NAME.STREAM_MESSAGE,".").concat(Cs.STREAM_PUSH_CHUNKS)}),body:{from:"",to:"",streamMessageID:"",ackIndex:0},keyMap:{}}}(e))}},{key:"has",value:function(e){return this._map.has(e)}},{key:"get",value:function(e){return this._map.get(e)}},{key:"update",value:function(){this._fillMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(Be.w("".concat(this._n,".getKeyMap unknown P:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.P,n=e.data,s=this.get(t),i=null;if(n){var a=this._simpleDeepCopy(s),o=this._updateService(n,a),r=o.body,c=Object.create(null);for(var u in r)if(Object.prototype.hasOwnProperty.call(r,u)){if(c[u]=r[u],void 0===n[u])continue;c[u]=n[u]}o.body=c,i=this._getUplinkData(o)}else i=this._getUplinkData(s);return i}},{key:"_getUplinkData",value:function(e){var t=this._dataCleaner(e),n=jt(t.head),s=_a(t.body,this._getReqKeyMap(n));return t.body=s,t}},{key:"_updateService",value:function(e,t){var n=jt(t.head);if(this._isFromGroupRequest(t)){var s=e.type,i=e.groupID,a=void 0===i?void 0:i,o=e.groupIDList,r=void 0===o?[]:o;gt(a)&&(a=r[0]||""),Lt({type:s,groupID:a})&&(t.head.servcmd="".concat(H.NAME.GRP_COMMUNITY,".").concat(n))}return t}},{key:"_isFromGroupRequest",value:function(e){return e.head.servcmd.includes(H.NAME.GRP)||e.head.servcmd.includes(H.NAME.GRP_ATTR)}},{key:"_getReqKeyMap",value:function(e){var t=this.getKeyMap(e);return _(_({},ga.req),t.req)}},{key:"_dataCleaner",value:function(e){var t=Array.isArray(e)?[]:Object.create(null);for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&yt(n)&&null!==e[n]&&void 0!==e[n]&&("object"!==C(e[n])?t[n]=e[n]:t[n]=this._dataCleaner.bind(this)(e[n]));return t}},{key:"_simpleDeepCopy",value:function(e){for(var t,n=Object.keys(e),s={},i=0,a=n.length;i<a;i++)t=n[i],ht(e[t])?s[t]=Array.from(e[t]):lt(e[t])?s[t]=this._simpleDeepCopy(e[t]):s[t]=e[t];return s}}]),Ua=[Cs.MSG_PUSH_ACK,Cs.STREAM_CHUNK_ACK],Pa=r((function e(t){i(this,e),this._sessionM=t,this._n="MsgDispatcher",this._eventHandlerMap=new Map,this._eventHandlerMap.set("C2CMessageArray",this._onC2CMsgArray.bind(this)),this._eventHandlerMap.set("groupMessageArray",this._onGroupMsgArray.bind(this)),this._eventHandlerMap.set("groupTips",this._onGroupTips.bind(this)),this._eventHandlerMap.set("C2CNotifyMessageArray",this._onC2CNotifyMsgArray.bind(this)),this._eventHandlerMap.set("C2CReadReceiptArray",this._onC2CReadReceiptArray.bind(this)),this._eventHandlerMap.set("profileModify",this._onProfileModified.bind(this)),this._eventHandlerMap.set("friendListMod",this._onRelationChainModified.bind(this)),this._eventHandlerMap.set("recentContactMod",this._onRecentContact.bind(this)),this._eventHandlerMap.set("readAllC2CMessage",this._onAllMsgRead.bind(this)),this._eventHandlerMap.set("c2cMessageModified",this._onC2CMsgModified.bind(this)),this._eventHandlerMap.set("groupMessageModified",this._onGroupMsgModified.bind(this)),this._eventHandlerMap.set("userStatusList",this._onUserStatusList.bind(this)),this._eventHandlerMap.set("messageExtensionNotify",this._onMsgExtNotify.bind(this)),this._eventHandlerMap.set("messageReactionNotifyList",this._onMsgReactionNotifyList.bind(this)),this._eventHandlerMap.set("messageReactionNotify",this._onMsgReactionNotify.bind(this)),this._eventHandlerMap.set("followChangeList",this._onFollowNotify.bind(this)),this._keys=I(this._eventHandlerMap.keys())}),[{key:"_onC2CMsgArray",value:function(e){var t=this._sessionM.get(Kn);e.dataList.forEach((function(e){if(1===e.isSyncMessage){var t=e.from;e.from=e.to,e.to=t}})),1===e.needSync&&this._sessionM.get(Qn).syncOnNeed(),t.onNewMessage({dataList:e.dataList,isInstantMessage:!0})}},{key:"_onC2CMsgModified",value:function(e){this._sessionM.get(Kn).onMsgModified(e)}},{key:"_onGroupMsgArray",value:function(e){var t=this._sessionM.get(Hn);t&&t.onNewMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}},{key:"_onGroupMsgModified",value:function(e){var t=this._sessionM.get(Hn);t&&t.onMsgModified(e)}},{key:"_onGroupTips",value:function(e){var t=this._sessionM.get(Hn);if(t){var n=e.event,s=e.dataList,i=e.isInstantMessage,a=void 0===i||i,o=e.isSyncingEnded;switch(n){case 4:case 6:t.onNewGroupTips({event:n,dataList:s});break;case 5:for(var r=0;r<s.length;r++)if(ht(s[r].elements.revokedInfos))t.onMsgRevoked({dataList:s});else if(ht(s[r].elements.groupMessageReadNotice))t.onMsgReadNotice({dataList:s});else{if(!ht(s[r].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:s,isInstantMessage:a,isSyncingEnded:o});break}t.onReadReceiptList({dataList:s})}break;case 12:this._sessionM.get(Yn).onNewGroupAtTips({dataList:s});break;default:Be.l("".concat(this._n,"._onGroupTips unknown event:").concat(n," dataList:"),s)}}}},{key:"_onC2CNotifyMsgArray",value:function(e){var t=this,n=e.dataList;if(ht(n)){var s=this._sessionM.get(Kn);n.forEach((function(e){if(dt(e))if(e.hasOwnProperty("kickoutMsgNotify")){var i=e.kickoutMsgNotify,a=i.kickType,o=i.newInstanceInfo,r=void 0===o?{}:o;1===a?t._sessionM.onMultipleAccountKickedOut(r):2===a?t._sessionM.onMultipleDeviceKickedOut(r):3===a&&t._sessionM.onRestApiKickedOut(r)}else e.hasOwnProperty("c2cMessageRevokedNotify")?s&&s.onMsgRevoked({dataList:n},!0):e.hasOwnProperty("c2cMessageReadReceipt")?s&&s.onMsgReadReceipt({dataList:n}):e.hasOwnProperty("c2cMessageReadNotice")?s&&s.onMsgReadNotice({dataList:n}):e.hasOwnProperty("muteNotificationsSync")&&t._sessionM.get(Yn).onC2CMsgRemindTypeSynced({dataList:n})}))}}},{key:"_onC2CReadReceiptArray",value:function(e){this._sessionM.get(Kn).onReadReceiptList(e)}},{key:"_onProfileModified",value:function(e){this._sessionM.get(qn).onProfileModified({dataList:e.dataList});var t=this._sessionM.get(jn);t&&t.onFriendProfileModified({dataList:e.dataList})}},{key:"_onRelationChainModified",value:function(e){this._sessionM.get(qn).onRelationChainModified({dataList:e.dataList});var t=this._sessionM.get(jn);t&&t.onRelationChainModified({dataList:e.dataList})}},{key:"_onRecentContact",value:function(e){var t=e.dataList;if(ht(t)){var n=this._sessionM.get(Yn);n&&t.forEach((function(e){var t=e.pushType;if(1===t){var s=e.recentContactDeleteItem;n.onConvDeleted(s.recentContactList)}else if(2===t){var i=e.recentContactTopItem;n.onConvPinnedStatus(i.recentContactList,!0)}else if(3===t){var a=e.recentContactTopItem;n.onConvPinnedStatus(a.recentContactList,!1)}else if(4===t){var o=e.recentContactMarkContact;n.onConvMarkUpdated(o.recentContactMarkContactItem)}else if(5===t){var r=e.recentContactCreateContactGroup;n.onConvGroupCreated(r.msgContactGroupContactItem)}else if(6===t){var c=e.recentContactDelContactGroup;n.onConvGroupDeleted(c.msgGroupItem)}else if(7===t){var u=e.recentContactUpdateContactGroup,l=u.updateType,d=u.msgUpdateGroup,h=u.msgUpdateContact;if(1===l){var g=d.updateGroupType;1===g?n.onConvGroupNameUpdated(d):2===g&&n.onConvInGroupUpdated(d)}else 2===l&&n.onConvAddedToOrDeletedFromGroup(h)}}))}}},{key:"_onAllMsgRead",value:function(e){var t=e.dataList,n=this._sessionM.get(Yn);n&&n.onPushedAllMessageRead(t)}},{key:"_onUserStatusList",value:function(e){this._sessionM.get(qn).onUserStatusUpdated(e)}},{key:"_onMsgExtNotify",value:function(e){this._sessionM.get(Vn).onMsgExtNotify(e)}},{key:"_onMsgReactionNotifyList",value:function(e){this._sessionM.get(ds).onReactionNotifyList(e)}},{key:"_onMsgReactionNotify",value:function(e){this._sessionM.get(ds).onReactionNotify(e)}},{key:"_onFollowNotify",value:function(e){this._sessionM.get(hs).onFollowNotify(e)}},{key:"_onTopicLatestMsg",value:function(e){this._sessionM.get(Bn).onTopicLatestMsg(e)}},{key:"onMessage",value:function(e){var t=this,n=e.body;if(this._filterMsgFromIMOpenPush(e)){var s=n.eventArray,i=n.isInstantMessage,a=n.isSyncingEnded,o=n.needSync;if(ht(s))for(var r=null,c=null,u=0,l=0,d=s.length;l<d;l++)if(100!==(u=(r=s[l]).event))if(24!==u)if(26!==u){var h=Object.keys(r).find((function(e){return-1!==t._keys.indexOf(e)}));h?(c=14===u?{readAllC2CMessage:r[h],groupMessageReadInfoList:r.groupMessageReadNotice||[]}:16===u?{userID:r.userID,timestamp:r.timestamp,readReceiptList:r[h]}:r[h],this._eventHandlerMap.get(h)({event:u,dataList:c,isInstantMessage:i,isSyncingEnded:a,needSync:o})):Be.l("".concat(this._n,".onMessage unknown eventItem:"),r)}else this._onTopicLatestMsg(r);else this._onAllRcvMsgOptNotify(r);else this._onRoomCustomData(r.content)}}},{key:"_onRoomCustomData",value:function(e){this._sessionM.get(rs).onRoomCustomDataReceived(e),Be.l("".concat(this._n,"._onRoomCustomData data:").concat(e))}},{key:"_onAllRcvMsgOptNotify",value:function(e){this._sessionM.get(Yn).onAllRcvMsgOptNotify(e)}},{key:"_filterMsgFromIMOpenPush",value:function(e){var t=e.head,n=e.body,s=t.servcmd,i=!1;if(gt(s)||(i=s.includes(H.NAME.IM_CONFIG_MANAGER)||s.includes(H.NAME.OVERLOAD_PUSH)||s.includes(H.NAME.STAT_SERVICE)||s.includes(H.NAME.STREAM_MESSAGE)),!i)return!0;if(s.includes(Cs.PUSHED_CLOUD_CTRL_CONFIG))this._sessionM.get(ns).onPushedConfig(n);else if(s.includes(Cs.PUSHED_COMMERCIAL_CONFIG))this._sessionM.get(os).onPushedConfig(n);else if(s.includes(Cs.OVERLOAD_NOTIFY))this._sessionM.onPushedServerOverload(n);else if(s.includes(Cs.KICK_OTHER)){var a=Date.now();this._sessionM.reLoginOnKickOther();var o=new Gs("kickOther"),r=this._sessionM.get(Fn).getLastWsHelloTs(),c=a-r;o.setMessage("last wshello time:".concat(r," diff:").concat(c,"ms")).end()}else s.includes(Cs.STREAM_PUSH_CHUNKS)&&this._sessionM.get(Yn).onPushedChunks(n);return!1}}]),wa=[{cmd:Cs.GET_GRP_PROFILE,interval:1,count:8},{cmd:Cs.UPDATE_GRP_PROFILE,interval:1,count:8},{cmd:Cs.GET_GRP_PENDENCY,interval:1,count:15},{cmd:Cs.GET_TOPIC_LIST,interval:1,count:10},{cmd:Cs.SET_GRP_ATTR,interval:5,count:10},{cmd:Cs.MODIFY_GRP_ATTR,interval:5,count:10},{cmd:Cs.DEL_GRP_ATTR,interval:5,count:10},{cmd:Cs.CLEAR_GRP_ATTR,interval:5,count:10},{cmd:Cs.GET_GRP_ATTR,interval:5,count:20},{cmd:Cs.UPDATE_GRP_COUNTER,interval:5,count:20},{cmd:Cs.GET_GRP_COUNTER,interval:5,count:20},{cmd:Cs.SET_ALL_MSG_READ,interval:1,count:1},{cmd:Cs.GET_USER_STATUS,interval:5,count:20},{cmd:Cs.SUB_USER_STATUS,interval:5,count:20},{cmd:Cs.UNSUB_USER_STATUS,interval:5,count:20},{cmd:Cs.CS,interval:5,count:20},{cmd:Cs.GRP_CS,interval:5,count:20},{cmd:Cs.MBR_CS,interval:5,count:20},{cmd:Cs.USER_CS,interval:5,count:20},{cmd:Cs.CHECK_FOLLOW_TYPE,interval:5,count:20},{cmd:Cs.GET_GRP_ROAMING_MSG,interval:1,count:20},{cmd:Cs.GET_C2C_ROAMING_MSG,interval:1,count:20}],ba=new Map,Ga=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],Fa=0,xa=Ga.length;Fa<xa;Fa++)ba.set(Fa,Ga[Fa]);function Va(e){var t,n,s=e;e.length%8!=0&&(s="0".repeat(8-e.length%8)+e);for(var i="",a=0,o=s.length;a<o;a+=8)t=parseInt(s.slice(a,a+4),2),n=parseInt(s.slice(a+4,a+8),2),i+=ba.get(t)+ba.get(n);return i}var qa=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="SessionModule",s._platform=s.getPlatform(),s._pHandler=new La(s),s._msgDispatcher=new Pa(s),s._cmdFreqLimitMap=new Map,s._cmdReqInfoMap=new Map,s._serverOverloadInfoMap=new Map,s._incrementalPullContactFlag=!0,s._init(),s.getIEmitInst().on(mi.CLOUD_CONFIG,s._onCloudConfig,s),s}return d(t,e),r(t,[{key:"_init",value:function(){this._updateCmdFreqLimitMap(wa)}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("cmd_frequency_limit");gt(e)||(e=JSON.parse(e),this._updateCmdFreqLimitMap(e))}},{key:"_updateCmdFreqLimitMap",value:function(e){var t=this;e.forEach((function(e){t._cmdFreqLimitMap.set(e.cmd,{interval:e.interval,count:e.count})}))}},{key:"updateProtocolConfig",value:function(){this._pHandler.update()}},{key:"req",value:function(e){Be.d("".concat(this._n,".req options:"),e);var t=e.P;if(!this._pHandler.has(t))return Be.w("".concat(this._n,".req unknown P:").concat(t)),Is({code:_s.NO_PROTOCOL});var n,s=this.getProtocolData(e),i=s.head.servcmd;if(this._isFreqOverLimit(i))return Is({code:n=_s.OVER_FREQUENCY_LIMIT,message:this.getErrMsg(n,this._getCmd(i))});if(this._isServerOverload(i))return Is({code:n=_s.OPEN_SERVICE_OVERLOAD_ERROR,message:this.getErrMsg(n,this._getCmd(i))});var a=this.get(ts);return Ua.includes(t)?a.simplySend(s):a.send(s)}},{key:"getKeyMap",value:function(e){return this._pHandler.getKeyMap(e)}},{key:"genCommonHead",value:function(){var e=this.get(Wn);return{ver:"v4",platform:this._platform,websdkappid:U,websdkversion:L,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:151379687,sdkability_ext:Va(""),cappid:e.getApplicationID(),cs:0}}},{key:"genCosSpecifiedHead",value:function(){var e=this.get(Wn);return{ver:"v4",platform:this._platform,websdkappid:U,websdkversion:L,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:151379687,sdkability_ext:Va(""),cappid:e.getApplicationID(),cs:0}}},{key:"genSSOReportHead",value:function(){var e=this.get(Wn);return{ver:"v4",platform:this._platform,websdkappid:U,websdkversion:L,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:151379687,sdkability_ext:Va(""),cappid:e.getApplicationID(),cs:0}}},{key:"getProtocolData",value:function(e){return this._pHandler.getProtocolData(e)}},{key:"trans",value:function(e){var t=e.servcmd,n=e.data,s={head:_(_({},this.genCommonHead()),{},{servcmd:t}),body:n};return this.get(ts).send(s)}},{key:"sendComboMessage",value:function(e){var t=e.servcmd,n=e.data,s={head:_(_({},this.genCommonHead()),{},{servcmd:t}),body:n};return this.get(ts).send(s)}},{key:"onErrorCodeNotZero",value:function(e){var t=e.errorCode;if(t===_s.HELLO_ANSWER_KICKED_OUT){var n=e.kickType,s=e.newInstanceInfo,i=void 0===s?{}:s;1===n?this.onMultipleAccountKickedOut(i):2===n?this.onMultipleDeviceKickedOut(i):3===n&&this.onRestApiKickedOut(i)}t!==_s.MSG_A2KEY_EXPIRED&&t!==_s.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.get(ts).reConnect())}},{key:"onMessage",value:function(e){var t=e.body,n=t.needAck,s=void 0===n?0:n,i=t.sessionData;1===s&&this._sendACK(i),this._msgDispatcher.onMessage(e)}},{key:"onReconnected",value:function(e){this._incrementalPullContactFlag=e<=300,this._reLoginOnReconnected()}},{key:"reLoginOnKickOther",value:function(){Be.l("".concat(this._n,".reLoginOnKickOther")),this._reLogin()}},{key:"_reLoginOnReconnected",value:function(){Be.l("".concat(this._n,"._reLoginOnReconnected")),this._reLogin()}},{key:"_reLogin",value:function(){var e=this,t="".concat(this._n,"._reLogin");if(this.isLoggedIn()){var n=new Gs("reLogin");this.req({P:Cs.LOGIN,data:{isWebUniapp:0,customInfo:this.get(Wn).getCustomLoginInfo()}}).then((function(s){var i=s.data,a=i.instanceID,o=i.customStatus,r=e.get(Wn),c=Vi(o);r.setStatusInstanceID(a);var u=e.get(ts),l=u.getSocketID(),d="socketID:".concat(l," instanceID:").concat(a," customStatus:").concat(c);n.setMessage(d).end(!0),Be.l("".concat(t," ok. ").concat(d)),r.getCustomStatus()!==c&&e.get(qn).onUserStatusUpdated({dataList:[{to:e.getMyUserID(),statusType:D.USER_STATUS_ONLINE,customStatus:o}]}),u.diagnose(),e.get(Yn).syncConvList(e._incrementalPullContactFlag).then((function(){Be.l("".concat(t,", sync conv list ok.")),e.get(is).start()}))}))}}},{key:"onMultipleAccountKickedOut",value:function(e){this.get(Fn).onMultipleAccountKickedOut(e)}},{key:"onMultipleDeviceKickedOut",value:function(e){this.get(Fn).onMultipleDeviceKickedOut(e)}},{key:"_onUserSigExpired",value:function(){this.get(Fn).onUserSigExpired()}},{key:"onRestApiKickedOut",value:function(e){this.get(Fn).onRestApiKickedOut(e)}},{key:"_sendACK",value:function(e){this.req({P:Cs.MSG_PUSH_ACK,data:{sessionData:e}})}},{key:"_isFreqOverLimit",value:function(e){var t=e.split(".")[1];if(!this._cmdFreqLimitMap.has(t))return!1;if(!this._cmdReqInfoMap.has(t))return this._cmdReqInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;var n=this._cmdFreqLimitMap.get(t),s=n.count,i=n.interval,a=this._cmdReqInfoMap.get(t),o=a.startTime,r=a.requestCount;if(Date.now()-o>1e3*i)return this._cmdReqInfoMap.set(t,{startTime:Date.now(),requestCount:1}),!1;r+=1,this._cmdReqInfoMap.set(t,{startTime:o,requestCount:r});var c=!1;return r>s&&(c=!0),c}},{key:"_isServerOverload",value:function(e){if(!this._serverOverloadInfoMap.has(e))return!1;var t=this._serverOverloadInfoMap.get(e),n=t.overloadTime,s=t.waitingTime,i=!1;return Date.now()-n<=1e3*s?i=!0:(this._serverOverloadInfoMap.delete(e),i=!1),i}},{key:"_getCmd",value:function(e){var t="";if(!e.includes("."))return t;var n=e.split(".")[1];for(var s in Cs)if(Cs[s]===n){t=s;break}return t}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand,n=e.waitingTime;this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:n}),Be.w("".concat(this._n,".onPushedServerOverload waitingTime:").concat(n,"s cmd:").concat(this._getCmd(t)))}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._updateCmdFreqLimitMap(wa),this._cmdReqInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}])}(Ms),Ka=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="CloudControlModule",s._cloudConfig=new Map,s._expiredTime=0,s._version=0,s._isFetching=!1,s}return d(t,e),r(t,[{key:"getCloudConfig",value:function(e){return gt(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}},{key:"getServerConfig",value:function(e){var t={code:0,data:""};return!gt(e)&&this._cloudConfig.has(e)&&(t.data=this._cloudConfig.get(e)),Promise.resolve(t)}},{key:"_canFetch",value:function(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}},{key:"fetchConfig",value:function(){var e=this,t="".concat(this._n,".fetchConfig"),n=this._canFetch();if(Be.l("".concat(t," canFetch:").concat(n)),n){var s=new Gs("fetchCloudCtrlConfig"),i=this.get(Wn).getSDKAppID();this._isFetching=!0,this.req({P:Cs.FETCH_CLOUD_CTRL_CONFIG,data:{SDKAppID:i,version:this._version}}).then((function(n){e._isFetching=!1;var i=n.data,a=i.version,o=i.cloudControlConfig;s.setMessage("version:".concat(e._version," newVersion:").concat(a," config:").concat(o)).end(),Be.l("".concat(t," ok")),e._parse(n.data)})).catch((function(n){e._isFetching=!1,s.setError(n).end(),Be.l("".concat(t," failed. error:"),n),e._setExpiredTime(12e4)}))}}},{key:"onPushedConfig",value:function(e){Be.l("".concat(this._n,".onPushedConfig config:"),e),new Gs("pushedCloudCtrlConfig").setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parse(e)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"_parse",value:function(e){var t=this,n="".concat(this._n,"._parse"),s=e.errorCode,i=e.errorMessage,a=e.cloudControlConfig,o=e.version,r=e.expiredTime;if(0===s){if(this._version!==o){var c=null;try{c=JSON.parse(a)}catch(e){this.isPrivateNetWork()||Be.e("".concat(n," failed. config:"),a)}c&&(this._cloudConfig.clear(),Object.keys(c).forEach((function(e){t._cloudConfig.set(e,c[e])})),this._version=o,this.emitIEvt(mi.CLOUD_CONFIG),this.emitOEvt(k.SERVER_CONFIG_UPDATED,{config:c}))}this._setExpiredTime(1e3*r)}else gt(s)?(Be.l("".concat(n," failed. Invalid message format:"),e),this._setExpiredTime(36e5)):(Be.e("".concat(n," errorCode:").concat(s," errorMessage:").concat(i)),this._setExpiredTime(12e4))}},{key:"_setExpiredTime",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}])}(Ms),Ha=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="RecoverMsgModule",s.PULL_LIMIT_COUNT=15,s}return d(t,e),r(t,[{key:"start",value:function(){this._recoverC2CChat()}},{key:"_recoverC2CChat",value:function(){var e,t=this,n=this._getLocalConvList().filter((function(e){return e.type===D.CONV_C2C})),s=this.get(Yn),i=0,a=0,o=0,r=[Promise.resolve()],c=[];n.forEach((function(n){var u=n.conversationID,l=n.lastMessage;e=s.getLocalLastMessage(u),l&&0!==l.lastTime&&e&&(a=l.lastTime,i=e.time,o=a-i,i>0&&o>=1&&o<=600&&(r.push(t._recoverC2CMsg({conversationID:u,localLastMessageTime:i,remoteLastMessageTime:a})),c.push(u)))})),Promise.all(r).then((function(){Be.l("".concat(t._n,"._recoverC2CChat all done, convIDList:"),c),t.get(Qn).syncOnReconnected()}))}},{key:"_getLocalConvList",value:function(){return this.get(Yn).getLocalConvList()}},{key:"_recoverC2CMsg",value:function(e){var t=this,n="".concat(this._n,".").concat("_recoverC2CMsg");Be.l("".concat(n," options:"),e);var s=e.conversationID,i=e.localLastMessageTime,a=e.remoteLastMessageTime,o=JSON.stringify(e),r=new Gs("_recoverC2CMsg");return r.setMessage(o),this._getC2CRoamingMsg({conversationID:s,time:i}).then((function(e){var i=e.data,c=i.complete,u=i.messageList;if(!gt(u)){var l=u.length;t.get(Kn).onNewMessage({dataList:u,isInstantMessage:!0});var d=u[l-1].time,h=u.map((function(e){return e.random})),g="".concat(o," complete:").concat(c," randomList:").concat(h);if(Be.l("".concat(n," ").concat(g)),r.setMessage(g).end(),d<a&&1!==c)return t._recoverC2CMsg({conversationID:s,localLastMessageTime:d,remoteLastMessageTime:a})}})).catch((function(e){r.setError(e).end(),Be.w("".concat(n," failed. error:"),e)}))}},{key:"_getC2CRoamingMsg",value:function(e){var t=e.conversationID,n=e.time;return this.req({P:Cs.GET_C2C_ROAMING_MSG,data:{peerAccount:t.replace(D.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:n,direction:1}})}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}])}(Ms),ja=r((function e(){i(this,e),this._n="AvgE2EDelay",this._e2eDelayArray=[]}),[{key:"addMessageDelay",value:function(e){var t=qe()-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})),Bt(n/t,1)}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,n=e.min,s=e.max;return t.filter((function(e){return n<=e&&e<s})).length}},{key:"_calcPercent",value:function(e,t){var n=Bt(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 s=n.length,i=Math.min.apply(Math,I(n)),a=Math.max.apply(Math,I(n)),o=this._calcAvg(n,s),r=Bt(s/e.length*100,2);r>50&&new Gs("messageE2EDelayException").setMessage("count:".concat(s," min:").concat(i," max:").concat(a," avg:").concat(o," percent:").concat(r)).setLevel("warning").end()}}},{key:"getStatResult",value:function(){var e=this._e2eDelayArray.length;if(0===e)return null;var t=I(this._e2eDelayArray),n=this._calcCountWithLimit({e2eDelayArray:t,min:0,max:1}),s=this._calcCountWithLimit({e2eDelayArray:t,min:1,max:3}),i=this._calcPercent(n,e),a=this._calcPercent(s,e),o=this._calcAvg(t,e);return this._checkE2EDelayException(t,3),t.length=0,this.reset(),{totalCount:e,countLessThan1Second:n,percentOfCountLessThan1Second:i,countLessThan3Second:s,percentOfCountLessThan3Second:a,avgDelay:o}}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),Ba=r((function e(){i(this,e),this._n="AvgRTT",this._requestCount=0,this._rttArray=[]}),[{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=Bt(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,I(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,I(this._rttArray))}},{key:"getStatResult",value:function(){var e=this._calcTotalCount(),t=I(this._rttArray);if(0===e)return null;var n=this._calcRTTCount(t),s=this._calcSuccessRateOfRequest(n,e),i=this._calcAvg(t,n);return Be.l("".concat(this._n,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(i)),this.reset(),{totalCount:e,rttCount:n,successRateOfRequest:s,avgRTT:i}}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),Ya=r((function e(){i(this,e),this._map=new Map}),[{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!(gt(e)||!this._map.has(e)||(this._map.get(e).totalCount+=1,0))}},{key:"addSuccessCount",value:function(e){return!(gt(e)||!this._map.has(e)||(this._map.get(e).successCount+=1,0))}},{key:"addFailedCountOfUserSide",value:function(e){return!(gt(e)||!this._map.has(e)||(this._map.get(e).failedCountOfUserSide+=1,0))}},{key:"addCost",value:function(e,t){return!(gt(e)||!this._map.has(e)||(this._map.get(e).costArray.push(t),0))}},{key:"addFileSize",value:function(e,t){return!(gt(e)||!this._map.has(e)||(this._map.get(e).fileSizeArray.push(t),0))}},{key:"_calcSuccessRateOfBusiness",value:function(e){if(gt(e)||!this._map.has(e))return-1;var t=this._map.get(e),n=Bt(t.successCount/t.totalCount*100,2);return n>100&&(n=100),n}},{key:"_calcSuccessRateOfPlatform",value:function(e){if(gt(e)||!this._map.has(e))return-1;var t=this._map.get(e),n=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return(n=Bt(n,2))>100&&(n=100),n}},{key:"_calcTotalCount",value:function(e){return gt(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return gt(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){if(gt(e)||!this._map.has(e))return-1;var t=this._map.get(e);return t.successCount+t.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return gt(e)||!this._map.has(e)?-1:e===Rs?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),s=this._calcSuccessRateOfBusiness(e),i=this._calcSuccessCountOfPlatform(e),a=this._calcSuccessRateOfPlatform(e),o=this._calcAvg(e);return this.reset(e),{totalCount:t,successCountOfBusiness:n,successRateOfBusiness:s,successCountOfPlatform:i,successRateOfPlatform:a,avgValue:o}}},{key:"reset",value:function(e){gt(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),Wa=r((function e(){i(this,e),this._lastMap=new Map,this._currentMap=new Map}),[{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(gt(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var s=n.conversationID,i=n.sequence,a=s.replace(D.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(a)){var o=this._lastMap.get(t).get(a),r=o.length-1;i>o[0]&&i<o[r]?(o.push(i),o.sort(),this._lastMap.get(t).set(a,o)):this._addCurrentMap(e)}else this._addCurrentMap(e);return!0}},{key:"_addCurrentMap",value:function(e){var t=e.key,n=e.message,s=n.conversationID,i=n.sequence,a=s.replace(D.CONV_GROUP,"");this._currentMap.get(t).has(a)||this._currentMap.get(t).set(a,[]),this._currentMap.get(t).get(a).push(i)}},{key:"_copyData",value:function(e){if(!gt(e)){this._lastMap.set(e,new Map);var t,n=this._lastMap.get(e),s=c(this._currentMap.get(e));try{for(s.s();!(t=s.n()).done;){var i=y(t.value,2),a=i[0],o=i[1];n.set(a,o)}}catch(e){s.e(e)}finally{s.f()}n=null,this._currentMap.set(e,new Map)}}},{key:"getStatResult",value:function(e){if(gt(this._currentMap.get(e))||gt(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,s){var i=I(e.values()),a=i.length,o=i[a-1]-i[0]+1;t+=o,n+=a})),0===t)return null;var s=Bt(n/t*100,2);return s>100&&(s=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:n,successRateOfMessageReceived:s}}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),za=function(e){function t(e){var s;i(this,t),(s=n(this,t,[e]))._n="QualityStatModule",s.TAG="im-ssolog-quality-stat",s.reportIndex=0,s.wholePeriod=!1,s._qualityItems=[Ts,Ss,Es,ks,Ds,Os,Rs,As,Ns,Ls],s._messageSentItems=[Es,ks,Ds,Os,Rs],s._messageReceivedItems=[As,Ns,Ls],s.REPORT_INTERVAL=120,s.REPORT_SDKAPPID_BLACKLIST=[],s.REPORT_TINYID_WHITELIST=[],s._statInfoArr=[],s._avgRTT=new Ba,s._avgE2EDelay=new ja,s._rateMessageSent=new Ya,s._rateMessageReceived=new Wa;var a=s.getIEmitInst();return a.on(mi.A2KEY_AND_TINYID_UPDATED,s._onLoginSuccess,s),a.on(mi.CLOUD_CONFIG,s._onCloudConfig,s),s}return d(t,e),r(t,[{key:"_onLoginSuccess",value:function(){var e=this;this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var t=this.get(zn),n=t.getItem(this.TAG,!1);!st(n)&&ft(n.forEach)&&(Be.l("".concat(this._n,"._onLoginSuccess. logs count:").concat(n.length)),n.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),n=this.getCloudConfig("q_rpt_tinyid_wl");gt(e)||(this.REPORT_INTERVAL=Number(e)),gt(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((function(e){return Number(e)}))),gt(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)||Be.w("".concat(this._n,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||Be.w("".concat(this._n,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||Be.w("".concat(this._n,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||Be.w("".concat(this._n,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||Be.w("".concat(this._n,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||Be.w("".concat(this._n,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var t={},n=ws[this.get(Jn).getNetworkType()];gt(n)&&(n=8);var s={qualityType:Us[e],timestamp:xe(),networkType:n,extension:""};switch(e){case Ts:t=this._avgRTT.getStatResult();break;case Ss:t=this._avgE2EDelay.getStatResult();break;case Es:case ks:case Ds:case Os:case Rs:t=this._rateMessageSent.getStatResult(e);break;case As:case Ns:case Ls:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:_(_({},s),t)}},{key:"_report",value:function(e){var t=this,n=[],s=null;gt(e)?this._qualityItems.forEach((function(e){null!==(s=t._getQualityItem(e))&&(s.reportIndex=t.reportIndex,s.wholePeriod=t.wholePeriod,n.push(s))})):null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,n.push(s)),Be.d("".concat(this._n,"._report"),n),this._statInfoArr.length>0&&(n=n.concat(this._statInfoArr),this._statInfoArr=[]);var i=this.get(Wn),a=i.getSDKAppID(),o=i.getTinyID();Yt(this.REPORT_SDKAPPID_BLACKLIST,a)&&!Wt(this.REPORT_TINYID_WHITELIST,o)&&(n=[]),n.length>0&&this._doReport(n)}},{key:"_doReport",value:function(e){var t=this,n={header:zi(this),quality:e};this.req({P:Cs.SSO_STAT,data:_({},n)}).then((function(){t.reportIndex++,t.wholePeriod=!1})).catch((function(n){Be.w("".concat(t._n,"._doReport failed. error:"),n),t._statInfoArr=t._statInfoArr.concat(e),t._flushAtOnce()}))}},{key:"_flushAtOnce",value:function(){var e=this.get(zn),t=e.getItem(this.TAG,!1),n=this._statInfoArr,s="".concat(this._n,"._flushAtOnce");if(st(t))Be.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1);else{var i=n.concat(t);i.length>10&&(i=i.slice(0,10)),Be.l("".concat(s," count:").concat(i.length)),e.setItem(this.TAG,i,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}])}(Ms),$a=function(e){function t(e){var s;return i(this,t),(s=n(this,t,[e]))._n="WorkerTimerModule",s._isWorkerEnabled=!0,s._workerTimer=null,s._timerID=-1,s._init(),s.getIEmitInst().on(mi.CLOUD_CONFIG,s._onCloudConfig,s),s}return d(t,e),r(t,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&Ne}},{key:"startWorkerTimer",value:function(){Be.l("".concat(this._n,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){Be.l("".concat(this._n,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){if(Ne){var e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000); postMessage(interval); } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);var t=this;this._workerTimer.onmessage=function(e){e.data?(t._timerID=e.data,Be.l("".concat(t._n,"._init seed:").concat(t._timerID))):t._m.onCheckTimer()}}}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("enable_worker");Be.l("".concat(this._n,"._onCloudConfig enableWorker:").concat(e)),gt(e)||"1"===e?!this._isWorkerEnabled&&Ne&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&Ne&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}},{key:"terminate",value:function(){Be.l("".concat(this._n,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}},{key:"getTimerID",value:function(){return this._timerID}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}])}(Ms),Ja=r((function e(t){i(this,e),this._commercialConfigM=t,this._n="PurchasedFeatureHandler",this._isCSPluginReported=!1,this._featureMap=new Map}),[{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){if(this.isValidPurchaseBits(e)){this._featureMap.clear();for(var t=null,n=e.length-1,s=0;n>=0;n--,s++)t=s<32?new R(0,Math.pow(2,s)).toString():new R(Math.pow(2,s-32),0).toString(),"1"===e[n]?this._featureMap.set(t,!0):this._featureMap.set(t,!1)}else Be.w("".concat(this._n,".parsePurchaseBits invalid purchasebits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._featureMap.get(e)}},{key:"isFeatureEnabled",value:function(e){for(var t=parseInt(e).toString(2),n=void 0,s=!0,i=t.length-1,a=0;i>=0;i--,a++)if("1"===t.charAt(i)&&(n=a<32?new R(0,Math.pow(2,a)).toString():new R(Math.pow(2,a-32),0).toString(),!this._featureMap.get(n))){s=!1;break}return Be.l("".concat(this._n,".isFeatureEnabled decimalNumber:").concat(e," key:").concat(n," ret:").concat(s)),ys({enabled:s})}},{key:"isFeatureEnabledForStat",value:function(e){for(var t=parseInt(e).toString(2),n=void 0,s=t.length-1,i=0;s>=0;s--,i++)if("1"===t.charAt(s)){if(n=i<32?new R(0,Math.pow(2,i)).toString():new R(Math.pow(2,i-32),0).toString(),!this._featureMap.get(n))break;var a="",o=0;if(n===j.PLUGIN_TRANSLATE?(a="plugin_translate",o=16):n===j.PLUGIN_VOICE_TO_TEXT?(a="plugin_voice_to_text",o=17):n===j.PLUGIN_CS?(a="plugin_cs",o=14):n===j.PLUGIN_PUSH?(a="plugin_push",o=13):n===j.PLUGIN_BOT?(a="plugin_bot",o=15):n===j.MSG_REACTION&&(a="plugin_emoji_reaction",o=18),""!==a){var r=this._commercialConfigM.get(Wn).getUIPlatform();new Gs(a).setCode(o).setUIPlatform(r).end(),Be.l("".concat(this._n,".isFeatureEnabledForStat ").concat(a," code:").concat(o," uiPlatform:").concat(r))}}}},{key:"isCSPluginEnabled",value:function(){if(!this._isCSPluginReported){var e=this._commercialConfigM.get(Wn).getUIPlatform();new Gs("plugin_search").setCode(6).setUIPlatform(e).end(),this._isCSPluginReported=!0}}},{key:"clear",value:function(){this._featureMap.clear(),this._isCSPluginReported=!1}}]),Xa=r((function e(t){i(this,e),this._m=t,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new Ja(this)}),[{key:"_canFetch",value:function(){return this.get(Wn).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._n,".fetchConfig");if(Be.l("".concat(n," canFetch:").concat(t)),t){var s=new Gs("fetchCommercialConfig"),i=this.get(Wn).getSDKAppID(),a=this.get(es);this._isFetching=!0,a.req({P:Cs.FETCH_COMMERCIAL_CONFIG,data:{SDKAppID:i}}).then((function(t){s.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),Be.l("".concat(n," ok.")),e._parseConfig(t.data),e._isFetching=!1})).catch((function(t){s.setError(t).end(),e._isFetching=!1}))}}},{key:"onPushedConfig",value:function(e){var t="".concat(this._n,".onPushedConfig data:").concat(JSON.stringify(e));Be.l("".concat(t)),new Gs("pushedCommercialConfig").setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._n,"._parseConfig"),n=e.errorCode,s=e.errorMessage,i=e.purchaseBits,a=e.expiredTime;0===n?(this._purchasedFeatureHandler.parsePurchaseBits(i),this._expiredTime=Date.now()+1e3*a):gt(n)?(Be.l("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(Be.e("".concat(t," errorCode:").concat(n," errorMessage:").concat(s)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"canIUse",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"isFeatureEnabled",value:function(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}},{key:"isFeatureEnabledForStat",value:function(e){this._purchasedFeatureHandler.isFeatureEnabledForStat(e)}},{key:"isCSPluginEnabled",value:function(){this._purchasedFeatureHandler.isCSPluginEnabled()}},{key:"get",value:function(e){return this._m.get(e)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),Za=r((function e(t){i(this,e),this._m=t,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"],this._TRTCCommandMap=new Map,this._setTRTCCommandMap(),this._m.getIEmitInst().on(mi.CLOUD_CONFIG,this._onCloudConfig,this)}),[{key:"_onCloudConfig",value:function(){var e=this,t=this._m.get(ns).getCloudConfig("rtc_cmd");gt(t)||((t=JSON.parse(t)).forEach((function(t){e._TRTCCommandList.includes(t)||e._TRTCCommandList.push(t)})),this._setTRTCCommandMap())}},{key:"_setTRTCCommandMap",value:function(){for(var e=null,t=0,n=this._TRTCCommandList.length;t<n;t++)e=this._TRTCCommandList[t].split(".")[0],this._TRTCCommandMap.set(e,1)}},{key:"onRoomCustomDataReceived",value:function(e){this._m.getOEmitInst().emit(k.ROOM_CUSTOM_DATA_RECEIVED,e)}},{key:"sendTRTCCustomData",value:function(e){var t=e.serviceCommand,n=e.data,s="".concat(H.NAME.TUIROOM_SVR,".*");return gt(t)||(s=t),this._isValidServiceCommand(s)?this._trans({servcmd:s,data:n}):Is({code:_s.INVALID_TRTC_CMD})}},{key:"_trans",value:function(e){Be.d("".concat(this._n,"._trans. options:").concat(JSON.stringify(e)));var t=e.servcmd,n=e.data;return this._m.get(es).trans({servcmd:t,data:ut(n)?JSON.parse(n):n})}},{key:"_isValidServiceCommand",value:function(e){if(e.endsWith(".*"))return this._TRTCCommandList.includes(e);var t=e.split(".")[0];return this._TRTCCommandMap.has(t)}},{key:"isTRTCCommand",value:function(e){var t=e.split(".")[0];return this._TRTCCommandMap.has(t)}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}]),Qa=r((function e(t){i(this,e),this._m=t,this._n="ErrMsgModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this.CURRENT_DOMAIN=B,this._map=new Map,this._init()}),[{key:"_init",value:function(){var e=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(e){var t;try{t=JSON.parse(e)}catch(e){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),Be.w("".concat(this._n,"._init error:"),e)}t&&(this._needToUpdate(t)?this._fetch():this._fillMap(t.message))}else this._fetch()}},{key:"_needToUpdate",value:function(e){var t=e.localSavedTime,n=e.localSavedVersion,s=t&&(new Date).getTime()-t>=this.STORAGE_EXPIRES_TIME,i=!n||n!==E;return Be.l("".concat(this._n,"._needToUpdate isTimeout:").concat(s," isDifferentVersion:").concat(i)),s||i}},{key:"_fetch",value:function(){this._m.get(Wn).isPrivateNetWork()||this._fetchWithRetry()}},{key:"_fetchWithRetry",value:function(){var e=this;this._fetchAdapter().catch((function(){e.CURRENT_DOMAIN!==W&&(e._generateCurrentDomain(),e._fetchWithRetry())}))}},{key:"_generateCurrentDomain",value:function(){this.CURRENT_DOMAIN===B?this.CURRENT_DOMAIN=Y:this.CURRENT_DOMAIN===Y&&(this.CURRENT_DOMAIN=W)}},{key:"_fetchAdapter",value:function(){var e="https://".concat(this.CURRENT_DOMAIN,"/im/download/error-message/v3/0.0.7/tim-error-message.txt"),t="application/x-www-form-urlencoded;charset=UTF-8",n="".concat(this._n,"._fetchAdapter ok in"),s=this;return new Promise((function(i,a){if(ue)ge.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:function(e){s._fillAndSave(e.data),Be.l("".concat(n," mini program.")),i()},fail:function(e){a(e)}});else{var o=new XMLHttpRequest,r=setTimeout((function(){o.abort()}),3e3);o.onreadystatechange=function(){4===o.readyState&&(r&&clearTimeout(r),200===o.status||304===o.status?(Be.l("".concat(n," browser.")),s._fillAndSave(o.responseText),i()):a(o.status))},o.onerror=function(e){a(e)},o.open("GET",e,!0),o.setRequestHeader("Content-type",t),o.send()}}))}},{key:"_fillAndSave",value:function(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:E}),!0,!1)}},{key:"_getStorageModule",value:function(){return this._m.get(zn)}},{key:"_fillMap",value:function(e){this._map.clear();for(var t,n,s,i=e.split(";\n"),a=i.length,o=new RegExp(/'/g),r=0;r<a;r++)if(t=i[r].indexOf(":"),n=i[r].slice(0,t),s=i[r].slice(t+1,i[r].length),!n.startsWith("//")){if(gt(s))continue;this._map.set(n,s.replace(o,""))}}},{key:"get",value:function(e){var t=e.isIntl,n=e.key,s=e.replacement1,i=e.replacement2,a="".concat(n,t?"_en":"_cn");!this._map.has(a)&&this._map.has(n)&&(a=n);var o="";return this._map.has(a)?(o=this._map.get(a),gt(s)||(o=o.replace("$replacement1",s)),gt(i)||(o=o.replace("$replacement2",i)),o):o}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset"))}}]),eo=Qi((function(e,t){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function s(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==C(n))throw new TypeError(n+"must be non-object");for(var i in n)s(n,i)&&(e[i]=n[i])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,s,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+s),i);else for(var a=0;a<s;a++)e[i+a]=t[n+a]},flattenChunks:function(e){var t,n,s,i,a,o;for(s=0,t=0,n=e.length;t<n;t++)s+=e[t].length;for(o=new Uint8Array(s),i=0,t=0,n=e.length;t<n;t++)a=e[t],o.set(a,i),i+=a.length;return o}},a={arraySet:function(e,t,n,s,i){for(var a=0;a<s;a++)e[i+a]=t[n+a]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,i)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,a))},t.setTyped(n)}));eo.assign,eo.shrinkBuf,eo.setTyped,eo.Buf8,eo.Buf16,eo.Buf32;var to=function(e,t,n,s){for(var i=65535&e,a=e>>>16&65535,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+t[s++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16},no=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}(),so=function(e,t,n,s){var i=no,a=s+n;e^=-1;for(var o=s;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e},io=function(e,t){var n,s,i,a,o,r,c,u,l,d,h,g,p,f,_,v,m,y,I,M,C,T,S,E,k;n=e.state,s=e.next_in,E=e.input,i=s+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),r=a+(e.avail_out-257),c=n.dmax,u=n.wsize,l=n.whave,d=n.wnext,h=n.window,g=n.hold,p=n.bits,f=n.lencode,_=n.distcode,v=(1<<n.lenbits)-1,m=(1<<n.distbits)-1;e:do{p<15&&(g+=E[s++]<<p,p+=8,g+=E[s++]<<p,p+=8),y=f[g&v];t:for(;;){if(g>>>=I=y>>>24,p-=I,0==(I=y>>>16&255))k[a++]=65535&y;else{if(!(16&I)){if(!(64&I)){y=f[(65535&y)+(g&(1<<I)-1)];continue t}if(32&I){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}M=65535&y,(I&=15)&&(p<I&&(g+=E[s++]<<p,p+=8),M+=g&(1<<I)-1,g>>>=I,p-=I),p<15&&(g+=E[s++]<<p,p+=8,g+=E[s++]<<p,p+=8),y=_[g&m];n:for(;;){if(g>>>=I=y>>>24,p-=I,!(16&(I=y>>>16&255))){if(!(64&I)){y=_[(65535&y)+(g&(1<<I)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(C=65535&y,p<(I&=15)&&(g+=E[s++]<<p,(p+=8)<I&&(g+=E[s++]<<p,p+=8)),(C+=g&(1<<I)-1)>c){e.msg="invalid distance too far back",n.mode=30;break e}if(g>>>=I,p-=I,C>(I=a-o)){if((I=C-I)>l&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(T=0,S=h,0===d){if(T+=u-I,I<M){M-=I;do{k[a++]=h[T++]}while(--I);T=a-C,S=k}}else if(d<I){if(T+=u+d-I,(I-=d)<M){M-=I;do{k[a++]=h[T++]}while(--I);if(T=0,d<M){M-=I=d;do{k[a++]=h[T++]}while(--I);T=a-C,S=k}}}else if(T+=d-I,I<M){M-=I;do{k[a++]=h[T++]}while(--I);T=a-C,S=k}for(;M>2;)k[a++]=S[T++],k[a++]=S[T++],k[a++]=S[T++],M-=3;M&&(k[a++]=S[T++],M>1&&(k[a++]=S[T++]))}else{T=a-C;do{k[a++]=k[T++],k[a++]=k[T++],k[a++]=k[T++],M-=3}while(M>2);M&&(k[a++]=k[T++],M>1&&(k[a++]=k[T++]))}break}}break}}while(s<i&&a<r);s-=M=p>>3,g&=(1<<(p-=M<<3))-1,e.next_in=s,e.next_out=a,e.avail_in=s<i?i-s+5:5-(s-i),e.avail_out=a<r?r-a+257:257-(a-r),n.hold=g,n.bits=p},ao=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],oo=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],ro=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],co=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],uo=function(e,t,n,s,i,a,o,r){var c,u,l,d,h,g,p,f,_,v=r.bits,m=0,y=0,I=0,M=0,C=0,T=0,S=0,E=0,k=0,D=0,O=null,R=0,A=new eo.Buf16(16),N=new eo.Buf16(16),L=null,U=0;for(m=0;m<=15;m++)A[m]=0;for(y=0;y<s;y++)A[t[n+y]]++;for(C=v,M=15;M>=1&&0===A[M];M--);if(C>M&&(C=M),0===M)return i[a++]=20971520,i[a++]=20971520,r.bits=1,0;for(I=1;I<M&&0===A[I];I++);for(C<I&&(C=I),E=1,m=1;m<=15;m++)if(E<<=1,(E-=A[m])<0)return-1;if(E>0&&(0===e||1!==M))return-1;for(N[1]=0,m=1;m<15;m++)N[m+1]=N[m]+A[m];for(y=0;y<s;y++)0!==t[n+y]&&(o[N[t[n+y]]++]=y);if(0===e?(O=L=o,g=19):1===e?(O=ao,R-=257,L=oo,U-=257,g=256):(O=ro,L=co,g=-1),D=0,y=0,m=I,h=a,T=C,S=0,l=-1,d=(k=1<<C)-1,1===e&&k>852||2===e&&k>592)return 1;for(;;){p=m-S,o[y]<g?(f=0,_=o[y]):o[y]>g?(f=L[U+o[y]],_=O[R+o[y]]):(f=96,_=0),c=1<<m-S,I=u=1<<T;do{i[h+(D>>S)+(u-=c)]=p<<24|f<<16|_}while(0!==u);for(c=1<<m-1;D&c;)c>>=1;if(0!==c?(D&=c-1,D+=c):D=0,y++,0==--A[m]){if(m===M)break;m=t[n+o[y]]}if(m>C&&(D&d)!==l){for(0===S&&(S=C),h+=I,E=1<<(T=m-S);T+S<M&&!((E-=A[T+S])<=0);)T++,E<<=1;if(k+=1<<T,1===e&&k>852||2===e&&k>592)return 1;i[l=D&d]=C<<24|T<<16|h-a}}return 0!==D&&(i[h+D]=m-S<<24|64<<16),r.bits=C,0};function lo(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ho(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new eo.Buf16(320),this.work=new eo.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function go(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new eo.Buf32(852),t.distcode=t.distdyn=new eo.Buf32(592),t.sane=1,t.back=-1,0):-2}function po(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,go(e)):-2}function fo(e,t){var n,s;return e&&e.state?(s=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=n,s.wbits=t,po(e))):-2}function _o(e,t){var n,s;return e?(s=new ho,e.state=s,s.window=null,0!==(n=fo(e,t))&&(e.state=null),n):-2}var vo,mo,yo=!0;function Io(e){if(yo){var t;for(vo=new eo.Buf32(512),mo=new eo.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(uo(1,e.lens,0,288,vo,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;uo(2,e.lens,0,32,mo,0,e.work,{bits:5}),yo=!1}e.lencode=vo,e.lenbits=9,e.distcode=mo,e.distbits=5}function Mo(e,t,n,s){var i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new eo.Buf8(a.wsize)),s>=a.wsize?(eo.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>s&&(i=s),eo.arraySet(a.window,t,n-s,i,a.wnext),(s-=i)?(eo.arraySet(a.window,t,n-s,s,0),a.wnext=s,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}var Co={inflateReset:po,inflateReset2:fo,inflateResetKeep:go,inflateInit:function(e){return _o(e,15)},inflateInit2:_o,inflate:function(e,t){var n,s,i,a,o,r,c,u,l,d,h,g,p,f,_,v,m,y,I,M,C,T,S,E,k=0,D=new eo.Buf8(4),O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,s=e.input,r=e.avail_in,u=n.hold,l=n.bits,d=r,h=c,T=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(2&n.wrap&&35615===u){n.check=0,D[0]=255&u,D[1]=u>>>8&255,n.check=so(n.check,D,2,0),u=0,l=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",n.mode=30;break}if(l-=4,C=8+(15&(u>>>=4)),0===n.wbits)n.wbits=C;else if(C>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<C,e.adler=n.check=1,n.mode=512&u?10:12,u=0,l=0;break;case 2:for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(n.flags=u,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=u>>8&1),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=so(n.check,D,2,0)),u=0,l=0,n.mode=3;case 3:for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.head&&(n.head.time=u),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,D[2]=u>>>16&255,D[3]=u>>>24&255,n.check=so(n.check,D,4,0)),u=0,l=0,n.mode=4;case 4:for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.head&&(n.head.xflags=255&u,n.head.os=u>>8),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=so(n.check,D,2,0)),u=0,l=0,n.mode=5;case 5:if(1024&n.flags){for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.length=u,n.head&&(n.head.extra_len=u),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=so(n.check,D,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((g=n.length)>r&&(g=r),g&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),eo.arraySet(n.head.extra,s,a,g,C)),512&n.flags&&(n.check=so(n.check,s,g,a)),r-=g,a+=g,n.length-=g),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===r)break e;g=0;do{C=s[a+g++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C))}while(C&&g<r);if(512&n.flags&&(n.check=so(n.check,s,g,a)),r-=g,a+=g,C)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===r)break e;g=0;do{C=s[a+g++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C))}while(C&&g<r);if(512&n.flags&&(n.check=so(n.check,s,g,a)),r-=g,a+=g,C)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}u=0,l=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}e.adler=n.check=lo(u),u=0,l=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){u>>>=7&l,l-=7&l,n.mode=27;break}for(;l<3;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}switch(n.last=1&u,l-=1,3&(u>>>=1)){case 0:n.mode=14;break;case 1:if(Io(n),n.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&u,u=0,l=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(g=n.length){if(g>r&&(g=r),g>c&&(g=c),0===g)break e;eo.arraySet(i,s,a,g,o),r-=g,a+=g,c-=g,o+=g,n.length-=g;break}n.mode=12;break;case 17:for(;l<14;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(n.nlen=257+(31&u),u>>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;l<3;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.lens[O[n.have++]]=7&u,u>>>=3,l-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},T=uo(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,T){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;v=(k=n.lencode[u&(1<<n.lenbits)-1])>>>16&255,m=65535&k,!((_=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(m<16)u>>>=_,l-=_,n.lens[n.have++]=m;else{if(16===m){for(E=_+2;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u>>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}C=n.lens[n.have-1],g=3+(3&u),u>>>=2,l-=2}else if(17===m){for(E=_+3;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}l-=_,C=0,g=3+(7&(u>>>=_)),u>>>=3,l-=3}else{for(E=_+7;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}l-=_,C=0,g=11+(127&(u>>>=_)),u>>>=7,l-=7}if(n.have+g>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;g--;)n.lens[n.have++]=C}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,S={bits:n.lenbits},T=uo(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,T){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},T=uo(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,T){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(r>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,io(e,h),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,s=e.input,r=e.avail_in,u=n.hold,l=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;v=(k=n.lencode[u&(1<<n.lenbits)-1])>>>16&255,m=65535&k,!((_=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(v&&!(240&v)){for(y=_,I=v,M=m;v=(k=n.lencode[M+((u&(1<<y+I)-1)>>y)])>>>16&255,m=65535&k,!(y+(_=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}u>>>=y,l-=y,n.back+=y}if(u>>>=_,l-=_,n.back+=_,n.length=m,0===v){n.mode=26;break}if(32&v){n.back=-1,n.mode=12;break}if(64&v){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&v,n.mode=22;case 22:if(n.extra){for(E=n.extra;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.length+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;v=(k=n.distcode[u&(1<<n.distbits)-1])>>>16&255,m=65535&k,!((_=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(!(240&v)){for(y=_,I=v,M=m;v=(k=n.distcode[M+((u&(1<<y+I)-1)>>y)])>>>16&255,m=65535&k,!(y+(_=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}u>>>=y,l-=y,n.back+=y}if(u>>>=_,l-=_,n.back+=_,64&v){e.msg="invalid distance code",n.mode=30;break}n.offset=m,n.extra=15&v,n.mode=24;case 24:if(n.extra){for(E=n.extra;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.offset+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===c)break e;if(g=h-c,n.offset>g){if((g=n.offset-g)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}g>n.wnext?(g-=n.wnext,p=n.wsize-g):p=n.wnext-g,g>n.length&&(g=n.length),f=n.window}else f=i,p=o-n.offset,g=n.length;g>c&&(g=c),c-=g,n.length-=g;do{i[o++]=f[p++]}while(--g);0===n.length&&(n.mode=21);break;case 26:if(0===c)break e;i[o++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;l<32;){if(0===r)break e;r--,u|=s[a++]<<l,l+=8}if(h-=c,e.total_out+=h,n.total+=h,h&&(e.adler=n.check=n.flags?so(n.check,i,h,o-h):to(n.check,i,h,o-h)),h=c,(n.flags?u:lo(u))!==n.check){e.msg="incorrect data check",n.mode=30;break}u=0,l=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}u=0,l=0}n.mode=29;case 29:T=1;break e;case 30:T=-3;break e;case 31:return-4;default:return-2}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,(n.wsize||h!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&Mo(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,n.total+=h,n.wrap&&h&&(e.adler=n.check=n.flags?so(n.check,i,h,e.next_out-h):to(n.check,i,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===d&&0===h||4===t)&&0===T&&(T=-5),T},inflateEnd:function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},inflateGetHeader:function(e,t){var n;return e&&e.state&&2&(n=e.state).wrap?(n.head=t,t.done=!1,0):-2},inflateSetDictionary:function(e,t){var n,s=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&to(1,t,s,0)!==n.check?-3:Mo(e,t,s,s)?(n.mode=31,-4):(n.havedict=1,0):-2},inflateInfo:"pako inflate (from Nodeca project)"},To=!0,So=!0;try{String.fromCharCode.apply(null,[0])}catch(e){To=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){So=!1}for(var Eo=new eo.Buf8(256),ko=0;ko<256;ko++)Eo[ko]=ko>=252?6:ko>=248?5:ko>=240?4:ko>=224?3:ko>=192?2:1;function Do(e,t){if(t<65534&&(e.subarray&&So||!e.subarray&&To))return String.fromCharCode.apply(null,eo.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}Eo[254]=Eo[254]=1;var Oo=function(e){var t,n,s,i,a,o=e.length,r=0;for(i=0;i<o;i++)55296==(64512&(n=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(s=e.charCodeAt(i+1)))&&(n=65536+(n-55296<<10)+(s-56320),i++),r+=n<128?1:n<2048?2:n<65536?3:4;for(t=new eo.Buf8(r),a=0,i=0;a<r;i++)55296==(64512&(n=e.charCodeAt(i)))&&i+1<o&&56320==(64512&(s=e.charCodeAt(i+1)))&&(n=65536+(n-55296<<10)+(s-56320),i++),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},Ro=function(e){for(var t=new eo.Buf8(e.length),n=0,s=t.length;n<s;n++)t[n]=e.charCodeAt(n);return t},Ao=function(e,t){var n,s,i,a,o=t||e.length,r=new Array(2*o);for(s=0,n=0;n<o;)if((i=e[n++])<128)r[s++]=i;else if((a=Eo[i])>4)r[s++]=65533,n+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&n<o;)i=i<<6|63&e[n++],a--;a>1?r[s++]=65533:i<65536?r[s++]=i:(i-=65536,r[s++]=55296|i>>10&1023,r[s++]=56320|1023&i)}return Do(r,s)},No=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Eo[e[n]]>t?n:t},Lo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Uo={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Po=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},wo=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},bo=Object.prototype.toString;function Go(e){if(!(this instanceof Go))return new Go(e);this.options=eo.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Po,this.strm.avail_out=0;var n=Co.inflateInit2(this.strm,t.windowBits);if(n!==Lo.Z_OK)throw new Error(Uo[n]);if(this.header=new wo,Co.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Oo(t.dictionary):"[object ArrayBuffer]"===bo.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Co.inflateSetDictionary(this.strm,t.dictionary))!==Lo.Z_OK))throw new Error(Uo[n])}function Fo(e,t){var n=new Go(t);if(n.push(e,!0),n.err)throw n.msg||Uo[n.err];return n.result}Go.prototype.push=function(e,t){var n,s,i,a,o,r=this.strm,c=this.options.chunkSize,u=this.options.dictionary,l=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?Lo.Z_FINISH:Lo.Z_NO_FLUSH,"string"==typeof e?r.input=Ro(e):"[object ArrayBuffer]"===bo.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new eo.Buf8(c),r.next_out=0,r.avail_out=c),(n=Co.inflate(r,Lo.Z_NO_FLUSH))===Lo.Z_NEED_DICT&&u&&(n=Co.inflateSetDictionary(this.strm,u)),n===Lo.Z_BUF_ERROR&&!0===l&&(n=Lo.Z_OK,l=!1),n!==Lo.Z_STREAM_END&&n!==Lo.Z_OK)return this.onEnd(n),this.ended=!0,!1;r.next_out&&(0!==r.avail_out&&n!==Lo.Z_STREAM_END&&(0!==r.avail_in||s!==Lo.Z_FINISH&&s!==Lo.Z_SYNC_FLUSH)||("string"===this.options.to?(i=No(r.output,r.next_out),a=r.next_out-i,o=Ao(r.output,i),r.next_out=a,r.avail_out=c-a,a&&eo.arraySet(r.output,r.output,i,a,0),this.onData(o)):this.onData(eo.shrinkBuf(r.output,r.next_out)))),0===r.avail_in&&0===r.avail_out&&(l=!0)}while((r.avail_in>0||0===r.avail_out)&&n!==Lo.Z_STREAM_END);return n===Lo.Z_STREAM_END&&(s=Lo.Z_FINISH),s===Lo.Z_FINISH?(n=Co.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Lo.Z_OK):s!==Lo.Z_SYNC_FLUSH||(this.onEnd(Lo.Z_OK),r.avail_out=0,!0)},Go.prototype.onData=function(e){this.chunks.push(e)},Go.prototype.onEnd=function(e){e===Lo.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=eo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var xo={Inflate:Go,inflate:Fo,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Fo(e,t)},ungzip:Fo},Vo={};(0,eo.assign)(Vo,xo,Lo);var qo=Vo,Ko=r((function e(t){i(this,e),this._m=t,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1}),[{key:"inflate",value:function(e){var t,n=new Uint8Array(e).slice(4),s=Date.now();try{t=qo.inflate(n,{to:"string"}),this._bLogForInflateOK||(this._bLogForInflateOK=!0,new Gs("inflateOK").end())}catch(e){if(this._bLogForInflateError)return;return this._bLogForInflateError=!0,void new Gs("inflateError").setMessage(e).end()}var i=n.length+4,a=t.length;return Be.d("inflate ok. zipped:".concat(i," unzipped:").concat(a)+" compression ratio:".concat(Math.round(100*(a-i)/a),"% cost:").concat(Date.now()-s)),t}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}]),Ho=r((function e(t){i(this,e);var n=new Gs("sdkConstruct");this._n="ModuleManager",this._isReady=!1,this._reason=_s.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._map=new Map,this._optionalModuleMap=new Map,this._codeMsgForTUIMap=new Map,this._iEmitter=null,this._oEmitter=null,this._checkCount=0,this._checkTimer=-1,this._map.set(Wn,new Ki(this,t)),this._map.set(gs,new Ko(this)),this._map.set(Jn,new Zi(this)),this._map.set(os,new Xa(this)),this._map.set(ns,new Ka(this)),this._map.set(ss,new $a(this)),this._map.set(as,new za(this)),this._map.set(ts,new Na(this)),this._map.set(es,new qa(this)),this._map.set(Fn,new ji(this)),this._map.set(xn,new la(this)),this._map.set(qn,new qi(this)),this._map.set(Kn,new vi(this)),this._map.set(Yn,new Fi(this)),this._map.set(zn,new Yi(this)),this._map.set(us,new Qa(this)),this._map.set($n,new $i(this)),this._map.set(Xn,new aa(this)),this._map.set(Zn,new da(this)),this._map.set(Qn,new ha(this)),this._map.set(is,new Ha(this)),this._map.set(rs,new Za(this)),this._eventThrottleMap=new Map,this._eventThrottling=t.eventThrottling,this._map.get(Wn).isPartialUpdatedConvs()&&(this._eventThrottling=!1),this._map.has(Hn)||this._map.get(Wn).setUsingChatCore(!0);var s=t.instanceID,a=t.SDKAppID,o=this._map.get(Wn).isIntl(),r=this._map.get(Wn).isUsingChatCore(),c="instanceID:".concat(s," SDKAppID:").concat(a," isIntl:").concat(o," isUsingChatCore:").concat(r," host:").concat(Vt())+" isIOSWebView:".concat(Ue," platform:").concat(_e," canIUseInflate:").concat(this.canIUseInflate())+" workerAvailable:".concat(Ne," eventThrottling:").concat(this._eventThrottling," UserAgent:").concat(pe);Gs.bindEventStatModule(this._map.get($n)),Gs.bindNetMonitorModule(this._map.get(Jn)),n.setMessage("".concat(c," ").concat(function(){var e="";if(ue)try{var t=ge.getSystemInfoSync(),n=t.model,s=t.version,i=t.system,a=t.platform,o=t.SDKVersion;e="model:".concat(n," version:").concat(s," system:").concat(i," platform:").concat(a," SDKVersion:").concat(o)}catch(t){e=""}return e}())).end(),Be.i("SDK ".concat(c)),fs.prototype._getErrMsg=this.getErrMsg.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}),[{key:"_startTimer",value:function(){var e=this._map.get(ss),t=e.isWorkerEnabled();Be.l("".concat(this._n,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3)),Be.l("".concat(this._n,"._startMainThreadTimer seed:").concat(this._checkTimer))}},{key:"stopTimer",value:function(){var e=this._map.get(ss),t=e.isWorkerEnabled();Be.l("".concat(this._n,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){Be.l("".concat(this._n,"._stopMainThreadTimer")),this._checkTimer>0&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){Be.l("".concat(this._n,"._stopMainThreadSocket"));var e=this._map.get(ts);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){Be.l("".concat(this._n,"._startMainThreadSocket"));var e=this._map.get(ts);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){Be.l("".concat(this._n,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){Be.l("".concat(this._n,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=c(this._map);try{for(t.s();!(e=t.n()).done;){var n=y(e.value,2)[1];n.onCheckTimer&&n.onCheckTimer(this._checkCount)}}catch(e){t.e(e)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._map.get(Fn)],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._oEmitter.emit(k.SDK_READY);var t=Date.now()-this._startLoginTs;Be.w("SDK is ready. cost ".concat(t," ms")),this._startLoginTs=Date.now();var n=this._ssoLogForReady.getStartTs()+Fe;this._ssoLogForReady.setMessage(t).start(n).end()}}},{key:"login",value:function(){0===this._startLoginTs&&(Ve(),this._startLoginTs=Date.now(),this._startTimer(),this._map.get(Jn).start(),this._ssoLogForReady=new Gs("sdkReady"),this._reason=_s.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOEmitInst",value:function(){return null===this._oEmitter&&(this._oEmitter=new ea,ms(this._oEmitter),this._oEmitter._emit=this._oEmitter.emit,this._oEmitter.emit=function(e,t){var n=this;if(this._canIUseSignaling()&&(e===k.MESSAGE_RECEIVED&&this.get(ls).onNewMessageList(t),e===k.MESSAGE_MODIFIED&&this.get(ls).onMessageModified(t)),e===k.MESSAGE_RECEIVED&&this.get(Yn).getStreamMessageBeforeEmit(t),e===k.CONVERSATION_LIST_UPDATED||e===k.FRIEND_LIST_UPDATED||e===k.GROUP_LIST_UPDATED||e===k.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED)if(!1!==this._eventThrottling)if(this._eventThrottleMap.has(e)){var s=Date.now(),i=this._eventThrottleMap.get(e);s-i.last<=1e3?(i.timeoutID>-1&&clearTimeout(i.timeoutID),i.timeoutID=setTimeout((function(){i.last=Date.now(),n._oEmitter._emit.apply(n._oEmitter,[e,{name:e,data:n._getEventData(e)}])}),1e3)):(i.last=s,this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:arguments[1]}])}.bind(this)),this._oEmitter}},{key:"_canIUseSignaling",value:function(){var e=this.get(ls);return!!e&&e.canIUseSignaling()}},{key:"_getEventData",value:function(e){return e===k.CONVERSATION_LIST_UPDATED?this._map.get(Wn).isPartialUpdatedConvs()?this._map.get(Yn).getPartialUpdatedConvs():this._map.get(Yn).getLocalConvList():e===k.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._map.get(Yn).getTotalUnreadCount():void 0}},{key:"getIEmitInst",value:function(){return null===this._iEmitter&&(this._iEmitter=new ea,this._iEmitter._emit=this._iEmitter.emit,this._iEmitter.emit=function(e,t){var n;n=dt(arguments[1])&&arguments[1].data?[e,{name:arguments[0],data:arguments[1].data}]:[e,{name:arguments[0],data:arguments[1]}],this._iEmitter._emit.apply(this._iEmitter,n)}.bind(this)),this._iEmitter}},{key:"hasModule",value:function(e){return this._map.has(e)}},{key:"get",value:function(e){return this._map.get(e)}},{key:"canIUseModule",value:function(e){return!this._map.get(Wn).isUsingChatCore()||this._optionalModuleMap.has(e)}},{key:"canIUseInflate",value:function(){return!!this._map.get(gs)}},{key:"isReady",value:function(){return this._isReady}},{key:"isIntl",value:function(){return this.get(Wn).isIntl()}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"getErrMsg",value:function(e,t,n){return this._map.get(us).get({key:e,replacement1:t,replacement2:n,isIntl:this.isIntl()})}},{key:"warn",value:function(e,t,n){var s=this.getErrMsg(e,t,n);s&&Be.w(s)}},{key:"onError",value:function(e){var t="code:".concat(e.code," message:").concat(e.message);Be.w("Oops! ".concat(t)),new Gs("error").setMessage(t).setLevel("error").end(),this.getOEmitInst().emit(k.ERROR,e)}},{key:"restartTimer",value:function(){Be.l("".concat(this._n,".restartTimer")),this.stopTimer(),this._startTimer();var e=this.get(Hn);e&&e.restartPolling()}},{key:"getTimerID",value:function(){var e=this._map.get(ss);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}},{key:"getPollingTimerID",value:function(e){return this._map.get(Hn).getPollingTimerID(e)}},{key:"statTUIKeyFeatures",value:function(e){var t=e.code,n=e.msg,s=void 0===n?"":n,i=t+s;if(!this._codeMsgForTUIMap.has(i)){this._codeMsgForTUIMap.set(i,1);var a=this.get(Wn).getUIPlatform();new Gs("tui_key_features").setCode(t).setMessage(s).setUIPlatform(a).end()}}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),Ve();var e,t=c(this._map);try{for(t.s();!(e=t.n()).done;){var n=y(e.value,2)[1];n.reset&&n.reset()}}catch(e){t.e(e)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._oEmitter.emit(k.SDK_NOT_READY);var s,i=c(this._eventThrottleMap);try{for(i.s();!(s=i.n()).done;){var a=y(s.value,2)[1];a.timeoutID>-1&&clearTimeout(a.timeoutID)}}catch(e){i.e(e)}finally{i.f()}this._eventThrottleMap.clear(),this._codeMsgForTUIMap.clear()}}]),jo=r((function e(t){i(this,e),this._funcMap=new Map,this._m=t,this._n="SafetyCallback",this._reportCount=0}),[{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 s=null;return this._funcMap.get(e).has(t)?s=this._funcMap.get(e).get(t):(s=this._pack(e,t,n),this._funcMap.get(e).set(t,s)),s}},{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):(this._m.warn("ListenerFnNotFound",e),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){var s=this;return function(){try{t.apply(n,Array.from(arguments))}catch(t){var i=Object.values(k).indexOf(e),a="CallbackError";if(-1!==i){var o=Object.keys(k)[i];s._m.warn(a,o,t)}s._reportCount<5&&(new Gs(a).setMessage("eventName:".concat(e)).setMoreMessage(t.message).end(),s._reportCount+=1)}}}},{key:"destroy",value:function(){this._funcMap.clear()}},{key:"reset",value:function(){Be.l("".concat(this._n,".reset")),this._reportCount=0}}]),Bo=r((function e(t){i(this,e);var n={SDKAppID:t.SDKAppID,unlimitedAVChatRoom:t.unlimitedAVChatRoom||!1,scene:t.scene||"",oversea:t.oversea||!1,instanceID:xt(),devMode:t.devMode||!1,testEnv:t.testEnv||!1,proxyServer:t.proxyServer||void 0,fileUploadProxy:t.fileUploadProxy||void 0,fileDownloadProxy:t.fileDownloadProxy||t.fileUploadProxy||void 0,eventThrottling:!1!==t.eventThrottling,partialUpdatedConversations:!0===t.partialUpdatedConversations,disableIndependentDomain:!0===t.disableIndependentDomain,modules:t.modules||void 0};this._m=new Ho(n),this._safetyCallbackFactory=new jo(this._m)}),[{key:"onError",value:function(e){this._m.onError(e)}},{key:"login",value:function(e){return this._m.login(),this._get(Fn).login(e)}},{key:"logout",value:function(){var e=this;return this._get(Fn).logout().then((function(t){return e._safetyCallbackFactory.reset(),e._m.reset(),t}))}},{key:"getLoginUser",value:function(){return this._get(Fn).getLoginUser()}},{key:"getServerTime",value:function(){return xe()}},{key:"isReady",value:function(){return this._m.isReady()}},{key:"isIntl",value:function(){return this._m.isIntl()}},{key:"getNotReadyReason",value:function(){return this._m.getNotReadyReason()}},{key:"getErrMsg",value:function(e,t,n){return this._m.getErrMsg(e,t,n)}},{key:"_get",value:function(e){return this._m.get(e)}},{key:"destroy",value:function(){var e=this,t=this._get(Wn),n=t.getSDKAppID();return Be.w("destroy ".concat(n," ").concat(t.getInstanceID())),this.logout().finally((function(){e._safetyCallbackFactory.destroy(),e._m.stopTimer(),e._get(ss).terminate(),e._get(ts).dealloc(),e._m.getOEmitInst().emit(k.SDK_DESTROY,{SDKAppID:n})}))}},{key:"on",value:function(e,t,n){Be.d("on","eventName:".concat(e)),this._m.getOEmitInst().on(e,this._safetyCallbackFactory.defense(e,t,n),n)}},{key:"off",value:function(e,t,n,s){Be.d("off","eventName:".concat(e));var i=this._safetyCallbackFactory.find(e,t);null!==i&&(this._m.getOEmitInst().off(e,i,n,s),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._get(Zn).registerPlugin(e)}},{key:"setLogLevel",value:function(e){if(e<=0){var t=this.getErrMsg("TIM_ASCII_ART");t&&console.log(t);var n=this.getErrMsg("API_REFER");n&&(Xt()?console.log("%c ".concat("IM SDK API ->"," %c"),"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",n):console.log("IM SDK API ->",n));var s=this.getErrMsg("DOCS_GUIDE");s&&console.log(s);var i=this.getErrMsg("IOS_WEBVIEW_WARNING");Ue&&i&&console.warn(i)}Be.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._get(xn).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._get(xn).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._get(xn).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._get(xn).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._get(xn).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._get(xn).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._get(xn).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._get(xn).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._get(xn).createLocationMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof ri?this._get(xn).sendMessageInstance(e,t):Is({code:_s.MSG_INSTANCE_REQUIRED})}},{key:"callExperimentalAPI",value:function(e,t){return"sendComboMessage"===e?this._get(cs).sendMessage(t):"handleGroupInvitation"===e?this._get(Hn).handleGroupInvitation(t):"isCommercialAbilityEnabled"===e?this._get(os).isFeatureEnabled(t):"isFeatureEnabledForStat"===e?this._get(os).isFeatureEnabledForStat(t):"isIntl"===e?this.isIntl():"sendTRTCCustomData"===e||"sendRoomCustomData"===e?this._get(rs).sendTRTCCustomData(t):"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):"setApplicationID"===e?(this._get(Wn).setApplicationID(t),void this._get(es).updateProtocolConfig()):"getServerConfig"===e?this._get(ns).getServerConfig(t):"canIUseModule"===e?this._m.canIUseModule(t):"startMessageLongPolling"===e?this._get(Hn).startMessageLongPolling(t):"stopMessageLongPolling"===e?this._get(Hn).stopMessageLongPolling(t):"disableMessagePullOnInvite"===e?this._get(Yn).disableMsgPullOnInvite(t):"clearLocalMessage"===e?this._get(Yn).clearMemMsg(t,!1):"setCustomLoginInfo"===e?this._get(Wn).setCustomLoginInfo(t):"statTUIKeyFeatures"===e?this._m.statTUIKeyFeatures(t):"getGroupReceiptsByUsers"===e?this._get(Hn).getGroupReceiptsByUsers(t):Is({code:_s.INVALID_OPERATION})}},{key:"revokeMessage",value:function(e){return this._get(xn).revokeMessage(e)}},{key:"resendMessage",value:function(e,t){return e instanceof ri?this._get(xn).resendMessage(e,t):Is({code:_s.MSG_INSTANCE_REQUIRED})}},{key:"deleteMessage",value:function(e){return this._get(xn).deleteMessage(e)}},{key:"translateText",value:function(e){return this._get(xn).translateText(e)}},{key:"convertVoiceToText",value:function(e){return this._get(xn).convertVoiceToText(e)}},{key:"modifyMessage",value:function(e){return this._get(xn).modifyRemoteMessage(e)}},{key:"getMessageList",value:function(e){return this._get(Yn).getMessageList(e)}},{key:"getMessageListHopping",value:function(e){return this._get(Yn).getMessageListHopping(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._get(Yn).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._get(Yn).getReadReceiptList(e)}},{key:"findMessage",value:function(e){return this._get(Yn).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._get(Yn).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._get(Yn).getConvList(e)}},{key:"getConversationProfile",value:function(e){return this._get(Yn).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._get(Yn).deleteConversation(e)}},{key:"setConversationDraft",value:function(e){return this._get(Yn).setConvDraft(e)}},{key:"clearHistoryMessage",value:function(e){return this._get(Yn).clearHistoryMessage(e)}},{key:"pinConversation",value:function(e){return this._get(Yn).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._get(Yn).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._get(Yn).setMessageRemindType(e)}},{key:"setAllReceiveMessageOpt",value:function(e){return this._get(Yn).setAllRcvMsgOpt(e)}},{key:"getAllReceiveMessageOpt",value:function(){return this._get(Yn).getAllRcvMsgOpt()}},{key:"getTotalUnreadMessageCount",value:function(){return this._get(Yn).getTotalUnreadCount()}},{key:"setConversationCustomData",value:function(e){return this._get(Yn).setConvCustomData(e)}},{key:"markConversation",value:function(e){return this._get(Yn).markConv(e)}},{key:"getMyProfile",value:function(){return this._get(qn).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._get(qn).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._get(qn).updateMyProfile(e)}}]),Yo={login:1,logout:1,getLoginUser:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1,isReady:1,addSignalingListener:1,removeSignalingListener:1,callExperimentalAPI:1};function Wo(e,t){if(e.isReady()||1===Yo[t])return!0;var n=e.getNotReadyReason(),s={code:n,message:"".concat(e.getErrMsg(n)," | ").concat(t," | ").concat(e.getErrMsg(_s.SDK_IS_NOT_READY))};return e.onError(s),s}var zo={},$o={create:function(e){var t="TencentCloudChat.create",n=0,s=e.SDKAppID;if(ct(s))n=s;else if(n=parseInt(s),isNaN(s))return Be.e("".concat(t," failed. Failed to parse the SDKAppID, please check the arguments")),null;if(n&&zo[n])return zo[n];Be.l("".concat(t));var i=new Bo(_(_({},e),{},{SDKAppID:n}));i.on(k.SDK_DESTROY,(function(e){zo[e.data.SDKAppID]=null,delete zo[e.data.SDKAppID]}));var a=function(e){var t=Object.create(null);return Object.keys(Gn).forEach((function(n){if(e[n]){var s=new O;t[n]=function(){var t=Array.from(arguments);return s.use((function(t,s){var i=Wo(e,n);return!0===i?s():Is(i)})).use((function(e,t){if(!0===nn(e,bn[n],n))return t()})).use((function(t,s){return e[n].apply(e,t)})),s.run(t)}}})),t}(i);return zo[n]=a,bn.hookGetAPITips(i.getErrMsg.bind(i)),Be.l("".concat(t," ok")),a}};return $o.TYPES=D,$o.EVENT=k,$o.VERSION=E,Be.l("TencentCloudChat.VERSION:".concat($o.VERSION)),$o}());class _{constructor(e){return _.instance||(_.instance=this,this.engine=e,this.events={},this.bindIMEvents()),_.instance}addEvent(e,t){this.events[e]||(this.events[e]=new Map),this.events[e].set(t,1)}removeEvents(){Object.keys(this.events).forEach((e=>{this.events[e].clear()})),this.events={}}dispatch(e,t){if(this.events[e])for(const n of this.events[e].keys())n.call(this,t)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this)}onSDKReady(e){this.dispatch(this.engine.EVENT.SDK_READY,e.data)}onSDKNotReady(e){this.dispatch(this.engine.EVENT.SDK_NOT_READY,e.data)}onKickedOut(e){this.dispatch(this.engine.EVENT.KICKED_OUT,e.data)}onNetStateChange(e){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,e.data)}onReceiveMessage(e){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,e.data)}onMessageModified(e){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,e.data)}onMessageRevoked(e){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,e.data)}onMessageReadByPeer(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,e.data)}onMessageReadReceiptReceived(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,e.data)}onMessageReactionsUpdated(e){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,e.data)}onConversationListUpdated(e){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,e.data)}onTotalMessageCountUpdated(e){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,e.data)}onProfileUpdated(e){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,e.data)}onBlacklistUpdated(e){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,e.data)}onUserStatusUpdated(e){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,e.data)}onGroupListUpdated(e){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,e.data)}onGroupAttributesUpdated(e){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,e.data)}onGroupCounterUpdated(e){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,e.data)}onFriendListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,e.data)}onFriendApplicationListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,e.data)}}!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIUser="TUIUser",e.TUIReport="TUIReport"}(a||(a={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.SEARCH="search",e.CUSTOM="custom"}(o||(o={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(r||(r={})),function(e){e.BUSINESS_ID="user_typing_status",e[e.STATUS_START=1]="STATUS_START",e[e.STATUS_END=0]="STATUS_END",e[e.VERSION=1]="VERSION",e[e.ACTION_START_ID=14]="ACTION_START_ID",e[e.ACTION_END_ID=0]="ACTION_END_ID",e.ACTION_START="EIMAMSG_InputStatus_Ing",e.ACTION_END="EIMAMSG_InputStatus_End",e[e.NEED_TYPING=1]="NEED_TYPING"}(c||(c={})),function(e){e.ADD="add",e.REMOVE="remove"}(u||(u={})),function(e){e[e.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",e[e.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",e[e.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(l||(l={})),function(e){e[e.NOT_INIT=-1e5]="NOT_INIT",e[e.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",e[e.CONV_ID_SAME=-100002]="CONV_ID_SAME",e[e.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",e[e.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",e[e.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(d||(d={})),function(e){e.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",e.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",e.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(h||(h={})),function(e){e.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",e.INVALID_CONV_ID="会话 ID 无效",e.CONV_ID_SAME="您切换的是同一个会话 ID",e.CONV_NOT_EXIST="会话不存在",e.GET_MSG_LIST_ERROR="Chat SDK is not ready.",e.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(g||(g={}));const v={logout:1,destroy:1},m={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1},y={modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},I={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},M=function(e){return void 0===e},C=function(e){return e.startsWith("_")},T=function(e){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(e)};const S=function(e){return e&&function(e){if("string"==typeof e)try{return!!JSON.parse(e)}catch(e){return!1}return!1}(e)?JSON.parse(e):e},E=function(e){let t="";return t=e>=1048576?`${(e/1048576).toFixed(2)} Mb`:e>=1024?`${(e/1024).toFixed(2)} Kb`:`${e.toFixed(2)}B`,t},k="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_16.png",D="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.png",O="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",R="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",A="https://web.sdk.qcloud.com/im/assets/face-elem/",N="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",L="https://apis.map.qq.com/ws/staticmap/v2/?",U={"[TUIEmoji_Expect]":"emoji_0@2x.png","[TUIEmoji_Blink]":"emoji_1@2x.png","[TUIEmoji_Guffaw]":"emoji_2@2x.png","[TUIEmoji_KindSmile]":"emoji_3@2x.png","[TUIEmoji_Haha]":"emoji_4@2x.png","[TUIEmoji_Cheerful]":"emoji_5@2x.png","[TUIEmoji_Smile]":"emoji_6@2x.png","[TUIEmoji_Sorrow]":"emoji_7@2x.png","[TUIEmoji_Speechless]":"emoji_8@2x.png","[TUIEmoji_Amazed]":"emoji_9@2x.png","[TUIEmoji_Complacent]":"emoji_10@2x.png","[TUIEmoji_Lustful]":"emoji_11@2x.png","[TUIEmoji_Stareyes]":"emoji_12@2x.png","[TUIEmoji_Giggle]":"emoji_13@2x.png","[TUIEmoji_Daemon]":"emoji_14@2x.png","[TUIEmoji_Rage]":"emoji_15@2x.png","[TUIEmoji_Yawn]":"emoji_16@2x.png","[TUIEmoji_TearsLaugh]":"emoji_17@2x.png","[TUIEmoji_Silly]":"emoji_18@2x.png","[TUIEmoji_Wail]":"emoji_19@2x.png","[TUIEmoji_Kiss]":"emoji_20@2x.png","[TUIEmoji_Trapped]":"emoji_21@2x.png","[TUIEmoji_Fear]":"emoji_22@2x.png","[TUIEmoji_BareTeeth]":"emoji_23@2x.png","[TUIEmoji_FlareUp]":"emoji_24@2x.png","[TUIEmoji_Tact]":"emoji_25@2x.png","[TUIEmoji_Shit]":"emoji_26@2x.png","[TUIEmoji_ShutUp]":"emoji_27@2x.png","[TUIEmoji_Sigh]":"emoji_28@2x.png","[TUIEmoji_Hehe]":"emoji_29@2x.png","[TUIEmoji_Silent]":"emoji_30@2x.png","[TUIEmoji_Skull]":"emoji_31@2x.png","[TUIEmoji_Mask]":"emoji_32@2x.png","[TUIEmoji_Beer]":"emoji_33@2x.png","[TUIEmoji_Cake]":"emoji_34@2x.png","[TUIEmoji_RedPacket]":"emoji_35@2x.png","[TUIEmoji_Bombs]":"emoji_36@2x.png","[TUIEmoji_Ai]":"emoji_37@2x.png","[TUIEmoji_Celebrate]":"emoji_38@2x.png","[TUIEmoji_Bless]":"emoji_39@2x.png","[TUIEmoji_Flower]":"emoji_40@2x.png","[TUIEmoji_Watermelon]":"emoji_41@2x.png","[TUIEmoji_Cow]":"emoji_42@2x.png","[TUIEmoji_Fool]":"emoji_43@2x.png","[TUIEmoji_Surprised]":"emoji_44@2x.png","[TUIEmoji_Askance]":"emoji_45@2x.png","[TUIEmoji_Monster]":"emoji_46@2x.png","[TUIEmoji_Pig]":"emoji_47@2x.png","[TUIEmoji_Coffee]":"emoji_48@2x.png","[TUIEmoji_Ok]":"emoji_49@2x.png","[TUIEmoji_Heart]":"emoji_50@2x.png","[TUIEmoji_Sun]":"emoji_51@2x.png","[TUIEmoji_Moon]":"emoji_52@2x.png","[TUIEmoji_Star]":"emoji_53@2x.png","[TUIEmoji_Rich]":"emoji_54@2x.png","[TUIEmoji_Fortune]":"emoji_55@2x.png","[TUIEmoji_857]":"emoji_56@2x.png","[TUIEmoji_666]":"emoji_57@2x.png","[TUIEmoji_Prohibit]":"emoji_58@2x.png","[TUIEmoji_Convinced]":"emoji_59@2x.png","[TUIEmoji_Knife]":"emoji_60@2x.png","[TUIEmoji_Like]":"emoji_61@2x.png"},P={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},w={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},b=["messageList","conversationList","newMessageList"],G=["translateTextInfo","voiceToTextInfo"],F="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),x="undefined"!=typeof uni&&"undefined"==typeof window,V=F||x,q="undefined"!=typeof uni,K=("undefined"!=typeof uni||"undefined"!=typeof window)&&!V,H=F?wx:q?uni:window,j=K&&window&&window.navigator&&window.navigator.userAgent||"",B=/Android/i.test(j),Y=/(?:Windows Phone)/.test(j),W=/(?:SymbianOS)/.test(j),z=/iPad/i.test(j)||/iPhone/i.test(j)||/iPod/i.test(j),$=B||Y||W||z,J=K&&!$;class X{constructor(){this.global=H,this.isOfficial=!1}static getInstance(){return X.instance||(X.instance=new X),X.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return J?e="pc":$?e="h5":F?e="wechat":x&&!F&&(e="app"),e}}class Z{constructor(){this.EVENT=f.EVENT,this.TYPES=f.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}mount(e,t){this[e]=t}login(e){const{chat:t,SDKAppID:n,userID:s}=e,i=1400187352===n||1400188366===n;return this.createChat(e),this.userID=s,X.getInstance().initOfficial(i),this.TUIStore.update(o.APP,"isOfficial",i),this.TUIStore.update(o.APP,"SDKVersion",f.VERSION),this.eventCenter=new _(this),this.eventCenter.removeEvents(),this.resetStore(),this.initService(),t&&t.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(e),this.eventCenter.addEvent(this.EVENT.SDK_READY,(()=>{this.onSDKReady()})),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,(()=>{this.onSDKNotReady()})),this.loginChat(e))}logout(){return this.userID="",this.isInited=!1,this.resetStore(),this.eventCenter.removeEvents(),this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){if(this.chat)return this.chat.setLogLevel(e);console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.resetStore(),this.eventCenter.removeEvents(),this.chat.destroy()}getMyUserID(){return this.userID}resetStore(){this.TUIStore.reset(o.CHAT),this.TUIStore.reset(o.CONV),this.TUIStore.reset(o.USER),this.TUIStore.reset(o.CUSTOM),console.log("TUIChatEngine.resetStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}createChat(e){const{chat:n,scene:s}=e,i=t(e,["chat","scene"]);M(n)?this.chat=f.create(Object.assign(Object.assign({},i),{scene:s||"aidesk-uikit-engine"})):this.chat=n}loginChat(e){const{userID:t,userSig:n}=e;return new Promise(((e,s)=>{this.chat.login({userID:t,userSig:n}).then((t=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),t.data.repeatLogin&&this.chat.isReady()&&e(t),this.loginStatusPromise.set("login",{resolve:e,reject:s,imResponse:t})})).catch((e=>{s(e)}))}))}registerPlugin(t){const{useUploadPlugin:n=!1,useProfanityFilterPlugin:s=!1,TIMPush:i,pushConfig:a,TUIOfflinePush:o,offlinePushConfig:r}=t;!0===n&&this.chat.registerPlugin({"tim-upload-plugin":e})}onSDKReady(){if(this.loginStatusPromise.has("login")){const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){if(this.loginStatusPromise.has("login")){this.loginStatusPromise.get("login").reject(new Error("sdk not ready"))}this.loginStatusPromise.delete("login"),this.resetStore()}checkCommercialAbility(){Object.keys(w).forEach((e=>{const t=w[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then((t=>{const{enabled:n=!1}=t.data;this.TUIStore.update(o.APP,e,n)}))}))}}class Q{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class ee{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateUserStatusList(e){0!==e.length?e.forEach((e=>{const{userID:t,statusType:n=0,customStatus:s=""}=e;n===r.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:n,customStatus:s})})):this.store.userStatusList.clear()}}class te{getEngine(){return Z.getInstance()}}const ne=function(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(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}(e)){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return!1},se=["[图片]","[语音]","[视频]","[文件]","[位置]","[地理位置]","[动画表情]","[自定义消息]","[群提示消息]","[聊天记录]"];class ie extends te{constructor(e){super(),this.initProxy(e),this.isMuted=this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_ACPT_NOT_NOTE||this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_DISCARD,this.operationType=0,this._conversation=e}initProxy(e){Object.keys(e).forEach((t=>{C(t)||(this[t]=e[t])}))}updateProperties(e){Object.keys(e).forEach((t=>{C(t)||(this[t]=e[t])}))}updateOperationType(e){this.operationType=e}getConversation(){return this._conversation}deleteConversation(){return this.getEngine().TUIConversation.deleteConversation(this.conversationID)}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!0===this.isMuted?e.TYPES.MSG_REMIND_ACPT_AND_NOTE:e.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===e.TYPES.CONV_C2C){const n=this.conversationID.replace(e.TYPES.CONV_C2C,"");t.userIDList=[n]}else if(this.type===e.TYPES.CONV_GROUP){const n=this.conversationID.replace(e.TYPES.CONV_GROUP,"");t.groupID=n}return e.TUIConversation.muteConversation(t)}getAvatar(){var e,t,n,s,i,a;const o=this.getEngine();let r="";switch(this.type){case o.TYPES.CONV_C2C:r=T(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:k;break;case o.TYPES.CONV_GROUP:r=T(null===(n=this.groupProfile)||void 0===n?void 0:n.avatar)?null===(s=this.groupProfile)||void 0===s?void 0:s.avatar:D;break;case o.TYPES.CONV_SYSTEM:r=T(null===(i=this.groupProfile)||void 0===i?void 0:i.avatar)?null===(a=this.groupProfile)||void 0===a?void 0:a.avatar:O}return r}getShowName(){var e,t,n,s;const i=this.getEngine();let a="";switch(this.type){case i.TYPES.CONV_C2C:a=this.remark||(null===(e=this.userProfile)||void 0===e?void 0:e.nick)||(null===(t=this.userProfile)||void 0===t?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:a=(null===(n=this.groupProfile)||void 0===n?void 0:n.name)||(null===(s=this.groupProfile)||void 0===s?void 0:s.groupID)||"";break;case i.TYPES.CONV_SYSTEM:a=i.TUITranslate.t("系统通知")}return a}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),n=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let s="";for(let e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(s=n[this.groupAtInfoList[e].atTypeArray[0]-1]);return s}getLastMessage(e){return"time"===e?this.getLastMessageTime():"text"===e?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let n="";return(null===(e=this.lastMessage)||void 0===e?void 0:e.lastTime)>0&&(n=function(e,t){const n=6e4,s=36e5,i=24*s,a=7*i,o=(new Date).getTime()-e;let r="";if(o<0)return r;const c=o/n,u=o/s,l=o/i,d=o/a;if(d>=1&&d<=4)r=` ${parseInt(`${d}`,10)} ${t("time.周")}${t("time.前")}`;else if(l>=1&&l<=6)r=` ${parseInt(`${l}`,10)} ${t("time.天")}${t("time.前")}`;else if(u>=1&&u<=23)r=` ${parseInt(`${u}`,10)} ${t("time.小时")}${t("time.前")}`;else if(c>=1&&c<=59)r=` ${parseInt(`${c}`,10)} ${t("time.分钟")}${t("time.前")}`;else if(o>=0&&o<=n)r=`${t("time.刚刚")}`;else{const t=new Date;t.setTime(e),r=`${t.getFullYear()}-${t.getMonth()+1<10?`0${t.getMonth()+1}`:t.getMonth()+1}-${t.getDate()<10?`0${t.getDate()}`:t.getDate()}`}return r}(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),n}getLastMessageText(){var e;if(this.draftText){return S(this.draftText).abstract}const t=this.getEngine(),n=t.TUITranslate.t.bind(t.TUITranslate);if(4===this.operationType)return n("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return n("TUIConversation.该群聊已被解散");if(8===this.operationType)return n("TUIConversation.您已退出该群聊");const s=this._conversation,i=this.lastMessage;let a="";const o=s.unreadCount>0&&s.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${s.unreadCount>99?"99+":s.unreadCount}${n("TUIConversation.条")}]`:"";if(i.type===t.TYPES.MSG_TEXT)a=this.decodeTextMessage(i.payload.text);else if(i.type===t.TYPES.MSG_CUSTOM){const s=S(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.data);if(1===(null==s?void 0:s.businessID))return a=t.TUIChat.messageHandler.handleCallKitSignaling(i),a;a=se.includes(i.messageForShow)?n(`TUIChat.${i.messageForShow}`):i.messageForShow}else a=se.includes(i.messageForShow)?n(`TUIChat.${i.messageForShow}`):i.messageForShow;return i.isRevoked&&(a=n("TUIChat.撤回了一条消息")),s.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?a:`${o}${a}`}decodeTextMessage(e){if(ne(e))return e;const t=/(\[.+?\])/g;let n=e;if(t.test(e)){const s=this.getEngine(),i=s.TUITranslate.t.bind(s.TUITranslate);n=e.replace(t,(e=>{const t=i(`Emoji.${e}`);return F||!t||t.startsWith("Emoji.")?P[e]||e:t}))}return n}}class ae{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(e,t){switch(e){case"conversationList":this.updateConversationList(t);break;case"operationTypeMap":this.updateOperationTypeMap(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find((t=>t.conversationID===e))}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateConversationList(e){const t=[];e.forEach((e=>{let n=e;e instanceof ie?n.updateProperties(e):n=new ie(e);const s=this.getOperationType(e);n.updateOperationType(s),t.push(n)})),this.store.conversationList=t}updateOperationTypeMap(e){const{conversationID:t,operationType:n=0}=e;this.store.operationTypeMap.set(t,n)}getOperationType(e){const{conversationID:t}=e;return this.store.operationTypeMap.get(t)||0}}class oe extends te{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:e=>this.getEngine().TUIChat.messageHandler.handleTextMessage(e),[this.getEngine().TYPES.MSG_FACE]:e=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(e),[this.getEngine().TYPES.MSG_LOCATION]:e=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(e),[this.getEngine().TYPES.MSG_IMAGE]:e=>this.getEngine().TUIChat.messageHandler.handleImageMessage(e),[this.getEngine().TYPES.MSG_AUDIO]:e=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(e),[this.getEngine().TYPES.MSG_VIDEO]:e=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(e),[this.getEngine().TYPES.MSG_FILE]:e=>this.getEngine().TUIChat.messageHandler.handleFileMessage(e),[this.getEngine().TYPES.MSG_CUSTOM]:e=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(e),[this.getEngine().TYPES.MSG_MERGER]:e=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(e),[this.getEngine().TYPES.MSG_GRP_TIP]:e=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(e),[this.getEngine().TYPES.MSG_STREAM]:e=>this.getEngine().TUIChat.messageHandler.handleStreamMessage(e)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(e)}initProperties(e){Object.keys(e).forEach((t=>{C(t)||(this[t]=e[t])}))}updateProperties(e){this._message=e,Object.keys(e).forEach((t=>{C(t)||(this[t]=e[t])}))}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:d.MISMATCH_TYPE_AND_PAYLOAD,message:g.MISMATCH_TYPE_AND_PAYLOAD}):(this._message.type=e.type||this._message.type,this._message.payload=e.payload||this._message.payload,this._message.cloudCustomData=e.cloudCustomData||this._message.cloudCustomData,this.getEngine().TUIChat.modifyMessage(this._message))}revokeMessage(){return this.getEngine().TUIChat.revokeMessage(this._message)}resendMessage(){return this.getEngine().TUIChat.resendMessage(this._message)}deleteMessage(){return this.getEngine().TUIChat.deleteMessage([this._message])}quoteMessage(){return this.getEngine().TUIChat.quoteMessage(this._message)}replyMessage(){return this.getEngine().TUIChat.replyMessage(this._message)}setMessageExtensions(e){return this.getEngine().TUIChat.setMessageExtensions(this._message,e)}getMessageExtensions(){return this.getEngine().TUIChat.getMessageExtensions(this._message)}deleteMessageExtensions(e){return this.getEngine().TUIChat.deleteMessageExtensions(this._message,e)}getSignalingInfo(){return null}getMessageContent(){const e=this.messageHandlers[this.type];return M(e)?{}:this.type===this.getEngine().TYPES.MSG_GRP_TIP?e(this._message):Object.assign(Object.assign({},e(this._message)),{showName:this.nick||this.from})}sendForwardMessage(e){return this.getEngine().TUIChat.sendForwardMessage(e,[this._message])}}class re{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(e,t){switch(e){case"messageList":this.updateMessageList(t);break;case"translateTextInfo":this.updateTranslateTextInfo(t);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find((t=>t.ID===e))}reset(e=[]){const t=e.filter((e=>!G.includes(e)));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==t?void 0:t.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateMessageList(e){const t=[];e.forEach((e=>{let n=e;e instanceof oe||(n=this.getModel(e.ID),n?n.updateProperties(e):n=new oe(e)),t.push(n)})),this.store.messageList=t}updateTranslateTextInfo(e){this.updateBykey("translateTextInfo",e)}updateVoiceToTextInfo(e){this.updateBykey("voiceToTextInfo",e)}updateBykey(e,t){const{conversationID:n,messageID:s,visible:i=!1}=t;this.store[e]||(this.store[e]=new Map),this.store[e].has(n)||this.store[e].set(n,[]);const a=this.store[e].get(n)||[];let o=!0;for(let e=0;e<a.length;e++)if(a[e].messageID===s){a[e].visible=i,o=!1;break}o&&a.push({messageID:s,visible:i}),this.store[e].set(n,a)}}class ce{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:void 0})),{}))}}class ue{constructor(){this.storeMap={[o.APP]:new Q,[o.USER]:new ee,[o.CONV]:new ae,[o.CHAT]:new re},this.task={}}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}watch(e,t){this.task[e]||(this.task[e]={});const n=this.task[e];Object.keys(t).forEach((s=>{const i=t[s];n[s]||(n[s]=new Map),n[s].set(i,1),this.notifyOnWatch(e,s,i)}))}unwatch(e,t){if(!this.task[e])return;const n=this.task[e];Object.keys(t).forEach((e=>{var s;null===(s=n[e])||void 0===s||s.delete(t[e])}))}update(e,t,n){var s;e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ce),null===(s=this.storeMap[e])||void 0===s||s.update(t,n),this.notify(e,t)}getData(e,t){var n;return e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ce),null===(n=this.storeMap[e])||void 0===n?void 0:n.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[o.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[o.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],n=!1){if(e in this.storeMap){const s=this.storeMap[e];0===t.length&&(t=Object.keys(null==s?void 0:s.store)),s.reset(t),n&&t.forEach((t=>{this.notify(e,t)}))}}notifyOnWatch(e,t,n){const s=this.getData(e,t);b.indexOf(t)>-1&&0===s.length||n&&n.call(this,s)}notify(e,t){if(!this.task[e])return;const n=this.task[e];if(n[t]){const s=n[t],i=this.getData(e,t);for(const[e]of s.entries())e.call(this,i)}}}function le(e){return le="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},le(e)}function de(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e){var t=function(e,t){if("object"!=le(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=le(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==le(t)?t:t+""}function ge(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,he(s.key),s)}}function pe(e,t,n){return t&&ge(e.prototype,t),n&&ge(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function fe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e,t){return _e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_e(e,t)}function ve(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_e(e,t)}function me(e,t){if(t&&("object"==le(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return fe(e)}function ye(e){return ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ye(e)}function Ie(e,t,n){return(t=he(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}function Ce(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Me(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Me(e,t):void 0}}(e)||function(){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 Te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function Se(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Te(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ee={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},ke=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(this,e),this.init(t,n)}return pe(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Ee,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,s){return s&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Se(Se({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),De=function(){function e(){de(this,e),this.observers={}}return pe(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function Oe(){var e,t,n=new Promise((function(n,s){e=n,t=s}));return n.resolve=e,n.reject=t,n}function Re(e){return null==e?"":""+e}function Ae(e,t,n){function s(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var a="string"!=typeof t?[].concat(t):t.split(".");a.length>1;){if(i())return{};var o=s(a.shift());!e[o]&&n&&(e[o]=new n),e=Object.prototype.hasOwnProperty.call(e,o)?e[o]:{}}return i()?{}:{obj:e,k:s(a.shift())}}function Ne(e,t,n){var s=Ae(e,t,Object);s.obj[s.k]=n}function Le(e,t){var n=Ae(e,t),s=n.obj,i=n.k;if(s)return s[i]}function Ue(e,t,n){for(var s in t)"__proto__"!==s&&"constructor"!==s&&(s in e?"string"==typeof e[s]||e[s]instanceof String||"string"==typeof t[s]||t[s]instanceof String?n&&(e[s]=t[s]):Ue(e[s],t[s],n):e[s]=t[s]);return e}function Pe(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var we={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function be(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return we[e]})):e}var Ge="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Fe=[" ",",","?","!",";"];function xe(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var s=t.split(n),i=e,a=0;a<s.length;++a){if(!i)return;if("string"==typeof i[s[a]]&&a+1<s.length)return;if(void 0===i[s[a]]){for(var o=2,r=s.slice(a,a+o).join(n),c=i[r];void 0===c&&s.length>a+o;)o++,c=i[r=s.slice(a,a+o).join(n)];if(void 0===c)return;if(null===c)return null;if(t.endsWith(r)){if("string"==typeof c)return c;if(r&&"string"==typeof c[r])return c[r]}var u=s.slice(a+o).join(n);return u?xe(c,u,n):void 0}i=i[s[a]]}return i}}function Ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ve(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ve(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ke(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return me(this,n)}}var He=function(){ve(t,De);var e=Ke(t);function t(n){var s,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return de(this,t),s=e.call(this),Ge&&De.call(fe(s)),s.data=n||{},s.options=i,void 0===s.options.keySeparator&&(s.options.keySeparator="."),void 0===s.options.ignoreJSONStructure&&(s.options.ignoreJSONStructure=!0),s}return pe(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,a=void 0!==s.ignoreJSONStructure?s.ignoreJSONStructure:this.options.ignoreJSONStructure,o=[e,t];n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."));var r=Le(this.data,o);return r||!a||"string"!=typeof n?r:xe(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},a=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(s=t,t=(o=e.split("."))[1]),this.addNamespaces(t),Ne(this.data,o,s),i.silent||this.emit("added",e,t,n,s)}},{key:"addResources",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});s.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,s,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(s=n,n=t,t=(o=e.split("."))[1]),this.addNamespaces(t);var r=Le(this.data,o)||{};s?Ue(r,n,i):r=qe(qe({},r),n),Ne(this.data,o,r),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?qe(qe({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),t}(),je={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,s,i){var a=this;return e.forEach((function(e){a.processors[e]&&(t=a.processors[e].process(t,n,s,i))})),t}};function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function We(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return me(this,n)}}var ze={},$e=function(){ve(t,De);var e=We(t);function t(n){var s,i,a,o,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return de(this,t),s=e.call(this),Ge&&De.call(fe(s)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],a=n,o=fe(s),i.forEach((function(e){a[e]&&(o[e]=a[e])})),s.options=r,void 0===s.options.keySeparator&&(s.options.keySeparator="."),s.logger=ke.create("translator"),s}return pe(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var s=Fe.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===s.length)return!0;var i=new RegExp("(".concat(s.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),a=!i.test(e);if(!a){var o=e.indexOf(n);o>0&&!i.test(e.substring(0,o))&&(a=!0)}return a}(e,n,s));if(a&&!o){var r=e.match(this.interpolator.nestingRegexp);if(r&&r.length>0)return{key:e,namespaces:i};var c=e.split(n);(n!==s||n===s&&this.options.ns.indexOf(c[0])>-1)&&(i=c.shift()),e=c.join(s)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,n,s){var i=this;if("object"!==le(n)&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"===le(n)&&(n=Ye({},n)),n||(n={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=this.extractFromKey(e[e.length-1],n),c=r.key,u=r.namespaces,l=u[u.length-1],d=n.lng||this.language,h=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(h){var g=n.nsSeparator||this.options.nsSeparator;return a?{res:"".concat(l).concat(g).concat(c),usedKey:c,exactUsedKey:c,usedLng:d,usedNS:l}:"".concat(l).concat(g).concat(c)}return a?{res:c,usedKey:c,exactUsedKey:c,usedLng:d,usedNS:l}:c}var p=this.resolve(e,n),f=p&&p.res,_=p&&p.usedKey||c,v=p&&p.exactUsedKey||c,m=Object.prototype.toString.apply(f),y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject;if(I&&f&&("string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(m)<0&&("string"!=typeof y||"[object Array]"!==m)){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(_,f,Ye(Ye({},n),{},{ns:u})):"key '".concat(c," (").concat(this.language,")' returned an object instead of string.");return a?(p.res=M,p):M}if(o){var C="[object Array]"===m,T=C?[]:{},S=C?v:_;for(var E in f)if(Object.prototype.hasOwnProperty.call(f,E)){var k="".concat(S).concat(o).concat(E);T[E]=this.translate(k,Ye(Ye({},n),{joinArrays:!1,ns:u})),T[E]===k&&(T[E]=f[E])}f=T}}else if(I&&"string"==typeof y&&"[object Array]"===m)(f=f.join(y))&&(f=this.extendTranslation(f,e,n,s));else{var D=!1,O=!1,R=void 0!==n.count&&"string"!=typeof n.count,A=t.hasDefaultValue(n),N=R?this.pluralResolver.getSuffix(d,n.count,n):"",L=n["defaultValue".concat(N)]||n.defaultValue;!this.isValidLookup(f)&&A&&(D=!0,f=L),this.isValidLookup(f)||(O=!0,f=c);var U=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&O?void 0:f,P=A&&L!==f&&this.options.updateMissing;if(O||D||P){if(this.logger.log(P?"updateKey":"missingKey",d,l,c,P?L:f),o){var w=this.resolve(c,Ye(Ye({},n),{},{keySeparator:!1}));w&&w.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var b=[],G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&G&&G[0])for(var F=0;F<G.length;F++)b.push(G[F]);else"all"===this.options.saveMissingTo?b=this.languageUtils.toResolveHierarchy(n.lng||this.language):b.push(n.lng||this.language);var x=function(e,t,s){var a=A&&s!==f?s:U;i.options.missingKeyHandler?i.options.missingKeyHandler(e,l,t,a,P,n):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,l,t,a,P,n),i.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&R?b.forEach((function(e){i.pluralResolver.getSuffixes(e,n).forEach((function(t){x([e],c+t,n["defaultValue".concat(t)]||L)}))})):x(b,c,L))}f=this.extendTranslation(f,e,n,p,s),O&&f===c&&this.options.appendNamespaceToMissingKey&&(f="".concat(l,":").concat(c)),(O||D)&&this.options.parseMissingKeyHandler&&(f="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(l,":").concat(c):c,D?f:void 0):this.options.parseMissingKeyHandler(f))}return a?(p.res=f,p):f}},{key:"extendTranslation",value:function(e,t,n,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Ye(Ye({},this.options.interpolation.defaultVariables),n),s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Ye(Ye({},n),{interpolation:Ye(Ye({},this.options.interpolation),n.interpolation)}));var o,r="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(r){var c=e.match(this.interpolator.nestingRegexp);o=c&&c.length}var u=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(u=Ye(Ye({},this.options.interpolation.defaultVariables),u)),e=this.interpolator.interpolate(e,u,n.lng||this.language,n),r){var l=e.match(this.interpolator.nestingRegexp);o<(l&&l.length)&&(n.nest=!1)}!n.lng&&"v1"!==this.options.compatibilityAPI&&s&&s.res&&(n.lng=s.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return i&&i[0]===s[0]&&!n.context?(a.logger.warn("It seems you are nesting recursively key: ".concat(s[0]," in key: ").concat(t[0])),null):a.translate.apply(a,s.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var d=n.postProcess||this.options.postProcess,h="string"==typeof d?[d]:d;return null!=e&&h&&h.length&&!1!==n.applyPostProcessor&&(e=je.handle(h,e,t,this.options&&this.options.postProcessPassResolved?Ye({i18nResolved:s},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,s,i,a,o=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!o.isValidLookup(t)){var c=o.extractFromKey(e,r),u=c.key;n=u;var l=c.namespaces;o.options.fallbackNS&&(l=l.concat(o.options.fallbackNS));var d=void 0!==r.count&&"string"!=typeof r.count,h=d&&!r.ordinal&&0===r.count&&o.pluralResolver.shouldUseIntlApi(),g=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,p=r.lngs?r.lngs:o.languageUtils.toResolveHierarchy(r.lng||o.language,r.fallbackLng);l.forEach((function(e){o.isValidLookup(t)||(a=e,!ze["".concat(p[0],"-").concat(e)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(a)&&(ze["".concat(p[0],"-").concat(e)]=!0,o.logger.warn('key "'.concat(n,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(a,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((function(n){if(!o.isValidLookup(t)){i=n;var a,c=[u];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(c,u,n,e,r);else{var l;d&&(l=o.pluralResolver.getSuffix(n,r.count,r));var p="".concat(o.options.pluralSeparator,"zero");if(d&&(c.push(u+l),h&&c.push(u+p)),g){var f="".concat(u).concat(o.options.contextSeparator).concat(r.context);c.push(f),d&&(c.push(f+l),h&&c.push(f+p))}}for(;a=c.pop();)o.isValidLookup(t)||(s=a,t=o.getResource(n,e,a,r))}})))}))}})),{res:t,usedKey:n,exactUsedKey:s,usedLng:i,usedNS:a}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,s):this.resourceStore.getResource(e,t,n,s)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,12)&&void 0!==e[n])return!0;return!1}}]),t}();function Je(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Xe=function(){function e(t){de(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ke.create("languageUtils")}return pe(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Je(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Je(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=Je(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var s=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(s)||(t=s)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var s=n.getLanguagePartFromCode(e);if(n.isSupportedCode(s))return t=s;t=n.options.supportedLngs.find((function(e){return e===s?e:e.indexOf("-")<0&&s.indexOf("-")<0?void 0:0===e.indexOf(s)?e:void 0}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,s=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],a=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),s.forEach((function(e){i.indexOf(e)<0&&a(n.formatLanguageCode(e))})),i}}]),e}(),Ze=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Qe={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},et=["v1","v2","v3"],nt={zero:0,one:1,two:2,few:3,many:4,other:5};var st=function(){function e(t){var n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(this,e),this.languageUtils=t,this.options=s,this.logger=ke.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},Ze.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:Qe[e.fc]}}))})),n)}return pe(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((function(e,t){return nt[e]-nt[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):s.numbers.map((function(s){return t.getSuffix(e,s,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(t)):this.getSuffixRetroCompatible(s,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,s=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[s];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var a=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!et.includes(this.options.compatibilityJSON)}}]),e}();function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ot(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=function(e,t,n){var s=Le(e,n);return void 0!==s?s:Le(t,n)}(e,t,n);return!a&&i&&"string"==typeof n&&void 0===(a=xe(e,n,s))&&(a=xe(t,n,s)),a}var rt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};de(this,e),this.logger=ke.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return pe(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:be,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Pe(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Pe(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Pe(t.nestingPrefix):t.nestingPrefixEscaped||Pe("$t("),this.nestingSuffix=t.nestingSuffix?Pe(t.nestingSuffix):t.nestingSuffixEscaped||Pe(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,s){var i,a,o,r=this,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(r.formatSeparator)<0){var i=ot(t,c,e,r.options.keySeparator,r.options.ignoreJSONStructure);return r.alwaysFormat?r.format(i,void 0,n,at(at(at({},s),t),{},{interpolationkey:e})):i}var a=e.split(r.formatSeparator),o=a.shift().trim(),u=a.join(r.formatSeparator).trim();return r.format(ot(t,c,o,r.options.keySeparator,r.options.ignoreJSONStructure),u,n,at(at(at({},s),t),{},{interpolationkey:o}))};this.resetRegExp();var d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return u(e)}},{regex:this.regexp,safeValue:function(e){return r.escapeValue?u(r.escape(e)):u(e)}}].forEach((function(t){for(o=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(a=l(n)))if("function"==typeof d){var c=d(e,i,s);a="string"==typeof c?c:""}else if(s&&Object.prototype.hasOwnProperty.call(s,n))a="";else{if(h){a=i[0];continue}r.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),a=""}else"string"==typeof a||r.useRawValueToEscape||(a=Re(a));var u=t.safeValue(a);if(e=e.replace(i[0],u),h?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++o>=r.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,s,i,a=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function r(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var s=e.split(new RegExp("".concat(n,"[ ]*{"))),a="{".concat(s[1]);e=s[0];var o=(a=this.interpolate(a,i)).match(/'/g),r=a.match(/"/g);(o&&o.length%2==0&&!r||r.length%2!=0)&&(a=a.replace(/'/g,'"'));try{i=JSON.parse(a),t&&(i=at(at({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(a)}return delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){var c=[];(i=(i=at({},o)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var u=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var l=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=l.shift(),c=l,u=!0}if((s=t(r.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof s)return s;"string"!=typeof s&&(s=Re(s)),s||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),s=""),u&&(s=c.reduce((function(e,t){return a.format(e,t,o.lng,at(at({},o),{},{interpolationkey:n[1].trim()}))}),s.trim())),e=e.replace(n[0],s),this.regexp.lastIndex=0}return e}}]),e}();function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function ut(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function lt(e){var t={};return function(n,s,i){var a=s+JSON.stringify(i),o=t[a];return o||(o=e(s,i),t[a]=o),o(n)}}var dt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};de(this,e),this.logger=ke.create("formatter"),this.options=t,this.formats={number:lt((function(e,t){var n=new Intl.NumberFormat(e,ut({},t));return function(e){return n.format(e)}})),currency:lt((function(e,t){var n=new Intl.NumberFormat(e,ut(ut({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:lt((function(e,t){var n=new Intl.DateTimeFormat(e,ut({},t));return function(e){return n.format(e)}})),relativetime:lt((function(e,t){var n=new Intl.RelativeTimeFormat(e,ut({},t));return function(e){return n.format(e,t.range||"day")}})),list:lt((function(e,t){var n=new Intl.ListFormat(e,ut({},t));return function(e){return n.format(e)}}))},this.init(t)}return pe(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=lt(t)}},{key:"format",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce((function(e,t){var a=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var s=e.split("(");t=s[0].toLowerCase().trim();var i=s[1].substring(0,s[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=Ce(e.split(":")),s=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[s.trim()]||(n[s.trim()]=i),"false"===i&&(n[s.trim()]=!1),"true"===i&&(n[s.trim()]=!0),isNaN(i)||(n[s.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:n}}(t),o=a.formatName,r=a.formatOptions;if(s.formats[o]){var c=e;try{var u=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},l=u.locale||u.lng||i.locale||i.lng||n;c=s.formats[o](e,l,ut(ut(ut({},r),i),u))}catch(e){s.logger.warn(e)}return c}return s.logger.warn("there was no format function for ".concat(o)),e}),e)}}]),e}();function ht(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function gt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return me(this,n)}}var ft=function(){ve(t,De);var e=pt(t);function t(n,s,i){var a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return de(this,t),a=e.call(this),Ge&&De.call(fe(a)),a.backend=n,a.store=s,a.services=i,a.languageUtils=i.languageUtils,a.options=o,a.logger=ke.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=o.maxParallelReads||10,a.readingCalls=0,a.maxRetries=o.maxRetries>=0?o.maxRetries:5,a.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(i,o.backend,o),a}return pe(t,[{key:"queueLoad",value:function(e,t,n,s){var i=this,a={},o={},r={},c={};return e.forEach((function(e){var s=!0;t.forEach((function(t){var r="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[r]=2:i.state[r]<0||(1===i.state[r]?void 0===o[r]&&(o[r]=!0):(i.state[r]=1,s=!1,void 0===o[r]&&(o[r]=!0),void 0===a[r]&&(a[r]=!0),void 0===c[t]&&(c[t]=!0)))})),s||(r[e]=!0)})),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(c)}}},{key:"loaded",value:function(e,t,n){var s=e.split("|"),i=s[0],a=s[1];t&&this.emit("failedLoading",i,a,t),n&&this.store.addResourceBundle(i,a,n),this.state[e]=t?-1:2;var o={};this.queue.forEach((function(n){var s,r,c,u,l,d;s=n.loaded,r=a,u=Ae(s,[i],Object),l=u.obj,d=u.k,l[d]=l[d]||[],c&&(l[d]=l[d].concat(r)),c||l[d].push(r),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((function(e){o[e]||(o[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===o[e][t]&&(o[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:a,callback:o});else{this.readingCalls++;var r=function(r,c){if(s.readingCalls--,s.waitingReads.length>0){var u=s.waitingReads.shift();s.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}r&&c&&i<s.maxRetries?setTimeout((function(){s.read.call(s,e,t,n,i+1,2*a,o)}),a):o(r,c)},c=this.backend[n].bind(this.backend);if(2!==c.length)return c(e,t,r);try{var u=c(e,t);u&&"function"==typeof u.then?u.then((function(e){return r(null,e)})).catch(r):r(null,u)}catch(e){r(e)}}}},{key:"prepareLoading",value:function(e,t){var n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var a=this.queueLoad(e,t,s,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("|"),i=s[0],a=s[1];this.read(i,a,"read",void 0,void 0,(function(s,o){s&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(i," failed"),s),!s&&o&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(i),o),t.loaded(e,s,o)}))}},{key:"saveMissing",value:function(e,t,n,s,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=n&&""!==n){if(this.backend&&this.backend.create){var r=gt(gt({},a),{},{isUpdate:i}),c=this.backend.create.bind(this.backend);if(c.length<6)try{var u;(u=5===c.length?c(e,t,n,s,r):c(e,t,n,s))&&"function"==typeof u.then?u.then((function(e){return o(null,e)})).catch(o):o(null,u)}catch(e){o(e)}else c(e,t,n,s,o,r)}e&&e[0]&&this.store.addResource(e[0],t,n,s)}}}]),t}();function _t(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===le(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===le(e[2])||"object"===le(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,s){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function vt(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mt(Object(n),!0).forEach((function(t){Ie(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function It(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return me(this,n)}}function Mt(){}var Ct=function(){ve(t,De);var e=It(t);function t(){var n,s,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;if(de(this,t),n=e.call(this),Ge&&De.call(fe(n)),n.options=vt(i),n.services={},n.logger=ke,n.modules={external:[]},s=fe(n),Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach((function(e){"function"==typeof s[e]&&(s[e]=s[e].bind(s))})),a&&!n.isInitialized&&!i.isClone){if(!n.options.initImmediate)return n.init(i,a),me(n,fe(n));setTimeout((function(){n.init(i,a)}),0)}return n}return pe(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var s=_t();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=yt(yt(yt({},s),this.options),vt(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=yt(yt({},s.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var a;this.modules.logger?ke.init(i(this.modules.logger),this.options):ke.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=dt);var o=new Xe(this.options);this.store=new He(this.options.resources,this.options);var r=this.services;r.logger=ke,r.resourceStore=this.store,r.languageUtils=o,r.pluralResolver=new st(o,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!a||this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format||(r.formatter=i(a),r.formatter.init(r,this.options),this.options.interpolation.format=r.formatter.format.bind(r.formatter)),r.interpolator=new rt(this.options),r.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},r.backendConnector=new ft(i(this.modules.backend),r.resourceStore,r,this.options),r.backendConnector.on("*",(function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))})),this.modules.languageDetector&&(r.languageDetector=i(this.modules.languageDetector),r.languageDetector.init&&r.languageDetector.init(r,this.options.detection,this.options)),this.modules.i18nFormat&&(r.i18nFormat=i(this.modules.i18nFormat),r.i18nFormat.init&&r.i18nFormat.init(this)),this.translator=new $e(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=Mt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&"dev"!==c[0]&&(this.options.lng=c[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var u=Oe(),l=function(){var t=function(t,s){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),u.resolve(s),n(t,s)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),u}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,s="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase())return n();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};if(s)a(s);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return a(e)}));this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(i,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var s=Oe();return e||(e=this.languages),t||(t=this.options.ns),n||(n=Mt),this.services.backendConnector.reload(e,t,(function(e){s.resolve(),n(e)})),s}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&je.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var s=Oe();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},a=function(a){e||a||!n.services.languageDetector||(a=[]);var o="string"==typeof a?a:n.services.languageUtils.getBestMatchFromCodes(a);o&&(n.language||i(o),n.translator.language||n.translator.changeLanguage(o),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage&&n.services.languageDetector.cacheUserLanguage(o)),n.loadResources(o,(function(e){!function(e,a){a?(i(a),n.translator.changeLanguage(a),n.isLanguageChangingTo=void 0,n.emit("languageChanged",a),n.logger.log("languageChanged",a)):n.isLanguageChangingTo=void 0,s.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,o)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),s}},{key:"getFixedT",value:function(e,t,n){var s=this,i=function e(t,i){var a;if("object"!==le(i)){for(var o=arguments.length,r=new Array(o>2?o-2:0),c=2;c<o;c++)r[c-2]=arguments[c];a=s.options.overloadTranslationOptionHandler([t,i].concat(r))}else a=yt({},i);a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns,a.keyPrefix=a.keyPrefix||n||e.keyPrefix;var u,l=s.options.keySeparator||".";return u=a.keyPrefix&&Array.isArray(t)?t.map((function(e){return"".concat(a.keyPrefix).concat(l).concat(e)})):a.keyPrefix?"".concat(a.keyPrefix).concat(l).concat(t):t,s.t(u,a)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var s=n.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;var o=function(e,n){var s=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===s||2===s};if(n.precheck){var r=n.precheck(this,o);if(void 0!==r)return r}return!!this.hasResourceBundle(s,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,e)||i&&!o(a,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,s=Oe();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=Oe();"string"==typeof e&&(e=[e]);var s=this.options.preload||[],i=e.filter((function(e){return s.indexOf(e)<0}));return i.length?(this.options.preload=s.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new Xe(_t());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,i=yt(yt(yt({},this.options),n),{isClone:!0}),a=new t(i);void 0===n.debug&&void 0===n.prefix||(a.logger=a.logger.clone(n));return["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=yt({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new $e(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];a.emit.apply(a,[e].concat(n))})),a.init(i,s),a.translator.options=a.options,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),t}();Ie(Ct,"createInstance",(function(){return new Ct(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var Tt=Ct.createInstance();Tt.createInstance=Ct.createInstance,Tt.createInstance,Tt.dir,Tt.init,Tt.loadResources,Tt.reloadResources,Tt.use,Tt.changeLanguage,Tt.getFixedT,Tt.t,Tt.exists,Tt.setDefaultNamespace,Tt.hasLoadedNamespace,Tt.loadNamespaces,Tt.loadLanguages;class St extends te{constructor(){super(),this.languages=null,this.keyMap={}}static getInstance(){return St.instance||(St.instance=new St),St.instance}provideLanguages(e){var t;F||(this.languages=e,(null===(t=e["zh-CN"])||void 0===t?void 0:t.Chat)&&this.setKeyMap(e["zh-CN"]),console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){var t;if(F)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const n={};for(const[e,t]of Object.entries(this.languages)){n["zh_cn"===e?"zh":e]={translation:t}}Tt.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:n});let s=this.normalizeLanguageKey(e||"zh");null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(201,s)}changeLanguage(e){let t=this.normalizeLanguageKey(e);return this.getEngine().TUIReport.reportFeature(201,t),Tt.changeLanguage(e)}normalizeLanguageKey(e){return e.includes("en")?"en-us":e.includes("tw")?"zh-tw":e.includes("zh")||e.includes("cn")?"zh-cn":e.includes("ko")||e.includes("kr")?"ko-kr":e.includes("ja")||e.includes("jp")?"ja-jp":"other-"+e}t(e){if(!this.languages){let t=e;return!M(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}const t=this.keyMap[e];return t?Tt.t(t):Tt.t(e)}setKeyMap(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=t?`${t}.${n}`:n;if(e[n]&&"object"==typeof e[n]&&!Array.isArray(e[n])&&null!==e[n])this.setKeyMap(e[n],s);else{let s=t?`${t}.${e[n]}`:e[n];s=this.replaceKey(s),this.keyMap[s]=`${t}.${n}`}}}replaceKey(e){return e.startsWith("Chat")?e.replace("Chat","TUIChat"):e.startsWith("Conversation")?e.replace("Conversation","TUIConversation"):e.startsWith("Message")?e.replace("Message","message.tip"):e.startsWith("Call")?e.replace("Call","message.custom"):e}}class Et extends te{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return Et.instance||(Et.instance=new Et),Et.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalUnreadCountUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getConversationInitData()}onConversationListUpdated(e){const t=this.filterSystemConversation(e);this.getEngine().TUIStore.update(o.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(o.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");let s=!1;for(let i=0;i<e.length;i++){if(e[i].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:a}=e[i].payload,r=`GROUP${e[i].to}`,c=4===a||5===a||8===a,u=2===a||6===a||7===a;if(c||u)for(let e=0;e<n.length;e++)if(n[e].type!==t.TYPES.CONV_C2C&&n[e].conversationID===r){if(c){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:r,operationType:a}),s=!0;break}if(u&&n[e].operationType>0){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:r,operationType:0}),s=!0;break}}}if(s){this.getEngine().TUIStore.update(o.CONV,"conversationList",n);const e=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID")||"",t=this.findConversation(e);t&&this.getEngine().TUIStore.update(o.CONV,"currentConversation",t)}}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then((t=>{const{conversationList:n,isSyncCompleted:s}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${n.length} isSyncCompleted:${s}`),n.length>0){this.onConversationListUpdated(n);const t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}}))}switchConversation(e){return n(this,void 0,void 0,(function*(){const t=`${this.serv}.switchConversation`,n=this.getEngine();if(!e)return n.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(o.CONV,"currentConversationID",""),n.TUIStore.update(o.CONV,"currentConversation",null),console.log(`${t} conversationID is empty, conversationID:${e}`),Promise.resolve({});if(!e.startsWith(n.TYPES.CONV_C2C)&&!e.startsWith(n.TYPES.CONV_GROUP))return console.warn(`${t} conversationID is invalid, conversationID:${e}`),Promise.reject({code:d.INVALID_CONV_ID,message:g.INVALID_CONV_ID});const s=n.TUIStore.getData(o.CONV,"currentConversationID");if(s&&s===e)return this.setMessageRead(s),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:d.CONV_ID_SAME,message:g.CONV_ID_SAME});const i=yield this.getConversationModel(e);return M(i)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:d.CONV_NOT_EXIST,message:g.CONV_NOT_EXIST})):(s&&this.setMessageRead(s),e&&this.setMessageRead(e),n.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(o.CONV,"currentConversationID",e),n.TUIStore.update(o.CONV,"currentConversation",i),Promise.resolve(i))}))}getConversationModel(e){return n(this,void 0,void 0,(function*(){let t=this.findConversation(e);if(M(t))try{const n=yield this.getConversationProfile(e);n.data&&n.data.conversation&&(t=new ie(n.data.conversation))}catch(e){t=void 0}return t}))}findConversation(e){let t;const n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let s=0;s<n.length;s++)if(n[s].conversationID===e){t=n[s];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"currentConversationID"),n=this.findConversation(t);n&&e.TUIStore.update(o.CONV,"currentConversation",n)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){return this.getEngine().chat.deleteConversation(e).then((t=>{const n=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${n}`),e===n&&(this.getEngine().TUIStore.update(o.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(o.CONV,"currentConversation",null)),t}))}pinConversation(e){return this.getEngine().chat.pinConversation(e)}muteConversation(e){return this.getEngine().chat.setMessageRemindType(e)}clearHistoryMessage(e){return this.getEngine().chat.clearHistoryMessage(e).then((e=>(this.getEngine().TUIStore.update(o.CHAT,"messageList",[]),this.getEngine().TUIStore.update(o.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(o.CHAT,"isCompleted",!0),e)))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}setConversationDraft(e){const{conversationID:t,draftInfo:n}=e;let s="";return n&&(s=JSON.stringify(n)),this.getEngine().chat.setConversationDraft({conversationID:t,draftText:s}).then((e=>{const{conversation:t}=e.data;this.updateConversation(t)}))}updateConversation(e){let t=!1;const n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let s=0;s<n.length;s++)if(n[s].conversationID===e.conversationID){n[s]=e,t=!0;break}t&&this.getEngine().TUIStore.update(o.CONV,"conversationList",n)}filterSystemConversation(e){return e.filter((e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM))}}class kt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(e){const t=this.getEngine(),n=t.TUIStore.getData(o.USER,"userProfile");e.forEach((e=>{e.userID===n.userID&&t.TUIStore.update(o.USER,"userProfile",e)}))}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then((e=>{t.TUIStore.update(o.USER,"userBlacklist",e)}))}getUserProfileInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getBlacklist&&e.chat.getBlacklist().then((e=>{const t=e.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${t.length}`),t.length>0&&this.onBlacklistUpdated(t)}))}getBlacklistProfile(e){const t=[];let n=0;for(;n<e.length;)t.push(e.slice(n,n+=100));const s=[];t.forEach((e=>{s.push(this.TUIUserService.getUserProfile({userIDList:e}))}));const i=[];return Promise.all(s).then((e=>(e.forEach((e=>{const t=e.data.map((e=>{const{userID:t,nick:n,avatar:s}=e;return{userID:t,nick:n,avatar:s}}));i.push(...t)})),i)))}getUserProfile(e){const t=this.getEngine();return M(e)?t.chat.getMyProfile().then((e=>(t.TUIStore.update(o.USER,"userProfile",e.data),e))).catch((e=>Promise.reject(e))):t.chat.getUserProfile(e)}updateMyProfile(e){return this.getEngine().chat.updateMyProfile(e)}addToBlacklist(e){return this.getEngine().chat.addToBlacklist(e)}removeFromBlacklist(e){return this.getEngine().chat.removeFromBlacklist(e)}}function Dt(e,t,n=!0){!function(e,t){V?H.setStorageSync(e,t):At()&&localStorage.setItem(e,JSON.stringify(t))}(n?Rt(e):e,t)}function Ot(e,t=!0){try{return function(e){if(V)return H.getStorageSync(e);if(At()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?Rt(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function Rt(e){return`chat_engine_${e}`}function At(){return navigator&&navigator.cookieEnabled&&localStorage}class Nt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=Ot("displayOnlineStatus")||!1;e.TUIStore.update(o.USER,"displayOnlineStatus",t),e.eventCenter.addEvent(e.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated.bind(this)),this.onConversationListUpdated()}onConversationListUpdated(){const e=this.getEngine();e.TUIStore.watch(o.CONV,{conversationList:()=>{const t=e.TUIStore.getData(o.APP,"enabledOnlineStatus"),n=e.TUIStore.getData(o.USER,"displayOnlineStatus");t&&n&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(o.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:n=!1}=e;t.TUIStore.update(o.USER,"displayOnlineStatus",n),Dt("displayOnlineStatus",n);const s=t.TUIStore.getData(o.APP,"enabledOnlineStatus");s?!0===n?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${s} displayOnlineStatus:${n}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then((e=>{const{successUserList:n}=e.data;return n.length>0&&t.TUIStore.update(o.USER,"userStatusList",n),e})).catch((e=>Promise.reject(e)))}subscribeUserStatus(e){var t;const n=(null===(t=null==e?void 0:e.userIDList)||void 0===t?void 0:t.length)||0;return 0===n?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${n}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(e)}unsubscribeUserStatus(e){const t=this.getEngine(),{userIDList:n=[]}=e||{};return t.chat.unsubscribeUserStatus({userIDList:n}).then((e=>{const{failureUserList:s}=e.data,i=[];return n.forEach((e=>{s.includes(e)||i.push({userID:e,statusType:r.UNSUB_USER})})),t.TUIStore.update(o.USER,"userStatusList",i),e})).catch((e=>Promise.reject(e)))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"conversationList"),n=e.TUIStore.getData(o.USER,"userStatusList"),s=[];t.forEach((t=>{if(t.type===e.TYPES.CONV_C2C){const i=t.conversationID.replace(e.TYPES.CONV_C2C,"");n.has(i)||s.push(i)}})),0!==s.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:s}),this.getUserStatus({userIDList:s}))}}class Lt extends te{constructor(){super(),this.userProfileHandler=new kt(this),this.userStatusHandler=new Nt(this)}static getInstance(){return Lt.instance||(Lt.instance=new Lt),Lt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.KICKED_OUT,this.onKickedOut.bind(this)),e.eventCenter.addEvent(e.EVENT.NET_STATE_CHANGE,this.onNetStateChange.bind(this)),this.userProfileHandler.init(),this.userStatusHandler.init(),this.initMessageReadReceipt()}onKickedOut(e){this.getEngine().TUIStore.update(o.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(o.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=Ot("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e),Dt("displayMessageReadReceipt",e)}getUserProfile(e){return this.userProfileHandler.getUserProfile(e)}updateMyProfile(e){return this.userProfileHandler.updateMyProfile(e)}addToBlacklist(e){return this.userProfileHandler.addToBlacklist(e)}removeFromBlacklist(e){return this.userProfileHandler.removeFromBlacklist(e)}getUserStatus(e){return this.userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this.userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this.userStatusHandler.unsubscribeUserStatus(e)}}class Ut{constructor(e){this.TUIChatService=e,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(e){return this.getEngine().TUITranslate.t(e)}handleTextMessage(e){return{text:this.decodeText(e.payload)}}handleFaceMessage(e){const t={name:"",url:"",type:""};return e.payload.data.indexOf("@custom")>-1?(t.name=e.payload.data,t.type="custom",t):(t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${A}${t.name}.png`,t)}handleLocationMessage(e){const t={lon:"",lat:"",href:"",url:"",description:""};return t.lon=e.payload.longitude.toFixed(6),t.lat=e.payload.latitude.toFixed(6),t.href=`${N}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${L}center=${t.lat},${t.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${t.lat},${t.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`,t.description=e.payload.description,t}handleImageMessage(e){return{url:e.payload.imageInfoArray[0].url,width:e.payload.imageInfoArray[0].width,height:e.payload.imageInfoArray[0].height}}handleAudioMessage(e){return{url:e.payload.url,second:e.payload.second}}handleVideoMessage(e){return{url:e.payload.videoUrl,snapshotUrl:e.payload.snapshotUrl,snapshotWidth:e.payload.snapshotWidth,snapshotHeight:e.payload.snapshotHeight}}handleFileMessage(e){return{url:e.payload.fileUrl,name:e.payload.fileName,size:E(e.payload.fileSize)}}handleCustomMessage(e){var t;const n=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||n||(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.extension)||`${this.t("TUIChat.[自定义消息]")}`,businessID:n?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,n,s,i,a,o;const r=this.getEngine(),c={text:""};let u=(null==e?void 0:e.nick)||(null===(n=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.userIDList)||void 0===n?void 0:n.join(","));switch((null===(i=null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.memberList)||void 0===i?void 0:i.length)>0&&(u="",null===(o=null===(a=null==e?void 0:e.payload)||void 0===a?void 0:a.memberList)||void 0===o||o.map((e=>{const t=(null==e?void 0:e.nick)||(null==e?void 0:e.userID);u+=`${this.substringByLength(t)},`})),u=null==u?void 0:u.slice(0,-1)),e.payload.operationType){case r.TYPES.GRP_TIP_MBR_JOIN:c.text=`${u} ${this.t("message.tip.加入群组")}`;break;case r.TYPES.GRP_TIP_MBR_QUIT:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.退出群组")}`;break;case r.TYPES.GRP_TIP_MBR_KICKED_OUT:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case r.TYPES.GRP_TIP_MBR_SET_ADMIN:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.成为管理员")}`;break;case r.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被撤销管理员")}`;break;case r.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:c.text=this.handleGroupProfileUpdated(e);break;case r.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被禁言")}`:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被取消禁言")}`;break;default:c.text=`[${this.t("message.tip.群提示消息")}]`}return c}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,n={text:""};switch(e.payload.operationType){case 1:n.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${t}`;break;case 2:n.text=`${this.t("message.tip.成功加入群组")}:${t}`;break;case 3:n.text=`${this.t("message.tip.申请加入群组")}:${t} ${this.t("message.tip.被拒绝")}`;break;case 4:n.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}:${t}`;break;case 5:n.text=`${this.t("message.tip.群")}:${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:n.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}:${t}`;break;case 7:case 12:n.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${t}`;break;case 8:n.text=`${this.t("message.tip.你退出群组")}:${t}`;break;case 9:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}:${t} ${this.t("message.tip.的管理员")}`;break;case 10:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}:${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:n.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}:${t}`;break;case 14:n.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}:${t}`;break;case 255:n.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:n.text="未解析的群系统通知"}return n}handleCallKitSignaling(e){var t,n,s,i,a,o,r,c,u,l;const d=S(e.payload.data);if(1!==(null==d?void 0:d.businessID))return"";const h=S(null==d?void 0:d.data),g=e.fromAccount||e.from,p=this.getEngine().getMyUserID();let f=e.nick||g;switch(f=this.substringByLength(f),null==d?void 0:d.actionType){case 1:return"audioCall"!==(null===(t=null==h?void 0:h.data)||void 0===t?void 0:t.cmd)&&"videoCall"!==(null===(n=null==h?void 0:h.data)||void 0===n?void 0:n.cmd)||!(null==d?void 0:d.groupID)?"hangup"===(null===(s=null==h?void 0:h.data)||void 0===s?void 0:s.cmd)?(null==d?void 0:d.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let n,s,i,a="";return t>=3600?(n=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),s=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),i=t%3600<10?"0"+t%3600:t%3600,i>60&&(s=parseInt(""+i/60,10)<10?`0${parseInt(""+i/60,10)}`:parseInt(""+i/60,10),i=i%60<10?"0"+i%60:i%60),a=`${n}:${s}:${i}`):t>=60&&t<3600?(s=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),i=t%60<10?"0"+t%60:t%60,a=`00:${s}:${i}`):t<60&&(i=t<10?`0${t}`:t,a=`00:00:${i}`),a}(null==h?void 0:h.call_end)}`:"switchToAudio"===(null===(i=null==h?void 0:h.data)||void 0===i?void 0:i.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(a=null==h?void 0:h.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${f} ${this.t("message.custom.发起通话")}`;case 2:return(null==d?void 0:d.groupID)?`${f} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(null==d?void 0:d.inviter)===p?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return"switchToAudio"===(null===(o=null==h?void 0:h.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(r=null==h?void 0:h.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==d?void 0:d.groupID)?`${f} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==d?void 0:d.groupID)?`${f} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):"line_busy"===(null==h?void 0:h.line_busy)||"lineBusy"===(null==h?void 0:h.data.message)?(null==d?void 0:d.inviter)===p?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(null==d?void 0:d.inviter)===p?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if("switchToAudio"===(null===(c=null==h?void 0:h.data)||void 0===c?void 0:c.cmd))return`${this.t("message.custom.切换语音通话")}`;if("switchToVideo"===(null===(u=null==h?void 0:h.data)||void 0===u?void 0:u.cmd))return`${this.t("message.custom.切换视频通话")}`;if(null==d?void 0:d.groupID){if(g===(null==d?void 0:d.inviter)){this.handleCallkitTimeoutSignaling(d.inviteeList);let e="";return null===(l=d.inviteeList)||void 0===l||l.forEach((t=>{const n=this.userShowNameMap.get(t)||t;e+=`${this.substringByLength(n)}、`})),e=e.substring(0,e.lastIndexOf("、")),`${e} ${this.t("message.custom.无应答")}`}return`${f} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(null==d?void 0:d.inviter)===p?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleStreamMessage(e){return{}}handleCreateGroupCustomMessage(e){let t;const n=S(e.payload.data);return"group_create"===(null==n?void 0:n.businessID)&&(t=`${n.opUser} ${n.content}`),t}decodeText(e){const t=[];let n=e.text,s=-1,i=-1;for(;""!==n;)switch(s=n.indexOf("["),i=n.indexOf("]"),s){case 0:if(-1===i)t.push({name:"text",text:n}),n="";else{const e=n.slice(0,i+1);e.indexOf("@custom")>-1?(t.push({name:"img",src:"",type:"custom",emojiKey:e}),n=n.substring(i+1)):U[e]?(t.push({name:"img",src:R+U[e],emojiKey:e}),n=n.substring(i+1)):(t.push({name:"text",text:"["}),n=n.slice(1))}break;case-1:t.push({name:"text",text:n}),n="";break;default:t.push({name:"text",text:n.slice(0,s)}),n=n.substring(s)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:n}=e,{newGroupProfile:s,memberList:i,operatorID:a}=n;let o="";const r=t||a,c=Object.keys(s)[0];switch(c){case"muteAllMembers":o=s[c]?`${this.t("message.tip.管理员")} ${r} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${r} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":o=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":o=`${r} ${this.t("message.tip.修改群名为")} ${s[c]}`;break;case"notification":o=this.isOldUIKit("message.tip.把群公告修改为")?`${r} ${this.t("message.tip.发布新公告")}`:`${r} ${this.t("message.tip.把群公告修改为")} "${s[c]}"`}return o}handleCallkitTimeoutSignaling(e=[]){if(0===e.length)return;const t=[];e.forEach((e=>{this.requestedUserMap.has(e)||(t.push(e),this.requestedUserMap.set(e,1))})),t.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:t}).then((e=>{(e.data||[]).forEach((e=>{const{userID:t,nick:n}=e,s=n||t;this.userShowNameMap.set(t,s)}))})).catch((e=>{}))}substringByLength(e,t=12){return e.length>t?`${e.slice(0,t)}...`:e}isOldUIKit(e){var t;const n=e.lastIndexOf("."),s=e.slice(0,n+1);return null===(t=this.t(e))||void 0===t?void 0:t.startsWith(s)}}class Pt{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(o.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(o.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),n=t.TUIStore.getData(o.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const s=S(e.payload.data);if(s.businessID===c.BUSINESS_ID){const{typingStatus:e,userAction:i}=s;if(e===c.STATUS_START||i===c.ACTION_START_ID)return n?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(o.CHAT,"typingStatus",!0),this.timer=setTimeout((()=>{this.clearTypingStatus()}),3e4),t.TUIStore.getData(o.CHAT,"typingStatus");e!==c.STATUS_END&&i!==c.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(o.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter((e=>{if(e.type===this.getEngine().TYPES.MSG_CUSTOM){return S(e.payload.data).businessID!==c.BUSINESS_ID}return!0}))}createTypingMessage(e=c.STATUS_END,t=""){const{BUSINESS_ID:n,STATUS_START:s,VERSION:i,ACTION_START_ID:a,ACTION_END_ID:o,ACTION_START:r,ACTION_END:u,NEED_TYPING:l}=c;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:n,typingStatus:e,version:i,userAction:e===s?a:o,actionParam:e===s?r:u}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:l,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(c.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(c.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class wt{constructor(e){this.TUIChatService=e}getEngine(){return this.TUIChatService.getEngine()}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived.bind(this))}onMessageReadReceiptReceived(e){const t=this.getEngine(),n=t.TUIStore.getData(o.CONV,"currentConversationID"),s=[];e.forEach((e=>{const{messageID:i}=e,a=t.chat.findMessage(i);a&&n===a.conversationID&&s.push(a)})),s.length>0&&t.TUIChat.updateMessageList(s,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach((e=>{const n=e.getMessage();t.push(n)})),this.getEngine().chat.sendMessageReadReceipt(t)}getGroupMessageReadMemberList(e){const t=e.message.getMessage(),n=Object.assign(Object.assign({},e),{message:t});return this.getEngine().chat.getGroupMessageReadMemberList(n)}getMessageReadReceiptList(e){const t=this.getEngine(),n=t.TUIStore.getData(o.APP,"enabledMessageReadReceipt"),s=t.TUIStore.getData(o.USER,"displayMessageReadReceipt");!n||!s||0===e.length||e[0].conversationType!==t.TYPES.CONV_GROUP||t.chat.getMessageReadReceiptList(e).then((e=>{const{messageList:t}=e.data;this.TUIChatService.updateMessageList(t,"edit")})).catch((e=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${e.message}`)}))}}class bt extends te{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new Ut(this),this.typingHandler=new Pt(this),this.readReceiptHandler=new wt(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map,this.bindConversationIDWatcher=this.conversationIDWatcher.bind(this),this.bindMessageSourceWatcher=this.messageSourceWatcher.bind(this)}static getInstance(){return bt.instance||(bt.instance=new bt),bt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"received"),this.getEngine().TUIStore.update(o.CHAT,"newMessageList",e)}onMessageModified(e){this.updateMessageList(e,"edit")}onMessageRevoked(e){this.updateMessageList(e,"edit")}onMessageReadByPeer(e){this.updateMessageList(e,"edit")}onMessageReactionsUpdated(e){this.updateMessageReactionList([e])}onCurrentConversationIDUpdated(){const e=this.getEngine();e.TUIStore.unwatch(o.CONV,{currentConversationID:this.bindConversationIDWatcher}),e.TUIStore.watch(o.CONV,{currentConversationID:this.bindConversationIDWatcher})}conversationIDWatcher(e){this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),this.getEngine().TUIStore.reset(o.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),ne(e)||this.getMessageList().finally((()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()}))}onMessageSource(){const e=this.getEngine();e.TUIStore.unwatch(o.CHAT,{messageSource:this.bindMessageSourceWatcher}),e.TUIStore.watch(o.CHAT,{messageSource:this.bindMessageSourceWatcher})}messageSourceWatcher(e){const t=this.getEngine(),n=this.getStoreData(o.CONV,"currentConversationID");if(!n||e&&e.conversationID!==n)return;if(M(e))return this.hoppingConfigMap.clear(),t.TUIStore.update(o.CHAT,"messageList",[]),t.TUIStore.update(o.CHAT,"nextReqMessageID",""),t.TUIStore.update(o.CHAT,"isCompleted",!1),void this.getMessageList();const s=this.getStoreData(o.CHAT,"messageList");s&&s.find((t=>e&&t.ID===e.ID))||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}getMessageListHoppingForDown(){const e=this.getStoreData(o.CHAT,"messageList"),{conversationID:t,sequence:n,time:s,ID:i}=this.getStoreData(o.CHAT,"messageSource");if(e&&e.find((e=>i&&e.ID===i)))return;const a=this.getEngine();a.TUIStore.update(o.CHAT,"messageList",[]),a.TUIStore.update(o.CHAT,"nextReqMessageID",""),a.TUIStore.update(o.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:n,time:s,direction:1})}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}sendMessage(e,t){this.updateMessageList([e],"send");const n=this.getEngine().chat.sendMessage(e,t);return this.getResponse(n)}getResponse(e,t=!0,n=!0){return e.then((e=>{const n=e.data.messageList?e.data.messageList:[e.data.message];return t&&this.updateMessageList(n,"edit"),e})).catch((e=>{var t;return n&&(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)&&this.updateMessageList([e.data.message],"edit"),Promise.reject(e)}))}updateMessageList(e,t=""){if(this.getStoreData(o.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const n=this.getStoreData(o.CHAT,"messageList"),s=this.updateTargetMessageList(e,n,t);this.getEngine().TUIStore.update(o.CHAT,"messageList",s)}updateTargetMessageList(e,t,n=""){const s=this.getStoreData(o.CONV,"currentConversationID");let i=e.filter((e=>e.conversationID===s));if(!n||0===i.length)return t;const a=t||[];let r=[];if("send"===n||"push"===n){const e=this.getStoreData(o.CHAT,"userInfo");Object.keys(e).length>0&&this.updateLocalMessage(i,e)}switch(n){case"edit":for(const e of t){const t=i.find((t=>t.ID===e.ID));r.push(t||e)}break;case"resend":r=a.filter((e=>e.ID!==i[0].ID)).concat(i);break;case"send":r=a.concat(this.typingHandler.filterTypingMessage(i));break;case"push":r=a.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:s});break;case"received":r=a.concat(this.typingHandler.filterTypingMessage(i)),r=this.sortMessageList(r),this.getEngine().chat.setMessageRead({conversationID:s});break;case"unshift":r=i.filter((e=>0===a.length||!a.find((t=>t.ID===e.ID)))),r.push(...a),r=this.sortMessageList(r)}return r}enterTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),n=this.getStoreData(o.CONV,"currentConversationID");if(!n.startsWith(t.TYPES.CONV_C2C))return;const s=n.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(o.CHAT,"messageList").filter((e=>"in"===e.flow));if(0===e.length)return;const t=1e3*e[e.length-1].time;if((new Date).getTime()-t>3e4)return}this.typingHandler.sendTyping(e,s)}quoteMessage(e){var t;return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"quote"}),null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(205),e}replyMessage(e){return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(o.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t,n;const s=this.getEngine(),i={abstract:"",type:0};switch(e.type){case s.TYPES.MSG_TEXT:i.abstract=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text,i.type=1;break;case s.TYPES.MSG_CUSTOM:i.abstract="[自定义消息]",i.type=2;break;case s.TYPES.MSG_IMAGE:i.abstract="[图片]",i.type=3;break;case s.TYPES.MSG_AUDIO:i.abstract="[语音]",i.type=4;break;case s.TYPES.MSG_VIDEO:i.abstract="[视频]",i.type=5;break;case s.TYPES.MSG_FILE:i.abstract="[文件]",i.type=6;break;case s.TYPES.MSG_LOCATION:i.type=7;break;case s.TYPES.MSG_FACE:i.abstract="[表情]",i.type=8;break;case s.TYPES.MSG_GRP_TIP:i.type=9;break;case s.TYPES.MSG_MERGER:i.abstract=null===(n=null==e?void 0:e.payload)||void 0===n?void 0:n.title,i.type=10}return i}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:n,type:s}=this.getMessageAbstractAndType(e),i={messageAbstract:n,messageSender:e.nick||e.from,messageID:e.ID},a=Object.assign(Object.assign({},i),{messageType:s,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(a.messageRootID=e.ID,e.cloudCustomData)){const t=S(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(a.messageRootID=t.messageReply.messageRootID)}return{messageReply:a,messageReplyRoot:i}}getMessageInfo(e,t,n){const{messageReply:s,messageReplyRoot:i}=this.genMessageReply(t,n),a=e.cloudCustomData?S(e.cloudCustomData):{};let o;if(a.messageReply?a.messageReply=Object.assign(Object.assign({},s),a.messageReply):a.messageReply=s,"reply"===n){const{messageRootID:e}=s;o=this.getEngine().chat.findMessage(e);const t=(null==o?void 0:o.cloudCustomData)?S(o.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),r=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(r):"array"===Object.prototype.toString.call(r).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(i),o.cloudCustomData=JSON.stringify(t)}var r;return{cloudCustomData:JSON.stringify(a),rootMessage:o}}sendTextMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(a=this.getMessageInfo(e,s,i));const r=n.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then((e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),n.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e)))}sendTextAtMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(a=this.getMessageInfo(e,s,i));const r=n.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then((e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),n.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e)))}sendImageMessage(e,t){const n=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendAudioMessage(e,t){const n=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendVideoMessage(e,t){const n=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendCustomMessage(e,t){const n=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFaceMessage(e,t){const n=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFileMessage(e,t){const n=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendLocationMessage(e,t){const n=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}onProgress(e,t){const n=this.getEngine().TUIStore.getMessageModel(e);if(n){(t-n.progress>=.1||1===t)&&(n.progress=t,this.updateMessageList([n],"edit"))}}setAbstractList(e){const t=this.getEngine(),n=e.nick||e.from;let s="";switch(e.type){case t.TYPES.MSG_TEXT:s=e.payload.text||"",s.length>20&&(s=s.slice(0,20));break;case t.TYPES.MSG_MERGER:s=`${this.t("TUIChat.[聊天记录]")}`;break;case t.TYPES.MSG_IMAGE:s=`${this.t("TUIChat.[图片]")}`;break;case t.TYPES.MSG_AUDIO:s=`${this.t("TUIChat.[音频]")}`;break;case t.TYPES.MSG_VIDEO:s=`${this.t("TUIChat.[视频]")}`;break;case t.TYPES.MSG_CUSTOM:s=`${this.t("TUIChat.[自定义消息]")}`;break;case t.TYPES.MSG_FILE:s=`${this.t("TUIChat.[文件]")}`;break;case t.TYPES.MSG_FACE:s=`${this.t("TUIChat.[动画表情]")}`}return`${n}: ${s}`}genMergerForwardPayload(e,t){const{abstractList:n=[],compatibleText:s="",title:i}=t;return 0===n.length&&e.forEach((e=>{n.push(this.setAbstractList(e))})),{messageList:e,title:i,abstractList:n,compatibleText:s||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(e){const{conversationList:t,messageList:n,params:s,mergeInfo:i,sendMessageOptions:a}=e,o=[];for(let e=0;e<t.length;e++){const{conversationID:r,type:c}=t[e],u=Object.assign({to:r.replace(`${c}`,""),conversationType:c,payload:this.genMergerForwardPayload(n,i)},s),l=this.getEngine().chat.createMergerMessage(u);o.push(this.sendMessage(l,a))}return o}genTitle(e,t){const{nick:n,from:s,to:i}=e;return`${n||s} ${this.t("TUIChat.和")} ${t||i} ${this.t("TUIChat.的聊天记录")}`}genMergeInfo(e){var t;return n(this,void 0,void 0,(function*(){const{messageList:n,mergeInfo:s}=e;if(s.title)return s;if(n[0].conversationType===this.getEngine().TYPES.CONV_GROUP)return s.title=this.t("TUIChat.群聊的聊天记录"),s;try{const{data:e=[]}=yield this.getEngine().TUIUser.getUserProfile({userIDList:[n[0].to]});s.title=this.genTitle(n[0],null===(t=e[0])||void 0===t?void 0:t.nick)}catch(e){s.title=this.genTitle(n[0])}return s}))}sendMergerForwardMessage(e){return n(this,void 0,void 0,(function*(){return e.mergeInfo=yield this.genMergeInfo(e),Promise.all(this.genSendMergerForwardMessage(e))}))}getOriginMessageList(e){return e.map((e=>e instanceof oe?e.getMessage():e))}sendForwardMessage(e,n,s){n=this.getOriginMessageList(n);const i=s||{},{needMerge:a=!1,params:o={},mergeInfo:r={}}=i,c=t(i,["needMerge","params","mergeInfo"]);if(a)return this.sendMergerForwardMessage({conversationList:e,messageList:n,params:o,mergeInfo:r,sendMessageOptions:c});const u=[];for(let t=0;t<e.length;t++){const{conversationID:s,type:i}=e[t],a=Object.assign({to:s.replace(`${i}`,""),conversationType:i},o),r=c[s]||c;for(let e=0;e<n.length;e++){Reflect.set(a,"payload",n[e]);const t=this.getEngine().chat.createForwardMessage(a);u.push(this.sendMessage(t,r))}}return Promise.all(u)}revokeMessage(e){const t=this.getEngine().chat.revokeMessage(e);return this.getResponse(t,!0,!1)}resendMessage(e){e.status="unSend",this.updateMessageList([e],"resend");const t=this.getEngine().chat.resendMessage(e);return this.getResponse(t,!0,!0)}deleteMessage(e){const t=this.getEngine().chat.deleteMessage(e);return this.getResponse(t,!0,!1)}setMessageExtensions(e,t){return this.getEngine().chat.setMessageExtensions(e,t)}getMessageExtensions(e){return this.getEngine().chat.getMessageExtensions(e)}deleteMessageExtensions(e,t){return this.getEngine().chat.deleteMessageExtensions(e,t)}modifyMessage(e){const t=this.getEngine().chat.modifyMessage(e);return this.getResponse(t,!0,!1).catch((e=>{const{code:t=0,data:n={}}=e.code;throw t===l.MSG_MODIFY_CONFLICT?console.warn(`${h.MSG_MODIFY_CONFLICT} data.message: ${null==n?void 0:n.message}`):t===l.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(h.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===l.MODIFY_MESSAGE_NOT_EXIST&&console.warn(h.MODIFY_MESSAGE_NOT_EXIST),e}))}getMessageList(e={conversationID:this.getStoreData(o.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(o.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:d.GET_MSG_LIST_ERROR,message:g.GET_MSG_LIST_ERROR});if(this.getStoreData(o.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const n=this.getStoreData(o.CHAT,"messageSource"),s=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),a=s||i;return n&&n.conversationID===(null==e?void 0:e.conversationID)&&a?this.getMessageListHopping():t.chat.getMessageList(e).then((e=>{var n;const{messageList:s,nextReqMessageID:i,isCompleted:a}=e.data,r=this.getStoreData(o.CHAT,"userInfo");Object.keys(r).length>0&&this.updateLocalMessage(s,r),this.updateMessageList(s,"unshift"),t.TUIStore.update(o.CHAT,"nextReqMessageID",i),t.TUIStore.update(o.CHAT,"isCompleted",a);const c=null===(n=s[0])||void 0===n?void 0:n.conversationID,{operationType:u=0}=this.getEngine().TUIStore.getConversationModel(c)||{};return 0===u&&(this.getMessageReactions({messageList:s}),this.readReceiptHandler.getMessageReadReceiptList(s)),e})).catch((e=>Promise.reject(e)))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(o.CHAT,"messageSource"))||void 0===t?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const n=this.getEngine();return n.chat.getMessageListHopping(e).then((t=>{const{messageList:s,nextMessageSeq:i,nextMessageTime:a,isCompleted:r}=t.data,c=1===e.direction?e.sequence:i,u=1===e.direction?e.time:a;return this.updateMessageList(s,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",c),this.hoppingConfigMap.set("nextMessageTime",u),n.TUIStore.update(o.CHAT,"isCompleted",r),t})).catch((e=>Promise.reject(e)))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then((e=>{const{isCompleted:t,cursor:n,messageID:s,unreadUserIDList:i,readUserIDList:a}=e.data,o={code:0,data:{cursor:n,isCompleted:t,messageID:s,unreadUserInfoList:[],readUserInfoList:[]}},r=[...i,...a];return 0===r.length?o:this.getEngine().TUIUser.getUserProfile({userIDList:r}).then((e=>(i.length>0?e.data.forEach((e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.unreadUserInfoList.push({userID:t,nick:n,avatar:s})})):e.data.forEach((e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.readUserInfoList.push({userID:t,nick:n,avatar:s})})),o)))}))}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e)}setTranslationLanguage(e){this.getEngine().TUIStore.update(o.USER,"targetLanguage",e)}translateText(e){const t=this.getStoreData(o.USER,"targetLanguage"),n=Object.assign({targetLanguage:t,sourceLanguage:"auto"},e);return this.getEngine().chat.translateText(n)}searchCloudMessages(e){const n=this.getStoreData(o.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(e).then((e=>{const{searchResultList:s}=e.data;return e.data.searchResultList=s.map((e=>{const{messageList:s,conversationID:i}=e,a=t(e,["messageList","conversationID"]),o=s.map((e=>new oe(e))),r=n.find((e=>e.conversationID===i));return Object.assign(Object.assign({},a),{messageList:o.sort(((e,t)=>t.time-e.time)),conversation:r})})),e}))}addMessageReaction(e,t){return this.getEngine().chat.addMessageReaction(e.getMessage(),t)}removeMessageReaction(e,t){return this.getEngine().chat.removeMessageReaction(e.getMessage(),t)}getMessageReactions(e){}getAllUserListOfMessageReaction(e){var t;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},e),{message:null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.getMessage()}))}updateMessageReactionList(e){const t=[];e.forEach((e=>{const{messageID:n,reactionList:s}=e,i=this.getEngine().TUIStore.getMessageModel(n);if(i){const e=[];for(let t=0;t<s.length;t++){let n=!0;for(let e=0;e<i.reactionList.length;e++)if(s[t].reactionID===i.reactionList[e].reactionID){i.reactionList[e]=s[t],n=!1;break}n&&e.push(s[t])}i.reactionList.push(...e),e.length=0,t.push(i)}})),t.length>0&&this.updateMessageList(t,"edit")}convertVoiceToText(e){const{message:t,language:n="zh"}=e,s=t.getMessage();return this.getEngine().chat.convertVoiceToText({message:s,language:n})}clearHistoryMessage(e){const t=this.getEngine();return t.chat.clearHistoryMessage(e).then((e=>(t.TUIStore.update(o.CHAT,"messageList",[]),t.TUIStore.update(o.CHAT,"nextReqMessageID",""),t.TUIStore.update(o.CHAT,"isCompleted",!1),e)))}updateMessageInfo(e){const t=this.getStoreData(o.CHAT,"userInfo");this.getEngine().TUIStore.update(o.CHAT,"userInfo",Object.assign(t,e));const n=this.getStoreData(o.CHAT,"messageList");if(n.length>0){this.updateLocalMessage(n,e)&&this.getEngine().TUIStore.update(o.CHAT,"messageList",n)}}updateLocalMessage(e,t){let n=!1;return e.forEach((e=>{if(t[e.from]){const{nick:s,nameCard:i,avatar:a}=t[e.from];s&&(e.nick=s,n=!0),i&&(e.nameCard=i,n=!0),a&&(e.avatar=a,n=!0)}})),n}sortMessageList(e){if(e[0].conversationType===this.getEngine().TYPES.CONV_C2C)return e.sort(((e,t)=>e.time-t.time));const t=e.filter((e=>"success"===e.status)).sort(((e,t)=>e.sequence-t.sequence));for(let n=0;n<e.length;n++)"success"!==e[n].status&&t.splice(n,0,e[n]);return t}}class Gt extends te{static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}reportFeature(e,t){var n;return null===(n=this.getEngine().chat)||void 0===n?void 0:n.callExperimentalAPI("statTUIKeyFeatures",{code:e,msg:t?`${e}-${t}`:""})}}class Ft{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){return"function"!=typeof e&&console.error("middleware must be a function"),this.cache.push(e),this}next(){if(this.middlewares&&this.middlewares.length>0){return this.middlewares.shift().call(this,this.options,this.next.bind(this))}}run(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}function xt(e,t,n){const s=Object.create(null);Object.keys(n).forEach((n=>{if(!t[n])return;s[n]=t[n];const i=new Ft;t[n]=function(){const a=Array.from(arguments);return i.use((function(t,s){return e.isInited?s():Promise.reject({code:d.NOT_INIT,message:`${n} | ${g.NOT_INIT}`})})).use((function(e,i){return s[n].apply(t,e)})),i.run(a)}}))}console.log("TUIChatEngine.VERSION:2.4.0-0205");const Vt=Z.getInstance(),qt=X.getInstance(),Kt=ue.getInstance(),Ht=St.getInstance(),jt=Et.getInstance(),Bt=Lt.getInstance(),Yt=bt.getInstance(),Wt=Gt.getInstance();Vt.mount(a.TUIStore,Kt),Vt.mount(a.TUITranslate,Ht),Vt.mount(a.TUIConversation,jt),Vt.mount(a.TUIUser,Bt),Vt.mount(a.TUIChat,Yt),Vt.mount(a.TUIReport,Wt),xt(Vt,Vt,v),xt(Vt,jt,m),xt(Vt,Yt,y),xt(Vt,Bt,I),xt(Vt,Wt,v);export{o as StoreName,Vt as TUIChatEngine,Yt as TUIChatService,jt as TUIConversationService,qt as TUIGlobal,Wt as TUIReportService,Kt as TUIStore,Ht as TUITranslateService,Bt as TUIUserService,Vt as default};
1
+ import e from"tim-upload-plugin";function t(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(e);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(n[s[i]]=e[s[i]])}return n}function n(e,t,n,s){return new(n||(n=Promise))(function(i,a){function o(e){try{c(s.next(e))}catch(e){a(e)}}function r(e){try{c(s.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,r)}c((s=s.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,o,r,c,u,l,d,h,g,p={exports:{}},_=i(p.exports=function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}function t(e){if(Array.isArray(e))return e}function n(e,t,n){t=u(t);var s=e;if(!(t=d()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))||"object"!=typeof t&&"function"!=typeof t){if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");if(void 0===(t=s))throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,I(s.key),s)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(e,t){var n,s,i,a,o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(o)return i=!(s=!0),{s:function(){o=o.call(e)},n:function(){var e=o.next();return s=e.done,e},e:function(e){i=!0,n=e},f:function(){try{s||null==o.return||o.return()}finally{if(i)throw n}}};if(Array.isArray(e)||(o=C(e))||t&&e&&"number"==typeof e.length)return o&&(e=o),a=0,{s:t=function(){},n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t,n){return(t=I(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function h(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function g(){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 p(e,t){var n,s=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),s.push.apply(s,n)),s}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){c(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t){if(null==e)return{};var n,s=((e,t)=>{if(null==e)return{};var n,s={};for(n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;s[n]=e[n]}return s})(e,t);if(Object.getOwnPropertySymbols)for(var i=Object.getOwnPropertySymbols(e),a=0;a<i.length;a++)n=i[a],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n]);return s}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function v(e,n){return t(e)||((e,t)=>{var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var s,i,a,o,r=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(s=a.call(n)).done)&&(r.push(s.value),r.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return r}})(e,n)||C(e,n)||g()}function y(t){return(t=>{if(Array.isArray(t))return e(t)})(t)||h(t)||C(t)||(()=>{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 I(e){return e=(e=>{if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);if("object"!=typeof(t=t.call(e,"string")))return t;throw new TypeError("@@toPrimitive must return a primitive value.")})(e),"symbol"==typeof e?e:e+""}function M(e){return(M="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})(e)}function C(t,n){var s;if(t)return"string"==typeof t?e(t,n):"Map"===(s="Object"===(s={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:s)||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?e(t,n):void 0}function T(e){var t="function"==typeof Map?new Map:void 0;return function(e){if(null===e||!(e=>{try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}})(e))return e;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,n)}function n(){return function(e,t,n){var s;return d()?Reflect.construct.apply(null,arguments):((s=[null]).push.apply(s,t),t=new(e.bind.apply(e,s)),n&&m(t,n.prototype),t)}(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)}(e)}var S="3.6.4-260630",E={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",ROOM_CUSTOM_DATA_RECEIVED:"onRoomCustomDataReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",MESSAGE_REACTIONS_UPDATED:"onMessageReactionsUpdated",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",TOTAL_UNREAD_MESSAGE_COUNT_UPDATED:"onTotalUnreadMessageCountUpdated",CONVERSATION_GROUP_LIST_UPDATED:"onConversationGroupListUpdated",CONVERSATION_IN_GROUP_UPDATED:"onConversationInGroupUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",GROUP_COUNTER_UPDATED:"onGroupCounterUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",USER_STATUS_UPDATED:"onUserStatusUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",MY_FOLLOWERS_LIST_UPDATED:"onMyFollowersListUpdated",MY_FOLLOWING_LIST_UPDATED:"onMyFollowingListUpdated",MUTUAL_FOLLOWERS_LIST_UPDATED:"onMutualFollowersListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",ALL_RECEIVE_MESSAGE_OPT_UPDATED:"onAllReceiveMessageOptUpdated",SERVER_CONFIG_UPDATED:"onServerConfigUpdated",PINNED_GROUP_MESSAGE_UPDATED:"onPinnedGroupMessageUpdated"},k={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_STREAM:"TIMStreamElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"},D=o(function e(){i(this,e),this.cache=[],this.options=null},[{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&&0<this.middlewares.length)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()}}]),O=o(function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;i(this,e),this.high=t,this.low=n},[{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}}]),R={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},A="1.7.3",N=537048168,L="CHINA",U={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent:function(){this.CURRENT=R.PRODUCTION[0<arguments.length&&void 0!==arguments[0]?arguments[0]:L]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic",STREAM_MESSAGE:"StreamMsg"}},P={SEARCH_GRP_SNS:new O(0,Math.pow(2,1)).toString(),AV_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(),AV_MBR_LIST:new O(0,Math.pow(2,6)).toString(),USER_STATUS:new O(0,Math.pow(2,7)).toString(),CONV_MARK:new O(0,Math.pow(2,9)).toString(),CONV_GROUP:new O(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new O(0,Math.pow(2,11)).toString(),MSG_EXT:new O(0,Math.pow(2,13)).toString(),GRP_COUNTER:new O(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new O(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new O(Math.pow(2,7)).toString(),PLUGIN_CS:new O(Math.pow(2,8)).toString(),PLUGIN_PUSH:new O(Math.pow(2,9)).toString(),PLUGIN_BOT:new O(Math.pow(2,10)).toString(),MSG_REACTION:new O(Math.pow(2,16)).toString(),FOLLOW:new O(Math.pow(2,20)).toString()},w="web.sdk.qcloud.com",b="web.sdk.cloud.tencent.cn",G="web.sdk.tencent.cn";U.HOST.setCurrent(L);for(var F,x="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),V="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||x,q=V&&"function"==typeof wx.createGamePortal,K="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),H="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),j="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),B="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),Y=(x="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,"undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin),W=V&&"object"===M(wx.miniapp),z="undefined"!=typeof uni,$=V||K||H||j||B||Y||x,J="undefined"==typeof window&&!$&&void 0!==s&&void 0!==s.NativeScriptGlobals,X=void 0!==s&&(void 0!==s.nativeModuleProxy||void 0!==s.ReactNative),Z="undefined"!=typeof uni?!$:"undefined"!=typeof window&&!$&&!X,Q=K?qq:H?tt:j?swan:B?my:V?wx:Y?uni:x?jd:{},ee=Z&&window&&window.navigator&&window.navigator.userAgent||"",te=(x="WEB",/(micromessenger|webbrowser)/i.test(ee)?x="WEB":K?x="QQ_MP":H?x="TT_MP":j?x="BAIDU_MP":B?x="ALI_MP":V?x=W?"DONUT_NATIVE_APP":"WX_MP":Y?x="UNI_NATIVE_APP":J?x="NS_NATIVE_APP":X&&(x="RN_NATIVE_APP"),{ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21}[x]),ne=(W=/iPad/i.test(ee),J=/iPhone/i.test(ee)&&!W,x=/iPod/i.test(ee),J||W||x),se=(J=ee.match(/OS (\d+)_/i))&&J[1]?J[1]:null,ie=/Android/i.test(ee),ae=(W=ee.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i))?(x=W[1]&&parseFloat(W[1]),J=W[2]&&parseFloat(W[2]),x&&J?parseFloat(W[1]+"."+W[2]):x||null):null,oe=(W=!(J=/Edge/i.test(ee))&&/Chrome/i.test(ee),/MSIE/.test(ee)||-1<ee.indexOf("Trident")&&-1<ee.indexOf("rv:11.0")),re=x=!(x=(x=/MSIE\s(\d+)\.\d/.exec(ee))&&parseFloat(x[1]))&&/Trident\/7.0/i.test(ee)&&/rv:11.0/.test(ee)?11:x,ce=(x=/Safari/i.test(ee)&&!W&&!ie&&!J,/Windows/i.test(ee)),ue=/MAC OS X/i.test(ee),le=Z&&"undefined"!=typeof Worker&&!oe,de=Z&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,he="undefined"!=typeof window&&void 0!==window.navigator&&(W=window.navigator.standalone,!(!ne||W||x)),ge="undefined"!=typeof console?console:void 0!==s&&s.console?s.console:"undefined"!=typeof window&&window.console?window.console:{},pe=function(){},_e=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],fe=_e.length;fe--;)F=_e[fe],console[F]||(ge[F]=pe);function me(){return(new Date).getTime()+Me}function ve(){Me=0}function ye(){return Math.floor(me()/1e3)}var Ie=ge,Me=0,Ce=0;function Te(){return Dt()?"%c AIDesk-Chat %c":"AIDesk-Chat"}function Se(){var e;return(e=new Date).setTime(me()),e.toLocaleTimeString("en-US",{hour12:!1})+"."+(e=>{var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t})(e.getMilliseconds())}var Ee={arguments2String:function(e){var t="";if(1===e.length)t=e[0];else for(var n=0,s=e.length;n<s;n++){if(Qe(e[n]))try{t+=et(e[n])?JSON.stringify(e[n],["message","code"]):JSON.stringify(e[n])}catch(e){t+=e?e.message:"";break}else t+=e[n];t+=" "}return t},_exec:function(e,t){Dt()?Ie[e](Te(),"background:#1c66e5; padding:1px; border-radius:3px; color: #fff","background:transparent",Se(),t):Ie[e]("".concat(Te()," ").concat(Se()," ").concat(t))},d:function(){var e;Ce<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;Ce<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;Ce<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;Ce<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;Ce<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;Ce<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+Ce+" to "+e),Ce=e},getLevel:function(){return Ce}},ke={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},De={NICK:"".concat(J="Tag_Profile_IM_","Nick"),GENDER:"".concat(J,"Gender"),BIRTHDAY:"".concat(J,"BirthDay"),LOCATION:"".concat(J,"Location"),SELFSIGNATURE:"".concat(J,"SelfSignature"),ALLOWTYPE:"".concat(J,"AllowType"),LANGUAGE:"".concat(J,"Language"),AVATAR:"".concat(J,"Image"),MESSAGESETTINGS:"".concat(J,"MsgSettings"),ADMINFORBIDTYPE:"".concat(J,"AdminForbidType"),LEVEL:"".concat(J,"Level"),ROLE:"".concat(J,"Role")},Oe={UNKNOWN:"".concat(W="Gender_Type_","Unknown"),FEMALE:"".concat(W,"Female"),MALE:"".concat(W,"Male")},Re={NONE:"".concat("AdminForbid_Type_","None"),SEND_OUT:"".concat("AdminForbid_Type_","SendOut")},Ae={NEED_CONFIRM:"".concat("AllowType_Type_","NeedConfirm"),ALLOW_ANY:"".concat("AllowType_Type_","AllowAny"),DENY_ANY:"".concat("AllowType_Type_","DenyAny")},Ne="@TOPIC#_",Le=Object.prototype.hasOwnProperty;function Ue(e){if(null==e)return 1;if("boolean"!=typeof e){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(xe(e)){for(var t in e)if(Le.call(e,t))return;return 1}return(Pe(e)||we(e)||be(e))&&0===e.size}}function Pe(e){return"map"===nt(e)}function we(e){return"set"===nt(e)}function be(e){return"file"===nt(e)}function Ge(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"===M(e)&&e.constructor===Number)}function Fe(e){return null!==e&&"object"===M(e)}function xe(e){if("object"===M(e)&&null!==e){if(null===(e=Object.getPrototypeOf(e)))return 1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t}}function Ve(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===nt(e)}function qe(e){return"function"==typeof e}function Ke(e){return"filelist"===nt(e)}function He(e){return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))}function je(e,t,n,s){if(!Qe(e)||!Qe(t))return 0;for(var i,a=0,o=Object.keys(t),r=0,c=o.length;r<c;r++)if(i=o[r],!(Ze(t[i])||n&&n.includes(i)))if(Qe(e[i])&&Qe(t[i]))a+=je(e[i],t[i],n,s);else{if(s&&s.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=t[i],a+=1)}return a}function Be(e,t){var n,s=new Map,i=r(e.entries());try{for(i.s();!(n=i.n()).done;){var a=v(n.value,2),o=a[0],c=a[1];c&&s.set(o,t?JSON.stringify(c):JSON.parse(JSON.stringify(c)))}}catch(e){i.e(e)}finally{i.f()}return s}function Ye(e){if(0===e.length)return 0;for(var t=0,n=0,s="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)n+=e[t++].charCodeAt[t]<=255?1:!1===s?3:2;return n}function We(e){return e=e||99999999,Math.round(Math.random()*e)}function ze(e,t){for(var n in e)if(e[n]===t)return 1}function $e(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")}var Je=["url"],Xe=function(e){return"string"==typeof e},Ze=function(e){return void 0===e},Qe=function(e){return Ve(e)||Fe(e)},et=function(e){return e instanceof Error},nt=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},st=(Date.now||(Date.now=function(){return(new Date).getTime()}),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),it=st.length,at={};function ot(e,t){var n;return!(!Ve(e)||!Ve(t))&&(n=!1,t.forEach(function(t){var s=t.key,i=(t=t.value,e.find(function(e){return e.key===s}));i?i.value!==t&&(i.value=t,n=!0):(e.push({key:s,value:t}),n=!0)}),n)}function rt(e){return e===k.GRP_AVCHATROOM}function ct(e){var t=e.type;return e=e.groupID,t===k.GRP_COMMUNITY||"".concat(e).startsWith("@TGS#_")&&!"".concat(e).includes(Ne)}function ut(e){return"".concat(e).startsWith("@TGS#_")&&"".concat(e).includes(Ne)}function lt(e){return Xe(e)&&e.slice(0,3)===k.CONV_C2C}function dt(e){return Xe(e)&&e.slice(0,5)===k.CONV_GROUP}function ht(e){return Xe(e)&&e===k.CONV_SYSTEM}function gt(e,t){var n={};return Object.keys(e).forEach(function(s){n[s]=t(e[s],s)}),n}function pt(e){return X?Promise.resolve({width:0,height:0}):$?new Promise(function(t,n){Q.getImageInfo({src:e,success:function(e){t({width:e.width,height:e.height})},fail:function(){t({width:0,height:0})}})}):oe&&9===re?Promise.resolve({width:0,height:0}):new Promise(function(t,n){var s=new Image;s.onload=function(){t({width:this.width,height:this.height}),s=null},s.onerror=function(){t({width:0,height:0}),s=null},s.src=e})}function _t(){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 ft(){var e=ie?"android":ne?"ios":ce?"windows":ue?"mac":"unknown";if($)try{var t=Q.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(e){}return e}function mt(e,t){e=e.split("."),t=t.split(".");for(var n=Math.max(e.length,t.length);e.length<n;)e.push("0");for(;t.length<n;)t.push("0");for(var s=0;s<n;s++){var i=parseInt(e[s]),a=parseInt(t[s]);if(a<i)return 1;if(i<a)return-1}return 0}function vt(e){var t=void 0===(t=e.originUrl)?void 0:t,n=e.originHeight,s=void 0===(s=e.min)?198:s,i={url:void 0,width:0,height:0};return((e=parseInt(e.originWidth))<=(n=parseInt(n))?e:n)<=s?(i.url=t,i.width=e,i.height=n):(n<=e?(i.width=Math.ceil(e*s/n),i.height=s):(i.width=s,i.height=Math.ceil(n*s/e)),n=t&&-1<t.indexOf("?")?"".concat(t,"&"):"".concat(t,"?"),i.url="".concat(n,198===s?"imageView2/3/w/198/h/198":"imageView2/3/w/720/h/720")),Ze(t)?f(i,Je):i}function yt(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 It(e){return(e=e.servcmd).slice(e.indexOf(".")+1)}function Mt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function Ct(e,t){return e.includes(t)}function Tt(e,t){return e.includes(t)}function St(e){return e.split(Ne)[0]}function Et(e,t,n){if(Ze(t))return"";switch(e){case k.MSG_TEXT:return t.text;case k.MSG_IMAGE:return n?"[Image]":"[图片]";case k.MSG_LOCATION:return n?"[Location]":"[位置]";case k.MSG_AUDIO:return n?"[Voice]":"[语音]";case k.MSG_VIDEO:return n?"[Video]":"[视频]";case k.MSG_FILE:return n?"[File]":"[文件]";case k.MSG_CUSTOM:return n?"[Custom Messages]":"[自定义消息]";case k.MSG_GRP_TIP:return n?"[Group Notification]":"[群提示消息]";case k.MSG_GRP_SYS_NOTICE:return n?"[Group System Message]":"[群系统通知]";case k.MSG_FACE:return n?"[Animated Sticker]":"[动画表情]";case k.MSG_MERGER:return n?"[Chat Record]":"[聊天记录]";case k.MSG_STREAM:return n?"[Stream Message]":"[流式消息]";default:return""}}function kt(e){var t=[];if(Xe(e)){var n=e.length;if(0!==n)for(var s=n-1;0<=s;s--)"1"===e[s]&&t.push(Math.pow(2,n-s-1))}return t}function Dt(){return!oe&&!$}function Ot(e,t,n){t=!(1<arguments.length&&void 0!==t)||t,n=!(2<arguments.length&&void 0!==n)||n;var s=Date.now();return t?n?"".concat(s-e," ms"):"".concat(Math.round((s-e)/1e3)," s"):n?s-e:Math.round((s-e)/1e3)}function Rt(e){return!!(e&&1<e)}function At(e,t,n,s){var i,a,o;return void 0===t||(i=!0,t.required&&Ue(e)&&(Ee.e("[".concat(n,'] Missing required params: "').concat(s,'".')),i=!1),Ue(e)||(a=nt(e))===(o=t.type.toLowerCase())||"asyncfunction"===a&&"function"===o||(Ee.e("[".concat(n,'] Invalid params: type check failed for "').concat(s,'". Expected ').concat(t.type,".")),i=!1),t.validator&&!t.validator(e,n,s)&&(Ee.e("[".concat(n,'] Invalid params: custom validator check failed for "').concat(s,'".')),i=!1),i)}function Nt(e){return!(!e||!(lt(e)||dt(e)||ht(e))&&((e=an("InvalidConversationID",e))&&Ee.w(e),1))}function Lt(e){""!==e.desc&&""!==an("API_REFER")&&Ee.w("[".concat(e.api,"] | ").concat(e.paramName," | ").concat(e.desc,", ").concat(an("API_REFER")).concat(e.api))}function Ut(){return an("StringRequiredLog")}function Pt(e){return an("NonEmptyStringRequiredLog",e)}function wt(){return an("NumberRequiredLog")}function bt(){return an("UndefinedNotAllowedLog")}function Gt(){return an("FileRequiredLog")}function Ft(){return an("FunctionRequiredLog")}function xt(){return an("ArrayRequiredLog")}function Vt(){return an("NonEmptyArrayLog")}function qt(){return an("CallbackMissingLog")}function Kt(){return an("PositiveIntegerRequiredLog")}function Ht(){return an("PlainObjectRequiredLog")}function jt(){return an("NonEmptyContentRequiredLog")}function Bt(){return an("FileNotSelectedLog")}function Yt(){return an("MessageInstanceRequiredLog")}function Wt(){return an("NonAnonymousFunctionLog")}function zt(e){return{code:0,data:e||{}}}function $t(e){return Promise.resolve(zt(e))}function Jt(e){var t,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return e instanceof cn?(n&&null!==ln&&ln.emit(E.ERROR,e),Promise.reject(e)):e instanceof Error?(t=new cn({code:un.UNCAUGHT_ERROR}),n&&null!==ln&&ln.emit(E.ERROR,t),Promise.reject(t)):Ze(e)||Ze(e.code)?Promise.reject(new cn({code:un.UNCAUGHT_ERROR})):(t=new cn(e),n&&null!==ln&&ln.emit(E.ERROR,t),Promise.reject(t))}var Xt="unSend",Zt="success",Qt="notStart",en="pending",tn="resolved",nn="rejected",sn=(x={type:"String",required:!0},J={type:"Array",required:!0},{type:"Boolean",required:!0}),an=null,on={hookGetAPITips:function(e){an=e},login:{userID:x,userSig:x},on:[{name:"eventName",type:"String",validator:function(e,t,n){return"string"==typeof e&&0!==e.length||(Lt({api:t,paramName:n,desc:Pt(n)}),!1)}},{name:"handler",type:"Function",validator:function(e,t,n){return"function"!=typeof e?(Lt({api:t,paramName:n,desc:Ft()}),!1):(""===e.name&&Lt({api:t,paramName:n,desc:Wt()}),!0)}}],off:[{name:"eventName",type:"String",validator:function(e,t,n){return"string"==typeof e&&0!==e.length||(Lt({api:t,paramName:n,desc:Pt(n)}),!1)}},{name:"handler",type:"Function",validator:function(e,t,n){return"function"!=typeof e?(Lt({api:t,paramName:n,desc:Ft()}),!1):(""===e.name&&Lt({api:t,paramName:n,desc:Wt()}),!0)}}],sendMessage:[_({name:"message"},W={type:"Object",required:!0})],getMessageList:{conversationID:_(_({},x),{},{validator:Nt}),nextReqMessageID:{type:"String"},count:{type:"Number",validator:function(e,t,n){return!(!Ze(e)&&!/^[1-9][0-9]*$/.test(e)&&(Lt({api:t,paramName:n,desc:Kt()}),1))}}},getMessageListHopping:{conversationID:_(_({},x),{},{validator:Nt}),sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:function(e,t,n){return!(!Ze(e)&&0!==e&&1!==e&&(Lt({api:t,paramName:n,desc:an("0Or1RequiredLog")}),1))}},count:{type:"Number",validator:function(e,t,n){return!(!Ze(e)&&!/^[1-9][0-9]*$/.test(e)&&(Lt({api:t,paramName:n,desc:Kt}),1))}}},setMessageRead:{conversationID:_(_({},x),{},{validator:Nt})},setAllMessageRead:{scope:{type:"String",required:!1,validator:function(e,t,n){return!e||-1!==[k.READ_ALL_C2C_MSG,k.READ_ALL_GROUP_MSG,k.READ_ALL_MSG].indexOf(e)||(Lt({api:t,paramName:n,desc:an("ValidScopeRequired")}),!1)}}},getConversationProfile:[_(_({name:"conversationID"},x),{},{validator:Nt})],clearHistoryMessage:[_(_({name:"conversationID"},x),{},{validator:Nt})],pinConversation:{conversationID:_(_({},x),{},{validator:Nt}),isPinned:_({},sn)},setConversationDraft:{conversationID:_(_({},x),{},{validator:Nt}),draftText:{type:"String",validator:function(e,t,n){return!!Xe(e)||(Lt({api:t,paramName:n,desc:Ut()}),!1)}}},setConversationCustomData:{conversationIDList:_({},J),customData:{type:"String",validator:function(e,t,n){return Xe(e)?!(256<e.length&&(Lt({api:t,paramName:n,desc:an("StringNotLongerThanLog",n,256)}),1)):(Lt({api:t,paramName:n,desc:Ut()}),!1)}}},markConversation:{conversationIDList:_({},J),markType:{type:"number",validator:function(e,t,n){return Ge(e)?e<=0?(Lt({api:t,paramName:n,desc:an("NumberGreaterThanLog",n,0)}),!1):!(e>=Math.pow(2,64)&&(Lt({api:t,paramName:n,desc:an("NumberLessThanLog",n,"Math.pow(2,64)")}),1)):(Lt({api:t,paramName:n,desc:wt()}),!1)}},enableMark:_({},sn)},createTextMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return xe(e)?Xe(e.text)?0!==e.text.length||(Lt({api:t,paramName:"payload.text",desc:jt()}),!1):(Lt({api:t,paramName:"payload.text",desc:Ut()}),!1):(Lt({api:t,paramName:n,desc:Ht()}),!1)}})},createTextAtMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return xe(e)?Xe(e.text)?0===e.text.length?(Lt({api:t,paramName:"payload.text",desc:jt()}),!1):!(e.atUserList&&!Ve(e.atUserList)&&(Lt({api:t,paramName:"payload.atUserList",desc:xt()}),1)):(Lt({api:t,paramName:"payload.text",desc:Ut()}),!1):(Lt({api:t,paramName:n,desc:Ht()}),!1)}})},createCustomMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return xe(e)?e.data&&!Xe(e.data)?(Lt({api:t,paramName:"payload.data",desc:Ut()}),!1):e.description&&!Xe(e.description)?(Lt({api:t,paramName:"payload.description",desc:Ut()}),!1):!(e.extension&&!Xe(e.extension)&&(Lt({api:t,paramName:"payload.extension",desc:Ut()}),1)):(Lt({api:t,paramName:"payload",desc:Ht()}),!1)}})},createImageMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){if(!xe(e))return Lt({api:t,paramName:n,desc:Ht()}),!1;if(Ze(e.file))return Lt({api:t,paramName:"payload.file",desc:bt()}),!1;if(Z){if(!(e.file instanceof HTMLInputElement||be(e.file)))return xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Lt({api:t,paramName:"payload.file",desc:Bt()}),!1):(Lt({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Lt({api:t,paramName:"payload.file",desc:Bt()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e,t,n){return Ze(e)&&Lt({api:t,paramName:n,desc:qt()}),!0}}})},createAudioMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return!!xe(e)||(Lt({api:t,paramName:n,desc:Ht()}),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return Ze(e)&&Lt({api:t,paramName:n,desc:qt()}),!0}}},createVideoMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){if(!xe(e))return Lt({api:t,paramName:n,desc:Ht()}),!1;if(Ze(e.file))return Lt({api:t,paramName:"payload.file",desc:bt()}),!1;if(Z){if(!(e.file instanceof HTMLInputElement||be(e.file)))return xe(e.file)&&"undefined"!=typeof uni?!!be(e.file.tempFile)||(Lt({api:t,paramName:"payload.file",desc:Bt()}),!1):(Lt({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Lt({api:t,paramName:"payload.file",desc:Bt()}),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return Ze(e)&&Lt({api:t,paramName:n,desc:qt()}),!0}}},createFaceMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return xe(e)?Ge(e.index)?!!Xe(e.data)||(Lt({api:t,paramName:"payload.data",desc:Ut()}),!1):(Lt({api:t,paramName:"payload.index",desc:wt()}),!1):(Lt({api:t,paramName:n,desc:Ht()}),!1)}})},createFileMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){if(!xe(e))return Lt({api:t,paramName:n,desc:Ht()}),!1;if(Ze(e.file))return Lt({api:t,paramName:"payload.file",desc:bt()}),!1;if(Z){if(!(e.file instanceof HTMLInputElement||be(e.file)))return xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Lt({api:t,paramName:"payload.file",desc:Bt()}),!1):(Lt({api:t,paramName:"payload.file",desc:Gt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Lt({api:t,paramName:"payload.file",desc:Bt()}),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e,t,n){return Ze(e)&&Lt({api:t,paramName:n,desc:qt()}),!0}}},createLocationMessage:{to:x,conversationType:x,payload:_(_({},W),{},{validator:function(e,t,n){return xe(e)?Xe(e.description)?Ge(e.longitude)?!!Ge(e.latitude)||(Lt({api:t,paramName:"payload.latitude",desc:wt()}),!1):(Lt({api:t,paramName:"payload.longitude",desc:wt()}),!1):(Lt({api:t,paramName:"payload.description",desc:Ut()}),!1):(Lt({api:t,paramName:n,desc:Ht()}),!1)}})},revokeMessage:[_(_({name:"message"},W),{},{validator:function(e,t,n){return Ue(e)?(Lt({api:t,paramName:n,desc:Yt()}),!1):e.conversationType===k.CONV_SYSTEM?(Lt({api:t,paramName:n,desc:an("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Lt({api:t,paramName:n,desc:an("MessageRevokedLog")}),!1)}})],deleteMessage:[_(_({name:"messageList"},J),{},{validator:function(e,t,n){return!Ue(e)||(Lt({api:t,paramName:n,desc:Vt()}),!1)}})],translateText:{sourceTextList:J,sourceLanguage:x,targetLanguage:x},convertVoiceToText:{message:_(_({},W),{},{validator:function(e,t,n){return Ue(e)?(Lt({api:t,paramName:n,desc:Yt()}),!1):e.type===k.MSG_AUDIO&&e.status===Zt||(Lt({api:t,paramName:n,desc:an("AudioMessageRequiredLog")}),!1)}})},modifyMessage:[_(_({name:"message"},W),{},{validator:function(e,t,n){return Ue(e)?(Lt({api:t,paramName:n,desc:Yt()}),!1):e.conversationType===k.CONV_SYSTEM?(Lt({api:t,paramName:n,desc:an("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Lt({api:t,paramName:n,desc:an("OnlineMessageNotSupportLog")}),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e,t,n){return Ve(e)?(0===e.length&&Lt({api:t,paramName:n,desc:Vt()}),!0):(Lt({api:t,paramName:n,desc:xt()}),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e,t,n){return!!Ze(e)||!!Ve(e)||(Lt({api:t,paramName:n,desc:xt()}),!1)}}},setSelfStatus:{customStatus:{type:"String",validator:function(e,t,n){return!!Xe(e)||(Lt({api:t,paramName:n,desc:Ut()}),!1)}}},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:function(e,t,n){return Ve(e)?0!==e.length||(Lt({api:t,paramName:n,desc:Vt()}),!1):(Lt({api:t,paramName:n,desc:xt()}),!1)}}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:function(e,t,n){return Ve(e)?0!==e.length||(Lt({api:t,paramName:n,desc:Vt()}),!1):(Lt({api:t,paramName:n,desc:xt()}),!1)}}]},rn={login:1,logout:1,getLoginUser:1,getServerTime:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,isReady:1,createTextMessage:1,createTextAtMessage:1,createImageMessage:1,createAudioMessage:1,createVideoMessage:1,createCustomMessage:1,createFaceMessage:1,createFileMessage:1,createLocationMessage:1,createMergerMessage:1,downloadMergerMessage:1,createForwardMessage:1,sendMessage:1,resendMessage:1,revokeMessage:1,deleteMessage:1,translateText:1,convertVoiceToText:1,modifyMessage:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,setConversationDraft:1,pinConversation:1,getTotalUnreadMessageCount:1,setConversationCustomData:1,markConversation:1,createConversationGroup:1,getConversationGroupList:1,deleteConversationGroup:1,renameConversationGroup:1,addConversationsToGroup:1,deleteConversationsFromGroup:1,clearHistoryMessage:1,setMessageRemindType:1,setAllReceiveMessageOpt:1,getAllReceiveMessageOpt:1,getMyProfile:1,getUserProfile:1,updateMyProfile:1,setSelfStatus:1,getUserStatus:1,subscribeUserStatus:1,unsubscribeUserStatus:1,callExperimentalAPI:1},cn=(l(Rn,T(Error)),o(Rn)),un={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_F_IS_EMPTY:2108,MSG_ONPROGRESS_ERR:2109,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,VOICE_TO_TEXT_FAIL:2118,UNSUPPORTED_VOICE_FORMAT:2119,MSG_I_SELECT_F_FIRST:2251,MSG_I_TYPES_LIMIT:2252,MSG_I_SIZE_LIMIT:2253,MSG_A_UPLOAD_FAIL:2300,MSG_A_SIZE_LIMIT:2301,MSG_V_UPLOAD_FAIL:2350,MSG_V_SIZE_LIMIT:2351,MSG_V_TYPES_LIMIT:2352,MSG_F_UPLOAD_FAIL:2400,MSG_F_SELECT_F_FIRST:2401,MSG_F_SIZE_LIMIT:2402,MSG_F_URL_IS_EMPTY:2403,MSG_MERGER_TYPE_INVALID:2450,MSG_MERGER_KEY_INVALID:2451,MSG_MERGER_DOWNLOAD_FAIL:2452,MSG_FORWARD_TYPE_INVALID:2453,MSG_FORWARD_INVALID_ELEMENTS:2454,MSG_MODIFY_CONFLICT:2480,MSG_MODIFY_DISABLED_IN_AV:2481,CONV_NOT_FOUND:2500,USER_OR_GRP_NOT_FOUND:2501,CONV_UN_RECORDED_TYPE:2502,INVALID_CONV_ID:2503,ILLEGAL_GRP_TYPE:2600,ILLEGAL_GRP_ID:2602,CANNOT_FIND_GRP:2603,CANNOT_CHANGE_OWNER_IN_AV:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,MEMBER_NOT_IN_GRP:2623,JOIN_GRP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AV:2661,CANNOT_JOIN_NON_AV_WITHOUT_LOGIN:2662,NOT_OWNER:2681,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,BAN_DURATION_INVALID:2686,OPERATION_NOT_SUPPORTED_IN_AV:2687,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GRP_EXISTED:2710,FRIEND_GRP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,INVALID_TRTC_CMD:2995,OVER_FREQUENCY_LIMIT:2996,NO_PROTOCOL:2997,NO_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,NO_USE:3122,PROFANITY_FOUND:3123,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022,SIGNALING_INVALID_INVITE_ID:8010,SIGNALING_NO_PERMISSION:8011,SIGNALING_ALREADY_EXISTS:8012,INVALID_CANCEL_MESSAGE:8020},ln=null,dn=(sn=o(function e(t){i(this,e),this._m=t,this._n=""},[{key:"isLoggedIn",value:function(){return this._m.get(12).isLoggedIn()}},{key:"isOversea",value:function(){return this._m.get(12).isOversea()}},{key:"isPrivateNetWork",value:function(){var e=this._m.get(12);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}},{key:"getFileDownloadProxy",value:function(){return this._m.get(12).getFileDownloadProxy()}},{key:"getDownloadFileAuthKey",value:function(){return this._m.get(12).getDownloadFileAuthKey()}},{key:"getMyUserID",value:function(){return this._m.get(12).getUserID()}},{key:"getMyTinyID",value:function(){return this._m.get(12).getTinyID()}},{key:"getSDKAppID",value:function(){return this._m.get(12).getSDKAppID()}},{key:"isIntl",value:function(){return this._m.get(12).isIntl()}},{key:"isUsingChatCore",value:function(){return this._m.get(12).isUsingChatCore()}},{key:"isDevMode",value:function(){return this._m.get(12).isDevMode()}},{key:"get",value:function(e){return this._m.get(e)}},{key:"getPlatform",value:function(){return te}},{key:"getCloudConfig",value:function(e){return this._m.get(23).getCloudConfig(e)}},{key:"emitOEvt",value:function(e,t){this._m.getOEmitInst().emit(e,t)}},{key:"emitIEvt",value:function(e,t){this._m.getIEmitInst().emit(e,t)}},{key:"getIEmitInst",value:function(){return this._m.getIEmitInst()}},{key:"req",value:function(e){return this._m.get(20).req(e)}},{key:"canIUse",value:function(e){return this._m.get(27).canIUse(e)}},{key:"getErrMsg",value:function(e,t,n){return this._m.getErrMsg(e,t,n)}},{key:"warn",value:function(e,t,n){(e=this.getErrMsg(e,t,n))&&Ee.w(e)}},{key:"noUse",value:function(e){var t=un.NO_USE;return Jt({code:t,message:this.getErrMsg(t,e)})}}]),{LOGIN:"wslogin",LOGOUT:"wslogout",HELLO:"wshello",KICK_OTHER:"KickOther",SYNC_UNREAD_MSG:"getmsg",SEND_C2C_MSG:"sendmsg",GET_USER_PROFILE:"portrait_get_all",UPDATE_MY_PROFILE:"portrait_set",REVOKE_C2C_MSG:"msgwithdraw",SET_C2C_MSG_READ:"msgreaded",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_C2C_ROAMING_MSG:"getroammsg",GET_C2C_PEER_READ_TIME:"get_peer_read_time",DEL_C2C_MSG:"delete_c2c_msg_ramble",MODIFY_C2C_MSG:"modify_c2c_msg",MODIFY_C2C_MSG_EXT:"set_key_values",GET_C2C_MSG_EXT:"get_key_values",PAGING_GET_CONV_LIST:"page_get",DEL_CONV:"batch_delete",CLEAR_HISTORY_MSG:"clear_msg",PIN_CONV:"top",DEL_GROUP_AT_TIPS:"deletemsg",SET_CONV_CUSTOM_DATA:"set_conv_custom_data",MARK_CONV:"mark_contact",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",SIMPLE_COS_PRE_SIG:"simple_sig",GET_IMAGE_INFO:"get_imageinfo",GET_IP:"get_final_ip",VIDEO_COVER:"video_cover",SSO_STAT:"tim_web_report_v2",PING:"alive",MSG_PUSH:"msg_push",MSG_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",FETCH_CLOUD_CTRL_CONFIG:"fetch_config",PUSHED_CLOUD_CTRL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",OVERLOAD_NOTIFY:"notify2",SET_SELF_STATUS:"ws_set_custom_status",GET_USER_STATUS:"ws_get_user_status",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",PUSH_REPORT:"uniapp_sdk_report",TRANSLATE_TEXT:"ws_batch_trans_text",VOICE_TO_TEXT:"ws_sentence_recognition",SET_ALL_RECEIVE_MSG_OPT:"ws_set_do_not_disturb",GET_ALL_RECEIVE_MSG_OPT:"ws_get_do_not_disturb",STREAM_GET_STREAM:"GetStreamHttp",STREAM_CHUNK_ACK:"AckHttp",STREAM_PUSH_CHUNKS:"PushStreamHttp"}),hn="networkRTT",gn="messageE2EDelay",pn="sendMessageC2C",_n="sendMessageGroup",fn="sendMessageGroupAV",mn="sendMessageRichMedia",vn="cosUpload",yn="messageReceivedGroup",In="messageReceivedGroupAVPush",Mn="messageReceivedGroupAVPull",Cn=c(c(c(c(c(c(c(c(c(c({},hn,2),gn,3),pn,4),_n,5),fn,6),mn,7),yn,8),In,9),Mn,10),vn,11),Tn={info:4,warning:5,error:6},Sn={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},En={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16,tui_key_features:16},kn=o(On,[{key:"updateTimeStamp",value:function(){this.timestamp=me()}},{key:"start",value:function(e){return this._startts=e,this}},{key:"end",value:function(){var e,t=this,n=0<arguments.length&&void 0!==arguments[0]&&arguments[0];this._sentFlag||(this._netMonitorModule&&(e=this._netMonitorModule.getNetworkType(),this.setNetworkType(e)),e=me(),0===this.costTime&&(this.costTime=e-this._startts),this.setMoreMessage("startts:".concat(this._startts," endts:").concat(e)),n?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(function(){t._sentFlag=!0,t._eventStatModule&&t._eventStatModule.pushIn(t)},0))}},{key:"setError",value:function(e){var t;return e instanceof Error?this._sentFlag||(t=!0,(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)?(e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message)):this.setCode(un.NO_NETWORK),this.setLevel("error")):Ee.w("".concat(this._n,".setError value not instanceof Error, please check!")),this}},{key:"setCode",value:function(e){return Ze(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Ge(e)?this.code=e:Ee.w("".concat(this._n,".setCode value not a number, please check!"),e,M(e))),this}},{key:"setMessage",value:function(e){return Ze(e)||this._sentFlag||(Ge(e)&&(this.message=e.toString()),Xe(e)&&(this.message=e)),this}},{key:"setCostTime",value:function(e){return this.costTime=e,this}},{key:"setLevel",value:function(e){return Ze(e)||this._sentFlag||(this.level=Tn[e]),this}},{key:"setMoreMessage",value:function(e){return Ue(this.moreMessage)?this.moreMessage="".concat(e):this.moreMessage+=" ".concat(e),this}},{key:"setNetworkType",value:function(e){return Ze(e)?Ee.w("".concat(this._n,".setNetworkType value is undefined, please check!")):(e=Sn[e.toLowerCase()],Ze(e)||(this.networkType=e)),this}},{key:"getStartTs",value:function(){return this._startts}},{key:"setUIPlatform",value:function(e){return this.uiPlatform=e,this}},{key:"setExtension",value:function(e){return this.extension=e,this}},{key:"setEventType",value:function(e){return this.eventType=e,this}}],[{key:"bindEventStatModule",value:function(e){On.prototype._eventStatModule=e}},{key:"bindNetMonitorModule",value:function(e){On.prototype._netMonitorModule=e}}]),Dn=o(function e(t){i(this,e),this.type=k.MSG_TEXT,this.content={text:t.text||""}},[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]);function On(e){i(this,On),this._n="SSOLogData",this.eventType=En[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=me()}function Rn(e){i(this,Rn),t=n(this,Rn);var t,s=e.code,a=e.message;return e=e.data,t.code=s,a?t.message=a:t._getErrMsg&&(t.message=t._getErrMsg(t.code)),t.data=e||{},t}function An(e,t,n,s){var i;return s=3<arguments.length&&void 0!==s?s:[],e&&(i=e,t&&(e.startsWith("http://")?i=e.replace(/^http:\/\/[^/]+/,t):e.startsWith("https://")&&(i=e.replace(/^https:\/\/[^/]+/,t))),n&&-1===i.indexOf("authKey=")&&Un(i,s)?(-1<i.indexOf("?")?"".concat(i,"&authKey="):"".concat(i,"?authKey=")).concat(n):i)}function Nn(e,t,n){var s=2<arguments.length&&void 0!==n?n:[];return n=t[0].content||t[0].payload,e===k.MSG_IMAGE?n.imageInfoArray.forEach(function(e){Un(e.imageUrl,s)&&(e.imageUrl=Ln(e.imageUrl))}):e===k.MSG_VIDEO?(Un(n.snapshotUrl,s)&&(n.snapshotUrl=Ln(n.snapshotUrl),n.thumbUrl=Ln(n.thumbUrl)),Un(n.remoteVideoUrl,s)&&(n.remoteVideoUrl=Ln(n.remoteVideoUrl))):e===k.MSG_AUDIO?Un(n.remoteAudioUrl,s)&&(n.remoteAudioUrl=Ln(n.remoteAudioUrl)):e===k.MSG_FILE?Un(n.fileUrl,s)&&(n.fileUrl=Ln(n.fileUrl)):e===k.MSG_MERGER&&(e=(n=t[0].content||t[0].payload).downloadKey,n=void 0===(n=n.messageList)?[]:n,Ue(void 0===e?"":e))&&n.forEach(function(e){Nn(e.messageBody[0].type,e.messageBody,s)}),t}function Ln(e){if(!e)return e;if(-1===e.indexOf("authKey="))return e;for(var t=(e=e.split("?"))[1].split("&"),n=0,s=0;s<t.length;s++)if(-1<t[s].indexOf("authKey=")){n=s;break}return t.splice(n,1),0<t.length?"".concat(e[0],"?").concat(t.join("&")):e[0]}function Un(e,t){var n=!1;if(e){var s=(e=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/))&&e[2]||"";if(s.includes("rich-dev"))return 1;for(var i=0;i<t.length;i++)if(s.endsWith(t[i])){n=!0;break}}return n}var Pn=o(function e(t,n,s,a){i(this,e),this._imageMemoryURL="",this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,$||X?this.createImageDataASURL(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=k.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||ke.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._autoFixUrl()},[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=We(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.imageUrl||t.url||"",this.url=An(t.url||e._imageMemoryURL,e._fileDownloadProxy,e._authKey,e._fileDNList)},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(t){t&&(this.imageUrl=An(t,e._fileDownloadProxy,e._authKey,e._fileDNList))},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t,n=0,s=null;n<=2;)t=Ze(e)||Ze(e[n])?{type:0,size:0,width:0,height:0,url:""}:e[n],(s=new this._ImageInfoModel(t)).setSizeType(n+1),s.setType(n),this.addImageInfo(s),n++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,n=this.content.imageInfoArray.length,s=0;s<n;s++)t=this.content.imageInfoArray[s],e[s].size&&(t.size=e[s].size),e[s].url&&t.setImageUrl(e[s].url),e[s].width&&(t.width=e[s].width),e[s].height&&(t.height=e[s].height)}},{key:"_autoFixUrl",value:function(){for(var e=this.content.imageInfoArray.length,t="",n="",s=["http","https"],i=null,a=0;a<e;a++)this.content.imageInfoArray[a].url&&""!==(i=this.content.imageInfoArray[a]).imageUrl&&(n=i.imageUrl.slice(0,i.imageUrl.indexOf("://")+1),t=i.imageUrl.slice(i.imageUrl.indexOf("://")+1),s.indexOf(n)<0&&(n="https:"),this.content.imageInfoArray[a].setImageUrl([n,t].join("")))}},{key:"updatePercent",value:function(e){this._percent=e,1<this._percent&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=ke[e.toUpperCase()]||ke.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&0<e.files.length&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURL",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){3<=this.content.imageInfoArray.length||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=void 0===(t=(n=e[0]).width)?0:t,n=void 0===(n=n.height)?0:n;0!==t&&0!==n&&(yt(e),Object.assign(e[2],vt({originWidth:t,originHeight:n,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size}}]),wn=o(function e(t){i(this,e),this.type=k.MSG_FACE,this.content=t||null},[{key:"sendable",value:function(){return null!==this.content}}]),bn=o(function e(t,n,s,a){i(this,e),this.type=k.MSG_AUDIO,this._percent=0,this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,this.content={downloadFlag:2,second:t.second,size:t.size,url:An(t.url,this._fileDownloadProxy,this._authKey,this._fileDNList),remoteAudioUrl:An(t.url||"",this._fileDownloadProxy,this._authKey,this._fileDNList),uuid:t.uuid}},[{key:"updatePercent",value:function(e){this._percent=e,1<this._percent&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=An(e,this._fileDownloadProxy,this._authKey,this._fileDNList)}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),Gn={from:!0,groupID:!0,groupName:!0,to:!0},Fn=o(function e(t){i(this,e),this.type=k.MSG_GRP_TIP,this.content={},this._initContent(t)},[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach(function(n){switch(n){case"remarkInfo":case"memberExtraInfo":case"onlineMemberInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;case"operatorInfo":t.content.operatorInfo={},t._initOperatorInfo(e[n]);break;case"memberInfoList":case"msgMemberInfo":t._updateMemberList(e[n]);break;case"memberNum":t.content[n]=e[n],t.content.memberCount=e[n];break;case"newGroupProfile":t.content.newGroupProfile={},t._initNewGroupProfile(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 s=t[n];Gn[s]&&(this.content.groupProfile[s]=e[s])}}},{key:"_initOperatorInfo",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var s=t[n];this.content.operatorInfo[s]=e[s]}}},{key:"_updateMemberList",value:function(e){Ue(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)})})}},{key:"_initNewGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var s=t[n];this.content.newGroupProfile[s]="muteAllMembers"!==s?e[s]:1===e[s]}}}]),xn={from:!0,groupID:!0,groupName:!0,to:!0,groupType:!0},Vn=o(function e(t){i(this,e),this.type=k.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)},[{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 s=t[n];xn[s]&&("groupName"===s?this.content.groupProfile.name=e[s]:this.content.groupProfile[s]=e[s])}}}]),qn=o(function e(t,n,s,a){i(this,e),this.type=k.MSG_FILE,this._percent=0;var o=this._getFileInfo(t);this.content={downloadFlag:2,fileUrl:An(t.url||t.fileUrl,n,s,a)||"",uuid:t.uuid,fileName:o.name||"",fileSize:o.size||0}},[{key:"_getFileInfo",value:function(e){var t,n;return Ze(e.fileName)||Ze(e.fileSize)?(t=e.file.files[0],Y&&(t.path&&-1!==t.path.indexOf(".")&&(n=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase(),t.type=n,t.name||(t.name="".concat(We(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)),{size:t.size,name:t.name}):{size:e.fileSize,name:e.fileName}}},{key:"updatePercent",value:function(e){this._percent=e,1<this._percent&&(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}}]),Kn=o(function e(t){i(this,e),this.type=k.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}},[{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}}]),Hn=o(function e(t,n,s,a){i(this,e),this.type=k.MSG_VIDEO,this._percent=0,this._fileDownloadProxy=n,this._authKey=s,this._fileDNList=a,this.content={remoteVideoUrl:An(t.remoteVideoUrl||t.videoUrl||"",this._fileDownloadProxy,this._authKey,this._fileDNList),videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:An(t.videoUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,snapshotWidth:t.thumbWidth,thumbHeight:t.thumbHeight,snapshotHeight:t.thumbHeight,thumbSize:t.thumbSize,snapshotSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:An(t.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),snapshotUrl:An(t.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList)}},[{key:"updatePercent",value:function(e){this._percent=e,1<this._percent&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=An(e,this._fileDownloadProxy,this._authKey,this._fileDNList))}},{key:"updateSnapshotInfo",value:function(e){var t=e.snapshotUrl,n=e.snapshotWidth;e=e.snapshotHeight,Ue(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),Ue(n)||(this.content.thumbWidth=this.content.snapshotWidth=Number(n)),Ue(e)||(this.content.thumbHeight=this.content.snapshotHeight=Number(e))}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),jn=o(function e(t){i(this,e),this.type=k.MSG_LOCATION;var n=t.description;this.content={description:n,longitude:t.longitude,latitude:t.latitude}},[{key:"sendable",value:function(){return!0}}]),Bn=o(function e(t,n,s,a){var o,r;i(this,e),this.from=t.from,this.messageSender=t.from,this.time=t.time,this.messageSequence=t.sequence,this.clientSequence=t.clientSequence||t.sequence,this.messageRandom=t.random,this.cloudCustomData=t.cloudCustomData||"",this.clientTime=t.clientTime||void 0,t.ID?(this.ID=t.ID||"",this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=t.messageBody?JSON.parse(JSON.stringify(t.messageBody)):[{type:t.type,payload:t.payload}],t.conversationType?t.conversationType.startsWith(k.CONV_C2C)?this.receiverUserID=t.to:t.conversationType.startsWith(k.CONV_GROUP)&&(this.receiverGroupID=t.to):t.receiverGroupID?this.receiverGroupID=t.receiverGroupID:t.receiverUserID&&(this.receiverUserID=t.receiverUserID),this.messageReceiver=t.to||t.messageReceiver):(this.nick=t.nick||"",this.avatar=t.avatar||"",this.messageBody=[],o=t.elements[0].type,r=t.elements[0].content,this._patchRichMediaPayload(o,r),this._updateRichMediaDownloadUrl(o,r,n,s,a),o===k.MSG_MERGER?this.messageBody.push({type:o,payload:new Yn(r,n,s,a).content}):this.messageBody.push({type:o,payload:r}),t.groupID&&(this.receiverGroupID=t.groupID,this.messageReceiver=t.groupID),t.to&&(this.receiverUserID=t.to,this.messageReceiver=t.to),this.ID="".concat(t.tinyID,"-").concat(t.clientTime,"-").concat(t.random))},[{key:"_patchRichMediaPayload",value:function(e,t){e===k.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===k.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===k.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===k.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}},{key:"_updateRichMediaDownloadUrl",value:function(e,t,n,s,i){(n||s)&&(e===k.MSG_IMAGE?t.imageInfoArray.forEach(function(e){e.imageUrl=An(e.imageUrl,n,s,i),e.url=An(e.url,n,s,i)}):e===k.MSG_VIDEO?(t.remoteVideoUrl=An(t.remoteVideoUrl,n,s,i),t.videoUrl=An(t.videoUrl,n,s,i),t.thumbUrl=An(t.thumbUrl,n,s,i),t.snapshotUrl=An(t.thumbUrl,n,s,i),t.snapshotHeight=t.thumbHeight,t.snapshotWidth=t.thumbWidth):e===k.MSG_AUDIO?(t.remoteAudioUrl=An(t.remoteAudioUrl,n,s,i),t.url=An(t.url,n,s,i)):e===k.MSG_FILE&&(t.fileUrl=An(t.fileUrl,n,s,i)))}}]),Yn=o(function e(t,n,s,a){var o,r,c,u,l,d,h;i(this,e),this.type=k.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},t.downloadKey?(r=t.downloadKey,c=t.pbDownloadKey,u=t.title,l=t.abstractList,d=t.compatibleText,o=t.version,this.content.downloadKey=r,this.content.pbDownloadKey=c,this.content.title=u,this.content.abstractList=l,this.content.compatibleText=d,this.content.version=o||0):Ue(t.messageList)?1===t.layersOverLimit&&(this.content.layersOverLimit=!0):(r=t.messageList,c=t.title,u=t.abstractList,l=t.compatibleText,d=t.version,h=[],r.forEach(function(e){Ue(e)||(e=new Bn(e,n,s,a),h.push(e))}),this.content.messageList=h,this.content.title=c,this.content.abstractList=u,this.content.compatibleText=l,this.content.version=d||0)},[{key:"sendable",value:function(){return!Ue(this.content.messageList)||!Ue(this.content.downloadKey)}}]),Wn=o(function e(t){i(this,e),this.type=k.MSG_STREAM,this._chunks=[],this._lastIndex=0;var n=t.streamMessageID,s=t.errorCode,a=t.errorMessage,o=t.isStreamEnded;this.content={streamMessageID:n,compatibleText:t.compatibleText,markdown:t.markdown||"",binaryData:t.binaryData,errorCode:void 0===s?0:s,errorMessage:void 0===a?"":a,isStreamEnded:void 0!==o&&o},this.stopReason=0},[{key:"updateChunks",value:function(e){var t;e&&0!==e.length&&(e=e.sort(function(e,t){return e.index-t.index}),0<=(t=this._getMaxRevokedChunkIndex(e))&&(this._chunks=[],this._lastIndex=t,this._updateContent()),0!==(t=this._getValidChunks(e)).length)&&(this._mergeAndSortChunks(t),0<this._chunks.length)&&(e=this._chunks[this._chunks.length-1],this._lastIndex=e.index,this._updateContent(),this.content.isStreamEnded=e.isLast)}},{key:"_getMaxRevokedChunkIndex",value:function(e){for(var t,n=-1,s=0,i=e.length;s<i;s++)1===(t=e[s]).eventType&&t.index>n&&(n=t.index);return n}},{key:"_updateContent",value:function(){this.content=_(_({},this.content),{},{markdown:this._chunks.map(function(e){return e.markdown}).join("")});var e=this._chunks.map(function(e){return e.binaryData}).filter(function(e){return!!e&&0<e.length});if(0===e.length)this.content.binaryData=new Uint8Array(0);else if(1===e.length)this.content.binaryData=e[0];else{var t,n=e.reduce(function(e,t){return e+t.length},0),s=new Uint8Array(n),i=0,a=r(e);try{for(a.s();!(t=a.n()).done;){var o=t.value;s.set(o,i),i+=o.length}}catch(e){a.e(e)}finally{a.f()}this.content.binaryData=s}}},{key:"_mergeAndSortChunks",value:function(e){var t=new Map;this._chunks.forEach(function(e){t.set(e.index,e)}),e.forEach(function(e){t.set(e.index,e)}),this._chunks=Array.from(t.values()).sort(function(e,t){return e.index-t.index})}},{key:"getLastIndex",value:function(){return this._lastIndex}},{key:"_getValidChunks",value:function(e){var t=this;if(0===(e=e.filter(function(e){return 0===e.eventType&&e.index>t._lastIndex})).length)return[];var n,s=[],i=this._lastIndex+1,a=r(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;o.index===i&&(s.push(o),i++)}}catch(e){a.e(e)}finally{a.f()}return s}}]),zn={1:k.MSG_PRIORITY_HIGH,2:k.MSG_PRIORITY_NORMAL,3:k.MSG_PRIORITY_LOW,4:k.MSG_PRIORITY_LOWEST},$n=o(function e(t){i(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||k.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||0===t.random?t.random:We(),this.priority=this._computePriority(t.priority),this.nick=t.nick||"",this.avatar=t.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=Rt(t.checkResult),this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||Zt,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=t.cloudCustomData||"",this.isDeleted=!1,this.isModified=!!t.messageVersion,this._isExcludedFromUnreadCount=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!t.messageControlInfo||1!==t.messageControlInfo.excludedFromLastMessage),this.clientTime=t.clientTime||ye()||0,this.senderTinyID=t.senderTinyID||t.tinyID||"",this.readReceiptInfo=t.readReceiptInfo||{readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},this.needReadReceipt=!0===t.needReadReceipt||1===t.needReadReceipt,this.version=t.messageVersion||0,this.isBroadcastMessage=t.isBroadcastMessage||!1,this._receiverList=t.receiverList||void 0,this.isSupportExtension=!0===t.isSupportExtension||1===t.isSupportExtension,this._cmConfigID=t.customModerationConfigurationID,this.revoker=t.revokerInfo&&t.revokerInfo.revoker||"",this.revokerInfo=t.revokerInfo||{userID:"",nick:"",avatar:""},this.revokeReason=t.revokeReason||"",this.pinnerInfo=t.pinnerInfo||null,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null),this.handleGroupAtInfo(t),this.initC2CReadReceiptInfo(t)},[{key:"elements",get:function(){return this._elements}},{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){null!==e&&(Xe(e.nick)&&(this.nick=e.nick),Xe(e.avatar)&&(this.avatar=e.avatar),xe(e=e.messageFromAccountExtraInformation))&&Xe(e.nameCard)&&(this.nameCard=e.nameCard)}},{key:"handleGroupAtInfo",value:function(e){var t=this;e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach(function(e){e!==k.MSG_AT_ALL?(t._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),t.atUserList.push(e)):(t._groupAtInfoList.push({groupAtAllFlag:1}),t.atUserList.push(k.MSG_AT_ALL))}),Ve(e.groupAtInfo)&&e.groupAtInfo.forEach(function(e){0===e.groupAtAllFlag?t.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&t.atUserList.push(k.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?Zt:Xt,!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&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===k.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initSequence",value:function(e){var t,n,s;0===this.clientSequence&&e&&(this.clientSequence=!!e&&(void 0===at[e]&&(s=new Date,t="3".concat(s.getHours()).slice(-2),n="0".concat(s.getMinutes()).slice(-2),s="0".concat(s.getSeconds()).slice(-2),at[e]=parseInt([t,n,s,"0001"].join("")),s=n=t=null,Ee.l("autoIncrementIndex start index:".concat(at[e]))),at[e]++)),0===this.sequence&&this.conversationType===k.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(){this.from===k.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=this.conversationType;n!==k.CONV_SYSTEM?(e=n===k.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID=e?"".concat(n).concat(e):null):this.conversationID=k.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Dn||e instanceof Pn||e instanceof wn||e instanceof bn||e instanceof qn||e instanceof Hn||e instanceof Fn||e instanceof Vn||e instanceof Kn||e instanceof jn||e instanceof Yn||e instanceof Wn}},{key:"setElement",value:function(e,t,n,s){var i=this;if(this.isElement(e))this._elements=[e];else{var a=function(e){if(e.type&&e.content)switch(e.type){case k.MSG_TEXT:i.setTextElement(e.content);break;case k.MSG_IMAGE:i.setImageElement(e.content,t,n,s);break;case k.MSG_AUDIO:i.setAudioElement(e.content,t,n,s);break;case k.MSG_FILE:i.setFileElement(e.content,t,n,s);break;case k.MSG_VIDEO:i.setVideoElement(e.content,t,n,s);break;case k.MSG_CUSTOM:i.setCustomElement(e.content);break;case k.MSG_LOCATION:i.setLocationElement(e.content);break;case k.MSG_GRP_TIP:i.setGroupTipElement(e.content);break;case k.MSG_GRP_SYS_NOTICE:i.setGroupSystemNoticeElement(e.content);break;case k.MSG_FACE:i.setFaceElement(e.content);break;case k.MSG_MERGER:i.setMergerElement(e.content,t,n,s);break;case k.MSG_STREAM:i.setStreamElement(e.content)}};if(Ve(e))for(var o=0;o<e.length;o++)a(e[o]);else a(e)}this._initProxy()}},{key:"clearElement",value:function(){this._elements.length=0}},{key:"setTextElement",value:function(e){e="string"==typeof e?e:e.text,e=new Dn({text:e}),this._elements.push(e)}},{key:"setImageElement",value:function(e,t,n,s){e=new Pn(e,t,n,s),this._elements.push(e)}},{key:"setAudioElement",value:function(e,t,n,s){e=new bn(e,t,n,s),this._elements.push(e)}},{key:"setFileElement",value:function(e,t,n,s){e=new qn(e,t,n,s),this._elements.push(e)}},{key:"setVideoElement",value:function(e,t,n,s){e=new Hn(e,t,n,s),this._elements.push(e)}},{key:"setLocationElement",value:function(e){e=new jn(e),this._elements.push(e)}},{key:"setCustomElement",value:function(e){e=new Kn(e),this._elements.push(e)}},{key:"setGroupTipElement",value:function(e){var t,n={},s=e.operationType;Ue(e.memberInfoList)?e.operatorInfo&&(n=e.operatorInfo):s!==k.GRP_TIP_MBR_JOIN&&s!==k.GRP_TIP_MBR_KICKED_OUT&&s!==k.GRP_TIP_MBR_SET_ADMIN&&s!==k.GRP_TIP_MBR_CANCELED_ADMIN||(n=e.memberInfoList[0]),Ue(e.memberExtraInfo)||(t=e.memberExtraInfo.reason,e.msgMemberInfo.forEach(function(e){e.reason=t})),s=n.nick,n=n.avatar,Xe(s)&&(this.nick=s),Xe(n)&&(this.avatar=n),s=new Fn(e),this._elements.push(s)}},{key:"setGroupSystemNoticeElement",value:function(e){e=new Vn(e),this._elements.push(e)}},{key:"setFaceElement",value:function(e){e=new wn(e),this._elements.push(e)}},{key:"setMergerElement",value:function(e,t,n,s){e=new Yn(e,t,n,s),this._elements.push(e)}},{key:"setStreamElement",value:function(e){e=new Wn(e),this._elements.push(e)}},{key:"setIsRead",value:function(e){this.isRead=e}},{key:"setRelayFlag",value:function(e){this._relayFlag=e}},{key:"_computePriority",value:function(e){if(!Ze(e)){if(Xe(e)&&-1!==Object.values(zn).indexOf(e))return e;if(Ge(e)&&(e=""+e,-1!==Object.keys(zn).indexOf(e)))return zn[e]}return k.MSG_PRIORITY_NORMAL}},{key:"setNickAndAvatar",value:function(e){var t=e.nick;e=e.avatar,Xe(t)&&(this.nick=t),Xe(e)&&(this.avatar=e)}},{key:"setNameCard",value:function(e){Xe(e)&&(this.nameCard=e)}},{key:"initC2CReadReceiptInfo",value:function(e){var t=e.readReceiptSentByPeer;e=void 0===(e=e.timestamp)?0:e,this.conversationType===k.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===(void 0===t?void 0:t),this.readReceiptInfo.timestamp=e)}}]),Jn=["sound","FCMChannelID"],Xn=["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"],Zn={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Qn={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function es(e,t){for(var n in t){var s,i;Object.prototype.hasOwnProperty.call(t,n)&&(s=(i=t[n]).range,i=i.defaultValue,e[n]=s.includes(e[n])?e[n]:i)}return e}function ts(e){if(xe(e))return{pushFlag:!0===e.disablePush?1:0,title:e.title||"",desc:e.description||"",ext:e.extension||"",apnsInfo:(n=(t=e).apnsInfo,s=void 0!==(s=t.ignoreIOSBadge)&&s,t=t.disableVoipPush,i=(n=es(void 0===n?{}:n,Qn)).ignoreIOSBadge,a=n.disableVoipPush,o=n.enableIOSBackgroundNotification,n=f(n,Xn),i=!0===i||!0===s?1:0,s=void 0,Ze(t)||(s=!1===t?1:0),Ze(a)||(s=!1===a?1:0),_(_({},n),{},{badgeMode:i,isVoipPush:s,contentAvailable:o?1:0})),androidInfo:(a=void 0===(a=(t=e).androidInfo)?{}:a,t=t.androidOPPOChannelID,t=a.OPPOChannelID||(void 0===t?"":t),a=es(a,Zn),n=void 0===(n=a.sound)?"":n,i=void 0===(i=a.FCMChannelID)?"":i,_(_({},f(a,Jn)),{},{Sound:-1===(n=(a=n).lastIndexOf("."))?a:a.slice(0,n),OPPOChannelID:t,GoogleChannelID:i}))};var t,n,s,i,a,o}l(as,sn);var ns=o(as,[{key:"onNewMessage",value:function(e){var t=e.dataList,n=e.isInstantMessage,s=e.C2CRemainingUnreadList,i=e.C2CPairUnreadList,a=(e=e.isSyncingEnded,s=(n||Ee.l("".concat(this._n,".onNewMessage C2CPairUnreadList:"),i,"C2CRemainingUnreadList:",s),t=this._assembly({dataList:t,C2CRemainingUnreadList:s,C2CPairUnreadList:i,isInstantMessage:n})).conversationOptionsList,i=t.messageList,t=t.isUnreadC2CMessage,Ue(a=i)?[]:a.filter(function(e){return!0===e.isModified}));0<a.length&&this.emitOEvt(E.MESSAGE_MODIFIED,a),this.get(11).onNewMessage({conversationOptionsList:s,isInstantMessage:n,isUnreadC2CMessage:t,isSyncingEnded:e}),s=Ue(a=i)?[]:a.filter(function(e){return!1===e.isModified}),n&&0<s.length&&this.emitOEvt(E.MESSAGE_RECEIVED,s),i.length=0}},{key:"_assembly",value:function(e){for(var t=e.dataList,n=e.C2CRemainingUnreadList,s=e.C2CPairUnreadList,i=e.isInstantMessage,a=null,o=[],r=[],c={},u=this.get(26),l=!1,d=this.get(11),h=this.get(4),g=(e=this.get(17),this.getFileDownloadProxy()),p=this.getDownloadFileAuthKey(),_=e.getFileDNList(),f=0,m=t.length;f<m;f++)if(this._isC2CNotice(t[f]))this._noticeFromUnreadDBList.push(t[f].eventArray[0].c2CNotifyMsgArray[0]);else{var v=t[f],y=(v.currentUser=this.getMyUserID(),v.conversationType=k.CONV_C2C,v.isSystemMessage=!!v.isSystemMessage,(Ze(v.nick)||Ze(v.avatar))&&(l=!0),(a=new $n(v)).setElement(v.elements,g,p,_),a.setNickAndAvatar({nick:v.nick,avatar:v.avatar}),a.conversationID);if(i){if(this._msgFromUnreadDBMap.get(a.ID))continue;var I,M,C=!1,T=(a.from!==this.getMyUserID()?(M=d.getLatestMessageSentByPeer(y))&&(I=M.nick,M=M.avatar,l?a.setNickAndAvatar({nick:I,avatar:M}):I===a.nick&&M===a.avatar||(C=!0)):(I=d.getLatestMessageSentByMe(y))&&(M=I.nick,T=I.avatar,M===a.nick&&T===a.avatar||(d.modifyMessageSentByMe({conversationID:y,latestNick:a.nick,latestAvatar:a.avatar}),h.mockOnNickAvatarModified(a.nick,a.avatar))),1===t[f].isModified);if(d.isMessageSentByCurrentInstance(a)?a.isModified=T:T=!1,0===v.msgLifeTime)a._onlineOnlyFlag=!0,d.isMessageSentByCurrentInstance(a)||r.push(a);else{if(!d.pushIntoMessageList(r,a,T))continue;C&&(d.modifyMessageSentByPeer({conversationID:y,latestNick:a.nick,latestAvatar:a.avatar}),d.updateUserProfileSpecifiedKey({conversationID:y,nick:a.nick,avatar:a.avatar}))}i&&0<a.clientTime&&u.addMessageDelay(a.clientTime)}else this._msgFromUnreadDBMap.set(a.ID,a);if(0!==v.msgLifeTime){if(!1===a._onlineOnlyFlag){if(Ge(C=d.getLastMessageTime(y))&&a.time<C)continue;i&&(Ze(c[y])?(v=0,"in"!==a.flow||a._isExcludedFromUnreadCount||(v=1),c[y]=o.push({conversationID:y,unreadCount:v,type:a.conversationType,subType:a.conversationSubType,lastMessage:a._isExcludedFromLastMessage?"":a})-1):(v=c[y],o[v].type=a.conversationType,o[v].subType=a.conversationSubType,o[v].lastMessage=a._isExcludedFromLastMessage?"":a,"in"!==a.flow||a._isExcludedFromUnreadCount||o[v].unreadCount++))}}else a._onlineOnlyFlag=!0}this._handleNoticeFromUnreadDB();var S=!1;if(Ve(s)&&0<s.length)for(var E=0,D=s.length;E<D;E++)(e=>{if(s[e].from!==k.CONV_SYSTEM){S=!0;var t=o.find(function(t){return t.conversationID==="".concat(k.CONV_C2C).concat(s[e].from)});t?t.unreadCount=s[e].unreadCount:o.push({conversationID:"".concat(k.CONV_C2C).concat(s[e].from),unreadCount:s[e].unreadCount,type:k.CONV_C2C})}})(E);if(Ve(n))for(var O=0,R=n.length;O<R;O++)(e=>{o.find(function(t){return t.conversationID==="".concat(k.CONV_C2C).concat(n[e].from)})||o.push({conversationID:"".concat(k.CONV_C2C).concat(n[e].from),type:k.CONV_C2C,lastMsgTime:n[e].lastMsgTime})})(O);return{conversationOptionsList:o,messageList:r,isUnreadC2CMessage:S}}},{key:"getMessageListFromUnreadDB",value:function(){return y(this._msgFromUnreadDBMap.values())}},{key:"_isC2CNotice",value:function(e){return!(!Ve(e=e.eventArray)||10!==e[0].event)}},{key:"_handleNoticeFromUnreadDB",value:function(){var e,t=this._noticeFromUnreadDBList.length;0!==t&&(Ee.l("".concat(this._n,"._handleNoticeFromUnreadDB count:").concat(t)),e=[],this._noticeFromUnreadDBList.forEach(function(t){t.hasOwnProperty("c2cMessageRevokedNotify")&&e.push(t)}),this.onMsgRevoked({dataList:e}),this._noticeFromUnreadDBList.length=0,e.length=0)}},{key:"onMsgRevoked",value:function(e,t){var n,s=this,i=this.get(11),a=[];e.dataList.forEach(function(e){e.c2cMessageRevokedNotify&&(e=e.c2cMessageRevokedNotify.revokedInfos,Ze(e)||e.forEach(function(e){var t=s.getMyUserID()===e.from?"".concat(k.CONV_C2C).concat(e.to):"".concat(k.CONV_C2C).concat(e.from);n=i.revoke(t,e.sequence,e.random);var o,r=e.revokerInfo&&e.revokerInfo.revoker,c=e.revokerInfo&&e.revokerInfo.reason||"";n?o=n:(o={conversationID:t,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(o.ID="".concat(e.tinyID,"-").concat(e.clientTime,"-").concat(e.random)),e.time&&(o.time=e.time)),o&&(o.revoker=r,o.revokeReason=c,o.revokerInfo={userID:r,nick:"",avatar:""},a.push(o))}))}),0!==a.length&&(Ee.l("".concat(this._n,".onMsgRevoked count:").concat(a.length," updateUnreadCount:").concat(t)),i.onMessageRevoked(a,t),i.updateRevokerInfo(a).then(function(e){s.emitOEvt(E.MESSAGE_REVOKED,e)}))}},{key:"onMsgReadReceipt",value:function(e){var t=this;e.dataList.forEach(function(e){var n;Ue(e.c2cMessageReadReceipt)||(n=e.c2cMessageReadReceipt.to,e.c2cMessageReadReceipt.uinPairReadArray.forEach(function(e){e=e.peerReadTime;var s=(Ee.l("".concat(t._n,".onMsgReadReceipt to:").concat(n," peerReadTime:").concat(e)),"".concat(k.CONV_C2C).concat(n)),i=t.get(11);i.recordPeerReadTime(s,e),i.updateMsgIsPeerReadProp(s,e)}))})}},{key:"onMsgReadNotice",value:function(e){var t=this;e.dataList.forEach(function(e){var n;Ue(e.c2cMessageReadNotice)||(n=t.get(11),e.c2cMessageReadNotice.uinPairReadArray.forEach(function(e){var s=e.from;e=e.peerReadTime,Ee.l("".concat(t._n,".onMsgReadNotice from:").concat(s," lastReadTime:").concat(e)),s="".concat(k.CONV_C2C).concat(s),n.updateIsReadAfterReadReport({conversationID:s,lastMessageTime:e}),n.updateUnreadCount(s)}))})}},{key:"onMsgModified",value:function(e){Ee.l("".concat(this._n,".onMsgModified options:"),e);var t=this.get(11);e.dataList.forEach(function(e){t.onMessageModified(_(_({},e),{},{conversationType:k.CONV_C2C}))})}},{key:"onReadReceiptList",value:function(e){Ee.l("".concat(this._n,".onReadReceiptList options:"),e),this.get(11).updateReadReceiptInfo(e.dataList)}},{key:"sendMessage",value:function(e,t){return e=this._createC2CMessagePack(e,t),this.req(e)}},{key:"_createC2CMessagePack",value:function(e,t){var n=null,s=(t&&(t.offlinePushInfo&&(n=t.offlinePushInfo),!0===t.onlineUserOnly)&&(n?n.disablePush=!0:n={disablePush:!0}),""),i=(Xe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(s=e.cloudCustomData),[]),a=(xe(t)&&xe(t.messageControlInfo)&&(a=(r=t.messageControlInfo).excludedFromUnreadCount,o=r.excludedFromLastMessage,r=r.excludedFromContentModeration,!0===a&&i.push("NoUnread"),!0===o&&i.push("NoLastMsg"),!0===r)&&i.push("NoMsgCheck"),this.isOnlineMessage(e,t)?0:void 0),o=JSON.parse(JSON.stringify(e.getElements())),r=this.get(17).getFileDNList();return{P:dn.SEND_C2C_MSG,data:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:Nn(e.type,o,r),cloudCustomData:s,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:a,nick:e.nick,avatar:e.avatar,offlinePushInfo:ts(n),messageControlInfo:0!==a?i:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0,cmConfigID:e._cmConfigID,forbidCallbackControl:(e=>{if(xe(e)&&xe(e.webhookInfo)){var t=[];if(e.webhookInfo.disableCloudMessagePreHook&&t.push("ForbidBeforeSendMsgCallback"),e.webhookInfo.disableCloudMessagePostHook&&t.push("ForbidAfterSendMsgCallback"),0!==t.length)return t}})(t)}}}},{key:"isOnlineMessage",value:function(e,t){return!(!t||!0!==t.onlineUserOnly)}},{key:"revokeMessage",value:function(e){return this.req({P:dn.REVOKE_C2C_MSG,data:{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;return e=e.keyList,Ee.l("".concat(this._n,".deleteMessage toAccount:").concat(t," count:").concat(e.length)),this.req({P:dn.DEL_C2C_MSG,data:{fromAccount:this.getMyUserID(),to:t,keyList:e}})}},{key:"modifyRemoteMessage",value:function(e){var t=e.from,n=e.to,s=void 0===(s=e.version)?0:s,i=e.sequence,a=e.random,o=e.time,r=e.type,c=e.cloudCustomData,u=e._elements,l=void 0;return r!==k.MSG_TEXT&&r!==k.MSG_CUSTOM&&r!==k.MSG_LOCATION&&r!==k.MSG_FACE||(1<u.length&&u.splice(0,1,{type:r,content:e.payload}),l=u),this.req({P:dn.MODIFY_C2C_MSG,data:{from:t,to:n,version:s,sequence:i,random:a,time:o,elements:l,cloudCustomData:c}})}},{key:"setMessageRead",value:function(e){var t=this,n=e.conversationID,s=e.lastMessageTime,i="".concat(this._n,".").concat("setMessageRead"),a=(e="convID:".concat(n," lastMessageTime:").concat(s),Ee.l("".concat(i," ").concat(e)),Ge(s)||this.warn("DoNotModifyLastTime"),new kn("setMessageRead"));return a.setMessage(e),this.req({P:dn.SET_C2C_MSG_READ,data:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:n.replace("C2C",""),lastMessageTime:s,receipt:1}]}}}).then(function(){a.end(),Ee.l("".concat(i," ok"));var e=t.get(11);return e.updateIsReadAfterReadReport({conversationID:n,lastMessageTime:s}),e.updateUnreadCount(n),zt()}).catch(function(e){return a.setError(e).end(),Ee.l("".concat(i," failed. error:"),e),Jt(e)})}},{key:"getRoamingMessage",value:function(e){var t=this,n="".concat(this._n,".").concat("getRoamingMessage"),s=e.peerAccount,i=e.conversationID,a=e.count,o=e.lastMessageTime,r=(e=e.messageKey,"peerAccount:".concat(s," count:").concat(a||15," lastMessageTime:").concat(o||0," messageKey:").concat(e)),c=(Ee.l("".concat(n," ").concat(r)),new kn("getRoamingMessage"));return this.req({P:dn.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:a||15,lastMessageTime:o||0,messageKey:e}}).then(function(e){var s=(e=e.data).complete,a=e.messageList,o=e.messageKey,u=(e=e.lastMessageTime,Ze(a)?Ee.l("".concat(n," ok. complete:").concat(s," but messageList is undefined!")):Ee.l("".concat(n," ok. complete:").concat(s," count:").concat(a.length)),c.setMessage("".concat(r," complete:").concat(s," length:").concat(a.length)).end(),t.get(11)),l=1===s,d=(l&&u.setCompleted(i),[]),h=u.onRoamingMessage(a,i,!0,d),g=(u.modifyMessageList(i),u.updateIsRead(i),u.updateRoamingMsgKeyAndTime(i,o,e),"");return 0<h.length?g=h[0].ID:(s=u.getLocalOldestMessage(i))&&(g=s.ID),a=u.getPeerReadTime(i),Ee.l("".concat(n," update isPeerRead property. convID:").concat(i," peerReadTime:").concat(a)),a?(u.updateMsgIsPeerReadProp(i,a),Ee.l("".concat(n," nextReqID:").concat(g," storedMsgCount:").concat(h.length)),{nextReqID:g,storedMessageList:h,assembledMessageList:d,isPullingCompleted:l}):(o=i.replace(k.CONV_C2C,""),t.getRemotePeerReadTime([o]).then(function(){return u.updateMsgIsPeerReadProp(i,u.getPeerReadTime(i)),Ee.l("".concat(n," nextReqID:").concat(g," storedMsgCount:").concat(h.length)),{nextReqID:g,storedMessageList:h,assembledMessageList:d,isPullingCompleted:l}}))}).catch(function(e){return c.setMessage(r).setError(e).end(),Ee.w("".concat(n," failed. error:"),e),Jt(e)})}},{key:"getRoamingMessagesHopping",value:function(e){var t=this,n="".concat(this._n,".").concat("getRoamingMessagesHopping"),s=e.peerAccount,i=void 0===(i=e.time)?0:i,a=e.count,o=e.direction,r="".concat(k.CONV_C2C).concat(s),c="peerAccount:".concat(s," count:").concat(a," time:").concat(i," direction:").concat(o),u=(Ee.l("".concat(n," ").concat(c)),new kn("getRoamingMessagesHopping"));return this.req({P:dn.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:a+1,lastMessageTime:i,direction:o}}).then(function(e){var s=(e=e.data).complete,i=void 0===(i=e.messageList)?[]:i,a=(e=e.lastMessageTime,"complete:".concat(s," count:").concat(i.length)),l=(Ee.l("".concat(n," ok. ").concat(a)),u.setMessage("".concat(c," ").concat(a)).end(),1!==s&&(1===o?i.pop():i.shift()),t.get(11));return a=l.onRoamingMessage(i,r,!1),t._modifyMessageList(r,a),i=t._computeResult({complete:s,lastMessageTime:e,resultList:a}),l.storeHoppingMessageList(i.messageList),s=l.getPeerReadTime(r),Ee.l("".concat(n," update isPeerRead property. convID:").concat(r," peerReadTime:").concat(s)),s?l.updateMsgIsPeerReadProp(r,s):(e=r.replace(k.CONV_C2C,""),t.getRemotePeerReadTime([e]).then(function(){l.updateMsgIsPeerReadProp(r,l.getPeerReadTime(r))})),zt(i)}).catch(function(e){return u.setMessage(c).setError(e).end(),Ee.w("".concat(n," failed. error:"),e),Jt(e)})}},{key:"_computeResult",value:function(e){var t=void 0===(t=e.complete)?0:t,n=e.lastMessageTime;return e={messageList:y(void 0===(e=e.resultList)?[]:e),isCompleted:!1,nextMessageTime:""},1===t?e.isCompleted=!0:e.nextMessageTime=n,e}},{key:"_modifyMessageList",value:function(e,t){if(e=this.get(11).getLocalConversation(e))for(var n=e.userProfile.nick,s=e.userProfile.avatar,i=(e=this.get(4).getNickAndAvatarByUserID(this.getMyUserID())).nick,a=e.avatar,o=t.length-1;0<=o;o--){var r=t[o];"in"===r.flow&&(r.nick!==n&&r.setNickAndAvatar({nick:n}),r.avatar!==s)&&r.setNickAndAvatar({avatar:s}),"out"===r.flow&&(r.nick!==i&&r.setNickAndAvatar({nick:i}),r.avatar!==a)&&r.setNickAndAvatar({avatar:a})}}},{key:"getRemotePeerReadTime",value:function(e){var t,n=this,s="".concat(this._n,".").concat("getRemotePeerReadTime");return Ue(e)?Promise.resolve():(t=new kn("getRemotePeerReadTime"),Ee.l("".concat(s," userIDList:").concat(e)),this.req({P:dn.GET_C2C_PEER_READ_TIME,data:{userIDList:e}}).then(function(i){var a=i.data.peerReadTimeList;Ee.l("".concat(s," ok. peerReadTimeList:").concat(a));for(var o="",r=n.get(11),c=0;c<e.length;c++)o+="".concat(e[c],"-").concat(a[c]," "),0<a[c]&&r.recordPeerReadTime("".concat(k.CONV_C2C).concat(e[c]),a[c]);t.setMessage(o).end()}).catch(function(e){t.setError(e).end(),Ee.w("".concat(s," failed. error:"),e)}))}},{key:"sendReadReceipt",value:function(e){var t,n=e[0].conversationID.replace(k.CONV_C2C,""),s=new kn("sendReadReceipt"),i=(s.setMessage("peerAccount:".concat(n)),this.getMyUserID());return 0===(e=e.filter(function(e){return e.from!==i&&!0===e.needReadReceipt}).map(function(e){return{fromAccount:e.from,toAccount:e.to,sequence:e.sequence,random:e.random,time:e.time,clientTime:e.clientTime}})).length?Jt({code:un.READ_RECEIPT_MSG_LIST_EMPTY}):(t="".concat(this._n,".").concat("sendReadReceipt"),Ee.l("".concat(t,". peerAccount:").concat(n," length:").concat(e.length)),this.req({P:dn.SEND_C2C_READ_RECEIPT,data:{peerAccount:n,messageInfoList:e}}).then(function(e){return s.end(),Ee.l("".concat(t," ok")),zt()}).catch(function(e){return s.setError(e).end(),Ee.w("".concat(t," failed. error:"),e),Jt(e)}))}},{key:"getReadReceiptList",value:function(e){var t=e[0].conversationID.replace(k.CONV_C2C,"");return Ee.l("".concat(this._n,".getReadReceiptList peerAccount:").concat(t," msgCount:").concat(e.length)),$t({messageList:e})}},{key:"getMessageExtensions",value:function(e,t){return Ee.l("".concat(this._n,".getMessageExtensions startSequence:").concat(t)),this.req({P:dn.GET_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}},{key:"modifyMsgExts",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1;return Ee.l("".concat(this._n,".modifyMsgExts operateType:").concat(n)),this.req({P:dn.MODIFY_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),extensionList:t,operateType:n}})}},{key:"getMessageKey",value:function(e){var t=e.clientSequence,n=e.random;return e=e.time,"".concat(t,"_").concat(n,"_").concat(e)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._msgFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0}}]),ss={A2KEY_AND_TINYID_UPDATED:"_inner".concat(1),CLOUD_CONFIG:"_inner".concat(2),PROFILE_UPDATED:"_inner".concat(3),CONV_SYNC_COMPLETED:"_inner".concat(4),C2C_UNREAD_HANDLE_COMPLETED:"_inner".concat(5)},is=o(function e(t){i(this,e),this._convM=t,this._map=new Map,this._n="MsgListHandler",this._latestMsgSentByPeerMap=new Map,this._latestMsgSentByMeMap=new Map,this._hoppingMsgMap=new Map,this.TOPIC_MSG_LIMIT=1e3,this._convM.getIEmitInst().on(ss.CLOUD_CONFIG,this._onCloudConfig,this)},[{key:"_onCloudConfig",value:function(){var e=this._convM.getCloudConfig("topic_msg_limit");Ze(e)||(this.TOPIC_MSG_LIMIT=Number(e)),Ee.l("".concat(this._n,"._onCloudConfig topicMsgLimit:").concat(this.TOPIC_MSG_LIMIT))}},{key:"onCheckTimer",value:function(e){if(e%20==0&&0<this._map.size){var t,n=r(this._map);try{for(n.s();!(t=n.n()).done;){var s=v(t.value,2),i=s[0],a=s[1];i.includes(Ne)&&a.size>=this.TOPIC_MSG_LIMIT&&this._convM.clearMemMsg(i,!0)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"pushIn",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=e.conversationID,s=!0,i=(this._map.has(n)||this._map.set(n,new Map),this._getUniqueIDOfMsg(e));if(this._map.get(n).has(i)){var a=this._map.get(n).get(i);if(!t||!0===a.isModified)return!1}return this._map.get(n).set(i,e),this._setLatestMsgSentByPeer(n,e),this._setLatestMsgSentByMe(n,e),s}},{key:"unshift",value:function(e,t){var n;if(Ve(e)?0<e.length&&(n=e[0].conversationID,this._unshiftMultipleMsgs(e,t)):(n=e.conversationID,this._unshiftSingleMsg(e,t)),n){var s=Array.from(this._map.get(n).values());if(0!==(e=s.length)){for(var i=e-1;0<=i;i--)if("out"===s[i].flow){this._setLatestMsgSentByMe(n,s[i]);break}if(n.startsWith(k.CONV_C2C))for(var a=e-1;0<=a;a--)if("in"===s[a].flow){this._setLatestMsgSentByPeer(n,s[a]);break}}}}},{key:"_unshiftSingleMsg",value:function(e,t){var n,s,i=e.conversationID,a=this._getUniqueIDOfMsg(e);this._map.has(i)?(n=this._map.get(i),s=Array.from(n),n.has(a)||(s.unshift([a,e]),this._map.set(i,new Map(s)),t.push(e))):(this._map.set(i,new Map),this._map.get(i).set(a,e),t.push(e))}},{key:"_unshiftMultipleMsgs",value:function(e,t){for(var n=e.length,s=[],i=e[0].conversationID,a=this._map.get(i),o=this._map.has(i)?Array.from(a):[],r=0;r<n;r++){var c=this._getUniqueIDOfMsg(e[r]);a&&a.has(c)||(s.push([c,e[r]]),t.push(e[r]))}this._map.set(i,new Map(s.concat(o)))}},{key:"remove",value:function(e){var t=e.conversationID;e=this._getUniqueIDOfMsg(e),this._map.has(t)&&this._map.get(t).delete(e)}},{key:"revoke",value:function(e,t,n){var s;return this._map.has(e)?(s=this._map.get(e),this._updateMsgIsRevoked(s,t,n)):this._hoppingMsgMap.has(e)?(s=this._hoppingMsgMap.get(e),this._updateMsgIsRevoked(s,t,n)):null}},{key:"_updateMsgIsRevoked",value:function(e,t,n){var s,i=r(e);try{for(i.s();!(s=i.n()).done;){var a=v(s.value,2)[1];if(a.sequence===t&&(Ze(n)||a.random===n))return a.isRevoked||(a.isRevoked=!0),a}}catch(e){i.e(e)}finally{i.f()}}},{key:"removeByConvID",value:function(e){var t=this._map.has(e);Ee.l("".concat(this._n,".removeByConvID convID:").concat(e," has:").concat(t)),t&&(this._map.delete(e),this._latestMsgSentByPeerMap.delete(e),this._latestMsgSentByMeMap.delete(e))}},{key:"findMessage",value:function(e){return this._findMsg(e,this._map)||this._findMsg(e,this._hoppingMsgMap)}},{key:"_findMsg",value:function(e,t){var n,s=null,i=r(t);try{for(i.s();!(n=i.n()).done;)for(var a=y(v(n.value,2)[1].values()),o=a.length,c=0;c<o;c++)if(a[c].ID===e){s=a[c];break}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"updateMsgIsPeerReadProp",value:function(e,t){var n,s=[];return this._map.has(e)?(n=this._map.get(e),s=this._updateMsgIsPeerReadProp(n,t)):this._hoppingMsgMap.has(e)&&(n=this._hoppingMsgMap.get(e),s=this._updateMsgIsPeerReadProp(n,t)),Ee.l("".concat(this._n,".updateMsgIsPeerReadProp convID:").concat(e," peerReadTime:").concat(t," count:").concat(s.length)),s}},{key:"_updateMsgIsPeerReadProp",value:function(e,t){var n,s=[],i=r(e);try{for(i.s();!(n=i.n()).done;){var a=v(n.value,2)[1];a.time<=t&&!a.isPeerRead&&"out"===a.flow&&(a.isPeerRead=!0,s.push(a))}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"updateMsgIsModifiedProp",value:function(e){var t=e.conversationID;this._map.has(t)&&(e=this._getUniqueIDOfMsg(e),t=this._map.get(t).get(e))&&(t.isModified=!0)}},{key:"hasLocalMsgList",value:function(e){return this._map.has(e)}},{key:"getLocalMsgList",value:function(e){return this.hasLocalMsgList(e)?y(this._map.get(e).values()):[]}},{key:"getLocalMaxSeq",value:function(e){return this.hasLocalMsgList(e)?(e=y(this._map.get(e).values()).map(function(e){return e.sequence}),Math.max.apply(Math,y(e))):0}},{key:"getLocalMaxTime",value:function(e){return this.hasLocalMsgList(e)?(e=y(this._map.get(e).values()).map(function(e){return e.time}),Math.max.apply(Math,y(e))):0}},{key:"hasLocalMsg",value:function(e,t){for(var n=!1,s=this.getLocalMsgList(e),i=s.length,a=0;a<i;a++)s[a].ID===t&&(n=!0);return n}},{key:"getLocalMsg",value:function(e,t){for(var n=null,s=this.getLocalMsgList(e),i=s.length,a=0;a<i;a++)if(s[a].ID===t){n=s[a];break}return n}},{key:"getLocalLastMsg",value:function(e){for(var t=this.getLocalMsgList(e),n=void 0,s=t.length-1;0<=s;s--)if(t[s].status===Zt){n=t[s];break}return n}},{key:"getLocalSecondLastMsg",value:function(e){return(e=this.getLocalMsgList(e))[e.length-2]}},{key:"getLocalOldestMsg",value:function(e){return this.getLocalMsgList(e)[0]}},{key:"_setLatestMsgSentByPeer",value:function(e,t){e.startsWith(k.CONV_C2C)&&"in"===t.flow&&this._latestMsgSentByPeerMap.set(e,t)}},{key:"_setLatestMsgSentByMe",value:function(e,t){"out"===t.flow&&this._latestMsgSentByMeMap.set(e,t)}},{key:"getLatestMsgSentByPeer",value:function(e){return this._latestMsgSentByPeerMap.get(e)}},{key:"getLatestMsgSentByMe",value:function(e){return this._latestMsgSentByMeMap.get(e)}},{key:"modifyMsgSentByPeer",value:function(e){var t=e.conversationID,n=e.latestNick,s=e.latestAvatar;if(!Ue(e=this._map.get(t))){var i=Array.from(e.values());if(0!==(e=i.length)){for(var a=null,o=0,r=!1,c=e-1;0<=c;c--)"in"===i[c].flow&&((a=i[c]).nick!==n&&(a.setNickAndAvatar({nick:n}),r=!0),a.avatar!==s&&(a.setNickAndAvatar({avatar:s}),r=!0),r)&&(o+=1);Ee.l("".concat(this._n,".modifyMsgSentByPeer convID:").concat(t," count:").concat(o))}}}},{key:"modifyMsgSentByMe",value:function(e){var t=e.conversationID,n=e.latestNick,s=e.latestAvatar;if(!Ue(e=this._map.get(t))){var i=Array.from(e.values());if(0!==(e=i.length)){for(var a=null,o=0,r=!1,c=e-1;0<=c;c--)"out"===i[c].flow&&((a=i[c]).nick!==n&&(a.setNickAndAvatar({nick:n}),r=!0),a.avatar!==s&&(a.setNickAndAvatar({avatar:s}),r=!0),r)&&(o+=1);Ee.l("".concat(this._n,".modifyMsgSentByMe convID:").concat(t," count:").concat(o))}}}},{key:"getTopicConvIDList",value:function(e){return y(this._map.keys()).filter(function(t){return t.startsWith("".concat(k.CONV_GROUP).concat(e))})}},{key:"onMsgModified",value:function(e,t){var n,s,i,a;return(this._map.has(e)||this._hoppingMsgMap.has(e))&&(n="".concat(this._n,".onMsgModified"),i=this._getUniqueIDOfMsg(t),a=!!(s=this._getTargetMsg(e,i)),Ee.l("".concat(n," convID:").concat(e," uniqueID:").concat(i," has:").concat(a)),a)?(e=t.messageVersion,i=t.elements,a=t.cloudCustomData,t=t.checkResult,Ee.l("".concat(n," localVersion:").concat(s.version," remoteVersion:").concat(e)),s.version<e?(s.version=e,s._elements=JSON.parse(JSON.stringify(i)),s.payload=s._elements[0].content,s.type=s._elements[0].type,s.cloudCustomData=a,s.isModified=!0,s.hasRiskContent=Rt(t),{isUpdated:!0,message:s}):{isUpdated:!1,message:s}):{isUpdated:!1,message:null}}},{key:"_getUniqueIDOfMsg",value:function(e){var t=e.from,n=e.to,s=e.random,i=e.sequence;return e=e.time,"".concat(t,"-").concat(n,"-").concat(s,"-").concat(i,"-").concat(e)}},{key:"_getTargetMsg",value:function(e,t){if(this._map.has(e))return this._map.get(e).get(t);var n=void 0;if(this._hoppingMsgMap.has(e))for(var s=y(this._hoppingMsgMap.get(e).values()),i=0;i<s.length;i++)if(this._getUniqueIDOfMsg(s[i])===t){n=s[i];break}return n}},{key:"storeHoppingMsgList",value:function(e){if(0!==e.length){var t=e[0].conversationID,n=e.length;this._hoppingMsgMap.has(t)||this._hoppingMsgMap.set(t,new Map);for(var s=this._hoppingMsgMap.get(t),i=0;i<n;i++){var a=e[i];s.has(a.ID)||s.set(a.ID,a)}}}},{key:"getHoppingMsg",value:function(e,t){if(this._hoppingMsgMap.has(e))return this._hoppingMsgMap.get(e).get(t)}},{key:"findMsgBySeq",value:function(e,t){var n=[];return this._map.has(e)&&n.push.apply(n,y(this._map.get(e).values())),this._hoppingMsgMap.has(e)&&n.push.apply(n,y(this._hoppingMsgMap.get(e).values())),n.find(function(e){return e.sequence===t})}},{key:"reset",value:function(){this._map.clear(),this._latestMsgSentByPeerMap.clear(),this._latestMsgSentByMeMap.clear(),this._hoppingMsgMap.clear()}}]);function as(e){return i(this,as),(e=n(this,as,[e]))._n="C2CModule",e._msgFromUnreadDBMap=new Map,e._noticeFromUnreadDBList=[],e}function os(e){this.mixin(e)}function rs(e,t,n){return Ze(e)?{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:n&&e.ID||e instanceof $n?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Et(e.type,e.payload,t),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1,revoker:e.revoker||null}:_(_({},e),{},{messageForShow:Et(e.type,e.payload,t)})}function cs(e){var t=String(e).replace(/[=]+$/,""),n="";if(t.length%4==1)return"";for(var s,i,a=0,o=0;i=t.charAt(o++);~i&&(s=a%4?64*s+i:i,a++%4)&&(n+=String.fromCharCode(255&s>>(-2*a&6))))i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);try{return decodeURIComponent(escape(n))}catch(e){return""}}os.mixin=function(e){(e=e.prototype||e)._isReady=!1,e.ready=function(e){if(e)return this._isReady?void(1<arguments.length&&void 0!==arguments[1]&&arguments[1]?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},e.triggerReady=function(){var e=this;this._isReady=!0,setTimeout(function(){var t=e._readyQueue;e._readyQueue=[],t&&0<t.length&&t.forEach(function(e){e.call(this)},e)},1)},e.resetReady=function(){this._isReady=!1,this._readyQueue=[]},e.isReady=function(){return this._isReady}};var us=["jpg","jpeg","gif","png","bmp","image","webp"],ls=["mp4","quicktime","mov","video"],ds=o(function e(t){var n=this;i(this,e),Ue(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||k.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||k.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Ue(t.profileCustomField))||t.profileCustomField.forEach(function(e){n.profileCustomField.push({key:e.key,value:e.value})})},[{key:"validate",value:function(e){var t,n=!0,s="";if(Ue(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var i=e.profileCustomField.length,a=null,o=0;o<i;o++){if(a=e.profileCustomField[o],!Xe(a.key)||-1===a.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!Xe(a.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}for(t in e)if(Object.prototype.hasOwnProperty.call(e,t)){if("profileCustomField"===t)continue;if(Ue(e[t])&&!Xe(e[t])&&!Ge(e[t])){s="key:"+t+", invalid value:"+e[t],n=!1;continue}switch(t){case"nick":Xe(e[t])||(n=!(s="nick must be a string")),500<Ye(e[t])&&(s="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(Ye(e[t])," bytes"),n=!1);break;case"gender":ze(Oe,e.gender)||(s="key:gender, invalid value:"+e.gender,n=!1);break;case"birthday":Ge(e.birthday)||(n=!(s="birthday must be a number"));break;case"location":Xe(e.location)||(n=!(s="location must be a string"));break;case"selfSignature":Xe(e.selfSignature)||(n=!(s="selfSignature must be a string"));break;case"allowType":ze(Ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,n=!1);break;case"language":Ge(e.language)||(n=!(s="language must be a number"));break;case"avatar":Xe(e.avatar)||(n=!(s="avatar must be a string"));break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(n=!(s="messageSettings must be 0 or 1"));break;case"adminForbidType":ze(Re,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,n=!1);break;case"level":Ge(e.level)||(n=!(s="level must be a number"));break;case"role":Ge(e.role)||(n=!(s="role must be a number"));break;default:s="unknown key:"+t+" "+e[t],n=!1}}return{valid:n,tips:s}}}]),hs=o(function e(t){i(this,e),this.MAX_LENGTH=t,this.map=new Map},[{key:"set",value:function(e){var t;this.map.size>=this.MAX_LENGTH&&(t=this.map.entries().next().value[0],this.map.delete(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:"reset",value:function(){this.map.clear()}}]),gs=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"],ps=o(function e(t){i(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.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(t)},[{key:"memberNum",get:function(){return this.memberCount},set:function(e){}},{key:"maxMemberNum",get:function(){return this.maxMemberCount},set:function(e){}},{key:"_initGroup",value:function(e){for(var t in e)gs.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}},{key:"updateGroup",value:function(e){var t=this;(e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0),e=JSON.parse(JSON.stringify(e))).lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),Ze(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField&&ot(this.groupCustomField,e.groupCustomField),Ze(e.memberNum)||(this.memberCount=e.memberNum),Ze(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),Ze(e.isSupportTopic)||(this.isSupportTopic=Ge(e.isSupportTopic)?1===e.isSupportTopic:e.isSupportTopic),je(this,e,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),Ve(e.members)&&0<e.members.length&&e.members.forEach(function(e){e.userID===t.selfInfo.userID&&je(t.selfInfo,e,["sequence"])})}},{key:"updateSelfInfo",value:function(e){e={nameCard:e.nameCard,joinTime:e.joinTime,role:e.role,messageRemindType:e.messageRemindType,readedSequence:e.readedSequence,excludedUnreadSequenceList:e.excludedUnreadSequenceList},je(this.selfInfo,_({},e),[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),_s=o(function e(t,n){var s=2<arguments.length&&void 0!==arguments[2]&&arguments[2];i(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=rs(t.lastMessage,n,s),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this.groupAtInfoList=[],this.remark=t.remark||"",this.isPinned=t.isPinned||!1,this.messageRemindType=t.messageRemindType,this.markList=t.markList||[],this.customData=t.customData||"",this.conversationGroupList=t.conversationGroupList||[],this.draftText=t.draftText||"",this._initProfile(t),this.subType=this.groupProfile?this.groupProfile.type:""},[{key:"toAccount",get:function(){return this.conversationID.startsWith(k.CONV_C2C)?this.conversationID.replace(k.CONV_C2C,""):this.conversationID.startsWith(k.CONV_GROUP)?this.conversationID.replace(k.CONV_GROUP,""):""}},{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}}),Ze(this.userProfile)&&this.type===k.CONV_C2C?this.userProfile=new ds({userID:e.conversationID.replace("C2C","")}):Ze(this.groupProfile)&&this.type===k.CONV_GROUP&&(this.groupProfile=new ps({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e){var t=e.nextUnreadCount,n=e.isFromGetConversations;e=e.isUnreadC2CMessage,Ze(t)||(rt(this.subType)?this.unreadCount=0:n&&this.type===k.CONV_GROUP||n&&this.type===k.CONV_TOPIC||e&&this.type===k.CONV_C2C?this.unreadCount=t:this.unreadCount=this.unreadCount+t)}},{key:"updateLastMessage",value:function(e){this.lastMessage=rs(e)}},{key:"updateGroupAtInfoList",value:function(n){var s;this._isNeedMergeGroupAtInfo(n)||(-1!==(s=e(t(s=n.groupAtType)||h(s)||C(s)||g()).slice(0)).indexOf(k.CONV_AT_ME)&&-1!==s.indexOf(k.CONV_AT_ALL)&&(s=[k.CONV_AT_ALL_AT_ME]),s={from:n.from,groupID:n.groupID,topicID:n.topicID,messageSequence:n.sequence,atTypeArray:s,__random:n.__random,__sequence:n.__sequence},this.groupAtInfoList.push(s))}},{key:"_isNeedMergeGroupAtInfo",value:function(e){var t,n=e.groupID,s=e.sequence;return!!ct({groupID:n})&&(t=!1,this.groupAtInfoList.forEach(function(n){n.messageSequence===s&&(-1<n.atTypeArray.indexOf(k.CONV_AT_ME)&&-1<e.groupAtType.indexOf(k.CONV_AT_ALL)&&(n.atTypeArray=[k.CONV_AT_ALL_AT_ME]),-1<n.atTypeArray.indexOf(k.CONV_AT_ALL)&&-1<e.groupAtType.indexOf(k.CONV_AT_ME)&&(n.atTypeArray=[k.CONV_AT_ALL_AT_ME],n.__random=e.__random,n.__sequence=e.__sequence),t=!0)}),t)}},{key:"clearGroupAtInfoList",value:function(){this.groupAtInfoList.length=0}},{key:"reduceUnreadCount",value:function(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence;return this.type===k.CONV_C2C&&t===this.lastMessage.lastSequence&&e.time===this.lastMessage.lastTime||this.type===k.CONV_GROUP&&t===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}},{key:"setLastMessageRevoker",value:function(e){this.lastMessage.revoker=e}},{key:"setDraftText",value:function(e){this.draftText=e}}]),fs=c(c(c({},k.MSG_REMIND_ACPT_AND_NOTE,0),k.MSG_REMIND_DISCARD,1),k.MSG_REMIND_ACPT_NOT_NOTE,2),ms=o(function e(t){i(this,e),this._convM=t,this._n="MsgRemindHandler"},[{key:"onAllRcvMsgOptNotify",value:function(e){e=this._handleResult(e),this._convM.emitOEvt(E.ALL_RECEIVE_MESSAGE_OPT_UPDATED,e)}},{key:"getC2CMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".getC2CMsgRemindType");return this._convM.req({P:dn.GET_C2C_PEER_MUTE_NOTIFICATIONS,data:{toAccount:this._convM.getMyUserID(),userIDList:e}}).then(function(s){Ee.l("".concat(n," ok. userIDList:").concat(e)),s=s.data.muteFlagList,t._convM.onC2CMsgRemindTypeFetched(s)}).catch(function(e){Ee.e("".concat(n," failed. error:"),e)})}},{key:"set",value:function(e){return e.groupID?this._setGroupMsgRemindType(e):Ve(e.userIDList)?this._setC2CMsgRemindType(e):void 0}},{key:"_setGroupMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".").concat("_setGroupMsgRemindType"),s=e.groupID,i=e.messageRemindType,a="groupID:".concat(s," messageRemindType:").concat(i),o=new kn("_setGroupMsgRemindType"),r=(o.setMessage(a),this._get(7));return r?r.modifyGroupMemberInfo({groupID:s,messageRemindType:i,userID:this._convM.getMyUserID()}).then(function(){o.end(),Ee.l("".concat(n," ok. ").concat(a));var s=t.onGroupMsgRemindTypeUpdated(e);return t._convM.onTotalUnreadCountUpdate(),zt(s)}).catch(function(e){return o.setError(e).end(),Ee.e("".concat(n," failed. error:"),e),Jt(e)}):Jt({code:un.NO_MODULE})}},{key:"onGroupMsgRemindTypeUpdated",value:function(e){var t,n,s=e.groupID,i=(e=e.messageRemindType,Ee.l("".concat(this._n,".onGroupMsgRemindTypeUpdated groupID:").concat(s," messageRemindType:").concat(e)),this._get(7).getLocalGroupProfile(s));return i&&(i.selfInfo.messageRemindType=e),ut(s)?(t=St(n=s),(n=this._get(10).getLocalTopic(t,n))&&n.updateSelfInfo({messageRemindType:e})&&this._convM.emitOEvt(E.TOPIC_UPDATED,{groupID:t,topic:n}),{topic:n}):(this._convM.patchMsgRemindType({ID:s,isC2CConversation:!1,messageRemindType:e})&&this._emitConvUpdate(),{group:i})}},{key:"_setC2CMsgRemindType",value:function(e){var t=this,n="".concat(this._n,".").concat("_setC2CMsgRemindType"),s=e.userIDList,i=e.messageRemindType,a=s.slice(0,30),o=(e=fs[i]||0,"userIDList:".concat(a," messageRemindType:").concat(i)),r=new kn("_setC2CMsgRemindType");return r.setMessage(o),this._convM.req({P:dn.SET_C2C_PEER_MUTE_NOTIFICATIONS,data:{userIDList:a,muteFlag:e}}).then(function(e){r.end(),e=e.data.errorList;var s=[],c=[],u=(Ve(e)&&e.forEach(function(e){s.push(e.userID),c.push({userID:e.userID,code:e.errorCode})}),e=a.filter(function(e){return-1===s.indexOf(e)}),Ee.l("".concat(n," ok. ").concat(o," successUserIDList:").concat(e," failureUserIDList:").concat(JSON.stringify(c))),0);return e.forEach(function(e){t._convM.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(u+=1)}),1<=u&&t._emitConvUpdate(),a.length=s.length=0,t._convM.onTotalUnreadCountUpdate(),$t({successUserIDList:e.map(function(e){return{userID:e}}),failureUserIDList:c})}).catch(function(e){return r.setError(e).end(),Ee.e("".concat(n," failed. error:"),e),Jt(e)})}},{key:"_get",value:function(e){return this._convM.get(e)}},{key:"_emitConvUpdate",value:function(){this._convM.emitConvUpdate(!0,!1)}},{key:"setAllRcvMsgOpt",value:function(e){var t="".concat(this._n,".").concat("setAllRcvMsgOpt"),n=void 0===(n=e.messageRemindType)?k.MSG_REMIND_ACPT_NOT_NOTE:n,s=void 0===(s=e.isRepeated)||s,i=void 0===(i=(a=this._calcStartAndEndTime(e)).startTime)?0:i,a=void 0===(a=a.endTime)?0:a,o=(e=JSON.stringify(e),new kn("setAllRcvMsgOpt"));return o.setMessage(e),Ee.l("".concat(t," options:").concat(e)),this._convM.req({P:dn.SET_ALL_RECEIVE_MSG_OPT,data:{messageRemindType:fs[n],startTime:i,endTime:a,isRepeated:s?1:0}}).then(function(e){return o.end(),Ee.l("".concat(t," ok.")),zt(e)}).catch(function(e){return o.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})}},{key:"_calcStartAndEndTime",value:function(e){var t=void 0===(t=e.startHour)?0:t,n=void 0===(n=e.startMinute)?0:n,s=void 0===(s=e.startSecond)?0:s,i=void 0===(i=e.duration)?0:i,a=(e=void 0===(e=e.isRepeated)||e,(r=new Date).getFullYear()),o=r.getMonth(),r=r.getDate();return{startTime:a=Math.round(new Date(a,o,r,t,n,s).getTime()/1e3),endTime:e&&86400<=i?a+86400:a+i}}},{key:"getAllRcvMsgOpt",value:function(){var e=this,t="".concat(this._n,".").concat("getAllRcvMsgOpt"),n=new kn("getAllRcvMsgOpt");return this._convM.req({P:dn.GET_ALL_RECEIVE_MSG_OPT,data:{toAccount:this._convM.getMyUserID()}}).then(function(s){return s=s.data,n.setMessage(JSON.stringify(s)).end(),Ee.l("".concat(t," ok. data:").concat(JSON.stringify(s))),zt(s=e._handleResult(s))}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})}},{key:"_handleResult",value:function(e){var t=e.messageRemindType,n=k.MSG_REMIND_ACPT_AND_NOTE;return 1===t&&(n=k.MSG_REMIND_DISCARD),{messageRemindType:n=2===t?k.MSG_REMIND_ACPT_NOT_NOTE:n,startTime:e.startTime,endTime:e.endTime,isRepeated:1===e.isRepeated}}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}]),vs=o(function e(t){i(this,e),this._convM=t,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=Qt},[{key:"setConvCustomData",value:function(e){var t=this,n="".concat(this._n,".").concat("setConvCustomData"),s=e.conversationIDList,i=e.customData,a=(Ee.l("".concat(n," options:"),e),new kn("setConvCustomData")),o=(a.setMessage(JSON.stringify(e)),{fromAccount:this._getMyUserID(),itemList:[]}),r=[],c=[];return s.forEach(function(e){var n;return t._hasLocalConv(e)?lt(e)||dt(e)?(n={operationType:2,contactItem:void 0,customMark:i},lt(e)?n.contactItem={type:1,toAccount:e.replace(k.CONV_C2C,"")}:dt(e)&&(n.contactItem={type:2,groupID:e.replace(k.CONV_GROUP,"")}),void o.itemList.push(n)):(t._onConvIDInvalid(c,e),!0):(t._onConvNotFound(c,e),!0)}),c.length===s.length?$t({successConversationIDList:r,failureConversationIDList:c}):this._convM.req({P:dn.SET_CONV_CUSTOM_DATA,data:o}).then(function(e){var s,o,u;return a.end(),Ee.l("".concat(n," ok")),Ve(e=e.data.resultItem)&&(u=!1,e.forEach(function(e){s=t._concatConvID(e.contactItem),0===e.resultCode?(r.push(s),(o=t._getLocalConv(s))&&o.customData!==i&&(o.customData=i,u=!0)):c.push({conversationID:s,code:e.resultCode,message:e.resultInfo})}),!0===u)&&t._emitConvUpdate(),zt({successConversationIDList:r,failureConversationIDList:c})}).catch(function(e){return a.setError(e).end(),Ee.e("".concat(n," failed. error:"),e),Jt(e)})}},{key:"markConv",value:function(e){var t,n,s,i,a,o,r,c,u,l,d=this;return this._convM.canIUse(P.CONV_MARK)?(t="".concat(this._n,".").concat("markConv"),n=e.conversationIDList,s=e.markType,i=e.enableMark,Ee.l("".concat(t," options:"),e),a=new kn("markConv"),o=void a.setMessage(JSON.stringify(e)),r=void 0,e=this._getFlagBit(s),!0===i?r=[e]:o=[e],c={fromAccount:this._getMyUserID(),itemList:[]},u=[],l=[],n.forEach(function(e){var t;return d._hasLocalConv(e)?lt(e)||dt(e)?(t={operationType:1,contactItem:void 0,clearMark:o,setMark:r},lt(e)?t.contactItem={type:1,toAccount:e.replace(k.CONV_C2C,"")}:dt(e)&&(t.contactItem={type:2,groupID:e.replace(k.CONV_GROUP,"")}),void c.itemList.push(t)):(d._onConvIDInvalid(l,e),!0):(d._onConvNotFound(l,e),!0)}),l.length===n.length?$t({successConversationIDList:u,failureConversationIDList:l}):this._convM.req({P:dn.MARK_CONV,data:c}).then(function(e){var n,o,r;return a.end(),Ee.l("".concat(t," ok")),Ve(e=e.data.resultItem)&&(r=!1,e.forEach(function(e){var t;n=d._concatConvID(e.contactItem),0===e.resultCode?(u.push(n),(o=d._getLocalConv(n))&&(t=o.markList.indexOf(s),!0===i?-1===t&&(o.markList.push(s),r=!0):-1!==t&&(o.markList.splice(t,1),r=!0))):l.push({conversationID:n,code:e.resultCode,message:e.resultInfo})}),!0===r)&&d._emitConvUpdate(),zt({successConversationIDList:u,failureConversationIDList:l})}).catch(function(e){return a.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse("markConv")}},{key:"getLocalConvGroupList",value:function(){var e=this;return Ee.l("".concat(this._n,".getLocalConvGroupList pagingStatus:").concat(this._pagingStatus)),this._pagingStatus===nn?this.getRemoteConvGroupList().then(function(){return zt(y(e._convGroupMap.values()))}):$t(y(this._convGroupMap.values()))}},{key:"searchConvGroupAndMark",value:function(e,t){var n=this,s="".concat(this._n,".searchConvGroupAndMark"),i=[];return e.forEach(function(e){1===t?i.push({type:1,toAccount:e}):2===t&&i.push({type:2,groupID:e})}),Ee.l("".concat(s," type:").concat(t," list:"),e),this._convM.req({P:dn.SEARCH_CONV_GRP_MARK,data:{fromAccount:this._getMyUserID(),contactItem:i}}).then(function(e){var t=(e=e.data).contactItem;e=e.groupItem,Ee.l("".concat(s," ok. contactItem:"),t,"groupItem:",e),n._fillConvGroupMap(e),n._handleContactItem(t),n._emitConvUpdate()}).catch(function(e){Ee.w("".concat(s," failed. error:"),e)})}},{key:"_fillConvGroupMap",value:function(e){var t=this;Ve(e)&&e.forEach(function(e){var n=e.convGroupID;t._convGroupMap.set(n,e.groupName)})}},{key:"_handleContactItem",value:function(e){var t,n=this;Ve(e)&&e.forEach(function(e){var s=[],i=e.standardMark,a=e.customData,o=e.convGroupIDList;Ve(o)&&o.forEach(function(e){n._convGroupMap.has(e)&&s.push(n._convGroupMap.get(e))}),t=n._concatConvID(e),(t=n._getLocalConv(t))&&(t.markList=kt(i),t.customData=a||"",t.conversationGroupList=[].concat(s))})}},{key:"getRemoteConvGroupList",value:function(){var e=this,t="".concat(this._n,".getRemoteConvGroupList");return this._pagingStatus=en,this._convM.req({P:dn.GET_CONV_GRP_LIST,data:{fromAccount:this._getMyUserID(),startIndex:this._startIndex}}).then(function(n){var s=(n=n.data).completeFlag,i=n.contactItem,a=void 0===(a=n.nextStartIndex)?0:a;if(n=n.groupItem,e._startIndex=a,Ee.l("".concat(t," completeFlag:").concat(s," nextStartIndex:").concat(a,", groupItem:"),n,"contactItem:",i),e._fillConvGroupMap(n),e._handleContactItem(i),0===s)return e.getRemoteConvGroupList();1===s&&(e._pagingStatus=tn,e._emitConvUpdate(),e._emitConvGroupListUpdate())}).catch(function(n){e._pagingStatus=nn,Ee.w("".concat(t," failed. error:"),n)})}},{key:"createConvGroup",value:function(e){var t,n,s,i,a,o,r=this;return this._convM.canIUse(P.CONV_GROUP)?(t="".concat(this._n,".").concat("createConvGroup"),Ee.l("".concat(t," options:"),e),(n=new kn("createConvGroup")).setMessage(JSON.stringify(e)),s=e.groupName,e=e.conversationIDList,i={fromAccount:this._getMyUserID(),itemList:[{groupName:s,contactItem:[]}]},a=[],o=[],e.forEach(function(e){return r._hasLocalConv(e)?lt(e)||dt(e)?void(lt(e)?i.itemList[0].contactItem.push({type:1,toAccount:e.replace(k.CONV_C2C,"")}):dt(e)&&i.itemList[0].contactItem.push({type:2,groupID:e.replace(k.CONV_GROUP,"")})):(r._onConvIDInvalid(o,e),!0):(r._onConvNotFound(o,e),!0)}),o.length===e.length?$t({successConversationIDList:a,failureConversationIDList:o}):this._convM.req({P:dn.CREATE_CONV_GRP,data:i}).then(function(e){n.end(),Ee.l("".concat(t," ok"));var i,c,u,l=(e=e.data.groupResultItem[0]).groupItem;return e=e.resultItem,xe(l)&&(r._convGroupMap.set(l.convGroupID,l.groupName),r._emitConvGroupListUpdate()),Ve(e)&&(u=!1,e.forEach(function(e){i=r._concatConvID(e.contactItem),0===e.resultCode?(a.push(i),(c=r._getLocalConv(i))&&-1===c.conversationGroupList.indexOf(s)&&(c.conversationGroupList.push(s),u=!0)):o.push({conversationID:i,code:e.resultCode,message:e.resultInfo})}),!0===u)&&(r._emitConvUpdate(),r._emitConvGroupListUpdate()),zt({successConversationIDList:a,failureConversationIDList:o})}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse("createConvGroup")}},{key:"deleteConvGroup",value:function(e){var t,n,s=this;return this._convM.canIUse(P.CONV_GROUP)?(t="".concat(this._n,".").concat("deleteConvGroup"),Ee.l("".concat(t," groupName:").concat(e)),(n=new kn("deleteConvGroup")).setMessage(e),this._convM.req({P:dn.DEL_CONV_GRP,data:{fromAccount:this._getMyUserID(),groupName:[e]}}).then(function(i){var a;n.end(),Ee.l("".concat(t," ok")),Ve(i=i.data.groupItem)&&(a=!1,i.forEach(function(e){s._convGroupMap.has(e.convGroupID)&&(s._convGroupMap.delete(e.convGroupID),a=!0)}),!0===a)&&s._emitConvGroupListUpdate(),s._eraseFromConversationGroupList([e])}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse("deleteConvGroup")}},{key:"renameConvGroup",value:function(e){var t,n,s,i,a=this;return this._convM.canIUse(P.CONV_GROUP)?(t="".concat(this._n,".").concat("renameConvGroup"),Ee.l("".concat(t," options:"),e),(n=new kn("renameConvGroup")).setMessage(JSON.stringify(e)),s=e.oldName,i=e.newName,this._convM.req({P:dn.RENAME_CONV_GRP,data:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:s,newName:i}}}).then(function(e){n.end(),Ee.l("".concat(t," ok")),e=e.data.updateGroupResult.convGroupID,a._convGroupMap.set(e,i),a._emitConvGroupListUpdate(),e=a._convM.getLocalConvList();var o,r,c=!1;e.forEach(function(e){o=e.conversationGroupList,-1!==(r=o.indexOf(s))&&(o.splice(r,1,i),c=!0)}),!0===c&&a._emitConvUpdate()}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse("renameConvGroup")}},{key:"addConvsToGroup",value:function(e){var t,n,s,i,a,o,r,c=this;return this._convM.canIUse(P.CONV_GROUP)?(t="".concat(this._n,".").concat("addConvsToGroup"),Ee.l("".concat(t," options:"),e),(n=new kn("addConvsToGroup")).setMessage(JSON.stringify(e)),s=e.conversationIDList,i=e.groupName,a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:i,updateItem:[]}},o=[],r=[],s.forEach(function(e){return c._hasLocalConv(e)?lt(e)||dt(e)?void(lt(e)?a.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(k.CONV_C2C,"")}}):dt(e)&&a.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(k.CONV_GROUP,"")}})):(c._onConvIDInvalid(r,e),!0):(c._onConvNotFound(r,e),!0)}),r.length===s.length?$t({successConversationIDList:o,failureConversationIDList:r}):this._convM.req({P:dn.ADD_CONV_TO_GRP,data:a}).then(function(e){var s,a,u;return n.end(),Ee.l("".concat(t," ok")),Ve(e=e.data.updateGroupResult.contactResultItem)&&(u=!1,e.forEach(function(e){s=c._concatConvID(e.contactItem),0===e.resultCode?(a=c._getLocalConv(s))&&-1===a.conversationGroupList.indexOf(i)&&(a.conversationGroupList.push(i),o.push(s),u=!0):r.push({conversationID:s,code:e.resultCode,message:e.resultInfo})}),!0===u)&&(c._emitConvUpdate(),c._emitConvInGroupUpdate(i)),zt({successConversationIDList:o,failureConversationIDList:r})}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse("addConvsToGroup")}},{key:"deleteConvsFromGroup",value:function(e){var t,n,s,i,a,o,r,c=this,u="deleteConvsFromGroup";return this._convM.canIUse(P.CONV_GROUP)?(t="".concat(this._n,".").concat(u),Ee.l("".concat(t," options:"),e),(n=new kn(u)).setMessage(JSON.stringify(e)),s=e.conversationIDList,i=e.groupName,a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:i,updateItem:[]}},o=[],r=[],s.forEach(function(e){return c._hasLocalConv(e)?lt(e)||dt(e)?void(lt(e)?a.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(k.CONV_C2C,"")}}):dt(e)&&a.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(k.CONV_GROUP,"")}})):(c._onConvIDInvalid(r,e),!0):(c._onConvNotFound(r,e),!0)}),r.length===s.length?$t({successConversationIDList:o,failureConversationIDList:r}):this._convM.req({P:dn.DEL_CONV_FROM_GRP,data:a}).then(function(e){var s,a,u;return n.end(),Ee.l("".concat(t," ok")),Ve(e=e.data.updateGroupResult.contactResultItem)&&(u=!1,e.forEach(function(e){var t;s=c._concatConvID(e.contactItem),0===e.resultCode?(a=c._getLocalConv(s))&&-1!==(t=a.conversationGroupList.indexOf(i))&&(a.conversationGroupList.splice(t,1),o.push(s),u=!0):r.push({conversationID:s,code:e.resultCode,message:e.resultInfo})}),!0===u)&&(c._emitConvUpdate(),c._emitConvInGroupUpdate(i)),zt({successConversationIDList:o,failureConversationIDList:r})}).catch(function(e){return n.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})):this._convM.noUse(u)}},{key:"onConvMarkUpdated",value:function(e){var t,n,s=this;Ue(e)||(Ee.l("".concat(this._n,".onConvMarkUpdated markItemList:"),e),n=!1,e.forEach(function(e){var i=e.recentContactItem,a=e.optType,o=e.standardMark;e=e.customMark,t=s._concatConvID(i),(t=s._getLocalConv(t))&&(1===a?n=s._diffStandardMark(t,o):2===a?n=s._diffCustomMark(t,e):3===a&&(i=s._diffStandardMark(t,o),a=s._diffCustomMark(t,e),n=i||a))}),!0===n&&this._emitConvUpdate())}},{key:"_diffStandardMark",value:function(e,t){t=kt(t);var n=!1;return!0!==((e,t)=>{if(e!==t){if(!e||!t)return!1;if(e.length!==t.length)return!1;for(var n=0,s=e.length;n<s;n++)if(e[n]!==t[n])return!1}return!0})(e.markList,t)&&(e.markList=t,n=!0),n}},{key:"_diffCustomMark",value:function(e,t){var n=!1;return e.customData!==t&&void 0!==t&&(e.customData=t,n=!0),n}},{key:"onConvGroupCreated",value:function(e){var t=this,n=(Ee.l("".concat(this._n,".onConvGroupCreated resultList:"),e),!1),s=!1;Ve(e)&&(e.forEach(function(e){var i,a,o=(a=e.msgGroupItem).groupID,r=a.groupName;t._convGroupMap.get(o)!==r&&(t._convGroupMap.set(o,r),s=!0),Ve(a=e.msgRecentContactItem)&&a.forEach(function(e){i=t._concatConvID(e),(i=t._getLocalConv(i))&&-1===i.conversationGroupList.indexOf(r)&&(i.conversationGroupList.push(r),n=!0)})}),!0===n&&this._emitConvUpdate(),!0===s)&&this._emitConvGroupListUpdate()}},{key:"onConvGroupDeleted",value:function(e){var t,n=this,s=(Ee.l("".concat(this._n,".onConvGroupDeleted groupItemList:"),e),[]);Ve(e)&&(t=!1,e.forEach(function(e){var i=e.groupID;e=e.groupName,n._convGroupMap.has(i)&&(n._convGroupMap.delete(i),t=!0,s.push(e))}),!0===t)&&this._emitConvGroupListUpdate(),this._eraseFromConversationGroupList(s)}},{key:"_eraseFromConversationGroupList",value:function(e){Ue(e)||(this._convM.getLocalConvList().forEach(function(t){t.conversationGroupList=t.conversationGroupList.filter(function(t){return!e.includes(t)})}),this._emitConvUpdate())}},{key:"onConvGroupNameUpdated",value:function(e){Ee.l("".concat(this._n,".onConvGroupNameUpdated options:"),e);var t,n,s,i=e.groupID,a=e.groupName,o=e.oldGroupName;this._convGroupMap.get(i)!==a&&(this._convGroupMap.set(i,a),this._emitConvGroupListUpdate(),e=this._convM.getLocalConvList(),s=!1,e.forEach(function(e){t=e.conversationGroupList,-1!==(n=t.indexOf(o))&&(t.splice(n,1,a),s=!0)}),!0===s)&&this._emitConvUpdate()}},{key:"onConvInGroupUpdated",value:function(e){var t,n,s,i=this,a=(Ee.l("".concat(this._n,".onConvInGroupUpdated options:"),e),e.oldGroupName);Ve(e=e.recentContactUpdateGroupItem)&&(s=!1,e.forEach(function(e){var o=e.contactOptType;t=i._concatConvID(e.recentContactItem),(t=i._getLocalConv(t))&&(n=t.conversationGroupList.indexOf(a),1===o?-1===n&&(t.conversationGroupList.push(a),s=!0):2===o&&-1!==n&&(t.conversationGroupList.splice(n,1),s=!0))}),!0===s)&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(a))}},{key:"onConvAddedToOrDeletedFromGroup",value:function(e){var t,n,s=this,i=(Ee.l("".concat(this._n,".onConvAddedToOrDeletedFromGroup options:"),e),e.msgRecentContactItem),a=(e=e.msgRecentContactUpdateContactItem,i=this._concatConvID(i),this._getLocalConv(i));a&&Ve(e)&&(n=!1,e.forEach(function(e){var i=e.groupOptType;e=e.recentContactGroupItem.groupName,t=a.conversationGroupList.indexOf(e),1===i?-1===t&&(a.conversationGroupList.push(e),n=!0):2===i&&-1!==t&&(a.conversationGroupList.splice(t,1),n=!0),!0===n&&s._emitConvInGroupUpdate(e)}),!0===n)&&this._emitConvUpdate()}},{key:"onConvGroupListSynced",value:function(e){Ve(e)&&0!==e.length&&(Ee.l("".concat(this._n,".onConvGroupListSynced groupItem:"),e),this._fillConvGroupMap(e))}},{key:"getConvGroupListByID",value:function(e){var t,n=this;if(!Ue(e))return t=[],e.forEach(function(e){n._convGroupMap.has(e)&&t.push(n._convGroupMap.get(e))}),t}},{key:"_onConvNotFound",value:function(e,t){e.push({conversationID:t,code:un.CONV_NOT_FOUND,message:this._convM.getErrMsg(un.CONV_NOT_FOUND)})}},{key:"_onConvIDInvalid",value:function(e,t){e.push({conversationID:t,code:un.INVALID_CONV_ID,message:this._convM.getErrMsg(un.INVALID_CONV_ID)})}},{key:"_getFlagBit",value:function(e){for(var t=e.toString(2),n=t.length,s=n-1;0<=s;s--)if("1"===t[s])return n-s-1}},{key:"_concatConvID",value:function(e){var t,n=e.type,s=e.to,i=e.groupID;return e=e.userID,1===n?Ze(e)?Ze(s)||(t="".concat(k.CONV_C2C).concat(s)):t="".concat(k.CONV_C2C).concat(e):2===n&&(t="".concat(k.CONV_GROUP).concat(i)),t}},{key:"_getMyUserID",value:function(){return this._convM.getMyUserID()}},{key:"_getLocalConv",value:function(e){return this._convM.getLocalConversation(e)}},{key:"_hasLocalConv",value:function(e){return this._convM.hasLocalConversation(e)}},{key:"_emitConvUpdate",value:function(){this._convM.emitConvUpdate(!0,!1)}},{key:"_emitConvGroupListUpdate",value:function(){this._convM.emitOEvt(E.CONVERSATION_GROUP_LIST_UPDATED,y(this._convGroupMap.values()))}},{key:"_emitConvInGroupUpdate",value:function(e){var t={groupName:e,conversationList:[]},n=this._convM.getLocalConvList();t.conversationList=n.filter(function(t){return t.conversationGroupList.includes(e)}),this._convM.emitOEvt(E.CONVERSATION_IN_GROUP_UPDATED,t)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=Qt}}]),ys=o(function e(t){i(this,e);var n=t.eventType,s=t.index,a=t.markdown,o=t.isLast;t=t.binaryData,this.eventType=n,this.index=s,this.markdown=a,this.isLast=o,this.binaryData=t}),Is=o(function e(t){i(this,e),this._n="StreamMessageHandler",this._convM=t,this._messageMap=new Map,this._retryCountMap=new Map},[{key:"getStreamMessageInHistory",value:function(e){var t=this;0<e.length&&e.forEach(function(e){var n,s,i,a;e.type===k.MSG_STREAM&&(s=(a=(n=e._elements[0]).content||{}).streamMessageID,i=a.markdown,a=a.binaryData,s)&&(Ee.l("".concat(t._n,".getStreamMessageInHistory streamMessageID:").concat(s," markdown.length:").concat(i.length)),Ue(i)&&Ue(a)?(t._messageMap.set(s,e),t._getStreamMessage(e)):n.content.isStreamEnded=!0)})}},{key:"onPushedChunks",value:function(e){var t,n,s=e.chunks,i=e.streamMessageID,a=(e=e.stopReason,this._messageMap.get(i));a&&s&&0!==s.length&&(t=a._elements[0],this._containsExpectedChunk(t,s))&&(s=s.map(function(e){return new ys(e)}),t.updateChunks(s),a.payload=_({},t.content),this._convM.emitOEvt(E.MESSAGE_MODIFIED,[a]),this._sendAck(i,t.getLastIndex()),s=a.conversationID,a=a.sequence,(n=this._convM.getLocalConversation(s))&&(n=n.lastMessage).lastSequence===a&&t.content.isStreamEnded&&(Ee.l("".concat(this._n,".onPushedChunks convID:").concat(s," lastMessage updated. sequence:").concat(a)),n.type=t.type,n.payload=_({},t.content),n.messageForShow=n.payload.markdown,this._convM.emitConvUpdate(!0,!1)),t.content.isStreamEnded)&&(this._messageMap.delete(i),t.stopReason=e||!0)}},{key:"_sendAck",value:function(e,t){this._convM.req({P:dn.STREAM_CHUNK_ACK,data:{streamMessageID:e,ackIndex:t}})}},{key:"_containsExpectedChunk",value:function(e,t){for(var n=e.getLastIndex()+1,s=!1,i=0;i<t.length;i++)if(t[i].index===n){s=!0;break}return s}},{key:"getStreamMessageBeforeEmit",value:function(e){var t=this;0<e.length&&e.forEach(function(e){var n,s;e.type===k.MSG_STREAM&&(n=(s=e._elements[0].content||{}).streamMessageID,s=s.isStreamEnded,Ee.l("".concat(t._n,".getStreamMessageBeforeEmit streamMessageID:").concat(n," isStreamEnded:").concat(s)),n)&&!s&&(t._messageMap.set(n,e),t._getStreamMessage(e))})}},{key:"_getStreamMessage",value:function(e){var t=this,n=(e._elements[0].content||{}).streamMessageID;this._convM.req({P:dn.STREAM_GET_STREAM,data:{streamMessageID:n,from:e.from,to:e.to,ackIndex:0}}).then(function(e){Ee.l("".concat(t._n,"._getStreamMessage success. streamMessageID:").concat(n))}).catch(function(s){Ee.l("".concat(t._n,"._getStreamMessage failed. streamMessageID:").concat(n," error:"),s),t._shouldRetry(n)&&(s=t._retryCountMap.get(n)||0,t._retryCountMap.set(n,s+1),t._getStreamMessage(e))})}},{key:"_shouldRetry",value:function(e){return!this._retryCountMap.has(e)||this._retryCountMap.get(e)<=4}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._messageMap.clear(),this._retryCountMap.clear()}}]),Ms=(l(Rs,sn),o(Rs,[{key:"_initListeners",value:function(){var e=this.getIEmitInst();e.on(ss.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(ss.PROFILE_UPDATED,this._onProfileUpdated,this),e.on(ss.CLOUD_CONFIG,this._onCloudConfig,this)}},{key:"_init",value:function(){var e=this,t=(Ee.l("".concat(this._n,"._init")),this.get(13).getItem("conversationMap")),n=this.isIntl(),s=this.isUsingChatCore();if(t){for(var i=t.length,a=0;a<i;a++){var o=t[a];if(o){if(this._isNonExistentAccount(o.conversationID))continue;if(o.groupProfile&&rt(o.groupProfile.type))continue}this._convMap.set(o.conversationID,new _s(t[a],n,s))}this.emitConvUpdate(!0,!1)}this.ready(function(){0<e._tmpGroupList.length&&(e.updateConvGroupProfile(e._tmpGroupList),e._tmpGroupList.length=0)}),this.syncConvList()}},{key:"_isNonExistentAccount",value:function(e){var t;return"@TLS#ERROR"===(t=e.startsWith(k.CONV_C2C)?e.replace(k.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}},{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&this._msgListHandler.onCheckTimer(e)}},{key:"onMessageSent",value:function(e){this._onSendOrRcvMsg({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}},{key:"onNewMessage",value:function(e){this._onSendOrRcvMsg(e)}},{key:"_onSendOrRcvMsg",value:function(e){var t=this,n=e.conversationOptionsList,s=void 0===(s=e.isInstantMessage)||s,i=void 0!==(i=e.isUnreadC2CMessage)&&i,a=void 0===(a=e.updateUnreadCount)||a,o=void 0!==(o=e.isSyncingEnded)&&o;this._isReady?0!==n.length?(!0===s&&this._checkNewConv(n),this._updateLocalConvList({conversationOptionsList:n,isInstantMessage:s,isUnreadC2CMessage:i,isFromGetConversations:!1,updateUnreadCount:a}),s||(this._convIDFromUnreadDBMap=new Map([].concat(y(this._convIDFromUnreadDBMap),y(n.map(function(e){return[e.conversationID,1]})))),this._diffAndDeleteConv(),o&&this.emitIEvt(ss.C2C_UNREAD_HANDLE_COMPLETED)),0<n.filter(function(e){return!t._isConvNeedShow(e.conversationID)}).length||this.emitConvUpdate()):o&&this.emitIEvt(ss.C2C_UNREAD_HANDLE_COMPLETED):this.ready(function(){t._onSendOrRcvMsg(e)})}},{key:"updateConvGroupProfile",value:function(e){var t,n=this;Ve(e)&&0===e.length||(0!==this._convMap.size?(t=!1,e.forEach(function(e){var s="".concat(k.CONV_GROUP).concat(e.groupID);n._convMap.has(s)&&(t=!0,(s=n._convMap.get(s)).groupProfile=JSON.parse(JSON.stringify(e)),s.lastMessage.lastSequence<e.nextMessageSeq&&(s.lastMessage.lastSequence=e.nextMessageSeq-1),s.subType||(s.subType=e.type))}),t&&this.emitConvUpdate(!0,!1)):this._tmpGroupList=e)}},{key:"onMessageRevoked",value:function(e,t){var n,s,i,a,o=this;0!==e.length&&(n=null,s=!1,i=[],e.forEach(function(e){(n=o._convMap.get(e.conversationID))&&(t&&n.reduceUnreadCount()&&(s=n.type!==k.CONV_TOPIC),n.type===k.CONV_TOPIC?i.push(e):n.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(n.setLastMessageRevoked(!0),n.setLastMessageRevoker(e.revoker),s=!0))}),(a=this.get(10))&&a.onMessageRevoked(i),s)&&(this.emitConvUpdate(!0,!1),this._updateGroupLastMessage(e[0]))}},{key:"_updateGroupLastMessage",value:function(e){var t;(e=e.conversationID).startsWith(k.CONV_GROUP)&&(e=this._convMap.get(e),t=this.get(7))&&t.updateGroupLastMessage([e])}},{key:"updateRevokerInfo",value:function(e){for(var t=new Set,n=0;n<e.length;n++){var s=e[n].revoker;t.add(s)}var i=y(t),a=this.get(4);return new Promise(function(t){a.getUserProfile({userIDList:i}).then(function(n){if(!Ve(n=n.data)||0===n.length)return t(e);var s,i={},a=r(n);try{for(a.s();!(s=a.n()).done;){var o=s.value,c=o.userID;i[c]={nick:o.nick,avatar:o.avatar}}}catch(n){a.e(n)}finally{a.f()}e.forEach(function(e){var t=e.revoker;i[t]&&(e.revokerInfo.nick=i[t].nick||"",e.revokerInfo.avatar=i[t].avatar||"")}),t(e)}).catch(function(){t(e)})})}},{key:"isLastMessageRevoked",value:function(e){var t=!1,n=e.conversationID,s=e.sequence,i=e.time,a=this._convMap.get(n);return a&&(t=a.type===k.CONV_TOPIC?this.get(10).isLastMessageRevoked({topicID:n.replace(k.CONV_GROUP,""),sequence:s}):a.isLastMessageRevoked({sequence:s,time:i})),Ee.l("".concat(this._n,".isLastMessageRevoked options:"),e,"ret:".concat(t)),t}},{key:"onMessageDeleted",value:function(e){var t=this;if(0!==e.length){var n=null;e.forEach(function(e){(n=t._msgListHandler.getLocalMsg(e.conversationID,e.ID))&&(n.isDeleted=!0),e!==n&&(e.isDeleted=!0)}),e=e[0].conversationID;for(var s=this._msgListHandler.getLocalMsgList(e),i={},a=s.length-1;0<=a;a--)if(!s[a].isDeleted){i=s[a];break}var o,r=this._convMap.get(e);r&&(o=!1,r.lastMessage.lastSequence===i.sequence&&r.lastMessage.lastTime===i.time||(Ue(i)&&(i=void 0),r.updateLastMessage(i),r.type!==k.CONV_TOPIC&&(o=!0),Ee.l("".concat(this._n,".onMessageDeleted. update convID:").concat(e," with lastMessage:"),r.lastMessage)),e.startsWith(k.CONV_C2C)&&this.updateUnreadCount(e),o)&&this.emitConvUpdate(!0,!1)}}},{key:"onMessageModified",value:function(e){var t="".concat(this._n,".onMessageModified"),n=e.conversationType,s=e.from,i=e.to,a=e.time,o=e.sequence,r=e.elements,c=e.cloudCustomData,u=e.messageVersion,l=this.getMyUserID(),d="".concat(n).concat(i),h=(n=(i===l&&n===k.CONV_C2C&&(d="".concat(n).concat(s)),l=this._msgListHandler.onMsgModified(d,e)).isUpdated,l=l.message,!0===n&&this.emitOEvt(E.MESSAGE_MODIFIED,[l]),this._isTopicConv(d));return null===l?Ee.l("".concat(t," message is null! options:"),e):Ee.l("".concat(t," isUpdated:").concat(n," isTopicMessage:").concat(h," from:").concat(s," to:").concat(i," sequence:").concat(l.sequence," time:").concat(l.time)),h?this.get(10).onMessageModified(e):(n=this._convMap.get(d))&&(s=n.lastMessage)&&s.lastTime===a&&s.lastSequence===o&&s.version!==u&&(Ee.l("".concat(t," convID:").concat(d," lastMessage updated")),s.type=r[0].type,s.payload=r[0].content,s.messageForShow=Et(s.type,s.payload,this.isIntl()),s.cloudCustomData=c,s.version=u,this.emitConvUpdate(!0,!1)),l}},{key:"onNewGroupAtTips",value:function(e){var t=this,n=(e=e.dataList,null);e.forEach(function(e){e.groupAtTips?n=e.groupAtTips:e.elements?n=_(_({},e.elements),{},{sync:!0}):e.groupAtType&&(n=_(_({},e),{},{sync:!0})),n.__random=e.random,n.__sequence=e.clientSequence,t._tmpGroupAtTipsList.push(n)}),Ee.l("".concat(this._n,".onNewGroupAtTips isReady:").concat(this._isReady),this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}},{key:"_handleGroupAtTipsList",value:function(){var e,t=this;0!==this._tmpGroupAtTipsList.length&&(e=!1,this._tmpGroupAtTipsList.forEach(function(n){var s=n.groupID,i=void 0===(i=n.topicID)?void 0:i,a=void 0!==(a=n.sync)&&a;n.from!==t.getMyUserID()&&(Ze(i)?(s=t._convMap.get("".concat(k.CONV_GROUP).concat(s)))&&(s.updateGroupAtInfoList(n),e=!0):((s=t._convMap.get("".concat(k.CONV_GROUP).concat(i)))&&(s.updateGroupAtInfoList(n),t.get(10).onAtInfoUpdated({topicID:i,groupAtInfoList:s.groupAtInfoList})),Ue(s)&&a&&(t.updateTopicConversation([{conversationID:"".concat(k.CONV_GROUP).concat(i),type:k.CONV_TOPIC}]),t._convMap.get("".concat(k.CONV_GROUP).concat(i)).updateGroupAtInfoList(n))))}),e&&this.emitConvUpdate(!0,!1),this._tmpGroupAtTipsList.length=0)}},{key:"_checkNewConv",value:function(e){var t=this,n=[],s=[];e.forEach(function(e){t._convMap.has(e.conversationID)||(e.type===k.CONV_C2C?n.push(e.conversationID.replace(k.CONV_C2C,"")):e.type===k.CONV_GROUP&&s.push(e.conversationID.replace(k.CONV_GROUP,"")))}),0<n.length&&(this._onNewC2CConv(n),n=null),0<s.length&&(this._onNewGroupConv(s),s=null)}},{key:"_onNewC2CConv",value:function(e){var t=this.get(6);return Promise.all([t.getRemotePeerReadTime(e),this._msgRemindHandler.getC2CMsgRemindType(e)])}},{key:"_onNewGroupConv",value:function(e){var t=this.get(7);return t?Promise.all([t.getMsgRemindType(e)]):Promise.resolve()}},{key:"_setStorageConvList",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.getLocalConvList().filter(function(e){return e.type===k.CONV_C2C||e.type===k.CONV_GROUP&&e.lastMessage.type!==k.MSG_GRP_TIP}).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.get(13).setItem("conversationMap",t,e)}},{key:"emitConvUpdate",value:function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this.getLocalConvList();t&&(t=this.get(7))&&t.updateGroupLastMessage(n),e&&(this.get(12).isPartialUpdatedConvs()?(this._diffConvMap(this._convMapForDiff,this._convMap),0<this._partialUpdatedConvMap.size&&(this.emitOEvt(E.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate(),this._convMapForDiff.clear(),this._convMapForDiff=Be(this._convMap,!0)),0===this._convMapForDiff.size&&(this._convMapForDiff=Be(this._convMap,!0))):(this.emitOEvt(E.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate()))}},{key:"_diffConvMap",value:function(e,t){var n,s=r(t);try{for(s.s();!(n=s.n()).done;){var i=v(n.value,2),a=i[0],o=i[1];e.has(a)&&JSON.stringify(o)===e.get(a)||this._partialUpdatedConvMap.set(a,o)}}catch(e){s.e(e)}finally{s.f()}}},{key:"getPartialUpdatedConvs",value:function(){var e=y(Be(this._partialUpdatedConvMap,!1).values());return this._partialUpdatedConvMap.clear(),e}},{key:"getLocalConvList",value:function(){var e=this;return y(this._convMap.values()).filter(function(t){return e._isConvNeedShow(t.conversationID)})}},{key:"getLocalConversation",value:function(e){return this._convMap.get(e)}},{key:"hasLocalConversation",value:function(e){return this._convMap.has(e)}},{key:"getLocalOldestMessage",value:function(e){return this._msgListHandler.getLocalOldestMsg(e)}},{key:"syncConvList",value:function(){var e=this,t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n="syncConvList",s=new kn(n);return this._pagingStatus===Qt&&this._convMap.clear(),this._pagingGetConvList(t).then(function(t){var i=(e=>{var t;if(Ve(e)&&0!==e.length)return t=0,e.forEach(function(e){t+=e}),(t/e.length).toFixed(0)})(e._pagingGetCostList),a=(e=>{var t;if(Ve(e)&&0!==e.length)return t=0,e.forEach(function(e){t+=e}),t.toFixed(0)})(e._pagingGetCostList);return e._pagingGetCostList.length=0,e._pagingStatus=tn,e._diffAndDeleteConv(),e.emitConvUpdate(!0,!1),e._setStorageConvList(),e._handleC2CPeerReadTime(),e.emitIEvt(ss.CONV_SYNC_COMPLETED),a="count:".concat(e._convMap.size," sum:").concat(a," avg:").concat(i),Ee.l("".concat(e._n,".").concat(n,". ").concat(a)),s.setMessage(a).end(),t}).catch(function(t){return e._pagingStatus=nn,s.setMessage(e._pagingTs).setError(t).end(),Jt(t)})}},{key:"_diffAndDeleteConv",value:function(){var e,t=this;this._isSyncCompleted()&&(e=[],this._convMap.forEach(function(n,s){!t._pagingConvIDMap.has(s)&&t._convIDFromUnreadDBMap.has(s)&&(t._convMap.delete(s),e.push(s))}),Ee.l("".concat(this._n,"._diffAndDeleteConv list:").concat(e)),e=null)}},{key:"_pagingGetConvList",value:function(){var e=this,t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n="".concat(this._n,"._pagingGetConvList"),s=(Ee.l("".concat(n," incrementalPullFlag:").concat(t," ts:").concat(this._pagingTs," startIdx:").concat(this._pagingStartIdx)+" pinnedTs:".concat(this._pagingPinnedTs," pinnedStartIdx:").concat(this._pagingPinnedStartIdx)),Date.now());return this._pagingStatus=en,this.req({P:dn.PAGING_GET_CONV_LIST,data:{fromAccount:this.getMyUserID(),timeStamp:t?this._pagingTs:0,startIndex:t?this._pagingStartIdx:0,pinnedTimeStamp:t?this._pagingPinnedTs:0,pinnedStartIndex:t?this._pagingPinnedStartIdx:0,orderType:1}}).then(function(t){var i=(t=t.data).completeFlag,a=void 0===(a=t.conversations)?[]:a,o=t.timeStamp,r=t.startIndex,c=t.pinnedTimeStamp,u=t.pinnedStartIndex;if(t=t.groupItem,e._pagingGetCostList.push(Ot(s,!1)),Ee.l("".concat(n," ok. completeFlag:").concat(i," count:").concat(a.length," cost:").concat(Ot(s))),e._convGroupHandler.onConvGroupListSynced(t),0<a.length&&(t=e._getConvOptions(a),e._pagingConvIDMap=new Map([].concat(y(e._pagingConvIDMap),y(t.map(function(e){return[e.conversationID,1]})))),e._updateLocalConvList({conversationOptionsList:t,isFromGetConversations:!0,updateUnreadCount:!0}),e.isLoggedIn())&&e.emitConvUpdate(),!e._isReady){if(!e.isLoggedIn())return $t();e.triggerReady()}return e._pagingTs=o,e._pagingStartIdx=r,e._pagingPinnedTs=c,e._pagingPinnedStartIdx=u,1!==i?e._pagingGetConvList():(e._handleGroupAtTipsList(),$t())}).catch(function(t){throw!e.isLoggedIn()||e._isReady||(Ee.w("".concat(n," failed. error:"),t),e.triggerReady()),t})}},{key:"_updateLocalConvList",value:function(e){var t=e.isFromGetConversations,n=Date.now();e=this._getTmpConvListMapping(e).newConvList,this._convMap=new Map(this._sortConvList(y(this._convMap))),t||this._updateUserOrGroupProfile(e),Ee.l("".concat(this._n,"._updateLocalConvList cost:").concat(Ot(n)))}},{key:"_getTmpConvListMapping",value:function(e){for(var t=e.conversationOptionsList,n=e.isFromGetConversations,s=e.isInstantMessage,i=e.isUnreadC2CMessage,a=void 0!==i&&i,o=e.updateUnreadCount,r=[],c=[],u=this.get(7),l=this.get(8),d=this.isIntl(),h=this.isUsingChatCore(),g=0,p=t.length;g<p;g++){var _=new _s(t[g],d,h),f=_.conversationID,m=_.type;if(!this._isNonExistentAccount(f)){if(this._convMap.has(f)){var v=this._convMap.get(f);if(n&&m!==k.CONV_TOPIC){this._convMap.set(f,_),m===k.CONV_C2C?_.unreadCount=v.unreadCount:m===k.CONV_GROUP&&(_.groupProfile=JSON.parse(JSON.stringify(v.groupProfile)));continue}var y=["unreadCount","allowType","adminForbidType","payload","groupProfile"],I=(!1===s&&y.push("lastMessage"),"boolean"==typeof s&&y.push("isPinned"),t[g].lastMessage),M=!Ze(I);M||t[g].type===k.CONV_TOPIC||this._onLastMsgNotExist(t[g]),Ze(s)&&M&&null===v.lastMessage.payload&&(v.lastMessage.payload=I.payload),Ue(v.lastMessage.revoker)||(v.lastMessage.revoker=null),je(v,_,y,[null,void 0,"",0,NaN]),!0===o&&v.updateUnreadCount({nextUnreadCount:_.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:a}),s&&M&&(I.payload&&(v.lastMessage.payload=I.payload),v.type===k.CONV_GROUP)&&(v.lastMessage.nameCard=I.nameCard,v.lastMessage.nick=I.nick),M&&v.lastMessage.cloudCustomData!==I.cloudCustomData&&(v.lastMessage.cloudCustomData=I.cloudCustomData||"")}else m===k.CONV_GROUP&&u?(y=_.groupProfile.groupID,(M=u.getLocalGroupProfile(y))&&(_.groupProfile=M,!0===o)&&_.updateUnreadCount({nextUnreadCount:0})):m===k.CONV_C2C&&(v=f.replace(k.CONV_C2C,""),l)&&l.isMyFriend(v)&&(_.remark=l.getFriendRemark(v)),r.push(_),this._convMap.set(f,_);this._convMap.get(f).type===k.CONV_TOPIC&&c.push(this._convMap.get(f))}}for(var C=this.get(10),T=0,S=c.length;T<S;T++){var E,D=(E=c[T]).conversationID;Ue(E=E.groupAtInfoList)||C.onAtInfoUpdated({topicID:D.replace(k.CONV_GROUP,""),groupAtInfoList:E})}return{newConvList:r}}},{key:"_onLastMsgNotExist",value:function(e){new kn("lastMsgNotExist").setMessage(JSON.stringify(e)).end()}},{key:"_sortConvList",value:function(e){var t=[],n=[],s=[],i=[];return e.forEach(function(e){(!0===e[1].isPinned?Ue(e[1].lastMessage.lastTime)?n:t:Ue(e[1].lastMessage.lastTime)?i:s).push(e)}),t.sort(function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime}).concat(n).concat(s.sort(function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})).concat(i)}},{key:"_sortConvListAndEmitEvent",value:function(){this._convMap=new Map(this._sortConvList(y(this._convMap))),this.emitConvUpdate(!0,!1)}},{key:"_updateUserOrGroupProfile",value:function(e){var t,n,s,i,a=this;0!==e.length&&(t=[],n=[],s=this.get(4),i=this.get(7),e.forEach(function(e){e.type===k.CONV_C2C?t.push(e.toAccount):e.type===k.CONV_GROUP&&(e=e.toAccount,n.push(e))}),Ee.l("".concat(this._n,"._updateUserOrGroupProfile userIDList:").concat(t," groupIDList:").concat(n)),0<t.length&&s.getUserProfile({userIDList:t}).then(function(e){Ve(e=e.data)?e.forEach(function(e){a._doUpdateUserProfile("".concat(k.CONV_C2C).concat(e.userID),e)}):a._doUpdateUserProfile("".concat(k.CONV_C2C).concat(e.userID),e)}),0<n.length)&&i.getGroupProfileAdvance({groupIDList:n,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then(function(e){e=e.data.successGroupList;var t=!1;e.forEach(function(e){var n="".concat(k.CONV_GROUP).concat(e.groupID);a._convMap.has(n)&&(je((n=a._convMap.get(n)).groupProfile,e,[],[null,void 0,"",0,NaN]),!n.subType&&e.type&&(n.subType=e.type),t=!0)}),t&&a.emitConvUpdate()})}},{key:"_doUpdateUserProfile",value:function(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t,this.emitConvUpdate())}},{key:"_getConvOptions",value:function(e){var t=this,n=[],s=(e=e.filter(function(e){var n=e.type;return 1===n&&!t._isNonExistentAccount(e.userID)||2===n}),this.getMyUserID());return e=e.map(function(e){var i;return Ze(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type?(i={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar},n.push(i),{conversationID:"".concat(k.CONV_C2C).concat(e.userID),type:k.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?t._amendLayersOverLimitProp(e.lastMsg.elements[0].content,e.lastMsg.elements[0].type):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===s&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},unreadCount:0,userProfile:new ds(i),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:kt(e.standardMark),conversationGroupList:t._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:t._transMsgRemindType(e.messageRemindType)}):{conversationID:"".concat(k.CONV_GROUP).concat(e.groupID),type:k.CONV_GROUP,lastMessage:_(_({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},t._patchTypeAndPayload(e)),{},{cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||"",revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null}),groupProfile:new ps({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq}),unreadCount:t._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:kt(e.standardMark),conversationGroupList:t._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:t._transMsgRemindType(e.messageRemindType)}}),0<n.length&&this.get(4).onConvProfileUpdated(n),e}},{key:"_transMsgRemindType",value:function(e){var t="";return 0===e?t=k.MSG_REMIND_ACPT_AND_NOTE:1===e?t=k.MSG_REMIND_DISCARD:2===e?t=k.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=k.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}},{key:"_computeGroupUnreadCount",value:function(e){var t;return 0<(t=(void 0===(t=e.unreadCount)?0:t)-(void 0===(e=e.noUnreadCount)?0:e))?t:0}},{key:"_patchTypeAndPayload",value:function(e){var t=(e=e.lastMsg).event,n=void 0===(n=e.elements)?[]:n;return e=void 0===(e=e.groupTips)?{}:e,Ze(void 0===t?void 0:t)||Ue(e)?{type:n[0]?n[0].type:null,payload:n[0]?this._amendLayersOverLimitProp(n[0].content,n[0].type):null}:((t=new $n(e)).setElement({type:k.MSG_GRP_TIP,content:_(_({},e.elements),{},{groupProfile:e.groupProfile})}),n=JSON.parse(JSON.stringify(t.payload)),t=null,{type:k.MSG_GRP_TIP,payload:n})}},{key:"_amendLayersOverLimitProp",value:function(e,t){var n=this.getFileDownloadProxy(),s=this.getDownloadFileAuthKey(),i=this.get(17).getFileDNList(),a=e.layersOverLimit,o=null;return t===k.MSG_IMAGE&&(o=new Pn(e,n,s,i)),t===k.MSG_VIDEO&&(o=new Hn(e,n,s,i)),t===k.MSG_SOUND&&(o=new bn(e,n,s,i)),t===k.MSG_FILE&&((o=new qn(e,n,s,i)).content.url=void 0),0===a?e.layersOverLimit=!1:1===a&&(e.layersOverLimit=!0),o&&Object.assign(e,o.content),e}},{key:"getLocalMessageList",value:function(e){return this._msgListHandler.getLocalMsgList(e)}},{key:"deleteLocalMessage",value:function(e){e instanceof $n&&this._msgListHandler.remove(e)}},{key:"onConvDeleted",value:function(e){Ve(e)&&(e=e.map(function(e){var t=e.type,n=e.userID;return e=e.groupID,1===t?"".concat(k.CONV_C2C).concat(n):2===t?"".concat(k.CONV_GROUP).concat(e):void 0}),Ee.l("".concat(this._n,".onConvDeleted convIDList:").concat(e)),this.deleteLocalConvList(e))}},{key:"onConvPinnedStatus",value:function(e,t){var n,s=this;Ve(e)&&(n=!1,e.forEach(function(e){var i,a=e.type,o=e.userID;e=e.groupID,1===a?i=s.getLocalConversation("".concat(k.CONV_C2C).concat(o)):2===a&&(i=s.getLocalConversation("".concat(k.CONV_GROUP).concat(e))),i&&(Ee.l("".concat(s._n,".onConvPinnedStatus convID:").concat(i.conversationID," localPinned:").concat(i.isPinned," remotePinned:").concat(t)),t?i.isPinned||(i.isPinned=!0,n=!0):i.isPinned&&(i.isPinned=!1,n=!0))}),n)&&this._sortConvListAndEmitEvent()}},{key:"getMessageList",value:function(e){var t=this,n=e.conversationID,s=e.nextReqMessageID,i=(e=e.count,"".concat(this._n,".getMessageList")),a="";if((r=this.getLocalConversation(n))&&r.groupProfile&&(a=r.groupProfile.type),rt(a))return Ee.l("".concat(i," not available in ").concat(a,". convID:").concat(n)),$t({messageList:[],nextReqMessageID:"",isCompleted:!0});(Ze(e)||15<e)&&(e=15),s||this._isMeInCommunity(n)||this.clearMemMsg(n);var o=this._computeRemainingCount({conversationID:n,nextReqMessageID:s}),r=this._completedMap.has(n);return Ee.l("".concat(i," convID:").concat(n," isEverCleared:").concat(this._isEverCleared(n)," nextReqMessageID:").concat(s)+" remainingCount:".concat(o," count:").concat(e," isCompleted:").concat(r)),this._needGetHistory({conversationID:n,remainingCount:o,count:e})?this.getHistoryMessages({conversationID:n,nextReqMessageID:s,count:20}).then(function(e){var s=e.nextReqID,a=e.storedMessageList,r=e.assembledMessageList,c=(e=e.isPullingCompleted,t._completedMap.has(n)),u=a,l=(0<o&&(u=t._msgListHandler.getLocalMsgList(n).slice(0,a.length+o)),{nextReqMessageID:void 0,messageList:void 0,isCompleted:void 0});return t._isEverCleared(n)?(l.nextReqMessageID=s,l.messageList=r,l.isCompleted=e):(l.nextReqMessageID=c?"":s,l.messageList=u,l.isCompleted=c),t.getStreamMessageInHistory(l.messageList),a=l.messageList.filter(function(e){return e.isRevoked})||[],r=l.messageList.map(function(e){return e.sequence}),Ee.l("".concat(i," ret.nextReqMessageID:").concat(l.nextReqMessageID," ret.isCompleted:").concat(l.isCompleted," sequenceList:"),r),Ve(a)&&0!==a.length?t.updateRevokerInfo(a).then(function(e){return e.forEach(function(e){var t=e.revokerInfo;l.messageList=l.messageList.map(function(n){return n.ID===e.ID&&t&&(n.revokeReason=t.reason||"",n.revokerInfo={userID:t.revoker||n.revoker,nick:t.nick,avatar:t.avatar}),n})}),zt(l)}):zt(l)}):(this.modifyMessageList(n),$t(a=this._getMsgListFromMem({conversationID:n,nextReqMessageID:s,count:e})))}},{key:"_isEverCleared",value:function(e){return this._everClearedMap.has(e)}},{key:"_getMsgListFromMem",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,s=(e=e.count,"".concat(this._n,"._getMsgListFromMem")),i=this._msgListHandler.getLocalMsgList(t),a=i.length,o=lt(t),r=0,c={isCompleted:!1,nextReqMessageID:"",messageList:[]};return n?(r=o?i.findIndex(function(e){return e.ID===n}):i.findIndex(function(e){return e.sequence+""===n}))>e?(c.messageList=i.slice(r-e,r),c.nextReqMessageID=o?i[r-e].ID:i[r-e].sequence+""):(c.messageList=i.slice(0,r),c.isCompleted=!0):e<a?(c.messageList=i.slice(r=a-e,a),c.nextReqMessageID=o?i[r].ID:i[r].sequence+""):(c.messageList=i.slice(0,a),c.isCompleted=!0),e=c.messageList.map(function(e){return e.sequence}),Ee.l("".concat(s," convID:").concat(t)+" ret.nextReqMessageID:".concat(c.nextReqMessageID," ret.isCompleted:").concat(c.isCompleted," sequenceList:").concat(e)),c}},{key:"getMessageListHopping",value:function(e){var t,n,s=e.conversationID,i=e.sequence,a=e.time,o=e.count;return e=void 0===(e=e.direction)?0:e,(Ze(o)||15<o)&&(o=15),s.startsWith(k.CONV_C2C)?(t=this.get(6),n=s.replace(k.CONV_C2C,""),t.getRoamingMessagesHopping({peerAccount:n,time:a,count:o,direction:e})):s.startsWith(k.CONV_GROUP)?(t=this.get(7),n=s.replace(k.CONV_GROUP,""),t.getRoamingMessagesHopping({groupID:n,sequence:i,count:o,direction:e})):void 0}},{key:"_computeRemainingCount",value:function(e){var t,n=e.conversationID,s=e.nextReqMessageID,i=(e=this._msgListHandler.getLocalMsgList(n)).length;return Ee.l("".concat(this._n,"._computeRemainingCount convID:").concat(n," nextReqMessageID:").concat(s," length:").concat(i)),s?(t=0,lt(n)?t=e.findIndex(function(e){return e.ID===s}):dt(n)&&(t=-1!==s.indexOf("-")?e.findIndex(function(e){return e.ID===s}):e.findIndex(function(e){return e.sequence+""===s})),-1===t?0:t):i}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,n=e.remainingCount,s=(e=e.count,this.getLocalConversation(t)),i="";return s&&s.groupProfile&&(i=s.groupProfile.type),!(ht(t)||rt(i)||!this._isEverCleared(t)&&(s=n<=e&&!this._completedMap.has(t),Ee.l("".concat(this._n,"._needGetHistory convID:").concat(t," ret:").concat(s)),!s))}},{key:"_isTopicConv",value:function(e){return ut(e=e.replace(k.CONV_GROUP,""))}},{key:"getHistoryMessages",value:function(e){var t,n,s,i,a,o,r=e.conversationID,c=e.count;return e=e.nextReqMessageID,r===k.CONV_SYSTEM?$t():(c=20<c?20:15,t=null,lt(r)?(o=0,n="",s=!1,a=this._roamingMsgKeyAndTimeMap.has(r),e&&(s=!0,a?(o=this._roamingMsgKeyAndTimeMap.get(r).lastMessageTime,n=this._roamingMsgKeyAndTimeMap.get(r).messageKey):(i=this._msgListHandler.findMessage(e))&&(o=i.time,Ee.l("".concat(this._n,".getHistoryMessages convID:").concat(r," isRelayInfoExisted:").concat(a," lastMessageTime:").concat(o)))),(t=this.get(6)).getRoamingMessage({conversationID:r,peerAccount:r.replace(k.CONV_C2C,""),count:c,lastMessageTime:s?o:0,messageKey:s?n:""})):dt(r)?(t=this.get(7))?(i=r.replace(k.CONV_GROUP,""),a=null,this._convMap.has(r)&&!ut(i)&&(a=this._convMap.get(r).lastMessage),o=0,e?o=Number(e):a&&(o=a.lastSequence),t.getRoamingMessage({conversationID:r,groupID:i,count:c,sequence:o})):Jt({code:un.NO_MODULE}):$t())}},{key:"patchConvLastMessage",value:function(e){var t,n,s=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=this.getLocalConversation(e);i&&(t=(n=i.lastMessage).messageForShow,n=n.payload,Ue(t)||Ue(n)||s)&&0!==(t=this._msgListHandler.getLocalMsgList(e)).length&&(n=t[t.length-1],Ee.l("".concat(this._n,".patchConvLastMessage bForceUpdate:").concat(s," convID:").concat(e," payload:"),n.payload),i.updateLastMessage(n))}},{key:"onRoamingMessage",value:function(){var e,t,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],s=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],i=3<arguments.length?arguments[3]:void 0,a=(c=1<arguments.length?arguments[1]:void 0).startsWith(k.CONV_C2C)?k.CONV_C2C:k.CONV_GROUP,o=null,r=[],c=[],u=0,l=n.length,d=a===k.CONV_GROUP,h=this.getFileDownloadProxy(),g=this.getDownloadFileAuthKey(),p=Ve(i),f=this.get(17).getFileDNList(),m=function(){d?--u:++u},v=function(){return d?l<=u:u<l};for(u=d?n.length-1:0,l=d?0:n.length;v();m())1!==n[u].isPlaceMessage&&((o=new $n(n[u])).to=n[u].to,a!==k.CONV_GROUP||Ze(n[u].topicID)||(o.to=n[u].topicID),o.isSystemMessage=!!n[u].isSystemMessage,o.conversationType=a,e=4===n[u].event?{type:k.MSG_GRP_TIP,content:_(_({},n[u].elements),{},{groupProfile:n[u].groupProfile})}:n[u].elements,d||o.setNickAndAvatar({nick:n[u].nick,avatar:n[u].avatar}),Ue(e)?((t=new kn("emptyMessageBody")).setMessage("from:".concat(o.from," to:").concat(o.to," sequence:").concat(o.sequence," event:").concat(n[u].event)),t.setLevel("warning").end()):(o.setElement(e,h,g,f),o.reInitialize(this.getMyUserID()),r.push(o),p&&i.push(o)));return m=v=null,s?(this._msgListHandler.unshift(r,c),r=null,c):r}},{key:"findMessage",value:function(e){return this._msgListHandler.findMessage(e)}},{key:"_isMeInCommunity",value:function(e){var t=!0;return this._isTopicConv(e)&&(e=St(e.replace(k.CONV_GROUP,"")),this.get(7).hasLocalGroup(e)||(t=!1,Ee.l("".concat(this._n,"._isMeInCommunity groupID:").concat(e," ret:").concat(t)))),t}},{key:"deleteTopicRoamingInfo",value:function(e){var t=this;ct({groupID:e})&&this._msgListHandler.getTopicConvIDList(e).forEach(function(e){t.clearMemMsg(e)})}},{key:"deleteGroupRoamingInfo",value:function(e){e="".concat(k.CONV_GROUP).concat(e),0<this._msgListHandler.getLocalMsgList(e).length&&this.clearMemMsg(e)}},{key:"setMessageRead",value:function(e){var t=e.conversationID,n=this.getLocalConversation(t);if(e="".concat(this._n,".setMessageRead"),Ee.l("".concat(e," convID:").concat(t," unreadCount:").concat(n?n.unreadCount:0)),!n)return $t();if(n.type!==k.CONV_GROUP&&n.type!==k.CONV_TOPIC||Ue(n.groupAtInfoList)||this.deleteGroupAtTips(t),0===n.unreadCount)return $t();var s=this._msgListHandler.getLocalLastMsg(t),i=n.lastMessage.lastTime,a=(i<(a=this._msgListHandler.getLocalMaxTime(t))&&(Ee.l("".concat(e," update lastMessageTime from ").concat(i," to ").concat(a)),i=a),this._msgListHandler.getLocalMaxSeq(t)),o=n.lastMessage.lastSequence,r=(o<a&&(Ee.l("".concat(e," update lastMessageSeq from ").concat(o," to ").concat(a)),o=a),n.type===k.CONV_TOPIC&&Ze(s)&&(e=this.get(10),s=St(a=t.replace(k.CONV_GROUP,"")),e=e.getLocalTopic(s,a))&&(o=e.nextMessageSeq-1),null);switch(n.type){case k.CONV_C2C:return(r=this.get(6))?r.setMessageRead({conversationID:t,lastMessageTime:i}):Jt({code:un.NO_MODULE});case k.CONV_GROUP:case k.CONV_TOPIC:return(r=this.get(7))?r.setMessageRead({conversationID:t,lastMessageSeq:o}):Jt({code:un.NO_MODULE});case k.CONV_SYSTEM:return n.unreadCount=0,this.emitConvUpdate(!0,!1),$t();default:return $t()}}},{key:"setAllMessageRead",value:function(){var e,t=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},s="setAllMessageRead",i="".concat(this._n,".").concat(s),a=(n.scope||(n.scope=k.READ_ALL_MSG),Ee.l("".concat(i," options:"),n),this._createSetAllMessageReadPack(n));return 0===a.readAllC2CMessage&&0===a.groupMessageReadInfoList.length?$t():(e=new kn(s),this.req({P:dn.SET_ALL_MSG_READ,data:a}).then(function(s){return s=s.data,s=t._handleAllMsgRead(s),e.setMessage("scope:".concat(n.scope," failureGroups:").concat(JSON.stringify(s))).end(),$t()}).catch(function(t){return e.setError(t).end(),Ee.w("".concat(i," failed. error:"),t),Jt({code:t&&t.code?t.code:un.MSG_UNREAD_ALL_FAIL,message:t&&t.message?t.message:void 0})}))}},{key:"setConvCustomData",value:function(e){return this._convGroupHandler.setConvCustomData(e)}},{key:"markConv",value:function(e){return this._convGroupHandler.markConv(e)}},{key:"getConvGroupList",value:function(){return this._convGroupHandler.getLocalConvGroupList()}},{key:"createConvGroup",value:function(e){return this._convGroupHandler.createConvGroup(e)}},{key:"deleteConvGroup",value:function(e){return this._convGroupHandler.deleteConvGroup(e)}},{key:"renameConvGroup",value:function(e){return this._convGroupHandler.renameConvGroup(e)}},{key:"addConvsToGroup",value:function(e){return this._convGroupHandler.addConvsToGroup(e)}},{key:"deleteConvsFromGroup",value:function(e){return this._convGroupHandler.deleteConvsFromGroup(e)}},{key:"onConvMarkUpdated",value:function(e){this._convGroupHandler.onConvMarkUpdated(e)}},{key:"onConvGroupCreated",value:function(e){this._convGroupHandler.onConvGroupCreated(e)}},{key:"onConvGroupDeleted",value:function(e){this._convGroupHandler.onConvGroupDeleted(e)}},{key:"onConvGroupNameUpdated",value:function(e){this._convGroupHandler.onConvGroupNameUpdated(e)}},{key:"onConvInGroupUpdated",value:function(e){this._convGroupHandler.onConvInGroupUpdated(e)}},{key:"onConvAddedToOrDeletedFromGroup",value:function(e){this._convGroupHandler.onConvAddedToOrDeletedFromGroup(e)}},{key:"_getConvLastMessageSeq",value:function(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID);return e=e.lastMessage.lastSequence,t&&e<t.sequence?t.sequence:e}},{key:"_getConvLastMessageTime",value:function(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID);return e=e.lastMessage.lastTime,t&&e<t.time?t.time:e}},{key:"_createSetAllMessageReadPack",value:function(e){var t,n={readAllC2CMessage:0,groupMessageReadInfoList:[]},s=e.scope,i=r(this._convMap);try{for(i.s();!(t=i.n()).done;){var a,o=v(t.value,2)[1];if(0<o.unreadCount)if(o.type===k.CONV_C2C&&0===n.readAllC2CMessage){if(s===k.READ_ALL_MSG)n.readAllC2CMessage=1;else if(s===k.READ_ALL_C2C_MSG){n.readAllC2CMessage=1;break}}else o.type!==k.CONV_GROUP||s!==k.READ_ALL_GROUP_MSG&&s!==k.READ_ALL_MSG||(a=this._getConvLastMessageSeq(o),n.groupMessageReadInfoList.push({groupID:o.groupProfile.groupID,messageSequence:a}))}}catch(e){i.e(e)}finally{i.f()}return n}},{key:"onPushedAllMessageRead",value:function(e){this._handleAllMsgRead(e)}},{key:"_handleAllMsgRead",value:function(e){var t=e.groupMessageReadInfoList;return e=e.readAllC2CMessage,t=this._parseGroupReadInfo(t),1<=this._updateAllConvUnreadCount({readAllC2CMessage:e})&&this.emitConvUpdate(!0,!1),t}},{key:"_parseGroupReadInfo",value:function(e){var t=[];if(e&&e.length)for(var n=0,s=e.length;n<s;n++){var i=(r=e[n]).groupID,a=r.sequence,o=r.retCode,r=r.lastMessageSeq;Ze(o)?this._remoteGroupReadSeqMap.set(i,r):(this._remoteGroupReadSeqMap.set(i,a),0!==o&&t.push("".concat(i,"-").concat(a,"-").concat(o)))}return t}},{key:"_updateAllConvUnreadCount",value:function(e){var t,n=e.readAllC2CMessage,s=0,i=r(this._convMap);try{for(i.s();!(t=i.n()).done;){var a,o,c,u,l=v(t.value,2),d=l[0],h=l[1];1<=h.unreadCount&&(1===n&&h.type===k.CONV_C2C?(a=this._getConvLastMessageTime(h),this.updateIsReadAfterReadReport({conversationID:d,lastMessageTime:a})):h.type===k.CONV_GROUP&&(o=d.replace(k.CONV_GROUP,""),this._remoteGroupReadSeqMap.has(o))&&(c=this._remoteGroupReadSeqMap.get(o),u=this._getConvLastMessageSeq(h),this.updateIsReadAfterReadReport({conversationID:d,remoteReadSequence:c}),c<=u)&&this._remoteGroupReadSeqMap.delete(o),this.updateUnreadCount(d,!1))&&(s+=1)}}catch(e){i.e(e)}finally{i.f()}return s}},{key:"isRemoteRead",value:function(e){var t,n=e.conversationID,s=(e=e.sequence,n.replace(k.CONV_GROUP,"")),i=!1;return this._remoteGroupReadSeqMap.has(s)&&(e<=(t=this._remoteGroupReadSeqMap.get(s))&&(i=!0,Ee.l("".concat(this._n,".isRemoteRead convID:").concat(n," msgSeq:").concat(e," remoteReadSeq:").concat(t))),t+10<=e)&&this._remoteGroupReadSeqMap.delete(s),i}},{key:"updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,n=e.lastMessageSeq,s=e.lastMessageTime,i=this._msgListHandler.getLocalMsgList(t);if(0!==i.length)for(var a,o=i.length-1;0<=o;o--)if(a=i[o],!(s&&a.time>s||n&&a.sequence>n)){if("in"===a.flow&&a.isRead)break;a.setIsRead(!0)}}},{key:"updateUnreadCount",value:function(e){var t,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],s=!1,i=this.getLocalConversation(e),a=this._msgListHandler.getLocalMsgList(e);if(i)return(t=i.unreadCount)!==(a=a.filter(function(e){return!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted}).length)&&(i.unreadCount=a,s=!0,Ee.l("".concat(this._n,".updateUnreadCount from ").concat(t," to ").concat(a,", convID:").concat(e)),!0===n)&&this.emitConvUpdate(!0,!1),s&&i.type===k.CONV_TOPIC&&(t=i.unreadCount,a=this.get(10),n=e.replace(k.CONV_GROUP,""),a.onUnreadCountUpdatedFromConv(n,t)),s}},{key:"clearGroupAtInfoList",value:function(e){var t,n=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],s=this.getLocalConversation(e);s&&0<s.groupAtInfoList.length&&(s.clearGroupAtInfoList(),Ee.l("".concat(this._n,".clearGroupAtInfoList convID:").concat(e)),s.type===k.CONV_TOPIC&&(s=s.groupAtInfoList,t=this.get(10),e=e.replace(k.CONV_GROUP,""),t.onAtInfoUpdated({topicID:e,groupAtInfoList:s})),!0===n)&&this.emitConvUpdate(!0,!1)}},{key:"updateReadReceiptInfo",value:function(e){var t,n,s,i=this,a=void 0===(r=e.userID)?void 0:r,o=void 0===(r=e.groupID)?void 0:r,r=e.readReceiptList,c=void 0===(e=e.timestamp)?0:e;Ue(r)||(t=[],Ze(a)?Ze(o)||(n="".concat(k.CONV_GROUP).concat(o),r.forEach(function(e){var s=e.tinyID,a=e.clientTime,r=e.random,c=e.readCount;e=e.unreadCount,s="".concat(s,"-").concat(a,"-").concat(r),a=i._msgListHandler.getLocalMsg(n,s)||i._msgListHandler.getHoppingMsg(n,s),r={groupID:o,messageID:s,readCount:0,unreadCount:0},a&&(Ge(c)&&(a.readReceiptInfo.readCount=c,r.readCount=c),Ge(e)&&(a.readReceiptInfo.unreadCount=e,r.unreadCount=e),t.push(r))})):(s="".concat(k.CONV_C2C).concat(a),r.forEach(function(e){var n=e.tinyID,o=e.clientTime;e=e.random,n="".concat(n,"-").concat(o,"-").concat(e),(o=i._msgListHandler.getLocalMsg(s,n)||i._msgListHandler.getHoppingMsg(s,n))&&!o.readReceiptInfo.isPeerRead&&(o.readReceiptInfo.isPeerRead=!0,o.readReceiptInfo.timestamp=c,t.push({userID:a,messageID:n,isPeerRead:!0,timestamp:c}))})),0<t.length&&this.emitOEvt(E.MESSAGE_READ_RECEIPT_RECEIVED,t))}},{key:"updateIsRead",value:function(e){var t=this.getLocalConversation(e),n=this.getLocalMessageList(e);if(t&&0!==n.length&&!ht(t.type)){for(var s=[],i=0,a=n.length;i<a;i++)"in"!==n[i].flow?"out"!==n[i].flow||n[i].isRead||n[i].setIsRead(!0):s.push(n[i]);var o=0;o=t.type===k.CONV_C2C?(e=s.slice(-t.unreadCount).filter(function(e){return e.isRevoked}).length,s.length-t.unreadCount-e):s.length-t.unreadCount;for(var r=0;r<o&&!s[r].isRead;r++)s[r].setIsRead(!0)}}},{key:"deleteGroupAtTips",value:function(e){var t,n,s,i=this,a="".concat(this._n,".deleteGroupAtTips"),o=(Ee.l("".concat(a)),this._convMap.get(e));return o&&0!==(t=o.groupAtInfoList).length?(o=void 0,e.startsWith(k.CONV_GROUP)&&(o=e.replace(k.CONV_GROUP,"")),n=y(t),(ct({groupID:o})||ut(o))&&0===(n=t.filter(function(e){return!e.atTypeArray.includes(k.CONV_AT_ALL)})).length?(this.clearGroupAtInfoList(e,!1),Promise.resolve()):(s=this.getMyUserID(),this.req({P:dn.DEL_GROUP_AT_TIPS,data:{messageListToDelete:n.map(function(e){return{from:e.from,to:s,messageSeq:e.__sequence,messageRandom:e.__random,groupID:Ze(e.topicID)?e.groupID:e.topicID}})}}).then(function(){return Ee.l("".concat(a," ok. count:").concat(t.length)),i.clearGroupAtInfoList(e,!1),Promise.resolve()}).catch(function(e){return Ee.e("".concat(a," failed. error:"),e),Jt(e)}))):Promise.resolve()}},{key:"appendToMessageList",value:function(e){return this._msgListHandler.pushIn(e)}},{key:"setMessageRandom",value:function(e){this._sll.set(e.random)}},{key:"deleteMessageRandom",value:function(e){this._sll.delete(e.random)}},{key:"pushIntoMessageList",value:function(e,t,n){return!(!this._msgListHandler.pushIn(t,n)||this._sll.has(t.random)&&!n||(e.push(t),0))}},{key:"revoke",value:function(e,t,n){return this._msgListHandler.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)}},{key:"updateMsgIsPeerReadProp",value:function(e,t){var n;e.startsWith(k.CONV_C2C)&&0<t&&(0<(n=this._msgListHandler.updateMsgIsPeerReadProp(e,t)).length&&this.emitOEvt(E.MESSAGE_READ_BY_PEER,n),this._convMap.has(e))&&!Ue(n=this._convMap.get(e).lastMessage)&&n.fromAccount===this.getMyUserID()&&n.lastTime<=t&&!n.isPeerRead&&(n.isPeerRead=!0,this.emitConvUpdate(!0,!1))}},{key:"updateMsgIsModifiedProp",value:function(e){this._msgListHandler.updateMsgIsModifiedProp(e)}},{key:"setCompleted",value:function(e){Ee.l("".concat(this._n,".setCompleted convID:").concat(e)),this._completedMap.set(e,!0)}},{key:"updateRoamingMsgKeyAndTime",value:function(e,t,n){this._roamingMsgKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:n})}},{key:"getConvList",value:function(e){var t,n=this,s="".concat(this._n,".").concat("getConvList"),i="pagingStatus:".concat(this._pagingStatus,", local conversation count:").concat(this._convMap.size,", options:").concat(JSON.stringify(e));return Ee.l("".concat(s,". ").concat(i)),this._pagingStatus===nn?((t=new kn("getConvList")).setMessage(i),this.syncConvList().then(function(){return t.end(),zt({conversationList:n._getConvList(e),isSyncCompleted:n._isSyncCompleted()})}).catch(function(e){return t.setError(e).end(),Ee.e("".concat(s," failed. error:"),e),Jt(e)})):(i=this._getConvList(e),Ee.l("".concat(s,". returned conversation count:").concat(i.length)),$t({conversationList:i,isSyncCompleted:this._isSyncCompleted()}))}},{key:"_getConvList",value:function(e){var t,n,s,i,a,o=this;return Ze(e)?this.getLocalConvList():Ve(e)?0===e.length?[]:this.getLocalConvList().filter(function(t){return e.includes(t.conversationID)}):xe(e)?(t=e.type,n=e.markType,s=e.groupName,i=e.hasUnreadCount,a=e.hasGroupAtInfo,this.getLocalConvList().filter(function(e){return o._filterType(e,t)&&o._filterMarkType(e,n)&&o._filterGroupName(e,s)&&o._filterUnreadCount(e,i)&&o._filterGroupAtInfo(e,a)})):[]}},{key:"_filterType",value:function(e,t){return t!==k.CONV_C2C&&t!==k.CONV_GROUP||e.type===t}},{key:"_filterGroupName",value:function(e,t){return!Xe(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}},{key:"_filterMarkType",value:function(e,t){return!Ge(t)||(0===t?0===e.markList.length:e.markList.includes(t))}},{key:"_filterUnreadCount",value:function(e,t){var n=!0;return!0===t?n=1<=e.unreadCount:!1===t&&(n=0===e.unreadCount),n}},{key:"_filterGroupAtInfo",value:function(e,t){var n=!0;return!0===t?n=1<=e.groupAtInfoList.length:!1===t&&(n=0===e.groupAtInfoList.length),n}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=r(this._convMap);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2),s=n[0],i=n[1];i.type===k.CONV_C2C&&this.recordPeerReadTime(s,i.peerReadTime)}}catch(e){t.e(e)}finally{t.f()}}},{key:"_isPagingGetGroupListCompleted",value:function(){var e=this.get(7);return!e||e.isPagingGetCompleted()}},{key:"_getLocalGroupCount",value:function(){var e=this.get(7);return e?e.getLocalGroupList().length:0}},{key:"_hasLocalGroup",value:function(e){var t=this.get(7);return!!t&&t.hasLocalGroup(e.replace(k.CONV_GROUP,""))}},{key:"getConversationProfile",value:function(e){var t,n=this,s=!1;if(this._convMap.has(e)?t=this._convMap.get(e):(t=new _s({conversationID:e,type:lt(e)?k.CONV_C2C:k.CONV_GROUP},this.isIntl(),this.isUsingChatCore()),s=!0),t._isInfoCompleted||t.type===k.CONV_SYSTEM)return $t({conversation:t});if(dt(e)){if(!this.get(7))return Jt({code:un.NO_MODULE});if(!this._hasLocalGroup(e))return $t({conversation:t})}var i="".concat(this._n,".").concat("getConversationProfile"),a=new kn("getConversationProfile");return Ee.l("".concat(i,". convID:").concat(e," remark:").concat(t.remark," lastMessage:"),t.lastMessage),this._getUserOrGroupProfile(t).then(function(o){a.setMessage("convID:".concat(e," unreadCount:").concat(o.data.conversation.unreadCount)).end();var r,c=n.get(8);if(c&&t.type===k.CONV_C2C&&(r=e.replace(k.CONV_C2C,""),c.isMyFriend(r))&&(c=c.getFriendRemark(r),t.remark!==c)&&(t.remark=c,Ee.l("".concat(i,". convID:").concat(e," patch remark:").concat(t.remark))),Ee.l("".concat(i," ok. isNewConv:").concat(s," convID:").concat(e)),s){if(t.type===k.CONV_C2C)return n._onNewC2CConv([e.replace(k.CONV_C2C,"")]).then(function(){return $t({conversation:t})});if(t.type===k.CONV_GROUP)return n._onNewGroupConv([e.replace(k.CONV_GROUP,"")]).then(function(){return $t({conversation:t})})}return o}).catch(function(t){return a.setError(t).setMessage("convID:".concat(e)).end(),Ee.e("".concat(i," failed. error:"),t),Jt(t)})}},{key:"_getUserOrGroupProfile",value:function(e){var t=this;return e.type===k.CONV_C2C?this.get(4).getUserProfile({userIDList:[e.toAccount]}).then(function(n){return 0===(n=n.data).length?Jt({code:un.USER_OR_GRP_NOT_FOUND}):(e.userProfile=n[0],e._isInfoCompleted=!0,t._insertConvAfterTopmost(e),$t({conversation:e}))}):this.get(7).getGroupProfile({groupID:e.toAccount}).then(function(n){return e.groupProfile=n.data.group,e._isInfoCompleted=!0,t._insertConvAfterTopmost(e),$t({conversation:e})})}},{key:"_insertConvAfterTopmost",value:function(e){var t,n;e instanceof _s&&!this._convMap.has(e.conversationID)&&(n=(t=y(this._convMap)).findIndex(function(e){return!1===e[1].isPinned}),t.splice(n,0,[e.conversationID,e]),this._convMap=new Map(t),this._setStorageConvList(),this.emitConvUpdate(!0,!1))}},{key:"_onProfileUpdated",value:function(e){var t=this;e.data.forEach(function(e){var n=e.userID;n===t.getMyUserID()?t._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar}):(n=t._convMap.get("".concat(k.CONV_C2C).concat(n)))&&(n.userProfile=e)})}},{key:"_onCloudConfig",value:function(e){"0"===this.getCloudConfig("pull_on_invite")&&(this._bPullOnInvite=!1),Ee.l("".concat(this._n,"._onCloudConfig bPullOnInvite:").concat(this._bPullOnInvite))}},{key:"disableMsgPullOnInvite",value:function(){this._bPullOnInvite=!1}},{key:"_isSyncCompleted",value:function(){return this._pagingStatus===tn}},{key:"_errorLog",value:function(e,t,n,s){var i=new Error("Params validate failed."),a="".concat(this.getErrMsg("API_REFER")).concat(e);throw Ee.w("[".concat(e,"] | ").concat(t," | ").concat(this.getErrMsg(n,s),", ").concat(a)),Ee.e("[".concat(e,"] Invalid ").concat(t,": type check failed for ").concat(t,".")),i}},{key:"_isValidConvID",value:function(e){return lt(e)||dt(e)||ht(e)}},{key:"deleteConversation",value:function(e){var t=this,n="deleteConversation";return Xe(e)||Fe(e)||this._errorLog(n,"options","StringOrObjectRequiredLog"),Xe(e)?(this._isValidConvID(e)||this._errorLog(n,"options","InvalidConversationID",e),Ee.l("".concat(this._n,".").concat(n," convID:").concat(e)),this.deleteConvList({conversationIDList:[e],flag:1})):(Ve(e.conversationIDList)||this._errorLog(n,"conversationIDList","ArrayRequiredLog"),0===e.conversationIDList.length&&this._errorLog(n,"conversationIDList","NonEmptyArrayLog"),e.conversationIDList.forEach(function(e){t._isValidConvID(e)||t._errorLog(n,"conversationIDList","InvalidConversationID",e)}),"clearHistoryMessage"in e&&"boolean"!=typeof e.clearHistoryMessage&&this._errorLog(n,"clearHistoryMessage","BooleanRequiredLog"),100<e.conversationIDList.length&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConvList(e))}},{key:"deleteConvList",value:function(e){var t=void 0===(t=e.conversationIDList)?[]:t,n=void 0===(n=e.clearHistoryMessage)||n,s=void 0===(e=e.flag)?0:e,i="".concat(this._n,".").concat("deleteConvList"),a=(e="convIDList:".concat(t," clearHistoryMessage:").concat(n),Ee.l("".concat(i," ").concat(e)),new kn("deleteConvList"));return a.setMessage(e),Promise.all([this.rmLocalOnlyConvList(t),this.rmLocalAndRemoteConvList(t,n)]).then(function(e){return a.end(),0===(e=[].concat(y(e[0]),y(e[1]))).length?Jt(new cn({code:un.CONV_NOT_FOUND})):(Ee.l("".concat(i," ok")),$t(1===s?{conversationID:e[0]}:{conversationIDList:e}))}).catch(function(e){return a.setError(e).end(),Ee.e("".concat(i," failed. error:"),e),Jt(e)})}},{key:"rmLocalOnlyConvList",value:function(e){var t=this;return e.filter(function(e){var n;return!!t._convMap.has(e)&&((n=t.getLocalConversation(e).type)!==k.CONV_GROUP||t._hasLocalGroup(e)?n===k.CONV_SYSTEM&&(t.get(7).deleteGroupSystemNotice({messageList:t._msgListHandler.getLocalMsgList(e)}),t.deleteLocalConv(e),!0):(t.deleteLocalConv(e),!0))})}},{key:"rmLocalAndRemoteConvList",value:function(e,t){var n=this,s={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:t?1:0};return e.forEach(function(e){var t;n._convMap.has(e)&&((t=n.getLocalConversation(e).type)===k.CONV_C2C?s.conversationList.push({toAccount:e.replace(t,""),type:1}):t===k.CONV_GROUP&&n._hasLocalGroup(e)&&s.conversationList.push({toGroupID:e.replace(t,""),type:2}))}),0===s.conversationList.length?[]:this.req({P:dn.DEL_CONV,data:s}).then(function(e){var t=[];return 0<e.data.resultList.length&&e.data.resultList.map(function(e){0===e.code&&(e=1===e.type?"".concat(k.CONV_C2C).concat(e.to):"".concat(k.CONV_GROUP).concat(e.groupID),t.push(e))}),n.deleteLocalConvList(t),t})}},{key:"setConvDraft",value:function(e){var t=e.conversationID,n=(e=e.draftText,"".concat(this._n,".").concat("setConvDraft"));return Ee.l("".concat(n," convID:").concat(t," draftText:").concat(e)),this._convMap.has(t)?((n=this._convMap.get(t)).setDraftText(e),this.emitConvUpdate(),$t({code:0,conversation:n})):Jt({code:un.CONV_NOT_FOUND})}},{key:"clearHistoryMessage",value:function(e){var t=this,n={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._convMap.has(e))return Jt({code:un.CONV_NOT_FOUND});var s=this._convMap.get(e).type;if(s===k.CONV_C2C)n.type=1,n.toAccount=e.replace(k.CONV_C2C,"");else{if(s!==k.CONV_GROUP)return s===k.CONV_SYSTEM?(this.get(7).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(e)}),$t({conversationID:e})):Jt({code:un.CONV_UN_RECORDED_TYPE});n.type=2,n.toGroupID=e.replace(k.CONV_GROUP,"")}var i="".concat(this._n,".").concat("clearHistoryMessage"),a=new kn("clearHistoryMessage");return a.setMessage("convID:".concat(e)),Ee.l("".concat(i,". convID:").concat(e)),this.setMessageRead({conversationID:e}).then(function(){return t.req({P:dn.CLEAR_HISTORY_MSG,data:n})}).then(function(){a.end(),Ee.l("".concat(i," ok")),t.clearMemMsg(e);var n=t.getLocalConversation(e);return n&&(n.updateLastMessage(),t._sortConvListAndEmitEvent()),$t({conversationID:e})}).catch(function(e){return a.setError(e).end(),Ee.e("".concat(i," failed. error:"),e),Jt(e)})}},{key:"pinConversation",value:function(e){var t,n,s,i=this,a=e.conversationID,o=e.isPinned,r=this.getLocalConversation(a);return r&&r.isPinned===o?$t({conversationID:a}):ht(a)?(r&&(r.isPinned=o),this._sortConvListAndEmitEvent(),$t({conversationID:a})):(e=null,lt(a)?e={type:1,toAccount:a.replace(k.CONV_C2C,"")}:dt(a)&&(e={type:2,groupID:a.replace(k.CONV_GROUP,"")}),null===e?Jt({code:un.INVALID_CONV_ID}):(t="".concat(this._n,".").concat("pinConversation"),n="convID:".concat(a," isPinned:").concat(o),(s=new kn("pinConversation")).setMessage(n),Ee.l("".concat(t,". ").concat(n)),this.req({P:dn.PIN_CONV,data:{fromAccount:this.getMyUserID(),operationType:!0===o?1:2,itemList:[e]}}).then(function(){return s.end(),Ee.l("".concat(t," ok")),r?r.isPinned!==o&&(r.isPinned=o):i._convMap.set(a,new _s({conversationID:a,type:lt(a)?k.CONV_C2C:k.CONV_GROUP,isPinned:o},i.isIntl(),i.isUsingChatCore())),i._sortConvListAndEmitEvent(),zt({conversationID:a})}).catch(function(e){return s.setError(e).end(),Ee.e("".concat(t," failed. error:"),e),Jt(e)})))}},{key:"setMessageRemindType",value:function(e){return this._msgRemindHandler.set(e)}},{key:"patchMsgRemindType",value:function(e){var t=e.ID,n=e.messageRemindType,s=!1;return(t=this.getLocalConversation("".concat(e.isC2CConversation?k.CONV_C2C:k.CONV_GROUP).concat(t)))&&t.messageRemindType!==n&&(t.messageRemindType=n,s=!0),Ee.l("".concat(this._n,".patchMsgRemindType options:"),e,"ret:".concat(s)),s}},{key:"onC2CMsgRemindTypeFetched",value:function(e){var t,n=this;Ve(e)&&0<e.length&&(t=0,e.forEach(function(e){var s=e.userID;e=n._transMsgRemindType(e.muteFlag),!0===n.patchMsgRemindType({ID:s,isC2CConversation:!0,messageRemindType:e})&&(t+=1)}),Ee.l("".concat(this._n,".onC2CMsgRemindTypeFetched updateCount:").concat(t)),1<=t)&&this.emitConvUpdate(!0,!1)}},{key:"onC2CMsgRemindTypeSynced",value:function(e){var t=this,n="".concat(this._n,".onC2CMsgRemindTypeSynced");e.dataList.forEach(function(e){var s;Ue(e.muteNotificationsSync)||(s=(e=e.muteNotificationsSync).to,e=t._transMsgRemindType(e.muteFlag),t.patchMsgRemindType({ID:s,isC2CConversation:!(s=0),messageRemindType:e})&&(s+=1),Ee.l("".concat(n," updateCount:").concat(s)),1<=s&&t.emitConvUpdate(!0,!1))})}},{key:"onGroupMsgRemindTypeUpdated",value:function(e){this._msgRemindHandler.onGroupMsgRemindTypeUpdated(e)}},{key:"deleteLocalConv",value:function(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],n=this._convMap.has(e);Ee.l("".concat(this._n,".deleteLocalConv convID:").concat(e," has:").concat(n)),n&&(this._convMap.delete(e),this._convMapForDiff.delete(e),this.clearMemMsg(e),this._setStorageConvList(!0),t)&&(n=!this._isTopicConv(e),this.emitConvUpdate(n,!1))}},{key:"pullMsgOnInvite",value:function(e){var t,n,s,i,a,o=this,r=this.get(7);r&&(t="".concat(this._n,".pullMsgOnInvite"),Ee.l("".concat(t," flag:").concat(this._bPullOnInvite)),this._bPullOnInvite?(a=this.getLocalLastMessage(e),n=this.getLocalSecondLastMessage(e),i=s=1,a&&(s=a.sequence),n&&(i=n.sequence),a=r.getGroupRemoteLastSeq(e.replace(k.CONV_GROUP,"")),Ee.l("".concat(t," convID:").concat(e," localLastSeq:").concat(s," localSecondLastSeq:").concat(i," remoteLastSeq:").concat(a)),this.clearMemMsg(e),1<s-i?this._recursiveGetMsgList([],e,!1,s,i):1<a-s&&this._recursiveGetMsgList([],e,!0,a,s)):this.getMessageList({conversationID:e,count:1}).then(function(n){var s=o.hasLocalConversation(e);Ee.l("".concat(t," convID:").concat(e," has:").concat(s)),s?o.patchConvLastMessage(e,!0):o.getConversationProfile(e).then(function(){o.patchConvLastMessage(e,!0)})}))}},{key:"_recursiveGetMsgList",value:function(e,t,n,s,i,a){var o=this;this.getMessageList({conversationID:t,nextReqMessageID:a}).then(function(a){var r=(a=a.data).messageList,c=a.isCompleted,u=(a=a.nextReqMessageID,r.filter(function(e){return n?e.sequence>i&&e.sequence<=s:e.sequence>i&&e.sequence<s}));e.unshift.apply(e,y(u)),!c&&0<r.length&&r[0].sequence>i&&e.length<60?o._recursiveGetMsgList(e,t,n,s,i,a):o._emitMsgReceived(t,e)})}},{key:"_emitMsgReceived",value:function(e,t){var n,s,i=this;0<t.length&&(t=t.filter(function(e,t,n){return t===n.findIndex(function(t){return t.sequence===e.sequence})}),n=this.hasLocalConversation(e),s=t.map(function(e){return e.sequence}),Ee.l("".concat(this._n,"._emitMsgReceived convID:").concat(e," has:").concat(n," count:").concat(s.length," sequenceList:"),s),this.emitOEvt(E.MESSAGE_RECEIVED,t),n?this.patchConvLastMessage(e,!0):this.getConversationProfile(e).then(function(){i.patchConvLastMessage(e,!0)}))}},{key:"deleteLocalConvList",value:function(e){var t=this,n=!1;e.forEach(function(e){t._convMap.has(e)&&(t.deleteLocalConv(e,!1),n=!0)}),Ee.l("".concat(this._n,".deleteLocalConvList convID:").concat(e," isConvIDExisted:").concat(n)),n&&this.emitConvUpdate(!0,!1)}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this._msgListHandler.hasLocalMsg(e.conversationID,e.ID)&&!this._sll.has(e.random))}},{key:"modifyMessageList",value:function(e){var t,n;e.startsWith(k.CONV_C2C)&&this._convMap.has(e)&&(n=this._convMap.get(e),t=Date.now(),this._msgListHandler.modifyMsgSentByPeer({conversationID:e,latestNick:n.userProfile.nick,latestAvatar:n.userProfile.avatar}),n=this.get(4).getNickAndAvatarByUserID(this.getMyUserID()),this._msgListHandler.modifyMsgSentByMe({conversationID:e,latestNick:n.nick,latestAvatar:n.avatar}),Ee.l("".concat(this._n,".modifyMessageList convID:").concat(e," cost:").concat(Ot(t))))}},{key:"updateUserProfileSpecifiedKey",value:function(e){Ee.l("".concat(this._n,".updateUserProfileSpecifiedKey options:"),e);var t=e.conversationID,n=e.nick;e=e.avatar,this._convMap.has(t)&&(t=this._convMap.get(t).userProfile,Xe(n)&&t.nick!==n&&(t.nick=n),Xe(e)&&t.avatar!==e&&(t.avatar=e),this.emitConvUpdate(!0,!1))}},{key:"_onMyProfileModified",value:function(e){var t=this,n=this.getLocalConvList(),s=Date.now();n.forEach(function(n){t.modifyMessageSentByMe(_({conversationID:n.conversationID},e))}),Ee.l("".concat(this._n,"._onMyProfileModified. modify all messages sent by me, cost:").concat(Ot(s)))}},{key:"modifyMessageSentByMe",value:function(e){this._msgListHandler.modifyMsgSentByMe(e)}},{key:"getLatestMessageSentByMe",value:function(e){return this._msgListHandler.getLatestMsgSentByMe(e)}},{key:"modifyMessageSentByPeer",value:function(e){this._msgListHandler.modifyMsgSentByPeer(e)}},{key:"getLatestMessageSentByPeer",value:function(e){return this._msgListHandler.getLatestMsgSentByPeer(e)}},{key:"pushIntoNoticeResult",value:function(e,t){return!(!this._msgListHandler.pushIn(t)||this._sll.has(t.random)||(e.push(t),0))}},{key:"getLocalLastMessage",value:function(e){return this._msgListHandler.getLocalLastMsg(e)}},{key:"getLocalSecondLastMessage",value:function(e){return this._msgListHandler.getLocalSecondLastMsg(e)}},{key:"checkAndPatchRemark",value:function(){var e,t,n=this.get(8);0!==this._convMap.size&&n&&0!==(e=y(this._convMap.values()).filter(function(e){return e.type===k.CONV_C2C})).length&&(t=0,e.forEach(function(e){var s=e.conversationID.replace(k.CONV_C2C,"");n.isMyFriend(s)&&(s=n.getFriendRemark(s),e.remark!==s)&&(e.remark=s,t+=1)}),Ee.l("".concat(this._n,".checkAndPatchRemark. c2cConvCount:").concat(e.length," patchedCount:").concat(t)),0<t)&&this.emitConvUpdate(!0,!1)}},{key:"updateTopicConversation",value:function(e){this._updateLocalConvList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}},{key:"sendReadReceipt",value:function(e){var t=e[0],n=null;return t.conversationType===k.CONV_C2C?n=this._m.get(6):t.conversationType===k.CONV_GROUP&&(n=this._m.get(7)),n?n.sendReadReceipt(e):Jt({code:un.NO_MODULE})}},{key:"getReadReceiptList",value:function(e){var t=e[0],n=null;return t.conversationType===k.CONV_C2C?n=this._m.get(6):t.conversationType===k.CONV_GROUP&&(n=this._m.get(7)),n?n.getReadReceiptList(e):Jt({code:un.NO_MODULE})}},{key:"getLastMessageTime",value:function(e){return(e=this.getLocalConversation(e))?e.lastMessage.lastTime:0}},{key:"getTotalUnreadCount",value:function(){var e=this.getLocalConvList(),t=0;return e.forEach(function(e){e.type===k.CONV_SYSTEM||""!==e.messageRemindType&&e.messageRemindType!==k.MSG_REMIND_ACPT_AND_NOTE||(t+=e.unreadCount)}),t}},{key:"onTotalUnreadCountUpdate",value:function(){var e=this.getTotalUnreadCount();this._convTotalUnreadCount!==e&&(Ee.l("".concat(this._n,".onTotalUnreadCountUpdate from ").concat(this._convTotalUnreadCount," to ").concat(e)),this._convTotalUnreadCount=e,this.emitOEvt(E.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}},{key:"_isConvNeedShow",value:function(e){var t,n;return e=this.getLocalConversation(e),!(!Ze(e)&&(t=e.type===k.CONV_TOPIC,n=e.type===k.CONV_GROUP&&e.groupProfile.type===k.GRP_ROOM,e=e.type===k.CONV_GROUP&&e.groupProfile.type===k.GRP_LIVE,t||n||e))}},{key:"setAllRcvMsgOpt",value:function(e){return this._msgRemindHandler.setAllRcvMsgOpt(e)}},{key:"getAllRcvMsgOpt",value:function(){return this._msgRemindHandler.getAllRcvMsgOpt()}},{key:"onAllRcvMsgOptNotify",value:function(e){this._msgRemindHandler.onAllRcvMsgOptNotify(e)}},{key:"clearUnreadCount",value:function(e){(e=this.getLocalConversation(e))&&0<e.unreadCount&&(e.unreadCount=0,this.emitConvUpdate(!0,!1))}},{key:"storeHoppingMessageList",value:function(e){this._msgListHandler.storeHoppingMsgList(e),this.getStreamMessageInHistory(e)}},{key:"clearMemMsg",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];Ee.l("".concat(this._n,".clearMemMsg convID:").concat(e," isOverLimit:").concat(t)),this._msgListHandler.removeByConvID(e),this._completedMap.delete(e),this._roamingMsgKeyAndTimeMap.delete(e),this._everClearedMap.set(e,1)}},{key:"findMsgBySeq",value:function(e,t){return this._msgListHandler.findMsgBySeq(e,t)}},{key:"onPushedChunks",value:function(e){this._streamMessageHandler.onPushedChunks(e)}},{key:"getStreamMessageInHistory",value:function(e){this._streamMessageHandler.getStreamMessageInHistory(e)}},{key:"getStreamMessageBeforeEmit",value:function(e){this._streamMessageHandler.getStreamMessageBeforeEmit(e)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._setStorageConvList(!0),this._pagingStatus=Qt,this._msgListHandler.reset(),this._msgRemindHandler.reset(),this._roamingMsgKeyAndTimeMap.clear(),this._sll.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._convMap.clear(),this._pagingTs=0,this._pagingStartIdx=0,this._pagingPinnedTs=0,this._pagingPinnedStartIdx=0,this._remoteGroupReadSeqMap.clear(),this._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this._convMapForDiff.clear(),this._partialUpdatedConvMap.clear(),this._everClearedMap.clear(),this._bPullOnInvite=!0,this._convGroupHandler.reset(),this._streamMessageHandler.reset(),this.resetReady()}}])),Cs=o(function e(t){i(this,e),this._userM=t,this._n="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5},[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,n="".concat(this._n,".").concat("getUserProfile"),s=e.userIDList;e.fromAccount=this._userM.getMyAccount(),100<s.length&&(Ee.w("".concat(n," ").concat("the length of userIDList cannot exceed ".concat(100))),s.length=100);for(var i,a=[],o=[],r=0,c=s.length;r<c;r++)i=s[r],this._userM.isMyFriend(i)&&this._contains(i)?o.push(this._getProfileFromMap(i)):a.push(i);if(0===a.length)return $t(o);e.toAccount=a;var u=e.bFromGetMyProfile||!1,l=[],d=(e.toAccount.forEach(function(e){l.push({toAccount:e,standardSequence:0,customSequence:0})}),e.userItem=l,new kn("getUserProfile"));return d.setMessage(5<s.length?"userIDList.length:".concat(s.length):"userIDList:".concat(s)),this._userM.req({P:dn.GET_USER_PROFILE,data:e}).then(function(e){return d.end(),Ee.i("".concat(n," ok")),e=t._handleResponse(e).concat(o),zt(u?e[0]:e)}).catch(function(e){return d.setError(e).end(),Ee.e("".concat(n," failed. error:"),e),Jt(e)})}},{key:"getMyProfile",value:function(){var e,t=this._userM.getMyAccount(),n="".concat(this._n,".getMyProfile");return Ee.l("".concat(n," myAccount:").concat(t)),this._fill(),this._contains(t)?(e=this._getProfileFromMap(t),Ee.d("".concat(n," from cache, myProfile:").concat(JSON.stringify(e))),$t(e)):this.getUserProfile({fromAccount:t,userIDList:[t],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){var t=e.data.userProfileItem;if(!Ve(t))return[];for(var n=[],s=(e=Date.now(),0),i=t.length;s<i;s++){var a=t[s],o=a.to;"@TLS#NOT_FOUND"!==o&&""!==o&&(o=this._update(o,this._getLatestProfileFromResponse(o,a.profileItem)).latestProfile,n.push(o))}return Ee.l("".concat(this._n,"._handleResponse cost:").concat(Ot(e))),n}},{key:"_getLatestProfileFromResponse",value:function(e,t){var n={userID:e,profileCustomField:[]};if(!Ue(t))for(var s=0,i=t.length;s<i;s++)if(-1<t[s].tag.indexOf("Tag_Profile_Custom"))n.profileCustomField.push({key:t[s].tag,value:t[s].value});else switch(t[s].tag){case De.NICK:n.nick=t[s].value;break;case De.GENDER:n.gender=t[s].value;break;case De.BIRTHDAY:n.birthday=t[s].value;break;case De.LOCATION:n.location=t[s].value;break;case De.SELFSIGNATURE:n.selfSignature=t[s].value;break;case De.ALLOWTYPE:n.allowType=t[s].value;break;case De.LANGUAGE:n.language=t[s].value;break;case De.AVATAR:n.avatar=t[s].value;break;case De.MESSAGESETTINGS:n.messageSettings=t[s].value;break;case De.ADMINFORBIDTYPE:n.adminForbidType=t[s].value;break;case De.LEVEL:n.level=t[s].value;break;case De.ROLE:n.role=t[s].value;break;default:Ee.w("".concat(this._n,"._getLatestProfileFromResponse unknown tag:"),t[s].tag,t[s].value)}return n}},{key:"updateMyProfile",value:function(e){var t=this,n="".concat(this._n,".").concat("updateMyProfile");if(e.nick&&!1===this._userM.filterProfanity("nick",e))return Jt({code:un.PROFANITY_FOUND});if(e.selfSignature&&!1===this._userM.filterProfanity("selfSignature",e))return Jt({code:un.PROFANITY_FOUND});var s=new kn("updateMyProfile"),i=(s.setMessage(JSON.stringify(e)),(new ds).validate(e));if(!i.valid)return s.setCode(un.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:".concat(i.tips)).end(),Ee.e("".concat(n," info:").concat(i.tips)),Jt({code:un.UPDATE_PROFILE_INVALID_PARAM});var a,o,r=[];for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&("profileCustomField"===a?e.profileCustomField.forEach(function(e){r.push({tag:e.key,value:e.value})}):r.push({tag:De[a.toUpperCase()],value:e[a]}));return 0===r.length?(i=new cn({code:un.UPDATE_PROFILE_NO_KEY}),s.setError(i).end(),Ee.e("".concat(n," failed. error:"),i),Jt(i)):(o=this._userM.getMyAccount(),this._userM.req({P:dn.UPDATE_MY_PROFILE,data:{fromAccount:o,profileItem:r}}).then(function(i){s.end(),Ee.i("".concat(n," ok"));var a=(r=t._update(o,e)).isProfileUpdated,r=r.latestProfile;return!0===a&&t._userM.emitOEvt(E.PROFILE_UPDATED,[r]),$t(r)}).catch(function(e){return s.setError(e).end(),Ee.e("".concat(n," failed. error:"),e),Jt(e)}))}},{key:"onProfileModified",value:function(e){var t=e.dataList;if(!Ue(t)){var n=t.length;Ee.d("".concat(this._n,".onProfileModified count:").concat(n," dataList:"),e.dataList);for(var s=[],i=0;i<n;i++){var a=t[i].userID;!0===(a=this._update(a,this._getLatestProfileFromResponse(a,t[i].profileList))).isProfileUpdated&&s.push(a.latestProfile)}0<s.length&&(this._userM.emitIEvt(ss.PROFILE_UPDATED,s),this._userM.emitOEvt(E.PROFILE_UPDATED,s))}}},{key:"_fill",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),n=0,s=e.length;n<s;n++)t-e[n].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[n].userID,e[n]);Ee.l("".concat(this._n,"._fill from cache, size:").concat(this.accountProfileMap.size))}}},{key:"_update",value:function(e,t){var n,s=!1,i=Date.now();return this._contains(e)?(n=this._getProfileFromMap(e),t.profileCustomField&&!0===ot(n.profileCustomField,t.profileCustomField)&&(n.lastUpdatedTime=i,s=!0),0<je(n,t,["profileCustomField"])&&(n.lastUpdatedTime=i,s=!0)):(n=new ds(t),!this._userM.isMyFriend(e)&&e!==this._userM.getMyAccount()||(n.lastUpdatedTime=i,s=!0,this.accountProfileMap.set(e,n))),this._flush(e===this._userM.getMyAccount()),!0===s&&Ee.l("".concat(this._n,"._update account:").concat(e," isUpdated:").concat(s)),{isProfileUpdated:s,latestProfile:n}}},{key:"_flush",value:function(e){var t=y(this.accountProfileMap.values()),n=this._userM.getStorageModule();Ee.d("".concat(this._n,"._flush length:").concat(t.length," flushAtOnce:").concat(e)),n.setItem(this.TAG,t,e)}},{key:"_contains",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._userM.getStorageModule().getItem(this.TAG);return Ue(e)?[]:e}},{key:"onConvProfileUpdated",value:function(e){for(var t,n,s=[],i=0,a=e.length;i<a;i++)n=(t=e[i]).userID,this._userM.isMyFriend(n)&&(this._contains(n)?0<je(this._getProfileFromMap(n),t)&&s.push(n):s.push(t.userID));0!==s.length&&(Ee.l("".concat(this._n,".onConvProfileUpdated toAccountList:").concat(s)),this.getUserProfile({userIDList:s}))}},{key:"getNickAndAvatarByUserID",value:function(e){return this._contains(e)?{nick:(e=this._getProfileFromMap(e)).nick,avatar:e.avatar}:{nick:"",avatar:""}}},{key:"getUserNickAndAvatar",value:function(e){var t,n=this,s=y(new Set(e)),i=(Ee.l("".concat(this._n,".getUserNickAndAvatar userIDList.length:").concat(e.length," uniqueUserIDList.length:").concat(s.length)),[]);return 0===e.length?Promise.resolve(i):(e=this._createUserIDListGroup(s),t=[],e.forEach(function(e){t.push(n.getUserProfile({userIDList:e}))}),Promise.all(t).then(function(e){return e.forEach(function(e){e=e.data.map(function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}),i.push.apply(i,y(e))}),i}))}},{key:"_createUserIDListGroup",value:function(e){for(var t=[],n=0;n<e.length;)t.push(e.slice(n,n+=100));return t}},{key:"reset",value:function(){this._flush(!0),this.accountProfileMap.clear()}}]),Ts=(l(Os,sn),o(Os,[{key:"onContextUpdated",value:function(e){this._profileHandler.getMyProfile()}},{key:"mockOnNickAvatarModified",value:function(e,t){Ee.l("".concat(this._n,"._mockOnNickAvatarModified nick:").concat(e," avatar:").concat(t)),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:De.NICK,value:e},{tag:De.AVATAR,value:t}]}]})}},{key:"onProfileModified",value:function(e){this._profileHandler.onProfileModified(e)}},{key:"onRelationChainModified",value:function(e){}},{key:"onConvProfileUpdated",value:function(e){this._profileHandler.onConvProfileUpdated(e)}},{key:"getMyAccount",value:function(){return this.getMyUserID()}},{key:"getMyNick",value:function(){return this._profileHandler.getNickAndAvatarByUserID(this.getMyUserID()).nick}},{key:"getMyProfile",value:function(){return this._profileHandler.getMyProfile()}},{key:"getStorageModule",value:function(){return this.get(13)}},{key:"filterProfanity",value:function(e,t){}},{key:"isMyFriend",value:function(e){var t=this.get(8);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:"getUserNickAndAvatar",value:function(e){return this._profileHandler.getUserNickAndAvatar(e)}},{key:"getLocalBlacklist",value:function(){}},{key:"addBlacklist",value:function(e){}},{key:"deleteBlacklist",value:function(e){}},{key:"onUserStatusUpdated",value:function(e){}},{key:"setSelfStatus",value:function(e){}},{key:"getUserStatus",value:function(e){}},{key:"subscribeUserStatus",value:function(e){}},{key:"unsubscribeUserStatus",value:function(e){}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._profileHandler.reset()}}])),Ss=o(function e(t,n){i(this,e),this._m=t,this._isLoggedIn=!1,this._SDKAppID=n.SDKAppID,this._userID=n.userID||"",this._userSig=n.userSig||"",this._version=S,this._a2Key="",this._tinyID="",this._customStatus="",this._contentType="json",this._unlimitedAVChatRoom=n.unlimitedAVChatRoom,this._scene=n.scene||"",this._oversea=n.oversea,this._instanceID=n.instanceID,this._statusInstanceID=0,this._isDevMode=n.devMode,this._isTestEnv=n.testEnv,this._proxyServer=n.proxyServer,this._fileUploadProxy=n.fileUploadProxy,this._fileDownloadProxy=n.fileDownloadProxy,this._applicationID=0,this._isPartialUpdatedConvs=n.partialUpdatedConversations,this._isIndependentDomainDisabled=n.disableIndependentDomain,this._isUsingChatCore=!1,this._uiPlatform=0,this._authKey="",this._customLoginInfo=""},[{key:"isLoggedIn",value:function(){return this._isLoggedIn}},{key:"isOversea",value:function(){return this._oversea}},{key:"isPrivateNetWork",value:function(){return this._proxyServer}},{key:"isDevMode",value:function(){return this._isDevMode}},{key:"isTestEnv",value:function(){return this._isTestEnv}},{key:"isPartialUpdatedConvs",value:function(){return this._isPartialUpdatedConvs}},{key:"isIndependentDomainDisabled",value:function(){return this._isIndependentDomainDisabled}},{key:"isSingaporeSite",value:function(){return 2e7<=this._SDKAppID&&this._SDKAppID<3e7||172e7<=this._SDKAppID&&this._SDKAppID<173e7}},{key:"isKoreaSite",value:function(){return 3e7<=this._SDKAppID&&this._SDKAppID<4e7||173e7<=this._SDKAppID&&this._SDKAppID<174e7}},{key:"isGermanySite",value:function(){return 4e7<=this._SDKAppID&&this._SDKAppID<5e7||174e7<=this._SDKAppID&&this._SDKAppID<175e7}},{key:"isIndiaSite",value:function(){return 5e7<=this._SDKAppID&&this._SDKAppID<6e7||175e7<=this._SDKAppID&&this._SDKAppID<176e7}},{key:"isJapanSite",value:function(){return 6e7<=this._SDKAppID&&this._SDKAppID<7e7||176e7<=this._SDKAppID&&this._SDKAppID<177e7}},{key:"isUSASite",value:function(){return 7e7<=this._SDKAppID&&this._SDKAppID<8e7||177e7<=this._SDKAppID&&this._SDKAppID<178e7}},{key:"isIndonesiaSite",value:function(){return 8e7<=this._SDKAppID&&this._SDKAppID<9e7||178e7<=this._SDKAppID&&this._SDKAppID<179e7}},{key:"isIntl",value:function(){return 0===(e=this._SDKAppID)||2e7<=e&&e<9e7||172e7<=e&&e<179e7;var e}},{key:"isUnlimitedAVChatRoom",value:function(){return this._unlimitedAVChatRoom}},{key:"isUsingChatCore",value:function(){return this._isUsingChatCore}},{key:"setUsingChatCore",value:function(e){this._isUsingChatCore=e}},{key:"getUIPlatform",value:function(){return this._uiPlatform}},{key:"setUIPlatform",value:function(e){this._uiPlatform=e}},{key:"setUserID",value:function(e){this._userID=e}},{key:"getUserID",value:function(){return this._userID}},{key:"setUserSig",value:function(e){this._userSig=e}},{key:"getUserSig",value:function(){return this._userSig}},{key:"getSDKAppID",value:function(){return this._SDKAppID}},{key:"setTinyID",value:function(e){this._tinyID=e,this._isLoggedIn=!0}},{key:"getTinyID",value:function(){return this._tinyID}},{key:"setCustomStatus",value:function(e){this._customStatus=e}},{key:"getCustomStatus",value:function(){return this._customStatus}},{key:"getScene",value:function(){return de?window.tencent_cloud_im_csig_flutter_for_web_25F_cy: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:"getFileUploadProxy",value:function(){return this._fileUploadProxy}},{key:"getFileDownloadProxy",value:function(){return this._fileDownloadProxy}},{key:"setApplicationID",value:function(e){this._applicationID=e}},{key:"getApplicationID",value:function(){return this._applicationID}},{key:"setDowloadFileAuthKey",value:function(e){this._authKey=e}},{key:"getDownloadFileAuthKey",value:function(){return this._authKey}},{key:"setCustomLoginInfo",value:function(e){this._customLoginInfo=e}},{key:"getCustomLoginInfo",value:function(){return this._customLoginInfo}},{key:"_isTUIKit",value:function(){var e=!1,t=!1,n=!1,s=!1,i=[];$&&(i=Object.keys(Q));for(var a=0,o=(i=Z?z?Object.keys(uni):Object.keys(window):i).length;a<o;a++)if(i[a].toLowerCase().includes("uikit")){e=!0;break}i=null;var r,c=($&&!qe(Q.createGamePortal)&&qe(getApp)&&!Ze(getApp())&&xe(r=getApp().globalData)&&!0===r.isTUIKit&&(t=!0),!0===this._m.get(13).getStorageSync("TIM_".concat(this._SDKAppID,"_isTUIKit"))&&(n=!0),null);if(V&&!H&&"undefined"==typeof uni&&__wxConfig&&(c=__wxConfig.pages),K&&"undefined"==typeof uni&&__qqConfig&&(c=__qqConfig.pages),Ve(c)&&0<c.length){for(var u=0,l=c.length;u<l;u++)if(c[u].toLowerCase().includes("tui")){s=!0;break}c=null}return e||t||n||s}},{key:"reset",value:function(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}]),Es={"k-vue2-pc":1,"k-vue2-h5":2,"k-vue2-h5-uni":3,"k-vue2-app-uni":4,"k-vue2-mp-uni":5,"k-vue2-pc-uni":6,"k-vue3-pc":7,"k-vue3-h5":8,"k-vue3-h5-uni":9,"k-vue3-app-uni":10,"k-vue3-mp-uni":11,"k-vue3-pc-uni":12,"k-rn":13},ks=(l(Ds,sn),o(Ds,[{key:"onCheckTimer",value:function(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}},{key:"login",value:function(e){if(this.isLoggedIn())return n=this.getMyUserID(),(n=this.getErrMsg("RepeatLogin",n))&&Ee.w(n),$t({actionStatus:"OK",errorCode:0,errorInfo:n,repeatLogin:!0});if(Date.now()-this._lastLoginTs<=15e3)return this.warn("LoggingIn",e.userID),Jt({code:un.REPEAT_LOGIN});Ee.l("".concat(this._n,".login userID:").concat(e.userID));var t,n=this._checkLoginInfo(e);return 0!==n.code?Jt(n):(n=this.get(12),t=e.userID,e=e.userSig,n.setUserID(t),n.setUserSig(e),this.get(20).updateProtocolConfig(),this._login())}},{key:"_login",value:function(){var e=this,t=this.get(12),n=t.getScene(),s=n,i=(n&&n.startsWith("k-")&&(s=Es[n],n="tuikit"),new kn("login")),a=(i.setMessage("".concat(s)).setMoreMessage("identifier:".concat(this.getMyUserID())),s=0,"aidesk-uikit-engine"===n?s=1e3:"aidesk-customer-uni-vue2"===n?s=1001:"aidesk-customer-uni-vue3"===n?s=1002:"aidesk-customer-uni-mp"===n?s=1003:"aidesk-customer-web-vue2"===n?s=1004:"aidesk-customer-web-vue3"===n?s=1005:"aidesk-agent-list-vue2"===n?s=1006:"aidesk-agent-list-vue3"===n?s=1007:"test-window"===n||"aidesk-workstation"===n?s=1008:"aidesk-no-dev-required"===n&&(s=1009),i.setUIPlatform(s),t.setUIPlatform(s),"".concat(this._n,"._login"));return this._lastLoginTs=Date.now(),this.req({P:dn.LOGIN,data:{deviceBrand:0,isWebUniapp:this._isWebUniapp,customInfo:t.getCustomLoginInfo()}}).then(function(s){e._lastLoginTs=0;var o=Date.now(),r=null,c=(_=s.data).a2Key,u=_.tinyID,l=_.helloInterval,d=_.instanceID,h=_.timeStamp,g=void 0===(g=_.customStatus)?"":g,p=_.purchaseBits,_=void 0===(_=_.authKey)?"":_,f=1e3*h,m=o-i.getStartTs();if(m=f+parseInt(m/2)-o,o=i.getStartTs()+m,i.start(o),o=f,Me=m,(f=new Date).setTime(o),Ee.i("baseTime from server:".concat(f," offset:").concat(Me)),u){if(c)return o=e.get(21).getSocketID(),f=cs(g),g="socketID:".concat(o," scene:").concat(n," helloInterval:").concat(l," instanceID:").concat(d," timeStamp:").concat(h)+" offset:".concat(m," customStatus:").concat(f," isWebUniapp:").concat(e._isWebUniapp),Ee.l("".concat(a," ok. ").concat(g)),h=o="",V&&qe(Q.getAccountInfoSync)&&(m=Q.getAccountInfoSync().miniProgram)&&(o=m.appId,h=m.envVersion),i.setMoreMessage("".concat(g," href:").concat(Z?window.location.href:""," mpAppId:").concat(o," envVersion:").concat(h," authKey:").concat(_)).end(),t.setA2Key(c),t.setTinyID(u),t.setStatusInstanceID(d),t.setCustomStatus(f),t.setDowloadFileAuthKey(_),p&&e.get(27).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:p}),e.get(20).updateProtocolConfig(),e.emitIEvt(ss.A2KEY_AND_TINYID_UPDATED),e._helloInterval=l,e.triggerReady(),e._fetchCloudControlConfig(),s;r=new cn({code:un.NO_A2KEY})}else r=new cn({code:un.NO_TINYID});throw i.setError(r).end(),r}).catch(function(t){return i.setError(t).end(!0),e._m.setNotReadyReason(un.LOGIN_FAILED),Ee.e("".concat(a," failed. error:"),t),e._lastLoginTs=0,e._m.onLoginFailed(),Jt(t)})}},{key:"logout",value:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,n="".concat(this._n,".logout"),s=this.isLoggedIn();return Ee.i("".concat(n," type:").concat(t," isLoggedIn:").concat(s," isWebUniapp:").concat(this._isWebUniapp)),s?(new kn("logout").setMessage("identifier:".concat(this.getMyUserID())).end(!0),0===t&&this._m.setNotReadyReason(un.LOGGED_OUT),this.req({P:dn.LOGOUT,data:{type:t,isWebUniapp:this._isWebUniapp}}).then(function(){return e.resetReady(),$t({})}).catch(function(t){return Ee.e("".concat(n," error:"),t),e.resetReady(),$t({})})):Jt({code:un.USER_NOT_LOGGED_IN})}},{key:"getLoginUser",value:function(){return this.isLoggedIn()?this.getMyUserID():""}},{key:"_fetchCloudControlConfig",value:function(){this.get(23).fetchConfig()}},{key:"_getStatusInstanceID",value:function(){return uni.getStorageSync("timUniAppInstanceID")||0}},{key:"_hello",value:function(){var e=this;this._lastWsHelloTs=Date.now(),this.req({P:dn.HELLO,data:{isWebUniapp:this._isWebUniapp}}).catch(function(t){Ee.w("".concat(e._n,"._hello error:"),t)})}},{key:"getLastWsHelloTs",value:function(){return this._lastWsHelloTs}},{key:"_checkLoginInfo",value:function(e){var t=0;return Ue(this.get(12).getSDKAppID())?t=un.NO_SDKAPPID:Ue(e.userID)?t=un.NO_IDENTIFIER:Ue(e.userSig)&&(t=un.NO_USERSIG),{code:t}}},{key:"_isReactUIKit",value:function(){return Z&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}},{key:"onMultipleAccountKickedOut",value:function(e){var t=this;new kn("kickedOut").setMessage("type:".concat(k.KICKED_OUT_MULT_ACCOUNT," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Ee.w("".concat(this._n,".onMultipleAccountKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then(function(){t.emitOEvt(E.KICKED_OUT,{type:k.KICKED_OUT_MULT_ACCOUNT}),t._m.setNotReadyReason(un.KICKED_OUT_MULT_ACCOUNT),t._m.reset()})}},{key:"onMultipleDeviceKickedOut",value:function(e){var t=this;new kn("kickedOut").setMessage("type:".concat(k.KICKED_OUT_MULT_DEVICE," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Ee.w("".concat(this._n,".onMultipleDeviceKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),this.logout(1).then(function(){t.emitOEvt(E.KICKED_OUT,{type:k.KICKED_OUT_MULT_DEVICE}),t._m.setNotReadyReason(un.KICKED_OUT_MULT_DEVICE),t._m.reset()})}},{key:"onUserSigExpired",value:function(){new kn("kickedOut").setMessage(k.KICKED_OUT_USERSIG_EXPIRED).end(!0),Ee.w("".concat(this._n,".onUserSigExpired userID:").concat(this.getMyUserID())),0!==this.get(12).getStatusInstanceID()&&(this.emitOEvt(E.KICKED_OUT,{type:k.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(un.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}},{key:"onRestApiKickedOut",value:function(e){new kn("kickedOut").setMessage("type:".concat(k.KICKED_OUT_REST_API," newInstanceInfo:").concat(JSON.stringify(e))).end(!0),Ee.w("".concat(this._n,".onRestApiKickedOut userID:").concat(this.getMyUserID()," newInstanceInfo:"),e),0!==this.get(12).getStatusInstanceID()&&(this.emitOEvt(E.KICKED_OUT,{type:k.KICKED_OUT_REST_API}),this._m.setNotReadyReason(un.KICKED_OUT_REST_API),this._m.reset(),this.get(21).onRestApiKickedOut())}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}]));function Ds(e){return i(this,Ds),(e=n(this,Ds,[e]))._n="SignModule",e._helloInterval=120,e._lastLoginTs=0,e._lastWsHelloTs=0,e._isWebUniapp=0,os.mixin(e),e}function Os(e){return i(this,Os),(e=n(this,Os,[e]))._n="UserModule",e._profileHandler=new Cs(e),e.getIEmitInst().on(ss.A2KEY_AND_TINYID_UPDATED,e.onContextUpdated,e),e}function Rs(e){return i(this,Rs),(e=n(this,Rs,[e]))._n="ConvModule",os.mixin(e),e._msgListHandler=new is(e),e._msgRemindHandler=new ms(e),e._convGroupHandler=new vs(e),e._streamMessageHandler=new Is(e),e._sll=new hs(100),e._pagingStatus=Qt,e._pagingTs=0,e._pagingStartIdx=0,e._pagingPinnedTs=0,e._pagingPinnedStartIdx=0,e._pagingConvIDMap=new Map,e._convIDFromUnreadDBMap=new Map,e._convMap=new Map,e._tmpGroupList=[],e._tmpGroupAtTipsList=[],e._peerReadTimeMap=new Map,e._completedMap=new Map,e._roamingMsgKeyAndTimeMap=new Map,e._remoteGroupReadSeqMap=new Map,e._convTotalUnreadCount=0,e._pagingGetCostList=[],e._convMapForDiff=new Map,e._partialUpdatedConvMap=new Map,e._everClearedMap=new Map,e._bPullOnInvite=!0,e._initListeners(),e}function As(){return null}function Ns(e){var t=e.get(12);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:me()}}var Ls=o(function e(t){i(this,e),this._m=t,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()},[{key:"_errorTolerantHandle",value:function(){$||"undefined"!=typeof window&&this._canIUseCookies()||(this.getItem=As,this.setItem=As,this.removeItem=As,this.clear=As)}},{key:"onCheckTimer",value:function(e){e%20==0&&0!==this._storageQueue.size&&this._doFlush()}},{key:"_doFlush",value:function(){try{var e,t=r(this._storageQueue);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2),s=n[0],i=n[1];this._setStorageSync(this._getKey(s),i)}}catch(e){t.e(e)}finally{t.f()}this._storageQueue.clear()}catch(e){Ee.w("".concat(this._n,"._doFlush error:"),e)}}},{key:"_getPrefix",value:function(){var e=this._m.get(12);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=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;return this.getStorageSync(n)}catch(e){return Ee.w("".concat(this._n,".getItem error:"),e),{}}}},{key:"setItem",value:function(e,t){var n;2<arguments.length&&void 0!==arguments[2]&&arguments[2]?(n=3<arguments.length&&void 0!==arguments[3]&&!arguments[3]?e:this._getKey(e),this._setStorageSync(n,t)):this._storageQueue.set(e,t)}},{key:"clear",value:function(){try{$?Q.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){Ee.w("".concat(this._n,".clear error:"),e)}}},{key:"removeItem",value:function(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;this._removeStorageSync(n)}catch(e){Ee.w("".concat(this._n,".removeItem error:"),e)}}},{key:"getSize",value:function(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"b";try{var s={size:0,limitSize:5242880,unit:n};if(Object.defineProperty(s,"leftSize",{enumerable:!0,get:function(){return s.limitSize-s.size}}),$&&(s.limitSize=1024*Q.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if($)Q.getStorageInfoSync().keys.forEach(function(e){s.size+=JSON.stringify(t.getStorageSync(e)).length+t._getKey(e).length});else if(this._canIUseCookies())for(var i in localStorage)localStorage.hasOwnProperty(i)&&(s.size+=localStorage.getItem(i).length+i.length);return this._convertUnit(s)}catch(e){Ee.w("".concat(this._n," error:"),e)}}},{key:"_convertUnit",value:function(e){var t,n={},s=e.unit;for(t in n.unit=s,e)"number"==typeof e[t]&&("kb"===s.toLowerCase()?n[t]=Math.round(e[t]/1024):"mb"===s.toLowerCase()?n[t]=Math.round(e[t]/1024/1024):n[t]=e[t]);return n}},{key:"_setStorageSync",value:function(e,t){$?B?my.setStorageSync({key:e,data:t}):Q.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}},{key:"getStorageSync",value:function(e){return $?B?my.getStorageSync({key:e}).data:Q.getStorageSync(e):this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}},{key:"_removeStorageSync",value:function(e){$?B?my.removeStorageSync({key:e}):Q.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}},{key:"_canIUseCookies",value:function(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._doFlush()}}]),Us=o(function e(t){i(this,e),this._n="SSOLogBody",this._report=[]},[{key:"pushIn",value:function(e){Ee.d("".concat(this._n,".pushIn"),this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;Ve(e)&&0!==e.length&&(Ee.d("".concat(this._n,".backfill"),this._report.length,e.length),(t=this._report).unshift.apply(t,y(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}}]),Ps=(l(Fs,sn),o(Fs,[{key:"reportAtOnce",value:function(){this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.get(13),n=t.getItem(this.TAG,!1);!Ue(n)&&qe(n.forEach)&&(Ee.l("".concat(this._n,"._onLoginSuccess. logs count:").concat(n.length)),n.forEach(function(t){e._reportBody.pushIn(t)}),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),n=this.getCloudConfig("evt_rpt_level"),s=this.getCloudConfig("evt_rpt_sdkappid_bl"),i=this.getCloudConfig("evt_rpt_tinyid_wl");Ze(e)||(this.MIN_THRESHOLD=Number(e)),Ze(t)||(this.WAITING_TIME=Number(t)),Ze(n)||(this.REPORT_LEVEL=n.split(",").map(function(e){return Number(e)})),Ze(s)||(this.REPORT_SDKAPPID_BLACKLIST=s.split(",").map(function(e){return Number(e)})),Ze(i)||(this.REPORT_TINYID_WHITELIST=i.split(","))}},{key:"pushIn",value:function(e){e instanceof kn&&(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=(s=this.get(12)).getSDKAppID(),s=s.getTinyID();return Ct(this.REPORT_SDKAPPID_BLACKLIST,n)&&!Tt(this.REPORT_TINYID_WHITELIST,s)?[]:e.filter(function(e){return t.REPORT_LEVEL.includes(e.level)})}},{key:"_report",value:function(){var e,t,n=this;this._reportBody.isEmpty()||(e=this._reportBody.getLogsInMemory(),0!==(t=this._filterLogs(e)).length?(t={header:Ns(this),event:t},this.req({P:dn.SSO_STAT,data:_({},t)}).then(function(){n._lastReportTime=Date.now()}).catch(function(t){Ee.w("".concat(n._n,"._report failed. error:"),t),n._lastReportTime=Date.now(),n._reportBody.backfill(e),n._reportBody.getLogsNumInMemory()>n.MAX_THRESHOLD&&n._flushAtOnce()})):this._lastReportTime=Date.now())}},{key:"_flushAtOnce",value:function(){var e=this.get(13),t=e.getItem(this.TAG,!1),n=this._reportBody.getLogsInMemory(),s="".concat(this._n,"._flushAtOnce");Ue(t)?(Ee.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)):((n=n.concat(t)).length>this.MAX_THRESHOLD&&(n=n.slice(0,this.MAX_THRESHOLD)),Ee.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1))}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}])),ws="none",bs="online",Gs=o(function e(t){i(this,e),this._m=t,this._networkType=bs,this._n="NetMonitorModule",this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null,this._removeListener=null,this._m.getIEmitInst().on(ss.A2KEY_AND_TINYID_UPDATED,this._startRN,this)},[{key:"_startRN",value:function(){var e,t=this;X&&(e=this._m.get(18).getPlugin("chat-network-monitor"))&&(this._removeListener=e.addEventListener(function(e){var n=e.isConnected;e=e.type,t._networkType!==e&&t._onNetworkStatusChange({isConnected:void 0!==n&&n,networkType:e})}))}},{key:"start",value:function(){var e=this,t="".concat(this._n,".start");$?(Q.getNetworkType({success:function(n){e._networkType=n.networkType||n.subtype||"",n.networkType===ws?Ee.w("".concat(t," no network, please check!")):Ee.i("".concat(t," networkType:").concat(n.networkType))}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),Q.onNetworkStatusChange(this._mpNetworkStatusCallback)):Z&&(this._networkType=bs,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback))}},{key:"_onWebOnline",value:function(){this._onNetworkStatusChange({isConnected:!0,networkType:bs})}},{key:"_onWebOffline",value:function(){this._onNetworkStatusChange({isConnected:!1,networkType:ws})}},{key:"_onNetworkStatusChange",value:function(e){var t=e.isConnected,n=(e=e.networkType,"".concat(this._n,"._onNetworkStatusChange")),s=!1,i="previous:".concat(this._networkType," current:").concat(e);t?(Ee.i("".concat(n," ").concat(i)),this._networkType!==e&&(s=!0,this._networkType=e,this._m.get(21).reConnect(!0))):this._networkType!==e&&(s=!0,this._networkType=e,Ee.w("".concat(n," no network, please check!")),this._m.get(21).offline()),s&&new kn("networkChange").setMessage("isConnected:".concat(t," ").concat(i)).end()}},{key:"isOnline",value:function(){return this._networkType!==ws}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),$?null!==this._mpNetworkStatusCallback&&(Q.offNetworkStatusChange&&Q.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null):Z?(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null)):X&&this._removeListener&&(this._removeListener(),this._removeListener=null)}}]);function Fs(e){i(this,Fs),(e=n(this,Fs,[e]))._n="EventStatModule",e.TAG="im-ssolog-event",e._reportBody=new Us,e.MIN_THRESHOLD=20,e.MAX_THRESHOLD=100,e.WAITING_TIME=6e4,e.REPORT_LEVEL=[4,5,6],e.REPORT_SDKAPPID_BLACKLIST=[],e.REPORT_TINYID_WHITELIST=[],e._lastReportTime=Date.now();var t=e.getIEmitInst();return t.on(ss.A2KEY_AND_TINYID_UPDATED,e._onLoginSuccess,e),t.on(ss.CLOUD_CONFIG,e._onCloudConfig,e),e}function xs(e,t){return e(t={exports:{}},t.exports),t.exports}var Vs=xs(function(e){var t=Object.prototype.hasOwnProperty,n="~";function s(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,s,a,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");return s=new i(s,a||e,o),a=n?n+t:t,e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],s]:e._events[a].push(s):(e._events[a]=s,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function r(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),r.prototype.eventNames=function(){var e,s,i=[];if(0===this._eventsCount)return i;for(s in e=this._events)t.call(e,s)&&i.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},r.prototype.listeners=function(e){e=n?n+e:e;var t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var s=0,i=t.length,a=new Array(i);s<i;s++)a[s]=t[s].fn;return a},r.prototype.listenerCount=function(e){return e=n?n+e:e,(e=this._events[e])?e.fn?1:e.length:0},r.prototype.emit=function(e,t,s,i,a,o){var r=n?n+e:e;if(!this._events[r])return!1;var c,u=this._events[r],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,s),!0;case 4:return u.fn.call(u.context,t,s,i),!0;case 5:return u.fn.call(u.context,t,s,i,a),!0;case 6:return u.fn.call(u.context,t,s,i,a,o),!0}for(g=1,c=new Array(l-1);g<l;g++)c[g-1]=arguments[g];u.fn.apply(u.context,c)}else for(var d,h=u.length,g=0;g<h;g++)switch(u[g].once&&this.removeListener(e,u[g].fn,void 0,!0),l){case 1:u[g].fn.call(u[g].context);break;case 2:u[g].fn.call(u[g].context,t);break;case 3:u[g].fn.call(u[g].context,t,s);break;case 4:u[g].fn.call(u[g].context,t,s,i);break;default:if(!c)for(d=1,c=new Array(l-1);d<l;d++)c[d-1]=arguments[d];u[g].fn.apply(u[g].context,c)}return!0},r.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},r.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},r.prototype.removeListener=function(e,t,s,i){if(e=n?n+e:e,this._events[e])if(t){var a=this._events[e];if(a.fn)a.fn!==t||i&&!a.once||s&&a.context!==s||o(this,e);else{for(var r=0,c=[],u=a.length;r<u;r++)(a[r].fn!==t||i&&!a[r].once||s&&a[r].context!==s)&&c.push(a[r]);c.length?this._events[e]=1===c.length?c[0]:c:o(this,e)}}else o(this,e);return this},r.prototype.removeAllListeners=function(e){return e?(e=n?n+e:e,this._events[e]&&o(this,e)):(this._events=new s,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=n,e.exports=r.EventEmitter=r}),qs=["rich.my-imcloud.com","imrich.qcloud.com"],Ks=["existFlag"],Hs=(l(zs,sn),o(zs,[{key:"_init",value:function(){this._fileDownloadProxy=this.getFileDownloadProxy(),this._authKey=this.getDownloadFileAuthKey();var e=this.get(18);this.TIMUploadPlugin=e.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin?this._initUploaderMethod():(this.COSSDK=e.getPlugin(e=$?"cos-wx-sdk":"cos-js-sdk"),this.COSSDK?(this._getAuthorizationKey(),this.warn("CosReplacement",e)):this.warn("PluginUndetected"))}},{key:"_onCloudConfig",value:function(){var e=this,t="".concat(this._n,"._onCloudConfig"),n=this.getCloudConfig("upload_size_limit"),s=this.getCloudConfig("simple_cos"),i=this.getCloudConfig("file_dn_list");if(Ee.l("".concat(t," uploadSizeLimit:").concat(n," simpleCos:").concat(s)),!Ze(n))try{var a=JSON.parse(n);this.UPLOAD_SIZE_LIMIT={A:a.a?1048576*parseInt(a.a):this.UPLOAD_SIZE_LIMIT.A,F:a.f?1048576*parseInt(a.f):this.UPLOAD_SIZE_LIMIT.F,I:a.i?1048576*parseInt(a.i):this.UPLOAD_SIZE_LIMIT.I,V:a.v?1048576*parseInt(a.v):this.UPLOAD_SIZE_LIMIT.V}}catch(t){}if(Ze(s)||(this.isSimpleCos="1"===s),!Ze(i))try{JSON.parse(i).forEach(function(t){e._fileDNList.includes(t)||e._fileDNList.push(t)})}catch(t){}}},{key:"_getAuthorizationKey",value:function(){var e=this,t="".concat(this._n,".").concat("_getAuthorizationKey"),n=new kn("_getAuthorizationKey"),s=Math.ceil(Date.now()/1e3);this.req({P:dn.COS_SIGN,data:{duration:this.expiredTimeLimit}}).then(function(i){i=i.data;var a=(Ee.l("".concat(t," ok. data:"),i),i.expiredTime-s);n.setMessage("requestId:".concat(i.requestId," requestTime:").concat(s," expiredTime:").concat(i.expiredTime," diff:").concat(a,"s")).end(),!$&&i.region&&(e.region=i.region),e.appid=i.appid,e.bucketName=i.bucketName,e.ciUrl=i.ciUrl,e.directory=i.directory,e.downloadUrl=i.downloadUrl,e.uploadUrl=i.uploadUrl,e.cosOptions={secretId:i.secretId,secretKey:i.secretKey,sessionToken:i.sessionToken,expiredTime:i.expiredTime},Ee.l("".concat(t," ok. region:").concat(e.region," bucketName:").concat(e.bucketName)),e._initUploaderMethod()}).catch(function(e){n.setError(e).end(),Ee.w("".concat(t," failed. error:"),e)})}},{key:"_getCosPreSigUrl",value:function(e){var t=this,n="".concat(this._n,".").concat("_getCosPreSigUrl"),s=Math.ceil(Date.now()/1e3),i=new kn("_getCosPreSigUrl"),a={uploadMethod:e.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:e.userID,conversationType:e.conversationType,uploadConfig:[{fileID:1,fileType:e.fileType,fileName:e.fileName}],peerID:e.peerID},o=dn.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(a={fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration},o=dn.COS_PRE_SIG),this.req({P:o,data:a}).then(function(e){t.tryCount=0,e=e.data||{};var a,o,r=(Ee.l("".concat(n," ok. isSimpleCos:").concat(t.isSimpleCos," data:"),e),"");return r=t.isSimpleCos?(a=(o=e.preSig[0]).uploadUrl,o=o.fileKey,"uploadIP:".concat(e.uploadIP," uploadUrl:").concat(a," fileKey:").concat(o," cost:").concat(Ot(s))):"requestId:".concat(e.requestId," expiredTime:").concat(e.expiredTime," diff:").concat(e.expiredTime-s,"s"),i.setMessage(r).end(),e}).catch(function(s){return-1===s.code&&(s.code=un.COS_GET_SIG_FAIL),i.setError(s).end(),Ee.w("".concat(n," failed. error:"),s),t.tryCount<1?(t.tryCount++,t._getCosPreSigUrl(e)):(t.tryCount=0,Jt({code:un.COS_GET_SIG_FAIL}))})}},{key:"_initUploaderMethod",value:function(){var e=this;this.TIMUploadPlugin?(this.timUploadPlugin=new this.TIMUploadPlugin,this._cosUploadMethod=function(t,n){e.timUploadPlugin.uploadFile(t,n)}):this.appid&&(this.cos=$?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=$?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:"getFileDNList",value:function(){return this._fileDNList}},{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._relayFlag)return Promise.resolve();var t=this.get(26);switch(e.type){case k.MSG_IMAGE:return t.addTotalCount(vn),this._uploadImage(e);case k.MSG_FILE:return t.addTotalCount(vn),this._uploadFile(e);case k.MSG_AUDIO:return t.addTotalCount(vn),this._uploadAudio(e);case k.MSG_VIDEO:return t.addTotalCount(vn),this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var t=this,n=this.get(2),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadImage({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),qe(i.onProgress))try{i.onProgress(e)}catch(e){return Jt({code:un.MSG_ONPROGRESS_ERR})}}}).then(function(n){var i=n.location,a=n.fileType,o=n.fileSize,r=n.width,c=n.height,u=n.smallImageUrl,l=n.smallImageWidth,d=n.smallImageHeight,h=n.largeImageUrl,g=n.largeImageWidth,p=n.largeImageHeight,f=n.imageInfoArray;n=t.isPrivateNetWork()?i:$e(i),s.updateImageFormat(a);var m,v,y={size:o,url:n,width:r,height:c};if(f&&0<f.length)for(var I=0;I<f.length;I++){var M=f[I];1===M.type?m=M:2===M.type?v=M:y=_(_({},y),M)}else v=u&&h?(m={url:u,width:l,height:d},{url:h,width:g,height:p}):(m=vt({originUrl:n,originWidth:r,originHeight:c,min:198}),vt({originUrl:n,originWidth:r,originHeight:c,min:720}));return s.updateImageInfoArray([_({},y),_({},v),_({},m)]),e})}},{key:"_uploadFile",value:function(e){var t=this,n=this.get(2),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadFile({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),qe(i.onProgress))try{i.onProgress(e)}catch(e){return Jt({code:un.MSG_ONPROGRESS_ERR})}}}).then(function(n){var i=n=n.location;return t.isPrivateNetWork()||(i=An(i=$e(n),t._fileDownloadProxy,t._authKey,t._fileDNList)),s.updateFileUrl(i),e})}},{key:"_uploadAudio",value:function(e){var t=this,n=this.get(2),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadAudio({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),qe(i.onProgress))try{i.onProgress(e)}catch(e){return Jt({code:un.MSG_ONPROGRESS_ERR})}}}).then(function(n){return n=n.location,n=t.isPrivateNetWork()?n:$e(n),s.updateAudioUrl(n),e})}},{key:"_uploadVideo",value:function(e){var t=this,n=this.get(2),s=e.getElements()[0],i=n.getMessageOption(e.clientSequence);return this.doUploadVideo({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:e,onProgress:function(e){if(s.updatePercent(e),qe(i.onProgress))try{i.onProgress(e)}catch(e){return Jt({code:un.MSG_ONPROGRESS_ERR})}}}).then(function(n){var i=n.location;return n=n.snapshotInfo,i=t.isPrivateNetWork()?i:$e(i),s.updateVideoUrl(i),Ue(n)||s.updateSnapshotInfo(n),e})}},{key:"_checkSizeError",value:function(e){var t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),Jt({code:un["MSG_".concat(e,"_SIZE_LIMIT")],message:this.getErrMsg("UploadSizeLimit",t,"".concat(this.UPLOAD_SIZE_LIMIT[e]/1048576,"MB"))})}},{key:"doUploadImage",value:function(e){var t,n,s=this;return!e.file||this._isEmptyFileList(e.file.files)?Jt({code:un.MSG_I_SELECT_F_FIRST}):!0!==(t=this._checkImageType(e.file))||!0!==(t=this._checkImageSize(e.file))?t:(n=null,this._setUploadFileType(1),this.uploadByCOS(e).then(function(t){if(n=t,s.isPrivateNetWork())return pt(t.location);if(Ve(n.imageInfoArray)){var i=n.imageInfoArray.find(function(e){return 3===e.type});if(i)return i}return X?{width:e.file.width,height:e.file.height}:(i=$e(t.location),s.COSSDK?pt(i):pt(i=An(i,s._fileDownloadProxy,s._authKey,s._fileDNList)))}).then(function(e){return n.width=e.width,n.height=e.height,Promise.resolve(n)}))}},{key:"_checkImageType",value:function(e){var t="";return t=$?e.url.slice(e.url.lastIndexOf(".")+1):X?e.type.split("/")[1]:e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),0<=us.indexOf(t.toLowerCase())||Jt({code:un.MSG_I_TYPES_LIMIT})}},{key:"_checkImageSize",value:function(e){return 0===(e=($||X?e:e.files[0]).size)?Jt({code:un.MSG_F_IS_EMPTY}):e<this.UPLOAD_SIZE_LIMIT.I||this._checkSizeError("I")}},{key:"doUploadFile",value:function(e){return!e.file||this._isEmptyFileList(e.file.files)?Jt({code:un.MSG_F_SELECT_F_FIRST}):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?Jt({code:un.MSG_F_IS_EMPTY}):(this._setUploadFileType(255),this.uploadByCOS(e))}},{key:"doUploadVideo",value:function(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?Jt({code:un.MSG_F_IS_EMPTY}):-1===ls.indexOf(e.file.videoFile.type)?Jt({code:un.MSG_V_TYPES_LIMIT}):(this._setUploadFileType(2),$||X?this.handleVideoUpload(_(_({},e),{},{file:e.file.videoFile})):Z?this.handleVideoUpload(e):void 0)}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise(function(n,s){t.uploadByCOS(e).then(function(e){n(e)}).catch(function(){t.uploadByCOS(e).then(function(e){n(e)}).catch(function(){s(new cn({code:un.MSG_V_UPLOAD_FAIL}))})})})}},{key:"doUploadAudio",value:function(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?Jt({code:un.MSG_F_IS_EMPTY}):(this._setUploadFileType(3),this.uploadByCOS(e)):Jt({code:un.MSG_A_UPLOAD_FAIL})}},{key:"uploadByCOS",value:function(e){var t,n,s,i,a=this;return qe(this._cosUploadMethod)?this.timUploadPlugin?this._uploadWithPreSigUrl(e):(t=new kn("upload"),n="".concat(this._n,".uploadByCOS"),s=Date.now(),i=this._getFile(e),new Promise(function(o,r){var c=$?a._createCosOptionsWXMiniApp(e):a._createCosOptionsWeb(e),u=a;a._cosUploadMethod(c,function(e,c){var l,d,h=Object.create(null);c?e||Ve(c.files)&&c.files[0].error?(l=new cn({code:un.MSG_F_UPLOAD_FAIL}),t.setError(l).end(),Ee.l("".concat(n," failed. error:"),c.files[0].error),403===c.files[0].error.statusCode&&a._getAuthorizationKey(),r(l)):(h.fileName=i.name,h.fileSize=i.size,h.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),h.location=($?c:c.files[0].data).Location,l=Date.now()-s,c=u._formatFileSize(i.size),d=u._formatSpeed(1e3*i.size/l),c="size:".concat(c," time:").concat(l,"ms speed:").concat(d),Ee.l("".concat(n," success. name:").concat(i.name," ").concat(c)),o(h),(d=a.get(26)).addCost(vn,l),d.addFileSize(vn,i.size),t.setMessage(c).end()):(h=new cn({code:un.MSG_F_UPLOAD_FAIL}),t.setError(h).end(),Ee.w("".concat(n," failed. error:"),e),403===e.statusCode&&a._getAuthorizationKey(),r(h))})})):(this.warn("PluginUndetected"),Jt({code:un.COS_UNDETECTED}))}},{key:"_uploadWithPreSigUrl",value:function(e){var t=this,n="".concat(this._n,"._uploadWithPreSigUrl"),s=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then(function(e){return new Promise(function(i,a){var o=new kn("upload"),r=e.existFlag,c=f(e,Ks),u=Date.now();1!==r?t._cosUploadMethod(c,function(r,c){var l;r||403===c.statusCode?(l="".concat(Ze(r)?"":JSON.stringify(r)," ").concat(Ze(c)?"":JSON.stringify(c)),o.setMessage(l).end(),r={HttpStatusCode:9999,CostTime:Ot(u,!1),error:r,url:e.url},c.data&&c.data.uploadIP&&(r.uploadIP=c.data.uploadIP),t._uploadSSOLog(r),Ee.l("".concat(n," failed, error:").concat(l)),a(new cn({code:un.MSG_F_UPLOAD_FAIL}))):t._handleUploadSuccessResult({ssoLog:o,startTs:u,file:s,uploadOptions:e,uploadResult:c},i)}):t._handleUploadSuccessResult({ssoLog:o,startTs:u,file:s,uploadOptions:e,uploadResult:{data:{location:c.downloadUrl,statusCode:200}}},i)})})}},{key:"_handleUploadSuccessResult",value:function(e,t){var n=e.ssoLog,s=e.startTs,i=e.file,a=(h=e.uploadOptions).existFlag,o=h.fileType,r=h.url,c=h.downloadUrl,u=h.requestSnapshotUrl,l=h.thumbUrl,d=h.largeUrl,h=void 0===(h=h.imageInfoArray)?[]:h,g=(e=e.uploadResult,Object.create(null)),p=e.data.location||"",_=(this.isPrivateNetWork()||0!==p.indexOf("https://")&&0!==p.indexOf("http://")||(p=p.split("//")[1]),g.fileName=i.name,g.fileSize=i.size,g.fileType=i.type.slice(i.type.indexOf("/")+1).toLowerCase(),g.location=p,p=Ot(s,!1),s=this._formatFileSize(i.size),this._formatSpeed(1e3*i.size/(p||1)));if(s="exist:".concat(a," fileType:").concat(o," bytes:").concat(i.size," size:").concat(s," time:").concat(p,"ms speed:").concat(_," res:").concat(JSON.stringify(e)),Ee.l("".concat(this._n,"._uploadWithPreSigUrl ok. name:").concat(i.name," ").concat(s)),n.setMessage(s).end(),_={HttpStatusCode:e.statusCode,FileSize:i.size,CostTime:p,url:r},(e.data&&e.data.uploadIP&&(_.uploadIP=e.data.uploadIP),this._uploadSSOLog(_),n=this.get(26)).addCost(vn,p),n.addFileSize(vn,i.size),1===a){if(0<h.length)return g.imageInfoArray=h,void t(g);if(u)return this._getSnapshotInfoByUrl(u,g).then(function(){t(g)})}if(s=[],l&&d&&s.push.apply(s,[this._getSmallImageInfoByUrl(l,g),this._getLargeImageInfoByUrl(d,g)]),this.isSimpleCos&&1===o&&!this.isPrivateNetWork()&&(s.push(this._getImageInfoArray(c,g)),e.data.uploadIP)&&s.push(this._getDownloadIP(c.split("//")[1].split("/")[0],g)),u&&s.push(this._getSnapshotInfoByUrl(u,g)),0<s.length)return Promise.all(s).then(function(){t(g)});t(g)}},{key:"_getDownloadIP",value:function(e,t){var n="".concat(this._n,"._getDownloadIP"),s=Date.now();return this.req({P:dn.GET_IP,data:{domainName:e}}).then(function(e){var i;e.data&&e.data.ip&&(Ee.l("".concat(n," ok. downloadIP:").concat(e.data.ip," cost:").concat(Ot(s))),(i=t.location.split("/"))[0]=e.data.ip,t.location=i.join("/"))}).catch(function(e){})}},{key:"_getImageInfoArray",value:function(e,t){var n=this,s="".concat(this._n,"._getImageInfoArray"),i=Date.now();return this.req({P:dn.GET_IMAGE_INFO,data:{imageUrl:e}}).then(function(e){return e=e.data||{},Ee.l("".concat(s," ok. data: ").concat(JSON.stringify(e)," cost:").concat(Ot(i))),t.imageInfoArray=e.imageInfoArray,e}).catch(function(s){t.imageInfoArray=void 0,n._uploadSSOLog({HttpStatusCode:1e4,CostTime:Ot(i,!1),url:e})})}},{key:"_uploadSSOLog",value:function(e){var t,n;this.isSimpleCos&&((t=new kn).setEventType(18),e.error&&t.setError(new cn(e.error)),n="HttpStatusCode:".concat(e.HttpStatusCode,"|CosRequestId:").concat(e.CosRequestId||"","|")+"FileAlreadyExist:".concat(e.FileAlreadyExist||0,"|FileSize:").concat(e.FileSize||0,"|CostTime:").concat(e.CostTime),e.uploadIP&&(n+="|FinalIP:".concat(e.uploadIP)),t.setMessage("OK").setMoreMessage(e.url).setExtension(n).end())}},{key:"_getRawOrUploadProxyUrl",value:function(e){var t=this.get(12).getFileUploadProxy(),n=e;return t?e.replace(/^https:\/\/[^/]+/,t):n}},{key:"_getFile",value:function(e){return Ve(e.file.files)||Ke(e.file.files)?e.file.files[0]:e.file}},{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?Mt(e/1024,1)+"KB/s":Mt(e/1048576,1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=this._getFile(e),n=(n=t.name).slice(n.lastIndexOf("."));return n=this._genFileName("".concat(We(999999)).concat(n)),{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),Body:t}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){Ee.w("onProgress callback error:",t)}},onFileFinish:function(e,t,n){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this._getFile(e),n=this._genFileName(t.name);return t=t.url,{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),FilePath:t,onProgress:function(t){if(Ee.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){Ee.w("onProgress callback error:",t)}}}}},{key:"_createCosOptionsPreSigUrl",value:function(e){var t,n=this,s=e.customFileName,i="",a=0,o=this._getFile(e);return a=$||X?(Ze(s)&&(s=e.message.type===k.MSG_FILE||e.message.type===k.MSG_VIDEO?(t=(t=o.name).slice(t.lastIndexOf(".")),this._genFileName("".concat(We(999999)).concat(t))):this._genFileName(o.name)),i=o.url,1):(Ze(s)&&(t=(t=o.name).slice(t.lastIndexOf(".")),s=this._genFileName("".concat(We(999999)).concat(t))),i=o,0),this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:s,uploadMethod:a,duration:this.duration,userID:e.message.from,conversationType:lt(e.message.conversationID)?1:2,peerID:e.to}).then(function(t){var a=(h=n.isSimpleCos?t.preSig[0]:t).uploadUrl,o=h.downloadUrl,r=void 0===(r=h.requestSnapshotUrl)?void 0:r,c=h.thumbUrl,u=h.largeUrl,l=h.fileKey,d=void 0===(d=h.existFlag)?0:d,h=void 0===(h=h.imageInfoArray)?void 0:h;return t=void 0===(t=t.uploadIP)?"":t,{url:n._getRawOrUploadProxyUrl(a),fileType:n.uploadFileType,fileName:s,resources:i,downloadUrl:o,requestSnapshotUrl:r,thumbUrl:c,largeUrl:u,fileKey:l,existFlag:d,imageInfoArray:h,uploadIP:!n.isPrivateNetWork()&&t,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){Ee.w("onProgress callback error:",t),Ee.e(t)}}}})}},{key:"_genFileName",value:function(e){return"".concat(_t(),"-").concat(e)}},{key:"_setUploadFileType",value:function(e){this.uploadFileType=e}},{key:"_getSnapshotInfoByUrl",value:function(e,t){var n=this,s="_getSnapshotInfoByUrl",i=new kn(s);return this.req({P:dn.VIDEO_COVER,data:{platform:this.getPlatform(),coverName:this._genFileName(We(99999)),requestSnapshotUrl:e}}).then(function(e){var a;return e=(e.data||{}).snapshotUrl,Ee.l("".concat(n._n,".").concat(s," ok. snapshotUrl:").concat(e)),i.setMessage("snapshotUrl:".concat(e)).end(),Ue(e)?{}:pt(a=An(e,n._fileDownloadProxy,n._authKey,n._fileDNList)).then(function(e){t.snapshotInfo={snapshotUrl:a,snapshotWidth:e.width,snapshotHeight:e.height}})}).catch(function(e){return Ee.w("".concat(n._n,".").concat(s," failed. error:"),e),i.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}})}},{key:"_getSmallImageInfoByUrl",value:function(e,t){return pt(An(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then(function(n){t.smallImageUrl=e,t.smallImageWidth=n.width,t.smallImageHeight=n.height})}},{key:"_getLargeImageInfoByUrl",value:function(e,t){return pt(An(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then(function(n){t.largeImageUrl=e,t.largeImageWidth=n.width,t.largeImageHeight=n.height})}},{key:"_isEmptyFileList",value:function(e){return!(!Ke(e)||0!==e.length)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}])),js=["downloadKey","pbDownloadKey","messageList"],Bs=o(function e(t){i(this,e),this._n="MergerMessageHandler",this._msgM=t},[{key:"uploadMergerMessage",value:function(e,t){var n="".concat(this._n,".").concat("uploadMergerMessage"),s=(Ee.d("".concat(n," message:"),e,"messageBytes:".concat(t)),e=JSON.parse(JSON.stringify(e.payload)).messageList).length,i=this._msgM.get(17).getFileDNList(),a=new kn("uploadMergerMessage");return e.forEach(function(e){Nn(e.messageBody[0].type,e.messageBody,i)}),this._msgM.req({P:dn.UPLOAD_MERGER_MSG,data:{messageList:e}}).then(function(e){Ee.d("".concat(n," ok. response:"),e.data);var i={pbDownloadKey:i=(e=e.data).pbDownloadKey,downloadKey:e=e.downloadKey,messageNumber:s};return a.setMessage("".concat(s,"-").concat(t,"-").concat(e)).end(),i}).catch(function(e){throw Ee.w("".concat(n," failed. error:"),e),a.setError(e).end(),e})}},{key:"downloadMergerMessage",value:function(e){var t=this,n="".concat(this._n,".").concat("downloadMergerMessage"),s=(Ee.d("".concat(n," message:"),e),e.payload.downloadKey),i=this._msgM.getFileDownloadProxy(),a=this._msgM.getDownloadFileAuthKey(),o=new kn("downloadMergerMessage");return o.setMessage("downloadKey:".concat(s)),this._msgM.req({P:dn.DOWNLOAD_MERGER_MSG,data:{downloadKey:s}}).then(function(s){Ee.d("".concat(n," ok. response:"),s.data);var r,c,u=t._msgM.get(17).getFileDNList();return qe(e.clearElement)?((r=e.payload).downloadKey,r=f(r,js),e.clearElement(),e.setElement({type:e.type,content:_({messageList:s.data.messageList},r)},i,a,u)):(c=[],s.data.messageList.forEach(function(e){Ue(e)||(e=new Bn(e,i,a,u),c.push(e))}),e.payload.messageList=c,e.payload.downloadKey="",e.payload.pbDownloadKey=""),o.end(),e}).catch(function(e){throw Ee.w("".concat(n," failed. key:").concat(s," error:"),e),o.setError(e).end(),e})}},{key:"createMergerMessagePack",value:function(e,t,n){return e.conversationType===k.CONV_C2C?this._createC2CMergerMessagePack(e,t,n):this._createGroupMergerMessagePack(e,t,n)}},{key:"_createC2CMergerMessagePack",value:function(e,t,n){var s=null,i=(t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly)&&(s?s.disablePush=!0:s={disablePush:!0}),[]),a=(xe(t)&&xe(t.messageControlInfo)&&(a=(r=t.messageControlInfo).excludedFromUnreadCount,o=r.excludedFromLastMessage,r=r.excludedFromContentModeration,!0===a&&i.push("NoUnread"),!0===o&&i.push("NoLastMsg"),!0===r)&&i.push("NoMsgCheck"),""),o=(Xe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(a=e.cloudCustomData),n.pbDownloadKey),r=n.downloadKey,c=(n=n.messageNumber,(l=e.payload).title),u=l.abstractList,l=l.compatibleText,d=(d=this._msgM.get(6))&&d.isOnlineMessage(e,t)?0:void 0;return{P:dn.SEND_C2C_MSG,data:{fromAccount:this._msgM.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:o,downloadKey:r,title:c,abstractList:u,compatibleText:l,messageNumber:n}}],cloudCustomData:a,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:d,offlinePushInfo:ts(s),messageControlInfo:0!==d?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}},{key:"_createGroupMergerMessagePack",value:function(e,t,n){var s=null,i=(t&&t.offlinePushInfo&&(s=t.offlinePushInfo),[]),a=(xe(t)&&xe(t.messageControlInfo)&&(a=(r=t.messageControlInfo).excludedFromUnreadCount,o=r.excludedFromLastMessage,r=r.excludedFromContentModeration,!0===a&&i.push("NoUnread"),!0===o&&i.push("NoLastMsg"),!0===r)&&i.push("NoMsgCheck"),""),o=(Xe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(a=e.cloudCustomData),n.pbDownloadKey),r=n.downloadKey,c=(n=n.messageNumber,(l=e.payload).title),u=l.abstractList,l=l.compatibleText,d=this._msgM.get(7);return t=d&&d.isOnlineMessage(e,t)?1:0,{P:dn.SEND_GRP_MSG,data:{fromAccount:this._msgM.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:o,downloadKey:r,title:c,abstractList:u,compatibleText:l,messageNumber:n}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:a,onlineOnlyFlag:t,offlinePushInfo:ts(s),clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||d.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0==t?i:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}]),Ys={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},Ws=[un.MSG_ONPROGRESS_ERR,un.MSG_I_SELECT_F_FIRST,un.MSG_I_TYPES_LIMIT,un.MSG_F_IS_EMPTY,un.MSG_I_SIZE_LIMIT,un.MSG_F_SELECT_F_FIRST,un.MSG_F_SIZE_LIMIT,un.MSG_V_SIZE_LIMIT,un.MSG_V_TYPES_LIMIT,un.MSG_A_UPLOAD_FAIL,un.MSG_A_SIZE_LIMIT,un.COS_UNDETECTED];function zs(e){i(this,zs),(e=n(this,zs,[e]))._n="UploadModule",e.TIMUploadPlugin=null,e.timUploadPlugin=null,e.COSSDK=null,e._cosUploadMethod=null,e.expiredTimeLimit=600,e.appid=0,e.bucketName="",e.ciUrl="",e.directory="",e.downloadUrl="",e.uploadUrl="",e.region="ap-shanghai",e.cos=null,e.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},e.uploadFileType="",e.duration=900,e.tryCount=0,e.UPLOAD_SIZE_LIMIT={A:20971520,F:104857600,I:20971520,V:104857600},e.isSimpleCos=!e.isPrivateNetWork(),e._fileDownloadProxy="",e._authKey="",e._fileDNList=qs;var t=e.getIEmitInst();return t.on(ss.A2KEY_AND_TINYID_UPDATED,e._init,e),t.on(ss.CLOUD_CONFIG,e._onCloudConfig,e),e}l(ti,sn);var $s=o(ti,[{key:"createTextMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e));return e=Xe(e.payload)?e.payload:e.payload.text,e=new Dn({text:e}),t=this._getNickAndAvatarByUserID(t),n.setElement(e),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createImageMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e));if($){if(be(i=e.payload.file))return void this.warn("FileUnsupportedInMP","createImageMessage");var s=i.tempFiles[0].path||i.tempFiles[0].tempFilePath,i={url:s,name:s.slice(s.lastIndexOf("/")+1),size:i.tempFiles&&i.tempFiles[0].size||1,type:s.slice(s.lastIndexOf(".")+1).toLowerCase()};e.payload.file=i}else X?(i={url:(s=e.payload.file).uri,name:s.fileName,size:s.fileSize||1,type:s.type,width:s.width,height:s.height},e.payload.file=i):Z&&(be(e.payload.file)?(s=e.payload.file,e.payload.file={files:[s]}):xe(e.payload.file)&&"undefined"!=typeof uni&&(i=e.payload.file.tempFiles[0],e.payload.file={files:[i]}));return s=this.get(17).getFileDNList(),i=new Pn({imageFormat:ke.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),s),s=this._getNickAndAvatarByUserID(t),n.setElement(i),n.setNickAndAvatar(s),n.setNameCard(this._getNameCardByGroupID(n)),this._messageOptionsMap.set(n.clientSequence,e),n}},{key:"createAudioMessage",value:function(e){var t=e.payload.file,n=($&&(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),X&&(n={url:t.uri,name:t.uri.slice(t.uri.lastIndexOf("/")+1),size:t.fileSize||1,second:Math.floor(t.duration/1e3),type:t.uri.slice(t.uri.lastIndexOf(".")+1).toLowerCase()},e.payload.file=n,Ue(t.uri))&&this.warn("VoiceFileInRN"),this.getMyUserID()),s=(e.currentUser=n,e.senderTinyID=this.getMyTinyID(),this.get(17).getFileDNList()),i=new $n(e);return t=new bn({second:Math.floor(t.duration/1e3),size:t.fileSize||t.size||1,url:t.tempFilePath||t.uri,uuid:this._generateUUID(e.payload.file)},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),s),s=this._getNickAndAvatarByUserID(n),i.setElement(t),i.setNickAndAvatar(s),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createVideoMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="",e.payload.file.thumbSize=0,{});if($){if(be(e.payload.file))return void this.warn("FileUnsupportedInMP","createVideoMessage");Ve((s=e.payload.file).tempFiles)&&(s=s.tempFiles[0]),n.url=s.tempFilePath,n.name=s.tempFilePath.slice(s.tempFilePath.lastIndexOf("/")+1),n.size=s.size||1,n.second=s.duration||0,n.type=s.tempFilePath.slice(s.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else X?(s=e.payload.file,n.url=s.uri,n.name=s.fileName,n.size=s.fileSize||1,n.second=s.duration||0,n.type=s.type.split("/")[1]):Z&&(be(e.payload.file)?(s=e.payload.file,e.payload.file.files=[s]):xe(e.payload.file)&&"undefined"!=typeof uni&&(s=e.payload.file.tempFile,e.payload.file.files=[s]),s=e.payload.file,n.url=window.URL.createObjectURL(s.files[0]),n.name=s.files[0].name,n.size=s.files[0].size||1,n.second=s.files[0].duration||0,n.type=s.files[0].type.split("/")[1]);e.payload.file.videoFile=n;var s=this.get(17).getFileDNList(),i=new $n(e);return n=new Hn({videoFormat:n.type,videoSecond:Mt(n.second,0),videoSize:n.size,remoteVideoUrl:"",videoUrl:n.url,videoUUID:this._generateUUID(e.payload.file.videoFile),thumbUUID:this._generateUUID(e.payload.file.videoFile,"jpg"),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:"jpg"},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),s),s=this._getNickAndAvatarByUserID(t),i.setElement(n),i.setNickAndAvatar(s),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}},{key:"createCustomMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e));return e=new Kn({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),t=this._getNickAndAvatarByUserID(t),n.setElement(e),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createFaceMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e));return e=new wn(e.payload),t=this._getNickAndAvatarByUserID(t),n.setElement(e),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"createMergerMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),t=this._getNickAndAvatarByUserID(t),new $n(e));return e=new Yn(e.payload),n.setElement(e),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),n.setRelayFlag(!0),n}},{key:"createForwardMessage",value:function(e){var t,n,s=e.to,i=e.conversationType,a=e.priority,o=e.payload,r=e.needReadReceipt,c=e.receiverList;return Ve(o._elements)?(t=this.getMyUserID(),n=this._getNickAndAvatarByUserID(t),o.type===k.MSG_GRP_TIP?Jt({code:un.MSG_FORWARD_TYPE_INVALID}):(i={to:s,conversationType:i,conversationID:"".concat(i).concat(s),priority:a,isPlaceMessage:0,status:Xt,currentUser:t,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||o.cloudCustomData||"",needReadReceipt:r,receiverList:c,isSupportExtension:e.isSupportExtension||!1},(s=new $n(i)).setElement(o._elements[0]),s.setNickAndAvatar(n),s.setNameCard(this._getNameCardByGroupID(o)),s.setRelayFlag(!0),s)):Jt({code:un.MSG_FORWARD_INVALID_ELEMENTS})}},{key:"downloadMergerMessage",value:function(e){return this._mergerMessageHandler.downloadMergerMessage(e)}},{key:"createFileMessage",value:function(e){if($){if(!V&&!K&&!Y)return;var t=Q.getSystemInfoSync().SDKVersion;if(V&&mt(t,"2.5.0")<0)return void this.warn("WXChooseMessageFile");if(K&&mt(t,"1.18.0")<0)return void this.warn("QQChooseMessageFile")}Z||Y?be(e.payload.file)?(t=e.payload.file,e.payload.file={files:[t]}):xe(e.payload.file)&&"undefined"!=typeof uni&&(s=(t=e.payload.file).tempFiles,t=t.files,n=null,Ve(s)?n=s[0]:Ve(t)&&(n=t[0]),e.payload.file={files:[n]}):V||K?(t=_(_({},(s=e.payload.file.tempFiles)[0]),{},{url:s[0].path}),e.payload.file={files:[t]}):X&&(s=_(_({},n=e.payload.file),{},{url:n.uri}),e.payload.file={files:[s]}),t=this.getMyUserID();var n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e)),s=new qn({uuid:this._generateUUID(e.payload.file),file:e.payload.file});return t=this._getNickAndAvatarByUserID(t),n.setElement(s),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),this._messageOptionsMap.set(n.clientSequence,e),n}},{key:"createLocationMessage",value:function(e){var t=this.getMyUserID(),n=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new $n(e));return e=new jn(e.payload),t=this._getNickAndAvatarByUserID(t),n.setElement(e),n.setNickAndAvatar(t),n.setNameCard(this._getNameCardByGroupID(n)),n}},{key:"_onNoModule",value:function(){return Jt({code:un.NO_MODULE})}},{key:"sendMessageInstance",value:function(e,t){var n,s,i,a,o=this,r=null;if(e.conversationType===k.CONV_C2C)r=this.get(6);else{if(e.conversationType!==k.CONV_GROUP)return Jt({code:un.MSG_INVALID_CONV_TYPE});r=this.get(7)}return r?(s="".concat(this._n,".sendMessageInstance"),i=this.get(11),a=r.isOnlineMessage(e,t),this.get(17).upload(e).then(function(){return o._getSendMessageSpecifiedKey(e)===mn&&o.get(26).addSuccessCount(vn),o._guardForGroup(e).then(function(){if(!e.isSendable())return Jt({code:un.MSG_F_URL_IS_EMPTY});o._addSendMessageTotalCount(e),n=Date.now();var s=(e=>{var t="utf-8";Z&&document&&(t=document.charset.toLowerCase());var n,s=0,i=e.length;if("utf-8"===t||"utf8"===t)for(var a=0;a<i;a++)(n=e.codePointAt(a))<=127?s+=1:n<=2047?s+=2:n<=65535?s+=3:(s+=4,a++);else if("utf-16"===t||"utf16"===t)for(var o=0;o<i;o++)(n=e.codePointAt(o))<=65535?s+=2:(s+=4,o++);else s=e.replace(/[^\x00-\xff]/g,"aa").length;return s})(JSON.stringify(e));return e.type===k.MSG_MERGER&&11264<s?o._mergerMessageHandler.uploadMergerMessage(e,s).then(function(n){return n=o._mergerMessageHandler.createMergerMessagePack(e,t,n),o.req(n)}):(i.setMessageRandom(e),r.sendMessage(e,t))}).then(function(r){var c=(r=r.data).time,u=r.sequence,l=r.readReceiptCode;return r=r.messageDropReason,Ge(l)&&0!==l&&(new kn("sendMessageWithReceipt").setMessage("from:".concat(e.from," to:").concat(e.to," sequence:").concat(u," readReceiptCode:").concat(l)).end(),Ee.w("".concat(s," readReceiptCode:").concat(l," message:").concat(o.getErrMsg(l)))),r&&(l=new kn("messageDropReason"),r="from:".concat(e.from," to:").concat(e.to," sequence:").concat(u," messageDropReason:").concat(r),l.setMessage(r).end(),Ee.w("".concat(s," ").concat(r))),o._addSendMessageSuccessCount(e,n),o._messageOptionsMap.delete(e.clientSequence),!0===e.isResend&&(l=i.findMessage(e.ID))&&(Ee.l("".concat(s," resend ok. ID:").concat(l.ID)),i.deleteLocalMessage(l)),e.status=Zt,e.time=c,r=!1,e.conversationType===k.CONV_GROUP?e.sequence=u:e.conversationType===k.CONV_C2C&&(l=i.getLatestMessageSentByMe(e.conversationID))&&(c=l.nick,u=l.avatar,c===e.nick&&u===e.avatar||(r=!0)),r&&i.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),!0===a?e._onlineOnlyFlag=!0:(i.appendToMessageList(e),l=e,xe(t)&&xe(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,l=""),!0===t.messageControlInfo.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0),c=e.conversationType,ut(e.to)&&(c=k.CONV_TOPIC,o.get(10).onMessageSent({groupID:St(e.to),topicID:e.to,lastMessage:l})),i.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:c,subType:e.conversationSubType,lastMessage:l}]})),e._relayFlag||"TIMImageElem"!==e.type||yt(e.payload.imageInfoArray),zt({message:e})})}).catch(function(t){return o._onSendMessageFailed(e,t,a)})):this._onNoModule()}},{key:"_guardForGroup",value:function(e){if(e.conversationType!==k.CONV_GROUP)return Promise.resolve();var t=this.get(7);if(!t)return this._onNoModule();if(ct({groupID:e.to})){var n=t.getLocalGroupProfile(e.to);if(n&&n.isSupportTopic)return Jt({code:un.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return t.guardForAVChatRoom(e)}},{key:"_onSendMessageFailed",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],s="".concat(this._n,"._onSendMessageFailed"),i=(e.status="fail",80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0),this.get(11)),a=(i.deleteMessageRandom(e),10100<=t.code&&t.code<=10200||120001<=t.code&&t.code<=13e4);return n||a||!0===i.appendToMessageList(e)&&Ee.l("".concat(s," message stored, ID:").concat(e.ID)),this._addSendMessageFailCountOnUser(e,t),n=new kn("sendMessage"),a="head.seq:".concat(t.data.headSeq," type:").concat(e.type," from:").concat(e.from," to:").concat(e.to),Z&&("connection"in navigator&&(i=navigator.connection,a+=" downlink:".concat(i.downlink," effectiveType:").concat(i.effectiveType," rtt:").concat(i.rtt)),"memory"in window.performance)&&(i=window.performance.memory,a+=" usedJSHeapSize:".concat(i.usedJSHeapSize," totalJSHeapSize:").concat(i.totalJSHeapSize," jsHeapSizeLimit:").concat(i.jsHeapSizeLimit)),n.setMessage(a).setError(t).end(),Ee.e("".concat(s," ").concat(a," error:"),t),Jt(new cn({code:t&&t.code?t.code:un.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if([k.MSG_IMAGE,k.MSG_AUDIO,k.MSG_VIDEO,k.MSG_FILE].includes(e.type))return mn;if(e.conversationType===k.CONV_C2C)return pn;if(e.conversationType===k.CONV_GROUP){var t=this.get(7);if(t&&(t=t.getLocalGroupProfile(e.to)))return rt(e=t.type)?fn:_n}}},{key:"_addSendMessageTotalCount",value:function(e){(e=this._getSendMessageSpecifiedKey(e))&&this.get(26).addTotalCount(e)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var n;(e=this._getSendMessageSpecifiedKey(e))&&((n=this.get(26)).addSuccessCount(e),n.addCost(e,Ot(t,!1)))}},{key:"_addSendMessageFailCountOnUser",value:function(e,t){t=void 0===(t=t.code)?-1:t;var n,s=this.get(26);(e=this._getSendMessageSpecifiedKey(e))===mn&&(n=!1,n=!!Ws.includes(t)||n)?s.addFailedCountOfUserSide(vn):(n=t,t=!1,Object.values(Ys).includes(n)&&(t=!0),(t=120001<=n&&n<=13e4||10100<=n&&n<=10200||t)&&e&&s.addFailedCountOfUserSide(e))}},{key:"resendMessage",value:function(e,t){return e.isResend=!0,e.status=Xt,this.sendMessageInstance(e,t)}},{key:"revokeMessage",value:function(e){var t,n,s=this,i=null;return e.conversationType===k.CONV_C2C?i=this.get(6):e.conversationType===k.CONV_GROUP&&(i=this.get(7)),i?((t=new kn("revokeMessage")).setMessage("type:".concat(e.type," from:").concat(e.from," to:").concat(e.to)),n="".concat(this._n,".").concat("revokeMessage"),i.revokeMessage(e).then(function(i){return Ue(i=i.data.recallRetList)||0===i[0].retCode?(Ee.i("".concat(n," ok. ID:").concat(e.ID)),e.isRevoked=!0,t.end(),s.get(11).onMessageRevoked([e]),zt({message:e})):(i=new cn({code:i[0].retCode,data:{message:e}}),t.setCode(i.code).setMoreMessage(i.message).end(),Jt(i))}).catch(function(s){t.setError(s).end();var i=new cn({code:s&&s.code?s.code:un.MSG_REVOKE_FAIL,message:s&&s.message?s.message:void 0,data:{message:e}});return Ee.w("".concat(n," failed. error:"),s),Jt(i)})):this._onNoModule()}},{key:"deleteMessage",value:function(e){var t=this,n=null,s=e[0],i=s.conversationID,a="",o=[],r=[];if(s.conversationType===k.CONV_C2C)n=this.get(6),a=i.replace(k.CONV_C2C,""),e.forEach(function(e){e&&e.status===Zt&&e.conversationID===i&&(e._onlineOnlyFlag||o.push("".concat(e.sequence,"_").concat(e.random,"_").concat(e.time)),r.push(e))});else if(s.conversationType===k.CONV_GROUP)n=this.get(7),a=i.replace(k.CONV_GROUP,""),e.forEach(function(e){e&&e.status===Zt&&e.conversationID===i&&(e._onlineOnlyFlag||o.push("".concat(e.sequence)),r.push(e))});else if(s.conversationType===k.CONV_SYSTEM)return Jt({code:un.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!n)return this._onNoModule();if(0===o.length)return this._onMessageDeleted(r);30<o.length&&(o=o.slice(0,30),r=r.slice(0,30));var c=new kn("deleteMessage"),u=(c.setMessage("to:".concat(a," count:").concat(o.length)),"".concat(this._n,".").concat("deleteMessage"));return n.deleteMessage({to:a,keyList:o}).then(function(e){return c.end(),Ee.i("".concat(u," ok")),t._onMessageDeleted(r)}).catch(function(e){return c.setError(e).end(),Ee.w("".concat(u," failed. error:"),e),Jt(e=new cn({code:e&&e.code?e.code:un.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0}))})}},{key:"_onMessageDeleted",value:function(e){return this.get(11).onMessageDeleted(e),$t({messageList:e})}},{key:"translateText",value:function(e){var t="".concat(this._n,".").concat("translateText"),n=e.sourceTextList,s=e.sourceLanguage,i=(e=e.targetLanguage,new kn("translateText"));return i.setMessage("sourceLanguage:".concat(s," targetLanguage:").concat(e)),this.req({P:dn.TRANSLATE_TEXT,data:{sourceTextList:n,source:s||"auto",target:e,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then(function(e){var n=(e=e.data).error,s=e.requestID;if(e=e.translatedTextList,0===n.code)return i.end(),Ee.i("".concat(t," ok. requestID:").concat(s)),zt({translatedTextList:e});throw _(_({},n),{},{requestID:s})}).catch(function(e){return i.setCode(e.code).setMoreMessage(e.requestID).end(),Ee.w("".concat(t," failed. error:"),e),Jt({code:e.code||un.TRANSLATE_TEXT_FAIL,message:e.message})})}},{key:"convertVoiceToText",value:function(e){var t,n,s,i=e.message,a=(e=e.language,i.payload.url);return(i.from===this.getMyUserID()&&"out"===i.flow&&(a=i.payload.remoteAudioUrl),i=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/).test(a)?(i=i.exec(a)[1]||"mp3",t="16k_zh-PY",e?"zh (cmn-Hans-CN)"===e?t="16k_zh":"en-US"===e?t="16k_en":"yue-Hant-HK"===e?t="16k_yue":"ja-JP"===e&&(t="16k_ja"):t="16k_zh-PY",e="serviceType:".concat(t," url:").concat(a),n="".concat(this._n,".").concat("convertVoiceToText"),Ee.i("".concat(n," ").concat(e)),(s=new kn("convertVoiceToText")).setMessage(e),this.req({P:dn.VOICE_TO_TEXT,data:{url:a,language:t,SDKAppID:this.getSDKAppID(),format:i}}).then(function(e){var t=(e=e.data).error,i=e.requestID;if(e=e.result,0===t.code)return s.end(),Ee.i("".concat(n," ok. requestID:").concat(i)),zt({result:e});throw _(_({},t),{},{requestID:i})}).catch(function(e){return s.setCode(e.code).setMoreMessage(e.requestID||"").end(),Ee.w("".concat(n," failed. error:"),e),Jt({code:un.VOICE_TO_TEXT_FAIL})})):Jt({code:un.UNSUPPORTED_VOICE_FORMAT})}},{key:"modifyRemoteMessage",value:function(e){var t=this,n=null,s=e.conversationType,i=e.to;if(s===k.CONV_C2C)n=this.get(6);else if(s===k.CONV_GROUP){if(!(n=this.get(7)))return this._onNoModule();if(n.isMessageFromOrToAVChatroom(i))return Jt({code:un.MSG_MODIFY_DISABLED_IN_AV,data:{message:e}})}var a=new kn("modifyMessage"),o=(a.setMessage("to:".concat(i)),"".concat(this._n,".modifyRemoteMessage"));return n.modifyRemoteMessage(e).then(function(n){return a.end(),Ee.i("".concat(o," ok")),zt({message:n=t._onModifyRemoteMessageResp(e,n.data)})}).catch(function(n){var s;return a.setCode(n.code).setMoreMessage(n.message).end(),Ee.w("".concat(o," failed. error:"),n),20027===n.code?(s=t._onModifyRemoteMessageResp(e,n.data),Jt({code:un.MSG_MODIFY_CONFLICT,data:{message:s}})):Jt({code:n.code,message:n.message,data:{message:e}})})}},{key:"_onModifyRemoteMessageResp",value:function(e,t){Ee.d("".concat(this._n,"._onModifyRemoteMessageResp options:"),t);var n=e.conversationType,s=e.from,i=e.to,a=e.random,o=e.sequence,r=(e=e.time,t.elements),c=t.messageVersion;return t=void 0===(t=t.cloudCustomData)?"":t,this.get(11).onMessageModified({conversationType:n,from:s,to:i,time:e,random:a,sequence:o,elements:r,cloudCustomData:t,messageVersion:c})}},{key:"_generateUUID",value:function(e,t){var n=this.get(12);return n="".concat(n.getSDKAppID(),"-").concat(n.getUserID(),"-").concat((()=>{for(var e="",t=32;0<t;--t)e+=st[Math.floor(Math.random()*it)];return e})()),(t=t||(e=(t=Ve((t=e).files)?e.files[0]:t).name||t.value||t.url||t.tempFilePath)&&e.slice(e.lastIndexOf(".")+1))?"".concat(n,".").concat(t):n}},{key:"getMessageOption",value:function(e){return this._messageOptionsMap.get(e)}},{key:"_getNickAndAvatarByUserID",value:function(e){return this.get(4).getNickAndAvatarByUserID(e)}},{key:"_getNameCardByGroupID",value:function(e){if(e.conversationType===k.CONV_GROUP){var t=this.get(7);if(t)return t.getMyNameCardByGroupID(e.to)}return""}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._messageOptionsMap.clear()}}]),Js=(l(ei,sn),o(ei,[{key:"registerPlugin",value:function(e){var t=this,n="0";Object.keys(e).forEach(function(s){t.plugins[s]=e[s],"tim-upload-plugin"===s&&"function"==typeof e[s].getVersion&&(n=e[s].getVersion())}),new kn("registerPlugin").setMessage("".concat(Object.keys(e))).setMoreMessage("version:".concat(n)).end()}},{key:"getPlugin",value:function(e){return this.plugins[e]}},{key:"reset",value:function(){}}])),Xs=(l(Qs,sn),o(Qs,[{key:"_init",value:function(){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"_startSync",value:function(e){var t=this,n=e.cookie,s=e.syncFlag,i=e.isOnlineSync,a="".concat(this._n,"._startSync"),o=(Ee.l("".concat(a," options:"),e),new kn("syncUnread"));o.setMessage(JSON.stringify(e)),this.req({P:dn.SYNC_UNREAD_MSG,data:{cookie:n,syncFlag:s,isOnlineSync:i}}).then(function(e){var n=(s=e.data).cookie,s=s.syncFlag,i="$cookie:".concat(n," syncFlag:").concat(s);Ee.l("".concat(a," ok. ").concat(i)),t._cookie=n,o.setMoreMessage(i).end(),Ue(n)||(0===s||1===s?(t._dispatch(_(_({},e.data),{},{isSyncingEnded:!1})),t._startSync({cookie:n,syncFlag:s,isOnlineSync:0})):2===s&&t._dispatch(_(_({},e.data),{},{isSyncingEnded:!0})))}).catch(function(e){o.setError(e).end(),Ee.e("".concat(a," failed. error:"),e)})}},{key:"_dispatch",value:function(e){e.eventArray&&this.get(20).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}}),this.get(6).onNewMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded})}},{key:"syncOnNeed",value:function(){Ee.l("".concat(this._n,".syncOnNeed cookie:").concat(this._cookie)),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}},{key:"syncOnReconnected",value:function(){Ee.l("".concat(this._n,".syncOnReconnected cookie:").concat(this._cookie)),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._onlineSyncFlag=!1,this._cookie=""}}])),Zs={req:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic",isWebUniapp:"is_web_uniapp",isSupportExtension:"SupportMessageExtension",messageSequence:"MsgSeq",messageKey:"MsgKey",startSequence:"startSeq",simplifiedMessage:"DownsizeFlag",isRelayMessage:"IsRelayMsg",reactionID:"Reaction",messageSequenceList:"MsgSeqList",messageKeyList:"MsgKeyList",cmConfigID:"CustomModerationConfigID",streamMessageID:"StreamMsgID",ackIndex:"AckIndex"},res:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"isWithChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified",ApplyJoinOption:"joinOption",MsgFlag:"messageRemindType",AtInfoList:"groupAtInfoList",AtFlagList:"groupAtType",AtMsgSeq:"sequence",BanDuration:"duration",BanDescription:"reason",NotVisible:"invisible",BytesTag:"tag",BytesValue:"value",RptBytesValue:"value",LatestSeq:"globalSequence",ClearSeq:"clearSequence",SupportMessageExtension:"isSupportExtension",ExtensionList:"extensions",GroupCounter:"counterList",Revoker_Account:"revoker",MsgExtensionNotify:"messageExtensionNotify",ExtensionC2cMsgInfo:"messageInfo",ExtensionGroupMsgInfo:"messageInfo",MsgOptType:"operateType",SetKVInfo:"operateResultList",DeleteKVInfo:"operateResultList",ClearKVInfo:"operateResultList",MsgKeyValue:"extensions",ClearMsgSeq:"clearSequence",MsgLastSeq:"globalSequence",InviteJoinOption:"inviteOption",MemberList_Account:"inviteeList",MsgMemberExtraInfoList:"inviteeInfoList",E:"event",GInf:"groupProfile",MCT:"clientTime",MR:"random",MP:"priority",MTS:"time",GId:"groupID",MS:"sequence",CCD:"cloudCustomData",F_Account:"from",F_Hd:"avatar",F_NN:"nick",GN:"groupName",GT:"groupType",IsSys:"isSystemMessage",OpInf:"operatorInfo",Img:"avatar",NN:"nick",OnlineInf:"onlineMemberInfo",ET:"expireTime",Num:"onlineMemberNum",Opt:"operationType",O_Account:"operatorID",RT:"operationType",UDF:"userDefinedField",L_Account:"userIDList",IsPlaceMsg:"isPlaceMessage",MsgCheckResult:"checkResult",Results:"resultList",Reaction:"reactionID",Reaction_Account:"userIDList",MsgReactionNotifyList:"messageReactionNotifyList",MsgReactionNotify:"messageReactionNotify",MsgReactionSummary:"reactionList",C2CMsgInfo:"C2CMessageInfo",GroupMsgInfo:"groupMessageInfo",int32_err_code:"errorCode",str_err_msg:"errorMsg",MsgDropReason:"messageDropReason",ReactedByMe:"reactedByMyself",Level:"messageRemindType",PeerReadTime:"timestamp",NoUnreadSeqList:"excludedUnreadSequenceList",NewMsg:"topicLatestMessage",PinnedMsg:"pinnedMessage",SdkGroupMessageId:"unPinnedMessageInfo",StreamID:"streamMessageID",StreamMsgID:"streamMessageID"},ignoreKeyWord:["C2C","ID","USP"]};function Qs(e){return i(this,Qs),(e=n(this,Qs,[e]))._n="SyncUnreadMsgModule",e._cookie="",e._onlineSyncFlag=!1,e.getIEmitInst().on(ss.A2KEY_AND_TINYID_UPDATED,e._init,e),e}function ei(e){return i(this,ei),(e=n(this,ei,[e]))._n="PluginModule",e.plugins={},e}function ti(e){return i(this,ti),(e=n(this,ti,[e]))._n="MessageModule",e._messageOptionsMap=new Map,e._mergerMessageHandler=new Bs(e),e}function ni(e,t){if("string"==typeof e||Array.isArray(e))return t=Object.assign({pascalCase:!1},t),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=(e=e!==e.toLowerCase()?si(e):e).replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,function(e,t){return t.toUpperCase()}).replace(/\d+(\w|$)/g,function(e){return e.toUpperCase()}),t.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e);throw new TypeError("Expected the input to be `string | string[]`")}var si=function(e){for(var t=!1,n=!1,s=!1,i=0;i<e.length;i++){var a=e[i];t&&/[a-zA-Z]/.test(a)&&a.toUpperCase()===a?(e=e.slice(0,i)+"-"+e.slice(i),s=n,n=!(t=!1),i++):n&&s&&/[a-zA-Z]/.test(a)&&a.toLowerCase()===a?(e=e.slice(0,i-1)+"-"+e.slice(i-1),s=n,t=!(n=!1)):(t=a.toLowerCase()===a&&a.toUpperCase()!==a,s=n,n=a.toUpperCase()===a&&a.toLowerCase()!==a)}return e};function ii(e,t){var n=0;return function e(t,s){var i,a,o,r;return 100<++n?(n--,t):Ve(t)?(i=t.map(function(t){return Fe(t)?e(t,s):t}),n--,i):Fe(t)?(a=t,o=function(e,t){if(!He(t))return!1;if(t!==ni(t))for(var n=0;n<Zs.ignoreKeyWord.length&&!t.includes(Zs.ignoreKeyWord[n]);n++);var i;return Ze(s[t])?(i=t)[0].toUpperCase()+ni(i).slice(1):s[t]},r=Object.create(null),Object.keys(a).forEach(function(e){var t=o(a[e],e);t&&(r[t]=a[e])}),i=gt(i=r,function(t,n){return Ve(t)||Fe(t)?e(t,s):t}),n--,i):void 0}(e,t)}for(var ai=String.fromCharCode,oi=function(e){var t=0|e.charCodeAt(0);if(55296<=t)if(t<56320)if(56320<=(e=0|e.charCodeAt(1))&&e<=57343){if(65535<(t=(t<<10)+e-56613888|0))return ai(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?ai(192|t>>>6,128|63&t):ai(224|t>>>12,128|t>>>6&63,128|63&t)},ri=function(e){for(var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,oi),n=0|t.length,s=new Uint8Array(n),i=0;i<n;i=i+1|0)s[i]=0|t.charCodeAt(i);return s},ci=o(function e(t){var n,s,a=this,o=(i(this,e),(this._handler=t).getURL());this._socket=null,this._workerSocket=null,this._id=We(),this._handler.getIsWorkerEnabled()?(s=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", extensions: _socket.extensions }); }; _socket.onclose = function(e) { postMessage({ callback: "onClose", 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(s),(n=this)._workerSocket.onmessage=function(e){var t=e.data,s=t.callback,i=t.e;"onOpen"===s?n._onOpen(t.extensions):"onClose"===s?n._onClose(i):"onError"===s?n._onError(i):"onMessage"===s&&n._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:o})):$?(s={"content-type":"application/json"},B?(Q.connectSocket({url:o,header:s}),Q.onSocketClose(this._onClose.bind(this)),Q.onSocketOpen(this._onOpen.bind(this)),Q.onSocketMessage(this._onMessage.bind(this)),Q.onSocketError(this._onError.bind(this))):H?this._socket=Q.connectSocket({url:o,header:s,success:function(){a._bindEventsInMini()},fail:function(e){a._onFail({code:e.errNo,reason:e.errMsg})}}):(this._socket=Q.connectSocket({url:o,header:s,complete:function(){}}),this._bindEventsInMini())):(this._socket=new WebSocket(o),this._socket.binaryType="arraybuffer",this._socket.onopen=this._onOpen.bind(this,this._socket.extensions),this._socket.onmessage=this._onMessage.bind(this),this._socket.onclose=this._onClose.bind(this),this._socket.onerror=this._onError.bind(this)),this._canIUseBinaryFrame=t.canIUseBinaryFrame()},[{key:"getID",value:function(){return this._id}},{key:"getClient",value:function(){return this._socket}},{key:"_bindEventsInMini",value:function(){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))}},{key:"_onOpen",value:function(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}},{key:"_onClose",value:function(e){this._handler.onClose({id:this._id,e:e})}},{key:"_onFail",value:function(e){this._handler.onFail({id:this._id,e:e})}},{key:"_onMessage",value:function(e){e=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):(e=>{for(var t=new Uint8Array(e),n="",s=0,i=t.length;s<i;){var a=t[s],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),0<i-s-o)for(var c=0;c<o;)r=r<<6|63&(a=t[s+c+1]),c+=1;else r=65533,o=i-s;n+=String.fromCodePoint(r),s+=o+1}return n})(e.data):e.data,this._handler.onMessage({data:e})}},{key:"_isAppCompressedData",value:function(e){return 67===(e=new Uint8Array(e))[0]&&79===e[1]&&77===e[2]&&80===e[3]}},{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){this._workerSocket&&(this._workerSocket.postMessage({cmd:"stop",code:e}),this._workerSocket.terminate(),this._workerSocket=null),B?(Q.offSocketClose(),Q.offSocketMessage(),Q.offSocketOpen(),Q.offSocketError(),Q.closeSocket()):this._socket&&($?(this._socket.onClose(function(){}),this._socket.onOpen(function(){}),this._socket.onMessage(function(){}),this._socket.onError(function(){})):(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),j?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}},{key:"send",value:function(e){this._workerSocket?this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?ri(e.data).buffer:e.data}):B?Q.sendSocketMessage({data:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket&&($?this._socket.send({data:this._canIUseBinaryFrame?ri(e.data).buffer:e.data,fail:function(){e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket.send(this._canIUseBinaryFrame?ri(e.data):e.data))}}]),ui=["keyMap"],li=["keyMap"],di="connected",hi="connecting",gi="disconnected",pi=o(function e(t){i(this,e),this._chM=t,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=gi,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=We(),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._currentSite=L,this._setWebsocketHost(),this._initConnection(),this._addAppVisibilityListener()},[{key:"_addAppVisibilityListener",value:function(){var e=this;H&&Q.onAppShow(function(){Ee.l("".concat(e._n,"._addAppVisibilityListener onAppShow readyState:").concat(e._readyState)),e._readyState===gi&&e._initConnection()})}},{key:"_setWebsocketHost",value:function(){var e=this._chM.get(12);this._currentSite=L,this._chM.isOversea()&&(this._currentSite="OVERSEA"),e.isSingaporeSite()?this._currentSite="SINGAPORE":e.isKoreaSite()?this._currentSite="KOREA":e.isGermanySite()?this._currentSite="GERMANY":e.isIndiaSite()?this._currentSite="IND":e.isJapanSite()?this._currentSite="JPN":e.isUSASite()?this._currentSite="USA":e.isIndonesiaSite()&&(this._currentSite="INDONESIA"),U.HOST.setCurrent(this._currentSite)}},{key:"_initConnection",value:function(){var e=this._chM.get(12).getSDKAppID()+"",t=this._chM.get(12).isIndependentDomainDisabled();Ue(e=(Ze(U.HOST.CURRENT.BACKUP)?this._url=U.HOST.CURRENT.DEFAULT:""===this._url?this._url=t?U.HOST.CURRENT.DEFAULT:U.HOST.CURRENT.DEFAULT0.replace("*",e):-1<this._url.indexOf(e)?this._url=U.HOST.CURRENT.DEFAULT:this._url===U.HOST.CURRENT.DEFAULT?this._url=U.HOST.CURRENT.IPV6:this._url===U.HOST.CURRENT.IPV6?this._url=Z?this._genRandomDomain():U.HOST.CURRENT.BACKUP:this._isWebBackupUrl(this._url)||this._url===U.HOST.CURRENT.BACKUP?this._canIUseBackupCN()?this._url=U.HOST.CURRENT.BACKUP_CN:this._canIUseAnyCast()?this._url=U.HOST.CURRENT.ANYCAST:this._url=U.HOST.CURRENT.DEFAULT:this._url===U.HOST.CURRENT.BACKUP_CN?this._url=this._canIUseAnyCast()?U.HOST.CURRENT.ANYCAST:U.HOST.CURRENT.DEFAULT:this._url===U.HOST.CURRENT.ANYCAST&&(U.HOST.CURRENT.ANYCAST="",this._url=U.HOST.CURRENT.DEFAULT),t=this._chM.get(12)).getProxyServer())||(this._url=e),t.isTestEnv()&&(this._url=R.TEST[this._currentSite].DEFAULT),this._connect(),this._nextPingTs=0}},{key:"_genRandomDomain",value:function(){var e=Math.floor(10001*Math.random())+1e4;return U.HOST.CURRENT.BACKUP_WEB.replace("*",e)}},{key:"_isWebBackupUrl",value:function(e){return e.includes("my-cpaas.com")}},{key:"_canIUseAnyCast",value:function(){return Z&&U.HOST.CURRENT.ANYCAST}},{key:"_canIUseBackupCN",value:function(){return U.HOST.CURRENT.BACKUP_CN}},{key:"onCheckTimer",value:function(e){e%1==0&&(this._checkPromiseMap(),this._checkNativeAppWS())}},{key:"_checkPromiseMap",value:function(){var e=this;0!==this._promiseMap.size&&this._promiseMap.forEach(function(t,n){var s=t.reject,i=t.timestamp,a=(t=t.headSeq,15e3);-1!==n.indexOf(dn.LOGIN)?a=9e4:-1!==n.indexOf(dn.PING)&&(a=3e3),Date.now()-i>=a&&(Ee.l("".concat(e._n,"._checkPromiseMap request timeout, delete requestID:").concat(n)),e._promiseMap.delete(n),s(new cn({code:un.NETWORK_TIMEOUT,data:{headSeq:t}})),e._chM.onRequestTimeout())})}},{key:"_checkNativeAppWS",value:function(){Y&&!this.isConnected()&&this._reConnect()}},{key:"onOpen",value:function(e){var t,n;this._readyState!==gi&&(this._onOpenTs=Date.now(),n=e.id,e=e.res,this._socketID=n,t=Ot(this._startTs,!1),n="socketID:".concat(n," res:").concat(e),Ee.l("".concat(this._n,"._onOpen cost:").concat(t," ms. ").concat(n)),new kn("wsOnOpen").setMessage(t).setCostTime(t).setMoreMessage(n).end(),this._readyState=di,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._chM.onReconnected(),this._reConnectFlag=!1),this._chM.onOpen())}},{key:"onClose",value:function(e){var t=new kn("wsOnClose"),n=e.id,s=(e=e.e,"sourceSocketID:".concat(n," currentSocketID:").concat(this._socketID," code:").concat(e.code," reason:").concat(e.reason)),i=0;0!==this._onOpenTs&&(i=Date.now()-this._onOpenTs),t.setMessage(i).setCostTime(i).setMoreMessage(s).setCode(e.code).end(!0),Ee.l("".concat(this._n,"._onClose ").concat(s," onlineTime:").concat(i)),n!==this._socketID||B&&!0===this._reConnectFlag&&n===this._socketID&&0===i||(this._readyState=gi,i<1e3?this._chM.onReconnectFailed():this._chM.onClose())}},{key:"onError",value:function(e){var t=e.id,n=(e=e.e,"sourceSocketID:".concat(t," currentSocketID:").concat(this._socketID));new kn("wsOnError").setMessage(e.errMsg||JSON.stringify(e,["message","code"])).setMoreMessage(n).setLevel("error").end(!0),Ee.w("".concat(this._n,"._onError"),e,n),t===this._socketID&&(this._readyState=gi,this._chM.onError())}},{key:"onFail",value:function(e){this._readyState=gi;var t=e.id;e=e.e,t="currentSocketID:".concat(t," code:").concat(e.code," reason:").concat(e.reason),new kn("wsOnFail").setMessage(t).setCode(e.code).end(!0),Ee.l("".concat(this._n,"._onFail ").concat(t))}},{key:"onMessage",value:function(e){var t,n,s,i,a,o;try{t=JSON.parse(e.data)}catch(t){new kn("jsonParseError").setMessage(e.data).end()}t&&t.head&&(e=this._getRequestIDFromHead(t.head),n=t.body,this._chM.get(30).isTRTCCommand(e)||(o=It(t.head),n=function e(t,n){var s,i,a;return Ve(t)?t.map(function(t){return Fe(t)?e(t,n):t}):Fe(t)?(s=t,i=function(e,t){return Ze(n[t])?ni(t):n[t]},a={},Object.keys(s).forEach(function(e){a[i(s[e],e)]=s[e]}),gt(a,function(t){return Ve(t)||Fe(t)?e(t,n):t})):void 0}(t.body,this._getResKeyMap(o))),Ee.d("".concat(this._n,".onMessage ret:").concat(JSON.stringify(n)," requestID:").concat(e," has:").concat(this._promiseMap.has(e))),this._setNextPingTs(),this._promiseMap.has(e)?(s=(o=this._promiseMap.get(e)).resolve,i=o.reject,a=o.timestamp,o=o.headSeq,this._promiseMap.delete(e),this._calcRTT(a),n.errorCode&&0!==n.errorCode?(this._chM.onErrorCodeNotZero(n),i(new cn({code:n.errorCode,message:n.errorInfo||"",data:e.includes(dn.MODIFY_C2C_MSG)||e.includes(dn.MODIFY_GRP_MSG)?{elements:n.elements,messageVersion:n.messageVersion,cloudCustomData:n.cloudCustomData,headSeq:o}:{headSeq:o}}))):s(zt(n))):this._chM.onMessage({head:t.head,body:n}))}},{key:"_calcRTT",value:function(e){e=Date.now()-e,this._chM.get(26).addRTT(e)}},{key:"_connect",value:function(){if(this._readyState!==hi&&this._readyState!==di){if(this._startTs=Date.now(),this._onOpenTs=0,this._readyState=hi,this._socket=new ci(this),this._socketID=this._socket.getID(),H){var e=this._socket.getClient().readyState;if(Ze(e))return void(this._readyState=gi)}new kn("wsConnect").setMessage("socketID:".concat(this._socketID," url:").concat(this.getURL())).end(),Ee.l("".concat(this._n,"._connect isWorkerEnabled:").concat(this.getIsWorkerEnabled()," socketID:").concat(this._socketID," url:").concat(this.getURL()))}}},{key:"getURL",value:function(){this._chM.isDevMode()&&(this._canIUseBinaryFrame=!1);var e=ft(),t=((B||V&&"windows"===e)&&(this._canIUseBinaryFrame=!1),Y&&(i=void 0===(i=(n=v((s=void 0===(s=Q.getSystemInfoSync().uniRuntimeVersion)?"":s).split(".").map(Number),3))[0])?0:i,t=void 0===(t=n[1])?0:t,n=n[2],i=2<i||!(i<2)&&(2<t||!(t<2)&&6<=(void 0===n?0:n)),Ee.l("".concat(this._n,".getURL uniRuntimeVersion:").concat(s," isUniRuntimeVersionGte226:").concat(i)),i||(this._canIUseBinaryFrame=!1)),-1),n=("ios"===e?t=se||-1:"android"===e&&(t=ae||-1),this._chM.get(12)),s=this._chM.getPlatform(),i=n.getSDKAppID(),a=n.getInstanceID();return a="sdkappid=".concat(i,"&instanceid=").concat(a,"&random=").concat(this._getRandom(),"&platform=").concat(s,"&host=").concat(e)+"&version=".concat(t,"&sdkversion=").concat(S),q&&(a+="&isminigame=1"),this._chM.canIUseInflate()&&(a+="&compress=gzip"),(this._canIUseBinaryFrame?"".concat(this._url,"/binfo?"):"".concat(this._url,"/info?")).concat(a)}},{key:"_closeConnection",value:function(e){Ee.l("".concat(this._n,"._closeConnection socketID:").concat(this._socketID)),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=gi)}},{key:"_resend",value:function(){var e=this;if(Ee.l("".concat(this._n,"._resend reConnectFlag:").concat(this._reConnectFlag),"promiseMap.size:".concat(this._promiseMap.size," simpleRequestMap.size:").concat(this._simpleRequestMap.size)),0<this._promiseMap.size&&this._promiseMap.forEach(function(t,n){var s=t.uplinkData,i=t.resolve;t=t.reject,-1!==n.indexOf(dn.AV_POLLING)?e._promiseMap.delete(n):(e._promiseMap.set(n,{resolve:i,reject:t,timestamp:Date.now(),uplinkData:s}),e._execute(n,s))}),0<this._simpleRequestMap.size){var t,n=r(this._simpleRequestMap);try{for(n.s();!(t=n.n()).done;){var s=v(t.value,2),i=s[0],a=s[1];this._execute(i,a)}}catch(t){n.e(t)}finally{n.f()}this._simpleRequestMap.clear()}}},{key:"send",value:function(e){var t=this,n=(e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3),e.head.cs=this._calcCheckSum(e.head.servcmd,e.body),e.keyMap,f(e,ui)),s=this._getRequestIDFromHead(e.head),i=JSON.stringify(n);return new Promise(function(a,o){t._promiseMap.set(s,{resolve:a,reject:o,timestamp:Date.now(),uplinkData:i,headSeq:e.head.seq}),Ee.d("".concat(t._n,".send uplinkData:").concat(JSON.stringify(n)," requestID:").concat(s," readyState:").concat(t._readyState)),t._readyState!==di?t._reConnect():(t._execute(s,i),t._chM.get(26).addRequestCount())})}},{key:"simplySend",value:function(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3),e.keyMap;var t=f(e,li);e=this._getRequestIDFromHead(e.head),t=JSON.stringify(t),this._readyState!==di?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(e,t):Ee.l("".concat(this._n,".simplySend. simpleRequestMap is full, drop request!")),this._reConnect()):this._execute(e,t)}},{key:"_execute",value:function(e,t){this._socket.send({data:t,fail:$?this._onSendFail.bind(this):void 0,requestID:e})}},{key:"_onSendFail",value:function(e){Ee.l("".concat(this._n,"._onSendFail requestID:").concat(e)),this._chM.onSendFail()}},{key:"_getSequence",value:function(){var e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=We()),e}},{key:"_getRequestIDFromHead",value:function(e){return e.servcmd+e.seq}},{key:"_getResKeyMap",value:function(e){return e=this._chM.getKeyMap(e),_(_({},Zs.res),e.res)}},{key:"_reConnect",value:function(){this._readyState!==di&&this._readyState!==hi&&this.forcedReconnect()}},{key:"forcedReconnect",value:function(){var e="".concat(this._n,".forcedReconnect");Ee.l("".concat(e," count:").concat(this._reConnectCount," readyState:").concat(this._readyState)),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(4001),this._initConnection()):(this._reConnectCount=0,this._chM.get(15).isOnline()?(Ee.w("".concat(e," disconnected from wsserver but network is ok, continue...")),this._closeConnection(4001),this._initConnection()):this._chM.onReconnectFailed())}},{key:"getReconnectFlag",value:function(){return this._reConnectFlag}},{key:"_setNextPingTs",value:function(){this._nextPingTs=Y?Date.now()+5e3:Date.now()+1e4}},{key:"getNextPingTs",value:function(){return this._nextPingTs}},{key:"isConnected",value:function(){return this._readyState===di}},{key:"canIUseBinaryFrame",value:function(){return this._canIUseBinaryFrame}},{key:"getSocketID",value:function(){return this._socketID}},{key:"inflate",value:function(e){if(this._chM.canIUseInflate())return this._chM.get(37).inflate(e)}},{key:"setIsWorkerEnabled",value:function(e){Ee.l("".concat(this._n,".setIsWorkerEnabled flag:").concat(e)),this._isWorkerEnabled=e}},{key:"getIsWorkerEnabled",value:function(){return this._isWorkerEnabled&&le}},{key:"_getRandom",value:function(){return 0===this._random&&(this._random=Math.random()),this._random}},{key:"_resetRandom",value:function(){this._random=0}},{key:"_calcCheckSum",value:function(e,t){if(-1!==e.indexOf(dn.PING)||-1!==e.indexOf(dn.LOGIN)||-1!==e.indexOf(dn.LOGOUT)||-1!==e.indexOf(dn.AV_POLLING)||-1!==e.indexOf(dn.AV_NOAUTH_POLLING))return 0;for(var n=ri(JSON.stringify(t)),s=4294967295,i=0,a=n.length;i<a;i++){s^=n[i];for(var o=0;o<8;o++)1&~s?s>>>=1:s=s>>>1^3988292384}return(4294967295^s)>>>0}},{key:"close",value:function(){Ee.l("".concat(this._n,".close")),this._closeConnection(4e3),this._promiseMap.clear(),this._startSequence=We(),this._readyState=gi,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}]),_i=function(e,t,n){return new Promise(function(s,i){var a,o,r="application/x-www-form-urlencoded;charset=UTF-8";$?Q.request({url:t,data:n,method:e,timeout:3e3,header:{"content-type":r},success:function(e){e&&e.data&&e.data.NetCheckInfo&&Ee.l("".concat("getconninfo ok in"," miniapp. ret:"),e.data),s()},fail:function(){i(new cn({code:un.NETWORK_ERROR}))}}):(a=new XMLHttpRequest,o=setTimeout(function(){a.abort(),i(new cn({code:un.NETWORK_TIMEOUT}))},3e3),a.onreadystatechange=function(){4===a.readyState&&(o&&clearTimeout(o),200===a.status||304===a.status?(a.responseText&&-1<a.responseText.indexOf("NetCheckInfo")&&Ee.l("".concat("getconninfo ok in"," web. ret:"),JSON.parse(a.responseText)),s()):i(new cn({code:un.NETWORK_ERROR})))},a.open(e,t,!0),a.setRequestHeader("Content-type",r),n?a.send(n):a.send())})},fi=(l(Ei,sn),o(Ei,[{key:"onCheckTimer",value:function(e){this._socketHandler&&(this.isLoggedIn()?(0<this._timerForNotLoggedIn&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}},{key:"onErrorCodeNotZero",value:function(e){this.get(20).onErrorCodeNotZero(e)}},{key:"onMessage",value:function(e){this.get(20).onMessage(e)}},{key:"send",value:function(e){return this._socketHandler?this._previousState!==k.NET_STATE_CONNECTED&&e.head.servcmd.includes(dn.SSO_STAT)?(this.reConnect(),this.isPrivateNetWork()?Promise.resolve():this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}},{key:"_sendLogViaHTTP",value:function(e){var t=U.HOST.CURRENT.STAT;return t="".concat(t,"/v4/imopenstat/tim_web_report_v2?sdkappid=").concat(e.head.sdkappid,"&reqtime=").concat(Date.now()),e=JSON.stringify(e.body),_i("POST",t,e)}},{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(k.NET_STATE_DISCONNECTED),this.reConnect()}},{key:"onError",value:function(){$&&!Y&&this.warn("DomainNameInMP"),this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED)}},{key:"getKeyMap",value:function(e){return this.get(20).getKeyMap(e)}},{key:"onRequestTimeout",value:function(){3e4<=Date.now()-this._lastDiagnoseTS&&this.diagnose()}},{key:"onSendFail",value:function(){this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED)}},{key:"onReconnected",value:function(){Ee.l("".concat(this._n,".onReconnected cost:").concat(Ot(this._disconnectedTS,!0,!0))),this._m.restartTimer(),this.get(20).onReconnected(Ot(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(k.NET_STATE_CONNECTED)}},{key:"onReconnectFailed",value:function(){Ee.l("".concat(this._n,".onReconnectFailed")),this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED)}},{key:"setIsWorkerEnabled",value:function(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}},{key:"offline",value:function(){this._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED)}},{key:"reConnect",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=!1,n=(this._socketHandler&&(t=this._socketHandler.getReconnectFlag()),"forcedFlag:".concat(e," fatalErrorFlag:").concat(this._fatalErrorFlag," previousState:").concat(this._previousState," reconnectFlag:").concat(t));Ee.l("".concat(this._n,".reConnect ").concat(n)),this._fatalErrorFlag||!this._socketHandler||!0!==e&&this._previousState===k.NET_STATE_CONNECTING&&t||(this._socketHandler.forcedReconnect(),this._emitNetStateChangeEvent(k.NET_STATE_CONNECTING))}},{key:"_emitNetStateChangeEvent",value:function(e){this._previousState!==e&&(Ee.l("".concat(this._n,"._emitNetStateChangeEvent from ").concat(this._previousState," to ").concat(e)),e===k.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now(),this.diagnose()),this._previousState=e,this.emitOEvt(E.NET_STATE_CHANGE,{state:e}))}},{key:"_ping",value:function(){var e,t=this;!0!==this._probing&&(this._probing=!0,e=this.get(20).getProtocolData({P:dn.PING}),this.send(e).then(function(){t._probing=!1}).catch(function(e){t._probing=!1;var n=t.get(15).isOnline();Ee.w("".concat(t._n,"._ping failed. bOnline:").concat(n," error:"),e),e&&60002===e.code?(new kn("error").setMessage("code:".concat(e.code," message:").concat(e.message)).end(),t._fatalErrorFlag=!0,t._emitNetStateChangeEvent(k.NET_STATE_DISCONNECTED)):n?t.reConnect():t._emitNetStateChangeEvent(k.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),-1<this._timerForNotLoggedIn&&clearInterval(this._timerForNotLoggedIn)}},{key:"onRestApiKickedOut",value:function(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}},{key:"canIUseInflate",value:function(){return this._m.canIUseInflate()}},{key:"getSocketID",value:function(){if(this._socketHandler)return this._socketHandler.getSocketID()}},{key:"diagnose",value:function(){this.isPrivateNetWork()||(this._lastDiagnoseTS=Date.now(),this._diagnoseBySSO(),this._diagnoseByCDN())}},{key:"_diagnoseBySSO",value:function(){var e=this,t=this._socketHandler.getURL(),n=t.split("/")[2];n.startsWith("ws")&&(t=t.slice(t.indexOf("info?")+5),n="https://".concat(n,"/v3/netcheck/getconninfo?").concat(t,"&reqtime=").concat(Date.now()),_i("GET",n).catch(function(t){Ee.w("".concat(e._n,"._diagnoseBySSO failed. error:"),t)}))}},{key:"_diagnoseByCDN",value:function(){var e=this,t=(t=this._socketHandler.getURL()).slice(t.indexOf("info?")+5);t="https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?".concat(t,"&reqtime=").concat(Date.now()),_i("GET",t).catch(function(t){Ee.w("".concat(e._n,"._diagnoseByCDN failed. error:"),t)})}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._previousState=k.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0,this._lastDiagnoseTS=0}}])),mi=o(function e(t){i(this,e),this._n="PHandler",this._sessionM=t,this._map=new Map,this._fillMap()},[{key:"_fillMap",value:function(){this._map.clear();var e=this._sessionM.genCommonHead(),t=this._sessionM.genCosSpecifiedHead(),n=this._sessionM.genSSOReportHead();this._map.set(dn.LOGIN,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.LOGIN)}),body:{state:"Online",isWebUniapp:0,deviceBrand:0,customInfo:""},keyMap:{req:{deviceBrand:"InstType"},res:{InstId:"instanceID",HelloInterval:"helloInterval",RichMsgAuthKey:"authKey"}}}),this._map.set(dn.LOGOUT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.LOGOUT)}),body:{type:0,isWebUniapp:0},keyMap:{req:{type:"wslogout_type"}}}),this._map.set(dn.HELLO,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.HELLO)}),body:{isWebUniapp:0},keyMap:{res:{NewInstInfo:"newInstanceInfo"}}}),this._map.set(dn.KICK_OTHER,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.STAT_SERVICE,".").concat(dn.KICK_OTHER)}),body:{}}),this._map.set(dn.COS_SIGN,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.IM_COS_SIGN,".").concat(dn.COS_SIGN)}),body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{req:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},res:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}),this._map.set(dn.COS_PRE_SIG,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.CUSTOM_UPLOAD,".").concat(dn.COS_PRE_SIG)}),body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{req:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},res:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}),this._map.set(dn.SIMPLE_COS_PRE_SIG,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.CUSTOM_UPLOAD,".").concat(dn.SIMPLE_COS_PRE_SIG)}),body:{uploadMethod:0,platform:2,SDKAppID:0,userID:"",conversationType:1,peerID:"",uploadConfig:[{fileID:1,fileType:1,fileName:""}]},keyMap:{req:{platform:"uint32_platform",SDKAppID:"uint32_sdkappid",userID:"str_user_id",uploadMethod:"uint32_upload_method",conversationType:"uint32_scene",peerID:"str_peer_id",uploadConfig:"rpt_upload_object",fileID:"uint32_file_id",fileType:"uint32_file_type",fileName:"str_file_name"},res:{str_final_ip:"uploadIP",rpt_pre_sig:"preSig",uint32_file_id:"fileID",uint32_exist_flag:"existFlag",str_download_url:"downloadUrl",str_upload_url:"uploadUrl",str_snapshot_url:"requestSnapshotUrl",str_file_key:"fileKey",rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}),this._map.set(dn.GET_IMAGE_INFO,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.CUSTOM_UPLOAD,".").concat(dn.GET_IMAGE_INFO)}),body:{imageUrl:""},keyMap:{req:{imageUrl:"str_image_url"},res:{rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}),this._map.set(dn.GET_IP,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.CUSTOM_UPLOAD,".").concat(dn.GET_IP)}),body:{domainName:""},keyMap:{req:{domainName:"str_domain"},res:{str_final_ip:"ip"}}}),this._map.set(dn.VIDEO_COVER,{head:_(_({},t),{},{servcmd:"".concat(U.NAME.CUSTOM_UPLOAD,".").concat(dn.VIDEO_COVER)}),body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{req:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},res:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}),this._map.set(dn.FETCH_COMMERCIAL_CONFIG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_CONFIG_MANAGER,".").concat(dn.FETCH_COMMERCIAL_CONFIG)}),body:{SDKAppID:0},keyMap:{req:{SDKAppID:"uint32_sdkappid"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}),this._map.set(dn.PUSHED_COMMERCIAL_CONFIG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_CONFIG_MANAGER,".").concat(dn.PUSHED_COMMERCIAL_CONFIG)}),body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}),this._map.set(dn.FETCH_CLOUD_CTRL_CONFIG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_CONFIG_MANAGER,".").concat(dn.FETCH_CLOUD_CTRL_CONFIG)}),body:{SDKAppID:0,version:0},keyMap:{req:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}),this._map.set(dn.PUSHED_CLOUD_CTRL_CONFIG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_CONFIG_MANAGER,".").concat(dn.PUSHED_CLOUD_CTRL_CONFIG)}),body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}),this._map.set(dn.OVERLOAD_NOTIFY,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OVERLOAD_PUSH,".").concat(dn.OVERLOAD_NOTIFY)}),body:{},keyMap:{res:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}),this._map.set(dn.SYNC_UNREAD_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.SYNC_UNREAD_MSG)}),body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0,needSignaling:1,needCachedMsg:1},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},res:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"to",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}),this._map.set(dn.SEND_C2C_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.SEND_C2C_MSG)}),body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{sound:"",badgeMode:0,isVoipPush:void 0,image:"",interruptionLevel:"active",contentAvailable:0},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension:0,isRelayMessage:0,cmConfigID:void 0,forbidCallbackControl:void 0},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt",GoogleChannelID:"GoogleChannelID",XiaoMiChannelID:"XiaoMiChannelID",OPPOChannelID:"OPPOChannelID",OPPOCategory:"OPPOCategory",VIVOClassification:"VIVOClassification",VIVOCategory:"VIVOCategory",HonorImportance:"HonorImportance",MeizuNotifyType:"MeiZuNoticeMsgType"}}}),this._map.set(dn.REVOKE_C2C_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.REVOKE_C2C_MSG)}),body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{req:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}),this._map.set(dn.GET_C2C_ROAMING_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.GET_C2C_ROAMING_MSG)}),body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{req:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},res:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer"}}}),this._map.set(dn.MODIFY_C2C_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.MODIFY_C2C_MSG)}),body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{req:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}),this._map.set(dn.SET_C2C_MSG_READ,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.SET_C2C_MSG_READ)}),body:{C2CMsgReaded:void 0},keyMap:{req:{lastMessageTime:"LastedMsgTime"}}}),this._map.set(dn.SET_C2C_PEER_MUTE_NOTIFICATIONS,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.SET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{userIDList:void 0,muteFlag:0},keyMap:{req:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}),this._map.set(dn.GET_C2C_PEER_MUTE_NOTIFICATIONS,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.GET_C2C_PEER_MUTE_NOTIFICATIONS)}),body:{toAccount:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Peer_Account"},res:{MuteNotificationsList:"muteFlagList"}}}),this._map.set(dn.DEL_C2C_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.DEL_C2C_MSG)}),body:{fromAccount:"",to:"",keyList:void 0},keyMap:{req:{keyList:"MsgKeyList"}}}),this._map.set(dn.TRANSLATE_TEXT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_TRANSLATE,".").concat(dn.TRANSLATE_TEXT)}),body:{sourceTextList:void 0,SDKAppID:0,from:0,source:"",target:""},keyMap:{req:{sourceTextList:"SourceText",SDKAppID:"SdkAppId",from:"FromAccount"},res:{TargetText:"translatedTextList",RequestId:"requestID",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}),this._map.set(dn.VOICE_TO_TEXT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_SPEECH,".").concat(dn.VOICE_TO_TEXT)}),body:{url:"",SDKAppID:0,format:"",sourceType:0,language:""},keyMap:{req:{url:"BytesUrl",SDKAppID:"Uint32Sdkappid",format:"BytesVoiceFormat",sourceType:"Uint64SourceType",language:"BytesEngServiceType"},res:{BytesRequestid:"requestID",BytesResult:"result",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}),this._map.set(dn.SEND_C2C_READ_RECEIPT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.SEND_C2C_READ_RECEIPT)}),body:{peerAccount:"",messageInfoList:void 0},keyMap:{req:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}),this._map.set(dn.MODIFY_C2C_MSG_EXT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM_MSG_EXT,".").concat(dn.MODIFY_C2C_MSG_EXT)}),body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}),this._map.set(dn.GET_C2C_MSG_EXT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM_MSG_EXT,".").concat(dn.GET_C2C_MSG_EXT)}),body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}),this._map.set(dn.GET_C2C_PEER_READ_TIME,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.GET_C2C_PEER_READ_TIME)}),body:{userIDList:void 0},keyMap:{req:{userIDList:"To_Account"},res:{ReadTime:"peerReadTimeList"}}}),this._map.set(dn.PAGING_GET_CONV_LIST,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.PAGING_GET_CONV_LIST)}),body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:15,assistFlag:31},keyMap:{req:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},res:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex",GroupId:"convGroupID",C2cRemark:"friendRemark",MsgRecvOption:"messageRemindType",GroupIgnoredUnreadSeqCount:"noUnreadCount",GroupNextMsgSeq:"nextMessageSeq"}}}),this._map.set(dn.DEL_CONV,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.DEL_CONV)}),body:{fromAccount:"",conversationList:void 0,clearHistoryMessage:void 0},keyMap:{req:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble",conversationList:"ContactItem"},res:{ResultItem:"resultList",ToGroupid:"groupID",ResultCode:"code",ResultInfo:"info"}}}),this._map.set(dn.CLEAR_HISTORY_MSG,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.CLEAR_HISTORY_MSG)}),body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{req:{toGroupID:"ToGroupid"}}}),this._map.set(dn.PIN_CONV,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.PIN_CONV)}),body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{req:{itemList:"RecentContactItem"}}}),this._map.set(dn.DEL_GROUP_AT_TIPS,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.DEL_GROUP_AT_TIPS)}),body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._map.set(dn.SET_CONV_CUSTOM_DATA,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.MARK_CONV)}),body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(dn.MARK_CONV,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.RECENT_CONTACT,".").concat(dn.MARK_CONV)}),body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(dn.GET_USER_PROFILE,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.PROFILE,".").concat(dn.GET_USER_PROFILE)}),body:{fromAccount:"",userItem:[]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(dn.UPDATE_MY_PROFILE,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.PROFILE,".").concat(dn.UPDATE_MY_PROFILE)}),body:{fromAccount:"",profileItem:[{tag:De.NICK,value:""},{tag:De.GENDER,value:""},{tag:De.ALLOWTYPE,value:""},{tag:De.AVATAR,value:""}]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(dn.SET_SELF_STATUS,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.SET_SELF_STATUS)}),body:{customStatus:""}}),this._map.set(dn.SSO_STAT,{head:_(_({},n),{},{servcmd:"".concat(U.NAME.IM_OPEN_STAT,".").concat(dn.SSO_STAT)}),body:{header:{},event:[],quality:[]},keyMap:{req:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}),this._map.set(dn.PING,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.HEARTBEAT,".").concat(dn.PING)}),body:{}}),this._map.set(dn.MSG_PUSH,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_PUSH,".").concat(dn.MSG_PUSH)}),body:{},keyMap:{res:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt",Status:"statusType"}}}),this._map.set(dn.MSG_PUSH_ACK,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OPEN_IM,".").concat(dn.MSG_PUSH_ACK)}),body:{sessionData:void 0},keyMap:{req:{sessionData:"SessionData"}}}),this._map.set(dn.STATUS_FORCE_OFFLINE,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.STATUS_FORCE_OFFLINE)}),body:{},keyMap:{res:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}),this._map.set(dn.SET_TOKEN,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.SET_TOKEN)}),body:{tokenID:"",pushMsg:0,sdkAppID:0,businessID:"",deviceBrand:"",deviceToken:"",isTpns:0,isWebUniapp:0,notificationStatus:0,deviceModel:"",systemVersion:"",pushVersion:""},keyMap:{req:{tokenID:"TokenID",pushMsg:"PushMsg",sdkAppID:"EnterVersion",businessID:"BusiID",deviceBrand:"InstType",deviceToken:"VarToken",isTpns:"IsTpns",notificationStatus:"NotificationStatus",deviceModel:"DeviceModel",systemVersion:"SystemVersion",pushVersion:"PushPluginVersion"}}}),this._map.set(dn.STAT_FOREGROUND,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.STAT_FOREGROUND)}),body:{isWebUniapp:0}}),this._map.set(dn.STAT_BACKGROUND,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_OPEN_STATUS,".").concat(dn.STAT_BACKGROUND)}),body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{req:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}),this._map.set(dn.PUSH_REPORT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.OFFLINE_PUSH_REPORT,".").concat(dn.PUSH_REPORT)}),body:{eventList:[]},keyMap:{req:{eventList:"UinappPushEvents",type:"EventType",time:"EventTime",pushId:"ClickExt"}}}),this._map.set(dn.SET_ALL_RECEIVE_MSG_OPT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_MSG_LOGIC,".").concat(dn.SET_ALL_RECEIVE_MSG_OPT)}),body:{startTime:0,endTime:0,isRepeated:0,messageRemindType:0},keyMap:{req:{messageRemindType:"Level"}}}),this._map.set(dn.GET_ALL_RECEIVE_MSG_OPT,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.IM_MSG_LOGIC,".").concat(dn.GET_ALL_RECEIVE_MSG_OPT)}),body:{toAccount:void 0}}),this._map.set(dn.STREAM_GET_STREAM,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.STREAM_MESSAGE,".").concat(dn.STREAM_GET_STREAM)}),body:{from:"",to:"",streamMessageID:"",ackIndex:0},keyMap:{}}),this._map.set(dn.STREAM_CHUNK_ACK,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.STREAM_MESSAGE,".").concat(dn.STREAM_CHUNK_ACK)}),body:{streamMessageID:"",ackIndex:0},keyMap:{}}),this._map.set(dn.STREAM_PUSH_CHUNKS,{head:_(_({},e),{},{servcmd:"".concat(U.NAME.STREAM_MESSAGE,".").concat(dn.STREAM_PUSH_CHUNKS)}),body:{from:"",to:"",streamMessageID:"",ackIndex:0},keyMap:{}})}},{key:"has",value:function(e){return this._map.has(e)}},{key:"get",value:function(e){return this._map.get(e)}},{key:"update",value:function(){this._fillMap()}},{key:"getKeyMap",value:function(e){return this.has(e)?this.get(e).keyMap||{}:(Ee.w("".concat(this._n,".getKeyMap unknown P:").concat(e)),{})}},{key:"getProtocolData",value:function(e){var t=e.P,n=e.data;if(e=this.get(t),t=null,n){var s,i=this._simpleDeepCopy(e),a=(i=this._updateService(n,i)).body,o=Object.create(null);for(s in a)if(Object.prototype.hasOwnProperty.call(a,s)){if(o[s]=a[s],void 0===n[s])continue;o[s]=n[s]}i.body=o,t=this._getUplinkData(i)}else t=this._getUplinkData(e);return t}},{key:"_getUplinkData",value:function(e){var t=It((e=this._dataCleaner(e)).head);return t=ii(e.body,this._getReqKeyMap(t)),e.body=t,e}},{key:"_updateService",value:function(e,t){var n,s,i=It(t.head);return this._isFromGroupRequest(t)&&(n=e.type,s=void 0===(s=e.groupIDList)?[]:s,Ze(e=void 0===(e=e.groupID)?void 0:e)&&(e=s[0]||""),ct({type:n,groupID:e}))&&(t.head.servcmd="".concat(U.NAME.GRP_COMMUNITY,".").concat(i)),t}},{key:"_isFromGroupRequest",value:function(e){return e.head.servcmd.includes(U.NAME.GRP)||e.head.servcmd.includes(U.NAME.GRP_ATTR)}},{key:"_getReqKeyMap",value:function(e){return e=this.getKeyMap(e),_(_({},Zs.req),e.req)}},{key:"_dataCleaner",value:function(e){var t,n=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&He(t)&&null!=e[t]&&("object"!==M(e[t])?n[t]=e[t]:n[t]=this._dataCleaner.bind(this)(e[t]));return n}},{key:"_simpleDeepCopy",value:function(e){for(var t,n=Object.keys(e),s={},i=0,a=n.length;i<a;i++)Ve(e[t=n[i]])?s[t]=Array.from(e[t]):Fe(e[t])?s[t]=this._simpleDeepCopy(e[t]):s[t]=e[t];return s}}]),vi=[dn.MSG_PUSH_ACK,dn.STREAM_CHUNK_ACK],yi=o(function e(t){i(this,e),this._sessionM=t,this._n="MsgDispatcher",this._eventHandlerMap=new Map,this._eventHandlerMap.set("C2CMessageArray",this._onC2CMsgArray.bind(this)),this._eventHandlerMap.set("groupMessageArray",this._onGroupMsgArray.bind(this)),this._eventHandlerMap.set("groupTips",this._onGroupTips.bind(this)),this._eventHandlerMap.set("C2CNotifyMessageArray",this._onC2CNotifyMsgArray.bind(this)),this._eventHandlerMap.set("C2CReadReceiptArray",this._onC2CReadReceiptArray.bind(this)),this._eventHandlerMap.set("profileModify",this._onProfileModified.bind(this)),this._eventHandlerMap.set("friendListMod",this._onRelationChainModified.bind(this)),this._eventHandlerMap.set("recentContactMod",this._onRecentContact.bind(this)),this._eventHandlerMap.set("readAllC2CMessage",this._onAllMsgRead.bind(this)),this._eventHandlerMap.set("c2cMessageModified",this._onC2CMsgModified.bind(this)),this._eventHandlerMap.set("groupMessageModified",this._onGroupMsgModified.bind(this)),this._eventHandlerMap.set("userStatusList",this._onUserStatusList.bind(this)),this._eventHandlerMap.set("messageExtensionNotify",this._onMsgExtNotify.bind(this)),this._eventHandlerMap.set("messageReactionNotifyList",this._onMsgReactionNotifyList.bind(this)),this._eventHandlerMap.set("messageReactionNotify",this._onMsgReactionNotify.bind(this)),this._eventHandlerMap.set("followChangeList",this._onFollowNotify.bind(this)),this._keys=y(this._eventHandlerMap.keys())},[{key:"_onC2CMsgArray",value:function(e){var t=this._sessionM.get(6);e.dataList.forEach(function(e){var t;1===e.isSyncMessage&&(t=e.from,e.from=e.to,e.to=t)}),1===e.needSync&&this._sessionM.get(19).syncOnNeed(),t.onNewMessage({dataList:e.dataList,isInstantMessage:!0})}},{key:"_onC2CMsgModified",value:function(e){this._sessionM.get(6).onMsgModified(e)}},{key:"_onGroupMsgArray",value:function(e){var t=this._sessionM.get(7);t&&t.onNewMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}},{key:"_onGroupMsgModified",value:function(e){var t=this._sessionM.get(7);t&&t.onMsgModified(e)}},{key:"_onGroupTips",value:function(e){var t=this._sessionM.get(7);if(t){var n=e.event,s=e.dataList,i=e.isInstantMessage,a=void 0===i||i,o=e.isSyncingEnded;switch(n){case 4:case 6:t.onNewGroupTips({event:n,dataList:s});break;case 5:for(var r=0;r<s.length;r++)if(Ve(s[r].elements.revokedInfos))t.onMsgRevoked({dataList:s});else if(Ve(s[r].elements.groupMessageReadNotice))t.onMsgReadNotice({dataList:s});else{if(!Ve(s[r].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:s,isInstantMessage:a,isSyncingEnded:o});break}t.onReadReceiptList({dataList:s})}break;case 12:this._sessionM.get(11).onNewGroupAtTips({dataList:s});break;default:Ee.l("".concat(this._n,"._onGroupTips unknown event:").concat(n," dataList:"),s)}}}},{key:"_onC2CNotifyMsgArray",value:function(e){var t,n=this,s=e.dataList;Ve(s)&&(t=this._sessionM.get(6),s.forEach(function(e){var i,a;xe(e)&&(e.hasOwnProperty("kickoutMsgNotify")?(i=(a=e.kickoutMsgNotify).kickType,a=void 0===(a=a.newInstanceInfo)?{}:a,1===i?n._sessionM.onMultipleAccountKickedOut(a):2===i?n._sessionM.onMultipleDeviceKickedOut(a):3===i&&n._sessionM.onRestApiKickedOut(a)):e.hasOwnProperty("c2cMessageRevokedNotify")?t&&t.onMsgRevoked({dataList:s},!0):e.hasOwnProperty("c2cMessageReadReceipt")?t&&t.onMsgReadReceipt({dataList:s}):e.hasOwnProperty("c2cMessageReadNotice")?t&&t.onMsgReadNotice({dataList:s}):e.hasOwnProperty("muteNotificationsSync")&&n._sessionM.get(11).onC2CMsgRemindTypeSynced({dataList:s}))}))}},{key:"_onC2CReadReceiptArray",value:function(e){this._sessionM.get(6).onReadReceiptList(e)}},{key:"_onProfileModified",value:function(e){this._sessionM.get(4).onProfileModified({dataList:e.dataList});var t=this._sessionM.get(8);t&&t.onFriendProfileModified({dataList:e.dataList})}},{key:"_onRelationChainModified",value:function(e){this._sessionM.get(4).onRelationChainModified({dataList:e.dataList});var t=this._sessionM.get(8);t&&t.onRelationChainModified({dataList:e.dataList})}},{key:"_onRecentContact",value:function(e){var t;Ve(e=e.dataList)&&(t=this._sessionM.get(11))&&e.forEach(function(e){var n,s,i=e.pushType;1===i?(n=e.recentContactDeleteItem,t.onConvDeleted(n.recentContactList)):2===i?(n=e.recentContactTopItem,t.onConvPinnedStatus(n.recentContactList,!0)):3===i?(n=e.recentContactTopItem,t.onConvPinnedStatus(n.recentContactList,!1)):4===i?(n=e.recentContactMarkContact,t.onConvMarkUpdated(n.recentContactMarkContactItem)):5===i?(n=e.recentContactCreateContactGroup,t.onConvGroupCreated(n.msgContactGroupContactItem)):6===i?(n=e.recentContactDelContactGroup,t.onConvGroupDeleted(n.msgGroupItem)):7===i&&(i=(n=e.recentContactUpdateContactGroup).updateType,e=n.msgUpdateGroup,n=n.msgUpdateContact,1===i?1===(s=e.updateGroupType)?t.onConvGroupNameUpdated(e):2===s&&t.onConvInGroupUpdated(e):2===i&&t.onConvAddedToOrDeletedFromGroup(n))})}},{key:"_onAllMsgRead",value:function(e){e=e.dataList;var t=this._sessionM.get(11);t&&t.onPushedAllMessageRead(e)}},{key:"_onUserStatusList",value:function(e){this._sessionM.get(4).onUserStatusUpdated(e)}},{key:"_onMsgExtNotify",value:function(e){this._sessionM.get(3).onMsgExtNotify(e)}},{key:"_onMsgReactionNotifyList",value:function(e){this._sessionM.get(34).onReactionNotifyList(e)}},{key:"_onMsgReactionNotify",value:function(e){this._sessionM.get(34).onReactionNotify(e)}},{key:"_onFollowNotify",value:function(e){this._sessionM.get(35).onFollowNotify(e)}},{key:"_onTopicLatestMsg",value:function(e){this._sessionM.get(10).onTopicLatestMsg(e)}},{key:"onMessage",value:function(e){var t=this,n=e.body;if(this._filterMsgFromIMOpenPush(e)){var s,i=n.eventArray,a=n.isInstantMessage,o=n.isSyncingEnded,r=n.needSync;if(Ve(i))for(var c,u,l,d=0,h=i.length;d<h;d++)100!==(l=(c=i[d]).event)?24!==l?26!==l?(s=Object.keys(c).find(function(e){return-1!==t._keys.indexOf(e)}))?(u=14===l?{readAllC2CMessage:c[s],groupMessageReadInfoList:c.groupMessageReadNotice||[]}:16===l?{userID:c.userID,timestamp:c.timestamp,readReceiptList:c[s]}:c[s],this._eventHandlerMap.get(s)({event:l,dataList:u,isInstantMessage:a,isSyncingEnded:o,needSync:r})):Ee.l("".concat(this._n,".onMessage unknown eventItem:"),c):this._onTopicLatestMsg(c):this._onAllRcvMsgOptNotify(c):this._onRoomCustomData(c.content)}}},{key:"_onRoomCustomData",value:function(e){this._sessionM.get(30).onRoomCustomDataReceived(e),Ee.l("".concat(this._n,"._onRoomCustomData data:").concat(e))}},{key:"_onAllRcvMsgOptNotify",value:function(e){this._sessionM.get(11).onAllRcvMsgOptNotify(e)}},{key:"_filterMsgFromIMOpenPush",value:function(e){var t,n,s=e.head,i=(e=e.body,s=s.servcmd,!1);return!(i=Ze(s)?i:s.includes(U.NAME.IM_CONFIG_MANAGER)||s.includes(U.NAME.OVERLOAD_PUSH)||s.includes(U.NAME.STAT_SERVICE)||s.includes(U.NAME.STREAM_MESSAGE))||(s.includes(dn.PUSHED_CLOUD_CTRL_CONFIG)?this._sessionM.get(23).onPushedConfig(e):s.includes(dn.PUSHED_COMMERCIAL_CONFIG)?this._sessionM.get(27).onPushedConfig(e):s.includes(dn.OVERLOAD_NOTIFY)?this._sessionM.onPushedServerOverload(e):s.includes(dn.KICK_OTHER)?(i=Date.now(),this._sessionM.reLoginOnKickOther(),t=new kn("kickOther"),n=i-(i=this._sessionM.get(1).getLastWsHelloTs()),t.setMessage("last wshello time:".concat(i," diff:").concat(n,"ms")).end()):s.includes(dn.STREAM_PUSH_CHUNKS)&&this._sessionM.get(11).onPushedChunks(e),!1)}}]),Ii=[{cmd:dn.GET_GRP_PROFILE,interval:1,count:8},{cmd:dn.UPDATE_GRP_PROFILE,interval:1,count:8},{cmd:dn.GET_GRP_PENDENCY,interval:1,count:15},{cmd:dn.GET_TOPIC_LIST,interval:1,count:10},{cmd:dn.SET_GRP_ATTR,interval:5,count:10},{cmd:dn.MODIFY_GRP_ATTR,interval:5,count:10},{cmd:dn.DEL_GRP_ATTR,interval:5,count:10},{cmd:dn.CLEAR_GRP_ATTR,interval:5,count:10},{cmd:dn.GET_GRP_ATTR,interval:5,count:20},{cmd:dn.UPDATE_GRP_COUNTER,interval:5,count:20},{cmd:dn.GET_GRP_COUNTER,interval:5,count:20},{cmd:dn.SET_ALL_MSG_READ,interval:1,count:1},{cmd:dn.GET_USER_STATUS,interval:5,count:20},{cmd:dn.SUB_USER_STATUS,interval:5,count:20},{cmd:dn.UNSUB_USER_STATUS,interval:5,count:20},{cmd:dn.CS,interval:5,count:20},{cmd:dn.GRP_CS,interval:5,count:20},{cmd:dn.MBR_CS,interval:5,count:20},{cmd:dn.USER_CS,interval:5,count:20},{cmd:dn.CHECK_FOLLOW_TYPE,interval:5,count:20},{cmd:dn.GET_GRP_ROAMING_MSG,interval:1,count:20},{cmd:dn.GET_C2C_ROAMING_MSG,interval:1,count:20}],Mi=new Map,Ci=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],Ti=0,Si=Ci.length;Ti<Si;Ti++)Mi.set(Ti,Ci[Ti]);function Ei(e){return i(this,Ei),(e=n(this,Ei,[e]))._n="ChannelModule",e._socketHandler=new pi(e),e._probing=!1,e._isAppShowing=!0,e._previousState=k.NET_STATE_CONNECTED,e._timerForNotLoggedIn=-1,e._timerForNotLoggedIn=setInterval(e.onCheckTimer.bind(e),1e3),e._fatalErrorFlag=!1,e._disconnectedTS=0,e._lastDiagnoseTS=0,e}function ki(e){for(var t,n,s=e,i="",a=0,o=(s=e.length%8!=0?"0".repeat(8-e.length%8)+e:s).length;a<o;a+=8)t=parseInt(s.slice(a,a+4),2),n=parseInt(s.slice(a+4,a+8),2),i+=Mi.get(t)+Mi.get(n);return i}l(Bi,sn);var Di=o(Bi,[{key:"_init",value:function(){this._updateCmdFreqLimitMap(Ii)}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("cmd_frequency_limit");Ze(e)||(e=JSON.parse(e),this._updateCmdFreqLimitMap(e))}},{key:"_updateCmdFreqLimitMap",value:function(e){var t=this;e.forEach(function(e){t._cmdFreqLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}},{key:"updateProtocolConfig",value:function(){this._pHandler.update()}},{key:"req",value:function(e){Ee.d("".concat(this._n,".req options:"),e);var t,n,s=e.P;return this._pHandler.has(s)?(t=(e=this.getProtocolData(e)).head.servcmd,this._isFreqOverLimit(t)?Jt({code:n=un.OVER_FREQUENCY_LIMIT,message:this.getErrMsg(n,this._getCmd(t))}):this._isServerOverload(t)?Jt({code:n=un.OPEN_SERVICE_OVERLOAD_ERROR,message:this.getErrMsg(n,this._getCmd(t))}):(n=this.get(21),vi.includes(s)?n.simplySend(e):n.send(e))):(Ee.w("".concat(this._n,".req unknown P:").concat(s)),Jt({code:un.NO_PROTOCOL}))}},{key:"getKeyMap",value:function(e){return this._pHandler.getKeyMap(e)}},{key:"genCommonHead",value:function(){var e=this.get(12);return{ver:"v4",platform:this._platform,websdkappid:N,websdkversion:A,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:151379687,sdkability_ext:ki(""),cappid:e.getApplicationID(),cs:0}}},{key:"genCosSpecifiedHead",value:function(){var e=this.get(12);return{ver:"v4",platform:this._platform,websdkappid:N,websdkversion:A,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:151379687,sdkability_ext:ki(""),cappid:e.getApplicationID(),cs:0}}},{key:"genSSOReportHead",value:function(){var e=this.get(12);return{ver:"v4",platform:this._platform,websdkappid:N,websdkversion:A,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:151379687,sdkability_ext:ki(""),cappid:e.getApplicationID(),cs:0}}},{key:"getProtocolData",value:function(e){return this._pHandler.getProtocolData(e)}},{key:"trans",value:function(e){var t=e.servcmd;return e=e.data,t={head:_(_({},this.genCommonHead()),{},{servcmd:t}),body:e},this.get(21).send(t)}},{key:"sendComboMessage",value:function(e){var t=e.servcmd;return e=e.data,t={head:_(_({},this.genCommonHead()),{},{servcmd:t}),body:e},this.get(21).send(t)}},{key:"onErrorCodeNotZero",value:function(e){var t,n=e.errorCode;n===un.HELLO_ANSWER_KICKED_OUT&&(t=e.kickType,e=void 0===(e=e.newInstanceInfo)?{}:e,1===t?this.onMultipleAccountKickedOut(e):2===t?this.onMultipleDeviceKickedOut(e):3===t&&this.onRestApiKickedOut(e)),n!==un.MSG_A2KEY_EXPIRED&&n!==un.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.get(21).reConnect())}},{key:"onMessage",value:function(e){var t=e.body,n=t.needAck;1===(void 0===n?0:n)&&this._sendACK(t.sessionData),this._msgDispatcher.onMessage(e)}},{key:"onReconnected",value:function(e){this._incrementalPullContactFlag=e<=300,this._reLoginOnReconnected()}},{key:"reLoginOnKickOther",value:function(){Ee.l("".concat(this._n,".reLoginOnKickOther")),this._reLogin()}},{key:"_reLoginOnReconnected",value:function(){Ee.l("".concat(this._n,"._reLoginOnReconnected")),this._reLogin()}},{key:"_reLogin",value:function(){var e,t=this,n="".concat(this._n,"._reLogin");this.isLoggedIn()&&(e=new kn("reLogin"),this.req({P:dn.LOGIN,data:{isWebUniapp:0,customInfo:this.get(12).getCustomLoginInfo()}}).then(function(s){var i=(s=s.data).instanceID,a=(s=s.customStatus,t.get(12)),o=cs(s),r=(a.setStatusInstanceID(i),t.get(21)),c=r.getSocketID();c="socketID:".concat(c," instanceID:").concat(i," customStatus:").concat(o),e.setMessage(c).end(!0),Ee.l("".concat(n," ok. ").concat(c)),a.getCustomStatus()!==o&&t.get(4).onUserStatusUpdated({dataList:[{to:t.getMyUserID(),statusType:k.USER_STATUS_ONLINE,customStatus:s}]}),r.diagnose(),t.get(11).syncConvList(t._incrementalPullContactFlag).then(function(){Ee.l("".concat(n,", sync conv list ok.")),t.get(25).start()})}))}},{key:"onMultipleAccountKickedOut",value:function(e){this.get(1).onMultipleAccountKickedOut(e)}},{key:"onMultipleDeviceKickedOut",value:function(e){this.get(1).onMultipleDeviceKickedOut(e)}},{key:"_onUserSigExpired",value:function(){this.get(1).onUserSigExpired()}},{key:"onRestApiKickedOut",value:function(e){this.get(1).onRestApiKickedOut(e)}},{key:"_sendACK",value:function(e){this.req({P:dn.MSG_PUSH_ACK,data:{sessionData:e}})}},{key:"_isFreqOverLimit",value:function(e){var t,n,s,i;return e=e.split(".")[1],!!this._cmdFreqLimitMap.has(e)&&(!this._cmdReqInfoMap.has(e)||(t=(n=this._cmdFreqLimitMap.get(e)).count,n=n.interval,s=(i=this._cmdReqInfoMap.get(e)).startTime,i=i.requestCount,Date.now()-s>1e3*n)?(this._cmdReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1):(this._cmdReqInfoMap.set(e,{startTime:s,requestCount:i+=1}),t<i))}},{key:"_isServerOverload",value:function(e){var t,n;return!!this._serverOverloadInfoMap.has(e)&&(t=(n=this._serverOverloadInfoMap.get(e)).overloadTime,n=n.waitingTime,Date.now()-t<=1e3*n||(this._serverOverloadInfoMap.delete(e),!1))}},{key:"_getCmd",value:function(e){var t="";if(e.includes(".")){var n,s=e.split(".")[1];for(n in dn)if(dn[n]===s){t=n;break}}return t}},{key:"onPushedServerOverload",value:function(e){var t=e.overloadCommand;e=e.waitingTime,this._serverOverloadInfoMap.set(t,{overloadTime:Date.now(),waitingTime:e}),Ee.w("".concat(this._n,".onPushedServerOverload waitingTime:").concat(e,"s cmd:").concat(this._getCmd(t)))}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._updateCmdFreqLimitMap(Ii),this._cmdReqInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}]),Oi=(l(ji,sn),o(ji,[{key:"getCloudConfig",value:function(e){return Ze(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}},{key:"getServerConfig",value:function(e){var t={code:0,data:""};return!Ze(e)&&this._cloudConfig.has(e)&&(t.data=this._cloudConfig.get(e)),Promise.resolve(t)}},{key:"_canFetch",value:function(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}},{key:"fetchConfig",value:function(){var e,t=this,n="".concat(this._n,".fetchConfig"),s=this._canFetch();Ee.l("".concat(n," canFetch:").concat(s)),s&&(e=new kn("fetchCloudCtrlConfig"),s=this.get(12).getSDKAppID(),this._isFetching=!0,this.req({P:dn.FETCH_CLOUD_CTRL_CONFIG,data:{SDKAppID:s,version:this._version}}).then(function(s){t._isFetching=!1;var i=(a=s.data).version,a=a.cloudControlConfig;e.setMessage("version:".concat(t._version," newVersion:").concat(i," config:").concat(a)).end(),Ee.l("".concat(n," ok")),t._parse(s.data)}).catch(function(s){t._isFetching=!1,e.setError(s).end(),Ee.l("".concat(n," failed. error:"),s),t._setExpiredTime(12e4)}))}},{key:"onPushedConfig",value:function(e){Ee.l("".concat(this._n,".onPushedConfig config:"),e),new kn("pushedCloudCtrlConfig").setMessage("newVersion:".concat(e.version," config:").concat(e.cloudControlConfig)).end(),this._parse(e)}},{key:"onCheckTimer",value:function(e){this._canFetch()&&this.fetchConfig()}},{key:"_parse",value:function(e){var t=this,n="".concat(this._n,"._parse"),s=e.errorCode,i=e.errorMessage,a=e.cloudControlConfig,o=e.version,r=e.expiredTime;if(0===s){if(this._version!==o){var c=null;try{c=JSON.parse(a)}catch(e){this.isPrivateNetWork()||Ee.e("".concat(n," failed. config:"),a)}c&&(this._cloudConfig.clear(),Object.keys(c).forEach(function(e){t._cloudConfig.set(e,c[e])}),this._version=o,this.emitIEvt(ss.CLOUD_CONFIG),this.emitOEvt(E.SERVER_CONFIG_UPDATED,{config:c}))}this._setExpiredTime(1e3*r)}else Ze(s)?(Ee.l("".concat(n," failed. Invalid message format:"),e),this._setExpiredTime(36e5)):(Ee.e("".concat(n," errorCode:").concat(s," errorMessage:").concat(i)),this._setExpiredTime(12e4))}},{key:"_setExpiredTime",value:function(e){this._expiredTime=Date.now()+e}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}])),Ri=(l(Hi,sn),o(Hi,[{key:"start",value:function(){this._recoverC2CChat()}},{key:"_recoverC2CChat",value:function(){var e,t,n,s=this,i=this._getLocalConvList().filter(function(e){return e.type===k.CONV_C2C}),a=this.get(11),o=[Promise.resolve()],r=[];i.forEach(function(i){var c=i.conversationID;i=i.lastMessage,e=a.getLocalLastMessage(c),i&&0!==i.lastTime&&e&&(t=i.lastTime,e=e.time,n=t-e,0<e)&&1<=n&&n<=600&&(o.push(s._recoverC2CMsg({conversationID:c,localLastMessageTime:e,remoteLastMessageTime:t})),r.push(c))}),Promise.all(o).then(function(){Ee.l("".concat(s._n,"._recoverC2CChat all done, convIDList:"),r),s.get(19).syncOnReconnected()})}},{key:"_getLocalConvList",value:function(){return this.get(11).getLocalConvList()}},{key:"_recoverC2CMsg",value:function(e){var t=this,n="".concat(this._n,".").concat("_recoverC2CMsg"),s=(Ee.l("".concat(n," options:"),e),e.conversationID),i=e.localLastMessageTime,a=e.remoteLastMessageTime,o=JSON.stringify(e),r=new kn("_recoverC2CMsg");return r.setMessage(o),this._getC2CRoamingMsg({conversationID:s,time:i}).then(function(e){var i=(e=e.data).complete;if(e=e.messageList,!Ze(e)){var c=e.length;if(t.get(6).onNewMessage({dataList:e,isInstantMessage:!0}),c=e[c-1].time,e=e.map(function(e){return e.random}),e="".concat(o," complete:").concat(i," randomList:").concat(e),Ee.l("".concat(n," ").concat(e)),r.setMessage(e).end(),c<a&&1!==i)return t._recoverC2CMsg({conversationID:s,localLastMessageTime:c,remoteLastMessageTime:a})}}).catch(function(e){r.setError(e).end(),Ee.w("".concat(n," failed. error:"),e)})}},{key:"_getC2CRoamingMsg",value:function(e){var t=e.conversationID;return e=e.time,this.req({P:dn.GET_C2C_ROAMING_MSG,data:{peerAccount:t.replace(k.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:e,direction:1}})}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}])),Ai=o(function e(){i(this,e),this._n="AvgE2EDelay",this._e2eDelayArray=[]},[{key:"addMessageDelay",value:function(e){0<=(e=ye()-e)&&this._e2eDelayArray.push(e)}},{key:"_calcAvg",value:function(e,t){var n;return 0===t?0:(n=0,e.forEach(function(e){n+=e}),Mt(n/t,1))}},{key:"_calcCountWithLimit",value:function(e){var t=e.e2eDelayArray,n=e.min,s=e.max;return t.filter(function(e){return n<=e&&e<s}).length}},{key:"_calcPercent",value:function(e,t){return 100<(e=Mt(e/t*100,2))?100:e}},{key:"_checkE2EDelayException",value:function(e,t){var n,s,i,a=e.filter(function(e){return t<e});0<a.length&&(n=a.length,s=Math.min.apply(Math,y(a)),i=Math.max.apply(Math,y(a)),a=this._calcAvg(a,n),50<(e=Mt(n/e.length*100,2)))&&new kn("messageE2EDelayException").setMessage("count:".concat(n," min:").concat(s," max:").concat(i," avg:").concat(a," percent:").concat(e)).setLevel("warning").end()}},{key:"getStatResult",value:function(){var e,t,n,s,i,a,o=this._e2eDelayArray.length;return 0===o?null:(e=y(this._e2eDelayArray),t=this._calcCountWithLimit({e2eDelayArray:e,min:0,max:1}),n=this._calcCountWithLimit({e2eDelayArray:e,min:1,max:3}),s=this._calcPercent(t,o),i=this._calcPercent(n,o),a=this._calcAvg(e,o),this._checkE2EDelayException(e,3),e.length=0,this.reset(),{totalCount:o,countLessThan1Second:t,percentOfCountLessThan1Second:s,countLessThan3Second:n,percentOfCountLessThan3Second:i,avgDelay:a})}},{key:"reset",value:function(){this._e2eDelayArray.length=0}}]),Ni=o(function e(){i(this,e),this._n="AvgRTT",this._requestCount=0,this._rttArray=[]},[{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){return 0===t?0:100<(e=Mt(e/t*100,2))?100:e}},{key:"_calcAvg",value:function(e,t){var n;return 0===t?0:(n=0,e.forEach(function(e){n+=e}),parseInt(n/t))}},{key:"_calcMax",value:function(){return Math.max.apply(Math,y(this._rttArray))}},{key:"_calcMin",value:function(){return Math.min.apply(Math,y(this._rttArray))}},{key:"getStatResult",value:function(){var e,t,n=this._calcTotalCount(),s=y(this._rttArray);return 0===n?null:(e=this._calcRTTCount(s),t=this._calcSuccessRateOfRequest(e,n),s=this._calcAvg(s,e),Ee.l("".concat(this._n,".getStatResult max:").concat(this._calcMax()," min:").concat(this._calcMin()," avg:").concat(s)),this.reset(),{totalCount:n,rttCount:e,successRateOfRequest:t,avgRTT:s})}},{key:"reset",value:function(){this._requestCount=0,this._rttArray.length=0}}]),Li=o(function e(){i(this,e),this._map=new Map},[{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!(Ze(e)||!this._map.has(e)||(this._map.get(e).totalCount+=1,0))}},{key:"addSuccessCount",value:function(e){return!(Ze(e)||!this._map.has(e)||(this._map.get(e).successCount+=1,0))}},{key:"addFailedCountOfUserSide",value:function(e){return!(Ze(e)||!this._map.has(e)||(this._map.get(e).failedCountOfUserSide+=1,0))}},{key:"addCost",value:function(e,t){return!(Ze(e)||!this._map.has(e)||(this._map.get(e).costArray.push(t),0))}},{key:"addFileSize",value:function(e,t){return!(Ze(e)||!this._map.has(e)||(this._map.get(e).fileSizeArray.push(t),0))}},{key:"_calcSuccessRateOfBusiness",value:function(e){return Ze(e)||!this._map.has(e)?-1:100<(e=Mt((e=this._map.get(e)).successCount/e.totalCount*100,2))?100:e}},{key:"_calcSuccessRateOfPlatform",value:function(e){var t;return Ze(e)||!this._map.has(e)?-1:(t=this._map.get(e),100<(e=Mt(e=this._calcSuccessCountOfPlatform(e)/t.totalCount*100,2))?100:e)}},{key:"_calcTotalCount",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"_calcSuccessCountOfBusiness",value:function(e){return Ze(e)||!this._map.has(e)?-1:this._map.get(e).successCount}},{key:"_calcSuccessCountOfPlatform",value:function(e){return Ze(e)||!this._map.has(e)?-1:(e=this._map.get(e)).successCount+e.failedCountOfUserSide}},{key:"_calcAvg",value:function(e){return Ze(e)||!this._map.has(e)?-1:e===vn?this._calcAvgSpeed(e):this._calcAvgCost(e)}},{key:"_calcAvgCost",value:function(e){var t,n=this._map.get(e).costArray.length;return 0===n?0:(t=0,this._map.get(e).costArray.forEach(function(e){t+=e}),parseInt(t/n))}},{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,n,s,i,a,o=this._calcTotalCount(e);return 0===o?null:(t=this._calcSuccessCountOfBusiness(e),n=this._calcSuccessRateOfBusiness(e),s=this._calcSuccessCountOfPlatform(e),i=this._calcSuccessRateOfPlatform(e),a=this._calcAvg(e),this.reset(e),{totalCount:o,successCountOfBusiness:t,successRateOfBusiness:n,successCountOfPlatform:s,successRateOfPlatform:i,avgValue:a})}},{key:"reset",value:function(e){Ze(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}]),Ui=o(function e(){i(this,e),this._lastMap=new Map,this._currentMap=new Map},[{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,n,s,i=e.key,a=e.message;return!(Ze(i)||!this._lastMap.has(i)||!this._currentMap.has(i)||(t=a.conversationID,a=a.sequence,t=t.replace(k.CONV_GROUP,""),0!==this._lastMap.get(i).size&&this._lastMap.get(i).has(t)&&(s=(n=this._lastMap.get(i).get(t)).length-1,n[0]<a)&&a<n[s]?(n.push(a),n.sort(),this._lastMap.get(i).set(t,n)):this._addCurrentMap(e),0))}},{key:"_addCurrentMap",value:function(e){var t=e.key,n=(e=e.message).conversationID;e=e.sequence,n=n.replace(k.CONV_GROUP,""),this._currentMap.get(t).has(n)||this._currentMap.get(t).set(n,[]),this._currentMap.get(t).get(n).push(e)}},{key:"_copyData",value:function(e){if(!Ze(e)){this._lastMap.set(e,new Map);var t,n=this._lastMap.get(e),s=r(this._currentMap.get(e));try{for(s.s();!(t=s.n()).done;){var i=v(t.value,2),a=i[0],o=i[1];n.set(a,o)}}catch(e){s.e(e)}finally{s.f()}n=null,this._currentMap.set(e,new Map)}}},{key:"getStatResult",value:function(e){var t,n,s;return Ze(this._currentMap.get(e))||Ze(this._lastMap.get(e))?null:0===this._lastMap.get(e).size?(this._copyData(e),null):(n=t=0,this._lastMap.get(e).forEach(function(e,s){var i=(e=y(e.values())).length;t+=e[i-1]-e[0]+1,n+=i}),0===t?null:(100<(s=Mt(n/t*100,2))&&(s=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:n,successRateOfMessageReceived:s}))}},{key:"reset",value:function(){this._currentMap.clear(),this._lastMap.clear()}}]),Pi=(l(Ki,sn),o(Ki,[{key:"_onLoginSuccess",value:function(){var e=this,t=(this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems),this.get(13)),n=t.getItem(this.TAG,!1);!Ue(n)&&qe(n.forEach)&&(Ee.l("".concat(this._n,"._onLoginSuccess. logs count:").concat(n.length)),n.forEach(function(t){e._statInfoArr.push(t)}),t.removeItem(this.TAG,!1))}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),n=this.getCloudConfig("q_rpt_tinyid_wl");Ze(e)||(this.REPORT_INTERVAL=Number(e)),Ze(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map(function(e){return Number(e)})),Ze(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)||Ee.w("".concat(this._n,".addTotalCount invalid key:"),e)}},{key:"addSuccessCount",value:function(e){this._rateMessageSent.addSuccessCount(e)||Ee.w("".concat(this._n,".addSuccessCount invalid key:"),e)}},{key:"addFailedCountOfUserSide",value:function(e){this._rateMessageSent.addFailedCountOfUserSide(e)||Ee.w("".concat(this._n,".addFailedCountOfUserSide invalid key:"),e)}},{key:"addCost",value:function(e,t){this._rateMessageSent.addCost(e,t)||Ee.w("".concat(this._n,".addCost invalid key or cost:"),e,t)}},{key:"addFileSize",value:function(e,t){this._rateMessageSent.addFileSize(e,t)||Ee.w("".concat(this._n,".addFileSize invalid key or size:"),e,t)}},{key:"addMessageSequence",value:function(e){this._rateMessageReceived.addMessageSequence(e)||Ee.w("".concat(this._n,".addMessageSequence invalid key:"),e.key)}},{key:"_getQualityItem",value:function(e){var t={},n=Sn[this.get(15).getNetworkType()];switch(Ze(n)&&(n=8),n={qualityType:Cn[e],timestamp:me(),networkType:n,extension:""},e){case hn:t=this._avgRTT.getStatResult();break;case gn:t=this._avgE2EDelay.getStatResult();break;case pn:case _n:case fn:case mn:case vn:t=this._rateMessageSent.getStatResult(e);break;case yn:case In:case Mn:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:_(_({},n),t)}},{key:"_report",value:function(e){var t=this,n=[],s=null,i=(Ze(e)?this._qualityItems.forEach(function(e){null!==(s=t._getQualityItem(e))&&(s.reportIndex=t.reportIndex,s.wholePeriod=t.wholePeriod,n.push(s))}):null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,n.push(s)),Ee.d("".concat(this._n,"._report"),n),0<this._statInfoArr.length&&(n=n.concat(this._statInfoArr),this._statInfoArr=[]),e=this.get(12)).getSDKAppID();e=e.getTinyID(),0<(n=Ct(this.REPORT_SDKAPPID_BLACKLIST,i)&&!Tt(this.REPORT_TINYID_WHITELIST,e)?[]:n).length&&this._doReport(n)}},{key:"_doReport",value:function(e){var t=this,n={header:Ns(this),quality:e};this.req({P:dn.SSO_STAT,data:_({},n)}).then(function(){t.reportIndex++,t.wholePeriod=!1}).catch(function(n){Ee.w("".concat(t._n,"._doReport failed. error:"),n),t._statInfoArr=t._statInfoArr.concat(e),t._flushAtOnce()})}},{key:"_flushAtOnce",value:function(){var e=this.get(13),t=e.getItem(this.TAG,!1),n=this._statInfoArr,s="".concat(this._n,"._flushAtOnce");Ue(t)?(Ee.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)):(10<(n=n.concat(t)).length&&(n=n.slice(0,10)),Ee.l("".concat(s," count:").concat(n.length)),e.setItem(this.TAG,n,!0,!1)),this._statInfoArr=[]}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}])),wi=(l(qi,sn),o(qi,[{key:"isWorkerEnabled",value:function(){return this._isWorkerEnabled&&le}},{key:"startWorkerTimer",value:function(){Ee.l("".concat(this._n,".startWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("start")}},{key:"stopWorkerTimer",value:function(){Ee.l("".concat(this._n,".stopWorkerTimer")),this._workerTimer&&this._workerTimer.postMessage("stop")}},{key:"_init",value:function(){var e,t;le&&(e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000); postMessage(interval); } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"})),this._workerTimer=new Worker(e),(t=this)._workerTimer.onmessage=function(e){e.data?(t._timerID=e.data,Ee.l("".concat(t._n,"._init seed:").concat(t._timerID))):t._m.onCheckTimer()})}},{key:"_onCloudConfig",value:function(){var e=this.getCloudConfig("enable_worker");Ee.l("".concat(this._n,"._onCloudConfig enableWorker:").concat(e)),Ze(e)||"1"===e?!this._isWorkerEnabled&&le&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&le&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}},{key:"terminate",value:function(){Ee.l("".concat(this._n,".terminate")),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}},{key:"getTimerID",value:function(){return this._timerID}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}])),bi=o(function e(t){i(this,e),this._commercialConfigM=t,this._n="PurchasedFeatureHandler",this._isCSPluginReported=!1,this._featureMap=new Map},[{key:"isValidPurchaseBits",value:function(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"parsePurchaseBits",value:function(e){if(this.isValidPurchaseBits(e)){this._featureMap.clear();for(var t,n=e.length-1,s=0;0<=n;n--,s++)t=(s<32?new O(0,Math.pow(2,s)):new O(Math.pow(2,s-32),0)).toString(),"1"===e[n]?this._featureMap.set(t,!0):this._featureMap.set(t,!1)}else Ee.w("".concat(this._n,".parsePurchaseBits invalid purchasebits:").concat(e))}},{key:"hasPurchasedFeature",value:function(e){return!!this._featureMap.get(e)}},{key:"isFeatureEnabled",value:function(e){for(var t=parseInt(e).toString(2),n=void 0,s=!0,i=t.length-1,a=0;0<=i;i--,a++)if("1"===t.charAt(i)&&(n=(a<32?new O(0,Math.pow(2,a)):new O(Math.pow(2,a-32),0)).toString(),!this._featureMap.get(n))){s=!1;break}return Ee.l("".concat(this._n,".isFeatureEnabled decimalNumber:").concat(e," key:").concat(n," ret:").concat(s)),$t({enabled:s})}},{key:"isFeatureEnabledForStat",value:function(e){for(var t=parseInt(e).toString(2),n=t.length-1,s=0;0<=n;n--,s++)if("1"===t.charAt(n)){if(i=(s<32?new O(0,Math.pow(2,s)):new O(Math.pow(2,s-32),0)).toString(),!this._featureMap.get(i))break;var i,a="",o=0;i===P.PLUGIN_TRANSLATE?(a="plugin_translate",o=16):i===P.PLUGIN_VOICE_TO_TEXT?(a="plugin_voice_to_text",o=17):i===P.PLUGIN_CS?(a="plugin_cs",o=14):i===P.PLUGIN_PUSH?(a="plugin_push",o=13):i===P.PLUGIN_BOT?(a="plugin_bot",o=15):i===P.MSG_REACTION&&(a="plugin_emoji_reaction",o=18),""!==a&&(i=this._commercialConfigM.get(12).getUIPlatform(),new kn(a).setCode(o).setUIPlatform(i).end(),Ee.l("".concat(this._n,".isFeatureEnabledForStat ").concat(a," code:").concat(o," uiPlatform:").concat(i)))}}},{key:"isCSPluginEnabled",value:function(){var e;this._isCSPluginReported||(e=this._commercialConfigM.get(12).getUIPlatform(),new kn("plugin_search").setCode(6).setUIPlatform(e).end(),this._isCSPluginReported=!0)}},{key:"clear",value:function(){this._featureMap.clear(),this._isCSPluginReported=!1}}]),Gi=o(function e(t){i(this,e),this._m=t,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new bi(this)},[{key:"_canFetch",value:function(){return this.get(12).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,t,n=this,s=this._canFetch(),i="".concat(this._n,".fetchConfig");Ee.l("".concat(i," canFetch:").concat(s)),s&&(e=new kn("fetchCommercialConfig"),s=this.get(12).getSDKAppID(),t=this.get(20),this._isFetching=!0,t.req({P:dn.FETCH_COMMERCIAL_CONFIG,data:{SDKAppID:s}}).then(function(t){e.setMessage("purchaseBits:".concat(t.data.purchaseBits)).end(),Ee.l("".concat(i," ok.")),n._parseConfig(t.data),n._isFetching=!1}).catch(function(t){e.setError(t).end(),n._isFetching=!1}))}},{key:"onPushedConfig",value:function(e){var t="".concat(this._n,".onPushedConfig data:").concat(JSON.stringify(e));Ee.l("".concat(t)),new kn("pushedCommercialConfig").setMessage("purchaseBits:".concat(e.purchaseBits)).end(),this._parseConfig(e)}},{key:"_parseConfig",value:function(e){var t="".concat(this._n,"._parseConfig"),n=e.errorCode,s=e.errorMessage,i=e.expiredTime;0===n?(this._purchasedFeatureHandler.parsePurchaseBits(e.purchaseBits),this._expiredTime=Date.now()+1e3*i):Ze(n)?(Ee.l("".concat(t," failed. Invalid message format:"),e),this._setExpiredTimeOnResponseError(36e5)):(Ee.e("".concat(t," errorCode:").concat(n," errorMessage:").concat(s)),this._setExpiredTimeOnResponseError(12e4))}},{key:"_setExpiredTimeOnResponseError",value:function(e){this._expiredTime=Date.now()+e}},{key:"canIUse",value:function(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}},{key:"isFeatureEnabled",value:function(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}},{key:"isFeatureEnabledForStat",value:function(e){this._purchasedFeatureHandler.isFeatureEnabledForStat(e)}},{key:"isCSPluginEnabled",value:function(){this._purchasedFeatureHandler.isCSPluginEnabled()}},{key:"get",value:function(e){return this._m.get(e)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}]),Fi=o(function e(t){i(this,e),this._m=t,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"],this._TRTCCommandMap=new Map,this._setTRTCCommandMap(),this._m.getIEmitInst().on(ss.CLOUD_CONFIG,this._onCloudConfig,this)},[{key:"_onCloudConfig",value:function(){var e=this,t=this._m.get(23).getCloudConfig("rtc_cmd");Ze(t)||((t=JSON.parse(t)).forEach(function(t){e._TRTCCommandList.includes(t)||e._TRTCCommandList.push(t)}),this._setTRTCCommandMap())}},{key:"_setTRTCCommandMap",value:function(){for(var e,t=0,n=this._TRTCCommandList.length;t<n;t++)e=this._TRTCCommandList[t].split(".")[0],this._TRTCCommandMap.set(e,1)}},{key:"onRoomCustomDataReceived",value:function(e){this._m.getOEmitInst().emit(E.ROOM_CUSTOM_DATA_RECEIVED,e)}},{key:"sendTRTCCustomData",value:function(e){var t=e.serviceCommand,n=(e=e.data,"".concat(U.NAME.TUIROOM_SVR,".*"));return Ze(t)||(n=t),this._isValidServiceCommand(n)?this._trans({servcmd:n,data:e}):Jt({code:un.INVALID_TRTC_CMD})}},{key:"_trans",value:function(e){Ee.d("".concat(this._n,"._trans. options:").concat(JSON.stringify(e)));var t=e.servcmd;return e=e.data,this._m.get(20).trans({servcmd:t,data:Xe(e)?JSON.parse(e):e})}},{key:"_isValidServiceCommand",value:function(e){return e.endsWith(".*")?this._TRTCCommandList.includes(e):(e=e.split(".")[0],this._TRTCCommandMap.has(e))}},{key:"isTRTCCommand",value:function(e){return e=e.split(".")[0],this._TRTCCommandMap.has(e)}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}]),xi=o(function e(t){i(this,e),this._m=t,this._n="ErrMsgModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this.CURRENT_DOMAIN=w,this._map=new Map,this._init()},[{key:"_init",value:function(){var e,t=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(t){try{e=JSON.parse(t)}catch(e){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),Ee.w("".concat(this._n,"._init error:"),e)}e&&(this._needToUpdate(e)?this._fetch():this._fillMap(e.message))}else this._fetch()}},{key:"_needToUpdate",value:function(e){var t=e.localSavedTime;return e=e.localSavedVersion,t=t&&(new Date).getTime()-t>=this.STORAGE_EXPIRES_TIME,e=!e||e!==S,Ee.l("".concat(this._n,"._needToUpdate isTimeout:").concat(t," isDifferentVersion:").concat(e)),t||e}},{key:"_fetch",value:function(){this._m.get(12).isPrivateNetWork()||this._fetchWithRetry()}},{key:"_fetchWithRetry",value:function(){var e=this;this._fetchAdapter().catch(function(){e.CURRENT_DOMAIN!==G&&(e._generateCurrentDomain(),e._fetchWithRetry())})}},{key:"_generateCurrentDomain",value:function(){this.CURRENT_DOMAIN===w?this.CURRENT_DOMAIN=b:this.CURRENT_DOMAIN===b&&(this.CURRENT_DOMAIN=G)}},{key:"_fetchAdapter",value:function(){var e="https://".concat(this.CURRENT_DOMAIN,"/im/download/error-message/v3/0.0.7/tim-error-message.txt"),t="application/x-www-form-urlencoded;charset=UTF-8",n="".concat(this._n,"._fetchAdapter ok in"),s=this;return new Promise(function(i,a){var o,r;$?Q.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:function(e){s._fillAndSave(e.data),Ee.l("".concat(n," mini program.")),i()},fail:function(e){a(e)}}):(o=new XMLHttpRequest,r=setTimeout(function(){o.abort()},3e3),o.onreadystatechange=function(){4===o.readyState&&(r&&clearTimeout(r),200===o.status||304===o.status?(Ee.l("".concat(n," browser.")),s._fillAndSave(o.responseText),i()):a(o.status))},o.onerror=function(e){a(e)},o.open("GET",e,!0),o.setRequestHeader("Content-type",t),o.send())})}},{key:"_fillAndSave",value:function(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:S}),!0,!1)}},{key:"_getStorageModule",value:function(){return this._m.get(13)}},{key:"_fillMap",value:function(e){this._map.clear();for(var t,n,s=e.split(";\n"),i=s.length,a=new RegExp(/'/g),o=0;o<i;o++)if(n=s[o].indexOf(":"),t=s[o].slice(0,n),n=s[o].slice(n+1,s[o].length),!t.startsWith("//")){if(Ze(n))continue;this._map.set(t,n.replace(a,""))}}},{key:"get",value:function(e){var t=e.isIntl,n=e.key,s=e.replacement1;return e=e.replacement2,t="".concat(n,t?"_en":"_cn"),!this._map.has(t)&&this._map.has(n)&&(t=n),n="",this._map.has(t)&&(n=this._map.get(t),Ze(s)||(n=n.replace("$replacement1",s)),Ze(e)||(n=n.replace("$replacement2",e))),n}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset"))}}]),Vi=xs(function(e,t){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;t.assign=function(e){for(var t,n,s=Array.prototype.slice.call(arguments,1);s.length;){var i=s.shift();if(i){if("object"!==M(i))throw new TypeError(i+"must be non-object");for(var a in i)t=i,n=a,Object.prototype.hasOwnProperty.call(t,n)&&(e[a]=i[a])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var s={arraySet:function(e,t,n,s,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+s),i);else for(var a=0;a<s;a++)e[i+a]=t[n+a]},flattenChunks:function(e){for(var t,n,s,i=0,a=0,o=e.length;a<o;a++)i+=e[a].length;for(s=new Uint8Array(i),a=t=0,o=e.length;a<o;a++)n=e[a],s.set(n,t),t+=n.length;return s}},i={arraySet:function(e,t,n,s,i){for(var a=0;a<s;a++)e[i+a]=t[n+a]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,s)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,i))},t.setTyped(n)});function qi(e){return i(this,qi),(e=n(this,qi,[e]))._n="WorkerTimerModule",e._isWorkerEnabled=!0,e._workerTimer=null,e._timerID=-1,e._init(),e.getIEmitInst().on(ss.CLOUD_CONFIG,e._onCloudConfig,e),e}function Ki(e){i(this,Ki),(e=n(this,Ki,[e]))._n="QualityStatModule",e.TAG="im-ssolog-quality-stat",e.reportIndex=0,e.wholePeriod=!1,e._qualityItems=[hn,gn,pn,_n,fn,mn,vn,yn,In,Mn],e._messageSentItems=[pn,_n,fn,mn,vn],e._messageReceivedItems=[yn,In,Mn],e.REPORT_INTERVAL=120,e.REPORT_SDKAPPID_BLACKLIST=[],e.REPORT_TINYID_WHITELIST=[],e._statInfoArr=[],e._avgRTT=new Ni,e._avgE2EDelay=new Ai,e._rateMessageSent=new Li,e._rateMessageReceived=new Ui;var t=e.getIEmitInst();return t.on(ss.A2KEY_AND_TINYID_UPDATED,e._onLoginSuccess,e),t.on(ss.CLOUD_CONFIG,e._onCloudConfig,e),e}function Hi(e){return i(this,Hi),(e=n(this,Hi,[e]))._n="RecoverMsgModule",e.PULL_LIMIT_COUNT=15,e}function ji(e){return i(this,ji),(e=n(this,ji,[e]))._n="CloudControlModule",e._cloudConfig=new Map,e._expiredTime=0,e._version=0,e._isFetching=!1,e}function Bi(e){return i(this,Bi),(e=n(this,Bi,[e]))._n="SessionModule",e._platform=e.getPlatform(),e._pHandler=new mi(e),e._msgDispatcher=new yi(e),e._cmdFreqLimitMap=new Map,e._cmdReqInfoMap=new Map,e._serverOverloadInfoMap=new Map,e._incrementalPullContactFlag=!0,e._init(),e.getIEmitInst().on(ss.CLOUD_CONFIG,e._onCloudConfig,e),e}function Yi(e,t,n,s){for(var i=65535&e,a=e>>>16&65535,o=0;0!==n;){for(n-=o=2e3<n?2e3:n;a=a+(i=i+t[s++]|0)|0,--o;);i%=65521,a%=65521}return i|a<<16}function Wi(e,t,n,s){var i=$i,a=s+n;e^=-1;for(var o=s;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}function zi(e,t,n,s,i,a,o,r){var c,u,l,d,h,g,p,_,f,m=r.bits,v=0,y=0,I=0,M=0,C=0,T=0,S=0,E=0,k=0,D=0,O=null,R=0,A=new Vi.Buf16(16),N=new Vi.Buf16(16),L=null,U=0;for(v=0;v<=15;v++)A[v]=0;for(y=0;y<s;y++)A[t[n+y]]++;for(C=m,M=15;1<=M&&0===A[M];M--);if(M<C&&(C=M),0===M)i[a++]=20971520,i[a++]=20971520,r.bits=1;else{for(I=1;I<M&&0===A[I];I++);for(C<I&&(C=I),v=E=1;v<=15;v++)if((E=(E<<1)-A[v])<0)return-1;if(0<E&&(0===e||1!==M))return-1;for(N[1]=0,v=1;v<15;v++)N[v+1]=N[v]+A[v];for(y=0;y<s;y++)0!==t[n+y]&&(o[N[t[n+y]]++]=y);if(g=0===e?(O=L=o,19):1===e?(O=Ji,R-=257,L=Xi,U-=257,256):(O=Zi,L=Qi,-1),v=I,h=a,S=y=D=0,l=-1,d=(k=1<<(T=C))-1,1===e&&852<k||2===e&&592<k)return 1;for(;;){for(f=o[y]<g?(_=0,o[y]):o[y]>g?(_=L[U+o[y]],O[R+o[y]]):(_=96,0),c=1<<(p=v-S),I=u=1<<T;i[h+(D>>S)+(u-=c)]=p<<24|_<<16|f,0!==u;);for(c=1<<v-1;D&c;)c>>=1;if(D=0!==c?(D&c-1)+c:0,y++,0==--A[v]){if(v===M)break;v=t[n+o[y]]}if(C<v&&(D&d)!==l){for(h+=I,E=1<<(T=v-(S=0===S?C:S));T+S<M&&!((E-=A[T+S])<=0);)T++,E<<=1;if(k+=1<<T,1===e&&852<k||2===e&&592<k)return 1;i[l=D&d]=C<<24|T<<16|h-a}}0!==D&&(i[h+D]=v-S<<24|64<<16),r.bits=C}return 0}Vi.assign;var $i=(()=>{for(var e=[],t=0;t<256;t++){for(var n=t,s=0;s<8;s++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e})(),Ji=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Xi=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Zi=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Qi=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function ea(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ta(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Vi.Buf16(320),this.work=new Vi.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function na(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Vi.Buf32(852),t.distcode=t.distdyn=new Vi.Buf32(592),t.sane=1,t.back=-1,0):-2}function sa(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,na(e)):-2}function ia(e,t){var n,s;return!e||!e.state||(s=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?-2:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=n,s.wbits=t,sa(e))}function aa(e,t){var n;return e?(n=new ta,(e.state=n).window=null,0!==(n=ia(e,t))&&(e.state=null),n):-2}var oa,ra,ca=!0;function ua(e,t,n,s){var i;return null===(e=e.state).window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new Vi.Buf8(e.wsize)),e.wsize<=s?(Vi.arraySet(e.window,t,n-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):((i=e.wsize-e.wnext)>s&&(i=s),Vi.arraySet(e.window,t,n-s,i,e.wnext),(s-=i)?(Vi.arraySet(e.window,t,n-s,s,0),e.wnext=s,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}var la={inflateReset:sa,inflateReset2:ia,inflateResetKeep:na,inflateInit:function(e){return aa(e,15)},inflateInit2:aa,inflate:function(e,t){var n,s,i,a,o,r,c,u,l,d,h,g,p,_,f,m,v,y,I,M,C,T,S,E,k=0,D=new Vi.Buf8(4),O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),o=e.next_out,i=e.output,a=e.next_in,s=e.input,u=n.hold,l=n.bits,d=r=e.avail_in,h=c=e.avail_out,T=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap)n.mode=13;else{for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(2&n.wrap&&35615===u)D[n.check=0]=255&u,D[1]=u>>>8&255,n.check=Wi(n.check,D,2,0),l=u=0,n.mode=2;else if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31)e.msg="incorrect header check",n.mode=30;else if(8!=(15&u))e.msg="unknown compression method",n.mode=30;else{if(l-=4,C=8+(15&(u>>>=4)),0===n.wbits)n.wbits=C;else if(C>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<C,e.adler=n.check=1,n.mode=512&u?10:12,l=u=0}}break;case 2:for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(n.flags=u,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=u>>8&1),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=Wi(n.check,D,2,0)),l=u=0,n.mode=3;case 3:for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.head&&(n.head.time=u),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,D[2]=u>>>16&255,D[3]=u>>>24&255,n.check=Wi(n.check,D,4,0)),l=u=0,n.mode=4;case 4:for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.head&&(n.head.xflags=255&u,n.head.os=u>>8),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=Wi(n.check,D,2,0)),l=u=0,n.mode=5;case 5:if(1024&n.flags){for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.length=u,n.head&&(n.head.extra_len=u),512&n.flags&&(D[0]=255&u,D[1]=u>>>8&255,n.check=Wi(n.check,D,2,0)),l=u=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((g=(g=n.length)>r?r:g)&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Vi.arraySet(n.head.extra,s,a,g,C)),512&n.flags&&(n.check=Wi(n.check,s,g,a)),r-=g,a+=g,n.length-=g),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===r)break e;for(g=0;C=s[a+g++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C)),C&&g<r;);if(512&n.flags&&(n.check=Wi(n.check,s,g,a)),r-=g,a+=g,C)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===r)break e;for(g=0;C=s[a+g++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C)),C&&g<r;);if(512&n.flags&&(n.check=Wi(n.check,s,g,a)),r-=g,a+=g,C)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;l<16;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}l=u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}e.adler=n.check=ea(u),l=u=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last)u>>>=7&l,l-=7&l,n.mode=27;else{for(;l<3;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}switch(n.last=1&u,--l,3&(u>>>=1)){case 0:n.mode=14;break;case 1:R=A=void 0;var R,A=n;if(ca){for(oa=new Vi.Buf32(512),ra=new Vi.Buf32(32),R=0;R<144;)A.lens[R++]=8;for(;R<256;)A.lens[R++]=9;for(;R<280;)A.lens[R++]=7;for(;R<288;)A.lens[R++]=8;for(zi(1,A.lens,0,288,oa,0,A.work,{bits:9}),R=0;R<32;)A.lens[R++]=5;zi(2,A.lens,0,32,ra,0,A.work,{bits:5}),ca=!1}if(A.lencode=oa,A.lenbits=9,A.distcode=ra,A.distbits=5,n.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}u>>>=2,l-=2}break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&u,l=u=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(g=n.length){if(0===(g=c<(g=r<g?r:g)?c:g))break e;Vi.arraySet(i,s,a,g,o),r-=g,a+=g,c-=g,o+=g,n.length-=g}else n.mode=12;break;case 17:for(;l<14;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(n.nlen=257+(31&u),u>>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;l<3;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.lens[O[n.have++]]=7&u,u>>>=3,l-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,S={bits:n.lenbits},T=zi(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,T){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;m=(k=n.lencode[u&(1<<n.lenbits)-1])>>>16&255,v=65535&k,!((f=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(v<16)u>>>=f,l-=f,n.lens[n.have++]=v;else{if(16===v){for(E=f+2;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u>>>=f,l-=f,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}C=n.lens[n.have-1],g=3+(3&u),u>>>=2,l-=2}else if(17===v){for(E=f+3;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}C=0,g=3+(7&(u>>>=f)),u>>>=3,l=l-f-3}else{for(E=f+7;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}C=0,g=11+(127&(u>>>=f)),u>>>=7,l=l-f-7}if(n.have+g>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;g--;)n.lens[n.have++]=C}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,S={bits:n.lenbits},T=zi(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,T){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},T=zi(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,T){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=r&&258<=c){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,j=q=b=w=P=U=L=N=se=ne=te=ee=Q=Z=X=J=$=z=W=Y=B=H=K=V=x=F=G=void 0;var N,L,U,P,w,b,G=e,F=h,x=G.state,V=G.next_in,q=G.input,K=V+(G.avail_in-5),H=G.next_out,j=G.output,B=H-(F-G.avail_out),Y=H+(G.avail_out-257),W=x.dmax,z=x.wsize,$=x.whave,J=x.wnext,X=x.window,Z=x.hold,Q=x.bits,ee=x.lencode,te=x.distcode,ne=(1<<x.lenbits)-1,se=(1<<x.distbits)-1;t:do{for(Q<15&&(Z+=q[V++]<<Q,Q+=8,Z+=q[V++]<<Q,Q+=8),N=ee[Z&ne];;){if(Z>>>=L=N>>>24,Q-=L,0==(L=N>>>16&255))j[H++]=65535&N;else{if(!(16&L)){if(!(64&L)){N=ee[(65535&N)+(Z&(1<<L)-1)];continue}if(32&L){x.mode=12;break t}G.msg="invalid literal/length code",x.mode=30;break t}for(U=65535&N,(L&=15)&&(Q<L&&(Z+=q[V++]<<Q,Q+=8),U+=Z&(1<<L)-1,Z>>>=L,Q-=L),Q<15&&(Z+=q[V++]<<Q,Q+=8,Z+=q[V++]<<Q,Q+=8),N=te[Z&se];;){if(Z>>>=L=N>>>24,Q-=L,!(16&(L=N>>>16&255))){if(!(64&L)){N=te[(65535&N)+(Z&(1<<L)-1)];continue}G.msg="invalid distance code",x.mode=30;break t}if(P=65535&N,Q<(L&=15)&&(Z+=q[V++]<<Q,(Q+=8)<L)&&(Z+=q[V++]<<Q,Q+=8),(P+=Z&(1<<L)-1)>W){G.msg="invalid distance too far back",x.mode=30;break t}if(Z>>>=L,Q-=L,P>(L=H-B)){if((L=P-L)>$&&x.sane){G.msg="invalid distance too far back",x.mode=30;break t}if(b=X,(w=0)===J){if(w+=z-L,L<U){for(U-=L;j[H++]=X[w++],--L;);w=H-P,b=j}}else if(J<L){if(w+=z+J-L,(L-=J)<U){for(U-=L;j[H++]=X[w++],--L;);if(w=0,J<U){for(U-=L=J;j[H++]=X[w++],--L;);w=H-P,b=j}}}else if(w+=J-L,L<U){for(U-=L;j[H++]=X[w++],--L;);w=H-P,b=j}for(;2<U;)j[H++]=b[w++],j[H++]=b[w++],j[H++]=b[w++],U-=3;U&&(j[H++]=b[w++],1<U)&&(j[H++]=b[w++])}else{for(w=H-P;j[H++]=j[w++],j[H++]=j[w++],j[H++]=j[w++],2<(U-=3););U&&(j[H++]=j[w++],1<U)&&(j[H++]=j[w++])}break}}break}}while(V<K&&H<Y);V-=U=Q>>3,Z&=(1<<(Q-=U<<3))-1,G.next_in=V,G.next_out=H,G.avail_in=V<K?K-V+5:5-(V-K),G.avail_out=H<Y?Y-H+257:257-(H-Y),x.hold=Z,x.bits=Q,o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,s=e.input,r=e.avail_in,u=n.hold,l=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;m=(k=n.lencode[u&(1<<n.lenbits)-1])>>>16&255,v=65535&k,!((f=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(m&&!(240&m)){for(y=f,I=m,M=v;m=(k=n.lencode[M+((u&(1<<y+I)-1)>>y)])>>>16&255,v=65535&k,!(y+(f=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}u>>>=y,l-=y,n.back+=y}if(u>>>=f,l-=f,n.back+=f,n.length=v,0===m){n.mode=26;break}if(32&m){n.back=-1,n.mode=12;break}if(64&m){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&m,n.mode=22;case 22:if(n.extra){for(E=n.extra;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.length+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;m=(k=n.distcode[u&(1<<n.distbits)-1])>>>16&255,v=65535&k,!((f=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(!(240&m)){for(y=f,I=m,M=v;m=(k=n.distcode[M+((u&(1<<y+I)-1)>>y)])>>>16&255,v=65535&k,!(y+(f=k>>>24)<=l);){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}u>>>=y,l-=y,n.back+=y}if(u>>>=f,l-=f,n.back+=f,64&m){e.msg="invalid distance code",n.mode=30;break}n.offset=v,n.extra=15&m,n.mode=24;case 24:if(n.extra){for(E=n.extra;l<E;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}n.offset+=u&(1<<n.extra)-1,u>>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===c)break e;if(n.offset>(g=h-c)){if((g=n.offset-g)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}p=g>n.wnext?(g-=n.wnext,n.wsize-g):n.wnext-g,g>n.length&&(g=n.length),_=n.window}else _=i,p=o-n.offset,g=n.length;for(c-=g=c<g?c:g,n.length-=g;i[o++]=_[p++],--g;);0===n.length&&(n.mode=21);break;case 26:if(0===c)break e;i[o++]=n.length,c--,n.mode=21;break;case 27:if(n.wrap){for(;l<32;){if(0===r)break e;r--,u|=s[a++]<<l,l+=8}if(h-=c,e.total_out+=h,n.total+=h,h&&(e.adler=n.check=(n.flags?Wi:Yi)(n.check,i,h,o-h)),h=c,(n.flags?u:ea(u))!==n.check){e.msg="incorrect data check",n.mode=30;break}l=u=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;l<32;){if(0===r)break e;r--,u+=s[a++]<<l,l+=8}if(u!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}l=u=0}n.mode=29;case 29:T=1;break e;case 30:T=-3;break e;case 31:return-4;default:return-2}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=r,n.hold=u,n.bits=l,(n.wsize||h!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&ua(e,e.output,e.next_out,h-e.avail_out),h-=e.avail_out,e.total_in+=d-=e.avail_in,e.total_out+=h,n.total+=h,n.wrap&&h&&(e.adler=n.check=(n.flags?Wi:Yi)(n.check,i,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0==d&&0===h||4===t)&&0===T?-5:T},inflateEnd:function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,0):-2},inflateGetHeader:function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,0):-2},inflateSetDictionary:function(e,t){var n,s=t.length;return!e||!e.state||0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&Yi(1,t,s,0)!==n.check?-3:ua(e,t,s,s)?(n.mode=31,-4):(n.havedict=1,0)},inflateInfo:"pako inflate (from Nodeca project)"},da=!0,ha=!0;try{String.fromCharCode.apply(null,[0])}catch(o){da=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(o){ha=!1}for(var ga=new Vi.Buf8(256),pa=0;pa<256;pa++)ga[pa]=252<=pa?6:248<=pa?5:240<=pa?4:224<=pa?3:192<=pa?2:1;function _a(e,t){for(var n,s,i=t||e.length,a=new Array(2*i),o=0,r=0;r<i;)if((n=e[r++])<128)a[o++]=n;else if(4<(s=ga[n]))a[o++]=65533,r+=s-1;else{for(n&=2===s?31:3===s?15:7;1<s&&r<i;)n=n<<6|63&e[r++],s--;1<s?a[o++]=65533:n<65536?a[o++]=n:(n-=65536,a[o++]=55296|n>>10&1023,a[o++]=56320|1023&n)}var c=a,u=o;if(u<65534&&(c.subarray&&ha||!c.subarray&&da))return String.fromCharCode.apply(null,Vi.shrinkBuf(c,u));for(var l="",d=0;d<u;d++)l+=String.fromCharCode(c[d]);return l}function fa(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function ma(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}ga[254]=ga[254]=1;var va={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},ya={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ia=Object.prototype.toString;function Ma(e){if(!(this instanceof Ma))return new Ma(e);this.options=Vi.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;if(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new fa,this.strm.avail_out=0,(e=la.inflateInit2(this.strm,t.windowBits))!==va.Z_OK)throw new Error(ya[e]);if(this.header=new ma,la.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=(e=>{for(var t,n,s,i,a=e.length,o=0,r=0;r<a;r++)55296==(64512&(n=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=e.charCodeAt(r+1)))&&(n=65536+(n-55296<<10)+(s-56320),r++),o+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Vi.Buf8(o),r=i=0;i<o;r++)55296==(64512&(n=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=e.charCodeAt(r+1)))&&(n=65536+(n-55296<<10)+(s-56320),r++),n<128?t[i++]=n:(n<2048?t[i++]=192|n>>>6:(n<65536?t[i++]=224|n>>>12:(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63),t[i++]=128|n>>>6&63),t[i++]=128|63&n);return t})(t.dictionary):"[object ArrayBuffer]"===Ia.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=la.inflateSetDictionary(this.strm,t.dictionary))!==va.Z_OK)throw new Error(ya[e])}function Ca(e,t){if((t=new Ma(t)).push(e,!0),t.err)throw t.msg||ya[t.err];return t.result}Ma.prototype.push=function(e,t){var n,s,i,a,o,r=this.strm,c=this.options.chunkSize,u=this.options.dictionary,l=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?va.Z_FINISH:va.Z_NO_FLUSH,"string"==typeof e?r.input=(e=>{for(var t=new Vi.Buf8(e.length),n=0,s=t.length;n<s;n++)t[n]=e.charCodeAt(n);return t})(e):"[object ArrayBuffer]"===Ia.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new Vi.Buf8(c),r.next_out=0,r.avail_out=c),(n=(n=la.inflate(r,va.Z_NO_FLUSH))===va.Z_NEED_DICT&&u?la.inflateSetDictionary(this.strm,u):n)===va.Z_BUF_ERROR&&!0===l&&(n=va.Z_OK,l=!1),n!==va.Z_STREAM_END&&n!==va.Z_OK)return this.onEnd(n),!(this.ended=!0);!r.next_out||0!==r.avail_out&&n!==va.Z_STREAM_END&&(0!==r.avail_in||s!==va.Z_FINISH&&s!==va.Z_SYNC_FLUSH)||("string"===this.options.to?(i=((e,t)=>{for(var n=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=n&&128==(192&e[n]);)n--;return!(n<0||0===n)&&n+ga[e[n]]>t?n:t})(r.output,r.next_out),a=r.next_out-i,o=_a(r.output,i),r.next_out=a,r.avail_out=c-a,a&&Vi.arraySet(r.output,r.output,i,a,0),this.onData(o)):this.onData(Vi.shrinkBuf(r.output,r.next_out))),0===r.avail_in&&0===r.avail_out&&(l=!0)}while((0<r.avail_in||0===r.avail_out)&&n!==va.Z_STREAM_END);return(s=n===va.Z_STREAM_END?va.Z_FINISH:s)===va.Z_FINISH?(n=la.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===va.Z_OK):s!==va.Z_SYNC_FLUSH||(this.onEnd(va.Z_OK),!(r.avail_out=0))},Ma.prototype.onData=function(e){this.chunks.push(e)},Ma.prototype.onEnd=function(e){e===va.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Vi.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},J={};var Ta=((0,Vi.assign)(J,{Inflate:Ma,inflate:Ca,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Ca(e,t)},ungzip:Ca},va),J),Sa=o(function e(t){i(this,e),this._m=t,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1},[{key:"inflate",value:function(e){e=new Uint8Array(e).slice(4);var t,n=Date.now();try{t=Ta.inflate(e,{to:"string"}),this._bLogForInflateOK||(this._bLogForInflateOK=!0,new kn("inflateOK").end())}catch(e){return this._bLogForInflateError?void 0:(this._bLogForInflateError=!0,void new kn("inflateError").setMessage(e).end())}e=e.length+4;var s=t.length;return Ee.d("inflate ok. zipped:".concat(e," unzipped:").concat(s)+" compression ratio:".concat(Math.round(100*(s-e)/s),"% cost:").concat(Date.now()-n)),t}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}]),Ea=o(function e(t){i(this,e);var n=new kn("sdkConstruct"),s=(this._n="ModuleManager",this._isReady=!1,this._reason=un.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._map=new Map,this._optionalModuleMap=new Map,this._codeMsgForTUIMap=new Map,this._iEmitter=null,this._oEmitter=null,this._checkCount=0,this._checkTimer=-1,this._map.set(12,new Ss(this,t)),this._map.set(37,new Sa(this)),this._map.set(15,new Gs(this)),this._map.set(27,new Gi(this)),this._map.set(23,new Oi(this)),this._map.set(24,new wi(this)),this._map.set(26,new Pi(this)),this._map.set(21,new fi(this)),this._map.set(20,new Di(this)),this._map.set(1,new ks(this)),this._map.set(2,new $s(this)),this._map.set(4,new Ts(this)),this._map.set(6,new ns(this)),this._map.set(11,new Ms(this)),this._map.set(13,new Ls(this)),this._map.set(32,new xi(this)),this._map.set(14,new Ps(this)),this._map.set(17,new Hs(this)),this._map.set(18,new Js(this)),this._map.set(19,new Xs(this)),this._map.set(25,new Ri(this)),this._map.set(30,new Fi(this)),this._eventThrottleMap=new Map,this._eventThrottling=t.eventThrottling,this._map.get(12).isPartialUpdatedConvs()&&(this._eventThrottling=!1),this._map.has(7)||this._map.get(12).setUsingChatCore(!0),t.instanceID),a=(t=t.SDKAppID,this._map.get(12).isIntl()),o=this._map.get(12).isUsingChatCore();s="instanceID:".concat(s," SDKAppID:").concat(t," isIntl:").concat(a," isUsingChatCore:").concat(o," host:").concat(ft())+" isIOSWebView:".concat(he," platform:").concat(te," canIUseInflate:").concat(this.canIUseInflate())+" workerAvailable:".concat(le," eventThrottling:").concat(this._eventThrottling," UserAgent:").concat(ee),kn.bindEventStatModule(this._map.get(14)),kn.bindNetMonitorModule(this._map.get(15)),n.setMessage("".concat(s," ").concat((()=>{var e="";if($)try{var t=Q.getSystemInfoSync(),n=t.model,s=t.version,i=t.system,a=t.platform,o=t.SDKVersion;e="model:".concat(n," version:").concat(s," system:").concat(i," platform:").concat(a," SDKVersion:").concat(o)}catch(t){e=""}return e})())).end(),Ee.i("SDK ".concat(s)),cn.prototype._getErrMsg=this.getErrMsg.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()},[{key:"_startTimer",value:function(){var e=this._map.get(24),t=e.isWorkerEnabled();Ee.l("".concat(this._n,".startTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.startWorkerTimer():this._startMainThreadTimer()}},{key:"_startMainThreadTimer",value:function(){this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3)),Ee.l("".concat(this._n,"._startMainThreadTimer seed:").concat(this._checkTimer))}},{key:"stopTimer",value:function(){var e=this._map.get(24),t=e.isWorkerEnabled();Ee.l("".concat(this._n,".stopTimer isWorkerEnabled:").concat(t," seed:").concat(this._checkTimer)),t?e.stopWorkerTimer():this._stopMainThreadTimer()}},{key:"_stopMainThreadTimer",value:function(){Ee.l("".concat(this._n,"._stopMainThreadTimer")),0<this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}},{key:"_stopMainThreadSocket",value:function(){Ee.l("".concat(this._n,"._stopMainThreadSocket"));var e=this._map.get(21);e.setIsWorkerEnabled(!0),e.reConnect()}},{key:"_startMainThreadSocket",value:function(){Ee.l("".concat(this._n,"._startMainThreadSocket"));var e=this._map.get(21);e.setIsWorkerEnabled(!1),e.reConnect()}},{key:"onWorkerTimerEnabled",value:function(){Ee.l("".concat(this._n,".onWorkerTimerEnabled, disable main thread timer and socket")),this._stopMainThreadTimer(),this._stopMainThreadSocket()}},{key:"onWorkerTimerDisabled",value:function(){Ee.l("".concat(this._n,".onWorkerTimerDisabled, enable main thread timer and socket")),this._startMainThreadTimer(),this._startMainThreadSocket()}},{key:"onCheckTimer",value:function(){this._checkCount+=1;var e,t=r(this._map);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2)[1];n.onCheckTimer&&n.onCheckTimer(this._checkCount)}}catch(e){t.e(e)}finally{t.f()}}},{key:"_initReadyList",value:function(){var e=this;this._readyList=[this._map.get(1)],this._readyList.forEach(function(t){t.ready(function(){return e._onModuleReady()})})}},{key:"_onModuleReady",value:function(){var e,t,n=!0;this._readyList.forEach(function(e){e.isReady()||(n=!1)}),n&&!this._isReady&&(this._isReady=!0,this._oEmitter.emit(E.SDK_READY),e=Date.now()-this._startLoginTs,Ee.w("SDK is ready. cost ".concat(e," ms")),this._startLoginTs=Date.now(),t=this._ssoLogForReady.getStartTs()+Me,this._ssoLogForReady.setMessage(e).start(t).end())}},{key:"login",value:function(){0===this._startLoginTs&&(ve(),this._startLoginTs=Date.now(),this._startTimer(),this._map.get(15).start(),this._ssoLogForReady=new kn("sdkReady"),this._reason=un.LOGGING_IN)}},{key:"onLoginFailed",value:function(){this._startLoginTs=0}},{key:"getOEmitInst",value:function(){return null===this._oEmitter&&(this._oEmitter=new Vs,e=this._oEmitter,ln=e,this._oEmitter._emit=this._oEmitter.emit,this._oEmitter.emit=function(e,t){var n,s,i=this;this._canIUseSignaling()&&(e===E.MESSAGE_RECEIVED&&this.get(33).onNewMessageList(t),e===E.MESSAGE_MODIFIED)&&this.get(33).onMessageModified(t),e===E.MESSAGE_RECEIVED&&this.get(11).getStreamMessageBeforeEmit(t),e===E.CONVERSATION_LIST_UPDATED||e===E.FRIEND_LIST_UPDATED||e===E.GROUP_LIST_UPDATED||e===E.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?!1!==this._eventThrottling?this._eventThrottleMap.has(e)?(n=Date.now())-(s=this._eventThrottleMap.get(e)).last<=1e3?(-1<s.timeoutID&&clearTimeout(s.timeoutID),s.timeoutID=setTimeout(function(){s.last=Date.now(),i._oEmitter._emit.apply(i._oEmitter,[e,{name:e,data:i._getEventData(e)}])},1e3)):(s.last=n,this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}])):(this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}])):this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]):this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:t}])}.bind(this)),this._oEmitter;var e}},{key:"_canIUseSignaling",value:function(){var e=this.get(33);return!!e&&e.canIUseSignaling()}},{key:"_getEventData",value:function(e){return e===E.CONVERSATION_LIST_UPDATED?this._map.get(12).isPartialUpdatedConvs()?this._map.get(11).getPartialUpdatedConvs():this._map.get(11).getLocalConvList():e===E.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._map.get(11).getTotalUnreadCount():void 0}},{key:"getIEmitInst",value:function(){return null===this._iEmitter&&(this._iEmitter=new Vs,this._iEmitter._emit=this._iEmitter.emit,this._iEmitter.emit=function(e,t){e=xe(t)&&t.data?[e,{name:e,data:t.data}]:[e,{name:e,data:t}],this._iEmitter._emit.apply(this._iEmitter,e)}.bind(this)),this._iEmitter}},{key:"hasModule",value:function(e){return this._map.has(e)}},{key:"get",value:function(e){return this._map.get(e)}},{key:"canIUseModule",value:function(e){return!this._map.get(12).isUsingChatCore()||this._optionalModuleMap.has(e)}},{key:"canIUseInflate",value:function(){return!!this._map.get(37)}},{key:"isReady",value:function(){return this._isReady}},{key:"isIntl",value:function(){return this.get(12).isIntl()}},{key:"getNotReadyReason",value:function(){return this._reason}},{key:"setNotReadyReason",value:function(e){this._reason=e}},{key:"getErrMsg",value:function(e,t,n){return this._map.get(32).get({key:e,replacement1:t,replacement2:n,isIntl:this.isIntl()})}},{key:"warn",value:function(e,t,n){(e=this.getErrMsg(e,t,n))&&Ee.w(e)}},{key:"onError",value:function(e){var t="code:".concat(e.code," message:").concat(e.message);Ee.w("Oops! ".concat(t)),new kn("error").setMessage(t).setLevel("error").end(),this.getOEmitInst().emit(E.ERROR,e)}},{key:"restartTimer",value:function(){Ee.l("".concat(this._n,".restartTimer")),this.stopTimer(),this._startTimer();var e=this.get(7);e&&e.restartPolling()}},{key:"getTimerID",value:function(){var e=this._map.get(24);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}},{key:"getPollingTimerID",value:function(e){return this._map.get(7).getPollingTimerID(e)}},{key:"statTUIKeyFeatures",value:function(e){var t=e.code,n=t+(e=void 0===(e=e.msg)?"":e);this._codeMsgForTUIMap.has(n)||(this._codeMsgForTUIMap.set(n,1),n=this.get(12).getUIPlatform(),new kn("tui_key_features").setCode(t).setMessage(e).setUIPlatform(n).end())}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),ve();var e,t=r(this._map);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2)[1];n.reset&&n.reset()}}catch(e){t.e(e)}finally{t.f()}this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._oEmitter.emit(E.SDK_NOT_READY);var s,i=r(this._eventThrottleMap);try{for(i.s();!(s=i.n()).done;){var a=v(s.value,2)[1];-1<a.timeoutID&&clearTimeout(a.timeoutID)}}catch(e){i.e(e)}finally{i.f()}this._eventThrottleMap.clear(),this._codeMsgForTUIMap.clear()}}]),ka=o(function e(t){i(this,e),this._funcMap=new Map,this._m=t,this._n="SafetyCallback",this._reportCount=0},[{key:"defense",value:function(e,t){var n=2<arguments.length&&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 s=null;return this._funcMap.get(e).has(t)?s=this._funcMap.get(e).get(t):(s=this._pack(e,t,n),this._funcMap.get(e).set(t,s)),s}},{key:"defenseOnce",value:function(e,t){return"function"!=typeof t?null:this._pack(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:void 0)}},{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):(this._m.warn("ListenerFnNotFound",e),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){var s=this;return function(){try{t.apply(n,Array.from(arguments))}catch(t){var i=Object.values(E).indexOf(e),a="CallbackError";-1!==i&&(i=Object.keys(E)[i],s._m.warn(a,i,t)),s._reportCount<5&&(new kn(a).setMessage("eventName:".concat(e)).setMoreMessage(t.message).end(),s._reportCount+=1)}}}},{key:"destroy",value:function(){this._funcMap.clear()}},{key:"reset",value:function(){Ee.l("".concat(this._n,".reset")),this._reportCount=0}}]),Da=o(function e(t){i(this,e),t={SDKAppID:t.SDKAppID,unlimitedAVChatRoom:t.unlimitedAVChatRoom||!1,scene:t.scene||"",oversea:t.oversea||!1,instanceID:_t(),devMode:t.devMode||!1,testEnv:t.testEnv||!1,proxyServer:t.proxyServer||void 0,fileUploadProxy:t.fileUploadProxy||void 0,fileDownloadProxy:t.fileDownloadProxy||t.fileUploadProxy||void 0,eventThrottling:!1!==t.eventThrottling,partialUpdatedConversations:!0===t.partialUpdatedConversations,disableIndependentDomain:!0===t.disableIndependentDomain,modules:t.modules||void 0},this._m=new Ea(t),this._safetyCallbackFactory=new ka(this._m)},[{key:"onError",value:function(e){this._m.onError(e)}},{key:"login",value:function(e){return this._m.login(),this._get(1).login(e)}},{key:"logout",value:function(){var e=this;return this._get(1).logout().then(function(t){return e._safetyCallbackFactory.reset(),e._m.reset(),t})}},{key:"getLoginUser",value:function(){return this._get(1).getLoginUser()}},{key:"getServerTime",value:me},{key:"isReady",value:function(){return this._m.isReady()}},{key:"isIntl",value:function(){return this._m.isIntl()}},{key:"getNotReadyReason",value:function(){return this._m.getNotReadyReason()}},{key:"getErrMsg",value:function(e,t,n){return this._m.getErrMsg(e,t,n)}},{key:"_get",value:function(e){return this._m.get(e)}},{key:"destroy",value:function(){var e=this,t=this._get(12),n=t.getSDKAppID();return Ee.w("destroy ".concat(n," ").concat(t.getInstanceID())),this.logout().finally(function(){e._safetyCallbackFactory.destroy(),e._m.stopTimer(),e._get(24).terminate(),e._get(21).dealloc(),e._m.getOEmitInst().emit(E.SDK_DESTROY,{SDKAppID:n})})}},{key:"on",value:function(e,t,n){Ee.d("on","eventName:".concat(e)),this._m.getOEmitInst().on(e,this._safetyCallbackFactory.defense(e,t,n),n)}},{key:"off",value:function(e,t,n,s){Ee.d("off","eventName:".concat(e));var i=this._safetyCallbackFactory.find(e,t);null!==i&&(this._m.getOEmitInst().off(e,i,n,s),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){this._get(18).registerPlugin(e)}},{key:"setLogLevel",value:function(e){var t;e<=0&&((t=this.getErrMsg("TIM_ASCII_ART"))&&console.log(t),(t=this.getErrMsg("API_REFER"))&&(Dt()?console.log("%c ".concat("IM SDK API ->"," %c"),"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",t):console.log("IM SDK API ->",t)),(t=this.getErrMsg("DOCS_GUIDE"))&&console.log(t),t=this.getErrMsg("IOS_WEBVIEW_WARNING"),he)&&t&&console.warn(t),Ee.setLevel(e)}},{key:"createTextMessage",value:function(e){return this._get(2).createTextMessage(e)}},{key:"createTextAtMessage",value:function(e){return this._get(2).createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this._get(2).createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this._get(2).createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this._get(2).createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this._get(2).createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this._get(2).createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this._get(2).createFileMessage(e)}},{key:"createLocationMessage",value:function(e){return this._get(2).createLocationMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof $n?this._get(2).sendMessageInstance(e,t):Jt({code:un.MSG_INSTANCE_REQUIRED})}},{key:"callExperimentalAPI",value:function(e,t){return"sendComboMessage"===e?this._get(31).sendMessage(t):"handleGroupInvitation"===e?this._get(7).handleGroupInvitation(t):"isCommercialAbilityEnabled"===e?this._get(27).isFeatureEnabled(t):"isFeatureEnabledForStat"===e?this._get(27).isFeatureEnabledForStat(t):"isIntl"===e?this.isIntl():"sendTRTCCustomData"===e||"sendRoomCustomData"===e?this._get(30).sendTRTCCustomData(t):"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):"setApplicationID"===e?(this._get(12).setApplicationID(t),void this._get(20).updateProtocolConfig()):"getServerConfig"===e?this._get(23).getServerConfig(t):"canIUseModule"===e?this._m.canIUseModule(t):"startMessageLongPolling"===e?this._get(7).startMessageLongPolling(t):"stopMessageLongPolling"===e?this._get(7).stopMessageLongPolling(t):"disableMessagePullOnInvite"===e?this._get(11).disableMsgPullOnInvite(t):"clearLocalMessage"===e?this._get(11).clearMemMsg(t,!1):"setCustomLoginInfo"===e?this._get(12).setCustomLoginInfo(t):"statTUIKeyFeatures"===e?this._m.statTUIKeyFeatures(t):"getGroupReceiptsByUsers"===e?this._get(7).getGroupReceiptsByUsers(t):Jt({code:un.INVALID_OPERATION})}},{key:"revokeMessage",value:function(e){return this._get(2).revokeMessage(e)}},{key:"resendMessage",value:function(e,t){return e instanceof $n?this._get(2).resendMessage(e,t):Jt({code:un.MSG_INSTANCE_REQUIRED})}},{key:"deleteMessage",value:function(e){return this._get(2).deleteMessage(e)}},{key:"translateText",value:function(e){return this._get(2).translateText(e)}},{key:"convertVoiceToText",value:function(e){return this._get(2).convertVoiceToText(e)}},{key:"modifyMessage",value:function(e){return this._get(2).modifyRemoteMessage(e)}},{key:"getMessageList",value:function(e){return this._get(11).getMessageList(e)}},{key:"getMessageListHopping",value:function(e){return this._get(11).getMessageListHopping(e)}},{key:"sendMessageReadReceipt",value:function(e){return this._get(11).sendReadReceipt(e)}},{key:"getMessageReadReceiptList",value:function(e){return this._get(11).getReadReceiptList(e)}},{key:"findMessage",value:function(e){return this._get(11).findMessage(e)}},{key:"setMessageRead",value:function(e){return this._get(11).setMessageRead(e)}},{key:"getConversationList",value:function(e){return this._get(11).getConvList(e)}},{key:"getConversationProfile",value:function(e){return this._get(11).getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this._get(11).deleteConversation(e)}},{key:"setConversationDraft",value:function(e){return this._get(11).setConvDraft(e)}},{key:"clearHistoryMessage",value:function(e){return this._get(11).clearHistoryMessage(e)}},{key:"pinConversation",value:function(e){return this._get(11).pinConversation(e)}},{key:"setAllMessageRead",value:function(e){return this._get(11).setAllMessageRead(e)}},{key:"setMessageRemindType",value:function(e){return this._get(11).setMessageRemindType(e)}},{key:"setAllReceiveMessageOpt",value:function(e){return this._get(11).setAllRcvMsgOpt(e)}},{key:"getAllReceiveMessageOpt",value:function(){return this._get(11).getAllRcvMsgOpt()}},{key:"getTotalUnreadMessageCount",value:function(){return this._get(11).getTotalUnreadCount()}},{key:"setConversationCustomData",value:function(e){return this._get(11).setConvCustomData(e)}},{key:"markConversation",value:function(e){return this._get(11).markConv(e)}},{key:"getMyProfile",value:function(){return this._get(4).getMyProfile()}},{key:"getUserProfile",value:function(e){return this._get(4).getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this._get(4).updateMyProfile(e)}}]),Oa={login:1,logout:1,getLoginUser:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1,isReady:1,addSignalingListener:1,removeSignalingListener:1,callExperimentalAPI:1},Ra={};return(x={}).create=function(e){var t,n,s,i="TencentCloudChat.create",a=0;if(Ge(s=e.SDKAppID))a=s;else if(a=parseInt(s),isNaN(s))return Ee.e("".concat(i," failed. Failed to parse the SDKAppID, please check the arguments")),null;return a&&Ra[a]?Ra[a]:(Ee.l("".concat(i)),(s=new Da(_(_({},e),{},{SDKAppID:a}))).on(E.SDK_DESTROY,function(e){Ra[e.data.SDKAppID]=null,delete Ra[e.data.SDKAppID]}),t=s,n=Object.create(null),Object.keys(rn).forEach(function(e){var s;t[e]&&(s=new D,n[e]=function(){var n=Array.from(arguments);return s.use(function(n,s){o=e;var i,a,o=!(!(i=t).isReady()&&1!==Oa[o])||(a={code:a=i.getNotReadyReason(),message:"".concat(i.getErrMsg(a)," | ").concat(o," | ").concat(i.getErrMsg(un.SDK_IS_NOT_READY))},i.onError(a),a);return!0===o?s():Jt(o)}).use(function(t,n){if(!0===((e,t,n)=>{if(void 0===t)return!0;var s=!0;if(xe(t))Object.keys(t).forEach(function(i){var a=1===e.length?e[0][i]:void 0;s=!!At(a,t[i],n,i)&&s});else if(Ve(t))for(var i=0;i<t.length;i++)s=!!At(e[i],t[i],n,t[i].name)&&s;if(s)return s;throw new Error("Params validate failed.")})(t,on[e],e))return n()}).use(function(n,s){return t[e].apply(t,n)}),s.run(n)})}),e=n,Ra[a]=e,on.hookGetAPITips(s.getErrMsg.bind(s)),Ee.l("".concat(i," ok")),e)},x.TYPES=k,x.EVENT=E,x.VERSION=S,Ee.l("TencentCloudChat.VERSION:".concat(x.VERSION)),x}());class f{constructor(e){return f.instance||(f.instance=this,this.engine=e,this.events={},this.bindIMEvents()),f.instance}addEvent(e,t){this.events[e]||(this.events[e]=new Map),this.events[e].set(t,1)}removeEvents(){Object.keys(this.events).forEach(e=>{this.events[e].clear()}),this.events={}}dispatch(e,t){if(this.events[e])for(const n of this.events[e].keys())n.call(this,t)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this)}onSDKReady(e){this.dispatch(this.engine.EVENT.SDK_READY,e.data)}onSDKNotReady(e){this.dispatch(this.engine.EVENT.SDK_NOT_READY,e.data)}onKickedOut(e){this.dispatch(this.engine.EVENT.KICKED_OUT,e.data)}onNetStateChange(e){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,e.data)}onReceiveMessage(e){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,e.data)}onMessageModified(e){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,e.data)}onMessageRevoked(e){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,e.data)}onMessageReadByPeer(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,e.data)}onMessageReadReceiptReceived(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,e.data)}onMessageReactionsUpdated(e){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,e.data)}onConversationListUpdated(e){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,e.data)}onTotalMessageCountUpdated(e){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,e.data)}onProfileUpdated(e){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,e.data)}onBlacklistUpdated(e){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,e.data)}onUserStatusUpdated(e){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,e.data)}onGroupListUpdated(e){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,e.data)}onGroupAttributesUpdated(e){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,e.data)}onGroupCounterUpdated(e){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,e.data)}onFriendListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,e.data)}onFriendApplicationListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,e.data)}}!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIUser="TUIUser",e.TUIReport="TUIReport"}(a||(a={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.SEARCH="search",e.CUSTOM="custom"}(o||(o={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(r||(r={})),function(e){e.BUSINESS_ID="user_typing_status",e[e.STATUS_START=1]="STATUS_START",e[e.STATUS_END=0]="STATUS_END",e[e.VERSION=1]="VERSION",e[e.ACTION_START_ID=14]="ACTION_START_ID",e[e.ACTION_END_ID=0]="ACTION_END_ID",e.ACTION_START="EIMAMSG_InputStatus_Ing",e.ACTION_END="EIMAMSG_InputStatus_End",e[e.NEED_TYPING=1]="NEED_TYPING"}(c||(c={})),function(e){e.ADD="add",e.REMOVE="remove"}(u||(u={})),function(e){e[e.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",e[e.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",e[e.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(l||(l={})),function(e){e[e.NOT_INIT=-1e5]="NOT_INIT",e[e.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",e[e.CONV_ID_SAME=-100002]="CONV_ID_SAME",e[e.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",e[e.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",e[e.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(d||(d={})),function(e){e.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",e.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",e.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(h||(h={})),function(e){e.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",e.INVALID_CONV_ID="会话 ID 无效",e.CONV_ID_SAME="您切换的是同一个会话 ID",e.CONV_NOT_EXIST="会话不存在",e.GET_MSG_LIST_ERROR="Chat SDK is not ready.",e.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(g||(g={}));const m={logout:1,destroy:1},v={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1},y={modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},I={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},M=function(e){return void 0===e},C=function(e){return e.startsWith("_")},T=function(e){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(e)};const S=function(e){return e&&function(e){if("string"==typeof e)try{return!!JSON.parse(e)}catch(e){return!1}return!1}(e)?JSON.parse(e):e},E=function(e){let t="";return t=e>=1048576?`${(e/1048576).toFixed(2)} Mb`:e>=1024?`${(e/1024).toFixed(2)} Kb`:`${e.toFixed(2)}B`,t},k="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_16.png",D="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.png",O="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",R="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",A="https://web.sdk.qcloud.com/im/assets/face-elem/",N="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",L="https://apis.map.qq.com/ws/staticmap/v2/?",U={"[TUIEmoji_Expect]":"emoji_0@2x.png","[TUIEmoji_Blink]":"emoji_1@2x.png","[TUIEmoji_Guffaw]":"emoji_2@2x.png","[TUIEmoji_KindSmile]":"emoji_3@2x.png","[TUIEmoji_Haha]":"emoji_4@2x.png","[TUIEmoji_Cheerful]":"emoji_5@2x.png","[TUIEmoji_Smile]":"emoji_6@2x.png","[TUIEmoji_Sorrow]":"emoji_7@2x.png","[TUIEmoji_Speechless]":"emoji_8@2x.png","[TUIEmoji_Amazed]":"emoji_9@2x.png","[TUIEmoji_Complacent]":"emoji_10@2x.png","[TUIEmoji_Lustful]":"emoji_11@2x.png","[TUIEmoji_Stareyes]":"emoji_12@2x.png","[TUIEmoji_Giggle]":"emoji_13@2x.png","[TUIEmoji_Daemon]":"emoji_14@2x.png","[TUIEmoji_Rage]":"emoji_15@2x.png","[TUIEmoji_Yawn]":"emoji_16@2x.png","[TUIEmoji_TearsLaugh]":"emoji_17@2x.png","[TUIEmoji_Silly]":"emoji_18@2x.png","[TUIEmoji_Wail]":"emoji_19@2x.png","[TUIEmoji_Kiss]":"emoji_20@2x.png","[TUIEmoji_Trapped]":"emoji_21@2x.png","[TUIEmoji_Fear]":"emoji_22@2x.png","[TUIEmoji_BareTeeth]":"emoji_23@2x.png","[TUIEmoji_FlareUp]":"emoji_24@2x.png","[TUIEmoji_Tact]":"emoji_25@2x.png","[TUIEmoji_Shit]":"emoji_26@2x.png","[TUIEmoji_ShutUp]":"emoji_27@2x.png","[TUIEmoji_Sigh]":"emoji_28@2x.png","[TUIEmoji_Hehe]":"emoji_29@2x.png","[TUIEmoji_Silent]":"emoji_30@2x.png","[TUIEmoji_Skull]":"emoji_31@2x.png","[TUIEmoji_Mask]":"emoji_32@2x.png","[TUIEmoji_Beer]":"emoji_33@2x.png","[TUIEmoji_Cake]":"emoji_34@2x.png","[TUIEmoji_RedPacket]":"emoji_35@2x.png","[TUIEmoji_Bombs]":"emoji_36@2x.png","[TUIEmoji_Ai]":"emoji_37@2x.png","[TUIEmoji_Celebrate]":"emoji_38@2x.png","[TUIEmoji_Bless]":"emoji_39@2x.png","[TUIEmoji_Flower]":"emoji_40@2x.png","[TUIEmoji_Watermelon]":"emoji_41@2x.png","[TUIEmoji_Cow]":"emoji_42@2x.png","[TUIEmoji_Fool]":"emoji_43@2x.png","[TUIEmoji_Surprised]":"emoji_44@2x.png","[TUIEmoji_Askance]":"emoji_45@2x.png","[TUIEmoji_Monster]":"emoji_46@2x.png","[TUIEmoji_Pig]":"emoji_47@2x.png","[TUIEmoji_Coffee]":"emoji_48@2x.png","[TUIEmoji_Ok]":"emoji_49@2x.png","[TUIEmoji_Heart]":"emoji_50@2x.png","[TUIEmoji_Sun]":"emoji_51@2x.png","[TUIEmoji_Moon]":"emoji_52@2x.png","[TUIEmoji_Star]":"emoji_53@2x.png","[TUIEmoji_Rich]":"emoji_54@2x.png","[TUIEmoji_Fortune]":"emoji_55@2x.png","[TUIEmoji_857]":"emoji_56@2x.png","[TUIEmoji_666]":"emoji_57@2x.png","[TUIEmoji_Prohibit]":"emoji_58@2x.png","[TUIEmoji_Convinced]":"emoji_59@2x.png","[TUIEmoji_Knife]":"emoji_60@2x.png","[TUIEmoji_Like]":"emoji_61@2x.png"},P={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},w={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},b=["messageList","conversationList","newMessageList"],G=["translateTextInfo","voiceToTextInfo"],F="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),x="undefined"!=typeof uni&&"undefined"==typeof window,V=F||x,q="undefined"!=typeof uni,K=("undefined"!=typeof uni||"undefined"!=typeof window)&&!V,H=F?wx:q?uni:window,j=K&&window&&window.navigator&&window.navigator.userAgent||"",B=/Android/i.test(j),Y=/(?:Windows Phone)/.test(j),W=/(?:SymbianOS)/.test(j),z=/iPad/i.test(j)||/iPhone/i.test(j)||/iPod/i.test(j),$=B||Y||W||z,J=K&&!$;class X{constructor(){this.global=H,this.isOfficial=!1}static getInstance(){return X.instance||(X.instance=new X),X.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return J?e="pc":$?e="h5":F?e="wechat":x&&!F&&(e="app"),e}}class Z{constructor(){this.EVENT=_.EVENT,this.TYPES=_.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}mount(e,t){this[e]=t}login(e){const{chat:t,SDKAppID:n,userID:s}=e,i=1400187352===n||1400188366===n;return this.createChat(e),this.userID=s,X.getInstance().initOfficial(i),this.TUIStore.update(o.APP,"isOfficial",i),this.TUIStore.update(o.APP,"SDKVersion",_.VERSION),this.eventCenter=new f(this),this.eventCenter.removeEvents(),this.resetStore(),this.initService(),t&&t.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(e),this.eventCenter.addEvent(this.EVENT.SDK_READY,()=>{this.onSDKReady()}),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,()=>{this.onSDKNotReady()}),this.loginChat(e))}logout(){return this.userID="",this.isInited=!1,this.resetStore(),this.eventCenter.removeEvents(),this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){if(this.chat)return this.chat.setLogLevel(e);console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.resetStore(),this.eventCenter.removeEvents(),this.chat.destroy()}getMyUserID(){return this.userID}resetStore(){this.TUIStore.reset(o.CHAT),this.TUIStore.reset(o.CONV),this.TUIStore.reset(o.USER),this.TUIStore.reset(o.CUSTOM),console.log("TUIChatEngine.resetStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}createChat(e){const{chat:n,scene:s}=e,i=t(e,["chat","scene"]);M(n)?this.chat=_.create(Object.assign(Object.assign({},i),{scene:s||"aidesk-uikit-engine"})):this.chat=n}loginChat(e){const{userID:t,userSig:n}=e;return new Promise((e,s)=>{this.chat.login({userID:t,userSig:n}).then(t=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),t.data.repeatLogin&&this.chat.isReady()&&e(t),this.loginStatusPromise.set("login",{resolve:e,reject:s,imResponse:t})}).catch(e=>{s(e)})})}registerPlugin(t){const{useUploadPlugin:n=!1,useProfanityFilterPlugin:s=!1,TIMPush:i,pushConfig:a,TUIOfflinePush:o,offlinePushConfig:r}=t;!0===n&&this.chat.registerPlugin({"tim-upload-plugin":e})}onSDKReady(){if(this.loginStatusPromise.has("login")){const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){if(this.loginStatusPromise.has("login")){this.loginStatusPromise.get("login").reject(new Error("sdk not ready"))}this.loginStatusPromise.delete("login"),this.resetStore()}checkCommercialAbility(){Object.keys(w).forEach(e=>{const t=w[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then(t=>{const{enabled:n=!1}=t.data;this.TUIStore.update(o.APP,e,n)})})}}class Q{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}}class ee{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}updateUserStatusList(e){0!==e.length?e.forEach(e=>{const{userID:t,statusType:n=0,customStatus:s=""}=e;n===r.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:n,customStatus:s})}):this.store.userStatusList.clear()}}class te{getEngine(){return Z.getInstance()}}const ne=function(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(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}(e)){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return!1},se=["[图片]","[语音]","[视频]","[文件]","[位置]","[地理位置]","[动画表情]","[自定义消息]","[群提示消息]","[聊天记录]"];class ie extends te{constructor(e){super(),this.initProxy(e),this.isMuted=this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_ACPT_NOT_NOTE||this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_DISCARD,this.operationType=0,this._conversation=e}initProxy(e){Object.keys(e).forEach(t=>{C(t)||(this[t]=e[t])})}updateProperties(e){Object.keys(e).forEach(t=>{C(t)||(this[t]=e[t])})}updateOperationType(e){this.operationType=e}getConversation(){return this._conversation}deleteConversation(){return this.getEngine().TUIConversation.deleteConversation(this.conversationID)}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!0===this.isMuted?e.TYPES.MSG_REMIND_ACPT_AND_NOTE:e.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===e.TYPES.CONV_C2C){const n=this.conversationID.replace(e.TYPES.CONV_C2C,"");t.userIDList=[n]}else if(this.type===e.TYPES.CONV_GROUP){const n=this.conversationID.replace(e.TYPES.CONV_GROUP,"");t.groupID=n}return e.TUIConversation.muteConversation(t)}getAvatar(){var e,t,n,s,i,a;const o=this.getEngine();let r="";switch(this.type){case o.TYPES.CONV_C2C:r=T(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:k;break;case o.TYPES.CONV_GROUP:r=T(null===(n=this.groupProfile)||void 0===n?void 0:n.avatar)?null===(s=this.groupProfile)||void 0===s?void 0:s.avatar:D;break;case o.TYPES.CONV_SYSTEM:r=T(null===(i=this.groupProfile)||void 0===i?void 0:i.avatar)?null===(a=this.groupProfile)||void 0===a?void 0:a.avatar:O}return r}getShowName(){var e,t,n,s;const i=this.getEngine();let a="";switch(this.type){case i.TYPES.CONV_C2C:a=this.remark||(null===(e=this.userProfile)||void 0===e?void 0:e.nick)||(null===(t=this.userProfile)||void 0===t?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:a=(null===(n=this.groupProfile)||void 0===n?void 0:n.name)||(null===(s=this.groupProfile)||void 0===s?void 0:s.groupID)||"";break;case i.TYPES.CONV_SYSTEM:a=i.TUITranslate.t("系统通知")}return a}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),n=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let s="";for(let e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(s=n[this.groupAtInfoList[e].atTypeArray[0]-1]);return s}getLastMessage(e){return"time"===e?this.getLastMessageTime():"text"===e?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let n="";return(null===(e=this.lastMessage)||void 0===e?void 0:e.lastTime)>0&&(n=function(e,t){const n=6e4,s=36e5,i=24*s,a=7*i,o=(new Date).getTime()-e;let r="";if(o<0)return r;const c=o/n,u=o/s,l=o/i,d=o/a;if(d>=1&&d<=4)r=` ${parseInt(`${d}`,10)} ${t("time.周")}${t("time.前")}`;else if(l>=1&&l<=6)r=` ${parseInt(`${l}`,10)} ${t("time.天")}${t("time.前")}`;else if(u>=1&&u<=23)r=` ${parseInt(`${u}`,10)} ${t("time.小时")}${t("time.前")}`;else if(c>=1&&c<=59)r=` ${parseInt(`${c}`,10)} ${t("time.分钟")}${t("time.前")}`;else if(o>=0&&o<=n)r=`${t("time.刚刚")}`;else{const t=new Date;t.setTime(e),r=`${t.getFullYear()}-${t.getMonth()+1<10?`0${t.getMonth()+1}`:t.getMonth()+1}-${t.getDate()<10?`0${t.getDate()}`:t.getDate()}`}return r}(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),n}getLastMessageText(){var e;if(this.draftText){return S(this.draftText).abstract}const t=this.getEngine(),n=t.TUITranslate.t.bind(t.TUITranslate);if(4===this.operationType)return n("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return n("TUIConversation.该群聊已被解散");if(8===this.operationType)return n("TUIConversation.您已退出该群聊");const s=this._conversation,i=this.lastMessage;let a="";const o=s.unreadCount>0&&s.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${s.unreadCount>99?"99+":s.unreadCount}${n("TUIConversation.条")}]`:"";if(i.type===t.TYPES.MSG_TEXT)a=this.decodeTextMessage(i.payload.text);else if(i.type===t.TYPES.MSG_CUSTOM){const s=S(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.data);if(1===(null==s?void 0:s.businessID))return a=t.TUIChat.messageHandler.handleCallKitSignaling(i),a;a=se.includes(i.messageForShow)?n(`TUIChat.${i.messageForShow}`):i.messageForShow}else a=se.includes(i.messageForShow)?n(`TUIChat.${i.messageForShow}`):i.messageForShow;return i.isRevoked&&(a=n("TUIChat.撤回了一条消息")),s.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?a:`${o}${a}`}decodeTextMessage(e){if(ne(e))return e;const t=/(\[.+?\])/g;let n=e;if(t.test(e)){const s=this.getEngine(),i=s.TUITranslate.t.bind(s.TUITranslate);n=e.replace(t,e=>{const t=i(`Emoji.${e}`);return F||!t||t.startsWith("Emoji.")?P[e]||e:t})}return n}}class ae{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(e,t){switch(e){case"conversationList":this.updateConversationList(t);break;case"operationTypeMap":this.updateOperationTypeMap(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find(t=>t.conversationID===e)}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}updateConversationList(e){const t=[];e.forEach(e=>{let n=e;e instanceof ie?n.updateProperties(e):n=new ie(e);const s=this.getOperationType(e);n.updateOperationType(s),t.push(n)}),this.store.conversationList=t}updateOperationTypeMap(e){const{conversationID:t,operationType:n=0}=e;this.store.operationTypeMap.set(t,n)}getOperationType(e){const{conversationID:t}=e;return this.store.operationTypeMap.get(t)||0}}class oe extends te{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:e=>this.getEngine().TUIChat.messageHandler.handleTextMessage(e),[this.getEngine().TYPES.MSG_FACE]:e=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(e),[this.getEngine().TYPES.MSG_LOCATION]:e=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(e),[this.getEngine().TYPES.MSG_IMAGE]:e=>this.getEngine().TUIChat.messageHandler.handleImageMessage(e),[this.getEngine().TYPES.MSG_AUDIO]:e=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(e),[this.getEngine().TYPES.MSG_VIDEO]:e=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(e),[this.getEngine().TYPES.MSG_FILE]:e=>this.getEngine().TUIChat.messageHandler.handleFileMessage(e),[this.getEngine().TYPES.MSG_CUSTOM]:e=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(e),[this.getEngine().TYPES.MSG_MERGER]:e=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(e),[this.getEngine().TYPES.MSG_GRP_TIP]:e=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(e),[this.getEngine().TYPES.MSG_STREAM]:e=>this.getEngine().TUIChat.messageHandler.handleStreamMessage(e)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(e)}initProperties(e){Object.keys(e).forEach(t=>{C(t)||(this[t]=e[t])})}updateProperties(e){this._message=e,Object.keys(e).forEach(t=>{C(t)||(this[t]=e[t])})}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:d.MISMATCH_TYPE_AND_PAYLOAD,message:g.MISMATCH_TYPE_AND_PAYLOAD}):(this._message.type=e.type||this._message.type,this._message.payload=e.payload||this._message.payload,this._message.cloudCustomData=e.cloudCustomData||this._message.cloudCustomData,this.getEngine().TUIChat.modifyMessage(this._message))}revokeMessage(){return this.getEngine().TUIChat.revokeMessage(this._message)}resendMessage(){return this.getEngine().TUIChat.resendMessage(this._message)}deleteMessage(){return this.getEngine().TUIChat.deleteMessage([this._message])}quoteMessage(){return this.getEngine().TUIChat.quoteMessage(this._message)}replyMessage(){return this.getEngine().TUIChat.replyMessage(this._message)}setMessageExtensions(e){return this.getEngine().TUIChat.setMessageExtensions(this._message,e)}getMessageExtensions(){return this.getEngine().TUIChat.getMessageExtensions(this._message)}deleteMessageExtensions(e){return this.getEngine().TUIChat.deleteMessageExtensions(this._message,e)}getSignalingInfo(){return null}getMessageContent(){const e=this.messageHandlers[this.type];return M(e)?{}:this.type===this.getEngine().TYPES.MSG_GRP_TIP?e(this._message):Object.assign(Object.assign({},e(this._message)),{showName:this.nick||this.from})}sendForwardMessage(e){return this.getEngine().TUIChat.sendForwardMessage(e,[this._message])}}class re{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(e,t){switch(e){case"messageList":this.updateMessageList(t);break;case"translateTextInfo":this.updateTranslateTextInfo(t);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find(t=>t.ID===e)}reset(e=[]){const t=e.filter(e=>!G.includes(e));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==t?void 0:t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}updateMessageList(e){const t=[];e.forEach(e=>{let n=e;e instanceof oe||(n=this.getModel(e.ID),n?n.updateProperties(e):n=new oe(e)),t.push(n)}),this.store.messageList=t}updateTranslateTextInfo(e){this.updateBykey("translateTextInfo",e)}updateVoiceToTextInfo(e){this.updateBykey("voiceToTextInfo",e)}updateBykey(e,t){const{conversationID:n,messageID:s,visible:i=!1}=t;this.store[e]||(this.store[e]=new Map),this.store[e].has(n)||this.store[e].set(n,[]);const a=this.store[e].get(n)||[];let o=!0;for(let e=0;e<a.length;e++)if(a[e].messageID===s){a[e].visible=i,o=!1;break}o&&a.push({messageID:s,visible:i}),this.store[e].set(n,a)}}class ce{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:void 0}),{}))}}class ue{constructor(){this.storeMap={[o.APP]:new Q,[o.USER]:new ee,[o.CONV]:new ae,[o.CHAT]:new re},this.task={}}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}watch(e,t){this.task[e]||(this.task[e]={});const n=this.task[e];Object.keys(t).forEach(s=>{const i=t[s];n[s]||(n[s]=new Map),n[s].set(i,1),this.notifyOnWatch(e,s,i)})}unwatch(e,t){if(!this.task[e])return;const n=this.task[e];Object.keys(t).forEach(e=>{var s;null===(s=n[e])||void 0===s||s.delete(t[e])})}update(e,t,n){var s;e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ce),null===(s=this.storeMap[e])||void 0===s||s.update(t,n),this.notify(e,t)}getData(e,t){var n;return e!==o.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ce),null===(n=this.storeMap[e])||void 0===n?void 0:n.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[o.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[o.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],n=!1){if(e in this.storeMap){const s=this.storeMap[e];0===t.length&&(t=Object.keys(null==s?void 0:s.store)),s.reset(t),n&&t.forEach(t=>{this.notify(e,t)})}}notifyOnWatch(e,t,n){const s=this.getData(e,t);b.indexOf(t)>-1&&0===s.length||n&&n.call(this,s)}notify(e,t){if(!this.task[e])return;const n=this.task[e];if(n[t]){const s=n[t],i=this.getData(e,t);for(const[e]of s.entries())e.call(this,i)}}}function le(e){return le="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},le(e)}function de(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e){var t=function(e,t){if("object"!=le(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=le(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==le(t)?t:t+""}function ge(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,he(s.key),s)}}function pe(e,t,n){return t&&ge(e.prototype,t),n&&ge(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function fe(e,t){return fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},fe(e,t)}function me(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fe(e,t)}function ve(e,t){if(t&&("object"==le(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _e(e)}function ye(e){return ye=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ye(e)}function Ie(e,t,n){return(t=he(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}function Ce(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Me(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Me(e,t):void 0}}(e)||function(){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 Te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function Se(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Te(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Te(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Ee={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},ke=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(this,e),this.init(t,n)}return pe(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Ee,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,s){return s&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Se(Se({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),De=function(){function e(){de(this,e),this.observers={}}return pe(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach(function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)}),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter(function(e){return e!==t}):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,n)});this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(n))})}}]),e}();function Oe(){var e,t,n=new Promise(function(n,s){e=n,t=s});return n.resolve=e,n.reject=t,n}function Re(e){return null==e?"":""+e}function Ae(e,t,n){function s(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var a="string"!=typeof t?[].concat(t):t.split(".");a.length>1;){if(i())return{};var o=s(a.shift());!e[o]&&n&&(e[o]=new n),e=Object.prototype.hasOwnProperty.call(e,o)?e[o]:{}}return i()?{}:{obj:e,k:s(a.shift())}}function Ne(e,t,n){var s=Ae(e,t,Object);s.obj[s.k]=n}function Le(e,t){var n=Ae(e,t),s=n.obj,i=n.k;if(s)return s[i]}function Ue(e,t,n){for(var s in t)"__proto__"!==s&&"constructor"!==s&&(s in e?"string"==typeof e[s]||e[s]instanceof String||"string"==typeof t[s]||t[s]instanceof String?n&&(e[s]=t[s]):Ue(e[s],t[s],n):e[s]=t[s]);return e}function Pe(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var we={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function be(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return we[e]}):e}var Ge="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Fe=[" ",",","?","!",";"];function xe(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var s=t.split(n),i=e,a=0;a<s.length;++a){if(!i)return;if("string"==typeof i[s[a]]&&a+1<s.length)return;if(void 0===i[s[a]]){for(var o=2,r=s.slice(a,a+o).join(n),c=i[r];void 0===c&&s.length>a+o;)o++,c=i[r=s.slice(a,a+o).join(n)];if(void 0===c)return;if(null===c)return null;if(t.endsWith(r)){if("string"==typeof c)return c;if(r&&"string"==typeof c[r])return c[r]}var u=s.slice(a+o).join(n);return u?xe(c,u,n):void 0}i=i[s[a]]}return i}}function Ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ve(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ve(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ke(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return ve(this,n)}}var He=function(){me(t,De);var e=Ke(t);function t(n){var s,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return de(this,t),s=e.call(this),Ge&&De.call(_e(s)),s.data=n||{},s.options=i,void 0===s.options.keySeparator&&(s.options.keySeparator="."),void 0===s.options.ignoreJSONStructure&&(s.options.ignoreJSONStructure=!0),s}return pe(t,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,a=void 0!==s.ignoreJSONStructure?s.ignoreJSONStructure:this.options.ignoreJSONStructure,o=[e,t];n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."));var r=Le(this.data,o);return r||!a||"string"!=typeof n?r:xe(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},a=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(s=t,t=(o=e.split("."))[1]),this.addNamespaces(t),Ne(this.data,o,s),i.silent||this.emit("added",e,t,n,s)}},{key:"addResources",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});s.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,s,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(s=n,n=t,t=(o=e.split("."))[1]),this.addNamespaces(t);var r=Le(this.data,o)||{};s?Ue(r,n,i):r=qe(qe({},r),n),Ne(this.data,o,r),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?qe(qe({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(),je={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,s,i){var a=this;return e.forEach(function(e){a.processors[e]&&(t=a.processors[e].process(t,n,s,i))}),t}};function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function We(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return ve(this,n)}}var ze={},$e=function(){me(t,De);var e=We(t);function t(n){var s,i,a,o,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return de(this,t),s=e.call(this),Ge&&De.call(_e(s)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],a=n,o=_e(s),i.forEach(function(e){a[e]&&(o[e]=a[e])}),s.options=r,void 0===s.options.keySeparator&&(s.options.keySeparator="."),s.logger=ke.create("translator"),s}return pe(t,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var s=Fe.filter(function(e){return t.indexOf(e)<0&&n.indexOf(e)<0});if(0===s.length)return!0;var i=new RegExp("(".concat(s.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),a=!i.test(e);if(!a){var o=e.indexOf(n);o>0&&!i.test(e.substring(0,o))&&(a=!0)}return a}(e,n,s));if(a&&!o){var r=e.match(this.interpolator.nestingRegexp);if(r&&r.length>0)return{key:e,namespaces:i};var c=e.split(n);(n!==s||n===s&&this.options.ns.indexOf(c[0])>-1)&&(i=c.shift()),e=c.join(s)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,n,s){var i=this;if("object"!==le(n)&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"===le(n)&&(n=Ye({},n)),n||(n={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=this.extractFromKey(e[e.length-1],n),c=r.key,u=r.namespaces,l=u[u.length-1],d=n.lng||this.language,h=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(h){var g=n.nsSeparator||this.options.nsSeparator;return a?{res:"".concat(l).concat(g).concat(c),usedKey:c,exactUsedKey:c,usedLng:d,usedNS:l}:"".concat(l).concat(g).concat(c)}return a?{res:c,usedKey:c,exactUsedKey:c,usedLng:d,usedNS:l}:c}var p=this.resolve(e,n),_=p&&p.res,f=p&&p.usedKey||c,m=p&&p.exactUsedKey||c,v=Object.prototype.toString.apply(_),y=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject;if(I&&_&&("string"!=typeof _&&"boolean"!=typeof _&&"number"!=typeof _)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(v)<0&&("string"!=typeof y||"[object Array]"!==v)){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,_,Ye(Ye({},n),{},{ns:u})):"key '".concat(c," (").concat(this.language,")' returned an object instead of string.");return a?(p.res=M,p):M}if(o){var C="[object Array]"===v,T=C?[]:{},S=C?m:f;for(var E in _)if(Object.prototype.hasOwnProperty.call(_,E)){var k="".concat(S).concat(o).concat(E);T[E]=this.translate(k,Ye(Ye({},n),{joinArrays:!1,ns:u})),T[E]===k&&(T[E]=_[E])}_=T}}else if(I&&"string"==typeof y&&"[object Array]"===v)(_=_.join(y))&&(_=this.extendTranslation(_,e,n,s));else{var D=!1,O=!1,R=void 0!==n.count&&"string"!=typeof n.count,A=t.hasDefaultValue(n),N=R?this.pluralResolver.getSuffix(d,n.count,n):"",L=n["defaultValue".concat(N)]||n.defaultValue;!this.isValidLookup(_)&&A&&(D=!0,_=L),this.isValidLookup(_)||(O=!0,_=c);var U=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&O?void 0:_,P=A&&L!==_&&this.options.updateMissing;if(O||D||P){if(this.logger.log(P?"updateKey":"missingKey",d,l,c,P?L:_),o){var w=this.resolve(c,Ye(Ye({},n),{},{keySeparator:!1}));w&&w.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var b=[],G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&G&&G[0])for(var F=0;F<G.length;F++)b.push(G[F]);else"all"===this.options.saveMissingTo?b=this.languageUtils.toResolveHierarchy(n.lng||this.language):b.push(n.lng||this.language);var x=function(e,t,s){var a=A&&s!==_?s:U;i.options.missingKeyHandler?i.options.missingKeyHandler(e,l,t,a,P,n):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,l,t,a,P,n),i.emit("missingKey",e,l,t,_)};this.options.saveMissing&&(this.options.saveMissingPlurals&&R?b.forEach(function(e){i.pluralResolver.getSuffixes(e,n).forEach(function(t){x([e],c+t,n["defaultValue".concat(t)]||L)})}):x(b,c,L))}_=this.extendTranslation(_,e,n,p,s),O&&_===c&&this.options.appendNamespaceToMissingKey&&(_="".concat(l,":").concat(c)),(O||D)&&this.options.parseMissingKeyHandler&&(_="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(l,":").concat(c):c,D?_:void 0):this.options.parseMissingKeyHandler(_))}return a?(p.res=_,p):_}},{key:"extendTranslation",value:function(e,t,n,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Ye(Ye({},this.options.interpolation.defaultVariables),n),s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Ye(Ye({},n),{interpolation:Ye(Ye({},this.options.interpolation),n.interpolation)}));var o,r="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(r){var c=e.match(this.interpolator.nestingRegexp);o=c&&c.length}var u=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(u=Ye(Ye({},this.options.interpolation.defaultVariables),u)),e=this.interpolator.interpolate(e,u,n.lng||this.language,n),r){var l=e.match(this.interpolator.nestingRegexp);o<(l&&l.length)&&(n.nest=!1)}!n.lng&&"v1"!==this.options.compatibilityAPI&&s&&s.res&&(n.lng=s.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return i&&i[0]===s[0]&&!n.context?(a.logger.warn("It seems you are nesting recursively key: ".concat(s[0]," in key: ").concat(t[0])),null):a.translate.apply(a,s.concat([t]))},n)),n.interpolation&&this.interpolator.reset()}var d=n.postProcess||this.options.postProcess,h="string"==typeof d?[d]:d;return null!=e&&h&&h.length&&!1!==n.applyPostProcessor&&(e=je.handle(h,e,t,this.options&&this.options.postProcessPassResolved?Ye({i18nResolved:s},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,s,i,a,o=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!o.isValidLookup(t)){var c=o.extractFromKey(e,r),u=c.key;n=u;var l=c.namespaces;o.options.fallbackNS&&(l=l.concat(o.options.fallbackNS));var d=void 0!==r.count&&"string"!=typeof r.count,h=d&&!r.ordinal&&0===r.count&&o.pluralResolver.shouldUseIntlApi(),g=void 0!==r.context&&("string"==typeof r.context||"number"==typeof r.context)&&""!==r.context,p=r.lngs?r.lngs:o.languageUtils.toResolveHierarchy(r.lng||o.language,r.fallbackLng);l.forEach(function(e){o.isValidLookup(t)||(a=e,!ze["".concat(p[0],"-").concat(e)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(a)&&(ze["".concat(p[0],"-").concat(e)]=!0,o.logger.warn('key "'.concat(n,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(a,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach(function(n){if(!o.isValidLookup(t)){i=n;var a,c=[u];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(c,u,n,e,r);else{var l;d&&(l=o.pluralResolver.getSuffix(n,r.count,r));var p="".concat(o.options.pluralSeparator,"zero");if(d&&(c.push(u+l),h&&c.push(u+p)),g){var _="".concat(u).concat(o.options.contextSeparator).concat(r.context);c.push(_),d&&(c.push(_+l),h&&c.push(_+p))}}for(;a=c.pop();)o.isValidLookup(t)||(s=a,t=o.getResource(n,e,a,r))}}))})}}),{res:t,usedKey:n,exactUsedKey:s,usedLng:i,usedNS:a}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,s):this.resourceStore.getResource(e,t,n,s)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,12)&&void 0!==e[n])return!0;return!1}}]),t}();function Je(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Xe=function(){function e(t){de(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ke.create("languageUtils")}return pe(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map(function(e){return e.toLowerCase()}):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Je(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=Je(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=Je(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach(function(e){if(!t){var s=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(s)||(t=s)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var s=n.getLanguagePartFromCode(e);if(n.isSupportedCode(s))return t=s;t=n.options.supportedLngs.find(function(e){return e===s?e:e.indexOf("-")<0&&s.indexOf("-")<0?void 0:0===e.indexOf(s)?e:void 0})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,s=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],a=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),s.forEach(function(e){i.indexOf(e)<0&&a(n.formatLanguageCode(e))}),i}}]),e}(),Ze=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Qe={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},et=["v1","v2","v3"],nt={zero:0,one:1,two:2,few:3,many:4,other:5};var st=function(){function e(t){var n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};de(this,e),this.languageUtils=t,this.options=s,this.logger=ke.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(n={},Ze.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:Qe[e.fc]}})}),n)}return pe(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(e,t){return nt[e]-nt[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):s.numbers.map(function(s){return t.getSuffix(e,s,n)}):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(t)):this.getSuffixRetroCompatible(s,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,s=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[s];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var a=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!et.includes(this.options.compatibilityJSON)}}]),e}();function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=function(e,t,n){var s=Le(e,n);return void 0!==s?s:Le(t,n)}(e,t,n);return!a&&i&&"string"==typeof n&&void 0===(a=xe(e,n,s))&&(a=xe(t,n,s)),a}var rt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};de(this,e),this.logger=ke.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return pe(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:be,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Pe(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Pe(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Pe(t.nestingPrefix):t.nestingPrefixEscaped||Pe("$t("),this.nestingSuffix=t.nestingSuffix?Pe(t.nestingSuffix):t.nestingSuffixEscaped||Pe(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,s){var i,a,o,r=this,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(r.formatSeparator)<0){var i=ot(t,c,e,r.options.keySeparator,r.options.ignoreJSONStructure);return r.alwaysFormat?r.format(i,void 0,n,at(at(at({},s),t),{},{interpolationkey:e})):i}var a=e.split(r.formatSeparator),o=a.shift().trim(),u=a.join(r.formatSeparator).trim();return r.format(ot(t,c,o,r.options.keySeparator,r.options.ignoreJSONStructure),u,n,at(at(at({},s),t),{},{interpolationkey:o}))};this.resetRegExp();var d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,h=s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return u(e)}},{regex:this.regexp,safeValue:function(e){return r.escapeValue?u(r.escape(e)):u(e)}}].forEach(function(t){for(o=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(a=l(n)))if("function"==typeof d){var c=d(e,i,s);a="string"==typeof c?c:""}else if(s&&Object.prototype.hasOwnProperty.call(s,n))a="";else{if(h){a=i[0];continue}r.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),a=""}else"string"==typeof a||r.useRawValueToEscape||(a=Re(a));var u=t.safeValue(a);if(e=e.replace(i[0],u),h?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++o>=r.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var n,s,i,a=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function r(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var s=e.split(new RegExp("".concat(n,"[ ]*{"))),a="{".concat(s[1]);e=s[0];var o=(a=this.interpolate(a,i)).match(/'/g),r=a.match(/"/g);(o&&o.length%2==0&&!r||r.length%2!=0)&&(a=a.replace(/'/g,'"'));try{i=JSON.parse(a),t&&(i=at(at({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(a)}return delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){var c=[];(i=(i=at({},o)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var u=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var l=n[1].split(this.formatSeparator).map(function(e){return e.trim()});n[1]=l.shift(),c=l,u=!0}if((s=t(r.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof s)return s;"string"!=typeof s&&(s=Re(s)),s||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),s=""),u&&(s=c.reduce(function(e,t){return a.format(e,t,o.lng,at(at({},o),{},{interpolationkey:n[1].trim()}))},s.trim())),e=e.replace(n[0],s),this.regexp.lastIndex=0}return e}}]),e}();function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function ut(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lt(e){var t={};return function(n,s,i){var a=s+JSON.stringify(i),o=t[a];return o||(o=e(s,i),t[a]=o),o(n)}}var dt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};de(this,e),this.logger=ke.create("formatter"),this.options=t,this.formats={number:lt(function(e,t){var n=new Intl.NumberFormat(e,ut({},t));return function(e){return n.format(e)}}),currency:lt(function(e,t){var n=new Intl.NumberFormat(e,ut(ut({},t),{},{style:"currency"}));return function(e){return n.format(e)}}),datetime:lt(function(e,t){var n=new Intl.DateTimeFormat(e,ut({},t));return function(e){return n.format(e)}}),relativetime:lt(function(e,t){var n=new Intl.RelativeTimeFormat(e,ut({},t));return function(e){return n.format(e,t.range||"day")}}),list:lt(function(e,t){var n=new Intl.ListFormat(e,ut({},t));return function(e){return n.format(e)}})},this.init(t)}return pe(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=lt(t)}},{key:"format",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce(function(e,t){var a=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var s=e.split("(");t=s[0].toLowerCase().trim();var i=s[1].substring(0,s[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(function(e){if(e){var t=Ce(e.split(":")),s=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[s.trim()]||(n[s.trim()]=i),"false"===i&&(n[s.trim()]=!1),"true"===i&&(n[s.trim()]=!0),isNaN(i)||(n[s.trim()]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}}(t),o=a.formatName,r=a.formatOptions;if(s.formats[o]){var c=e;try{var u=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},l=u.locale||u.lng||i.locale||i.lng||n;c=s.formats[o](e,l,ut(ut(ut({},r),i),u))}catch(e){s.logger.warn(e)}return c}return s.logger.warn("there was no format function for ".concat(o)),e},e)}}]),e}();function ht(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function gt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return ve(this,n)}}var _t=function(){me(t,De);var e=pt(t);function t(n,s,i){var a,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return de(this,t),a=e.call(this),Ge&&De.call(_e(a)),a.backend=n,a.store=s,a.services=i,a.languageUtils=i.languageUtils,a.options=o,a.logger=ke.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=o.maxParallelReads||10,a.readingCalls=0,a.maxRetries=o.maxRetries>=0?o.maxRetries:5,a.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(i,o.backend,o),a}return pe(t,[{key:"queueLoad",value:function(e,t,n,s){var i=this,a={},o={},r={},c={};return e.forEach(function(e){var s=!0;t.forEach(function(t){var r="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[r]=2:i.state[r]<0||(1===i.state[r]?void 0===o[r]&&(o[r]=!0):(i.state[r]=1,s=!1,void 0===o[r]&&(o[r]=!0),void 0===a[r]&&(a[r]=!0),void 0===c[t]&&(c[t]=!0)))}),s||(r[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(r),toLoadNamespaces:Object.keys(c)}}},{key:"loaded",value:function(e,t,n){var s=e.split("|"),i=s[0],a=s[1];t&&this.emit("failedLoading",i,a,t),n&&this.store.addResourceBundle(i,a,n),this.state[e]=t?-1:2;var o={};this.queue.forEach(function(n){var s,r,c,u,l,d;s=n.loaded,r=a,u=Ae(s,[i],Object),l=u.obj,d=u.k,l[d]=l[d]||[],c&&(l[d]=l[d].concat(r)),c||l[d].push(r),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(function(e){o[e]||(o[e]={});var t=n.loaded[e];t.length&&t.forEach(function(t){void 0===o[e][t]&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:a,callback:o});else{this.readingCalls++;var r=function(r,c){if(s.readingCalls--,s.waitingReads.length>0){var u=s.waitingReads.shift();s.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}r&&c&&i<s.maxRetries?setTimeout(function(){s.read.call(s,e,t,n,i+1,2*a,o)},a):o(r,c)},c=this.backend[n].bind(this.backend);if(2!==c.length)return c(e,t,r);try{var u=c(e,t);u&&"function"==typeof u.then?u.then(function(e){return r(null,e)}).catch(r):r(null,u)}catch(e){r(e)}}}},{key:"prepareLoading",value:function(e,t){var n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var a=this.queueLoad(e,t,s,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(function(e){n.loadOne(e)})}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("|"),i=s[0],a=s[1];this.read(i,a,"read",void 0,void 0,function(s,o){s&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(i," failed"),s),!s&&o&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(i),o),t.loaded(e,s,o)})}},{key:"saveMissing",value:function(e,t,n,s,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(null!=n&&""!==n){if(this.backend&&this.backend.create){var r=gt(gt({},a),{},{isUpdate:i}),c=this.backend.create.bind(this.backend);if(c.length<6)try{var u;(u=5===c.length?c(e,t,n,s,r):c(e,t,n,s))&&"function"==typeof u.then?u.then(function(e){return o(null,e)}).catch(o):o(null,u)}catch(e){o(e)}else c(e,t,n,s,o,r)}e&&e[0]&&this.store.addResource(e[0],t,n,s)}}}]),t}();function ft(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===le(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===le(e[2])||"object"===le(e[3])){var n=e[3]||e[2];Object.keys(n).forEach(function(e){t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,s){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function mt(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vt(Object(n),!0).forEach(function(t){Ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function It(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,s=ye(e);if(t){var i=ye(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return ve(this,n)}}function Mt(){}var Ct=function(){me(t,De);var e=It(t);function t(){var n,s,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;if(de(this,t),n=e.call(this),Ge&&De.call(_e(n)),n.options=mt(i),n.services={},n.logger=ke,n.modules={external:[]},s=_e(n),Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(function(e){"function"==typeof s[e]&&(s[e]=s[e].bind(s))}),a&&!n.isInitialized&&!i.isClone){if(!n.options.initImmediate)return n.init(i,a),ve(n,_e(n));setTimeout(function(){n.init(i,a)},0)}return n}return pe(t,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var s=ft();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=yt(yt(yt({},s),this.options),mt(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=yt(yt({},s.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var a;this.modules.logger?ke.init(i(this.modules.logger),this.options):ke.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=dt);var o=new Xe(this.options);this.store=new He(this.options.resources,this.options);var r=this.services;r.logger=ke,r.resourceStore=this.store,r.languageUtils=o,r.pluralResolver=new st(o,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!a||this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format||(r.formatter=i(a),r.formatter.init(r,this.options),this.options.interpolation.format=r.formatter.format.bind(r.formatter)),r.interpolator=new rt(this.options),r.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},r.backendConnector=new _t(i(this.modules.backend),r.resourceStore,r,this.options),r.backendConnector.on("*",function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))}),this.modules.languageDetector&&(r.languageDetector=i(this.modules.languageDetector),r.languageDetector.init&&r.languageDetector.init(r,this.options.detection,this.options)),this.modules.i18nFormat&&(r.i18nFormat=i(this.modules.i18nFormat),r.i18nFormat.init&&r.i18nFormat.init(this)),this.translator=new $e(this.services,this.options),this.translator.on("*",function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,n||(n=Mt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&"dev"!==c[0]&&(this.options.lng=c[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}});var u=Oe(),l=function(){var t=function(t,s){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),u.resolve(s),n(t,s)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?l():setTimeout(l,0),u}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,s="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase())return n();var i=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){i.indexOf(e)<0&&i.push(e)})};if(s)a(s);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return a(e)});this.options.preload&&this.options.preload.forEach(function(e){return a(e)}),this.services.backendConnector.load(i,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,n){var s=Oe();return e||(e=this.languages),t||(t=this.options.ns),n||(n=Mt),this.services.backendConnector.reload(e,t,function(e){s.resolve(),n(e)}),s}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&je.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var s=Oe();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},a=function(a){e||a||!n.services.languageDetector||(a=[]);var o="string"==typeof a?a:n.services.languageUtils.getBestMatchFromCodes(a);o&&(n.language||i(o),n.translator.language||n.translator.changeLanguage(o),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage&&n.services.languageDetector.cacheUserLanguage(o)),n.loadResources(o,function(e){!function(e,a){a?(i(a),n.translator.changeLanguage(a),n.isLanguageChangingTo=void 0,n.emit("languageChanged",a),n.logger.log("languageChanged",a)):n.isLanguageChangingTo=void 0,s.resolve(function(){return n.t.apply(n,arguments)}),t&&t(e,function(){return n.t.apply(n,arguments)})}(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),s}},{key:"getFixedT",value:function(e,t,n){var s=this,i=function e(t,i){var a;if("object"!==le(i)){for(var o=arguments.length,r=new Array(o>2?o-2:0),c=2;c<o;c++)r[c-2]=arguments[c];a=s.options.overloadTranslationOptionHandler([t,i].concat(r))}else a=yt({},i);a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns,a.keyPrefix=a.keyPrefix||n||e.keyPrefix;var u,l=s.options.keySeparator||".";return u=a.keyPrefix&&Array.isArray(t)?t.map(function(e){return"".concat(a.keyPrefix).concat(l).concat(e)}):a.keyPrefix?"".concat(a.keyPrefix).concat(l).concat(t):t,s.t(u,a)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var s=n.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;var o=function(e,n){var s=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===s||2===s};if(n.precheck){var r=n.precheck(this,o);if(void 0!==r)return r}return!!this.hasResourceBundle(s,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,e)||i&&!o(a,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,s=Oe();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)}),this.loadResources(function(e){s.resolve(),t&&t(e)}),s):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=Oe();"string"==typeof e&&(e=[e]);var s=this.options.preload||[],i=e.filter(function(e){return s.indexOf(e)<0});return i.length?(this.options.preload=s.concat(i),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new Xe(ft());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Mt,i=yt(yt(yt({},this.options),n),{isClone:!0}),a=new t(i);void 0===n.debug&&void 0===n.prefix||(a.logger=a.logger.clone(n));return["store","services","language"].forEach(function(t){a[t]=e[t]}),a.services=yt({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new $e(a.services,a.options),a.translator.on("*",function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];a.emit.apply(a,[e].concat(n))}),a.init(i,s),a.translator.options=a.options,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),t}();Ie(Ct,"createInstance",function(){return new Ct(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)});var Tt=Ct.createInstance();Tt.createInstance=Ct.createInstance,Tt.createInstance,Tt.dir,Tt.init,Tt.loadResources,Tt.reloadResources,Tt.use,Tt.changeLanguage,Tt.getFixedT,Tt.t,Tt.exists,Tt.setDefaultNamespace,Tt.hasLoadedNamespace,Tt.loadNamespaces,Tt.loadLanguages;class St extends te{constructor(){super(),this.languages=null,this.keyMap={}}static getInstance(){return St.instance||(St.instance=new St),St.instance}provideLanguages(e){var t;F||(this.languages=e,(null===(t=e["zh-CN"])||void 0===t?void 0:t.Chat)&&this.setKeyMap(e["zh-CN"]),console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){var t;if(F)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const n={};for(const[e,t]of Object.entries(this.languages)){n["zh_cn"===e?"zh":e]={translation:t}}Tt.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:n});let s=this.normalizeLanguageKey(e||"zh");null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(201,s)}changeLanguage(e){let t=this.normalizeLanguageKey(e);return this.getEngine().TUIReport.reportFeature(201,t),Tt.changeLanguage(e)}normalizeLanguageKey(e){return e.includes("en")?"en-us":e.includes("tw")?"zh-tw":e.includes("zh")||e.includes("cn")?"zh-cn":e.includes("ko")||e.includes("kr")?"ko-kr":e.includes("ja")||e.includes("jp")?"ja-jp":"other-"+e}t(e){if(!this.languages){let t=e;return!M(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}const t=this.keyMap[e];return t?Tt.t(t):Tt.t(e)}setKeyMap(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=t?`${t}.${n}`:n;if(e[n]&&"object"==typeof e[n]&&!Array.isArray(e[n])&&null!==e[n])this.setKeyMap(e[n],s);else{let s=t?`${t}.${e[n]}`:e[n];s=this.replaceKey(s),this.keyMap[s]=`${t}.${n}`}}}replaceKey(e){return e.startsWith("Chat")?e.replace("Chat","TUIChat"):e.startsWith("Conversation")?e.replace("Conversation","TUIConversation"):e.startsWith("Message")?e.replace("Message","message.tip"):e.startsWith("Call")?e.replace("Call","message.custom"):e}}class Et extends te{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return Et.instance||(Et.instance=new Et),Et.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalUnreadCountUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getConversationInitData()}onConversationListUpdated(e){const t=this.filterSystemConversation(e);this.getEngine().TUIStore.update(o.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(o.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");let s=!1;for(let i=0;i<e.length;i++){if(e[i].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:a}=e[i].payload,r=`GROUP${e[i].to}`,c=4===a||5===a||8===a,u=2===a||6===a||7===a;if(c||u)for(let e=0;e<n.length;e++)if(n[e].type!==t.TYPES.CONV_C2C&&n[e].conversationID===r){if(c){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:r,operationType:a}),s=!0;break}if(u&&n[e].operationType>0){this.getEngine().TUIStore.update(o.CONV,"operationTypeMap",{conversationID:r,operationType:0}),s=!0;break}}}if(s){this.getEngine().TUIStore.update(o.CONV,"conversationList",n);const e=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID")||"",t=this.findConversation(e);t&&this.getEngine().TUIStore.update(o.CONV,"currentConversation",t)}}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then(t=>{const{conversationList:n,isSyncCompleted:s}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${n.length} isSyncCompleted:${s}`),n.length>0){this.onConversationListUpdated(n);const t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}})}switchConversation(e){return n(this,void 0,void 0,function*(){const t=`${this.serv}.switchConversation`,n=this.getEngine();if(!e)return n.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(o.CONV,"currentConversationID",""),n.TUIStore.update(o.CONV,"currentConversation",null),console.log(`${t} conversationID is empty, conversationID:${e}`),Promise.resolve({});if(!e.startsWith(n.TYPES.CONV_C2C)&&!e.startsWith(n.TYPES.CONV_GROUP))return console.warn(`${t} conversationID is invalid, conversationID:${e}`),Promise.reject({code:d.INVALID_CONV_ID,message:g.INVALID_CONV_ID});const s=n.TUIStore.getData(o.CONV,"currentConversationID");if(s&&s===e)return this.setMessageRead(s),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:d.CONV_ID_SAME,message:g.CONV_ID_SAME});const i=yield this.getConversationModel(e);return M(i)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:d.CONV_NOT_EXIST,message:g.CONV_NOT_EXIST})):(s&&this.setMessageRead(s),e&&this.setMessageRead(e),n.TUIStore.reset(o.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(o.CONV,"currentConversationID",e),n.TUIStore.update(o.CONV,"currentConversation",i),Promise.resolve(i))})}getConversationModel(e){return n(this,void 0,void 0,function*(){let t=this.findConversation(e);if(M(t))try{const n=yield this.getConversationProfile(e);n.data&&n.data.conversation&&(t=new ie(n.data.conversation))}catch(e){t=void 0}return t})}findConversation(e){let t;const n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let s=0;s<n.length;s++)if(n[s].conversationID===e){t=n[s];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"currentConversationID"),n=this.findConversation(t);n&&e.TUIStore.update(o.CONV,"currentConversation",n)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){return this.getEngine().chat.deleteConversation(e).then(t=>{const n=this.getEngine().TUIStore.getData(o.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${n}`),e===n&&(this.getEngine().TUIStore.update(o.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(o.CONV,"currentConversation",null)),t})}pinConversation(e){return this.getEngine().chat.pinConversation(e)}muteConversation(e){return this.getEngine().chat.setMessageRemindType(e)}clearHistoryMessage(e){return this.getEngine().chat.clearHistoryMessage(e).then(e=>(this.getEngine().TUIStore.update(o.CHAT,"messageList",[]),this.getEngine().TUIStore.update(o.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(o.CHAT,"isCompleted",!0),e))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}setConversationDraft(e){const{conversationID:t,draftInfo:n}=e;let s="";return n&&(s=JSON.stringify(n)),this.getEngine().chat.setConversationDraft({conversationID:t,draftText:s}).then(e=>{const{conversation:t}=e.data;this.updateConversation(t)})}updateConversation(e){let t=!1;const n=this.getEngine().TUIStore.getData(o.CONV,"conversationList");for(let s=0;s<n.length;s++)if(n[s].conversationID===e.conversationID){n[s]=e,t=!0;break}t&&this.getEngine().TUIStore.update(o.CONV,"conversationList",n)}filterSystemConversation(e){return e.filter(e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM)}}class kt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(e){const t=this.getEngine(),n=t.TUIStore.getData(o.USER,"userProfile");e.forEach(e=>{e.userID===n.userID&&t.TUIStore.update(o.USER,"userProfile",e)})}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then(e=>{t.TUIStore.update(o.USER,"userBlacklist",e)})}getUserProfileInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getBlacklist&&e.chat.getBlacklist().then(e=>{const t=e.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${t.length}`),t.length>0&&this.onBlacklistUpdated(t)})}getBlacklistProfile(e){const t=[];let n=0;for(;n<e.length;)t.push(e.slice(n,n+=100));const s=[];t.forEach(e=>{s.push(this.TUIUserService.getUserProfile({userIDList:e}))});const i=[];return Promise.all(s).then(e=>(e.forEach(e=>{const t=e.data.map(e=>{const{userID:t,nick:n,avatar:s}=e;return{userID:t,nick:n,avatar:s}});i.push(...t)}),i))}getUserProfile(e){const t=this.getEngine();return M(e)?t.chat.getMyProfile().then(e=>(t.TUIStore.update(o.USER,"userProfile",e.data),e)).catch(e=>Promise.reject(e)):t.chat.getUserProfile(e)}updateMyProfile(e){return this.getEngine().chat.updateMyProfile(e)}addToBlacklist(e){return this.getEngine().chat.addToBlacklist(e)}removeFromBlacklist(e){return this.getEngine().chat.removeFromBlacklist(e)}}function Dt(e,t,n=!0){!function(e,t){V?H.setStorageSync(e,t):At()&&localStorage.setItem(e,JSON.stringify(t))}(n?Rt(e):e,t)}function Ot(e,t=!0){try{return function(e){if(V)return H.getStorageSync(e);if(At()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?Rt(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function Rt(e){return`chat_engine_${e}`}function At(){return navigator&&navigator.cookieEnabled&&localStorage}class Nt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=Ot("displayOnlineStatus")||!1;e.TUIStore.update(o.USER,"displayOnlineStatus",t),e.eventCenter.addEvent(e.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated.bind(this)),this.onConversationListUpdated()}onConversationListUpdated(){const e=this.getEngine();e.TUIStore.watch(o.CONV,{conversationList:()=>{const t=e.TUIStore.getData(o.APP,"enabledOnlineStatus"),n=e.TUIStore.getData(o.USER,"displayOnlineStatus");t&&n&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(o.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:n=!1}=e;t.TUIStore.update(o.USER,"displayOnlineStatus",n),Dt("displayOnlineStatus",n);const s=t.TUIStore.getData(o.APP,"enabledOnlineStatus");s?!0===n?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${s} displayOnlineStatus:${n}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then(e=>{const{successUserList:n}=e.data;return n.length>0&&t.TUIStore.update(o.USER,"userStatusList",n),e}).catch(e=>Promise.reject(e))}subscribeUserStatus(e){var t;const n=(null===(t=null==e?void 0:e.userIDList)||void 0===t?void 0:t.length)||0;return 0===n?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${n}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(e)}unsubscribeUserStatus(e){const t=this.getEngine(),{userIDList:n=[]}=e||{};return t.chat.unsubscribeUserStatus({userIDList:n}).then(e=>{const{failureUserList:s}=e.data,i=[];return n.forEach(e=>{s.includes(e)||i.push({userID:e,statusType:r.UNSUB_USER})}),t.TUIStore.update(o.USER,"userStatusList",i),e}).catch(e=>Promise.reject(e))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(o.CONV,"conversationList"),n=e.TUIStore.getData(o.USER,"userStatusList"),s=[];t.forEach(t=>{if(t.type===e.TYPES.CONV_C2C){const i=t.conversationID.replace(e.TYPES.CONV_C2C,"");n.has(i)||s.push(i)}}),0!==s.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:s}),this.getUserStatus({userIDList:s}))}}class Lt extends te{constructor(){super(),this.userProfileHandler=new kt(this),this.userStatusHandler=new Nt(this)}static getInstance(){return Lt.instance||(Lt.instance=new Lt),Lt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.KICKED_OUT,this.onKickedOut.bind(this)),e.eventCenter.addEvent(e.EVENT.NET_STATE_CHANGE,this.onNetStateChange.bind(this)),this.userProfileHandler.init(),this.userStatusHandler.init(),this.initMessageReadReceipt()}onKickedOut(e){this.getEngine().TUIStore.update(o.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(o.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=Ot("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(o.USER,"displayMessageReadReceipt",e),Dt("displayMessageReadReceipt",e)}getUserProfile(e){return this.userProfileHandler.getUserProfile(e)}updateMyProfile(e){return this.userProfileHandler.updateMyProfile(e)}addToBlacklist(e){return this.userProfileHandler.addToBlacklist(e)}removeFromBlacklist(e){return this.userProfileHandler.removeFromBlacklist(e)}getUserStatus(e){return this.userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this.userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this.userStatusHandler.unsubscribeUserStatus(e)}}class Ut{constructor(e){this.TUIChatService=e,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(e){return this.getEngine().TUITranslate.t(e)}handleTextMessage(e){return{text:this.decodeText(e.payload)}}handleFaceMessage(e){const t={name:"",url:"",type:""};return e.payload.data.indexOf("@custom")>-1?(t.name=e.payload.data,t.type="custom",t):(t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${A}${t.name}.png`,t)}handleLocationMessage(e){const t={lon:"",lat:"",href:"",url:"",description:""};return t.lon=e.payload.longitude.toFixed(6),t.lat=e.payload.latitude.toFixed(6),t.href=`${N}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${L}center=${t.lat},${t.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${t.lat},${t.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`,t.description=e.payload.description,t}handleImageMessage(e){return{url:e.payload.imageInfoArray[0].url,width:e.payload.imageInfoArray[0].width,height:e.payload.imageInfoArray[0].height}}handleAudioMessage(e){return{url:e.payload.url,second:e.payload.second}}handleVideoMessage(e){return{url:e.payload.videoUrl,snapshotUrl:e.payload.snapshotUrl,snapshotWidth:e.payload.snapshotWidth,snapshotHeight:e.payload.snapshotHeight}}handleFileMessage(e){return{url:e.payload.fileUrl,name:e.payload.fileName,size:E(e.payload.fileSize)}}handleCustomMessage(e){var t;const n=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||n||(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.extension)||`${this.t("TUIChat.[自定义消息]")}`,businessID:n?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,n,s,i,a,o;const r=this.getEngine(),c={text:""};let u=(null==e?void 0:e.nick)||(null===(n=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.userIDList)||void 0===n?void 0:n.join(","));switch((null===(i=null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.memberList)||void 0===i?void 0:i.length)>0&&(u="",null===(o=null===(a=null==e?void 0:e.payload)||void 0===a?void 0:a.memberList)||void 0===o||o.map(e=>{const t=(null==e?void 0:e.nick)||(null==e?void 0:e.userID);u+=`${this.substringByLength(t)},`}),u=null==u?void 0:u.slice(0,-1)),e.payload.operationType){case r.TYPES.GRP_TIP_MBR_JOIN:c.text=`${u} ${this.t("message.tip.加入群组")}`;break;case r.TYPES.GRP_TIP_MBR_QUIT:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.退出群组")}`;break;case r.TYPES.GRP_TIP_MBR_KICKED_OUT:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case r.TYPES.GRP_TIP_MBR_SET_ADMIN:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.成为管理员")}`;break;case r.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被撤销管理员")}`;break;case r.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:c.text=this.handleGroupProfileUpdated(e);break;case r.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被禁言")}`:c.text=`${this.t("message.tip.群成员")}:${u} ${this.t("message.tip.被取消禁言")}`;break;default:c.text=`[${this.t("message.tip.群提示消息")}]`}return c}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,n={text:""};switch(e.payload.operationType){case 1:n.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${t}`;break;case 2:n.text=`${this.t("message.tip.成功加入群组")}:${t}`;break;case 3:n.text=`${this.t("message.tip.申请加入群组")}:${t} ${this.t("message.tip.被拒绝")}`;break;case 4:n.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}:${t}`;break;case 5:n.text=`${this.t("message.tip.群")}:${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:n.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}:${t}`;break;case 7:case 12:n.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${t}`;break;case 8:n.text=`${this.t("message.tip.你退出群组")}:${t}`;break;case 9:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}:${t} ${this.t("message.tip.的管理员")}`;break;case 10:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}:${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:n.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}:${t}`;break;case 14:n.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}:${t}`;break;case 255:n.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:n.text="未解析的群系统通知"}return n}handleCallKitSignaling(e){var t,n,s,i,a,o,r,c,u,l;const d=S(e.payload.data);if(1!==(null==d?void 0:d.businessID))return"";const h=S(null==d?void 0:d.data),g=e.fromAccount||e.from,p=this.getEngine().getMyUserID();let _=e.nick||g;switch(_=this.substringByLength(_),null==d?void 0:d.actionType){case 1:return"audioCall"!==(null===(t=null==h?void 0:h.data)||void 0===t?void 0:t.cmd)&&"videoCall"!==(null===(n=null==h?void 0:h.data)||void 0===n?void 0:n.cmd)||!(null==d?void 0:d.groupID)?"hangup"===(null===(s=null==h?void 0:h.data)||void 0===s?void 0:s.cmd)?(null==d?void 0:d.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let n,s,i,a="";return t>=3600?(n=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),s=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),i=t%3600<10?"0"+t%3600:t%3600,i>60&&(s=parseInt(""+i/60,10)<10?`0${parseInt(""+i/60,10)}`:parseInt(""+i/60,10),i=i%60<10?"0"+i%60:i%60),a=`${n}:${s}:${i}`):t>=60&&t<3600?(s=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),i=t%60<10?"0"+t%60:t%60,a=`00:${s}:${i}`):t<60&&(i=t<10?`0${t}`:t,a=`00:00:${i}`),a}(null==h?void 0:h.call_end)}`:"switchToAudio"===(null===(i=null==h?void 0:h.data)||void 0===i?void 0:i.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(a=null==h?void 0:h.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${_} ${this.t("message.custom.发起通话")}`;case 2:return(null==d?void 0:d.groupID)?`${_} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(null==d?void 0:d.inviter)===p?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return"switchToAudio"===(null===(o=null==h?void 0:h.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(r=null==h?void 0:h.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==d?void 0:d.groupID)?`${_} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==d?void 0:d.groupID)?`${_} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):"line_busy"===(null==h?void 0:h.line_busy)||"lineBusy"===(null==h?void 0:h.data.message)?(null==d?void 0:d.inviter)===p?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(null==d?void 0:d.inviter)===p?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if("switchToAudio"===(null===(c=null==h?void 0:h.data)||void 0===c?void 0:c.cmd))return`${this.t("message.custom.切换语音通话")}`;if("switchToVideo"===(null===(u=null==h?void 0:h.data)||void 0===u?void 0:u.cmd))return`${this.t("message.custom.切换视频通话")}`;if(null==d?void 0:d.groupID){if(g===(null==d?void 0:d.inviter)){this.handleCallkitTimeoutSignaling(d.inviteeList);let e="";return null===(l=d.inviteeList)||void 0===l||l.forEach(t=>{const n=this.userShowNameMap.get(t)||t;e+=`${this.substringByLength(n)}、`}),e=e.substring(0,e.lastIndexOf("、")),`${e} ${this.t("message.custom.无应答")}`}return`${_} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(null==d?void 0:d.inviter)===p?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleStreamMessage(e){return{}}handleCreateGroupCustomMessage(e){let t;const n=S(e.payload.data);return"group_create"===(null==n?void 0:n.businessID)&&(t=`${n.opUser} ${n.content}`),t}decodeText(e){const t=[];let n=e.text,s=-1,i=-1;for(;""!==n;)switch(s=n.indexOf("["),i=n.indexOf("]"),s){case 0:if(-1===i)t.push({name:"text",text:n}),n="";else{const e=n.slice(0,i+1);e.indexOf("@custom")>-1?(t.push({name:"img",src:"",type:"custom",emojiKey:e}),n=n.substring(i+1)):U[e]?(t.push({name:"img",src:R+U[e],emojiKey:e}),n=n.substring(i+1)):(t.push({name:"text",text:"["}),n=n.slice(1))}break;case-1:t.push({name:"text",text:n}),n="";break;default:t.push({name:"text",text:n.slice(0,s)}),n=n.substring(s)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:n}=e,{newGroupProfile:s,memberList:i,operatorID:a}=n;let o="";const r=t||a,c=Object.keys(s)[0];switch(c){case"muteAllMembers":o=s[c]?`${this.t("message.tip.管理员")} ${r} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${r} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":o=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":o=`${r} ${this.t("message.tip.修改群名为")} ${s[c]}`;break;case"notification":o=this.isOldUIKit("message.tip.把群公告修改为")?`${r} ${this.t("message.tip.发布新公告")}`:`${r} ${this.t("message.tip.把群公告修改为")} "${s[c]}"`}return o}handleCallkitTimeoutSignaling(e=[]){if(0===e.length)return;const t=[];e.forEach(e=>{this.requestedUserMap.has(e)||(t.push(e),this.requestedUserMap.set(e,1))}),t.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:t}).then(e=>{(e.data||[]).forEach(e=>{const{userID:t,nick:n}=e,s=n||t;this.userShowNameMap.set(t,s)})}).catch(e=>{})}substringByLength(e,t=12){return e.length>t?`${e.slice(0,t)}...`:e}isOldUIKit(e){var t;const n=e.lastIndexOf("."),s=e.slice(0,n+1);return null===(t=this.t(e))||void 0===t?void 0:t.startsWith(s)}}class Pt{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(o.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(o.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),n=t.TUIStore.getData(o.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const s=S(e.payload.data);if(s.businessID===c.BUSINESS_ID){const{typingStatus:e,userAction:i}=s;if(e===c.STATUS_START||i===c.ACTION_START_ID)return n?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(o.CHAT,"typingStatus",!0),this.timer=setTimeout(()=>{this.clearTypingStatus()},3e4),t.TUIStore.getData(o.CHAT,"typingStatus");e!==c.STATUS_END&&i!==c.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(o.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter(e=>{if(e.type===this.getEngine().TYPES.MSG_CUSTOM){return S(e.payload.data).businessID!==c.BUSINESS_ID}return!0})}createTypingMessage(e=c.STATUS_END,t=""){const{BUSINESS_ID:n,STATUS_START:s,VERSION:i,ACTION_START_ID:a,ACTION_END_ID:o,ACTION_START:r,ACTION_END:u,NEED_TYPING:l}=c;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:n,typingStatus:e,version:i,userAction:e===s?a:o,actionParam:e===s?r:u}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:l,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(c.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(c.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class wt{constructor(e){this.TUIChatService=e}getEngine(){return this.TUIChatService.getEngine()}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived.bind(this))}onMessageReadReceiptReceived(e){const t=this.getEngine(),n=t.TUIStore.getData(o.CONV,"currentConversationID"),s=[];e.forEach(e=>{const{messageID:i}=e,a=t.chat.findMessage(i);a&&n===a.conversationID&&s.push(a)}),s.length>0&&t.TUIChat.updateMessageList(s,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach(e=>{const n=e.getMessage();t.push(n)}),this.getEngine().chat.sendMessageReadReceipt(t)}getGroupMessageReadMemberList(e){const t=e.message.getMessage(),n=Object.assign(Object.assign({},e),{message:t});return this.getEngine().chat.getGroupMessageReadMemberList(n)}getMessageReadReceiptList(e){const t=this.getEngine(),n=t.TUIStore.getData(o.APP,"enabledMessageReadReceipt"),s=t.TUIStore.getData(o.USER,"displayMessageReadReceipt");!n||!s||0===e.length||e[0].conversationType!==t.TYPES.CONV_GROUP||t.chat.getMessageReadReceiptList(e).then(e=>{const{messageList:t}=e.data;this.TUIChatService.updateMessageList(t,"edit")}).catch(e=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${e.message}`)})}}class bt extends te{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new Ut(this),this.typingHandler=new Pt(this),this.readReceiptHandler=new wt(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map,this.bindConversationIDWatcher=this.conversationIDWatcher.bind(this),this.bindMessageSourceWatcher=this.messageSourceWatcher.bind(this)}static getInstance(){return bt.instance||(bt.instance=new bt),bt.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"received"),this.getEngine().TUIStore.update(o.CHAT,"newMessageList",e)}onMessageModified(e){this.updateMessageList(e,"edit")}onMessageRevoked(e){this.updateMessageList(e,"edit")}onMessageReadByPeer(e){this.updateMessageList(e,"edit")}onMessageReactionsUpdated(e){this.updateMessageReactionList([e])}onCurrentConversationIDUpdated(){const e=this.getEngine();e.TUIStore.unwatch(o.CONV,{currentConversationID:this.bindConversationIDWatcher}),e.TUIStore.watch(o.CONV,{currentConversationID:this.bindConversationIDWatcher})}conversationIDWatcher(e){this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),this.getEngine().TUIStore.reset(o.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),ne(e)||this.getMessageList().finally(()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()})}onMessageSource(){const e=this.getEngine();e.TUIStore.unwatch(o.CHAT,{messageSource:this.bindMessageSourceWatcher}),e.TUIStore.watch(o.CHAT,{messageSource:this.bindMessageSourceWatcher})}messageSourceWatcher(e){const t=this.getEngine(),n=this.getStoreData(o.CONV,"currentConversationID");if(!n||e&&e.conversationID!==n)return;if(M(e))return this.hoppingConfigMap.clear(),t.TUIStore.update(o.CHAT,"messageList",[]),t.TUIStore.update(o.CHAT,"nextReqMessageID",""),t.TUIStore.update(o.CHAT,"isCompleted",!1),void this.getMessageList();const s=this.getStoreData(o.CHAT,"messageList");s&&s.find(t=>e&&t.ID===e.ID)||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}getMessageListHoppingForDown(){const e=this.getStoreData(o.CHAT,"messageList"),{conversationID:t,sequence:n,time:s,ID:i}=this.getStoreData(o.CHAT,"messageSource");if(e&&e.find(e=>i&&e.ID===i))return;const a=this.getEngine();a.TUIStore.update(o.CHAT,"messageList",[]),a.TUIStore.update(o.CHAT,"nextReqMessageID",""),a.TUIStore.update(o.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:n,time:s,direction:1})}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}sendMessage(e,t){this.updateMessageList([e],"send");const n=this.getEngine().chat.sendMessage(e,t);return this.getResponse(n)}getResponse(e,t=!0,n=!0){return e.then(e=>{const n=e.data.messageList?e.data.messageList:[e.data.message];return t&&this.updateMessageList(n,"edit"),e}).catch(e=>{var t;return n&&(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)&&this.updateMessageList([e.data.message],"edit"),Promise.reject(e)})}updateMessageList(e,t=""){if(this.getStoreData(o.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const n=this.getStoreData(o.CHAT,"messageList"),s=this.updateTargetMessageList(e,n,t);this.getEngine().TUIStore.update(o.CHAT,"messageList",s)}updateTargetMessageList(e,t,n=""){const s=this.getStoreData(o.CONV,"currentConversationID");let i=e.filter(e=>e.conversationID===s);if(!n||0===i.length)return t;const a=t||[];let r=[];if("send"===n||"push"===n){const e=this.getStoreData(o.CHAT,"userInfo");Object.keys(e).length>0&&this.updateLocalMessage(i,e)}switch(n){case"edit":for(const e of t){const t=i.find(t=>t.ID===e.ID);r.push(t||e)}break;case"resend":r=a.filter(e=>e.ID!==i[0].ID).concat(i);break;case"send":r=a.concat(this.typingHandler.filterTypingMessage(i));break;case"push":r=a.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:s});break;case"received":r=a.concat(this.typingHandler.filterTypingMessage(i)),r=this.sortMessageList(r),this.getEngine().chat.setMessageRead({conversationID:s});break;case"unshift":r=i.filter(e=>0===a.length||!a.find(t=>t.ID===e.ID)),r.push(...a),r=this.sortMessageList(r)}return r}enterTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(o.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),n=this.getStoreData(o.CONV,"currentConversationID");if(!n.startsWith(t.TYPES.CONV_C2C))return;const s=n.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(o.CHAT,"messageList").filter(e=>"in"===e.flow);if(0===e.length)return;const t=1e3*e[e.length-1].time;if((new Date).getTime()-t>3e4)return}this.typingHandler.sendTyping(e,s)}quoteMessage(e){var t;return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"quote"}),null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(205),e}replyMessage(e){return this.getEngine().TUIStore.update(o.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(o.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t,n;const s=this.getEngine(),i={abstract:"",type:0};switch(e.type){case s.TYPES.MSG_TEXT:i.abstract=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text,i.type=1;break;case s.TYPES.MSG_CUSTOM:i.abstract="[自定义消息]",i.type=2;break;case s.TYPES.MSG_IMAGE:i.abstract="[图片]",i.type=3;break;case s.TYPES.MSG_AUDIO:i.abstract="[语音]",i.type=4;break;case s.TYPES.MSG_VIDEO:i.abstract="[视频]",i.type=5;break;case s.TYPES.MSG_FILE:i.abstract="[文件]",i.type=6;break;case s.TYPES.MSG_LOCATION:i.type=7;break;case s.TYPES.MSG_FACE:i.abstract="[表情]",i.type=8;break;case s.TYPES.MSG_GRP_TIP:i.type=9;break;case s.TYPES.MSG_MERGER:i.abstract=null===(n=null==e?void 0:e.payload)||void 0===n?void 0:n.title,i.type=10}return i}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:n,type:s}=this.getMessageAbstractAndType(e),i={messageAbstract:n,messageSender:e.nick||e.from,messageID:e.ID},a=Object.assign(Object.assign({},i),{messageType:s,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(a.messageRootID=e.ID,e.cloudCustomData)){const t=S(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(a.messageRootID=t.messageReply.messageRootID)}return{messageReply:a,messageReplyRoot:i}}getMessageInfo(e,t,n){const{messageReply:s,messageReplyRoot:i}=this.genMessageReply(t,n),a=e.cloudCustomData?S(e.cloudCustomData):{};let o;if(a.messageReply?a.messageReply=Object.assign(Object.assign({},s),a.messageReply):a.messageReply=s,"reply"===n){const{messageRootID:e}=s;o=this.getEngine().chat.findMessage(e);const t=(null==o?void 0:o.cloudCustomData)?S(o.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),r=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(r):"array"===Object.prototype.toString.call(r).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(i),o.cloudCustomData=JSON.stringify(t)}var r;return{cloudCustomData:JSON.stringify(a),rootMessage:o}}sendTextMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(a=this.getMessageInfo(e,s,i));const r=n.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then(e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),n.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e))}sendTextAtMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(o.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(a=this.getMessageInfo(e,s,i));const r=n.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then(e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),n.TUIStore.reset(o.CHAT,["quoteMessage"],!0),e))}sendImageMessage(e,t){const n=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendAudioMessage(e,t){const n=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendVideoMessage(e,t){const n=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendCustomMessage(e,t){const n=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFaceMessage(e,t){const n=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFileMessage(e,t){const n=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendLocationMessage(e,t){const n=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}onProgress(e,t){const n=this.getEngine().TUIStore.getMessageModel(e);if(n){(t-n.progress>=.1||1===t)&&(n.progress=t,this.updateMessageList([n],"edit"))}}setAbstractList(e){const t=this.getEngine(),n=e.nick||e.from;let s="";switch(e.type){case t.TYPES.MSG_TEXT:s=e.payload.text||"",s.length>20&&(s=s.slice(0,20));break;case t.TYPES.MSG_MERGER:s=`${this.t("TUIChat.[聊天记录]")}`;break;case t.TYPES.MSG_IMAGE:s=`${this.t("TUIChat.[图片]")}`;break;case t.TYPES.MSG_AUDIO:s=`${this.t("TUIChat.[音频]")}`;break;case t.TYPES.MSG_VIDEO:s=`${this.t("TUIChat.[视频]")}`;break;case t.TYPES.MSG_CUSTOM:s=`${this.t("TUIChat.[自定义消息]")}`;break;case t.TYPES.MSG_FILE:s=`${this.t("TUIChat.[文件]")}`;break;case t.TYPES.MSG_FACE:s=`${this.t("TUIChat.[动画表情]")}`}return`${n}: ${s}`}genMergerForwardPayload(e,t){const{abstractList:n=[],compatibleText:s="",title:i}=t;return 0===n.length&&e.forEach(e=>{n.push(this.setAbstractList(e))}),{messageList:e,title:i,abstractList:n,compatibleText:s||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(e){const{conversationList:t,messageList:n,params:s,mergeInfo:i,sendMessageOptions:a}=e,o=[];for(let e=0;e<t.length;e++){const{conversationID:r,type:c}=t[e],u=Object.assign({to:r.replace(`${c}`,""),conversationType:c,payload:this.genMergerForwardPayload(n,i)},s),l=this.getEngine().chat.createMergerMessage(u);o.push(this.sendMessage(l,a))}return o}genTitle(e,t){const{nick:n,from:s,to:i}=e;return`${n||s} ${this.t("TUIChat.和")} ${t||i} ${this.t("TUIChat.的聊天记录")}`}genMergeInfo(e){var t;return n(this,void 0,void 0,function*(){const{messageList:n,mergeInfo:s}=e;if(s.title)return s;if(n[0].conversationType===this.getEngine().TYPES.CONV_GROUP)return s.title=this.t("TUIChat.群聊的聊天记录"),s;try{const{data:e=[]}=yield this.getEngine().TUIUser.getUserProfile({userIDList:[n[0].to]});s.title=this.genTitle(n[0],null===(t=e[0])||void 0===t?void 0:t.nick)}catch(e){s.title=this.genTitle(n[0])}return s})}sendMergerForwardMessage(e){return n(this,void 0,void 0,function*(){return e.mergeInfo=yield this.genMergeInfo(e),Promise.all(this.genSendMergerForwardMessage(e))})}getOriginMessageList(e){return e.map(e=>e instanceof oe?e.getMessage():e)}sendForwardMessage(e,n,s){n=this.getOriginMessageList(n);const i=s||{},{needMerge:a=!1,params:o={},mergeInfo:r={}}=i,c=t(i,["needMerge","params","mergeInfo"]);if(a)return this.sendMergerForwardMessage({conversationList:e,messageList:n,params:o,mergeInfo:r,sendMessageOptions:c});const u=[];for(let t=0;t<e.length;t++){const{conversationID:s,type:i}=e[t],a=Object.assign({to:s.replace(`${i}`,""),conversationType:i},o),r=c[s]||c;for(let e=0;e<n.length;e++){Reflect.set(a,"payload",n[e]);const t=this.getEngine().chat.createForwardMessage(a);u.push(this.sendMessage(t,r))}}return Promise.all(u)}revokeMessage(e){const t=this.getEngine().chat.revokeMessage(e);return this.getResponse(t,!0,!1)}resendMessage(e){e.status="unSend",this.updateMessageList([e],"resend");const t=this.getEngine().chat.resendMessage(e);return this.getResponse(t,!0,!0)}deleteMessage(e){const t=this.getEngine().chat.deleteMessage(e);return this.getResponse(t,!0,!1)}setMessageExtensions(e,t){return this.getEngine().chat.setMessageExtensions(e,t)}getMessageExtensions(e){return this.getEngine().chat.getMessageExtensions(e)}deleteMessageExtensions(e,t){return this.getEngine().chat.deleteMessageExtensions(e,t)}modifyMessage(e){const t=this.getEngine().chat.modifyMessage(e);return this.getResponse(t,!0,!1).catch(e=>{const{code:t=0,data:n={}}=e.code;throw t===l.MSG_MODIFY_CONFLICT?console.warn(`${h.MSG_MODIFY_CONFLICT} data.message: ${null==n?void 0:n.message}`):t===l.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(h.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===l.MODIFY_MESSAGE_NOT_EXIST&&console.warn(h.MODIFY_MESSAGE_NOT_EXIST),e})}getMessageList(e={conversationID:this.getStoreData(o.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(o.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:d.GET_MSG_LIST_ERROR,message:g.GET_MSG_LIST_ERROR});if(this.getStoreData(o.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const n=this.getStoreData(o.CHAT,"messageSource"),s=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),a=s||i;return n&&n.conversationID===(null==e?void 0:e.conversationID)&&a?this.getMessageListHopping():t.chat.getMessageList(e).then(e=>{var n;const{messageList:s,nextReqMessageID:i,isCompleted:a}=e.data,r=this.getStoreData(o.CHAT,"userInfo");Object.keys(r).length>0&&this.updateLocalMessage(s,r),this.updateMessageList(s,"unshift"),t.TUIStore.update(o.CHAT,"nextReqMessageID",i),t.TUIStore.update(o.CHAT,"isCompleted",a);const c=null===(n=s[0])||void 0===n?void 0:n.conversationID,{operationType:u=0}=this.getEngine().TUIStore.getConversationModel(c)||{};return 0===u&&(this.getMessageReactions({messageList:s}),this.readReceiptHandler.getMessageReadReceiptList(s)),e}).catch(e=>Promise.reject(e))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(o.CHAT,"messageSource"))||void 0===t?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const n=this.getEngine();return n.chat.getMessageListHopping(e).then(t=>{const{messageList:s,nextMessageSeq:i,nextMessageTime:a,isCompleted:r}=t.data,c=1===e.direction?e.sequence:i,u=1===e.direction?e.time:a;return this.updateMessageList(s,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",c),this.hoppingConfigMap.set("nextMessageTime",u),n.TUIStore.update(o.CHAT,"isCompleted",r),t}).catch(e=>Promise.reject(e))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then(e=>{const{isCompleted:t,cursor:n,messageID:s,unreadUserIDList:i,readUserIDList:a}=e.data,o={code:0,data:{cursor:n,isCompleted:t,messageID:s,unreadUserInfoList:[],readUserInfoList:[]}},r=[...i,...a];return 0===r.length?o:this.getEngine().TUIUser.getUserProfile({userIDList:r}).then(e=>(i.length>0?e.data.forEach(e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.unreadUserInfoList.push({userID:t,nick:n,avatar:s})}):e.data.forEach(e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.readUserInfoList.push({userID:t,nick:n,avatar:s})}),o))})}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e)}setTranslationLanguage(e){this.getEngine().TUIStore.update(o.USER,"targetLanguage",e)}translateText(e){const t=this.getStoreData(o.USER,"targetLanguage"),n=Object.assign({targetLanguage:t,sourceLanguage:"auto"},e);return this.getEngine().chat.translateText(n)}searchCloudMessages(e){const n=this.getStoreData(o.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(e).then(e=>{const{searchResultList:s}=e.data;return e.data.searchResultList=s.map(e=>{const{messageList:s,conversationID:i}=e,a=t(e,["messageList","conversationID"]),o=s.map(e=>new oe(e)),r=n.find(e=>e.conversationID===i);return Object.assign(Object.assign({},a),{messageList:o.sort((e,t)=>t.time-e.time),conversation:r})}),e})}addMessageReaction(e,t){return this.getEngine().chat.addMessageReaction(e.getMessage(),t)}removeMessageReaction(e,t){return this.getEngine().chat.removeMessageReaction(e.getMessage(),t)}getMessageReactions(e){}getAllUserListOfMessageReaction(e){var t;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},e),{message:null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.getMessage()}))}updateMessageReactionList(e){const t=[];e.forEach(e=>{const{messageID:n,reactionList:s}=e,i=this.getEngine().TUIStore.getMessageModel(n);if(i){const e=[];for(let t=0;t<s.length;t++){let n=!0;for(let e=0;e<i.reactionList.length;e++)if(s[t].reactionID===i.reactionList[e].reactionID){i.reactionList[e]=s[t],n=!1;break}n&&e.push(s[t])}i.reactionList.push(...e),e.length=0,t.push(i)}}),t.length>0&&this.updateMessageList(t,"edit")}convertVoiceToText(e){const{message:t,language:n="zh"}=e,s=t.getMessage();return this.getEngine().chat.convertVoiceToText({message:s,language:n})}clearHistoryMessage(e){const t=this.getEngine();return t.chat.clearHistoryMessage(e).then(e=>(t.TUIStore.update(o.CHAT,"messageList",[]),t.TUIStore.update(o.CHAT,"nextReqMessageID",""),t.TUIStore.update(o.CHAT,"isCompleted",!1),e))}updateMessageInfo(e){const t=this.getStoreData(o.CHAT,"userInfo");this.getEngine().TUIStore.update(o.CHAT,"userInfo",Object.assign(t,e));const n=this.getStoreData(o.CHAT,"messageList");if(n.length>0){this.updateLocalMessage(n,e)&&this.getEngine().TUIStore.update(o.CHAT,"messageList",n)}}updateLocalMessage(e,t){let n=!1;return e.forEach(e=>{if(t[e.from]){const{nick:s,nameCard:i,avatar:a}=t[e.from];s&&(e.nick=s,n=!0),i&&(e.nameCard=i,n=!0),a&&(e.avatar=a,n=!0)}}),n}sortMessageList(e){if(e[0].conversationType===this.getEngine().TYPES.CONV_C2C)return e.sort((e,t)=>e.time-t.time);const t=e.filter(e=>"success"===e.status).sort((e,t)=>e.sequence-t.sequence);for(let n=0;n<e.length;n++)"success"!==e[n].status&&t.splice(n,0,e[n]);return t}}class Gt extends te{static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}reportFeature(e,t){var n;return null===(n=this.getEngine().chat)||void 0===n?void 0:n.callExperimentalAPI("statTUIKeyFeatures",{code:e,msg:t?`${e}-${t}`:""})}}class Ft{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){return"function"!=typeof e&&console.error("middleware must be a function"),this.cache.push(e),this}next(){if(this.middlewares&&this.middlewares.length>0){return this.middlewares.shift().call(this,this.options,this.next.bind(this))}}run(e){return this.middlewares=this.cache.map(function(e){return e}),this.options=e,this.next()}}function xt(e,t,n){const s=Object.create(null);Object.keys(n).forEach(n=>{if(!t[n])return;s[n]=t[n];const i=new Ft;t[n]=function(){const a=Array.from(arguments);return i.use(function(t,s){return e.isInited?s():Promise.reject({code:d.NOT_INIT,message:`${n} | ${g.NOT_INIT}`})}).use(function(e,i){return s[n].apply(t,e)}),i.run(a)}})}console.log("TUIChatEngine.VERSION:2.4.1-260702");const Vt=Z.getInstance(),qt=X.getInstance(),Kt=ue.getInstance(),Ht=St.getInstance(),jt=Et.getInstance(),Bt=Lt.getInstance(),Yt=bt.getInstance(),Wt=Gt.getInstance();Vt.mount(a.TUIStore,Kt),Vt.mount(a.TUITranslate,Ht),Vt.mount(a.TUIConversation,jt),Vt.mount(a.TUIUser,Bt),Vt.mount(a.TUIChat,Yt),Vt.mount(a.TUIReport,Wt),xt(Vt,Vt,m),xt(Vt,jt,v),xt(Vt,Yt,y),xt(Vt,Bt,I),xt(Vt,Wt,m);export{o as StoreName,Vt as TUIChatEngine,Yt as TUIChatService,jt as TUIConversationService,qt as TUIGlobal,Wt as TUIReportService,Kt as TUIStore,Ht as TUITranslateService,Bt as TUIUserService,Vt as default};