@tencentcloud/lite-chat 1.3.0 → 1.4.1
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.
- package/CHANGELOG.md +18 -0
- package/basic.es.js +3 -2
- package/basic.js +3 -2
- package/package.json +1 -1
- package/plugins/cloud-search.es.js +1 -1
- package/plugins/cloud-search.js +1 -1
- package/plugins/conversation-group.d.ts +8 -0
- package/plugins/conversation-group.es.js +1 -1
- package/plugins/conversation-group.js +1 -1
- package/plugins/conversation.es.js +1 -1
- package/plugins/conversation.js +1 -1
- package/plugins/follow.es.js +1 -1
- package/plugins/follow.js +1 -1
- package/plugins/friend.es.js +1 -1
- package/plugins/friend.js +1 -1
- package/plugins/group.es.js +1 -1
- package/plugins/group.js +1 -1
- package/plugins/message-enhancer.es.js +3 -4
- package/plugins/message-enhancer.js +3 -4
- package/plugins/offline-message-synchronizer.d.ts +9 -0
- package/plugins/offline-message-synchronizer.es.js +1 -0
- package/plugins/offline-message-synchronizer.js +1 -0
- package/plugins/rich-media-message.es.js +1 -1
- package/plugins/rich-media-message.js +1 -1
- package/plugins/signaling.d.ts +8 -0
- package/plugins/signaling.es.js +1 -1
- package/plugins/signaling.js +1 -1
- package/plugins/topic.es.js +1 -1
- package/plugins/topic.js +1 -1
- package/professional.es.js +5 -5
- package/professional.js +5 -5
- package/standard.es.js +5 -5
- package/standard.js +5 -5
package/basic.es.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,s,n){s&&(this.listeners[e]=null==(e=this.listeners[e])?void 0:e.filter(e=>{var t=e.fn===s,e=!n||e.context===n;return!(t&&e)}))}emit(e,...s){e=this.listeners[e];e&&e.forEach(e=>{var{fn:e,context:t}=e;e.apply(t,s)})}once(t,s,n){let i=(...e)=>{s.apply(n,e),this.off(t,i)};this.on(t,i)}}let t={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},s=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var n;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(n=n||{});var o,c,i=Object.freeze({__proto__:null,get ConvModifyPushType(){return n},ENUM_PLATFORM:t,IS_TOPIC_MESSAGE:2,NOT_NEED_CRC_SERVCMD:s});function r(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_TIPS_NOTIFICATION):s.push(o.GROUP_TIPS_NOTIFICATION)}),s}!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message"}(o=o||{});let a=[{conditions:[{type:"event",value:100}],subType:o.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:o.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:o.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:o.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:o.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:o.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:o.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:o.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:o.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:o.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.C2cNotifyMsgArray)&&t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(o.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(o.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(o.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(o.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(o.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(o.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(o.TOPIC_MESSAGE_READ_SYNC):s.push(o.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_SYSTEM_NOTIFICATION):s.push(o.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{var e=e["GroupAtTips"]["TopicId"];e?s.push(o.TOPIC_AT_TIPS):s.push(o.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.RecentContactMod)&&t.forEach(e=>{switch(e.PushType){case n.CONV_MARK_UPDATED:s.push(o.CONVERSATION_MARK_UPDATED);break;case n.CONV_GROUP_ADDED:s.push(o.CONVERSATION_GROUP_ADD);break;case n.CONV_GROUP_DELETED:s.push(o.CONVERSATION_GROUP_DELETED);break;case n.CONV_GROUP_UPDATED:s.push(o.CONVERSATION_GROUP_UPDATED);break;default:s.push(o.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:o.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:o.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:o.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:o.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:o.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:o.ALL_MESSAGE_READ}];function l(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],i=[];return t.forEach(t=>{t.Flag=n.body.Flag;var e=a.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!e)return null;let s=[];"function"==typeof e.subTypeParser?s=e.subTypeParser(t):e.subType&&(s=e.subType),Array.isArray(s)?s.forEach(e=>{i.push({type:c.SERVER_PUSH_MESSAGE+":"+e,data:t})}):i.push({type:c.SERVER_PUSH_MESSAGE+":"+s,data:t})}),i}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(c=c||{});let d={[c.SERVER_PUSH_MESSAGE]:l,[c.SERVER_PUSH_MESSAGE_MULTIPLE]:l,[c.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},u=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=o}subscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.on(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,i)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(d).includes(t)){let e=null==(t=d[t])?void 0:t.call(d,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.off(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,i)}}subscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.off(e,t,s)}emitOuterEvent(e,t){var s;null!=(s=this._outerEventEmitter)&&s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function _(e,t){var s={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}function h(e,r,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{o(l.next(e))}catch(e){t(e)}}function i(e){try{o(l.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}o((l=l.apply(e,r||[])).next())})}let g=e=>void 0===e,E=e=>"string"==typeof e,f=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[1].toLowerCase()},p=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===f(e),S=e=>null!==e&&"object"==typeof e,m=e=>p(e)||S(e),v=e=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},I=e=>{if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function C(e=99999999){return Math.round(Math.random()*e)}let T=(s,n,i,o)=>{if(!m(s)||!m(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(m(s[a])&&m(n[a]))r+=T(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r};function O(s){let n,i,o=s,r="";for(let e=0,t=(o=s.length%8!=0?"0".repeat(8-s.length%8)+s:o)["length"];e<t;e+=8)n=parseInt(o.slice(e,e+4),2),i=parseInt(o.slice(e+4,e+8),2),r+=base16Map.get(n)+base16Map.get(i);return r}let y="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),M="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||y,A=M&&"function"==typeof wx.createGamePortal,N="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),R="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),b="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,P="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,k=M&&"object"==typeof wx.miniapp,L="undefined"!=typeof uni,U=M||N||R||D||w||P||b,G="undefined"==typeof window&&!U&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,F="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),B="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),x="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!F,V=N?qq:R?tt:D?swan:w?my:M?wx:P?uni:b?jd:{},$=x&&window&&window.navigator&&window.navigator.userAgent||"",q=/(micromessenger|webbrowser)/i.test($),W=function(){let e="WEB";return q?e="WEB":N?e="QQ_MP":R?e="TT_MP":D?e="BAIDU_MP":w?e="ALI_MP":M?e=k?"DONUT_NATIVE_APP":"WX_MP":P?e="UNI_NATIVE_APP":G?e="NS_NATIVE_APP":F&&(e="RN_NATIVE_APP"),t[e]}(),Y=/iPad/i.test($),K=/iPhone/i.test($)&&!Y,j=/iPod/i.test($),H=K||Y||j,z=function(){var e=$.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Z=/Android/i.test($),J=function(){var e,t,s=$.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),X=/Firefox/i.test($),Q=/Edge/i.test($),ee=!Q&&/Chrome/i.test($),te=/MSIE/.test($)||-1<$.indexOf("Trident")&&-1<$.indexOf("rv:11.0"),se=function(){var e=/MSIE\s(\d+)\.\d/.exec($);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test($)&&/rv:11.0/.test($)?11:t}(),ne=/Safari/i.test($)&&!ee&&!Z&&!Q,oe=/Windows/i.test($),ie=/MAC OS X/i.test($),re=x&&"undefined"!=typeof Worker&&!te,ae=Z||H,ce=x&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,le=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!H||e||ne))}();function de(){let e="unknown";if(ie&&(e="mac"),oe&&(e="windows"),H&&(e="ios"),Z&&(e="android"),U)try{var t=wx.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}let ue=2800,_e=2801,he=3e3,ge="application/x-www-form-urlencoded;charset=UTF-8";function Ee(e){return h(this,arguments,void 0,function*({method:i,url:o,data:r,timeout:a=he}){return new Promise(U?(t,e)=>{V.request({url:o,data:r,method:i,timeout:a,header:{"content-type":ge},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${ue}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${_e}}`))},a);s.onreadystatechange=function(){if(4===s.readyState)if(clearTimeout(n),200===s.status||304===s.status)try{t(s.responseText?JSON.parse(s.responseText):null)}catch(e){t(s.responseText)}else e(new Error(`{"message":"Network error","code":${ue}}`))},s.open(i,o,!0),s.setRequestHeader("Content-type",ge),s.send(r||null)})})}function fe(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(I(e)){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(e)||"[object Set]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e))&&0===e.size}function pe(n){if(null===n||"object"!=typeof n)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(n instanceof Map){let s=new Map;return n.forEach((e,t)=>{s.set(pe(t),pe(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(pe(e))}),t}if(Array.isArray(n))return n.map(e=>pe(e));let e=Object.getPrototypeOf(n),s=Object.create(e);return[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)].forEach(e=>{var t=Object.getOwnPropertyDescriptor(n,e);t&&(t.get||t.set?Object.defineProperty(s,e,t):s[e]=pe(n[e]))}),s}function Se(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var me=Object.freeze({__proto__:null,ANDROID_VERSION:J,IE_VERSION:se,IN_ALIPAY_MINI_APP:w,IN_BAIDU_MINI_APP:D,IN_BROWSER:x,IN_DONUT_NATIVE_APP:k,IN_JD_MINI_APP:b,IN_MINI_APP:U,IN_NS_NATIVE_APP:G,IN_QQ_MINI_APP:N,IN_RN_APP:F,IN_TT_MINI_APP:R,IN_UNI_APP:L,IN_UNI_NATIVE_APP:P,IN_WX_MINI_APP:M,IN_WX_MINI_APP_DESK:y,IN_WX_MINI_GAME:A,IN_WX_MINI_PLUGIN:B,IOS_VERSION:z,IS_ANDROID:Z,IS_CHROME:ee,IS_EDGE:Q,IS_FIREFOX:X,IS_IE:te,IS_IOS:H,IS_IPAD:Y,IS_IPHONE:K,IS_IPOD:j,IS_MAC:ie,IS_SAFARI:ne,IS_WECHAT:q,IS_WIN:oe,IS_WORKER_AVAILABLE:re,MINI_APP_NAMESPACE:V,USER_AGENT:$,base16EncodeBinaryString:O,deepCopyWithMethods:pe,deepMerge:T,generatePromise:Se,getPlatformType:de,getType:f,httpRequest:Ee,isArray:p,isArrayOrObject:m,isEmpty:fe,isFlutterWeb:ce,isH5:ae,isIOSWebView:le,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(+e)||"object"==typeof e&&e.constructor===Number),isObject:S,isPlainObject:I,isString:E,isUndefined:g,isValidRequestKey:v,platform:W,randomInt:C,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t}});class ve{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t;try{null!=(t=this._socket)&&t.send(e)}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=s,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class Ie{connectSocket(e){return this._socket=wx.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null!=(t=this._socket)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}let Ce="CONNECT",Te="SEND",Oe="DISCONNECT",ye="OPEN",Me="MESSAGE",Ae="CLOSE",Ne="ERROR",Re="SEND_FAIL";class De{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){var t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:Ce,url:e})}send(e){var t;try{null!=(t=this._worker)&&t.postMessage({type:Te,data:e})}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:t,onMessage:n,onClose:i,onError:o,onSendFail:r}=e;if(this._worker){let s={[ye]:t,[Me]:n,[Ae]:i,[Ne]:o,[Re]:r};this._onSendFail=r,this._worker.onmessage=e=>{var t=((null==e?void 0:e.data)||{})["type"];"function"==typeof s[t]&&null!=(t=s[t])&&t.call(s,null==e?void 0:e.data)}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Oe}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var we,be=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return U?w?my.getStorageSync({key:e}).data:V.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){var s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){U?w?my.setStorageSync({key:e,data:JSON.stringify(t)}):V.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(we=we||{});class Pe{constructor(t){this._url="",this._readyState=we.DISCONNECTED,this._url=t,this._id=C(),this._emitter=new e,M?this._socket=new Ie:this._canUseWebWorker()?this._socket=new De:this._socket=new ve,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[we.CONNECTED,we.CONNECTING].includes(this._readyState)||(this._readyState=we.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==we.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[we.CONNECTED,we.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===we.CONNECTED}disconnect(){this._readyState=we.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===we.CONNECTING&&(this._readyState=we.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=we.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=we.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=we.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){var e=be.get("cloudConfig")||{};return(g(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&re}}let ke="CHINA",Le="SINGAPORE",Ue="KOREA",Ge="GERMANY",Fe="IND",Be="JPN",xe="USA",Ve="INDONESIA",$e={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:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},qe={[Le]:[[2e7,3e7],[172e7,173e7]],[Ue]:[[3e7,4e7],[173e7,174e7]],[Ge]:[[4e7,5e7],[174e7,175e7]],[Fe]:[[5e7,6e7],[175e7,176e7]],[Be]:[[6e7,7e7],[176e7,177e7]],[xe]:[[7e7,8e7],[177e7,178e7]],[Ve]:[[8e7,9e7],[178e7,179e7]]};function We(e){for(var t of Object.keys(qe))for(var[s,n]of qe[t])if(e>=s&&e<n)return t;return ke}var Ye,Ke="1.3.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(Ye=Ye||{});let je=Ye.INITIAL;function He(){var e=Math.random();return 0===e?He():e}function ze(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:i}=be.get("instance"),o=He(),r=de(),a=function(){var e=de();let t=-1;return"ios"===e?t=z||-1:"android"===e&&(t=J||-1),t}(),n=(s={sdkappid:n,instanceid:i,random:o,platform:W,host:r,version:a,sdkversion:Ke},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}var Ze=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){var s=Date.now();this._timeOffsetWithServer=t+(s-e)-s}};let Je=16;var Xe=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){var t=e["id"];this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){var{id:e,callback:t,context:s,isOnce:n=!1,intervalMs:i=Je}=e,o=Math.max(i,Je);return{id:e,nextExecuteTime:Date.now()+o,intervalMs:i,callback:t,context:s,isOnce:n}}addTask(e){e=this._createTask(e);this._addTaskToScheduler(e)}addOnceTask(e){e=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(t){var e=this._tasks.findIndex(e=>e.id===t);-1<e&&(this._tasks.splice(e,1),this._taskMap.delete(t),this._scheduleNextTask())}updateTaskInterval(e,t){e=this._taskMap.get(e);e&&(e.intervalMs=t,e.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);var e=this._tasks[0];e&&(e=Math.max(0,e.nextExecuteTime-Date.now()),this._timer=setTimeout(()=>this._execute(),e))}_execute(){for(var e=Date.now();this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){var t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function Qe(t){var s=[];for(let e=0;e<t.length;e+=1){var n,i=t.charCodeAt(e);55296<=i&&i<=56319?(n=t.charCodeAt(++e)-56320+(i-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):i<=127?s.push(i):i<=2047?s.push(192|i>>6,128|63&i):s.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(s)}function et(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&v(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=et(e[t]));return s}function st(e,t){if(s.includes(e))return 0;var n=Qe(JSON.stringify(t));let i=4294967295;var o=n["length"];for(let e=0;e<o;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return(4294967295^i)>>>0}function nt(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=be.get("login")||{},i=be.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,tjgID:"",seq:rt(),cs:0}),i=et(s);return n.cs=st(e,i),{head:n,body:i}}function ot(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=be.get("login")||{},i=be.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:rt(),cs:0}),i=et(s);return n.cs=st(e,i),{head:n,body:i}}let it=C();function rt(){return it=it<2415919103?it+1:C()}function at(){var e=be.get("login")||{},t=be.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.3.0",tiny_id:Number(e.tinyID),user_id:e.userId,platform:W,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var ct,_t,lt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=be.get("login")||{},i=be.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:rt(),cs:0}),i=et(s);return n.cs=st(e,i),{head:n,body:i}},generateProtocolData:nt,generateSSOLogProtocolData:ot,generateSequence:rt,getCommonHead:at,taskScheduler:Xe,timeManager:Ze});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(ct=ct||{});let dt={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class ut{constructor(e){this.level=ct.info,this._canSendLog=!0,this._logCreatedAt=Ze.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=void 0;var{method:e,eventType:t=0,uiPlatform:s,message:n}=e||{};this.eventType=t,this.method=e,this.uiPlatform=s,this.message=n||""}setMoreMessage(e){this.moreMessage=this.moreMessage+" "+e}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Ze.getTimeOffsetWithServer()}end(e=!1){var t;this._canSendLog&&(t=Ze.getServerTimeMs(),0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:`+t),e?(this._canSendLog=!1,this.timestamp=Ze.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout(()=>{this._canSendLog=!1,this.timestamp=Ze.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())},0))}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=be.get("netWorkMonitor"))&&t.isNetworkOnline&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage)&&this.setMoreMessage(e.errorMessage),this.level=ct.error):console.warn("SSOLogData.setError value not instanceof Error, please check!"),this}setLogInfo(t){return Object.keys(t).forEach(e=>{Object.keys(dt).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{dt[e]&&(t[dt[e]]=this[e])}),t}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(_t=_t||{});var ht=_t;let gt=20,Et=6e4,ft=[4,5,6],pt=[],St=[],mt="report-logger";var vt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=gt,this._maxThreshold=100,this._waitingTime=Et,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,u.subscribeInnerEvent(ht.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Xe.addTask({id:mt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=gt,evt_rpt_waiting:t=Et,evt_rpt_level:s=ft,evt_rpt_sdkappid_bl:n=pt,evt_rpt_tinyid_wl:i=St}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=i}createSSOLogData(e){var t=new ut(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately())&&this.uploadSSOLogData()}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&0<this._logQueue.length&&this.uploadSSOLogData()}uploadSSOLogData(){return h(this,void 0,void 0,function*(){var e,t;0!==this._logQueue.length&&(t=this._logQueue.slice(),t=this._filterLogs(t),this._logQueue=[],0===t.length||fe((t={Header:at(),Event:t}).Header.user_id)||(e=(t=ot({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void xt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(M){var s=null==(t=null==(e=wx.getAccountInfoSync)?void 0:e.call(wx))?void 0:t.miniProgram;if(s){let{appId:e,envVersion:t}=s;be.set("instance",{appId:e,envVersion:t})}}else x&&be.set("instance",{href:window.location.href})}_filterLogs(e){var t=(be.get("login")||{})["tinyID"],s=(be.get("instance")||{})["sdkAppId"];return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}reset(){console.log("SSO_LOG_MODULE.reset"),Xe.removeTask(mt),u.unSubscribeInnerEvent(ht.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=gt,this._maxThreshold=100,this._waitingTime=Et,this._logQueue=[]}};let It=15e3,Ct="Channel",Tt="channel_schedule_task",Ot="channel_reconnect_task",yt="connected",Mt="connecting",At="disconnected",Nt=500,Rt="network_status_change",Dt="activity_status_change",wt="send_fail",bt="reconnect_failed",Pt="socket_error",kt="socket_close";function Lt(e){return(Lt="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 Ut(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Gt,$t,Ft={exports:{}},Bt=(Gt||(Ft.exports=function s(n,i,o){function r(t,e){if(!i[t]){if(!n[t]){if(!e&&Ut)return Ut(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=i[t]={exports:{}};n[t][0].call(e.exports,function(e){return r(n[t][1][e]||e)},e,e.exports,s,n,i,o)}return i[t].exports}for(var a=Ut,e=0;e<o.length;e++)r(o[e]);return r}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,i=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var i=n.shift();if(i){if("object"!=Lt(i))throw new TypeError(i+"must be non-object");for(var o in i)t=i,s=o,Object.prototype.hasOwnProperty.call(t,s)&&(e[o]=i[o])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){for(var t,s,n,i,o=t=0,r=e.length;o<r;o++)t+=e[o].length;for(i=new Uint8Array(t),o=s=0,r=e.length;o<r;o++)n=e[o],i.set(n,s),s+=n.length;return i}}),o={arraySet:function(e,t,s,n,i){for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var c=new l.Buf8(256),n=0;n<256;n++)c[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function d(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}c[254]=c[254]=1,s.string2buf=function(e){for(var t,s,n,i,o=e.length,r=0,a=0;a<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),r+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(r),a=i=0;i<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),s<128?t[i++]=s:(s<2048?t[i++]=192|s>>>6:(s<65536?t[i++]=224|s>>>12:(t[i++]=240|s>>>18,t[i++]=128|s>>>12&63),t[i++]=128|s>>>6&63),t[i++]=128|63&s);return t},s.buf2binstring=function(e){return d(e,e.length)},s.binstring2buf=function(e){for(var t=new l.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){for(var s,n,i,o=t||e.length,r=new Array(2*o),a=s=0;a<o;)if((n=e[a++])<128)r[s++]=n;else if(4<(i=c[n]))r[s++]=65533,a+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&a<o;)n=n<<6|63&e[a++],i--;1<i?r[s++]=65533:n<65536?r[s++]=n:(n-=65536,r[s++]=55296|n>>10&1023,r[s++]=56320|1023&n)}return d(r,s)},s.utf8border=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+c[e[s]]>t?s:t}},{"./common":Gt=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var i=65535&e,o=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;o=o+(i=i+t[n++]|0)|0,--r;);i%=65521,o%=65521}return i|o<<16}},{}],4:[function(e,t,s){t.exports={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}},{}],5:[function(e,t,s){var a=function(){for(var e=[],t=0;t<256;t++){for(var s=t,n=0;n<8;n++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}();t.exports=function(e,t,s,n){var i=a,o=n+s;e^=-1;for(var r=n;r<o;r++)e=e>>>8^i[255&(e^t[r])];return~e}},{}],6:[function(e,t,s){t.exports=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}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,o,r,a,l=e.state,c=e.next_in,d=e.input,_=c+(e.avail_in-5),u=e.next_out,h=e.output,g=u-(t-e.avail_out),E=u+(e.avail_out-257),p=l.dmax,f=l.wsize,S=l.whave,m=l.wnext,v=l.window,I=l.hold,C=l.bits,O=l.lencode,T=l.distcode,y=(1<<l.lenbits)-1,M=(1<<l.distbits)-1;e:do{for(C<15&&(I+=d[c++]<<C,C+=8,I+=d[c++]<<C,C+=8),s=O[I&y];;){if(I>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))h[u++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=O[(65535&s)+(I&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(i=65535&s,(n&=15)&&(C<n&&(I+=d[c++]<<C,C+=8),i+=I&(1<<n)-1,I>>>=n,C-=n),C<15&&(I+=d[c++]<<C,C+=8,I+=d[c++]<<C,C+=8),s=T[I&M];;){if(I>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=T[(65535&s)+(I&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(o=65535&s,C<(n&=15)&&(I+=d[c++]<<C,(C+=8)<n)&&(I+=d[c++]<<C,C+=8),p<(o+=I&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(I>>>=n,C-=n,(n=u-g)<o){if(S<(n=o-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=v,(r=0)===m){if(r+=f-n,n<i){for(i-=n;h[u++]=v[r++],--n;);r=u-o,a=h}}else if(m<n){if(r+=f+m-n,(n-=m)<i){for(i-=n;h[u++]=v[r++],--n;);if(r=0,m<i){for(i-=n=m;h[u++]=v[r++],--n;);r=u-o,a=h}}}else if(r+=m-n,n<i){for(i-=n;h[u++]=v[r++],--n;);r=u-o,a=h}for(;2<i;)h[u++]=a[r++],h[u++]=a[r++],h[u++]=a[r++],i-=3;i&&(h[u++]=a[r++],1<i)&&(h[u++]=a[r++])}else{for(r=u-o;h[u++]=h[r++],h[u++]=h[r++],h[u++]=h[r++],2<(i-=3););i&&(h[u++]=h[r++],1<i)&&(h[u++]=h[r++])}break}}break}}while(c<_&&u<E);c-=i=C>>3,I&=(1<<(C-=i<<3))-1,e.next_in=c,e.next_out=u,e.avail_in=c<_?_-c+5:5-(c-_),e.avail_out=u<E?E-u+257:257-(u-E),l.hold=I,l.bits=C}},{}],8:[function(e,t,s){var w=e("../utils/common"),b=e("./adler32"),P=e("./crc32"),k=e("./inffast"),L=e("./inftrees"),U=0,G=-2,F=1,n=852,i=592;function V(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function o(){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 w.Buf16(320),this.work=new w.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function r(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=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new w.Buf32(n),t.distcode=t.distdyn=new w.Buf32(i),t.sane=1,t.back=-1,U):G}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,r(e)):G}function l(e,t){var s,n;return!e||!e.state||(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?G:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function c(e,t){var s;return e?(s=new o,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):G}var x,B,W=!0;function K(e,t,s,n){var i,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new w.Buf8(e.wsize)),n>=e.wsize?(w.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(i=e.wsize-e.wnext)&&(i=n),w.arraySet(e.window,t,s-n,i,e.wnext),(n-=i)?(w.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=r,s.inflateInit=function(e){return c(e,15)},s.inflateInit2=c,s.inflate=function(e,t){var s,n,i,o,r,a,l,c,d,_,u,h,g,E,p,f,S,m,v,I,C,O,T,y,M=0,A=new w.Buf8(4),N=[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 G;12===(s=e.state).mode&&(s.mode=13),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,d=s.bits,_=a,u=l,O=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;d<16;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(2&s.wrap&&35615===c)A[s.check=0]=255&c,A[1]=c>>>8&255,s.check=P(s.check,A,2,0),d=c=0,s.mode=2;else if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31)e.msg="incorrect header check",s.mode=30;else if(8!=(15&c))e.msg="unknown compression method",s.mode=30;else{if(d-=4,C=8+(15&(c>>>=4)),0===s.wbits)s.wbits=C;else if(C>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<C,e.adler=s.check=1,s.mode=512&c?10:12,d=c=0}}break;case 2:for(;d<16;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(s.flags=c,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=c>>8&1),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=P(s.check,A,2,0)),d=c=0,s.mode=3;case 3:for(;d<32;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.head&&(s.head.time=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,s.check=P(s.check,A,4,0)),d=c=0,s.mode=4;case 4:for(;d<16;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.head&&(s.head.xflags=255&c,s.head.os=c>>8),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=P(s.check,A,2,0)),d=c=0,s.mode=5;case 5:if(1024&s.flags){for(;d<16;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.length=c,s.head&&(s.head.extra_len=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=P(s.check,A,2,0)),d=c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=a<(h=s.length)?a:h)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),w.arraySet(s.head.extra,n,o,h,C)),512&s.flags&&(s.check=P(s.check,n,h,o)),a-=h,o+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=P(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=P(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;d<16;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}d=c=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;d<32;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}e.adler=s.check=V(c),d=c=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=d,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last)c>>>=7&d,d-=7&d,s.mode=27;else{for(;d<3;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}switch(s.last=1&c,--d,3&(c>>>=1)){case 0:s.mode=14;break;case 1:R=D=void 0;var R,D=s;if(W){for(x=new w.Buf32(512),B=new w.Buf32(32),R=0;R<144;)D.lens[R++]=8;for(;R<256;)D.lens[R++]=9;for(;R<280;)D.lens[R++]=7;for(;R<288;)D.lens[R++]=8;for(L(1,D.lens,0,288,x,0,D.work,{bits:9}),R=0;R<32;)D.lens[R++]=5;L(2,D.lens,0,32,B,0,D.work,{bits:5}),W=!1}if(D.lencode=x,D.lenbits=9,D.distcode=B,D.distbits=5,s.mode=20,6!==t)break;c>>>=2,d-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,d-=2}break;case 14:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,d=c=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;w.arraySet(i,n,o,h,r),a-=h,o+=h,l-=h,r+=h,s.length-=h}else s.mode=12;break;case 17:for(;d<14;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(s.nlen=257+(31&c),c>>>=5,d-=5,s.ndist=1+(31&c),c>>>=5,d-=5,s.ncode=4+(15&c),c>>>=4,d-=4,286<s.nlen||30<s.ndist){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;d<3;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.lens[N[s.have++]]=7&c,c>>>=3,d-=3}for(;s.have<19;)s.lens[N[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,T={bits:s.lenbits},O=L(0,s.lens,0,19,s.lencode,0,s.work,T),s.lenbits=T.bits,O){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;f=(M=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&M,!((p=M>>>24)<=d);){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(S<16)c>>>=p,d-=p,s.lens[s.have++]=S;else{if(16===S){for(y=p+2;d<y;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(c>>>=p,d-=p,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}C=s.lens[s.have-1],h=3+(3&c),c>>>=2,d-=2}else if(17===S){for(y=p+3;d<y;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}C=0,h=3+(7&(c>>>=p)),c>>>=3,d=d-p-3}else{for(y=p+7;d<y;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}C=0,h=11+(127&(c>>>=p)),c>>>=7,d=d-p-7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=C}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,T={bits:s.lenbits},O=L(1,s.lens,0,s.nlen,s.lencode,0,s.work,T),s.lenbits=T.bits,O){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,T={bits:s.distbits},O=L(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,T),s.distbits=T.bits,O){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(6<=a&&258<=l){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=d,k(e,u),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,d=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;f=(M=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&M,!((p=M>>>24)<=d);){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(f&&!(240&f)){for(m=p,v=f,I=S;f=(M=s.lencode[I+((c&(1<<m+v)-1)>>m)])>>>16&255,S=65535&M,!(m+(p=M>>>24)<=d);){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}c>>>=m,d-=m,s.back+=m}if(c>>>=p,d-=p,s.back+=p,s.length=S,0===f){s.mode=26;break}if(32&f){s.back=-1,s.mode=12;break}if(64&f){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&f,s.mode=22;case 22:if(s.extra){for(y=s.extra;d<y;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,d-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;f=(M=s.distcode[c&(1<<s.distbits)-1])>>>16&255,S=65535&M,!((p=M>>>24)<=d);){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(!(240&f)){for(m=p,v=f,I=S;f=(M=s.distcode[I+((c&(1<<m+v)-1)>>m)])>>>16&255,S=65535&M,!(m+(p=M>>>24)<=d);){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}c>>>=m,d-=m,s.back+=m}if(c>>>=p,d-=p,s.back+=p,64&f){e.msg="invalid distance code",s.mode=30;break}s.offset=S,s.extra=15&f,s.mode=24;case 24:if(s.extra){for(y=s.extra;d<y;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,d-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===l)break e;if(s.offset>(h=u-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}g=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),E=s.window}else E=i,g=r-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;i[r++]=E[g++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;i[r++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;d<32;){if(0===a)break e;a--,c|=n[o++]<<d,d+=8}if(u-=l,e.total_out+=u,s.total+=u,u&&(e.adler=s.check=(s.flags?P:b)(s.check,i,u,r-u)),u=l,(s.flags?c:V(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}d=c=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;d<32;){if(0===a)break e;a--,c+=n[o++]<<d,d+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}d=c=0}s.mode=29;case 29:O=1;break e;case 30:O=-3;break e;case 31:return-4;default:return G}return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=d,(s.wsize||u!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&K(e,e.output,e.next_out,u-e.avail_out)?(s.mode=31,-4):(_-=e.avail_in,u-=e.avail_out,e.total_in+=_,e.total_out+=u,s.total+=u,s.wrap&&u&&(e.adler=s.check=(s.flags?P:b)(s.check,i,u,e.next_out-u)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),O=(0==_&&0===u||4===t)&&O===U?-5:O)},s.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,U):G},s.inflateGetHeader=function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,U):G},s.inflateSetDictionary=function(e,t){var s,n=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?G:11===s.mode&&b(1,t,n,0)!==s.check?-3:K(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,U)},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var k=e("../utils/common"),L=[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],U=[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],G=[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],F=[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];t.exports=function(e,t,s,n,i,o,r,a){for(var l,c,d,_,u,h,g,E,p,f=a.bits,S=0,m=0,v=0,I=0,C=0,O=0,T=0,y=0,M=0,A=0,N=null,R=0,D=new k.Buf16(16),w=new k.Buf16(16),b=null,P=0,S=0;S<=15;S++)D[S]=0;for(m=0;m<n;m++)D[t[s+m]]++;for(C=f,I=15;1<=I&&0===D[I];I--);if(I<C&&(C=I),0===I)i[o++]=20971520,i[o++]=20971520,a.bits=1;else{for(v=1;v<I&&0===D[v];v++);for(C<v&&(C=v),S=y=1;S<=15;S++)if((y=(y<<1)-D[S])<0)return-1;if(0<y&&(0===e||1!==I))return-1;for(w[1]=0,S=1;S<15;S++)w[S+1]=w[S]+D[S];for(m=0;m<n;m++)0!==t[s+m]&&(r[w[t[s+m]]++]=m);if(h=0===e?(N=b=r,19):1===e?(N=L,R-=257,b=U,P-=257,256):(N=G,b=F,-1),S=v,u=o,T=m=A=0,d=-1,_=(M=1<<(O=C))-1,1===e&&852<M||2===e&&592<M)return 1;for(;;){for(p=r[m]<h?(E=0,r[m]):r[m]>h?(E=b[P+r[m]],N[R+r[m]]):(E=96,0),l=1<<(g=S-T),v=c=1<<O;i[u+(A>>T)+(c-=l)]=g<<24|E<<16|p,0!==c;);for(l=1<<S-1;A&l;)l>>=1;if(0!==l?A=(A&l-1)+l:A=0,m++,0==--D[S]){if(S===I)break;S=t[s+r[m]]}if(C<S&&(A&_)!==d){for(u+=v,y=1<<(O=S-(T=0===T?C:T));O+T<I&&!((y-=D[O+T])<=0);)O++,y<<=1;if(M+=1<<O,1===e&&852<M||2===e&&592<M)return 1;i[d=A&_]=C<<24|O<<16|u-o}}0!==A&&(i[u+A]=S-T<<24|64<<16),a.bits=C}return 0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={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"}},{}],11:[function(e,t,s){t.exports=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}},{}],"/lib/inflate.js":[function(e,t,s){var _=e("./zlib/inflate"),u=e("./utils/common"),h=e("./utils/strings"),g=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),o=e("./zlib/gzheader"),E=Object.prototype.toString;function r(e){if(!(this instanceof r))return new r(e);this.options=u.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(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 i,this.strm.avail_out=0,_.inflateInit2(this.strm,t.windowBits));if(e!==g.Z_OK)throw new Error(n[e]);if(this.header=new o,_.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===E.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=_.inflateSetDictionary(this.strm,t.dictionary))!==g.Z_OK)throw new Error(n[e])}function a(e,t){t=new r(t);if(t.push(e,!0),t.err)throw t.msg||n[t.err];return t.result}r.prototype.push=function(e,t){var s,n,i,o,r,a=this.strm,l=this.options.chunkSize,c=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?g.Z_FINISH:g.Z_NO_FLUSH,"string"==typeof e?a.input=h.binstring2buf(e):"[object ArrayBuffer]"===E.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new u.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=_.inflate(a,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&c?_.inflateSetDictionary(this.strm,c):s)===g.Z_BUF_ERROR&&!0===d&&(s=g.Z_OK,d=!1),s!==g.Z_STREAM_END&&s!==g.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==g.Z_STREAM_END&&(0!==a.avail_in||n!==g.Z_FINISH&&n!==g.Z_SYNC_FLUSH)||("string"===this.options.to?(i=h.utf8border(a.output,a.next_out),o=a.next_out-i,r=h.buf2string(a.output,i),a.next_out=o,a.avail_out=l-o,o&&u.arraySet(a.output,a.output,i,o,0),this.onData(r)):this.onData(u.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(d=!0),(0<a.avail_in||0===a.avail_out)&&s!==g.Z_STREAM_END);return(n=s===g.Z_STREAM_END?g.Z_FINISH:n)===g.Z_FINISH?(s=_.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===g.Z_OK):n!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(a.avail_out=0))},r.prototype.onData=function(e){this.chunks.push(e)},r.prototype.onEnd=function(e){e===g.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=u.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=r,s.inflate=a,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},s.ungzip=a},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),Ft.exports),xt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=Nt,this._currentConnectState=yt,this._beforeSendInterceptors=[]}init(){Xe.addTask({id:Tt,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){var{sdkAppId:t,testEnv:s}=be.get("instance"),n=We(t);return ze(s?$e.TEST[n].DEFAULT:$e.PRODUCTION[n].INITIAL.replace("*",""+t),{isBinary:e})}(this._isBinarySupported),u.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s,{requestId:n,timeout:i=It,canResend:o=!0}=t||{};if(fe(e))return console.warn(Ct+".sendPacket: packet is empty ",e),null;this._executeBeforeSendInterceptors(e);var r=JSON.stringify(e);let a=null;if(n){let{resolve:e,reject:t,promise:s}=Se();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:i,canResend:o})}t=this._isBinarySupported?Qe(r).buffer:r;return null!=(s=this._socketAdapter)&&s.send(t),a}connect(){this._socketAdapter=new Pe(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Ct+`.connect isWorkerEnabled: false socketID:${e} url:`+this._url;this._ssoLog({method:"connect",message:e}),console.log(e)}disconnect(){var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Ct+".disconnect socketID:"+e;this._ssoLog({method:"disconnect",message:e}),console.log(e),this._removeEventListeners(),null!=(e=this._socketAdapter)&&e.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(Ct+".dispose"),Xe.removeTask(Tt),Xe.removeTask(Ot),u.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=Nt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(var t of this._beforeSendInterceptors){var{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){var e=this._currentConnectState===Mt&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return h(this,void 0,void 0,function*(){var e=`${Ct} reconnect isReconnecting: ${this._isReconnecting} currentConnectState: `+this._currentConnectState;if(this._ssoLog({method:"reconnect",message:e}),console.log(e),!this._shouldSkipReconnect()){this._url=function(e){var{sdkAppId:t,testEnv:s}=be.get("instance"),t=We(t);if(s)return ze($e.TEST[t].DEFAULT,{isBinary:e});let n=$e.PRODUCTION[t],i=x&&n.ANYCAST;return ze({[Ye.INITIAL]:()=>(je=Ye.DEFAULT,n.DEFAULT),[Ye.DEFAULT]:()=>(je=Ye.BACKUP,n.BACKUP),[Ye.BACKUP]:()=>(je=i?Ye.ANYCAST:Ye.DEFAULT,i?n.ANYCAST:n.DEFAULT),[Ye.ANYCAST]:()=>(je=Ye.DEFAULT,n.ANYCAST="",n.DEFAULT)}[je](),{isBinary:e})}(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:At,reason:bt}),console.warn(Ct+" reconnect failed: ",e)}}})}_addEventListeners(){var e;null!=(e=this._socketAdapter)&&e.on("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.on("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.on("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.on("error",this._onError,this),null!=(e=this._socketAdapter)&&e.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e;null!=(e=this._socketAdapter)&&e.off("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.off("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.off("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.off("error",this._onError,this),null!=(e=this._socketAdapter)&&e.off("sendFail",this._onSendFail,this)}_onClose(e){var{socketId:e,event:t}=e||{},s=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,s=`${Ct} onClose closeSocketID: ${e} currentSocketID: ${this._connectionId} connectionDuration: ${s} code:${null==t?void 0:t.code} reason:`+(null==t?void 0:t.reason);this._ssoLog({method:"onClose",message:s}),console.warn(s),e===this._connectionId&&this._handleConnectStateChange({state:At,reason:kt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){var{socketId:e,error:t}=e||{},t=`${Ct} onError sourceSocketID: ${e} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+JSON.stringify(t);this._ssoLog({method:"onError",message:t}),console.warn(t),e===this._connectionId&&this._handleConnectStateChange({state:At,reason:Pt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){var{socketId:e,error:t}=e||{},t=`${Ct} onSendFail sendFailSocketId: ${e} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+t;this._ssoLog({method:"onSendFail",message:t}),console.warn(t),e===this._connectionId&&this._handleConnectStateChange({state:At,reason:wt}),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(t){let s,e;this._updateHeartbeatTime();try{s=this._isBinarySupported?(this._isCompressedData(t.data)?e=>{var t=new Uint8Array(e).slice(4);let s;try{s=Bt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s}:function(e){var i=new Uint8Array(e);let o="",r=0;for(var a=i["length"];r<a;){let t=i[r],s=0,n=0;if(t<=127?(s=0,n=255&t):t<=223?(s=1,n=31&t):t<=239?(s=2,n=15&t):t<=244&&(s=3,n=7&t),0<a-r-s)for(let e=0;e<s;e+=1)t=i[r+e+1],n=n<<6|63&t;else n=65533,s=a-r;o+=String.fromCodePoint(n),r+=s+1}return o})(t.data):t.data,e=JSON.parse(s)}catch(s){let e=t.data;return this._ssoLog({method:"jsonParseError",message:e}),void console.error(s)}var n;e&&e.head&&({seq:t,servcmd:n}=e.head,this._pendingRequests.has(""+t+n)?this._handleRequestResponse(e):this._handlePushMessage(e))}_handleRequestResponse(e){var{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:i,ErrorCode:n=n,ErrorInfo:i=i}=(null==e?void 0:e.body)||{},t=""+t+s,{resolve:s,reject:o}=this._pendingRequests.get(t);this._pendingRequests.delete(t),n&&0!==n?(u.emitInnerEvent("error",{errorCode:n,errorInfo:i}),o({errorCode:n,errorInfo:i})):s(e.body)}_handlePushMessage(e){var t=e.head["servcmd"],{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),u.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;console.log(`${Ct}._checkPendingRequestsAndResend reConnectFlag:${this._isReconnecting} promiseMap.size:`+this._pendingRequests.size),null!=(e=this._pendingRequests)&&e.forEach((e,t)=>{var{uplinkData:s,canResend:n,resolve:i,reject:o,timeout:r}=e;if(n){this._pendingRequests.set(t,{resolve:i,reject:o,timestamp:Date.now(),uplinkData:s,timeout:r,canResend:n});let e=this._isBinarySupported?Qe(s).buffer:s;null!=(i=this._socketAdapter)&&i.send(e)}else this._pendingRequests.delete(t)})}_onConnect(e){var{socketId:e,event:t={}}=e||{},s=(this._connectionId=e,this._connectionEstablishedTime=Date.now(),Date.now()-this._connectionStartTime),s=Ct+` onConnect cost:${s} ms. socketID:${e} res:`+JSON.stringify(t);if(this._ssoLog({method:"onConnect",message:s}),console.log(s),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){let e=Ct+" reconnect success";this._ssoLog({method:"reconnectSuccess",message:e}),console.log(e),u.emitInnerEvent(ht.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:yt})}_sendAck(e){e=nt({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return h(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var e;return(null==(e=this._socketAdapter)?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return h(this,void 0,void 0,function*(){var e,t=nt({servcmd:"heartbeat.alive",data:{}});try{let e=""+t.head.seq+t.head.servcmd;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){var s=null==(e=be.get("netWorkMonitor"))?void 0:e.isNetWorkOnline,s=Ct+` sendHeartbeat failed. isNetWorkOnline:${s} error: `+t;this._ssoLog({method:"sendHeartbeatError",message:s}),console.debug(s),this._handleConnectStateChange({state:At,reason:wt})}})}_sendHeartbeatIfReady(){return h(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=P?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){var t=Ct+" networkStatusChange "+JSON.stringify(e),{isNetworkOnline:t,networkType:e}=(this._ssoLog({method:"networkStatusChange",message:t}),console.warn(t),e);t&&"none"!==e?this._handleConnectStateChange({state:yt,reason:Rt}):this._handleConnectStateChange({state:At,reason:Rt})}isPrivateNetWork(){var e=be.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){var{state:t,reason:s}=e;if(this._currentConnectState!==t){let e=`${Ct}._handleConnectStateChange from ${this._currentConnectState} to ${t} reason: `+s;this._ssoLog({method:"handleConnectStateChange",message:e}),console.log(e),this._currentConnectState=t,u.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:t}}),t===At&&u.emitInnerEvent(ht.SOCKET_DISCONNECTED),t!==At&&t!==yt||(this._resetReconnectDelay(),Xe.addTask({id:Ot,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}}_handleActivityStatusChange(e){var t=null==(t=null==(t=this._socketAdapter)?void 0:t._ws)?void 0:t.readyState,e=`${Ct} activityStatusChange ${JSON.stringify(e)} readyState: `+t;this._ssoLog({method:"activityStatusChange",message:e}),console.warn(e),3===t&&this._handleConnectStateChange({state:At,reason:Dt})}_resetReconnectDelay(){Xe.removeTask(Ot);var e=null==(e=be.get("activityMonitor"))?void 0:e.isActive;this._intendedDelay=e?Nt:1e3}_scheduleReconnectWithBackoff(){var e=null==(e=be.get("activityMonitor"))?void 0:e.isActive,e=(this._intendedDelay=e?Math.min(5e3,Math.max(Nt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay)),(new Date).toTimeString().slice(0,8)),e=Ct+`.scheduleReconnectWithBackoff timeStr: ${e} intendedDelay: `+this._intendedDelay;this._ssoLog({method:"scheduleReconnectWithBackoff",message:e}),console.log(e),this.reconnect(),Xe.updateTaskInterval(Ot,this._intendedDelay)}_ssoLog(e){var{method:e,message:t}=e;vt.createSSOLogData({method:e}).setLogInfo({message:t}).end()}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(t){h(this,void 0,void 0,function*(){var e=t.split("/")[2];if(e.startsWith("ws")){e=`https://${e}/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Ee({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseBySSO failed. error:",e)}}})}(this._url),function(t){h(this,void 0,void 0,function*(){var e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield Ee({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseByCDN failed. error:",e)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(var[e,t]of this._pendingRequests.entries()){var{reject:t,timestamp:s,timeout:n}=t;Date.now()-s>=n&&(this._pendingRequests.delete(e),3e4<=Date.now()-this._lastDiagnoseAt&&this._diagnose(),t({errorCode:_e,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;(null!=(e=be.get("instance"))&&e.devMode||(e=de(),w)||M&&"windows"===e||P)&&(this._isBinarySupported=!1)}_isCompressedData(e){e=new Uint8Array(e);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};let Vt={init:function(e){be.set("instance",e),xt.init()},destroy:function(){xt.dispose(),be.clear(),Xe.dispose()},notificationCenter:u,channel:xt,store:be,ssoLog:vt,utils:me,common:lt,constants:i};!function(e){e.SDK_READY="sdkStateReady",e.SDK_NOT_READY="sdkStateNotReady",e.SDK_DESTROY="sdkDestroy",e.MESSAGE_RECEIVED="onMessageReceived",e.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",e.MESSAGE_MODIFIED="onMessageModified",e.MESSAGE_REVOKED="onMessageRevoked",e.MESSAGE_READ_BY_PEER="onMessageReadByPeer",e.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",e.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",e.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",e.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",e.CONVERSATION_LIST_UPDATED="onConversationListUpdated",e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",e.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",e.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",e.GROUP_LIST_UPDATED="onGroupListUpdated",e.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",e.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",e.TOPIC_CREATED="onTopicCreated",e.TOPIC_DELETED="onTopicDeleted",e.TOPIC_UPDATED="onTopicUpdated",e.PROFILE_UPDATED="onProfileUpdated",e.USER_STATUS_UPDATED="onUserStatusUpdated",e.BLACKLIST_UPDATED="blacklistUpdated",e.FRIEND_LIST_UPDATED="onFriendListUpdated",e.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",e.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",e.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",e.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",e.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",e.KICKED_OUT="kickedOut",e.ERROR="error",e.NET_STATE_CHANGE="netStateChange",e.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated"}($t=$t||{});var qt,Wt=$t;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated",e.TOPIC_MESSAGE_DELETED="topic_message_deleted",e.TOPIC_MESSAGE_REVOKED="topic_message_revoked",e.TOPIC_MESSAGE_MODIFIED="topic_message_modified",e.TOPIC_NEW_MESSAGE="topic_new_message",e.QUALITY_STAT="quality_stat"}(qt=qt||{});var Yt,Zt,Kt=qt,jt=(!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(Yt=Yt||{}),Yt);let Ht=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),zt={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"},Jt=(!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(Zt=Zt||{}),{modify:Kt.MESSAGE_MODIFIED,delete:Kt.MESSAGE_DELETED,revoke:Kt.MESSAGE_REVOKED}),Xt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},zt),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:Zt}),Qt={[Jt.modify]:Kt.TOPIC_MESSAGE_MODIFIED,[Jt.delete]:Kt.TOPIC_MESSAGE_DELETED,[Jt.revoke]:Kt.TOPIC_MESSAGE_REVOKED},es={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},ts=Object.assign({},es),ss={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},ns=Object.assign(Object.assign(Object.assign(Object.assign({},ss),{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}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),os=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{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"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{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"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),is={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},rs={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},as=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},is),{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}),{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"}),{GROUP_ID_PREFIX:rs}),cs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ht),Xt),ts),ns),os),as),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),ls={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,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,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},ds={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},us={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message"},_s={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report"},hs={[us.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:_s.USER_STATUS_UPDATE},{stepId:_s.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.CONVERSATION_RECOVER},{stepId:_s.HISTORY_MESSAGE_RECOVER,dependency:_s.CONVERSATION_RECOVER},{stepId:_s.BLACKLIST_RECOVER},{stepId:_s.FRIEND_RECOVER},{stepId:_s.GROUP_REVOKED_NOTICE_RECOVER},{stepId:_s.TOPIC_REQUEST_INFO_RESET},{stepId:_s.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[_s.UNREAD_MESSAGE_SYNC,_s.CONVERSATION_RECOVER]},{stepId:_s.EMIT_C2C_MESSAGE_EVENT,dependency:[_s.UNREAD_MESSAGE_SYNC,_s.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[us.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:_s.COMMERCIAL_CONFIG_UPDATE},{stepId:_s.CLOUD_CONFIG_SYNC},{stepId:_s.USER_PROFILE_SYNC},{stepId:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.FRIEND_AND_BLACKLIST_SYNC},{stepId:_s.GROUP_LIST_SYNC},{stepId:_s.CONVERSATION_LIST_SYNC},{stepId:_s.SIGNALING_MESSAGE_RECOVER,dependency:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[_s.UNREAD_MESSAGE_SYNC]},{stepId:_s.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[_s.UNREAD_MESSAGE_SYNC,_s.CONVERSATION_LIST_SYNC]},{stepId:_s.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[_s.GROUP_LIST_SYNC,_s.CONVERSATION_LIST_SYNC]},{stepId:_s.CONVERSATION_GROUP_LIST_SYNC},{stepId:_s.CONVERSATION_GROUP_UPDATE,dependency:[_s.CONVERSATION_LIST_SYNC,_s.CONVERSATION_GROUP_LIST_SYNC]},{stepId:_s.QUALITY_REPORT}],[us.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:_s.HANDLE_C2C_NEW_MESSAGE},{stepId:_s.UNREAD_MESSAGE_SYNC},{stepId:_s.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:_s.HANDLE_C2C_NEW_MESSAGE},{stepId:_s.EMIT_C2C_MESSAGE_EVENT,dependency:[_s.HANDLE_C2C_NEW_MESSAGE,_s.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:_s.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[_s.UNREAD_MESSAGE_SYNC]}],[us.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:_s.HANDLE_GROUP_NEW_MESSAGE},{stepId:_s.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:_s.HANDLE_GROUP_NEW_MESSAGE},{stepId:_s.UPDATE_GROUP_NEXT_SEQUENCE,dependency:_s.HANDLE_GROUP_NEW_MESSAGE},{stepId:_s.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:_s.HANDLE_GROUP_NEW_MESSAGE},{stepId:_s.EMIT_GROUP_MESSAGE_EVENT,dependency:[_s.HANDLE_GROUP_NEW_MESSAGE,_s.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}]},gs={REACT:"atomicx_react",VUE3:"atomicx_vue3"},Es={[gs.REACT+"_web"]:40,[gs.REACT+"_h5"]:41,[gs.VUE3+"_web"]:42,[gs.VUE3+"_h5"]:43},fs={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},ps={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"};var Ss=Object.freeze({__proto__:null,ERROR_CODE:ls,InnerEvent:Kt,OuterConstant:cs,OuterEvent:Wt,QUALITY_METRICS:fs,SDK_EDITION:ds,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:ps,SignalingEvent:jt,UIKIT_PREFIX:gs,UI_PLATFORM:Es,WORKFLOW_DEFINITIONS:hs,WORKFLOW_NAME:us,WORKFLOW_STEP:_s});function ms(t){var s;try{var n=be.getStorage("errorMessage");if(!t||!n)return"";var i=(null==(s=JSON.parse(n))?void 0:s.errorMessage)||{},{isIntl:o=!1,code:r,replacement1:a="",replacement2:l=""}=t;if(!r)return"";var c=o?r+"_en":r+"_cn";let e=i[i[c]?c:r]||"";return e=e&&(a&&(e=e.replace("$replacement1",a)),l)?e.replace("$replacement2",l):e}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class vs extends Error{constructor(e){var{functionName:t="Unknown",code:s,message:n="",data:i=""}=e;let o=n;s&&!n&&(o=ms(e));n=s?`${t} failed. error: {"message": ${o}, "code": ${s}}`:`${t} failed. error: {"message": ${o}}`;super(),this.code=s,this.errorCode=s,this.errorMessage=n,this.message=n,this.data=i}}function Is(e,t){if(e&&!0!==(null==(e=Vt.store.get("login"))?void 0:e.isLoggedIn))throw new vs({code:ls.USER_NOT_LOGGED_IN,functionName:t})}let Cs=e=>"function"==typeof e;function Ts(t,s,n){let i=n||[];var e,o;return!(!t||!s)&&(e=Object.keys(t).filter(e=>!i.includes(e)),o=Object.keys(s).filter(e=>!i.includes(e)),e.length===o.length)&&e.every(e=>!!s.hasOwnProperty(e)&&("object"==typeof t[e]&&null!==t[e]?Ts(t[e],s[e],n):t[e]===s[e]))}function Os(t,s,n){if(Array.isArray(t))for(let e=0;e<t.length;e++)ys.call(this,Object.assign(Object.assign({},t[e]),{value:s[e],name:n}));else for(var e in t)ys.call(this,Object.assign(Object.assign({},t[e]),{value:s[0][e],name:n,key:e}))}function ys({required:e,rules:n,value:t,allowEmpty:i,name:o,key:r,customValidator:a}){if(void 0===t){if(e)throw new vs({functionName:o,message:`[${o}] Missing required params: "${r}"`})}else{let s="";if(!n.some(e=>{return e===Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()})){for(let t=0;t<n.length;t++){let e=n[t];e=e.replace(e[0],e[0].toUpperCase()),s+=e+"/"}let e=`[${r}] must be type of ${s=s.substring(0,s.length-1)}, received type: ${Reflect.apply(Object.prototype.toString,t,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new vs({functionName:o,message:e})}if(!1===i){if(Array.isArray(t)&&(0===t.length||"string"==typeof t[0]&&""===t[0].trim()))throw new vs({functionName:o,message:r+" can not be empty."});if("string"==typeof t&&""===t.trim())throw new vs({functionName:o,message:r+" can not be empty."})}if(a&&"function"==typeof a){let e=a(t);if(!0!==e)throw new vs({functionName:o,message:`[${r}] custom validation failed: `+(e||"Invalid value")})}}}let Ms=[],As={},Ns={};function Rs(e,t){var s;Is(As[e],e),Os(Ns[e],t,e),s=e,Ms.forEach(e=>{var{interceptor:e,context:t}=e;e.apply(t,[s])})}function Ds(e,t){Ms.push({interceptor:e,context:t})}function ws(e){var{params:e,auth:t}=e;e&&"object"==typeof e&&Object.assign(Ns,e),t&&"object"==typeof t&&Object.assign(As,t)}var bs=new class{constructor(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}_installPlugin(e,t){var s=[];let n=(s=p(e)?e:[e]).findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=-1<n?s.splice(n,1):[];s.forEach(e=>{t.has(e)||(e&&Cs(e.install)?(t.add(e),Cs(e.getInstalledSubPlugins)?e.install(Fn(),i):e.install(Fn()),Cs(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):Cs(e)?(t.add(e),e(Fn()),Cs(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isLoggedIn(){var e;return!0===(null==(e=Vt.store.get("login"))?void 0:e.isLoggedIn)}};function Ps(e){return Vt.store.get("commercialConfig").get(e)}let ks=new Map;var Ls=new class{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{var s=Date.now();t?(this._stepStartTimes.set(e+"-"+t,s),console.log(`[Workflow ${e}] Step ${t} started at `+new Date(s).toISOString())):(this._workflowStartTimes.set(e,s),console.log(`[Workflow ${e}] started at `+new Date(s).toISOString()))},success:(s,e)=>{var n=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?n-t:0;this._stepStartTimes.delete(s+"-"+e),console.log(`[Workflow ${s}] Step ${e} completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}else{let e=this._workflowStartTimes.get(s),t=e?n-e:0;this._workflowStartTimes.delete(s),console.log(`[Workflow ${s}] completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}},error:(s,e,n)=>{var i=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?i-t:0;this._stepStartTimes.delete(s+"-"+e),console.error(`[Workflow ${s}] Step ${e} failed at ${new Date(i).toISOString()} (${t}ms)`,n)}else{let e=this._workflowStartTimes.get(s),t=e?i-e:0;this._workflowStartTimes.delete(s),console.error(`[Workflow ${s}] failed at ${new Date(i).toISOString()} (${t}ms)`,n)}}}}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){this._handlers.has(e)?hs[e].find(e=>e.stepId===t)?this._handlers.get(e).set(t,n?s.bind(n):s):console.debug(`Step '${t}' not defined in workflow '${e}'`):console.debug(`Workflow '${e}' not defined in core`)}executeWorkflow(r,s){return h(this,void 0,void 0,function*(){if(this._validateWorkflow(r)){console.log(`[Workflow ${r}] Started execution at `+(new Date).toISOString());let e=hs[r],o={cancelled:!1};this._activeWorkflows.set(r,{cancelToken:o});try{let t=new Map,i=(e.forEach(e=>{t.set(e.stepId,e)}),{workflowName:r,pendingSteps:new Set(e.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:t,stepResults:{},data:s,cancelToken:o});yield new Promise((t,s)=>{let n=()=>{o.cancelled?t():this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).forEach(e=>{i.completedSteps.has(e)||i.runningSteps.has(e)||this._executeWorkflowStep(e,i,{onComplete:()=>{0===i.pendingSteps.size?t():0===this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).length&&0===i.runningSteps.size&&(console.log(`Workflow ${r} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})})};n()}),console.log(`[Workflow ${r}] Completed execution at `+(new Date).toISOString())}catch(e){console.error(`[Workflow ${r}] Failed execution at `+(new Date).toISOString(),e)}finally{this._activeWorkflows.delete(r)}}})}_executeWorkflowStep(a,l,c){return h(this,void 0,void 0,function*(){let{workflowName:o,runningSteps:e,stepMap:s,stepResults:n,data:i}=l;e.add(a),this._logWorkflowExecution(o,a,"start");try{let e=s.get(a),t=null;null!=e&&e.dependency&&(E(e.dependency)?t=n[e.dependency]:Array.isArray(e.dependency)&&(t={},e.dependency.forEach(e=>{t[e]=n[e]})));var r=this._handlers.get(o).get(a);if(r){let e=yield Promise.resolve(r({data:i,result:t}));n[a]=e,this._logWorkflowExecution(o,a,"success")}l.completedSteps.add(a)}catch(e){let t=`[Workflow].${o}.`+a,{errorCode:s,errorInfo:n=t+" failed"}=e||{},i=new vs({functionName:t,code:s,message:n});Vt.ssoLog.createSSOLogData({method:"Workflow"}).setLogInfo({message:`workflowName: ${o}, stepId: `+a}).setError(i).end(),this._logWorkflowExecution(o,a,"error",e),c.onError(e)}finally{e.delete(a),l.pendingSteps.delete(a),c.onStepComplete(),c.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(hs).forEach(e=>{this._handlers.set(e,new Map)})}_cancelWorkFlow(e){var t=this._activeWorkflows.get(e);t&&(t=t["cancelToken"],t.cancelled=!0,this._activeWorkflows.delete(e))}_cancelAllWorkflows(){Object.keys(hs).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return hs[e]?!!this._handlers.get(e)||(console.debug(`No handlers registered for workflow '${e}'`),!1):(console.debug(`Workflow '${e}' not defined`),!1)}_getExecutableSteps(e){let{pendingSteps:t,completedSteps:s,stepMap:n,workflowName:i}=e;return Array.from(t).filter(e=>{var{dependency:t,skipIfDependencyMissing:e=!0}=n.get(e)||{};if(!t)return!0;if(E(t))return this._isStepRegistered({workflowName:i,stepId:t})?s.has(t):!e;if(p(t)){if(0<t.filter(e=>!this._isStepRegistered({workflowName:i,stepId:e})).length&&e)return!1;for(let e of t)if(!s.has(e))return!1;return!0}return!1})}_isStepRegistered(e){var{workflowName:e,stepId:t}=e;return null==(e=this._handlers.get(e))?void 0:e.has(t)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}};let Us=({type:e,groupID:t})=>e===cs.GRP_COMMUNITY||(""+t).startsWith(rs.COMMUNITY)&&!(""+t).includes(rs.TOPIC),Gs=(e="")=>{e=e.startsWith("GROUP")?e.replace("GROUP",""):e;return e.startsWith(rs.COMMUNITY)&&(""+e).includes(rs.TOPIC)},Fs="openim",Bs="million_group_open_http_svc";function xs(s){return h(this,void 0,void 0,function*(){var{servcmd:e,data:t}=Vs(e=s.data)||$s(e)?function(e){let{servcmd:t,data:s}=e;var n,i,o;return $s(s)?({servcmd:e,data:n}=e,{GroupId:i=""}=n,[i]=(o=i).split(rs.TOPIC),{servcmd:qs(e),data:Object.assign(Object.assign({},n),{GroupId:i,TopicId:o})}):{servcmd:t=Vs(s)?qs(t):t,data:s}}(s):s,t=Vt.common.generateProtocolData({servcmd:e,data:t}),e=""+t.head.seq+e;return Vt.channel.sendPacket(t,{requestId:e})})}function Vs(e){var{Type:e,GroupId:t,GroupIdList:s=[]}=e,t=t||s[0]||"";return Us({type:e,groupID:t})}function $s(e){var{GroupId:e=""}=e;return Gs(e)}function qs(e){return e.includes(Fs)?e:(e=e.split(".")[1],Bs+"."+e)}function Ws(){var e;return null==(e=Vt.store.get("login"))?void 0:e.userId}let Ys=e=>p(e)||S(e),Ks=(s,n,i,o)=>{if(!Ys(s)||!Ys(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(Ys(s[a])&&Ys(n[a]))r+=Ks(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r},js=(e,t)=>{if(g(t))return"";switch(e){case cs.MSG_TEXT:return t.text||"";case cs.MSG_IMAGE:return"[Image]";case cs.MSG_LOCATION:return"[Location]";case cs.MSG_AUDIO:return"[Voice]";case cs.MSG_VIDEO:return"[Video]";case cs.MSG_FILE:return"[File]";case cs.MSG_CUSTOM:return"[Custom Messages]";case cs.MSG_GRP_TIP:return"[Group Notification]";case cs.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case cs.MSG_FACE:return"[Animated Sticker]";case cs.MSG_MERGER:return"[Chat Record]";default:return""}},Hs=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_members",interval:3,count:1},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],zs="im_sdk_config_mgr.fetch_config",Zs="im_sdk_config_mgr.push_configv2",Js="cloud-config",Xs=2996;var Qs=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){var{notificationCenter:e,InnerEvent:t,helper:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i},channel:o}=this._core=e;e.subscribeInnerEvent(Zs,this._handlePushedConfig,this),s.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Hs),o.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(e){var t,s={code:0,data:""};return e&&(s.data=(null==(t=this._core.store.get("cloudConfig"))?void 0:t[e])||""),s}checkMethodCallOverLimit(e){if(this._cmdFrequencyLimitMap.has(e))if(this._methodCallFrequencyMap.has(e)){var{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e),{startTime:n,methodCallCounter:i}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:i+=1}),t<i)throw new this._core.helper.ChatError({code:Xs,replacement1:e})}else this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1})}_fetchCloudConfig(){return h(this,void 0,void 0,function*(){try{var e=(this._core.store.get("instance")||{})["sdkAppId"],t=this._core.helper.generateProtocolData({servcmd:zs,data:{uint32_sdkappid:e,uint64_version:this._version}}),s=""+t.head.seq+zs;return yield this._core.channel.sendPacket(t,{requestId:s})}catch(e){throw console.warn("fetch cloudControl fail: ",e),e}})}_handlePushedConfig(e){this._updateCloudConfig(e)}_handleLoginSuccess(){return h(this,void 0,void 0,function*(){try{var e;this._canFetch()&&(e=yield this._fetchCloudConfig(),this._updateCloudConfig(e)),this._core.helper.taskScheduler.addTask({id:Js,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){console.warn(e)}})}_fetchCloudConfigIfReady(){return h(this,void 0,void 0,function*(){if(this._canFetch())try{var e=yield this._fetchCloudConfig();this._updateCloudConfig(e)}catch(e){console.warn(e)}})}_updateCloudConfig(e){e=this._parseCloudConfig(e);e&&(this._core.store.set("cloudConfig",e),this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e))}_canFetch(){var e=(this._core.store.get("login")||{})["isLoggedIn"];return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){var{int32_error_code:t,str_json_config:s,uint32_expired_time:n,uint64_version:i}=e;let o=null;if(0===t){if(this._version!==i)try{o=JSON.parse(s),this._version=i}catch(e){}this._expirationTime=Date.now()+1e3*n}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return o}_parseCmdFreqLimit(){var e,t=null==(e=this.getServerConfig("cmd_frequency_limit"))?void 0:e.data,s=this._core.utils["isEmpty"];if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(Js),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Hs),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(Zs,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class en{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let tn={SEARCH_GRP_SNS:new en(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new en(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new en(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new en(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new en(0,Math.pow(2,6)).toString(),USER_STATUS:new en(0,Math.pow(2,7)).toString(),CONV_MARK:new en(0,Math.pow(2,9)).toString(),CONV_GROUP:new en(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new en(0,Math.pow(2,11)).toString(),MSG_EXT:new en(0,Math.pow(2,13)).toString(),GRP_COUNTER:new en(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new en(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new en(Math.pow(2,7)).toString(),PLUGIN_CS:new en(Math.pow(2,8)).toString(),PLUGIN_PUSH:new en(Math.pow(2,9)).toString(),PLUGIN_BOT:new en(Math.pow(2,10)).toString(),MSG_REACTION:new en(Math.pow(2,16)).toString(),FOLLOW:new en(Math.pow(2,20)).toString()},sn="CommercialConfig",nn="commercial-config";var ln,dn,on=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map}install(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i,InnerEvent:o}}=this._core=e;s.subscribeInnerEvent(o.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(o.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(o.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this)}isCommercialAbilityEnabled(e){return h(this,void 0,void 0,function*(){var s=parseInt(e,10).toString(2),n=s["length"];let i,o=!0;for(let e=n-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(i=(t<32?new en(0,2**t):new en(2**(t-32),0)).toString(),!this._featureMap.get(i))){o=!1;break}return console.log(`${sn}.isFeatureEnabled decimalNumber:${e} key:${i} ret:`+o),{code:0,data:{enabled:o}}})}_fetchAndParseCommercialConfig(){return h(this,void 0,void 0,function*(){var e;try{this._isFetching=!0;var t=this._core.helper.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null==(e=this._core.store.get("instance"))?void 0:e.sdkAppId}}),s=yield this._core.channel.sendPacket(t);null!=s&&s.body&&(this._parseCommercialConfig(s.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(e){console.warn("fetch commercial fail: ",e)}finally{this._isFetching=!1}})}_syncCommercialConfig(t){return h(this,void 0,void 0,function*(){var e=((null==t?void 0:t.data)||{})["purchaseBits"];e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:nn,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var e=null==(e=this._core.store.get("login"))?void 0:e.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(e){null!=e&&e.body&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return h(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){var t,s,n,i;"object"==typeof e&&({int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:i}=e,0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*i):void 0===t?(console.log(sn+"._parseCommercialConfig failed. Invalid message format:",e),this._expirationTime=Date.now()+36e5):(console.error(sn+`._parseCommercialConfig errorCode:${t} errorMessage:`+s),this._expirationTime=Date.now()+12e4))}_isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(s){if(this._isValidPurchaseBits(s)){this._featureMap.clear(),this._methodKeyMap.clear();var n;for(let e=s.length-1,t=0;0<=e;e--,t++)if(n=(t<32?new en(0,2**t):new en(2**(t-32),0)).toString(),"1"===s[e]){this._featureMap.set(n,!0);let e=this._getKeyByValue(tn,n);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(n,!1);let e=this._getKeyByValue(tn,n);e&&this._methodKeyMap.set(e,!1)}}else console.warn(sn+".parsePurchaseBits invalid purchases:"+s)}_getKeyByValue(e,t){e=Object.entries(e).find(([,e])=>e===t);return e?e[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(nn),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear()}},rn=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;var{notificationCenter:e,InnerEvent:t,channel:s}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(this._serverOverloadInfoMap.has(e)){var{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}}_handleOverLoadPush(e){var{OverLoadServCmd:e,DelaySecs:t}=e;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}},an=new class{constructor(){this._core=null}install(e){return h(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){let e=yield this._fetchErrorMessage();var t;e&&(t=this._parseResponse(e),this._saveErrorMessage(t))}})}_canFetch(){var e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return h(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}})}_isExpired(e){return!e||(e=e["errorMessageSavedTime"],e&&6048e5<=(new Date).getTime()-e)}_parseResponse(e){if("string"==typeof e){var s=e.split(";\n"),n={},i=new RegExp(/'/g);for(let t=0;t<s.length;t++){var o=s[t].indexOf(":"),r=s[t].slice(0,o);let e=s[t].slice(o+1);r.startsWith("//")||""!==e&&(e=e.replace(i,""),n[r]=e)}return n}}};function cn(i,l){return h(this,void 0,void 0,function*(){let{cookie:e,syncFlag:t,syncTriggerEvent:s}=i,n="openim.getmsg",r=l.helper.generateProtocolData({servcmd:n,data:{Cookie:e,SyncFlag:t,IsOnlineSync:s,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=""+r.head.seq+n;try{let e=yield l.channel.sendPacket(r,{requestId:a});if(!e)return null;let{C2CPairUnreadCount:t,C2CRemainingUnreadCount:s,EventArray:n}=e,{unreadMessageList:i,revokedMessageList:o}=function(e,v){let n=[],i=[];return null!=e&&e.forEach(m=>{var e,t,s=function(){var{From_Account:e,From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:d,To_Account:_,TinyId:u,MsgCheckResult:h,CloudCustomData:g,IsPeerRead:E,MsgFlagBits:p,MsgVersion:f,EventArray:S}=m;return{from:e,avatar:t,nick:s,needReadReceipt:1===n,readReceiptSentByPeer:E,clientTime:o,messageFlagBits:p,random:r,sequence:a,time:l,messageControlInfo:c,isSupportExtension:d,to:_,tinyID:u,checkResult:h,cloudCustomData:g,messageVersion:f,eventArray:S,elements:v.message.messageHelper.parseServerPushMessageElement(i)}}();if(null!=(t=null==(e=null==(e=null==m?void 0:m.EventArray)?void 0:e[0])?void 0:e.hasOwnProperty)&&t.call(e,"C2cNotifyMsgArray"))i.push(...function(){let e,t=[];return null!=(e=m.EventArray)&&e.forEach(e=>{var e=e["C2cNotifyMsgArray"],e=null==(e=null==(e=null==e?void 0:e[0])?void 0:e.WithdrawC2cMsgNotify)?void 0:e.C2cWithdrawInfoArray;Array.isArray(e)&&t.push(...e)}),t}());else{let e=v.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),t=s["elements"];e.setElement(t),n.push(e)}}),{unreadMessageList:n,revokedMessageList:i}}(e.MsgList,l);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:o,unreadCountList:t,overflowUnreadCountList:s,cookie:null==e?void 0:e.Cookie,groupTipList:n}}catch(e){console.warn(e)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(ln=ln||{}),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(dn=dn||{});var un=new class{constructor(){this._unreadDBMessageMap=new Map,this._cookie=""}install(e){var t=(this._core=e)["constants"];e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(t){return h(this,void 0,void 0,function*(){let{isAfterReOnline:r=!1,isAfterNewMessageReceived:a=!1,isAfterLogin:e=!1}=t||{},l=ln.START_SYNC;for(var c=[],d=[],_=[],u=[];this._canContinueSync({cookie:this._cookie,syncFlag:l});){let e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:l,syncTriggerEvent:a?dn.NEW_MESSAGE_RECEIVED:dn.LOGIN_SUCCESS});if(!e)break;let{unreadMessageList:t=[],revokedMessageList:s=[],overflowUnreadCountList:n,unreadCountList:i,groupTipList:o}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",l=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(t),_.push(...s),this._updateConversationUnreadOptions({unreadCountList:i,overflowUnreadCountList:n,conversationUpdateFieldList:c}),Array.isArray(o)&&d.push(...o),r){let e=this._handleNewMessageList(t)["messages"];u.push(...e)}}return r?{conversationUpdateFieldList:c,revokedMessageList:_,unreadMessageMap:this._unreadDBMessageMap,groupTipList:d,messages:u}:{conversationUpdateFieldList:c,isInstantMessage:!e,isUnreadC2CMessage:!0,revokedMessageList:_,unreadMessageMap:this._unreadDBMessageMap,groupTipList:d}})}_syncUnreadDBMessageAfterLogin(){return h(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return h(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(e){let{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{OuterConstant:{CONV_C2C:i,CONV_SYSTEM:o}}=this._core["constants"];null!=t&&t.forEach(e=>{let{From_Account:t,UnreadCount:s}=e;if(t!==o){let e=n.find(({conversationID:e})=>e===""+i+t);e?e.unreadCount=s:n.push({conversationID:""+i+t,unreadCount:s,type:i})}}),null!=s&&s.forEach(e=>{let{From_Account:t,LastMsgTime:s}=e;t===o||n.find(({conversationID:e})=>e===""+i+t)||n.push({conversationID:""+i+t,type:i,lastMsgTime:s})})}_syncUnreadDBMessageAfterReOnline(){return h(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(n){var e;let i=(this._core.message||{})["messageDataHandler"],t=null==(e=this._core.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;o&&r?o===e&&r===t||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}):(n.nick=e,n.avatar=t)}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_handleNewMessageList(e){let t=(this._core.message||{})["messageDataHandler"],l=new Map,s=[];return e.forEach(a=>{this._updateMessageProfile(a);let e=1===a.isModified;if(t.isMessageSentByCurrentInstance(a)?a.isModified=e:e=!1,a.isOnlineMessage())a._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(a)||s.push(a);else if(!t.isInMessageList(a)){if(t.storeConversationMessage(a)){let{conversationID:e,conversationType:t,conversationSubType:s,flow:n,_isExcludedFromUnreadCount:i,_isExcludedFromLastMessage:o}=a,r=o?"":a;l.has(e)?(l.get(e).lastMessage=r,"in"!==n||i||l.get(e).unreadCount++):l.set(e,{conversationID:e,type:t,subType:s,unreadCount:i||"in"!==n?0:1,lastMessage:r})}t.isMessageSentByCurrentInstance(a)&&!e||s.push(a)}}),{messages:s,conversationOptions:l}}_fetchUnreadDBMessage(l){return h(this,void 0,void 0,function*(){try{console.log("unread-message-synchronizer._fetchUnreadDBMessage options:",l);var e,t,s,n,i,o,r,a=yield cn(l,this._core);return a?({syncFlag:e,unreadMessageList:t,revokedMessageList:s,cookie:n,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}=a,this._parseAndSaveUnreadMessageList(t),{syncFlag:e,cookie:n,unreadMessageList:t,revokedMessageList:s,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}):null}catch(e){console.log(e)}})}_canContinueSync({cookie:e,syncFlag:t}){return t===ln.START_SYNC||t===ln.SYNCING&&!(null!=(t=this._core)&&t.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach(e=>{var t=e["ID"];this._unreadDBMessageMap.set(t,e)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},_n=new class{init(e){this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),document.addEventListener("visibilitychange",this._visibilityChangeHandler),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t="visible"===document.visibilityState;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:t}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},hn=new class{init(e){this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var e=((null==(e=this._core)?void 0:e.utils)||{})["MINI_APP_NAMESPACE"];e.onAppShow(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),e.onAppHide(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},gn=new class{init(e){var{IN_WX_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?hn:_n).init(e)}};let En="none",fn="online";var pn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:fn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:En})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Sn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){try{this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),wx.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}_deactivateNetworkMonitoring(){null!==this._mpNetworkStatusCallback&&(wx.offNetworkStatusChange&&wx.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},mn=new class{init(e){var t=e.helper["IN_WX_MINI_APP"];(t?Sn:pn).init(e)}},vn=new class{install(e){gn.init(e),mn.init(e)}};let In=new Set(["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.*"]),Cn="tui_room_svr.*";var Tn=new class{constructor(){this._transferredCommands=In}install(e){var{notificationCenter:e,InnerEvent:t,helper:s}=this._core=e;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),s.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),s.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(s){return h(this,void 0,void 0,function*(){var t="transferBusinessCommand";try{var{serviceCommand:e=Cn}=s||{};if(this._isValidTransferredCommand(e))return{code:0,data:(yield function(o,r){return h(this,void 0,void 0,function*(){var{helper:e,channel:t}=r,{serviceCommand:s=Cn,data:n}=o||{};let i={};try{i="string"==typeof n?JSON.parse(n):n}catch(e){console.warn(e)}n=e.generateProtocolData({servcmd:s,data:i}),e=""+n.head.seq+s;return t.sendPacket(n,{requestId:e})})}(s,this._core))||{}};throw new this._core.helper.ChatError({code:2995,functionName:t})}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}})}_onCloudConfigUpdate(e={}){try{var t;"string"==typeof e.rtc_cmd&&(t=JSON.parse(e.rtc_cmd),Array.isArray(t))&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){e=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(e){var{OuterEvent:t,notificationCenter:s}=this._core,e=(e||{})["MsgContent"],t=t["ROOM_CUSTOM_DATA_RECEIVED"];s.emitOuterEvent(t,{name:t,data:e})}_reset(){this._transferredCommands=In}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let On=ds.STANDARD,yn=[],Mn=[an,function(e){Qs.install(e),on.install(e),rn.install(e)},un,vn,Tn];On=ds.BASIC,yn=Mn;var Bn,xn,Vn,oo,io,ro,uo,An=Object.freeze({__proto__:null,ChatError:vs,buildAndSendPacket:xs,get builtInPlugins(){return yn},checkBusinessCapabilityBits:Ps,deepMerge:Ks,getCurrentUserID:Ws,getErrorMessage:ms,getMessagePreviewText:js,isC2CConv:e=>E(e)&&e.slice(0,3)===ss.CONV_C2C,isCommunity:Us,isGroupConv:e=>E(e)&&e.slice(0,5)===ss.CONV_GROUP,isTopic:Gs,isUnlimitedAVChatRoom:function(){var e;return!(null==(e=Vt.store.get("instance"))||!e.unlimitedAVChatRoom)},liteChatInstanceMap:ks,registerInterceptor:Ds,registerValidateConfig:ws,requireAuth:Is,get sdkEdition(){return On},updateGroupAtInfo:(t,s)=>{var{CONV_AT_ME:n,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:o}=cs;if(!function(t,e){let{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:i}=cs,{groupID:o,sequence:r}=t,a=!1;return Us({groupID:o})&&e.forEach(e=>{e.messageSequence===r&&(e.atTypeArray.includes(s)&&t.groupAtType.includes(n)&&(e.atTypeArray=[i]),e.atTypeArray.includes(n)&&t.groupAtType.includes(s)&&(e.atTypeArray=[i],e.__random=t.__random,e.__sequence=t.__sequence),a=!0)}),a}(t,s)){let e=[...t.groupAtType];e.includes(n)&&e.includes(i)&&(e=[o]);n={from:t.from,groupID:t.groupID,topicID:t.topicID,messageSequence:t.sequence,atTypeArray:e,__random:t.__random,__sequence:t.__sequence};s.push(n)}},validateAndExecute:Rs,validateParameters:Os,workflowManager:Ls}),Nn=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t,s={emit:!0,needSort:!1}){let{emit:n,needSort:i}=s,o=this._conversationMap.get(e);o&&!fe(t)&&(Object.keys(t).forEach(e=>{o[e]=t[e]}),n)&&Vt.notificationCenter.emitInnerEvent(Kt.CONVERSATION_UPDATED,{needSort:i})}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),Vt.notificationCenter.emitInnerEvent(Kt.CONVERSATION_UPDATED))}},Rn=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){let s=this._groupMap.get(e);s&&!fe(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},Dn=new class{constructor(){this._messagesByConversation=new Map}updateMessage(s,t,e){let n,{operation:i,updateUnreadCount:o=!0}=e,r=_(e,["operation","updateUnreadCount"]),a=[];for(let e of t){let t=null==(n=this._messagesByConversation.get(s))?void 0:n.get(e);if(!t)return!1;Object.keys(r).forEach(e=>{t[e]=r[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(i,{conversationID:s,messageList:a,updateUnreadCount:o}),a}getMessagesByConversation(e){return[...(null==(e=this._messagesByConversation.get(e))?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){var s=t["conversationID"];Gs(s)?Vt.notificationCenter.emitInnerEvent(Qt[e],t):Vt.notificationCenter.emitInnerEvent(e,t)}},wn=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},bn=Object.freeze({__proto__:null,conversationStore:Nn,groupStore:Rn,messageStore:Dn,userStore:wn});let Pn={on:Vt.notificationCenter.subscribeOuterEvent.bind(Vt.notificationCenter),off:Vt.notificationCenter.unSubscribeOuterEvent.bind(Vt.notificationCenter),destroy:function(){return h(this,void 0,void 0,function*(){var e,t;try{null!=(e=Vt.store.get("login"))&&e.isLogin&&(yield Pn.logout()),Vt.notificationCenter.emitInnerEvent(Kt.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{Vt.notificationCenter.emitOuterEvent(Wt.SDK_DESTROY,{SDKAppID:null==(t=Vt.store.get("instance"))?void 0:t.sdkAppId}),ks.clear(),bs.clear(),Ls.destroy(),Vt.destroy()}})},callExperimentalAPI:function(e,t){return kn[e]?kn[e](t):Promise.reject(new Error(`API ${e} is not found`))},use:bs.installExternalPlugin.bind(bs),registerPlugin:function(e){console.log("registerPlugin",e)},setLogLevel:function(e){console.log("setLogLevel",e),!Vt||"function"!=typeof Vt.setLogLevel||null!=Vt&&Vt.setLogLevel(e)}},kn={},Ln={};function Un(e){let{apiName:n,context:t,methodName:i=n,matcher:s}=e;Ln[n]||(Ln[n]=[]),Ln[n].push({context:t,methodName:i,matcher:s}),Pn[n]&&1!==Ln[n].length||(Pn[n]=(...t)=>{Rs(i,t);var s=Ln[n];for(let e of s)if(!e.matcher||e.matcher(t))return e.context[e.methodName].bind(e.context)(...t)})}function Gn(e,t,s){s=s||e;kn[e]=t[s].bind(t)}function Fn(){return Object.assign(Object.assign({InnerEvent:Kt,InnerEventSubType:Vt.notificationCenter.InnerEventSubType,OuterEvent:Wt,OuterConstant:cs,SignalingEvent:jt,helper:Object.assign(Object.assign(Object.assign({},Vt.utils),Vt.common),{registerApi:Un,registerExperimentalAPI:Gn,registerInterceptor:Ds,registerValidateConfig:ws,checkBusinessCapabilityBits:Ps,registerWorkflowStep:Ls.registerWorkflowStep.bind(Ls),ChatError:vs}),apiMap:Pn},Vt),{constants:Object.assign(Object.assign({},Ss),Vt.constants),common:Object.assign(Object.assign({},An),Vt.common),utils:Vt.utils,appStore:bn})}kn.statTUIKeyFeatures=function(e){console.log("statTUIKeyFeatures",e)},function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Bn=Bn||{}),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(xn=xn||{}),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Vn=Vn||{});let $n={[xn.multipleAccount]:"multipleAccount",[xn.multipleDevice]:"multipleDevice",[xn.restApi]:"REST_API_Kick",[Vn.multipleAccount]:"multipleAccount",[Vn.multipleDevice]:"multipleDevice",[Vn.restApi]:"REST_API_Kick",[Vn.usersigExpired]:"userSigExpired"},qn="login_online_presence_task",{ERROR:Wn,DESTROY:Yn,FORCE_OFFLINE:Kn}=Kt,{KICKED_OUT_MULT_ACCOUNT:jn,KICKED_OUT_MULT_DEVICE:Hn,KICKED_OUT_REST_API:zn,ACCOUNT_A2KEY_EXPIRED:Zn,MSG_A2KEY_EXPIRED:Jn}=ls;class Xn{init(){var e=Vt["notificationCenter"];e.subscribeInnerEvent(Kn,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(Wn,Jn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Wn,Zn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Wn,jn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Wn,Hn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Wn,zn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Yn,this._dispose,this)}_handleForceOfflineFromServerPush(e){var{EventArray:e=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(e).forEach(e=>{var{KickType:e,NewInstInfo:t}=e["KickoutMsgNotify"];this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}_extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{return this._isKickedOut(null==(e=null==e?void 0:e.KickoutMsgNotify)?void 0:e.KickType)})}_handleForceOfflineFromResponse(e){e=e.errorCode;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(t){return h(this,void 0,void 0,function*(){var e=t["kickedOutReasonCode"];try{yield Vt.login.loginAction.logout(Bn.KICKED_OUT)}catch(e){console.debug(e)}finally{this._logKickedOutEvent(t),Vt.notificationCenter.emitOuterEvent(Wt.KICKED_OUT,{data:{type:$n[e]},name:Wt.KICKED_OUT}),[xn.restApi,Zn,Jn].includes(e)&&Vt.channel.reconnect()}})}_logKickedOutEvent(e){var{kickedOutReasonCode:e,newInstanceInfo:t={}}=e,s=Vt.ssoLog.createSSOLogData({method:"kickedOut"}),e=`type:${$n[e]} newInstanceInfo: `+JSON.stringify(t);s.setLogInfo({message:e}).end(!0),console.warn("loginModule."+e)}_isKickedOut(e){return[xn.multipleAccount,xn.multipleDevice,xn.restApi].includes(e)}_dispose(){var e=Vt["notificationCenter"];e.unSubscribeInnerEvent(Kn,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(Wn,Zn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Wn,Jn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Wn,jn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Wn,Hn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Wn,zn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Yn,this._dispose,this)}}function Qn(){return h(this,void 0,void 0,function*(){let e="im_open_status.wslogin",t=Vt.common.generateProtocolData({servcmd:e,data:{state:"Online",isWebUniapp:0,InstType:0,customInfo:""}}),s=""+t.head.seq+e;try{let _=yield Vt.channel.sendPacket(t,{timeout:9e4,requestId:s});if(_){let{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:o,A2Key:r,RichMsgAuthKey:a,ErrorCode:l,ErrorInfo:c,ActionStatus:d}=_;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:o,a2Key:r,authKey:a,errorCode:l,errorInfo:c,actionStatus:d}}}catch(e){throw console.warn(e),e}})}class eo{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120}init(){var{notificationCenter:e,store:t}=Vt;t.set("login",{isReady:!1}),Un({apiName:"login",context:this}),Un({apiName:"logout",context:this}),Un({apiName:"getLoginUser",context:this}),Un({apiName:"isReady",context:this}),e.subscribeInnerEvent(Kt.RECONNECTED,this._reLogin,this),Vt.notificationCenter.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}login(s){return h(this,void 0,void 0,function*(){let e=this._getUiPlatform(),t=(Vt.store.get("instance")||{})["sdkEdition"],n=Vt.ssoLog.createSSOLogData({method:"login",eventType:4,uiPlatform:e,message:t});try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new vs({functionName:"login",code:ls.REPEAT_LOGIN});let e=yield this._performLogin(s);return this._validateAfterLogin(e),this._handleLoginSuccess(e),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),{code:0,data:e}}catch(e){let t=e["errorCode"],s=new vs({functionName:"login",code:t});throw n.setError(s).end(!0),s}finally{this._latestLoginAt=0}})}_getUiPlatform(){var{store:e,utils:{IN_BROWSER:t,isH5:s}}=Vt,e=(null==(e=e.get("instance"))?void 0:e.scene)||"";let n=e;return t&&(n=e+"_web",s)&&(n=e+"_h5"),Es[n]}_reLogin(){return h(this,void 0,void 0,function*(){var e,t,s,n,i,o;try{this._isLoginIn()&&(t=Vt.ssoLog.createSSOLogData({method:"reLogin"}),s=yield Qn())&&({instanceID:n,customStatus:i}=s,Vt.store.set("login",{statusInstanceId:n}),Ls.executeWorkflow(us.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:i,statusType:es.USER_STATUS_ONLINE}),o=`socketId:${null==(e=Vt.channel.getSocketAdapter())?void 0:e.getId()} instanceId:`+n,t.setLogInfo({message:o}).end(!0))}catch(e){console.warn(e)}})}logout(){return h(this,arguments,void 0,function*(s=Bn.USER_INITIATED){let e=Vt.ssoLog.createSSOLogData({method:"logout"});e.setLogInfo({moreMessage:"identifier:"+Ws()});try{yield this._performLogout(s),e.end(!0),Vt.ssoLog.uploadSSOLogData()}catch(s){let e=s["errorCode"],t=new vs({functionName:"logout",code:e});this._handleLogoutError(t)}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?Ws():""}isReady(){var e;return null==(e=Vt.store.get("login"))?void 0:e.isReady}_updateAndEmitSDKReady(){Vt.store.set("login",{isReady:!0}),setTimeout(()=>{Vt.notificationCenter.emitOuterEvent(Wt.SDK_READY,{name:Wt.SDK_READY})},1)}_updateAndEmitSDKNotReady(){Vt.store.set("login",{isReady:!1}),Vt.notificationCenter.emitOuterEvent(Wt.SDK_NOT_READY,{name:Wt.SDK_NOT_READY})}_validateAfterLogin(e){var t,s="login";if(!e)throw new vs({functionName:s,message:"login response is empty"});var{tinyID:e,a2Key:n}=e||{},i=Vt.ssoLog.getSSOLogData(s);if(!e){let e=new vs({functionName:s,code:ls.NO_TINYID});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}if(!n){let e=new vs({functionName:s,code:ls.NO_A2KEY});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:ms({code:"RepeatLogin",replacement1:null==(e=Vt.store.get("login"))?void 0:e.userId}),repeatLogin:!0}}}_performLogin(s){return h(this,void 0,void 0,function*(){var{userID:e,userSig:t}=s;return Vt.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),Qn()})}_ensureAsyncComplete(){return h(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){var t=Vt.common["timeManager"],{helloInterval:s,timeStamp:n,customStatus:i,purchaseBits:o}=e;t.calculateTimeOffsetWithServer(this._latestLoginAt,1e3*n),this._helloInterval=s||120,this._updateLoginStore(e),Vt.user.userStatus.setCustomStatus(i),Ls.executeWorkflow(us.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:o}),Vt.common.taskScheduler.addTask({id:qn,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this}),this._logLoginSuccess(e)}_performLogout(e){return function(s){return h(this,void 0,void 0,function*(){var e=s["logoutReason"],t="im_open_status.wslogout",e=Vt.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),t=e.head.seq+t;return yield Vt.channel.sendPacket(e,{requestId:t})})}({logoutReason:e})}_handleLogoutError(e){Vt.ssoLog.getSSOLogData("logout").setError(e).end(),console.error("logout "+e)}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),Ls.reset(),Vt.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){var{a2Key:e,tinyID:t,instanceID:s,authKey:n}=e;Vt.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:s,authKey:n,isLoggedIn:!0})}_logLoginSuccess(e){var t=Vt.ssoLog.getSSOLogData("login"),{helloInterval:e,instanceID:s,timeStamp:n,customStatus:i}=e,o=null==(o=Vt.channel.getSocketAdapter())?void 0:o.getId(),r=Vt.common.timeManager.getTimeOffsetWithServer(),{appId:a,href:l}=Vt.store.get("instance")||{},o=`login._logLoginSuccess socketID:${o} scene: helloInterval:${e} instanceID:${s}
|
|
2
|
-
timeStamp:${n} offset:${r} customStatus:${i} href: ${l} appId: `+a;console.log("login ok. "+o),t.updateLogCreatedAtByTimeOffset(),t.setLogInfo({moreMessage:o}).end()}_sendOnlinePresenceRequest(){return h(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{e="im_open_status.wshello",t=Vt.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),e=t.head.seq+e,yield Vt.channel.sendPacket(t,{requestId:e})}catch(e){console.warn("Login._sendOnlinePresenceRequest error:",e)}var e,t})}_isLoginIn(){var e;return!0===(null==(e=Vt.store.get("login"))?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){console.log("Login reset"),Vt.common.taskScheduler.removeTask(qn),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,Vt.store.clear("login"),Vt.store.set("login",{isReady:!1})}_dispose(){console.log("Login dispose"),this._reset();var e=Vt["notificationCenter"];e.unSubscribeInnerEvent(Kt.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this)}}let to={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},so={logout:!0};class no{constructor(){this.loginAction=new eo,this.kickedOutHandler=new Xn,this.loginAction.init(),this.kickedOutHandler.init(),ws({auth:so,params:to})}}!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(oo=oo||{}),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(io=io||{}),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(ro=ro||{});let ao={1:io.MSG_PRIORITY_HIGH,2:io.MSG_PRIORITY_NORMAL,3:io.MSG_PRIORITY_LOW,4:io.MSG_PRIORITY_LOWEST},co=0,lo=1,_o=(!function(e){e.IN="in",e.OUT="out"}(uo=uo||{}),{});function ho(e){var t,s,n;return e?(void 0===_o[e]?(t=("3"+(n=new Date).getHours()).slice(-2),s=("0"+n.getMinutes()).slice(-2),n=("0"+n.getSeconds()).slice(-2),_o[e]=parseInt([t,s,n,"0001"].join(""),10),console.log("autoIncrementIndex start index:"+_o[e])):_o[e]+=1,_o[e]):0}class go{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=io.MSG_PRIORITY_NORMAL,this._relayFlag=!1;var t,{clientTime:s=Vt.common.timeManager.getServerTimeSeconds()||0,senderTinyID:n,currentUser:i,needReadReceipt:o,isSupportExtension:r,customModerationConfigurationId:a,to:l,from:c,nick:d="",avatar:_="",time:u,messageControlInfo:h,tinyID:g,cloudCustomData:E="",messageLifeTime:p,messageVersion:f=0,conversationType:S,sequence:m,checkResult:v=0,isPlaceMessage:I=0,messageFlagBits:C,receiverList:O,isSystemMessage:T=!1,status:y=Zt.SUCCESS,revokeReason:M="",conversationSubType:A,clientSequence:N,protocol:R="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:w={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:b,groupProfile:P,atUserList:k,flow:L,isRead:U=!1}=e;this.clientTime=s,this.senderTinyID=n||g,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===r||1===r,this._cmConfigID=a,this.to=l,this.nick=d,this.avatar=_,this.protocol=R,this.random=void 0===b?(t=t||99999999,Math.round(Math.random()*t)):b,this.time=u||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!(null==h||!h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!(null==h||!h.excludedFromUnreadCount),this.isModified=!!f,this.cloudCustomData=E,this.messageLifeTime=p,this.from=c||null,this.sequence=m||0,this.conversationType=S||oo.CONV_C2C,this.hasRiskContent=1<v,this.version=f,this.isPlaceMessage=I,this.isRevoked=2===I||8===C,this.isSystemMessage=T,this.readReceiptInfo=w,this.revokeReason=M,this.revokerInfo=D,this._receiverList=O,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=N||m||0,this.status=y,this.atUserList=k||[],this.flow=L,this.isRead=U,this.reInitialize(i),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(P)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t;return this._relayFlag?{isValid:!0}:0<(null==(e=this._elements)?void 0:e.length)?null==(t=null==(e=this._elements[0])?void 0:e.validateBeforeSend)?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===oo.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(e){var t,s;e&&({From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:s}=e,s=(s||{})["NameCard"],"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof s)&&(this.nameCard=s)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){var t=this.conversationType;t!==oo.CONV_SYSTEM?(e=t!==oo.CONV_C2C||e===this.from?this.to:this.from,this.conversationID=e?""+t+e:null):this.conversationID=oo.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=ho(e)),0===this.sequence&&this.conversationType===oo.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===oo.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}setIsRead(e){this.isRead=e}}class Eo{static parseServerPushElement(e){var{MsgContent:e={}}=e,{Data:e,Ext:t,Desc:s}=e;return new Eo({data:e,description:s,extension:t})}constructor(e){this.type=ro.MSG_CUSTOM;var{data:e="",description:t="",extension:s=""}=e;this.content={data:e,description:t,extension:s}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},{data:e,description:t,extension:s}=e?this.payload:this.content;return{MsgType:this.type,MsgContent:{Data:e,Ext:s,Desc:t}}}validateBeforeSend(){let t=Vt.utils["isEmpty"],e=[this.content.data,this.content.description,this.content.extension].some(e=>!t(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class fo{static parseServerPushElement(e){var{MsgContent:e={Text:""}}=e,e=e["Text"];return new fo({text:e})}constructor(e){this.type=zt.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e;return 0<(null==(e=null==(e=this.content)?void 0:e.text)?void 0:e.length)?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},e=(e?this.payload:this.content)["text"];return{MsgType:this.type,MsgContent:{Text:e}}}}class po{constructor(){this._elementClassMap={[ro.MSG_CUSTOM]:Eo,[ro.MSG_TEXT]:fo}}init(){Un({apiName:"createCustomMessage",context:this}),Un({apiName:"createTextMessage",context:this})}registerElementClass(e,t){void 0!==t.prototype&&"constructor"in t.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){var{from:t,flow:s=uo.OUT}=e,n=(Vt.store.get("login")||{})["userId"],t=(this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=uo.OUT),Object.assign(Object.assign({},e),{currentUser:n}));return new go(t)}createCustomMessage(t){let e=Ws(),s=this.createMessage(Object.assign(Object.assign({},t),{from:e})),n=this._elementClassMap[ro.MSG_CUSTOM];if(!s)return null;if(n){let e=new n(t.payload);s.setElement(e)}return s}createTextMessage(e){var t,s;return e?(t="string"==typeof e.payload?e.payload:(null==(t=null==e?void 0:e.payload)?void 0:t.text)||"",t=new fo({text:t}),s=Ws(),(e=Vt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:s}))).setElement(t),e):null}_updateWithSenderInfo(e){var{nick:t,avatar:s}=e,{userId:n,tinyID:i}=Vt.store.get("login")||{},o=wn.getUserProfile(n);return e.nick=t||(null==o?void 0:o.nick)||"",e.avatar=s||(null==o?void 0:o.avatar)||"",e.tinyID=e.tinyID||i||"",e.from=n,e.status=Zt.UNSENT,e.flow=uo.OUT,e}_isMultiEndpointSyncMessage(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===uo.IN}_isSendByCurrentInstance(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===uo.OUT}}let So={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}},mo={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},vo={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Io(n,i){return Object.keys(i).forEach(e=>{var{range:t,defaultValue:s}=i[e];n[e]=t.includes(n[e])?n[e]:s}),n}function Co(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function To(e){var{androidInfo:e={},androidOPPOChannelID:t=""}=e,t=e.OPPOChannelID||t,e=Io(e,mo),{sound:s="",FCMChannelID:n=""}=e,e=_(e,["sound","FCMChannelID"]);return Object.assign(Object.assign({},e),{Sound:Co(s),OPPOChannelID:t,GoogleChannelID:n})}function Oo(e){var{apnsInfo:e={},ignoreIOSBadge:t=!1,disableVoipPush:s}=e,e=Io(e,vo),{ignoreIOSBadge:n,disableVoipPush:i,enableIOSBackgroundNotification:o}=e,e=_(e,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),n=!0===n||!0===t?1:0;let r;return g(s)||(r=!1===s?1:0),g(i)||(r=!1===i?1:0),Object.assign(Object.assign({},e),{BadgeMode:n,IsVoipPush:r,ContentAvailable:o?1:0})}function yo(e){return Vt.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Oo(e),AndroidInfo:To(e)}:So}function Mo(e){let{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:i,IsSyncMsg:o,MsgBody:r,MsgClientTime:a,MsgLifeTime:l,MsgRandom:c,MsgSeq:d,MsgTimeStamp:_,SendMsgControl:u,SupportMessageExtension:h,TinyId:g,MsgCheckResult:E,CloudCustomData:p,MsgVersion:f,MsgFlagBits:S,RevokerInfo:m}=e,v,{From_Account:I,To_Account:C}=e;if(1===o){let e=C;C=I,I=e}if(m){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:o,clientTime:a,messageLifeTime:l,random:c,sequence:d,time:_,messageControlInfo:{excludedFromLastMessage:1===(null==u?void 0:u.NoLastMsg),excludedFromUnreadCount:1===(null==u?void 0:u.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:E,cloudCustomData:p,revokerInfo:v,messageVersion:f,messageFlagBits:S,readReceiptSentByPeer:i,elements:Do(r)}}function Ao(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,To_Account:r,MsgVersion:a,CloudCustomData:l}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,to:r,elements:Do(t),messageVersion:a,cloudCustomData:l}}function No(e){let{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:d,TinyId:_,CloudCustomData:u,MsgVersion:h,MsgCheckResult:g,NeedReadReceipt:E,IsPlaceMsg:p,RevokerInfo:f,GroupAtInfo:S}=e,m,v=io.MSG_PRIORITY_NORMAL;if(Object.keys(ao).includes(String(e.MsgPriority))&&(v=ao[e.MsgPriority]),f){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=f;m={reason:e,revoker:t,revokerFromUin:s,userID:t}}var I=function(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===co?t.push(e.GroupAt_Account):e.GroupAtAllFlag===lo&&t.push(cs.MSG_AT_ALL)}),t}(S);return{clientSequence:t,from:s,groupProfile:n,clientTime:o,priority:v,random:r,sequence:a,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==c?void 0:c.NoLastMsg),excludedFromUnreadCount:1===(null==c?void 0:c.NoUnread)},isSupportExtension:d,tinyID:_,cloudCustomData:u,messageVersion:h,messageCheckResult:g,needReadReceipt:E,isPlaceMessage:p,revokerInfo:m,atUserList:I,elements:Do(i),to:Ro(e)}}function Ro(e){var{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=Vt,{ToGroupId:e,GroupInfo:{MillionGroupFlag:n=0,TopicId:i}={}}=e;return n!==s||t(i)?e:i}function Do(e){var t;return e?Array.isArray(e)?e.map(e=>{var t=Vt.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}):null==(t=Vt.message.messageFactory.getElementClass(e.MsgType))?void 0:t.parseServerPushElement(e):null}function wo(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,GroupId:r,TopicId:a,MsgVersion:l,CloudCustomData:c}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,groupID:r,topicID:a,elements:Do(t),messageVersion:l,cloudCustomData:c}}function bo({conversationUpdateFields:e,message:t}){var{conversationID:s,conversationType:n,conversationSubType:i,flow:o,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,a=a?"":t,t=!r&&o===uo.IN;e.has(s)?(e.get(s).lastMessage=a,t&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:i,unreadCount:t?1:0,lastMessage:a})}var Po=Object.freeze({__proto__:null,autoIncrementIndex:ho,parseServerGroupMessage:No,parseServerPushC2CModifyMessage:Ao,parseServerPushGroupModifyMessage:wo,parseServerPushMessage:Mo,parseServerPushMessageElement:Do,updateConversationFields:bo});let ko=Vt.utils["isPlainObject"];function Lo(e,t={}){let{onlineUserOnly:s,messageControlInfo:n}=t,i=t["offlinePushInfo"],o=(e.conversationType===oo.CONV_C2C&&!0===s&&(i?i.disablePush=!0:i={disablePush:!0}),"");"string"==typeof e.cloudCustomData&&0<e.cloudCustomData.length&&(o=e.cloudCustomData);var r=[];if(n&&ko(n)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&r.push("NoUnread"),!0===t&&r.push("NoLastMsg"),!0===s&&r.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:o,messageControlInfo:r,offlinePushInfo:i}}function Uo(e){var t,{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(e||s)return t=[],e&&t.push("ForbidBeforeSendMsgCallback"),s&&t.push("ForbidAfterSendMsgCallback"),t}function Go(t,s){return h(this,void 0,void 0,function*(){var e=yield xs((t.conversationType===oo.CONV_GROUP?function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=Lo(e,t),a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return p(e._receiverList)&&0<e._receiverList.length&&(l=e._receiverList,50<e._receiverList.length)&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit")),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null==(s=Vt.store.get("login"))?void 0:s.userId,GroupId:e.to,MsgBody:a,CloudCustomData:i,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:n?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:yo(r),SendMsgControl:n?void 0:o,NeedReadReceipt:!0===e.needReadReceipt?1:0,To_Account:l,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:Uo(t)}}}:function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=Lo(e,t),n=!0===n?0:void 0,a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null==(s=Vt.store.get("login"))?void 0:s.userId,To_Account:e.to,MsgBody:a,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:n,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==n?o:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:yo(r),forbidCallbackControl:Uo(t)}}})(t,s));return e?{time:e.MsgTime,messageDropReason:e.MsgDropReason,sequence:e.MsgSeq}:null})}let Fo=Vt.utils["isPlainObject"],{MSG_AUDIO:Bo,MSG_FILE:xo,MSG_IMAGE:Vo,MSG_VIDEO:$o,MSG_MERGER:qo}=cs;class Wo{init(){Un({apiName:"sendMessage",context:this,matcher:e=>![Bo,xo,Vo,$o,qo].includes(e[0].type)})}sendMessage(d,t){return h(this,void 0,void 0,function*(){let n=Vt.ssoLog.createSSOLogData({method:"sendMessage"}),{TOTAL_COUNT:e,SEND_COST:r,SUCCESS_COUNT:a,FAILED_COUNT:o}=ps;if(!(d instanceof go)){let e=new vs({code:ls.MSG_INSTANCE_REQUIRED});throw n.setError(e).end(),e}let i=d.validateBeforeSend();if(!i.isValid){let{code:e,message:t=""}=i.error||{},s=new vs({code:e,message:t});throw n.setError(s).end(),s}this._reportMessageSendQuality({name:e,message:d});let l=!1;var c=(Vt.message||{})["messageDataHandler"];try{let n=(t||{})["messageControlInfo"],i=null,o=(c.addRandomOfSentMessage(d.random),Date.now());if(d.conversationType===oo.CONV_C2C?(l=!0===(null==t?void 0:t.onlineUserOnly),i=yield Go(d,t)):d.conversationType===oo.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(d),i=yield Go(d,t)),i){let{messageDropReason:e,sequence:t,time:s}=i;if(this._updateNickAndAvatarOfSentMessageByMe(d),e&&this._logRateLimitInfo(d,t),this._reportMessageSendQuality({name:a,message:d}),this._reportMessageSendQuality({name:r,message:d,startTs:o}),!0===d.isResend){let e=c.findMessage(d.ID);e&&(console.log("sendMessage resend ok. ID:"+e.ID),c.deleteConversationMessage(e))}return d.status=Zt.SUCCESS,d.time=s,d.conversationType===oo.CONV_GROUP&&(d.sequence=t),l?d._onlineOnlyFlag=!0:(c.storeConversationMessage(d),this._applySentMessageControlInfo(d,n),this._emitOnlineMessageSent(d)),{code:0,data:{message:d}}}}catch(e){d.status=Zt.FAIL,c.removeRandomOfSentMessage(d.random);let{errorCode:t,errorMessage:s="",errorInfo:n=s}=e||{},i=(this._hasRiskContent(t)&&(d.hasRiskContent=!0),l||this._isRejectedByRestApi(t)||c.storeConversationMessage(d),this._reportMessageSendQuality({name:o,message:d,error:e}),new vs({code:t,message:n,data:{message:d}}));throw this._logSendMessageError({message:d,error:i}),i}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return 10100<=e&&e<=10200||120001<=e&&e<=13e4}_logSendMessageError({message:e,error:t}){var s=Vt.ssoLog.createSSOLogData({method:"sendMessage"});let n=`head.seq: type:${e.type} from:${e.from} to:`+e.to;if(Vt.utils.IN_BROWSER){if("connection"in navigator){let e=navigator.connection;n+=` downlink:${e.downlink} effectiveType:${e.effectiveType} rtt:`+e.rtt}if("memory"in window.performance){let e=window.performance.memory;n+=` usedJSHeapSize:${e.usedJSHeapSize} totalJSHeapSize:${e.totalJSHeapSize} jsHeapSizeLimit:`+e.jsHeapSizeLimit}}s.setLogInfo({message:n}).setError(t).end()}_emitOnlineMessageSent(e){var t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,i=Gs(s)?Kt.TOPIC_NEW_MESSAGE:Kt.NEW_MESSAGE;Vt.notificationCenter.emitInnerEvent(i,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&Fo(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0)}_logRateLimitInfo(e,t){var s=Vt.ssoLog.createSSOLogData({method:"messageDropReason"}),e=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:`+messageDropReason;s.setLogInfo({message:e}).end(),console.warn("sendMessage "+e)}_updateNickAndAvatarOfSentMessageByMe(e){var t=(Vt.message||{})["messageDataHandler"];let s=!1;var n,i=e["conversationID"],o=t.getLatestMsgSentByMe(i);o&&({nick:o,avatar:n}=o,s=o!==e.nick||n!==e.avatar||s)&&t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}_validateBeforeSendGroupMessage(i){return h(this,void 0,void 0,function*(){var{to:t,from:s}=i;let n=t,e=Rn.getGroup(n);if(Us({groupID:n})&&null!=e&&e.isSupportTopic)throw new vs({code:ls.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(Gs(t)&&([n]=t.split(rs.TOPIC),e=Rn.getGroup(n)),!e&&"function"==typeof(null==Pn?void 0:Pn.getGroupProfile)){let e=yield Pn.getGroupProfile({groupID:n});if((null==(t=null==(t=null==e?void 0:e.data)?void 0:t.group)?void 0:t.type)===cs.GRP_AVCHATROOM){let e=ms({code:ls.MSG_SEND_FAIL_NOT_IN_AV,replacement1:s,replacement2:n});throw new vs({code:ls.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){Vt.notificationCenter.emitInnerEvent(Kt.QUALITY_STAT,{label:fs.MESSAGE_SEND_SUCCESS_RATE,data:e})}}class Yo{constructor(e){this.value=e,this.next=null}}class Ko{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();e=new Yo(e);this.head?this.tail.next=e:this.head=e,this.tail=e,this.size+=1}delete(t){if(this.head)if(this.head.value===t)this.head=this.head.next;else{let e=this.head;for(;e.next;){if(e.next.value===t)return void(e.next=e.next.next);e=e.next}}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,--this.size)}peek(){var e;return null==(e=this.head)?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}class jo{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Ko(100),Vt.notificationCenter.subscribeInnerEvent(Kt.LOGOUT,this._reset,this),Vt.notificationCenter.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}get _messagesByConversation(){return Dn.getMessages()}storeConversationMessage(e,t=!1){var s=e["conversationID"];return!!s&&(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),!this._shouldSkipStoreMessage(e,t))&&(t=this._getUniqueIdOfMessage(e),this._messagesByConversation.get(s).set(t,e),this._updateLatestMessageMap(e),!0)}_updateLatestMessageMap(e){var t=e["conversationID"];"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){var s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null!=n&&n.has(s)){let e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var{conversationID:t=""}=e,e=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(t)&&null!=(t=this._messagesByConversation.get(t))&&t.delete(e)}modifyConversationMessage(a,t){var l;if(this._messagesByConversation.has(a)||this._sparseMessagesByConversation.has(a)){let e=this._getUniqueIdOfMessage(t),r=this._getMessageFromLocalMessage(a,e);if(r){let{messageVersion:s,elements:n,cloudCustomData:i,checkResult:e=0}=t,o=1<e;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${r.version} remoteVersion:`+s),r.version<s){let e=this._getUniqueIdOfMessage(r),t=pe(n);return null!=(l=this._messagesByConversation.get(a))&&l.has(e)?Dn.updateMessage(a,[e],{isModified:!0,version:s,_elements:t,payload:t[0].content,type:t[0].type,cloudCustomData:i,hasRiskContent:o,operation:Jt.modify}):(r.version=s,r._elements=t,r.payload=r._elements[0].content,r.type=r._elements[0].type,r.cloudCustomData=i,r.isModified=!0,r.hasRiskContent=o),{isUpdated:!0,message:r}}return{isUpdated:!1,message:r}}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,s){var t;if(this._messagesByConversation.has(e))return null==(t=this._messagesByConversation.get(e))?void 0:t.get(s);if(this._sparseMessagesByConversation.has(e)){let t=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<t.length;e++)if(this._getUniqueIdOfMessage(t[e])===s)return t[e]}return null}findMessage(t){let s=null,e=Array.from(this._messagesByConversation.values());for(var n of e)if(s=Array.from(n.values()).find(e=>e.ID===t)||null)break;if(!s){let e=Array.from(this._sparseMessagesByConversation.values());for(var i of e)if(s=i.get(t)||null,s)break}return s}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:t,sequence:s,random:n,revoker:i}){let e=this._messagesByConversation.get(t),o=null;if(e){var r=Array.from(e.values());if(o=this._findMessageBySequenceAndRandom({messageList:r,random:n,sequence:s})){let e=this._getUniqueIdOfMessage(o);return Dn.updateMessage(t,[e],{isRevoked:!0,revoker:i,operation:Jt.revoke}),o}}if(this._sparseMessagesByConversation.has(t)){let e=Array.from(this._sparseMessagesByConversation.get(t).values());if(o=this._findMessageBySequenceAndRandom({messageList:e,random:n,sequence:s}))return o.isRevoked=!0,o.revoker=i,o}}_findMessageBySequenceAndRandom({messageList:t,sequence:s,random:n}){for(let e=0;e<t.length;e+=1){var i=t[e];if(i.sequence===s&&(g(n)||i.random===n))return i}return null}prependLocalMessageList(e){let{messageList:s,conversationID:t}=e;if(0===s.length)return[];var n=[],i=[],o=this._messagesByConversation.get(t)||new Map;for(let t of s){let e=this._getUniqueIdOfMessage(t);o.has(e)||(n.push(t),i.push([e,t]))}if(0<i.length){let e=new Map([...i,...o.entries()]);this._messagesByConversation.set(t,e),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return n}storeSparseMessageList(n){if(0!==n.length){let e=n[0]["conversationID"],s=n.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);var i=this._sparseMessagesByConversation.get(e);for(let t=0;t<s;t++){let e=n[t];i.has(e.ID)||i.set(e.ID,e)}}}_updateLatestMessageSentByMe(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length)for(let e=s.length-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(t,s[e]);break}}_updateLatestMessageSentByPeer(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length&&t.startsWith("C2C"))for(let e=s.length-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(t,s[e]);break}}_getUniqueIdOfMessage(e){var{from:e,to:t,random:s,sequence:n,time:i}=e;return e+`-${t}-${s}-${n}-`+i}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){let{conversationID:t="",latestAvatar:o,latestNick:r,isSentByMe:s=!0}=e,n=this._messagesByConversation.get(t);if(n){let e=Array.from(n.values()),i=s?"out":"in";e.forEach(e=>{var{nick:t,avatar:s,flow:n}=e;n===i&&(t!==r&&(e.nick=r),s!==o)&&(e.avatar=o)})}}isInMessageList(e){var t=e["conversationID"];return!!t&&!!this._messagesByConversation.has(t)&&(e=this._getUniqueIdOfMessage(e),null==(t=this._messagesByConversation.get(t))?void 0:t.has(e))}isMessageSentByCurrentInstance(e){e=e.random;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){e=this._messagesByConversation.get(e);return e?[...e.values()]:[]}getSparseMessageList(e){e=this._sparseMessagesByConversation.get(e);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),Vt.notificationCenter.unSubscribeInnerEvent(Kt.LOGOUT,this._reset,this),Vt.notificationCenter.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this)}}function Ho(e,t){var s,n,i,o,r,a,l,c=Nn.getConversation(e);null!=c&&c.lastMessage&&(c=c["lastMessage"],{lastTime:s,lastSequence:n,version:i}=c,{time:t,sequence:o,messageVersion:r,elements:a,cloudCustomData:l}=t,s===t)&&n===o&&i!==r&&(c.type=a[0].type,c.payload=a[0].content,c.messageForShow=js(c.type,c.payload),c.cloudCustomData=l,c.version=r,Nn.updateConversation(e,{lastMessage:c}))}class zo{init(){Un({apiName:"modifyMessage",context:this})}modifyMessage(d){return h(this,void 0,void 0,function*(){let n=Vt.ssoLog.createSSOLogData({method:"modifyMessage"}),{to:i,payload:e,sequence:o,conversationType:r,random:a,time:l,from:c,type:t}=d;if(this._canModifyMessageElement(t)){var s=d.getElements();1<s.length&&(s[0].type=t,s[0].content=e);try{let t=null,s;if(n.setLogInfo({message:"to:"+i}),r===oo.CONV_C2C?t=yield function(d){return h(this,void 0,void 0,function*(){let{from:e,to:t,version:s=0,sequence:n,random:i,time:o,type:r,cloudCustomData:a}=d,l={From_Account:e,To_Account:t,MsgVersion:s,MsgSeq:n,MsgRandom:i,MsgTime:o,MsgType:r,MsgBody:d.transformElementsToServerFormat(),CloudCustomData:a},c=yield xs({servcmd:"openim.modify_c2c_msg",data:l});if(c){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=c;return{elements:Do(e),messageVersion:t,cloudCustomData:s}}})}(d):r===oo.CONV_GROUP&&(t=yield function(r){return h(this,void 0,void 0,function*(){let{to:e,version:t=0,sequence:s,cloudCustomData:n}=r,i={GroupId:e,MsgVersion:t,MsgSeq:s,MsgBody:r.transformElementsToServerFormat(),CloudCustomData:n},o=yield xs({servcmd:"openim.modify_group_msg",data:i});if(o){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=o;return{elements:Do(e),messageVersion:t,cloudCustomData:s}}})}(d)),t){n.end();let e=""+r+i;return i===Ws()&&r===oo.CONV_C2C&&(e=""+r+c),s={conversationType:r,from:c,to:i,time:l,random:a,sequence:o,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:e},this._handleModifyMessageSuccess(s),{code:0,data:{message:d}}}}catch(e){let t=(e||{})["errorCode"],s=new vs({functionName:"modifyMessage",code:t});throw this._logModifyMessageError(s),s}}else n.setLogInfo({message:"can not modify message element. message type: "+t}).end()})}_logModifyMessageError(e){Vt.ssoLog.getSSOLogData("modifyMessage").setError(e).end()}_handleModifyMessageSuccess(e){var t=e["conversationID"],{isUpdated:s,message:n}=Vt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Vt.notificationCenter.emitOuterEvent(Wt.MESSAGE_MODIFIED,{name:Wt.MESSAGE_MODIFIED,data:[n]}),Vt.notificationCenter.emitInnerEvent(Kt.MESSAGE_MODIFIED,{conversationID:t,message:n}),Ho(t,e)}_canModifyMessageElement(e){return[ro.MSG_TEXT,ro.MSG_CUSTOM,ro.MSG_LOCATION,ro.MSG_FACE].includes(e)}}class Zo{init(){var e=Vt["notificationCenter"],t=e["InnerEventSubType"];Ls.registerWorkflowStep(us.RECEIVE_C2C_NEW_MESSAGE,_s.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),Ls.registerWorkflowStep(us.RECEIVE_C2C_NEW_MESSAGE,_s.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),Ls.registerWorkflowStep(us.SYNC_SERVER_INFO_AFTER_RE_ONLINE,_s.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){Ls.executeWorkflow(us.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){let t=e.data||{},s=(Vt.message||{})["messageDataHandler"],n=[],i=new Map;return t.C2cMsgArray.forEach(e=>{e=this._generateC2CMessage(e);this._updateMessageProfile(e);let t=1===e.isModified;s.isMessageSentByCurrentInstance(e)?e.isModified=t:t=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||(s.storeConversationMessage(e)&&bo({conversationUpdateFields:i,message:e}),s.isMessageSentByCurrentInstance(e)&&!t)||n.push(e)}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[_s.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(e)}_emitMessageEventsAfterSyncUnreadMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[_s.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(e)}_emitMessageEvents(e){var t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&Vt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)));0<t.length&&Vt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(e){var t=oo.CONV_C2C,e=Mo(e),t=Vt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:uo.IN})),e=e["elements"];return t.setElement(e),t}_updateMessageProfile(n){var e;let i=(Vt.message||{})["messageDataHandler"],t=null==(e=Vt.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;g(o)||g(r)?(n.nick=E(e)?e:n.nick,n.avatar=E(t)?t:n.avatar):o===e&&r===t||(i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:a,nick:o,avatar:r}))}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_updateConversationUserProfile(e){var{conversationID:e,nick:t,avatar:s}=e,{userProfile:n={}}=Nn.getConversation(e)||{};n.avatar===s&&n.nick===t||Nn.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:s})})}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=Vt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Vt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Vt.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),Ho(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t=oo.CONV_C2C,e=Ao(e),{to:s,from:n}=e;let i=""+t+s;s===(null==(s=Vt.store.get("login"))?void 0:s.userId)&&(i=""+t+n),e=Object.assign({conversationType:t,conversationID:i},e),this._updateMessageListDueToModify(e)})}_dispose(){var e=Vt["notificationCenter"],e=e["InnerEventSubType"];Vt.notificationCenter.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),Vt.notificationCenter.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),Vt.notificationCenter.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this)}}class Jo{init(){var e=Vt["notificationCenter"],t=e["InnerEventSubType"];Ls.registerWorkflowStep(us.RECEIVE_GROUP_NEW_MESSAGE,_s.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),Ls.registerWorkflowStep(us.RECEIVE_GROUP_NEW_MESSAGE,_s.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&Ls.executeWorkflow(us.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){let t=e.data||{},s=Vt.message["messageDataHandler"],n=[],i=new Map,o=null==t?void 0:t.GroupMsgArray;return null!=o&&o.forEach(e=>{var t;1!==e.GroupInfo.NotVisible&&(e=this._generateGroupMessage(e),this.updateMessageProfile(e),t=1===e.isModified,s.isMessageSentByCurrentInstance(e)&&(e.isModified=t),e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||s.storeConversationMessage(e)&&(n.push(e),bo({conversationUpdateFields:i,message:e})))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEvents(e){var e=((null==(e=e.result)?void 0:e[_s.HANDLE_GROUP_NEW_MESSAGE])||{})["messages"],t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&Vt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),(null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)))||[]);0<t.length&&Vt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateGroupMessage(e){var t=oo.CONV_GROUP,e=No(e),t=Vt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:uo.IN})),e=e["elements"];return t.setElement(e),t}updateMessageProfile(e){var t=(Vt.message||{})["messageDataHandler"],{from:e,nick:s,avatar:n,conversationID:i=""}=e;if(e===(null==(e=Vt.store.get("login"))?void 0:e.userId)){let e=t.getLatestMsgSentByMe(i);!e||s===e.nick&&n===e.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:s,latestAvatar:n,isSentByMe:!0})}}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=Vt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Vt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Ho(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{var t=oo.CONV_GROUP,{topicID:s,groupID:n}=e=wo(e),s=s||n,e=Object.assign({conversationType:t,conversationID:""+t+s,to:s},e);this._updateMessageListDueToModify(e)})}_dispose(){var e=Vt["notificationCenter"],{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}=e["InnerEventSubType"];e.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var{GroupId:e,GroupType:t}=(null==(e=null==(e=null==e?void 0:e.GroupMsgArray)?void 0:e[0])?void 0:e.GroupInfo)||{},t=t===is.GRP_AVCHATROOM;return!(!Rn.getGroup(e)&&t)}}class Xo{constructor(){this.c2cMessageReceiver=new Zo,this.groupMessageReceiver=new Jo}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}}let Qo={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null==(e=null==e?void 0:e.text)?void 0:e.length))||"payload.text is invalid."}}}},ei={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};class ti{constructor(){this.messageHelper=Po,this.messageFactory=new po,this.messageSender=new Wo,this.messageAction=new zo,this.messageReceiver=new Xo,this.messageDataHandler=new jo,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),ws({auth:ei,params:Qo})}}let si="User",ni="Tag_Profile_IM_",oi=100,ii={NICK:ni+"Nick",GENDER:ni+"Gender",BIRTHDAY:ni+"BirthDay",LOCATION:ni+"Location",SELFSIGNATURE:ni+"SelfSignature",ALLOWTYPE:ni+"AllowType",LANGUAGE:ni+"Language",AVATAR:ni+"Image",MESSAGESETTINGS:ni+"MsgSettings",ADMINFORBIDTYPE:ni+"AdminForbidType",LEVEL:ni+"Level",ROLE:ni+"Role"},ri="USER_STATUS",ai=1,ci={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},li=new Map([[ii.NICK,"nick"],[ii.GENDER,"gender"],[ii.BIRTHDAY,"birthday"],[ii.LOCATION,"location"],[ii.SELFSIGNATURE,"selfSignature"],[ii.ALLOWTYPE,"allowType"],[ii.LANGUAGE,"language"],[ii.AVATAR,"avatar"],[ii.MESSAGESETTINGS,"messageSettings"],[ii.ADMINFORBIDTYPE,"adminForbidType"],[ii.LEVEL,"level"],[ii.ROLE,"role"]]);var di=new class{createProfile(e,t){let s={userID:e,profileCustomField:[]};return t.forEach(e=>{var{tag:e,value:t}=e;e&&-1<e.indexOf("Tag_Profile_Custom")?s.profileCustomField.push({key:e,value:t}):li.has(e)&&(s[li.get(e)]=t)}),Object.assign(Object.assign({},ci),s)}parseProfileItem(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}parseProfileList(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}convertParamsToProfile(t){let s=[];return Object.keys(t).forEach(e=>{s.push({tag:ii[e.toUpperCase()],value:t[e]})}),s}normalizeProfileFields(e){let n={};return e.forEach(e=>{var{tag:t,value:s}=e;if(li.has(t)){let e=li.get(t);n[e]=s}}),n}};let ui=Vt.common["generateProtocolData"];function _i(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_get_all",t={From_Account:Ws(),UserItem:[]};n.forEach(e=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});var o=ui({servcmd:e,data:t}),s=o.head.seq+e,o=yield Vt.channel.sendPacket(o,{requestId:s});if(o){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n,UserProfileItem:i}=o,r=[];return i.map(e=>{var{To_Account:e,CustomSequence:t,ResultCode:s,ResultInfo:n,StandardSequence:i,ProfileItem:o}=e,o=di.parseProfileItem(o);r.push({userId:e,customSequence:t,resultCode:s,resultInfo:n,standardSequence:i,profileItem:o})}),{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n,userProfile:r}}})}function hi(e){return wn.getFriendMap().has(e)}let gi=Vt.utils["isEmpty"];class Ei{init(){Un({apiName:"getMyProfile",context:this}),Un({apiName:"getUserProfile",context:this}),Un({apiName:"updateMyProfile",context:this}),this.createProfile=di.createProfile.bind(di);var e=Vt["notificationCenter"];Ls.registerWorkflowStep(us.SYNC_SERVER_INFO_AFTER_LOGIN,_s.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(Kt.LOGOUT,this._reset,this),e.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}getMyProfile(){return h(this,void 0,void 0,function*(){let t=Vt.ssoLog.createSSOLogData({method:"getMyProfile"});try{var s=Ws(),n=yield _i([s]);if(n){let e=this._handleProfileFormResponse(n)[0];return wn.getUserProfileMap().set(s,e),{code:0,data:e}}t.end()}catch(e){var{errorCode:n,errorInfo:s}=e,n=new vs({functionName:"getMyProfile",code:n,message:s});throw t.setError(n).end(),e}})}getUserProfile(l){return h(this,void 0,void 0,function*(){var i=Vt.ssoLog.createSSOLogData({method:"getUserProfile"});try{let e=l["userIDList"],{userIdListToRequest:t,userIdListToCache:s}=(e.length>oi&&(e=e.slice(0,oi)),this._filterRequestAndCacheUsers(e)),n=[];s.forEach(e=>{e=wn.getUserProfile(e);n.push(e)});var o="userIDList.length:"+e.length;if(0===t.length)return i.setLogInfo({message:o}).end(),{code:0,data:n};var r=yield _i(t);if(r){let e=this._handleProfileFormResponse(r);e.forEach(e=>{hi(e.userID)&&wn.getUserProfileMap().set(e.userID,e)});var a=e.concat(n);return i.setLogInfo({message:o}).end(),{code:0,data:a}}}catch(e){r=e["errorCode"],o=new vs({functionName:"getUserProfile",code:r});throw i.setError(o).end(),o}})}getMyProfileCacheThenServer(){return h(this,void 0,void 0,function*(){var e=Ws(),e=wn.getUserProfileMap().has(e);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(a){return h(this,void 0,void 0,function*(){let i=Vt.ssoLog.createSSOLogData({method:"updateMyProfile"}),t=Ws(),s={};for(let e in a)void 0!==a[e]&&(s[e]=a[e]);let n=di.convertParamsToProfile(s);try{let e={From_Account:t,ProfileItem:n};i.setLogInfo({message:JSON.stringify(n)}),yield function(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_set",t=ui({servcmd:e,data:n}),s=""+t.head.seq+e,i=yield Vt.channel.sendPacket(t,{requestId:s});if(i){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=i;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);var o=wn.getUserProfile(t),r=o?Object.assign(Object.assign({},o),s):di.createProfile(t,n);return Ts(o,r,["lastUpdatedTime","profileCustomField"])||Vt.notificationCenter.emitOuterEvent(Wt.PROFILE_UPDATED,{name:Wt.PROFILE_UPDATED,data:[r]}),r.lastUpdatedTime=Date.now(),wn.getUserProfileMap().set(t,r),i.end(),{code:0,data:r}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new vs({functionName:"updateMyProfile",code:t,message:s});throw i.setError(n).end(),n}})}updateMyNickAndAvatar(i){return h(this,void 0,void 0,function*(){var e=Ws(),t=Date.now(),s=wn.getUserProfile(e),n={};(n=s?Object.assign(s,i):di.createProfile(e,i)).lastUpdatedTime=t,wn.getUserProfileMap().set(e,n)})}_onProfileDataModify(n){var e,t=function(){var{Profile_Account:e,PushType:t,ProfileList:s}=n.ProfileDataMod[0];return{userId:e,pushType:t,profileList:di.parseProfileList(s)}}();gi(t)||({isProfileUpdated:t,profile:e}=this._handleProfileModified(t),t&&(Vt.notificationCenter.emitInnerEvent(Kt.PROFILE_UPDATE,{name:Kt.PROFILE_UPDATE,data:[e]}),Vt.notificationCenter.emitOuterEvent(Wt.PROFILE_UPDATED,{name:Wt.PROFILE_UPDATED,data:[e]})))}_dispose(){var e=Vt["notificationCenter"];e.unSubscribeInnerEvent(Kt.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){let{userId:t,profileList:s}=e,n=wn.getUserProfile(t);if(!n||!hi(t))return{isProfileUpdated:!1,profile:null};let i=di.normalizeProfileFields(s),o=Object.keys(i).some(e=>n[e]!==i[e]);return o?(e=Date.now(),e=Object.assign(Object.assign(Object.assign({},n),i),{lastUpdatedTime:e}),wn.getUserProfileMap().set(t,e),Nn.updateConversation("C2C"+t,{userProfile:e}),{isProfileUpdated:o,profile:e}):{isProfileUpdated:!1,profile:n}}_filterRequestAndCacheUsers(e){let s=[],n=[];return e.forEach(e=>{var t=wn.getUserProfileMap().has(e);(hi(e)&&t?n:s).push(e)}),{userIdListToRequest:s,userIdListToCache:n}}_handleProfileFormResponse(e){e=e.userProfile;if(!Array.isArray(e))return[];let t=e.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!gi(e.profileItem)),s=Date.now();return t.map(e=>{e=di.createProfile(e.userId,e.profileItem);return e.lastUpdatedTime=s,e})}_reset(){wn.getUserProfileMap().clear()}}let fi=new Map,pi=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=pi.length;e<t;e++)fi.set(e,pi[e]);function Si(e){if(!e)return"";var i=String(e).replace(/[=]+$/,"");let o="";if(i.length%4==1)return"";for(let e,t,s=0,n=0;t=i.charAt(n++);~t&&(e=s%4?64*e+t:t,s++%4)&&(o+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(o))}catch(e){return console.warn(e),""}}let mi=Vt.utils["isEmpty"],vi=Vt.common["generateProtocolData"];function Ii(i){return h(this,void 0,void 0,function*(){var e,t,s="im_open_status.ws_get_user_status",n=vi({servcmd:s,data:{To_Account:i}}),s=n.head.seq+s,n=yield Vt.channel.sendPacket(n,{requestId:s});if(n)return{ErrorCode:s,ErrorInfo:n,ErrorList:e=[],UserStatusList:t=[]}=n,{errorCode:s,errorInfo:n,successUserList:t.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Si(s)}}),failureUserList:e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:mi(t)?e:t,code:s,message:n}})}})}class Ci{constructor(){this._customStatus=""}init(){var e=Vt["notificationCenter"];Un({apiName:"getUserStatus",context:this}),Un({apiName:"setSelfStatus",context:this}),Un({apiName:"subscribeUserStatus",context:this}),Un({apiName:"unsubscribeUserStatus",context:this}),Ls.registerWorkflowStep(us.SYNC_SERVER_INFO_AFTER_RE_ONLINE,_s.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(Kt.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(Kt.LOGOUT,this._reset,this),e.subscribeInnerEvent(Kt.DESTROY,this._dispose,this)}setSelfStatus(s){return h(this,void 0,void 0,function*(){let i=Vt.ssoLog.createSSOLogData({method:"setSelfStatus"}),e=Ws(),t=s["customStatus"];try{return yield function(i){return h(this,void 0,void 0,function*(){let e="im_open_status.ws_set_custom_status",t=vi({servcmd:e,data:{CustomStatus:i}}),s=""+t.head.seq+e,n=yield Vt.channel.sendPacket(t,{requestId:s});if(n){let{ErrorCode:e,ErrorInfo:t}=n;return{errorCode:e,errorInfo:t}}})}(t),this._customStatus=t,i.setLogInfo({message:"customStatus: "+t}).end(),{code:0,data:{userID:e,statusType:ai,customStatus:t}}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new vs({functionName:"setSelfStatus",code:t,message:s});throw i.setError(n).end(),n}})}getUserStatus(s){return h(this,void 0,void 0,function*(){var e=Vt.ssoLog.createSSOLogData({method:"getUserStatus"}),{userIDList:t=[]}=s;return e.setLogInfo({moreMessage:"userIDList length: "+t.length}),this._isOnlyMeInArray(t)?this._getMyStatus():this._getUserStatus(t)})}setCustomStatus(e){e=Si(e);this._customStatus=e}subscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(si+" subscribeUserStatus options: ",n);var{userIDList:e=[]}=n,t=(this._checkBusinessCapabilityBits("subscribeUserStatus"),this._getMaxUserCount("subscribe")),s=yield function(n){return h(this,void 0,void 0,function*(){var e=Vt["channel"],t="im_open_status.ws_status_subscribe",s=vi({servcmd:t,data:{To_Account:n}}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(si+" subscribeUserStatus error:",e),e}})}unsubscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(si+" unsubscribeUserStatus options: ",n),this._checkBusinessCapabilityBits("unsubscribeUserStatus");var{userIDList:e=[]}=n,t=this._getMaxUserCount("unsubscribe"),s=yield function(n){return h(this,void 0,void 0,function*(){var e=Vt["channel"],t="im_open_status.ws_status_unsubscribe",s=0===n.length?{UnsubscribeAll:1}:{To_Account:n},s=vi({servcmd:t,data:s}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(si+" unsubscribeUserStatus error:",e),e}})}_onUserStatusUpdate(e){var{UserStatusList:e=[]}=e||{},e=e.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Si(s)}});this._emitUserStatusUpdatedEvent(e)}_onReOnline(e){var e=Si(e.data.customStatus);this._customStatus!==e&&(this._customStatus=e,e={userID:Ws(),statusType:ai,customStatus:e},this._emitUserStatusUpdatedEvent(e))}_emitUserStatusUpdatedEvent(e){Vt.notificationCenter.emitOuterEvent(Wt.USER_STATUS_UPDATED,{name:Wt.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){var{ErrorList:e=[]}=e;return e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Vt.utils.isEmpty(t)?e:t,code:s,message:n}})}_checkBusinessCapabilityBits(e){if(!Vt.store.get("commercialConfig").get(ri))throw new vs({functionName:e,code:ls.NO_USE,replacement1:e})}_getMaxUserCount(e){var t=Vt.store.get("cloudConfig")||{},{key:e,default:s}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:oi},unsubscribe:{key:"status_unsub_count",default:oi}}[e],t=t[e]||s;return parseInt(t,10)}_getMyStatus(){var e=Vt.ssoLog.getSSOLogData("getUserStatus"),t=(e.setLogInfo({moreMessage:"getUserStatus._getMyStatus"}),{userID:Ws(),statusType:ai,customStatus:this._customStatus});return e.end(),{code:0,data:{successUserList:[t],failureUserList:[]}}}_getUserStatus(i){return h(this,void 0,void 0,function*(){var t=Vt.ssoLog.getSSOLogData("getUserStatus");t.setLogInfo({moreMessage:"getUserStatus._getUserStatus"});try{this._checkBusinessCapabilityBits("getUserStatus");var s=this._getMaxUserCount("query"),{successUserList:n,failureUserList:e}=(yield Ii(this._sliceUserIDList(i,s)))||{};return t.end(),{code:0,data:{successUserList:n,failureUserList:e}}}catch(e){s=e["errorCode"],n=new vs({functionName:"getUserStatus",code:s});throw t.setError(n).end(),n}})}_isOnlyMeInArray(e){var t=Ws();return 1===e.length&&-1<e.indexOf(t)}_dispose(){var e=Vt["notificationCenter"];e.unSubscribeInnerEvent(Kt.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(Kt.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(Kt.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}let Ti={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},Oi={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class yi{constructor(){this.userProfile=new Ei,this.userStatus=new Ci,this.userProfile.init(),this.userStatus.init(),ws({auth:Oi,params:Ti})}}console.log("TencentCloudLiteChat.VERSION:"+Ke);var Mi={create:function(e){var{SDKAppID:e,testEnv:t=!1,devMode:s=!1,unlimitedAVChatRoom:n=!1,scene:i=""}=e;if("number"!=typeof e&&(o=Number(e),Number.isNaN(o)))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(e=Number(e),ks.has(e))return ks.get(e);var o=""+(r()+r())+r()+r()+r()+r()+r()+r();function r(){return(65536*(1+Math.random())|0).toString(16).substring(1)}Vt.init({sdkAppId:e,instanceId:o,testEnv:t,devMode:s,unlimitedAVChatRoom:n,scene:i,sdkEdition:On}),Ls.init(),Vt.message=new ti,Vt.user=new yi,Vt.login=new no,bs.installBuiltInPlugin(yn);t=Pn;return ks.set(e,t),t},TSignaling:jt,EVENT:Wt,VERSION:Ke,TYPES:cs};export{Mi as default};
|
|
1
|
+
class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,s,n){s&&(this.listeners[e]=null==(e=this.listeners[e])?void 0:e.filter(e=>{var t=e.fn===s,e=!n||e.context===n;return!(t&&e)}))}emit(e,...s){e=this.listeners[e];e&&e.forEach(e=>{var{fn:e,context:t}=e;e.apply(t,s)})}once(t,s,n){let i=(...e)=>{s.apply(n,e),this.off(t,i)};this.on(t,i)}}let t={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},s=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var n;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(n=n||{});var o,c,i=Object.freeze({__proto__:null,get ConvModifyPushType(){return n},ENUM_PLATFORM:t,IS_TOPIC_MESSAGE:2,NOT_NEED_CRC_SERVCMD:s});function r(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_TIPS_NOTIFICATION):s.push(o.GROUP_TIPS_NOTIFICATION)}),s}!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message"}(o=o||{});let a=[{conditions:[{type:"event",value:100}],subType:o.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:o.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:o.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:o.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:o.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:o.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:o.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:o.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:o.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:o.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.C2cNotifyMsgArray)&&t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(o.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(o.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(o.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(o.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(o.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(o.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(o.TOPIC_MESSAGE_READ_SYNC):s.push(o.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_SYSTEM_NOTIFICATION):s.push(o.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{var e=e["GroupAtTips"]["TopicId"];e?s.push(o.TOPIC_AT_TIPS):s.push(o.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.RecentContactMod)&&t.forEach(e=>{switch(e.PushType){case n.CONV_MARK_UPDATED:s.push(o.CONVERSATION_MARK_UPDATED);break;case n.CONV_GROUP_ADDED:s.push(o.CONVERSATION_GROUP_ADD);break;case n.CONV_GROUP_DELETED:s.push(o.CONVERSATION_GROUP_DELETED);break;case n.CONV_GROUP_UPDATED:s.push(o.CONVERSATION_GROUP_UPDATED);break;default:s.push(o.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:o.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:o.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:o.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:o.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:o.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:o.ALL_MESSAGE_READ}];function l(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],i=[];return t.forEach(t=>{t.Flag=n.body.Flag;var e=a.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!e)return null;let s=[];"function"==typeof e.subTypeParser?s=e.subTypeParser(t):e.subType&&(s=e.subType),Array.isArray(s)?s.forEach(e=>{i.push({type:c.SERVER_PUSH_MESSAGE+":"+e,data:t})}):i.push({type:c.SERVER_PUSH_MESSAGE+":"+s,data:t})}),i}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(c=c||{});let d={[c.SERVER_PUSH_MESSAGE]:l,[c.SERVER_PUSH_MESSAGE_MULTIPLE]:l,[c.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},u=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=o}subscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.on(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,i)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(d).includes(t)){let e=null==(t=d[t])?void 0:t.call(d,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.off(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,i)}}subscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.off(e,t,s)}emitOuterEvent(e,t){var s;null!=(s=this._outerEventEmitter)&&s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function _(e,t){var s={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}function h(e,r,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{o(l.next(e))}catch(e){t(e)}}function i(e){try{o(l.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}o((l=l.apply(e,r||[])).next())})}let g=e=>void 0===e,p=e=>"string"==typeof e,E=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[1].toLowerCase()},m=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===E(e),f=e=>null!==e&&"object"==typeof e,S=e=>m(e)||f(e),v=e=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},I=e=>{if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function C(e=99999999){return Math.round(Math.random()*e)}let M=(s,n,i,o)=>{if(!S(s)||!S(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(S(s[a])&&S(n[a]))r+=M(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r};function O(s){let n,i,o=s,r="";for(let e=0,t=(o=s.length%8!=0?"0".repeat(8-s.length%8)+s:o)["length"];e<t;e+=8)n=parseInt(o.slice(e,e+4),2),i=parseInt(o.slice(e+4,e+8),2),r+=base16Map.get(n)+base16Map.get(i);return r}let T="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),y="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||T,A=y&&"function"==typeof wx.createGamePortal,R="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,L="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,b=y&&"object"==typeof wx.miniapp,k="undefined"!=typeof uni,U=y||R||N||D||P||L||w,G="undefined"==typeof window&&!U&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,F="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),x="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),V="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!F,B=R?qq:N?tt:D?swan:P?my:y?wx:L?uni:w?jd:{},$=V&&window&&window.navigator&&window.navigator.userAgent||"",q=/(micromessenger|webbrowser)/i.test($),W=function(){let e="WEB";return q?e="WEB":R?e="QQ_MP":N?e="TT_MP":D?e="BAIDU_MP":P?e="ALI_MP":y?e=b?"DONUT_NATIVE_APP":"WX_MP":L?e="UNI_NATIVE_APP":G?e="NS_NATIVE_APP":F&&(e="RN_NATIVE_APP"),t[e]}(),Y=/iPad/i.test($),K=/iPhone/i.test($)&&!Y,H=/iPod/i.test($),j=K||Y||H,z=function(){var e=$.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Z=/Android/i.test($),J=function(){var e,t,s=$.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),X=/Firefox/i.test($),Q=/Edge/i.test($),ee=!Q&&/Chrome/i.test($),te=/MSIE/.test($)||-1<$.indexOf("Trident")&&-1<$.indexOf("rv:11.0"),se=function(){var e=/MSIE\s(\d+)\.\d/.exec($);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test($)&&/rv:11.0/.test($)?11:t}(),ne=/Safari/i.test($)&&!ee&&!Z&&!Q,oe=/Windows/i.test($),ie=/MAC OS X/i.test($),re=V&&"undefined"!=typeof Worker&&!te,ae=Z||j,ce=V&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,le=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!j||e||ne))}();function de(){let e="unknown";if(ie&&(e="mac"),oe&&(e="windows"),j&&(e="ios"),Z&&(e="android"),U)try{var t=wx.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}let ue=2800,_e=2801,he=3e3,ge="application/x-www-form-urlencoded;charset=UTF-8";function pe(e){return h(this,arguments,void 0,function*({method:i,url:o,data:r,timeout:a=he}){return new Promise(U?(t,e)=>{B.request({url:o,data:r,method:i,timeout:a,header:{"content-type":ge},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${ue}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${_e}}`))},a);s.onreadystatechange=function(){if(4===s.readyState)if(clearTimeout(n),200===s.status||304===s.status)try{t(s.responseText?JSON.parse(s.responseText):null)}catch(e){t(s.responseText)}else e(new Error(`{"message":"Network error","code":${ue}}`))},s.open(i,o,!0),s.setRequestHeader("Content-type",ge),s.send(r||null)})})}function Ee(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(I(e)){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(e)||"[object Set]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e))&&0===e.size}function me(n){if(null===n||"object"!=typeof n)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(n instanceof Map){let s=new Map;return n.forEach((e,t)=>{s.set(me(t),me(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(me(e))}),t}if(Array.isArray(n))return n.map(e=>me(e));let e=Object.getPrototypeOf(n),s=Object.create(e);return[...Object.getOwnPropertyNames(n),...Object.getOwnPropertySymbols(n)].forEach(e=>{var t=Object.getOwnPropertyDescriptor(n,e);t&&(t.get||t.set?Object.defineProperty(s,e,t):s[e]=me(n[e]))}),s}function fe(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var Se=Object.freeze({__proto__:null,ANDROID_VERSION:J,IE_VERSION:se,IN_ALIPAY_MINI_APP:P,IN_BAIDU_MINI_APP:D,IN_BROWSER:V,IN_DONUT_NATIVE_APP:b,IN_JD_MINI_APP:w,IN_MINI_APP:U,IN_NS_NATIVE_APP:G,IN_QQ_MINI_APP:R,IN_RN_APP:F,IN_TT_MINI_APP:N,IN_UNI_APP:k,IN_UNI_NATIVE_APP:L,IN_WX_MINI_APP:y,IN_WX_MINI_APP_DESK:T,IN_WX_MINI_GAME:A,IN_WX_MINI_PLUGIN:x,IOS_VERSION:z,IS_ANDROID:Z,IS_CHROME:ee,IS_EDGE:Q,IS_FIREFOX:X,IS_IE:te,IS_IOS:j,IS_IPAD:Y,IS_IPHONE:K,IS_IPOD:H,IS_MAC:ie,IS_SAFARI:ne,IS_WECHAT:q,IS_WIN:oe,IS_WORKER_AVAILABLE:re,MINI_APP_NAMESPACE:B,USER_AGENT:$,base16EncodeBinaryString:O,deepCopyWithMethods:me,deepMerge:M,generatePromise:fe,getPlatformType:de,getType:E,httpRequest:pe,isArray:m,isArrayOrObject:S,isEmpty:Ee,isFlutterWeb:ce,isH5:ae,isIOSWebView:le,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(+e)||"object"==typeof e&&e.constructor===Number),isObject:f,isPlainObject:I,isString:p,isUndefined:g,isValidRequestKey:v,platform:W,randomInt:C,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t}});class ve{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t;try{null!=(t=this._socket)&&t.send(e)}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=s,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class Ie{connectSocket(e){return this._socket=wx.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null!=(t=this._socket)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}let Ce="CONNECT",Me="SEND",Oe="DISCONNECT",Te="OPEN",ye="MESSAGE",Ae="CLOSE",Re="ERROR",Ne="SEND_FAIL";class De{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){var t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:Ce,url:e})}send(e){var t;try{null!=(t=this._worker)&&t.postMessage({type:Me,data:e})}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:t,onMessage:n,onClose:i,onError:o,onSendFail:r}=e;if(this._worker){let s={[Te]:t,[ye]:n,[Ae]:i,[Re]:o,[Ne]:r};this._onSendFail=r,this._worker.onmessage=e=>{var t=((null==e?void 0:e.data)||{})["type"];"function"==typeof s[t]&&null!=(t=s[t])&&t.call(s,null==e?void 0:e.data)}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Oe}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Pe,we=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return U?P?my.getStorageSync({key:e}).data:B.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){var s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){U?P?my.setStorageSync({key:e,data:JSON.stringify(t)}):B.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(Pe=Pe||{});class Le{constructor(t){this._url="",this._readyState=Pe.DISCONNECTED,this._url=t,this._id=C(),this._emitter=new e,y?this._socket=new Ie:this._canUseWebWorker()?this._socket=new De:this._socket=new ve,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Pe.CONNECTED,Pe.CONNECTING].includes(this._readyState)||(this._readyState=Pe.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Pe.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Pe.CONNECTED,Pe.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===Pe.CONNECTED}disconnect(){this._readyState=Pe.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Pe.CONNECTING&&(this._readyState=Pe.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){var e=we.get("cloudConfig")||{};return(g(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&re}}let be="CHINA",ke="OVERSEA",Ue="SINGAPORE",Ge="KOREA",Fe="GERMANY",xe="IND",Ve="JPN",Be="USA",$e="INDONESIA",qe={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:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},We={[Ue]:[[2e7,3e7],[172e7,173e7]],[Ge]:[[3e7,4e7],[173e7,174e7]],[Fe]:[[4e7,5e7],[174e7,175e7]],[xe]:[[5e7,6e7],[175e7,176e7]],[Ve]:[[6e7,7e7],[176e7,177e7]],[Be]:[[7e7,8e7],[177e7,178e7]],[$e]:[[8e7,9e7],[178e7,179e7]]};function Ye(t){var e;if(null!=(e=we.get("instance"))&&e.oversea)return ke;for(let e of Object.keys(We))for(var[s,n]of We[e])if(t>=s&&t<n)return e;return be}var Ke,He="1.4.1";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(Ke=Ke||{});let je=Ke.INITIAL;function ze(){var e=Math.random();return 0===e?ze():e}function Ze(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:i}=we.get("instance"),o=ze(),r=de(),a=function(){var e=de();let t=-1;return"ios"===e?t=z||-1:"android"===e&&(t=J||-1),t}(),n=(s={sdkappid:n,instanceid:i,random:o,platform:W,host:r,version:a,sdkversion:He},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}var Je=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){var s=Date.now();this._timeOffsetWithServer=t+(s-e)-s}};let Xe=16;var Qe=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){var t=e["id"];this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){var{id:e,callback:t,context:s,isOnce:n=!1,intervalMs:i=Xe}=e,o=Math.max(i,Xe);return{id:e,nextExecuteTime:Date.now()+o,intervalMs:i,callback:t,context:s,isOnce:n}}addTask(e){e=this._createTask(e);this._addTaskToScheduler(e)}addOnceTask(e){e=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(t){var e=this._tasks.findIndex(e=>e.id===t);-1<e&&(this._tasks.splice(e,1),this._taskMap.delete(t),this._scheduleNextTask())}updateTaskInterval(e,t){e=this._taskMap.get(e);e&&(e.intervalMs=t,e.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);var e=this._tasks[0];e&&(e=Math.max(0,e.nextExecuteTime-Date.now()),this._timer=setTimeout(()=>this._execute(),e))}_execute(){for(var e=Date.now();this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){var t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function et(t){var s=[];for(let e=0;e<t.length;e+=1){var n,i=t.charCodeAt(e);55296<=i&&i<=56319?(n=t.charCodeAt(++e)-56320+(i-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):i<=127?s.push(i):i<=2047?s.push(192|i>>6,128|63&i):s.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(s)}function st(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&v(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=st(e[t]));return s}function nt(e,t){if(s.includes(e))return 0;var n=et(JSON.stringify(t));let i=4294967295;var o=n["length"];for(let e=0;e<o;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return(4294967295^i)>>>0}function ot(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,tjgID:"",seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}}function it(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}}let rt=C();function at(){return rt=rt<2415919103?rt+1:C()}function ct(){var e=we.get("login")||{},t=we.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.4.1",tiny_id:Number(e.tinyID),user_id:e.userId,platform:W,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var lt,ht,dt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}},generateProtocolData:ot,generateSSOLogProtocolData:it,generateSequence:at,getCommonHead:ct,taskScheduler:Qe,timeManager:Je});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(lt=lt||{});let ut={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class _t{constructor(e){this.level=lt.info,this._canSendLog=!0,this._logCreatedAt=Je.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=void 0;var{method:e,eventType:t=0,uiPlatform:s,message:n}=e||{};this.eventType=t,this.method=e,this.uiPlatform=s,this.message=n||""}setMoreMessage(e){this.moreMessage=this.moreMessage+" "+e}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Je.getTimeOffsetWithServer()}end(e=!1){var t;this._canSendLog&&(t=Je.getServerTimeMs(),0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:`+t),e?(this._canSendLog=!1,this.timestamp=Je.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout(()=>{this._canSendLog=!1,this.timestamp=Je.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())},0))}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=we.get("netWorkMonitor"))&&t.isNetworkOnline&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage)&&this.setMoreMessage(e.errorMessage),this.level=lt.error):console.warn("SSOLogData.setError value not instanceof Error, please check!"),this}setLogInfo(t){return Object.keys(t).forEach(e=>{Object.keys(ut).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{ut[e]&&(t[ut[e]]=this[e])}),t}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(ht=ht||{});var gt=ht;let pt=20,Et=6e4,mt=[4,5,6],ft=[],St=[],vt="report-logger";var It=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=pt,this._maxThreshold=100,this._waitingTime=Et,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,u.subscribeInnerEvent(gt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Qe.addTask({id:vt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=pt,evt_rpt_waiting:t=Et,evt_rpt_level:s=mt,evt_rpt_sdkappid_bl:n=ft,evt_rpt_tinyid_wl:i=St}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=i}createSSOLogData(e){var t=new _t(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately())&&this.uploadSSOLogData()}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&0<this._logQueue.length&&this.uploadSSOLogData()}uploadSSOLogData(){return h(this,void 0,void 0,function*(){var e,t;0!==this._logQueue.length&&(t=this._logQueue.slice(),t=this._filterLogs(t),this._logQueue=[],0===t.length||Ee((t={Header:ct(),Event:t}).Header.user_id)||(e=(t=it({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void Bt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(y){var s=null==(t=null==(e=wx.getAccountInfoSync)?void 0:e.call(wx))?void 0:t.miniProgram;if(s){let{appId:e,envVersion:t}=s;we.set("instance",{appId:e,envVersion:t})}}else V&&we.set("instance",{href:window.location.href})}_filterLogs(e){var t=(we.get("login")||{})["tinyID"],s=(we.get("instance")||{})["sdkAppId"];return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}reset(){console.log("SSO_LOG_MODULE.reset"),Qe.removeTask(vt),u.unSubscribeInnerEvent(gt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=pt,this._maxThreshold=100,this._waitingTime=Et,this._logQueue=[]}};let Ct=15e3,Mt="Channel",Ot="channel_schedule_task",Tt="channel_reconnect_task",yt="connected",At="connecting",Rt="disconnected",Nt=1e3,Dt="network_status_change",Pt="activity_status_change",wt="send_fail",Lt="reconnect_failed",bt="socket_error",kt="socket_close";function Ut(e){return(Ut="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 Gt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ft,Yt,xt={exports:{}},Vt=(Ft||(xt.exports=function s(n,i,o){function r(t,e){if(!i[t]){if(!n[t]){if(!e&&Gt)return Gt(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=i[t]={exports:{}};n[t][0].call(e.exports,function(e){return r(n[t][1][e]||e)},e,e.exports,s,n,i,o)}return i[t].exports}for(var a=Gt,e=0;e<o.length;e++)r(o[e]);return r}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,i=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var i=n.shift();if(i){if("object"!=Ut(i))throw new TypeError(i+"must be non-object");for(var o in i)t=i,s=o,Object.prototype.hasOwnProperty.call(t,s)&&(e[o]=i[o])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){for(var t,s,n,i,o=t=0,r=e.length;o<r;o++)t+=e[o].length;for(i=new Uint8Array(t),o=s=0,r=e.length;o<r;o++)n=e[o],i.set(n,s),s+=n.length;return i}}),o={arraySet:function(e,t,s,n,i){for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var c=new l.Buf8(256),n=0;n<256;n++)c[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function u(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}c[254]=c[254]=1,s.string2buf=function(e){for(var t,s,n,i,o=e.length,r=0,a=0;a<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),r+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(r),a=i=0;i<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),s<128?t[i++]=s:(s<2048?t[i++]=192|s>>>6:(s<65536?t[i++]=224|s>>>12:(t[i++]=240|s>>>18,t[i++]=128|s>>>12&63),t[i++]=128|s>>>6&63),t[i++]=128|63&s);return t},s.buf2binstring=function(e){return u(e,e.length)},s.binstring2buf=function(e){for(var t=new l.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){for(var s,n,i,o=t||e.length,r=new Array(2*o),a=s=0;a<o;)if((n=e[a++])<128)r[s++]=n;else if(4<(i=c[n]))r[s++]=65533,a+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&a<o;)n=n<<6|63&e[a++],i--;1<i?r[s++]=65533:n<65536?r[s++]=n:(n-=65536,r[s++]=55296|n>>10&1023,r[s++]=56320|1023&n)}return u(r,s)},s.utf8border=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+c[e[s]]>t?s:t}},{"./common":Ft=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var i=65535&e,o=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;o=o+(i=i+t[n++]|0)|0,--r;);i%=65521,o%=65521}return i|o<<16}},{}],4:[function(e,t,s){t.exports={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}},{}],5:[function(e,t,s){var a=function(){for(var e=[],t=0;t<256;t++){for(var s=t,n=0;n<8;n++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}();t.exports=function(e,t,s,n){var i=a,o=n+s;e^=-1;for(var r=n;r<o;r++)e=e>>>8^i[255&(e^t[r])];return~e}},{}],6:[function(e,t,s){t.exports=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}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,o,r,a,l=e.state,c=e.next_in,u=e.input,d=c+(e.avail_in-5),_=e.next_out,h=e.output,g=_-(t-e.avail_out),p=_+(e.avail_out-257),E=l.dmax,m=l.wsize,S=l.whave,f=l.wnext,v=l.window,I=l.hold,C=l.bits,M=l.lencode,O=l.distcode,T=(1<<l.lenbits)-1,y=(1<<l.distbits)-1;e:do{for(C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=M[I&T];;){if(I>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))h[_++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=M[(65535&s)+(I&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(i=65535&s,(n&=15)&&(C<n&&(I+=u[c++]<<C,C+=8),i+=I&(1<<n)-1,I>>>=n,C-=n),C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=O[I&y];;){if(I>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=O[(65535&s)+(I&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(o=65535&s,C<(n&=15)&&(I+=u[c++]<<C,(C+=8)<n)&&(I+=u[c++]<<C,C+=8),E<(o+=I&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(I>>>=n,C-=n,(n=_-g)<o){if(S<(n=o-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=v,(r=0)===f){if(r+=m-n,n<i){for(i-=n;h[_++]=v[r++],--n;);r=_-o,a=h}}else if(f<n){if(r+=m+f-n,(n-=f)<i){for(i-=n;h[_++]=v[r++],--n;);if(r=0,f<i){for(i-=n=f;h[_++]=v[r++],--n;);r=_-o,a=h}}}else if(r+=f-n,n<i){for(i-=n;h[_++]=v[r++],--n;);r=_-o,a=h}for(;2<i;)h[_++]=a[r++],h[_++]=a[r++],h[_++]=a[r++],i-=3;i&&(h[_++]=a[r++],1<i)&&(h[_++]=a[r++])}else{for(r=_-o;h[_++]=h[r++],h[_++]=h[r++],h[_++]=h[r++],2<(i-=3););i&&(h[_++]=h[r++],1<i)&&(h[_++]=h[r++])}break}}break}}while(c<d&&_<p);c-=i=C>>3,I&=(1<<(C-=i<<3))-1,e.next_in=c,e.next_out=_,e.avail_in=c<d?d-c+5:5-(c-d),e.avail_out=_<p?p-_+257:257-(_-p),l.hold=I,l.bits=C}},{}],8:[function(e,t,s){var P=e("../utils/common"),w=e("./adler32"),L=e("./crc32"),b=e("./inffast"),k=e("./inftrees"),U=0,G=-2,F=1,n=852,i=592;function x(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function o(){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 P.Buf16(320),this.work=new P.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function r(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=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new P.Buf32(n),t.distcode=t.distdyn=new P.Buf32(i),t.sane=1,t.back=-1,U):G}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,r(e)):G}function l(e,t){var s,n;return!e||!e.state||(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?G:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function c(e,t){var s;return e?(s=new o,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):G}var V,B,q=!0;function $(e,t,s,n){var i,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new P.Buf8(e.wsize)),n>=e.wsize?(P.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(i=e.wsize-e.wnext)&&(i=n),P.arraySet(e.window,t,s-n,i,e.wnext),(n-=i)?(P.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=r,s.inflateInit=function(e){return c(e,15)},s.inflateInit2=c,s.inflate=function(e,t){var s,n,i,o,r,a,l,c,u,d,_,h,g,p,E,m,S,f,v,I,C,M,O,T,y=0,A=new P.Buf8(4),R=[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 G;12===(s=e.state).mode&&(s.mode=13),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,d=a,_=l,M=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(2&s.wrap&&35615===c)A[s.check=0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0),u=c=0,s.mode=2;else if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31)e.msg="incorrect header check",s.mode=30;else if(8!=(15&c))e.msg="unknown compression method",s.mode=30;else{if(u-=4,C=8+(15&(c>>>=4)),0===s.wbits)s.wbits=C;else if(C>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<C,e.adler=s.check=1,s.mode=512&c?10:12,u=c=0}}break;case 2:for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(s.flags=c,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=c>>8&1),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0,s.mode=3;case 3:for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.head&&(s.head.time=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,s.check=L(s.check,A,4,0)),u=c=0,s.mode=4;case 4:for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.head&&(s.head.xflags=255&c,s.head.os=c>>8),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0,s.mode=5;case 5:if(1024&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.length=c,s.head&&(s.head.extra_len=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=a<(h=s.length)?a:h)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),P.arraySet(s.head.extra,n,o,h,C)),512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}u=c=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}e.adler=s.check=x(c),u=c=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last)c>>>=7&u,u-=7&u,s.mode=27;else{for(;u<3;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}switch(s.last=1&c,--u,3&(c>>>=1)){case 0:s.mode=14;break;case 1:N=D=void 0;var N,D=s;if(q){for(V=new P.Buf32(512),B=new P.Buf32(32),N=0;N<144;)D.lens[N++]=8;for(;N<256;)D.lens[N++]=9;for(;N<280;)D.lens[N++]=7;for(;N<288;)D.lens[N++]=8;for(k(1,D.lens,0,288,V,0,D.work,{bits:9}),N=0;N<32;)D.lens[N++]=5;k(2,D.lens,0,32,B,0,D.work,{bits:5}),q=!1}if(D.lencode=V,D.lenbits=9,D.distcode=B,D.distbits=5,s.mode=20,6!==t)break;c>>>=2,u-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,u-=2}break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,u=c=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;P.arraySet(i,n,o,h,r),a-=h,o+=h,l-=h,r+=h,s.length-=h}else s.mode=12;break;case 17:for(;u<14;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(s.nlen=257+(31&c),c>>>=5,u-=5,s.ndist=1+(31&c),c>>>=5,u-=5,s.ncode=4+(15&c),c>>>=4,u-=4,286<s.nlen||30<s.ndist){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;u<3;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.lens[R[s.have++]]=7&c,c>>>=3,u-=3}for(;s.have<19;)s.lens[R[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,O={bits:s.lenbits},M=k(0,s.lens,0,19,s.lencode,0,s.work,O),s.lenbits=O.bits,M){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;m=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(S<16)c>>>=E,u-=E,s.lens[s.have++]=S;else{if(16===S){for(T=E+2;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c>>>=E,u-=E,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}C=s.lens[s.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===S){for(T=E+3;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}C=0,h=3+(7&(c>>>=E)),c>>>=3,u=u-E-3}else{for(T=E+7;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}C=0,h=11+(127&(c>>>=E)),c>>>=7,u=u-E-7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=C}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,O={bits:s.lenbits},M=k(1,s.lens,0,s.nlen,s.lencode,0,s.work,O),s.lenbits=O.bits,M){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,O={bits:s.distbits},M=k(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,O),s.distbits=O.bits,M){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(6<=a&&258<=l){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,b(e,_),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;m=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(m&&!(240&m)){for(f=E,v=m,I=S;m=(y=s.lencode[I+((c&(1<<f+v)-1)>>f)])>>>16&255,S=65535&y,!(f+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}c>>>=f,u-=f,s.back+=f}if(c>>>=E,u-=E,s.back+=E,s.length=S,0===m){s.mode=26;break}if(32&m){s.back=-1,s.mode=12;break}if(64&m){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&m,s.mode=22;case 22:if(s.extra){for(T=s.extra;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;m=(y=s.distcode[c&(1<<s.distbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(!(240&m)){for(f=E,v=m,I=S;m=(y=s.distcode[I+((c&(1<<f+v)-1)>>f)])>>>16&255,S=65535&y,!(f+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}c>>>=f,u-=f,s.back+=f}if(c>>>=E,u-=E,s.back+=E,64&m){e.msg="invalid distance code",s.mode=30;break}s.offset=S,s.extra=15&m,s.mode=24;case 24:if(s.extra){for(T=s.extra;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===l)break e;if(s.offset>(h=_-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}g=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),p=s.window}else p=i,g=r-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;i[r++]=p[g++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;i[r++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;u<32;){if(0===a)break e;a--,c|=n[o++]<<u,u+=8}if(_-=l,e.total_out+=_,s.total+=_,_&&(e.adler=s.check=(s.flags?L:w)(s.check,i,_,r-_)),_=l,(s.flags?c:x(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}u=c=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}u=c=0}s.mode=29;case 29:M=1;break e;case 30:M=-3;break e;case 31:return-4;default:return G}return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,(s.wsize||_!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&$(e,e.output,e.next_out,_-e.avail_out)?(s.mode=31,-4):(d-=e.avail_in,_-=e.avail_out,e.total_in+=d,e.total_out+=_,s.total+=_,s.wrap&&_&&(e.adler=s.check=(s.flags?L:w)(s.check,i,_,e.next_out-_)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),M=(0==d&&0===_||4===t)&&M===U?-5:M)},s.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,U):G},s.inflateGetHeader=function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,U):G},s.inflateSetDictionary=function(e,t){var s,n=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?G:11===s.mode&&w(1,t,n,0)!==s.check?-3:$(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,U)},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var b=e("../utils/common"),k=[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],U=[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],G=[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],F=[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];t.exports=function(e,t,s,n,i,o,r,a){for(var l,c,u,d,_,h,g,p,E,m=a.bits,S=0,f=0,v=0,I=0,C=0,M=0,O=0,T=0,y=0,A=0,R=null,N=0,D=new b.Buf16(16),P=new b.Buf16(16),w=null,L=0,S=0;S<=15;S++)D[S]=0;for(f=0;f<n;f++)D[t[s+f]]++;for(C=m,I=15;1<=I&&0===D[I];I--);if(I<C&&(C=I),0===I)i[o++]=20971520,i[o++]=20971520,a.bits=1;else{for(v=1;v<I&&0===D[v];v++);for(C<v&&(C=v),S=T=1;S<=15;S++)if((T=(T<<1)-D[S])<0)return-1;if(0<T&&(0===e||1!==I))return-1;for(P[1]=0,S=1;S<15;S++)P[S+1]=P[S]+D[S];for(f=0;f<n;f++)0!==t[s+f]&&(r[P[t[s+f]]++]=f);if(h=0===e?(R=w=r,19):1===e?(R=k,N-=257,w=U,L-=257,256):(R=G,w=F,-1),S=v,_=o,O=f=A=0,u=-1,d=(y=1<<(M=C))-1,1===e&&852<y||2===e&&592<y)return 1;for(;;){for(E=r[f]<h?(p=0,r[f]):r[f]>h?(p=w[L+r[f]],R[N+r[f]]):(p=96,0),l=1<<(g=S-O),v=c=1<<M;i[_+(A>>O)+(c-=l)]=g<<24|p<<16|E,0!==c;);for(l=1<<S-1;A&l;)l>>=1;if(0!==l?A=(A&l-1)+l:A=0,f++,0==--D[S]){if(S===I)break;S=t[s+r[f]]}if(C<S&&(A&d)!==u){for(_+=v,T=1<<(M=S-(O=0===O?C:O));M+O<I&&!((T-=D[M+O])<=0);)M++,T<<=1;if(y+=1<<M,1===e&&852<y||2===e&&592<y)return 1;i[u=A&d]=C<<24|M<<16|_-o}}0!==A&&(i[_+A]=S-O<<24|64<<16),a.bits=C}return 0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={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"}},{}],11:[function(e,t,s){t.exports=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}},{}],"/lib/inflate.js":[function(e,t,s){var d=e("./zlib/inflate"),_=e("./utils/common"),h=e("./utils/strings"),g=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),o=e("./zlib/gzheader"),p=Object.prototype.toString;function r(e){if(!(this instanceof r))return new r(e);this.options=_.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(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 i,this.strm.avail_out=0,d.inflateInit2(this.strm,t.windowBits));if(e!==g.Z_OK)throw new Error(n[e]);if(this.header=new o,d.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===p.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=d.inflateSetDictionary(this.strm,t.dictionary))!==g.Z_OK)throw new Error(n[e])}function a(e,t){t=new r(t);if(t.push(e,!0),t.err)throw t.msg||n[t.err];return t.result}r.prototype.push=function(e,t){var s,n,i,o,r,a=this.strm,l=this.options.chunkSize,c=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?g.Z_FINISH:g.Z_NO_FLUSH,"string"==typeof e?a.input=h.binstring2buf(e):"[object ArrayBuffer]"===p.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new _.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=d.inflate(a,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&c?d.inflateSetDictionary(this.strm,c):s)===g.Z_BUF_ERROR&&!0===u&&(s=g.Z_OK,u=!1),s!==g.Z_STREAM_END&&s!==g.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==g.Z_STREAM_END&&(0!==a.avail_in||n!==g.Z_FINISH&&n!==g.Z_SYNC_FLUSH)||("string"===this.options.to?(i=h.utf8border(a.output,a.next_out),o=a.next_out-i,r=h.buf2string(a.output,i),a.next_out=o,a.avail_out=l-o,o&&_.arraySet(a.output,a.output,i,o,0),this.onData(r)):this.onData(_.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(u=!0),(0<a.avail_in||0===a.avail_out)&&s!==g.Z_STREAM_END);return(n=s===g.Z_STREAM_END?g.Z_FINISH:n)===g.Z_FINISH?(s=d.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===g.Z_OK):n!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(a.avail_out=0))},r.prototype.onData=function(e){this.chunks.push(e)},r.prototype.onEnd=function(e){e===g.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=_.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=r,s.inflate=a,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},s.ungzip=a},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),xt.exports),Bt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=Nt,this._currentConnectState=yt,this._beforeSendInterceptors=[]}init(){Qe.addTask({id:Ot,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){var{sdkAppId:t,testEnv:s}=we.get("instance"),n=Ye(t);return Ze(s?qe.TEST[n].DEFAULT:qe.PRODUCTION[n].INITIAL.replace("*",""+t),{isBinary:e})}(this._isBinarySupported),u.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s,{requestId:n,timeout:i=Ct,canResend:o=!0}=t||{};if(Ee(e))return console.warn(Mt+".sendPacket: packet is empty ",e),null;this._executeBeforeSendInterceptors(e),this._currentConnectState===Rt&&this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:wt});var r=JSON.stringify(e);let a=null;if(n){let{resolve:e,reject:t,promise:s}=fe();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:i,canResend:o})}t=this._isBinarySupported?et(r).buffer:r;return null!=(s=this._socketAdapter)&&s.send(t),a}connect(){this._socketAdapter=new Le(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();var e=null==(e=this._socketAdapter)?void 0:e.getId(),t=Mt+`.connect isWorkerEnabled: false socketID:${e} url:`+this._url;this._connectionId=e,this._ssoLog({method:"connect",message:t}),console.log(t)}disconnect(){var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Mt+".disconnect socketID:"+e;this._ssoLog({method:"disconnect",message:e}),console.log(e),this._removeEventListeners(),null!=(e=this._socketAdapter)&&e.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(Mt+".dispose"),Qe.removeTask(Ot),Qe.removeTask(Tt),u.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=Nt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(var t of this._beforeSendInterceptors){var{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){var e=this._currentConnectState===At&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return h(this,void 0,void 0,function*(){var e=`${Mt}.reconnect isReconnecting: ${this._isReconnecting} currentConnectState: `+this._currentConnectState;if(this._ssoLog({method:"reconnect",message:e}),console.log(e),!this._shouldSkipReconnect()){this._url=function(e){var{sdkAppId:t,testEnv:s}=we.get("instance"),t=Ye(t);if(s)return Ze(qe.TEST[t].DEFAULT,{isBinary:e});let n=qe.PRODUCTION[t],i=V&&n.ANYCAST;return Ze({[Ke.INITIAL]:()=>(je=Ke.DEFAULT,n.DEFAULT),[Ke.DEFAULT]:()=>(je=Ke.IPV6,n.IPV6),[Ke.IPV6]:()=>(je=Ke.BACKUP,n.BACKUP),[Ke.BACKUP]:()=>(je=i?Ke.ANYCAST:Ke.DEFAULT,i?n.ANYCAST:n.DEFAULT),[Ke.ANYCAST]:()=>(je=Ke.DEFAULT,n.ANYCAST="",n.DEFAULT)}[je](),{isBinary:e})}(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Lt}),console.warn(Mt+".reconnect failed: ",e)}}})}_addEventListeners(){var e;null!=(e=this._socketAdapter)&&e.on("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.on("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.on("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.on("error",this._onError,this),null!=(e=this._socketAdapter)&&e.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e;null!=(e=this._socketAdapter)&&e.off("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.off("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.off("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.off("error",this._onError,this),null!=(e=this._socketAdapter)&&e.off("sendFail",this._onSendFail,this)}_onClose(e){var{socketId:e,event:t}=e||{},s=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,s=`${Mt}.onClose closeSocketID: ${e} currentSocketID: ${this._connectionId} connectionDuration: ${s} code: ${null==t?void 0:t.code} reason: `+(null==t?void 0:t.reason);this._ssoLog({method:"onClose",message:s}),console.warn(s),e===this._connectionId&&this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:kt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){var{socketId:e,error:t}=e||{},t=`${Mt}.onError sourceSocketID: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+JSON.stringify(t);this._ssoLog({method:"onError",message:t}),console.warn(t),e===this._connectionId&&this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:bt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){var{socketId:e,error:t}=e||{},e=`${Mt}.onSendFail sendFailSocketId: ${e} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+t;this._ssoLog({method:"onSendFail",message:e}),console.warn(e),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(t){let s,e;this._updateHeartbeatTime();try{s=this._isBinarySupported?(this._isCompressedData(t.data)?e=>{var t=new Uint8Array(e).slice(4);let s;try{s=Vt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s}:function(e){var i=new Uint8Array(e);let o="",r=0;for(var a=i["length"];r<a;){let t=i[r],s=0,n=0;if(t<=127?(s=0,n=255&t):t<=223?(s=1,n=31&t):t<=239?(s=2,n=15&t):t<=244&&(s=3,n=7&t),0<a-r-s)for(let e=0;e<s;e+=1)t=i[r+e+1],n=n<<6|63&t;else n=65533,s=a-r;o+=String.fromCodePoint(n),r+=s+1}return o})(t.data):t.data,e=JSON.parse(s)}catch(s){let e=t.data;return this._ssoLog({method:"jsonParseError",message:e}),void console.error(s)}var n;e&&e.head&&({seq:t,servcmd:n}=e.head,this._pendingRequests.has(""+t+n)?this._handleRequestResponse(e):this._handlePushMessage(e))}_handleRequestResponse(e){var{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:i,ErrorCode:n=n,ErrorInfo:i=i}=(null==e?void 0:e.body)||{},t=""+t+s,{resolve:s,reject:o}=this._pendingRequests.get(t);this._pendingRequests.delete(t),n&&0!==n?(u.emitInnerEvent("error",{errorCode:n,errorInfo:i}),o({errorCode:n,errorInfo:i})):s(e.body)}_handlePushMessage(e){var t=e.head["servcmd"],{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),u.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;console.log(`${Mt}._checkPendingRequestsAndResend reConnectFlag:${this._isReconnecting} promiseMap.size:`+this._pendingRequests.size),null!=(e=this._pendingRequests)&&e.forEach((e,t)=>{var{uplinkData:s,canResend:n,resolve:i,reject:o,timeout:r}=e;if(n){this._pendingRequests.set(t,{resolve:i,reject:o,timestamp:Date.now(),uplinkData:s,timeout:r,canResend:n});let e=this._isBinarySupported?et(s).buffer:s;null!=(i=this._socketAdapter)&&i.send(e)}else this._pendingRequests.delete(t)})}_onConnect(e){var{socketId:e,event:t={}}=e||{},s=(this._connectionId=e,this._connectionEstablishedTime=Date.now(),Date.now()-this._connectionStartTime),s=Mt+`.onConnect cost:${s} ms. socketID:${e} res:`+JSON.stringify(t);if(this._ssoLog({method:"onConnect",message:s}),console.log(s),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){let e=Mt+".reconnect success";this._ssoLog({method:"reconnectSuccess",message:e}),console.log(e),u.emitInnerEvent(gt.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:yt,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}_sendAck(e){e=ot({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return h(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var e;return(null==(e=this._socketAdapter)?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return h(this,void 0,void 0,function*(){var e,t=ot({servcmd:"heartbeat.alive",data:{}});try{let e=""+t.head.seq+t.head.servcmd;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){var s=null==(e=we.get("netWorkMonitor"))?void 0:e.isNetWorkOnline,s=Mt+`.sendHeartbeat failed. isNetWorkOnline:${s} error: `+t;this._ssoLog({method:"sendHeartbeatError",message:s}),console.debug(s),this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}_sendHeartbeatIfReady(){return h(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=L?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){var t=Mt+".networkStatusChange "+JSON.stringify(e),{isNetworkOnline:t,networkType:e}=(this._ssoLog({method:"networkStatusChange",message:t}),console.warn(t),e);t&&"none"!==e?this._handleConnectStateChange({state:yt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Dt}):this._handleConnectStateChange({state:Rt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Dt})}isPrivateNetWork(){var e=we.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){var{state:e,shouldAttemptReconnect:t,shouldEmitEvent:s,reason:n}=e,n=`${Mt}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${t} shouldEmitEvent: ${s} reason: `+n;this._currentConnectState!==e&&(this._ssoLog({method:"handleConnectStateChange",message:n}),console.log(n),s&&(console.log(`${Mt}._handleConnectStateChange from ${this._currentConnectState} to `+e),u.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:e}}),(this._currentConnectState=e)===Rt)&&u.emitInnerEvent(gt.SOCKET_DISCONNECTED),t)&&(this._resetReconnectDelay(),Qe.addTask({id:Tt,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}_handleActivityStatusChange(e){var t=null==(t=null==(t=this._socketAdapter)?void 0:t._ws)?void 0:t.readyState,e=`${Mt}.activityStatusChange ${JSON.stringify(e)} readyState: `+t;this._ssoLog({method:"activityStatusChange",message:e}),console.warn(e),3===t&&this._handleConnectStateChange({state:Rt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Pt})}_resetReconnectDelay(){console.log(Mt+"._resetReconnectDelay"),Qe.removeTask(Tt);var e=null==(e=we.get("activityMonitor"))?void 0:e.isActive;this._intendedDelay=e?Nt:1e3}_scheduleReconnectWithBackoff(){var e=null==(e=we.get("activityMonitor"))?void 0:e.isActive,e=(this._intendedDelay=e?Math.min(5e3,Math.max(Nt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay)),(new Date).toTimeString().slice(0,8)),e=Mt+`.scheduleReconnectWithBackoff timeStr: ${e} intendedDelay: `+this._intendedDelay;this._ssoLog({method:"scheduleReconnectWithBackoff",message:e}),console.log(e),this.reconnect(),Qe.updateTaskInterval(Tt,this._intendedDelay)}_ssoLog(e){var{method:e,message:t}=e;It.createSSOLogData({method:e}).setLogInfo({message:t}).end()}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(t){h(this,void 0,void 0,function*(){var e=t.split("/")[2];if(e.startsWith("ws")){e=`https://${e}/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield pe({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseBySSO failed. error:",e)}}})}(this._url),function(t){h(this,void 0,void 0,function*(){var e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield pe({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseByCDN failed. error:",e)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(var[e,t]of this._pendingRequests.entries()){var{reject:t,timestamp:s,timeout:n}=t;Date.now()-s>=n&&(this._pendingRequests.delete(e),3e4<=Date.now()-this._lastDiagnoseAt&&this._diagnose(),t({errorCode:_e,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;(null!=(e=we.get("instance"))&&e.devMode||(e=de(),P)||y&&"windows"===e||L)&&(this._isBinarySupported=!1)}_isCompressedData(e){e=new Uint8Array(e);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};let $t={init:function(e){we.set("instance",e),Bt.init()},destroy:function(){Bt.dispose(),we.clear(),Qe.dispose()},notificationCenter:u,channel:Bt,store:we,ssoLog:It,utils:Se,common:dt,constants:i},qt=e=>"function"==typeof e;function Wt(t,s,n){let i=n||[];var e,o;return!(!t||!s)&&(e=Object.keys(t).filter(e=>!i.includes(e)),o=Object.keys(s).filter(e=>!i.includes(e)),e.length===o.length)&&e.every(e=>!!s.hasOwnProperty(e)&&("object"==typeof t[e]&&null!==t[e]?Wt(t[e],s[e],n):t[e]===s[e]))}!function(e){e.SDK_READY="sdkStateReady",e.SDK_NOT_READY="sdkStateNotReady",e.SDK_DESTROY="sdkDestroy",e.MESSAGE_RECEIVED="onMessageReceived",e.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",e.MESSAGE_MODIFIED="onMessageModified",e.MESSAGE_REVOKED="onMessageRevoked",e.MESSAGE_READ_BY_PEER="onMessageReadByPeer",e.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",e.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",e.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",e.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",e.CONVERSATION_LIST_UPDATED="onConversationListUpdated",e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",e.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",e.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",e.GROUP_LIST_UPDATED="onGroupListUpdated",e.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",e.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",e.TOPIC_CREATED="onTopicCreated",e.TOPIC_DELETED="onTopicDeleted",e.TOPIC_UPDATED="onTopicUpdated",e.PROFILE_UPDATED="onProfileUpdated",e.USER_STATUS_UPDATED="onUserStatusUpdated",e.BLACKLIST_UPDATED="blacklistUpdated",e.FRIEND_LIST_UPDATED="onFriendListUpdated",e.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",e.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",e.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",e.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",e.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",e.KICKED_OUT="kickedOut",e.ERROR="error",e.NET_STATE_CHANGE="netStateChange",e.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated"}(Yt=Yt||{});var Kt,Ht=Yt;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated",e.TOPIC_MESSAGE_DELETED="topic_message_deleted",e.TOPIC_MESSAGE_REVOKED="topic_message_revoked",e.TOPIC_MESSAGE_MODIFIED="topic_message_modified",e.TOPIC_NEW_MESSAGE="topic_new_message",e.QUALITY_STAT="quality_stat",e.SYNC_CONVERSATION_LIST="sync_conversation_list"}(Kt=Kt||{});var jt,Qt,ts,zt=Kt,Zt=(!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(jt=jt||{}),jt);let Jt=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),Xt={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"},es=(!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(Qt=Qt||{}),{modify:zt.MESSAGE_MODIFIED,delete:zt.MESSAGE_DELETED,revoke:zt.MESSAGE_REVOKED}),ss=(!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(ts=ts||{}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Xt),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:Qt,Direction:ts})),ns={[es.modify]:zt.TOPIC_MESSAGE_MODIFIED,[es.delete]:zt.TOPIC_MESSAGE_DELETED,[es.revoke]:zt.TOPIC_MESSAGE_REVOKED},os={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},is=Object.assign({},os),rs={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},as=Object.assign(Object.assign(Object.assign(Object.assign({},rs),{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}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),cs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{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"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{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"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),ls={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},ds={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},us={JOINED:1,QUITTED:2,KICKED:3,ADMIN_SET:4,ADMIN_CANCELED:5,GROUP_PROFILE_UPDATED:6,GROUP_MEMBER_PROFILE_UPDATED:7,TOPIC_PROFILE_UPDATED:8},_s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ls),{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}),{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"}),{GROUP_ID_PREFIX:ds,GROUP_TIPS_OPERATION_TYPE:us}),hs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Jt),ss),is),as),cs),_s),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),gs={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,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,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},ps={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},Es={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message"},ms={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report",GROUP_TIPS_RECOVER:"group-tips-recover"},fs={[Es.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:ms.USER_STATUS_UPDATE},{stepId:ms.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.CONVERSATION_RECOVER},{stepId:ms.HISTORY_MESSAGE_RECOVER,dependency:ms.CONVERSATION_RECOVER},{stepId:ms.BLACKLIST_RECOVER},{stepId:ms.FRIEND_RECOVER},{stepId:ms.GROUP_REVOKED_NOTICE_RECOVER,dependency:ms.HISTORY_MESSAGE_RECOVER},{stepId:ms.GROUP_TIPS_RECOVER,dependency:ms.HISTORY_MESSAGE_RECOVER},{stepId:ms.TOPIC_REQUEST_INFO_RESET},{stepId:ms.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ms.UNREAD_MESSAGE_SYNC,ms.CONVERSATION_RECOVER]},{stepId:ms.EMIT_C2C_MESSAGE_EVENT,dependency:[ms.UNREAD_MESSAGE_SYNC,ms.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[Es.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:ms.COMMERCIAL_CONFIG_UPDATE},{stepId:ms.CLOUD_CONFIG_SYNC},{stepId:ms.USER_PROFILE_SYNC},{stepId:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.FRIEND_AND_BLACKLIST_SYNC},{stepId:ms.GROUP_LIST_SYNC},{stepId:ms.CONVERSATION_LIST_SYNC},{stepId:ms.SIGNALING_MESSAGE_RECOVER,dependency:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[ms.UNREAD_MESSAGE_SYNC]},{stepId:ms.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ms.UNREAD_MESSAGE_SYNC,ms.CONVERSATION_LIST_SYNC]},{stepId:ms.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[ms.GROUP_LIST_SYNC,ms.CONVERSATION_LIST_SYNC]},{stepId:ms.CONVERSATION_GROUP_LIST_SYNC},{stepId:ms.CONVERSATION_GROUP_UPDATE,dependency:[ms.CONVERSATION_LIST_SYNC,ms.CONVERSATION_GROUP_LIST_SYNC]},{stepId:ms.QUALITY_REPORT}],[Es.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:ms.HANDLE_C2C_NEW_MESSAGE},{stepId:ms.UNREAD_MESSAGE_SYNC},{stepId:ms.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ms.HANDLE_C2C_NEW_MESSAGE},{stepId:ms.EMIT_C2C_MESSAGE_EVENT,dependency:[ms.HANDLE_C2C_NEW_MESSAGE,ms.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:ms.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ms.UNREAD_MESSAGE_SYNC]}],[Es.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:ms.HANDLE_GROUP_NEW_MESSAGE},{stepId:ms.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ms.HANDLE_GROUP_NEW_MESSAGE},{stepId:ms.UPDATE_GROUP_NEXT_SEQUENCE,dependency:ms.HANDLE_GROUP_NEW_MESSAGE},{stepId:ms.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:ms.HANDLE_GROUP_NEW_MESSAGE},{stepId:ms.EMIT_GROUP_MESSAGE_EVENT,dependency:[ms.HANDLE_GROUP_NEW_MESSAGE,ms.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}]},Ss={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},vs={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"};var Cs,Ms,Os,Is=Object.freeze({__proto__:null,ERROR_CODE:gs,InnerEvent:zt,OuterConstant:hs,OuterEvent:Ht,QUALITY_METRICS:Ss,SDK_EDITION:ps,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:vs,SignalingEvent:Zt,WORKFLOW_DEFINITIONS:fs,WORKFLOW_NAME:Es,WORKFLOW_STEP:ms});!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Cs=Cs||{}),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Ms=Ms||{}),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Os=Os||{});let Ts={[Ms.multipleAccount]:"multipleAccount",[Ms.multipleDevice]:"multipleDevice",[Ms.restApi]:"REST_API_Kick",[Os.multipleAccount]:"multipleAccount",[Os.multipleDevice]:"multipleDevice",[Os.restApi]:"REST_API_Kick",[Os.usersigExpired]:"userSigExpired"},ys="login_online_presence_task",{ERROR:As,DESTROY:Rs,FORCE_OFFLINE:Ns}=zt,{KICKED_OUT_MULT_ACCOUNT:Ds,KICKED_OUT_MULT_DEVICE:Ps,KICKED_OUT_REST_API:ws,ACCOUNT_A2KEY_EXPIRED:Ls,MSG_A2KEY_EXPIRED:bs}=gs;class ks{init(){var e=$t["notificationCenter"];e.subscribeInnerEvent(Ns,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(As,bs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(As,Ls,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(As,Ds,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(As,Ps,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(As,ws,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Rs,this._dispose,this)}_handleForceOfflineFromServerPush(e){var{EventArray:e=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(e).forEach(e=>{var{KickType:e,NewInstInfo:t}=e["KickoutMsgNotify"];this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}_extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{return this._isKickedOut(null==(e=null==e?void 0:e.KickoutMsgNotify)?void 0:e.KickType)})}_handleForceOfflineFromResponse(e){e=e.errorCode;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(t){return h(this,void 0,void 0,function*(){var e=t["kickedOutReasonCode"];try{this._logKickedOutEvent(t),yield $t.login.loginAction.logout(Cs.KICKED_OUT)}catch(e){console.debug(e)}finally{$t.notificationCenter.emitOuterEvent(Ht.KICKED_OUT,{data:{type:Ts[e]},name:Ht.KICKED_OUT}),[Ms.restApi,Ls,bs].includes(e)&&$t.channel.reconnect()}})}_logKickedOutEvent(e){var{kickedOutReasonCode:e,newInstanceInfo:t={}}=e,s=$t.ssoLog.createSSOLogData({method:"kickedOut"}),e=`type:${Ts[e]} newInstanceInfo: `+JSON.stringify(t);s.setLogInfo({message:e}).end(!0),console.warn("loginModule."+e)}_isKickedOut(e){return[Ms.multipleAccount,Ms.multipleDevice,Ms.restApi].includes(e)}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Ns,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(As,Ls,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(As,bs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(As,Ds,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(As,Ps,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(As,ws,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Rs,this._dispose,this)}}function Us(){return h(this,void 0,void 0,function*(){let e="im_open_status.wslogin",t=$t.common.generateProtocolData({servcmd:e,data:{state:"Online",isWebUniapp:0,InstType:0,customInfo:""}}),s=""+t.head.seq+e;try{let d=yield $t.channel.sendPacket(t,{timeout:9e4,requestId:s});if(d){let{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:o,A2Key:r,RichMsgAuthKey:a,ErrorCode:l,ErrorInfo:c,ActionStatus:u}=d;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:o,a2Key:r,authKey:a,errorCode:l,errorInfo:c,actionStatus:u}}}catch(e){throw console.warn(e),e}})}function Gs(t){var s;try{var n=we.getStorage("errorMessage");if(!t||!n)return"";var i=(null==(s=JSON.parse(n))?void 0:s.errorMessage)||{},{isIntl:o=!1,code:r,replacement1:a="",replacement2:l=""}=t;if(!r)return"";var c=o?r+"_en":r+"_cn";let e=i[i[c]?c:r]||"";return e=e&&(a&&(e=e.replace("$replacement1",a)),l)?e.replace("$replacement2",l):e}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class Fs extends Error{constructor(e){var{functionName:t="Unknown",code:s,message:n="",data:i=""}=e;let o=n;s&&!n&&(o=Gs(e));n=s?`${t} failed. error: {"message": ${o}, "code": ${s}}`:`${t} failed. error: {"message": ${o}}`;super(),this.code=s,this.errorCode=s,this.errorMessage=n,this.message=n,this.data=i}}function xs(e,t){if(e&&!0!==(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn))throw new Fs({code:gs.USER_NOT_LOGGED_IN,functionName:t})}function Vs(t,s,n){if(Array.isArray(t))for(let e=0;e<t.length;e++)Bs.call(this,Object.assign(Object.assign({},t[e]),{value:s[e],name:n}));else for(var e in t)Bs.call(this,Object.assign(Object.assign({},t[e]),{value:s[0][e],name:n,key:e}))}function Bs({required:e,rules:n,value:t,allowEmpty:i,name:o,key:r,customValidator:a}){if(void 0===t){if(e)throw new Fs({functionName:o,message:`[${o}] Missing required params: "${r}"`})}else{let s="";if(!n.some(e=>{return e===Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()})){for(let t=0;t<n.length;t++){let e=n[t];e=e.replace(e[0],e[0].toUpperCase()),s+=e+"/"}let e=`[${r}] must be type of ${s=s.substring(0,s.length-1)}, received type: ${Reflect.apply(Object.prototype.toString,t,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new Fs({functionName:o,message:e})}if(!1===i){if(Array.isArray(t)&&(0===t.length||"string"==typeof t[0]&&""===t[0].trim()))throw new Fs({functionName:o,message:r+" can not be empty."});if("string"==typeof t&&""===t.trim())throw new Fs({functionName:o,message:r+" can not be empty."})}if(a&&"function"==typeof a){let e=a(t);if(!0!==e)throw new Fs({functionName:o,message:`[${r}] custom validation failed: `+(e||"Invalid value")})}}}let $s=[],qs={},Ws={};function Ys(e,t){var s;xs(qs[e],e),Vs(Ws[e],t,e),s=e,$s.forEach(e=>{var{interceptor:e,context:t}=e;e.apply(t,[s])})}function Ks(e,t){$s.push({interceptor:e,context:t})}function Hs(e){var{params:e,auth:t}=e;e&&"object"==typeof e&&Object.assign(Ws,e),t&&"object"==typeof t&&Object.assign(qs,t)}function js(e){return $t.store.get("commercialConfig").get(e)}class zs{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{var s=Date.now();t?(this._stepStartTimes.set(e+"-"+t,s),console.log(`[Workflow ${e}] Step ${t} started at `+new Date(s).toISOString())):(this._workflowStartTimes.set(e,s),console.log(`[Workflow ${e}] started at `+new Date(s).toISOString()))},success:(s,e)=>{var n=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?n-t:0;this._stepStartTimes.delete(s+"-"+e),console.log(`[Workflow ${s}] Step ${e} completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}else{let e=this._workflowStartTimes.get(s),t=e?n-e:0;this._workflowStartTimes.delete(s),console.log(`[Workflow ${s}] completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}},error:(s,e,n)=>{var i=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?i-t:0;this._stepStartTimes.delete(s+"-"+e),console.error(`[Workflow ${s}] Step ${e} failed at ${new Date(i).toISOString()} (${t}ms)`,n)}else{let e=this._workflowStartTimes.get(s),t=e?i-e:0;this._workflowStartTimes.delete(s),console.error(`[Workflow ${s}] failed at ${new Date(i).toISOString()} (${t}ms)`,n)}}}}static getInstance(){return zs._instance||(zs._instance=new zs),zs._instance}static setInstance(e){zs._instance=e}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){var i;this._handlers.has(e)?fs[e].find(e=>e.stepId===t)?(i=this._handlers.get(e)).has(t)||i.set(t,n?s.bind(n):s):console.debug(`Step '${t}' not defined in workflow '${e}'`):console.debug(`Workflow '${e}' not defined in core`)}executeWorkflow(r,s){return h(this,void 0,void 0,function*(){if(this._validateWorkflow(r)){console.log(`[Workflow ${r}] Started execution at `+(new Date).toISOString());let e=fs[r],o={cancelled:!1};this._activeWorkflows.set(r,{cancelToken:o});try{let t=new Map,i=(e.forEach(e=>{t.set(e.stepId,e)}),{workflowName:r,pendingSteps:new Set(e.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:t,stepResults:{},data:s,cancelToken:o});yield new Promise((t,s)=>{let n=()=>{o.cancelled?t():this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).forEach(e=>{i.completedSteps.has(e)||i.runningSteps.has(e)||this._executeWorkflowStep(e,i,{onComplete:()=>{0===i.pendingSteps.size?t():0===this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).length&&0===i.runningSteps.size&&(console.log(`Workflow ${r} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})})};n()}),console.log(`[Workflow ${r}] Completed execution at `+(new Date).toISOString())}catch(e){console.error(`[Workflow ${r}] Failed execution at `+(new Date).toISOString(),e)}finally{this._activeWorkflows.delete(r)}}})}_executeWorkflowStep(a,l,c){return h(this,void 0,void 0,function*(){let{workflowName:o,runningSteps:e,stepMap:s,stepResults:n,data:i}=l;e.add(a),this._logWorkflowExecution(o,a,"start");try{let e=s.get(a),t=null;null!=e&&e.dependency&&(p(e.dependency)?t=n[e.dependency]:Array.isArray(e.dependency)&&(t={},e.dependency.forEach(e=>{t[e]=n[e]})));var r=this._handlers.get(o).get(a);if(r){let e=yield Promise.resolve(r({data:i,result:t}));n[a]=e,this._logWorkflowExecution(o,a,"success")}l.completedSteps.add(a)}catch(e){let t=`[Workflow].${o}.`+a,{errorCode:s,errorInfo:n=t+" failed"}=e||{},i=new Fs({functionName:t,code:s,message:n});$t.ssoLog.createSSOLogData({method:"Workflow"}).setLogInfo({message:`workflowName: ${o}, stepId: `+a}).setError(i).end(),this._logWorkflowExecution(o,a,"error",e),c.onError(e)}finally{e.delete(a),l.pendingSteps.delete(a),c.onStepComplete(),c.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(fs).forEach(e=>{this._handlers.has(e)||this._handlers.set(e,new Map)})}_cancelWorkFlow(e){var t=this._activeWorkflows.get(e);t&&(t=t["cancelToken"],t.cancelled=!0,this._activeWorkflows.delete(e))}_cancelAllWorkflows(){Object.keys(fs).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return fs[e]?!!this._handlers.get(e)||(console.debug(`No handlers registered for workflow '${e}'`),!1):(console.debug(`Workflow '${e}' not defined`),!1)}_getExecutableSteps(e){let{pendingSteps:t,completedSteps:s,stepMap:n,workflowName:i}=e;return Array.from(t).filter(e=>{var{dependency:t,skipIfDependencyMissing:e=!0}=n.get(e)||{};if(!t)return!0;if(p(t))return this._isStepRegistered({workflowName:i,stepId:t})?s.has(t):!e;if(m(t)){if(0<t.filter(e=>!this._isStepRegistered({workflowName:i,stepId:e})).length&&e)return!1;for(let e of t)if(!s.has(e))return!1;return!0}return!1})}_isStepRegistered(e){var{workflowName:e,stepId:t}=e;return null==(e=this._handlers.get(e))?void 0:e.has(t)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}}let Zs=new Map,Js=({type:e,groupID:t})=>e===hs.GRP_COMMUNITY||(""+t).startsWith(ds.COMMUNITY)&&!(""+t).includes(ds.TOPIC),Xs=(e="")=>{e=e.startsWith("GROUP")?e.replace("GROUP",""):e;return e.startsWith(ds.COMMUNITY)&&(""+e).includes(ds.TOPIC)},Qs="openim",en="million_group_open_http_svc";function tn(s){return h(this,void 0,void 0,function*(){var{servcmd:e,data:t}=sn(e=s.data)||nn(e)?function(e){let{servcmd:t,data:s}=e;var n,i,o;return nn(s)?({servcmd:e,data:n}=e,{GroupId:i=""}=n,[i]=(o=i).split(ds.TOPIC),{servcmd:on(e),data:Object.assign(Object.assign({},n),{GroupId:i,TopicId:o})}):{servcmd:t=sn(s)?on(t):t,data:s}}(s):s,t=$t.common.generateProtocolData({servcmd:e,data:t}),e=""+t.head.seq+e;return $t.channel.sendPacket(t,{requestId:e})})}function sn(e){var{Type:e,GroupId:t,GroupIdList:s=[]}=e,t=t||s[0]||"";return Js({type:e,groupID:t})}function nn(e){var{GroupId:e=""}=e;return Xs(e)}function on(e){return e.includes(Qs)?e:(e=e.split(".")[1],en+"."+e)}function rn(){var e;return null==(e=$t.store.get("login"))?void 0:e.userId}let an=e=>m(e)||f(e),cn=(s,n,i,o)=>{if(!an(s)||!an(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(an(s[a])&&an(n[a]))r+=cn(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r},ln=(e,t)=>{if(g(t))return"";switch(e){case hs.MSG_TEXT:return t.text||"";case hs.MSG_IMAGE:return"[Image]";case hs.MSG_LOCATION:return"[Location]";case hs.MSG_AUDIO:return"[Voice]";case hs.MSG_VIDEO:return"[Video]";case hs.MSG_FILE:return"[File]";case hs.MSG_CUSTOM:return"[Custom Messages]";case hs.MSG_GRP_TIP:return"[Group Notification]";case hs.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case hs.MSG_FACE:return"[Animated Sticker]";case hs.MSG_MERGER:return"[Chat Record]";default:return""}},dn=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_members",interval:3,count:1},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],un="im_sdk_config_mgr.fetch_config",_n="im_sdk_config_mgr.push_configv2",hn="cloud-config",gn=2996;var pn=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){var{notificationCenter:e,InnerEvent:t,helper:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i},channel:o}=this._core=e;e.subscribeInnerEvent(_n,this._handlePushedConfig,this),s.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(dn),o.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(e){var t,s={code:0,data:""};return e&&(s.data=(null==(t=this._core.store.get("cloudConfig"))?void 0:t[e])||""),s}checkMethodCallOverLimit(e){if(this._cmdFrequencyLimitMap.has(e))if(this._methodCallFrequencyMap.has(e)){var{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e),{startTime:n,methodCallCounter:i}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:i+=1}),t<i)throw new this._core.helper.ChatError({code:gn,replacement1:e})}else this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1})}_fetchCloudConfig(){return h(this,void 0,void 0,function*(){try{var e=(this._core.store.get("instance")||{})["sdkAppId"],t=this._core.helper.generateProtocolData({servcmd:un,data:{uint32_sdkappid:e,uint64_version:this._version}}),s=""+t.head.seq+un;return yield this._core.channel.sendPacket(t,{requestId:s})}catch(e){throw console.warn("fetch cloudControl fail: ",e),e}})}_handlePushedConfig(e){this._updateCloudConfig(e)}_handleLoginSuccess(){return h(this,void 0,void 0,function*(){try{var e;this._canFetch()&&(e=yield this._fetchCloudConfig(),this._updateCloudConfig(e)),this._core.helper.taskScheduler.addTask({id:hn,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){console.warn(e)}})}_fetchCloudConfigIfReady(){return h(this,void 0,void 0,function*(){if(this._canFetch())try{var e=yield this._fetchCloudConfig();this._updateCloudConfig(e)}catch(e){console.warn(e)}})}_updateCloudConfig(e){e=this._parseCloudConfig(e);e&&(this._core.store.set("cloudConfig",e),this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e))}_canFetch(){var e=(this._core.store.get("login")||{})["isLoggedIn"];return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){var{int32_error_code:t,str_json_config:s,uint32_expired_time:n,uint64_version:i}=e;let o=null;if(0===t){if(this._version!==i)try{o=JSON.parse(s),this._version=i}catch(e){}this._expirationTime=Date.now()+1e3*n}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return o}_parseCmdFreqLimit(){var e,t=null==(e=this.getServerConfig("cmd_frequency_limit"))?void 0:e.data,s=this._core.utils["isEmpty"];if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(hn),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(dn),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(_n,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class En{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let mn={SEARCH_GRP_SNS:new En(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new En(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new En(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new En(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new En(0,Math.pow(2,6)).toString(),USER_STATUS:new En(0,Math.pow(2,7)).toString(),CONV_MARK:new En(0,Math.pow(2,9)).toString(),CONV_GROUP:new En(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new En(0,Math.pow(2,11)).toString(),MSG_EXT:new En(0,Math.pow(2,13)).toString(),GRP_COUNTER:new En(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new En(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new En(Math.pow(2,7)).toString(),PLUGIN_CS:new En(Math.pow(2,8)).toString(),PLUGIN_PUSH:new En(Math.pow(2,9)).toString(),PLUGIN_BOT:new En(Math.pow(2,10)).toString(),MSG_REACTION:new En(Math.pow(2,16)).toString(),FOLLOW:new En(Math.pow(2,20)).toString()},fn="CommercialConfig",Sn="commercial-config";var Tn,yn,vn=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map}install(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i,InnerEvent:o}}=this._core=e;s.subscribeInnerEvent(o.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(o.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(o.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this)}isCommercialAbilityEnabled(e){return h(this,void 0,void 0,function*(){var s=parseInt(e,10).toString(2),n=s["length"];let i,o=!0;for(let e=n-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(i=(t<32?new En(0,2**t):new En(2**(t-32),0)).toString(),!this._featureMap.get(i))){o=!1;break}return console.log(`${fn}.isFeatureEnabled decimalNumber:${e} key:${i} ret:`+o),{code:0,data:{enabled:o}}})}_fetchAndParseCommercialConfig(){return h(this,void 0,void 0,function*(){var e;try{this._isFetching=!0;var t=this._core.helper.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null==(e=this._core.store.get("instance"))?void 0:e.sdkAppId}}),s=yield this._core.channel.sendPacket(t);null!=s&&s.body&&(this._parseCommercialConfig(s.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(e){console.warn("fetch commercial fail: ",e)}finally{this._isFetching=!1}})}_syncCommercialConfig(t){return h(this,void 0,void 0,function*(){var e=((null==t?void 0:t.data)||{})["purchaseBits"];e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:Sn,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var e=null==(e=this._core.store.get("login"))?void 0:e.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(e){null!=e&&e.body&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return h(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){var t,s,n,i;"object"==typeof e&&({int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:i}=e,0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*i):void 0===t?(console.log(fn+"._parseCommercialConfig failed. Invalid message format:",e),this._expirationTime=Date.now()+36e5):(console.error(fn+`._parseCommercialConfig errorCode:${t} errorMessage:`+s),this._expirationTime=Date.now()+12e4))}_isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(s){if(this._isValidPurchaseBits(s)){this._featureMap.clear(),this._methodKeyMap.clear();var n;for(let e=s.length-1,t=0;0<=e;e--,t++)if(n=(t<32?new En(0,2**t):new En(2**(t-32),0)).toString(),"1"===s[e]){this._featureMap.set(n,!0);let e=this._getKeyByValue(mn,n);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(n,!1);let e=this._getKeyByValue(mn,n);e&&this._methodKeyMap.set(e,!1)}}else console.warn(fn+".parsePurchaseBits invalid purchases:"+s)}_getKeyByValue(e,t){e=Object.entries(e).find(([,e])=>e===t);return e?e[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(Sn),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear()}},In=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;var{notificationCenter:e,InnerEvent:t,channel:s}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(this._serverOverloadInfoMap.has(e)){var{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}}_handleOverLoadPush(e){var{OverLoadServCmd:e,DelaySecs:t}=e;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}},Cn=new class{constructor(){this.name="ConfigCenter"}install(e){pn.install(e),vn.install(e),In.install(e)}},Mn=new class{constructor(){this.name="ErrorMessage",this._core=null}install(e){return h(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){let e=yield this._fetchErrorMessage();var t;e&&(t=this._parseResponse(e),this._saveErrorMessage(t))}})}_canFetch(){var e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return h(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}})}_isExpired(e){return!e||(e=e["errorMessageSavedTime"],e&&6048e5<=(new Date).getTime()-e)}_parseResponse(e){if("string"==typeof e){var s=e.split(";\n"),n={},i=new RegExp(/'/g);for(let t=0;t<s.length;t++){var o=s[t].indexOf(":"),r=s[t].slice(0,o);let e=s[t].slice(o+1);r.startsWith("//")||""!==e&&(e=e.replace(i,""),n[r]=e)}return n}}};function On(i,l){return h(this,void 0,void 0,function*(){let{cookie:e,syncFlag:t,syncTriggerEvent:s}=i,n="openim.getmsg",r=l.helper.generateProtocolData({servcmd:n,data:{Cookie:e,SyncFlag:t,IsOnlineSync:s,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=""+r.head.seq+n;try{let e=yield l.channel.sendPacket(r,{requestId:a});if(!e)return null;let{C2CPairUnreadCount:t,C2CRemainingUnreadCount:s,EventArray:n}=e,{unreadMessageList:i,revokedMessageList:o}=function(e,v){let n=[],i=[];return null!=e&&e.forEach(f=>{var e,t,s=function(){var{From_Account:e,From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,To_Account:d,TinyId:_,MsgCheckResult:h,CloudCustomData:g,IsPeerRead:p,MsgFlagBits:E,MsgVersion:m,EventArray:S}=f;return{from:e,avatar:t,nick:s,needReadReceipt:1===n,readReceiptSentByPeer:p,clientTime:o,messageFlagBits:E,random:r,sequence:a,time:l,messageControlInfo:c,isSupportExtension:u,to:d,tinyID:_,checkResult:h,cloudCustomData:g,messageVersion:m,eventArray:S,elements:v.message.messageHelper.parseServerPushMessageElement(i)}}();if(null!=(t=null==(e=null==(e=null==f?void 0:f.EventArray)?void 0:e[0])?void 0:e.hasOwnProperty)&&t.call(e,"C2cNotifyMsgArray"))i.push(...function(){let e,t=[];return null!=(e=f.EventArray)&&e.forEach(e=>{var e=e["C2cNotifyMsgArray"],e=null==(e=null==(e=null==e?void 0:e[0])?void 0:e.WithdrawC2cMsgNotify)?void 0:e.C2cWithdrawInfoArray;Array.isArray(e)&&t.push(...e)}),t}());else{let e=v.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),t=s["elements"];e.setElement(t),n.push(e)}}),{unreadMessageList:n,revokedMessageList:i}}(e.MsgList,l);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:o,unreadCountList:t,overflowUnreadCountList:s,cookie:null==e?void 0:e.Cookie,groupTipList:n}}catch(e){console.warn(e)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(Tn=Tn||{}),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(yn=yn||{});var An=new class{constructor(){this.name="UnreadMessageSynchronizer",this._unreadDBMessageMap=new Map,this._cookie=""}install(e){var t=(this._core=e)["constants"];e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(t){return h(this,void 0,void 0,function*(){let{isAfterReOnline:r=!1,isAfterNewMessageReceived:a=!1,isAfterLogin:e=!1}=t||{},l=Tn.START_SYNC;for(var c=[],u=[],d=[],_=[];this._canContinueSync({cookie:this._cookie,syncFlag:l});){let e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:l,syncTriggerEvent:a?yn.NEW_MESSAGE_RECEIVED:yn.LOGIN_SUCCESS});if(!e)break;let{unreadMessageList:t=[],revokedMessageList:s=[],overflowUnreadCountList:n,unreadCountList:i,groupTipList:o}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",l=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(t),d.push(...s),this._updateConversationUnreadOptions({unreadCountList:i,overflowUnreadCountList:n,conversationUpdateFieldList:c}),Array.isArray(o)&&u.push(...o),r){let e=this._handleNewMessageList(t)["messages"];_.push(...e)}}return r?{conversationUpdateFieldList:c,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u,messages:_}:{conversationUpdateFieldList:c,isInstantMessage:!e,isUnreadC2CMessage:!0,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u}})}_syncUnreadDBMessageAfterLogin(){return h(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return h(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(e){let{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{OuterConstant:{CONV_C2C:i,CONV_SYSTEM:o}}=this._core["constants"];null!=t&&t.forEach(e=>{let{From_Account:t,UnreadCount:s}=e;if(t!==o){let e=n.find(({conversationID:e})=>e===""+i+t);e?e.unreadCount=s:n.push({conversationID:""+i+t,unreadCount:s,type:i})}}),null!=s&&s.forEach(e=>{let{From_Account:t,LastMsgTime:s}=e;t===o||n.find(({conversationID:e})=>e===""+i+t)||n.push({conversationID:""+i+t,type:i,lastMsgTime:s})})}_syncUnreadDBMessageAfterReOnline(){return h(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(n){var e;let i=(this._core.message||{})["messageDataHandler"],t=null==(e=this._core.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;o&&r?o===e&&r===t||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}):(n.nick=e,n.avatar=t)}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_handleNewMessageList(e){let t=(this._core.message||{})["messageDataHandler"],l=new Map,s=[];return e.forEach(a=>{this._updateMessageProfile(a);let e=1===a.isModified;if(t.isMessageSentByCurrentInstance(a)?a.isModified=e:e=!1,a.isOnlineMessage())a._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(a)||s.push(a);else if(!t.isInMessageList(a)){if(t.storeConversationMessage(a)){let{conversationID:e,conversationType:t,conversationSubType:s,flow:n,_isExcludedFromUnreadCount:i,_isExcludedFromLastMessage:o}=a,r=o?"":a;l.has(e)?(l.get(e).lastMessage=r,"in"!==n||i||l.get(e).unreadCount++):l.set(e,{conversationID:e,type:t,subType:s,unreadCount:i||"in"!==n?0:1,lastMessage:r})}t.isMessageSentByCurrentInstance(a)&&!e||s.push(a)}}),{messages:s,conversationOptions:l}}_fetchUnreadDBMessage(l){return h(this,void 0,void 0,function*(){try{console.log("unread-message-synchronizer._fetchUnreadDBMessage options:",l);var e,t,s,n,i,o,r,a=yield On(l,this._core);return a?({syncFlag:e,unreadMessageList:t,revokedMessageList:s,cookie:n,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}=a,this._parseAndSaveUnreadMessageList(t),{syncFlag:e,cookie:n,unreadMessageList:t,revokedMessageList:s,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}):null}catch(e){console.log(e)}})}_canContinueSync({cookie:e,syncFlag:t}){return t===Tn.START_SYNC||t===Tn.SYNCING&&!(null!=(t=this._core)&&t.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach(e=>{var t=e["ID"];this._unreadDBMessageMap.set(t,e)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Rn=new class{init(e){this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),document.addEventListener("visibilitychange",this._visibilityChangeHandler),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t="visible"===document.visibilityState;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:t}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},Nn=new class{init(e){this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var e=((null==(e=this._core)?void 0:e.utils)||{})["MINI_APP_NAMESPACE"];e.onAppShow(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),e.onAppHide(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},Dn=new class{init(e){var{IN_WX_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?Nn:Rn).init(e)}};let Pn="none",wn="online";var Ln=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:wn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Pn})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},bn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){try{this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),wx.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}_deactivateNetworkMonitoring(){null!==this._mpNetworkStatusCallback&&(wx.offNetworkStatusChange&&wx.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},kn=new class{init(e){var t=e.helper["IN_WX_MINI_APP"];(t?bn:Ln).init(e)}},Un=new class{constructor(){this.name="SystemStateMonitor"}install(e){Dn.init(e),kn.init(e)}};let Gn=new Set(["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.*"]),Fn="tui_room_svr.*";var xn=new class{constructor(){this.name="BusinessCommandTransfer",this._transferredCommands=Gn}install(e){var{notificationCenter:e,InnerEvent:t,helper:s}=this._core=e;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),s.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),s.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(s){return h(this,void 0,void 0,function*(){var t="transferBusinessCommand";try{var{serviceCommand:e=Fn}=s||{};if(this._isValidTransferredCommand(e))return{code:0,data:(yield function(o,r){return h(this,void 0,void 0,function*(){var{helper:e,channel:t}=r,{serviceCommand:s=Fn,data:n}=o||{};let i={};try{i="string"==typeof n?JSON.parse(n):n}catch(e){console.warn(e)}n=e.generateProtocolData({servcmd:s,data:i}),e=""+n.head.seq+s;return t.sendPacket(n,{requestId:e})})}(s,this._core))||{}};throw new this._core.helper.ChatError({code:2995,functionName:t})}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}})}_onCloudConfigUpdate(e={}){try{var t;"string"==typeof e.rtc_cmd&&(t=JSON.parse(e.rtc_cmd),Array.isArray(t))&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){e=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(e){var{OuterEvent:t,notificationCenter:s}=this._core,e=(e||{})["MsgContent"],t=t["ROOM_CUSTOM_DATA_RECEIVED"];s.emitOuterEvent(t,{name:t,data:e})}_reset(){this._transferredCommands=Gn}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let Vn=1,Bn=300;var $n=new class{constructor(){this.name="OfflineMessageSynchronizer",this._lastMessageSequenceMapOnDisconnect=new Map}install(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:i}}=this._core=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),e.notificationCenter.subscribeInnerEvent(i.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(e){let t=((null==e?void 0:e.result)||{})["conversationList"],{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){let e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}_recoverGroupHistoryMessage(e){return h(this,void 0,void 0,function*(){let i=this._core["OuterConstant"],o=[],r=[];return yield Promise.all(null==e?void 0:e.map(n=>h(this,void 0,void 0,function*(){var{groupProfile:{groupID:e}={},lastMessage:{lastSequence:t}={}}=n,e=""+i.CONV_GROUP+e,s=this._getLocalLastMessageSequence(e);this._shouldRecoverHistory({localLastMessageSequence:s,serverLastMessageSequence:t})&&(yield this._recoverHistoryForConversation({conversationID:e,localLastMessageSequence:s,serverLastMessageSequence:t,groupTipList:r})),o.push(e.replace(i.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:o,groupTipList:r}})}_recoverHistoryForConversation(e){return h(this,arguments,void 0,function*({conversationID:f,localLastMessageSequence:v,serverLastMessageSequence:I,groupTipList:C}){try{let{utils:{isArray:e,isObject:t,isEmpty:s},OuterEvent:n,OuterConstant:i,notificationCenter:o,message:r,appStore:a,common:{getMessagePreviewText:l}}=this._core,c=I-v,u=Math.min(20,c),d={},_=yield r.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:f,sequence:v+u,direction:i.Direction.FORWARD,count:u}),{nextReqMessageIDFromServer:h,hasNoMoreHistoryMessage:g,messageList:p,serverGroupTipList:E}=_,m=(e(E)&&C.push(...E),g&&h<0),S=[];if(e(p)&&(p.forEach(e=>{r.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===i.CONV_SYSTEM&&(e.isSystemMessage=!1),r.messageDataHandler.storeConversationMessage(e)&&!s(e.payload)&&(S.push(e),e._isExcludedFromLastMessage||(d.lastMessage=Object.assign({},e)))}),0<S.length)&&o.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:S}),!m&&0<p.length){let e=p[p.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:f,localLastMessageSequence:e,serverLastMessageSequence:I,groupTipList:C})}t(d.lastMessage)&&(d.lastMessage.messageForShow=l(d.lastMessage.type,d.lastMessage.payload),a.conversationStore.updateConversation(f,d))}catch(v){console.debug("Recovery failed for conversation:",f,v)}})}_updateLastMessageSequenceMapOnDisconnect(){let e=this._core["message"],n=e.messageDataHandler.getContinuousMessagesByConversation();for(let[t,s]of n)if(!t.startsWith("C2C")){let e=Array.from(s.values());var i;0<(null==e?void 0:e.length)&&(i=e[e.length-1].sequence,this._lastMessageSequenceMapOnDisconnect.set(t,i))}}_getLocalLastMessageSequence(e){var t=this._core["message"];return this._lastMessageSequenceMapOnDisconnect.has(e)?this._lastMessageSequenceMapOnDisconnect.get(e):null==(e=(t=t.messageDataHandler.getLocalMessageList(e))[t.length-1])?void 0:e.sequence}_shouldRecoverHistory(e){var t,{localLastMessageSequence:e,serverLastMessageSequence:s}=e;return"number"==typeof e&&"number"==typeof s&&(t=s-e,0!==s)&&0<e&&t>=Vn&&t<Bn}};let qn=ps.STANDARD,Wn=[];qn=ps.BASIC,Wn=[Mn,Cn,An,Un,xn,$n];var Yn=Object.freeze({__proto__:null,ChatError:Fs,WorkflowManager:zs,buildAndSendPacket:tn,get builtInPlugins(){return Wn},checkBusinessCapabilityBits:js,deepMerge:cn,getCurrentUserID:rn,getErrorMessage:Gs,getMessagePreviewText:ln,isC2CConv:e=>p(e)&&e.slice(0,3)===rs.CONV_C2C,isCommunity:Js,isGroupConv:e=>p(e)&&e.slice(0,5)===rs.CONV_GROUP,isTopic:Xs,isUnlimitedAVChatRoom:function(){var e;return!(null==(e=$t.store.get("instance"))||!e.unlimitedAVChatRoom)},liteChatInstanceMap:Zs,registerInterceptor:Ks,registerValidateConfig:Hs,requireAuth:xs,get sdkEdition(){return qn},updateGroupAtInfo:(t,s)=>{var{CONV_AT_ME:n,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:o}=hs;if(!function(t,e){let{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:i}=hs,{groupID:o,sequence:r}=t,a=!1;return Js({groupID:o})&&e.forEach(e=>{e.messageSequence===r&&(e.atTypeArray.includes(s)&&t.groupAtType.includes(n)&&(e.atTypeArray=[i]),e.atTypeArray.includes(n)&&t.groupAtType.includes(s)&&(e.atTypeArray=[i],e.__random=t.__random,e.__sequence=t.__sequence),a=!0)}),a}(t,s)){let e=[...t.groupAtType];e.includes(n)&&e.includes(i)&&(e=[o]);n={from:t.from,groupID:t.groupID,topicID:t.topicID,messageSequence:t.sequence,atTypeArray:e,__random:t.__random,__sequence:t.__sequence};s.push(n)}},validateAndExecute:Ys,validateParameters:Vs});class Kn{constructor(){this._builtInPlugins=new Set,this._externalPlugins=new Set}static getInstance(){return Kn._instance||(Kn._instance=new Kn),Kn._instance}static setInstance(e){Kn._instance=e}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}_installPlugin(e,t){var s=[];let n=(s=m(e)?e:[e]).findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=-1<n?s.splice(n,1):[];s.forEach(e=>{this._isPluginInstalled(e.name)||(e&&qt(e.install)?(t.add(e.name),qt(e.getInstalledSubPlugins)?e.install(Xn.getInstance().exposeApiForPlugin(),i):e.install(Xn.getInstance().exposeApiForPlugin()),qt(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):qt(e)?(t.add(e.name),e(Xn.getInstance().exposeApiForPlugin()),qt(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isPluginInstalled(e){return this._builtInPlugins.has(e)||this._externalPlugins.has(e)}_isLoggedIn(){var e;return!0===(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn)}}var no,oo,io,lo,Hn=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t,s={emit:!0,needSort:!1}){let{emit:n,needSort:i}=s,o=this._conversationMap.get(e);o&&!Ee(t)&&(Object.keys(t).forEach(e=>{o[e]=t[e]}),n)&&$t.notificationCenter.emitInnerEvent(zt.CONVERSATION_UPDATED,{needSort:i})}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),$t.notificationCenter.emitInnerEvent(zt.CONVERSATION_UPDATED))}},jn=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){let s=this._groupMap.get(e);s&&!Ee(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},zn=new class{constructor(){this._messagesByConversation=new Map}updateMessage(s,t,e){let n,{operation:i,updateUnreadCount:o=!0}=e,r=_(e,["operation","updateUnreadCount"]),a=[];for(let e of t){let t=null==(n=this._messagesByConversation.get(s))?void 0:n.get(e);if(!t)return!1;Object.keys(r).forEach(e=>{t[e]=r[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(i,{conversationID:s,messageList:a,updateUnreadCount:o}),a}getMessagesByConversation(e){return[...(null==(e=this._messagesByConversation.get(e))?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){var s=t["conversationID"];Xs(s)?$t.notificationCenter.emitInnerEvent(ns[e],t):$t.notificationCenter.emitInnerEvent(e,t)}},Zn=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},Jn=Object.freeze({__proto__:null,conversationStore:Hn,groupStore:jn,messageStore:zn,userStore:Zn});class Xn{static getInstance(){return Xn._instance||(Xn._instance=new Xn),Xn._instance}static setInstance(e){Xn._instance=e}constructor(){this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this)},this._apiHandlersMap={},this._apiMap={on:$t.notificationCenter.subscribeOuterEvent.bind($t.notificationCenter),off:$t.notificationCenter.unSubscribeOuterEvent.bind($t.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:Kn.getInstance().installExternalPlugin.bind(Kn.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}registerPlugin(e){console.log("registerPlugin",e)}statKeyFeatureUsage(e){console.log("statTUIKeyFeatures",e)}setLogLevel(e){console.log("setLogLevel",e),!$t||"function"!=typeof $t.setLogLevel||null!=$t&&$t.setLogLevel(e)}getApiMap(){return this._apiMap}setApiMap(e){this._apiMap=e}registerApi(e){let{apiName:n,context:t,methodName:i=n,matcher:s}=e;this._apiHandlersMap[n]||(this._apiHandlersMap[n]=[]),this._apiHandlersMap[n].push({context:t,methodName:i,matcher:s}),this._apiMap[n]&&1!==this._apiHandlersMap[n].length||(this._apiMap[n]=(...t)=>{Ys(i,t);var s=this._apiHandlersMap[n];for(let e of s)if(!e.matcher||e.matcher(t))return e.context[e.methodName].bind(e.context)(...t)})}registerExperimentalAPI(e,t,s){this._experimentalApiMap[e]=t[s||e].bind(t)}destroy(){return h(this,void 0,void 0,function*(){var e,t;try{null!=(e=$t.store.get("login"))&&e.isLogin&&(yield this._apiMap.logout()),$t.notificationCenter.emitInnerEvent(zt.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{$t.notificationCenter.emitOuterEvent(Ht.SDK_DESTROY,{SDKAppID:null==(t=$t.store.get("instance"))?void 0:t.sdkAppId}),Zs.clear(),Kn.getInstance().clear(),zs.getInstance().destroy(),$t.destroy()}})}exposeApiForClient(){return this._apiMap}exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:zt,InnerEventSubType:$t.notificationCenter.InnerEventSubType,OuterEvent:Ht,OuterConstant:hs,SignalingEvent:Zt,helper:Object.assign(Object.assign(Object.assign({},$t.utils),$t.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:Ks,registerValidateConfig:Hs,checkBusinessCapabilityBits:js,registerWorkflowStep:zs.getInstance().registerWorkflowStep.bind(zs.getInstance()),ChatError:Fs}),apiMap:this._apiMap},$t),{constants:Object.assign(Object.assign({},Is),$t.constants),common:Object.assign(Object.assign(Object.assign({},Yn),$t.common),{workflowManager:zs.getInstance()}),utils:$t.utils,appStore:Jn})}callExperimentalAPI(e,t){return this._experimentalApiMap[e]?this._experimentalApiMap[e](t):Promise.reject(new Error(`API ${e} is not found`))}}class Qn{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120}init(){var{notificationCenter:e,store:t}=$t;t.set("login",{isReady:!1}),Xn.getInstance().registerApi({apiName:"login",context:this}),Xn.getInstance().registerApi({apiName:"logout",context:this}),Xn.getInstance().registerApi({apiName:"getLoginUser",context:this}),Xn.getInstance().registerApi({apiName:"isReady",context:this}),e.subscribeInnerEvent(zt.RECONNECTED,this._reLogin,this),$t.notificationCenter.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}login(s){return h(this,void 0,void 0,function*(){let e=this._getUiPlatform(),t=($t.store.get("instance")||{})["sdkEdition"],n=$t.ssoLog.createSSOLogData({method:"login",eventType:4,uiPlatform:e,message:t});try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new Fs({functionName:"login",code:gs.REPEAT_LOGIN});let e=yield this._performLogin(s);return this._validateAfterLogin(e),this._handleLoginSuccess(e),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),{code:this._latestLoginAt=0,data:e}}catch(e){let t=e["errorCode"],s=(t!==gs.REPEAT_LOGIN&&(this._latestLoginAt=0),new Fs({functionName:"login",code:t}));throw n.setError(s).end(!0),s}})}_getUiPlatform(){var e,t=$t["store"],t=null==(e=t.get("instance"))?void 0:e.scene;if("string"==typeof t){let e=Number(t);return isNaN(e)?void 0:e}}_reLogin(){return h(this,void 0,void 0,function*(){var e,t,s,n,i,o;try{this._isLoginIn()&&(t=$t.ssoLog.createSSOLogData({method:"reLogin"}),s=yield Us())&&({instanceID:n,customStatus:i}=s,$t.store.set("login",{statusInstanceId:n}),zs.getInstance().executeWorkflow(Es.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:i,statusType:os.USER_STATUS_ONLINE}),o=`socketId:${null==(e=$t.channel.getSocketAdapter())?void 0:e.getId()} instanceId:`+n,t.setLogInfo({message:o}).end(!0))}catch(e){console.warn(e)}})}logout(){return h(this,arguments,void 0,function*(s=Cs.USER_INITIATED){let e=$t.ssoLog.createSSOLogData({method:"logout"});e.setLogInfo({moreMessage:"identifier:"+rn()});try{yield this._performLogout(s),e.end(!0),$t.ssoLog.uploadSSOLogData()}catch(s){let e=s["errorCode"],t=new Fs({functionName:"logout",code:e});this._handleLogoutError(t)}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?rn():""}isReady(){var e;return null==(e=$t.store.get("login"))?void 0:e.isReady}_updateAndEmitSDKReady(){$t.store.set("login",{isReady:!0}),setTimeout(()=>{$t.notificationCenter.emitOuterEvent(Ht.SDK_READY,{name:Ht.SDK_READY})},1)}_updateAndEmitSDKNotReady(){$t.store.set("login",{isReady:!1}),$t.notificationCenter.emitOuterEvent(Ht.SDK_NOT_READY,{name:Ht.SDK_NOT_READY})}_validateAfterLogin(e){var t,s="login";if(!e)throw new Fs({functionName:s,message:"login response is empty"});var{tinyID:e,a2Key:n}=e||{},i=$t.ssoLog.getSSOLogData(s);if(!e){let e=new Fs({functionName:s,code:gs.NO_TINYID});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}if(!n){let e=new Fs({functionName:s,code:gs.NO_A2KEY});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:Gs({code:"RepeatLogin",replacement1:null==(e=$t.store.get("login"))?void 0:e.userId}),repeatLogin:!0}}}_performLogin(s){return h(this,void 0,void 0,function*(){var{userID:e,userSig:t}=s;return $t.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),Us()})}_ensureAsyncComplete(){return h(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){var t=$t.common["timeManager"],{helloInterval:s,timeStamp:n,customStatus:i,purchaseBits:o}=e;t.calculateTimeOffsetWithServer(this._latestLoginAt,1e3*n),this._helloInterval=s||120,this._updateLoginStore(e),$t.user.userStatus.setCustomStatus(i),zs.getInstance().executeWorkflow(Es.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:o}),$t.common.taskScheduler.addTask({id:ys,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this}),this._logLoginSuccess(e)}_performLogout(e){return function(s){return h(this,void 0,void 0,function*(){var e=s["logoutReason"],t="im_open_status.wslogout",e=$t.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),t=e.head.seq+t;return yield $t.channel.sendPacket(e,{requestId:t})})}({logoutReason:e})}_handleLogoutError(e){$t.ssoLog.getSSOLogData("logout").setError(e).end(),console.error("logout "+e)}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),zs.getInstance().reset(),$t.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){var{a2Key:e,tinyID:t,instanceID:s,authKey:n}=e;$t.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:s,authKey:n,isLoggedIn:!0})}_logLoginSuccess(e){var t=$t.ssoLog.getSSOLogData("login"),{helloInterval:e,instanceID:s,timeStamp:n,customStatus:i}=e,o=null==(o=$t.channel.getSocketAdapter())?void 0:o.getId(),r=$t.common.timeManager.getTimeOffsetWithServer(),{appId:a,href:l}=$t.store.get("instance")||{},o=`login._logLoginSuccess socketID:${o} scene: helloInterval:${e} instanceID:${s}
|
|
2
|
+
timeStamp:${n} offset:${r} customStatus:${i} href: ${l} appId: `+a;console.log("login ok. "+o),t.updateLogCreatedAtByTimeOffset(),t.setLogInfo({moreMessage:o}).end()}_sendOnlinePresenceRequest(){return h(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{e="im_open_status.wshello",t=$t.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),e=t.head.seq+e,yield $t.channel.sendPacket(t,{requestId:e})}catch(e){console.warn("Login._sendOnlinePresenceRequest error:",e)}var e,t})}_isLoginIn(){var e;return!0===(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){console.log("Login reset"),$t.common.taskScheduler.removeTask(ys),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,$t.store.clear("login"),$t.store.set("login",{isReady:!1})}_dispose(){console.log("Login dispose"),this._reset();var e=$t["notificationCenter"];e.unSubscribeInnerEvent(zt.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this)}}let eo={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},to={logout:!0};class so{constructor(){this.loginAction=new Qn,this.kickedOutHandler=new ks,this.loginAction.init(),this.kickedOutHandler.init(),Hs({auth:to,params:eo})}}!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(no=no||{}),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(oo=oo||{}),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(io=io||{});let ro={1:oo.MSG_PRIORITY_HIGH,2:oo.MSG_PRIORITY_NORMAL,3:oo.MSG_PRIORITY_LOW,4:oo.MSG_PRIORITY_LOWEST},ao=0,co=1,uo=(!function(e){e.IN="in",e.OUT="out"}(lo=lo||{}),2),_o={};function ho(e){var t,s,n;return e?(void 0===_o[e]?(t=("3"+(n=new Date).getHours()).slice(-2),s=("0"+n.getMinutes()).slice(-2),n=("0"+n.getSeconds()).slice(-2),_o[e]=parseInt([t,s,n,"0001"].join(""),10),console.log("autoIncrementIndex start index:"+_o[e])):_o[e]+=1,_o[e]):0}class go{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=oo.MSG_PRIORITY_NORMAL,this._relayFlag=!1;var t,{clientTime:s=$t.common.timeManager.getServerTimeSeconds()||0,senderTinyID:n,currentUser:i,needReadReceipt:o,isSupportExtension:r,customModerationConfigurationId:a,to:l,from:c,nick:u="",avatar:d="",time:_,messageControlInfo:h,tinyID:g,cloudCustomData:p="",messageLifeTime:E,messageVersion:m=0,conversationType:S,sequence:f,checkResult:v=0,isPlaceMessage:I=0,messageFlagBits:C,receiverList:M,isSystemMessage:O=!1,status:T=Qt.SUCCESS,revokeReason:y="",conversationSubType:A,clientSequence:R,protocol:N="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:P={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:w,groupProfile:L,atUserList:b,flow:k,isRead:U=!1}=e;this.clientTime=s,this.senderTinyID=n||g,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===r||1===r,this._cmConfigID=a,this.to=l,this.nick=u,this.avatar=d,this.protocol=N,this.random=void 0===w?(t=t||99999999,Math.round(Math.random()*t)):w,this.time=_||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!(null==h||!h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!(null==h||!h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=p,this.messageLifeTime=E,this.from=c||null,this.sequence=f||0,this.conversationType=S||no.CONV_C2C,this.hasRiskContent=1<v,this.version=m,this.isPlaceMessage=I,this.isRevoked=2===I||8===C,this.isSystemMessage=O,this.readReceiptInfo=P,this.revokeReason=y,this.revokerInfo=D,this._receiverList=M,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=R||f||0,this.status=T,this.atUserList=b||[],this.flow=k,this.isRead=U,this.reInitialize(i),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(L)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t;return this._relayFlag?{isValid:!0}:0<(null==(e=this._elements)?void 0:e.length)?null==(t=null==(e=this._elements[0])?void 0:e.validateBeforeSend)?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===no.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(e){var t,s;e&&({From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:s}=e,s=(s||{})["NameCard"],"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof s)&&(this.nameCard=s)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){var t=this.conversationType;t!==no.CONV_SYSTEM?(e=t!==no.CONV_C2C||e===this.from?this.to:this.from,this.conversationID=e?""+t+e:null):this.conversationID=no.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=ho(e)),0===this.sequence&&this.conversationType===no.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===no.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}setIsRead(e){this.isRead=e}}class po{static parseServerPushElement(e){var{MsgContent:e={}}=e,{Data:e,Ext:t,Desc:s}=e;return new po({data:e,description:s,extension:t})}constructor(e){this.type=io.MSG_CUSTOM;var{data:e="",description:t="",extension:s=""}=e;this.content={data:e,description:t,extension:s}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},{data:e,description:t,extension:s}=e?this.payload:this.content;return{MsgType:this.type,MsgContent:{Data:e,Ext:s,Desc:t}}}validateBeforeSend(){let t=$t.utils["isEmpty"],e=[this.content.data,this.content.description,this.content.extension].some(e=>!t(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class Eo{static parseServerPushElement(e){var{MsgContent:e={Text:""}}=e,e=e["Text"];return new Eo({text:e})}constructor(e){this.type=Xt.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e;return 0<(null==(e=null==(e=this.content)?void 0:e.text)?void 0:e.length)?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},e=(e?this.payload:this.content)["text"];return{MsgType:this.type,MsgContent:{Text:e}}}}var mo=new class{constructor(){this._elementClassMap={[io.MSG_CUSTOM]:po,[io.MSG_TEXT]:Eo}}init(){Xn.getInstance().registerApi({apiName:"createCustomMessage",context:this}),Xn.getInstance().registerApi({apiName:"createTextMessage",context:this})}registerElementClass(e,t){void 0!==t.prototype&&"constructor"in t.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){var{from:t,flow:s=lo.OUT}=e,n=($t.store.get("login")||{})["userId"],t=(this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=lo.OUT),Object.assign(Object.assign({},e),{currentUser:n}));return new go(t)}createCustomMessage(t){let e=rn(),s=this.createMessage(Object.assign(Object.assign({},t),{from:e})),n=this._elementClassMap[io.MSG_CUSTOM];if(!s)return null;if(n){let e=new n(t.payload);s.setElement(e)}return s}createTextMessage(e){var t,s;return e?(t="string"==typeof e.payload?e.payload:(null==(t=null==e?void 0:e.payload)?void 0:t.text)||"",t=new Eo({text:t}),s=rn(),(e=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:s}))).setElement(t),e):null}_updateWithSenderInfo(e){var{nick:t,avatar:s}=e,{userId:n,tinyID:i}=$t.store.get("login")||{},o=Zn.getUserProfile(n);return e.nick=t||(null==o?void 0:o.nick)||"",e.avatar=s||(null==o?void 0:o.avatar)||"",e.tinyID=e.tinyID||i||"",e.from=n,e.status=Qt.UNSENT,e.flow=lo.OUT,e}_isMultiEndpointSyncMessage(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===lo.IN}_isSendByCurrentInstance(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===lo.OUT}};let fo={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}},So={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},vo={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Io(n,i){return Object.keys(i).forEach(e=>{var{range:t,defaultValue:s}=i[e];n[e]=t.includes(n[e])?n[e]:s}),n}function Co(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Mo(e){var{androidInfo:e={},androidOPPOChannelID:t=""}=e,t=e.OPPOChannelID||t,e=Io(e,So),{sound:s="",FCMChannelID:n=""}=e,e=_(e,["sound","FCMChannelID"]);return Object.assign(Object.assign({},e),{Sound:Co(s),OPPOChannelID:t,GoogleChannelID:n})}function Oo(e){var{apnsInfo:e={},ignoreIOSBadge:t=!1,disableVoipPush:s}=e,e=Io(e,vo),{ignoreIOSBadge:n,disableVoipPush:i,enableIOSBackgroundNotification:o}=e,e=_(e,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),n=!0===n||!0===t?1:0;let r;return g(s)||(r=!1===s?1:0),g(i)||(r=!1===i?1:0),Object.assign(Object.assign({},e),{BadgeMode:n,IsVoipPush:r,ContentAvailable:o?1:0})}function To(e){return $t.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Oo(e),AndroidInfo:Mo(e)}:fo}function yo(e){let{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:i,IsSyncMsg:o,MsgBody:r,MsgClientTime:a,MsgLifeTime:l,MsgRandom:c,MsgSeq:u,MsgTimeStamp:d,SendMsgControl:_,SupportMessageExtension:h,TinyId:g,MsgCheckResult:p,CloudCustomData:E,MsgVersion:m,MsgFlagBits:S,RevokerInfo:f}=e,v,{From_Account:I,To_Account:C}=e;if(1===o){let e=C;C=I,I=e}if(f){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=f;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:o,clientTime:a,messageLifeTime:l,random:c,sequence:u,time:d,messageControlInfo:{excludedFromLastMessage:1===(null==_?void 0:_.NoLastMsg),excludedFromUnreadCount:1===(null==_?void 0:_.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:p,cloudCustomData:E,revokerInfo:v,messageVersion:m,messageFlagBits:S,readReceiptSentByPeer:i,elements:Do(r)}}function Ao(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,To_Account:r,MsgVersion:a,CloudCustomData:l}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,to:r,elements:Do(t),messageVersion:a,cloudCustomData:l}}function Ro(e){let{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,TinyId:d,CloudCustomData:_,MsgVersion:h,MsgCheckResult:g,NeedReadReceipt:p,IsPlaceMsg:E,RevokerInfo:m,GroupAtInfo:S}=e,f,v=oo.MSG_PRIORITY_NORMAL;if(Object.keys(ro).includes(String(e.MsgPriority))&&(v=ro[e.MsgPriority]),m){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;f={reason:e,revoker:t,revokerFromUin:s,userID:t}}var I=function(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===ao?t.push(e.GroupAt_Account):e.GroupAtAllFlag===co&&t.push(hs.MSG_AT_ALL)}),t}(S);return{clientSequence:t,from:s,groupProfile:n,clientTime:o,priority:v,random:r,sequence:a,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==c?void 0:c.NoLastMsg),excludedFromUnreadCount:1===(null==c?void 0:c.NoUnread)},isSupportExtension:u,tinyID:d,cloudCustomData:_,messageVersion:h,messageCheckResult:g,needReadReceipt:p,isPlaceMessage:E,revokerInfo:f,atUserList:I,elements:Do(i),to:No(e)}}function No(e){var{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=$t,{ToGroupId:e,GroupInfo:{MillionGroupFlag:n=0,TopicId:i}={}}=e;return n!==s||t(i)?e:i}function Do(e){var t;return e?Array.isArray(e)?e.map(e=>{var t=$t.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}):null==(t=$t.message.messageFactory.getElementClass(e.MsgType))?void 0:t.parseServerPushElement(e):null}function Po(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,GroupId:r,TopicId:a,MsgVersion:l,CloudCustomData:c}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,groupID:r,topicID:a,elements:Do(t),messageVersion:l,cloudCustomData:c}}function wo({conversationUpdateFields:e,message:t}){var{conversationID:s,conversationType:n,conversationSubType:i,flow:o,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,a=a?"":t,t=!r&&o===lo.IN;e.has(s)?(e.get(s).lastMessage=a,t&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:i,unreadCount:t?1:0,lastMessage:a})}function Lo(e){return e.filter(e=>{var t=!Ee(null==e?void 0:e.getElements()),s=1===(null==e?void 0:e.isPlaceMessage);return t||$t.ssoLog.createSSOLogData({method:"emptyMessageBody"}).setLogInfo({message:`from:${e.from} to:${e.to} sequence:`+e.sequence}).end(),t&&!s})}var bo=Object.freeze({__proto__:null,autoIncrementIndex:ho,filterValidMessages:Lo,parseServerGroupMessage:Ro,parseServerPushC2CModifyMessage:Ao,parseServerPushGroupModifyMessage:Po,parseServerPushMessage:yo,parseServerPushMessageElement:Do,updateConversationFields:wo});let ko=$t.utils["isPlainObject"];function Uo(e,t={}){let{onlineUserOnly:s,messageControlInfo:n}=t,i=t["offlinePushInfo"],o=(e.conversationType===no.CONV_C2C&&!0===s&&(i?i.disablePush=!0:i={disablePush:!0}),"");"string"==typeof e.cloudCustomData&&0<e.cloudCustomData.length&&(o=e.cloudCustomData);var r=[];if(n&&ko(n)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&r.push("NoUnread"),!0===t&&r.push("NoLastMsg"),!0===s&&r.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:o,messageControlInfo:r,offlinePushInfo:i}}function Go(e){var t,{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(e||s)return t=[],e&&t.push("ForbidBeforeSendMsgCallback"),s&&t.push("ForbidAfterSendMsgCallback"),t}function Fo(t,s){return h(this,void 0,void 0,function*(){var e=yield tn((t.conversationType===no.CONV_GROUP?function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=Uo(e,t),a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return m(e._receiverList)&&0<e._receiverList.length&&(l=e._receiverList,50<e._receiverList.length)&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit")),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null==(s=$t.store.get("login"))?void 0:s.userId,GroupId:e.to,MsgBody:a,CloudCustomData:i,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:n?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:To(r),SendMsgControl:n?void 0:o,NeedReadReceipt:!0===e.needReadReceipt?1:0,To_Account:l,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:Go(t)}}}:function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=Uo(e,t),n=!0===n?0:void 0,a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null==(s=$t.store.get("login"))?void 0:s.userId,To_Account:e.to,MsgBody:a,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:n,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==n?o:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:To(r),forbidCallbackControl:Go(t)}}})(t,s));return e?{time:e.MsgTime,messageDropReason:e.MsgDropReason,sequence:e.MsgSeq}:null})}let xo=$t.utils["isPlainObject"],{MSG_AUDIO:Vo,MSG_FILE:Bo,MSG_IMAGE:$o,MSG_VIDEO:qo,MSG_MERGER:Wo}=hs;class Yo{init(){Xn.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:e=>![Vo,Bo,$o,qo,Wo].includes(e[0].type)})}sendMessage(u,t){return h(this,void 0,void 0,function*(){let n=$t.ssoLog.createSSOLogData({method:"sendMessage"}),{TOTAL_COUNT:e,SEND_COST:r,SUCCESS_COUNT:a,FAILED_COUNT:o}=vs;if(!(u instanceof go)){let e=new Fs({code:gs.MSG_INSTANCE_REQUIRED});throw n.setError(e).end(),e}let i=u.validateBeforeSend();if(!i.isValid){let{code:e,message:t=""}=i.error||{},s=new Fs({code:e,message:t});throw n.setError(s).end(),s}this._reportMessageSendQuality({name:e,message:u});let l=!1;var c=($t.message||{})["messageDataHandler"];try{let n=(t||{})["messageControlInfo"],i=null,o=(c.addRandomOfSentMessage(u.random),Date.now());if(u.conversationType===no.CONV_C2C?(l=!0===(null==t?void 0:t.onlineUserOnly),i=yield Fo(u,t)):u.conversationType===no.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(u),i=yield Fo(u,t)),i){let{messageDropReason:e,sequence:t,time:s}=i;if(this._updateNickAndAvatarOfSentMessageByMe(u),e&&this._logRateLimitInfo(u,t),this._reportMessageSendQuality({name:a,message:u}),this._reportMessageSendQuality({name:r,message:u,startTs:o}),!0===u.isResend){let e=c.findMessage(u.ID);e&&(console.log("sendMessage resend ok. ID:"+e.ID),c.deleteConversationMessage(e))}return u.status=Qt.SUCCESS,u.time=s,u.conversationType===no.CONV_GROUP&&(u.sequence=t),l?u._onlineOnlyFlag=!0:(c.storeConversationMessage(u),this._applySentMessageControlInfo(u,n),this._emitOnlineMessageSent(u)),{code:0,data:{message:u}}}}catch(e){u.status=Qt.FAIL,c.removeRandomOfSentMessage(u.random);let{errorCode:t,errorMessage:s="",errorInfo:n=s}=e||{},i=(this._hasRiskContent(t)&&(u.hasRiskContent=!0),l||this._isRejectedByRestApi(t)||c.storeConversationMessage(u),this._reportMessageSendQuality({name:o,message:u,error:e}),new Fs({code:t,message:n,data:{message:u}}));throw this._logSendMessageError({message:u,error:i}),i}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return 10100<=e&&e<=10200||120001<=e&&e<=13e4}_logSendMessageError({message:e,error:t}){var s=$t.ssoLog.createSSOLogData({method:"sendMessage"});let n=`head.seq: type:${e.type} from:${e.from} to:`+e.to;if($t.utils.IN_BROWSER){if("connection"in navigator){let e=navigator.connection;n+=` downlink:${e.downlink} effectiveType:${e.effectiveType} rtt:`+e.rtt}if("memory"in window.performance){let e=window.performance.memory;n+=` usedJSHeapSize:${e.usedJSHeapSize} totalJSHeapSize:${e.totalJSHeapSize} jsHeapSizeLimit:`+e.jsHeapSizeLimit}}s.setLogInfo({message:n}).setError(t).end()}_emitOnlineMessageSent(e){var t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,i=Xs(s)?zt.TOPIC_NEW_MESSAGE:zt.NEW_MESSAGE;$t.notificationCenter.emitInnerEvent(i,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&xo(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0)}_logRateLimitInfo(e,t){var s=$t.ssoLog.createSSOLogData({method:"messageDropReason"}),e=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:`+messageDropReason;s.setLogInfo({message:e}).end(),console.warn("sendMessage "+e)}_updateNickAndAvatarOfSentMessageByMe(e){var t=($t.message||{})["messageDataHandler"];let s=!1;var n,i=e["conversationID"],o=t.getLatestMsgSentByMe(i);o&&({nick:o,avatar:n}=o,s=o!==e.nick||n!==e.avatar||s)&&t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}_validateBeforeSendGroupMessage(i){return h(this,void 0,void 0,function*(){var{to:t,from:s}=i;let n=t,e=jn.getGroup(n);if(Js({groupID:n})&&null!=e&&e.isSupportTopic)throw new Fs({code:gs.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(Xs(t)&&([n]=t.split(ds.TOPIC),e=jn.getGroup(n)),!e&&"function"==typeof(null==(t=Xn.getInstance().getApiMap())?void 0:t.getGroupProfile)){let e=yield Xn.getInstance().getApiMap().getGroupProfile({groupID:n});if((null==(t=null==(t=null==e?void 0:e.data)?void 0:t.group)?void 0:t.type)===hs.GRP_AVCHATROOM){let e=Gs({code:gs.MSG_SEND_FAIL_NOT_IN_AV,replacement1:s,replacement2:n});throw new Fs({code:gs.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){$t.notificationCenter.emitInnerEvent(zt.QUALITY_STAT,{label:Ss.MESSAGE_SEND_SUCCESS_RATE,data:e})}}class Ko{constructor(e){this.value=e,this.next=null}}class Ho{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();e=new Ko(e);this.head?this.tail.next=e:this.head=e,this.tail=e,this.size+=1}delete(t){if(this.head)if(this.head.value===t)this.head=this.head.next;else{let e=this.head;for(;e.next;){if(e.next.value===t)return void(e.next=e.next.next);e=e.next}}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,--this.size)}peek(){var e;return null==(e=this.head)?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}var jo=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Ho(100),$t.notificationCenter.subscribeInnerEvent(zt.LOGOUT,this._reset,this),$t.notificationCenter.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}get _messagesByConversation(){return zn.getMessages()}storeConversationMessage(e,t=!1){var s=e["conversationID"];return!!s&&(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),!this._shouldSkipStoreMessage(e,t))&&(t=this._getUniqueIdOfMessage(e),this._messagesByConversation.get(s).set(t,e),this._updateLatestMessageMap(e),!0)}_updateLatestMessageMap(e){var t=e["conversationID"];"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){var s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null!=n&&n.has(s)){let e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var{conversationID:t=""}=e,e=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(t)&&null!=(t=this._messagesByConversation.get(t))&&t.delete(e)}modifyConversationMessage(a,t){var l;if(this._messagesByConversation.has(a)||this._sparseMessagesByConversation.has(a)){let e=this._getUniqueIdOfMessage(t),r=this._getMessageFromLocalMessage(a,e);if(r){let{messageVersion:s,elements:n,cloudCustomData:i,checkResult:e=0}=t,o=1<e;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${r.version} remoteVersion:`+s),r.version<s){let e=this._getUniqueIdOfMessage(r),t=me(n);return null!=(l=this._messagesByConversation.get(a))&&l.has(e)?zn.updateMessage(a,[e],{isModified:!0,version:s,_elements:t,payload:t[0].content,type:t[0].type,cloudCustomData:i,hasRiskContent:o,operation:es.modify}):(r.version=s,r._elements=t,r.payload=r._elements[0].content,r.type=r._elements[0].type,r.cloudCustomData=i,r.isModified=!0,r.hasRiskContent=o),{isUpdated:!0,message:r}}return{isUpdated:!1,message:r}}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,s){var t;if(this._messagesByConversation.has(e))return null==(t=this._messagesByConversation.get(e))?void 0:t.get(s);if(this._sparseMessagesByConversation.has(e)){let t=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<t.length;e++)if(this._getUniqueIdOfMessage(t[e])===s)return t[e]}return null}findMessage(t){let s=null,e=Array.from(this._messagesByConversation.values());for(var n of e)if(s=Array.from(n.values()).find(e=>e.ID===t)||null)break;if(!s){let e=Array.from(this._sparseMessagesByConversation.values());for(var i of e)if(s=i.get(t)||null,s)break}return s}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:t,sequence:s,random:n,revoker:i}){let e=this._messagesByConversation.get(t),o=null;if(e){var r=Array.from(e.values());if(o=this._findMessageBySequenceAndRandom({messageList:r,random:n,sequence:s})){let e=this._getUniqueIdOfMessage(o);return zn.updateMessage(t,[e],{isRevoked:!0,revoker:i,operation:es.revoke}),o}}if(this._sparseMessagesByConversation.has(t)){let e=Array.from(this._sparseMessagesByConversation.get(t).values());if(o=this._findMessageBySequenceAndRandom({messageList:e,random:n,sequence:s}))return o.isRevoked=!0,o.revoker=i,o}}_findMessageBySequenceAndRandom({messageList:t,sequence:s,random:n}){for(let e=0;e<t.length;e+=1){var i=t[e];if(i.sequence===s&&(g(n)||i.random===n))return i}return null}prependLocalMessageList(e){let{messageList:s,conversationID:t}=e;if(0===s.length)return[];var n=[],i=[],o=this._messagesByConversation.get(t)||new Map;for(let t of s){let e=this._getUniqueIdOfMessage(t);o.has(e)||(n.push(t),i.push([e,t]))}if(0<i.length){let e=new Map([...i,...o.entries()]);this._messagesByConversation.set(t,e),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return n}storeSparseMessageList(n){if(0!==n.length){let e=n[0]["conversationID"],s=n.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);var i=this._sparseMessagesByConversation.get(e);for(let t=0;t<s;t++){let e=n[t];i.has(e.ID)||i.set(e.ID,e)}}}_updateLatestMessageSentByMe(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length)for(let e=s.length-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(t,s[e]);break}}_updateLatestMessageSentByPeer(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length&&t.startsWith("C2C"))for(let e=s.length-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(t,s[e]);break}}_getUniqueIdOfMessage(e){var{from:e,to:t,random:s,sequence:n,time:i}=e;return e+`-${t}-${s}-${n}-`+i}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){let{conversationID:t="",latestAvatar:o,latestNick:r,isSentByMe:s=!0}=e,n=this._messagesByConversation.get(t);if(n){let e=Array.from(n.values()),i=s?"out":"in";e.forEach(e=>{var{nick:t,avatar:s,flow:n}=e;n===i&&(t!==r&&(e.nick=r),s!==o)&&(e.avatar=o)})}}isInMessageList(e){var t=e["conversationID"];return!!t&&!!this._messagesByConversation.has(t)&&(e=this._getUniqueIdOfMessage(e),null==(t=this._messagesByConversation.get(t))?void 0:t.has(e))}isMessageSentByCurrentInstance(e){e=e.random;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){e=this._messagesByConversation.get(e);return e?[...e.values()]:[]}getSparseMessageList(e){e=this._sparseMessagesByConversation.get(e);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),$t.notificationCenter.unSubscribeInnerEvent(zt.LOGOUT,this._reset,this),$t.notificationCenter.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this)}};function zo(e,t){var s,n,i,o,r,a,l,c=Hn.getConversation(e);null!=c&&c.lastMessage&&(c=c["lastMessage"],{lastTime:s,lastSequence:n,version:i}=c,{time:t,sequence:o,messageVersion:r,elements:a,cloudCustomData:l}=t,s===t)&&n===o&&i!==r&&(c.type=a[0].type,c.payload=a[0].content,c.messageForShow=ln(c.type,c.payload),c.cloudCustomData=l,c.version=r,Hn.updateConversation(e,{lastMessage:c}))}class Zo{init(){Xn.getInstance().registerApi({apiName:"modifyMessage",context:this})}modifyMessage(u){return h(this,void 0,void 0,function*(){let n=$t.ssoLog.createSSOLogData({method:"modifyMessage"}),{to:i,payload:e,sequence:o,conversationType:r,random:a,time:l,from:c,type:t}=u;if(this._canModifyMessageElement(t)){var s=u.getElements();1<s.length&&(s[0].type=t,s[0].content=e);try{let t=null,s;if(n.setLogInfo({message:"to:"+i}),r===no.CONV_C2C?t=yield function(u){return h(this,void 0,void 0,function*(){let{from:e,to:t,version:s=0,sequence:n,random:i,time:o,type:r,cloudCustomData:a}=u,l={From_Account:e,To_Account:t,MsgVersion:s,MsgSeq:n,MsgRandom:i,MsgTime:o,MsgType:r,MsgBody:u.transformElementsToServerFormat(),CloudCustomData:a},c=yield tn({servcmd:"openim.modify_c2c_msg",data:l});if(c){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=c;return{elements:Do(e),messageVersion:t,cloudCustomData:s}}})}(u):r===no.CONV_GROUP&&(t=yield function(r){return h(this,void 0,void 0,function*(){let{to:e,version:t=0,sequence:s,cloudCustomData:n}=r,i={GroupId:e,MsgVersion:t,MsgSeq:s,MsgBody:r.transformElementsToServerFormat(),CloudCustomData:n},o=yield tn({servcmd:"openim.modify_group_msg",data:i});if(o){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=o;return{elements:Do(e),messageVersion:t,cloudCustomData:s}}})}(u)),t){n.end();let e=""+r+i;return i===rn()&&r===no.CONV_C2C&&(e=""+r+c),s={conversationType:r,from:c,to:i,time:l,random:a,sequence:o,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:e},this._handleModifyMessageSuccess(s),{code:0,data:{message:u}}}}catch(e){let t=(e||{})["errorCode"],s=new Fs({functionName:"modifyMessage",code:t});throw this._logModifyMessageError(s),s}}else n.setLogInfo({message:"can not modify message element. message type: "+t}).end()})}_logModifyMessageError(e){$t.ssoLog.getSSOLogData("modifyMessage").setError(e).end()}_handleModifyMessageSuccess(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent(Ht.MESSAGE_MODIFIED,{name:Ht.MESSAGE_MODIFIED,data:[n]}),$t.notificationCenter.emitInnerEvent(zt.MESSAGE_MODIFIED,{conversationID:t,message:n}),zo(t,e)}_canModifyMessageElement(e){return[io.MSG_TEXT,io.MSG_CUSTOM,io.MSG_LOCATION,io.MSG_FACE].includes(e)}}class Jo{init(){var e=$t["notificationCenter"],t=e["InnerEventSubType"];zs.getInstance().registerWorkflowStep(Es.RECEIVE_C2C_NEW_MESSAGE,ms.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),zs.getInstance().registerWorkflowStep(Es.RECEIVE_C2C_NEW_MESSAGE,ms.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),zs.getInstance().registerWorkflowStep(Es.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ms.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){zs.getInstance().executeWorkflow(Es.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){let t=e.data||{},s=($t.message||{})["messageDataHandler"],n=[],i=new Map;return t.C2cMsgArray.forEach(e=>{e=this._generateC2CMessage(e);this._updateMessageProfile(e);let t=1===e.isModified;s.isMessageSentByCurrentInstance(e)?e.isModified=t:t=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||(s.storeConversationMessage(e)&&wo({conversationUpdateFields:i,message:e}),s.isMessageSentByCurrentInstance(e)&&!t)||n.push(e)}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[ms.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(e)}_emitMessageEventsAfterSyncUnreadMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[ms.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(e)}_emitMessageEvents(e){var t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)));0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(e){var t=no.CONV_C2C,e=yo(e),t=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:lo.IN})),e=e["elements"];return t.setElement(e),t}_updateMessageProfile(n){var e;let i=($t.message||{})["messageDataHandler"],t=null==(e=$t.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;g(o)||g(r)?(n.nick=p(e)?e:n.nick,n.avatar=p(t)?t:n.avatar):o===e&&r===t||(i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:a,nick:o,avatar:r}))}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_updateConversationUserProfile(e){var{conversationID:e,nick:t,avatar:s}=e,{userProfile:n={}}=Hn.getConversation(e)||{};n.avatar===s&&n.nick===t||Hn.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:s})})}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),$t.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),zo(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t=no.CONV_C2C,e=Ao(e),{to:s,from:n}=e;let i=""+t+s;s===(null==(s=$t.store.get("login"))?void 0:s.userId)&&(i=""+t+n),e=Object.assign({conversationType:t,conversationID:i},e),this._updateMessageListDueToModify(e)})}_dispose(){var e=$t["notificationCenter"],e=e["InnerEventSubType"];$t.notificationCenter.unSubscribeInnerEvent(zt.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),$t.notificationCenter.unSubscribeInnerEvent(zt.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),$t.notificationCenter.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this)}}class Xo{init(){var e=$t["notificationCenter"],t=e["InnerEventSubType"];zs.getInstance().registerWorkflowStep(Es.RECEIVE_GROUP_NEW_MESSAGE,ms.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),zs.getInstance().registerWorkflowStep(Es.RECEIVE_GROUP_NEW_MESSAGE,ms.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&zs.getInstance().executeWorkflow(Es.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){let t=e.data||{},s=$t.message["messageDataHandler"],n=[],i=new Map,o=null==t?void 0:t.GroupMsgArray;return null!=o&&o.forEach(e=>{var t;1!==e.GroupInfo.NotVisible&&(e=this._generateGroupMessage(e),this.updateMessageProfile(e),t=1===e.isModified,s.isMessageSentByCurrentInstance(e)&&(e.isModified=t),e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||s.storeConversationMessage(e)&&(n.push(e),wo({conversationUpdateFields:i,message:e})))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEvents(e){var e=((null==(e=e.result)?void 0:e[ms.HANDLE_GROUP_NEW_MESSAGE])||{})["messages"],t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),(null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)))||[]);0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateGroupMessage(e){var t=no.CONV_GROUP,e=Ro(e),t=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:lo.IN})),e=e["elements"];return t.setElement(e),t}updateMessageProfile(i){var e;let t=($t.message||{})["messageDataHandler"],s=null==(e=$t.store.get("login"))?void 0:e.userId,{from:n,nick:o,avatar:r,conversationID:a="",_elements:l}=i;if(n===s){let e=t.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}else if(n===hs.CONV_SYSTEM){let{operationType:e,memberInfoList:t,operatorInfo:s}=l,n={};if(Ee(t)?Ee(s)||(n=s):[us.JOINED,us.KICKED,us.ADMIN_SET,us.ADMIN_CANCELED].includes(e)&&(n=Object.assign({},t[0])),!Ee(n)){let{nick:e="",avatar:t=""}=n;i.nick=e,i.avatar=t}}}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),zo(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{var t=no.CONV_GROUP,{topicID:s,groupID:n}=e=Po(e),s=s||n,e=Object.assign({conversationType:t,conversationID:""+t+s,to:s},e);this._updateMessageListDueToModify(e)})}_dispose(){var e=$t["notificationCenter"],{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}=e["InnerEventSubType"];e.unSubscribeInnerEvent(zt.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(zt.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var{GroupId:e,GroupType:t}=(null==(e=null==(e=null==e?void 0:e.GroupMsgArray)?void 0:e[0])?void 0:e.GroupInfo)||{},t=t===ls.GRP_AVCHATROOM;return!(!jn.getGroup(e)&&t)}}var Qo=new class{constructor(){this.c2cMessageReceiver=new Jo,this.groupMessageReceiver=new Xo}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};let ei={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null==(e=null==e?void 0:e.text)?void 0:e.length))||"payload.text is invalid."}}}},ti={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var si=new class{getGroupRoamingMessagesByAnchor(s){return h(this,void 0,void 0,function*(){try{var r=$t.ssoLog.createSSOLogData({method:"getGroupRoamingMessagesByAnchor"}),{conversationID:t,count:e,direction:a,sequence:l}=s,c=t.replace(rs.CONV_GROUP,""),u=[];let o=l;if(a===ts.BACKWARD){if("number"!=typeof l)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};o=l+e-1}var d=yield function(n){return h(this,void 0,void 0,function*(){var{groupID:e,count:t,messageSequence:s}=n,e={GroupId:e,ReqMsgNumber:t,WithRecalledMsg:1,Version:1};return s&&(e.ReqMsgSeq=s),yield tn({servcmd:"group_open_http_svc.group_msg_get",data:e})})}({groupID:c,count:e,messageSequence:o});if(d){let{RspMsgList:t=[],NextReqMsgSeq:e=0,IsFinished:s,InvisibleMsgSeq:n}=d;r.setLogInfo({message:`groupID:${c} sequence:${l} reqSeq:${o} direction:${a}
|
|
3
|
+
complete:${s} nextSequence:${e} remoteMsgCount:${t.length} invisibleSequenceList:`+n}).end();var _=[];for(let e=0;e<t.length;e++){var g=t[e],p=(g.From_Account===hs.CONV_SYSTEM&&u.push(g),this._parseMessage(g));_.push(p)}_.reverse();let i=s===uo;return a===ts.BACKWARD&&(i=_[_.length-1].sequence>=l),{messageList:Lo(_),invisibleSequenceList:n,nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:i,serverGroupTipList:u}}}catch(e){t=new Fs({code:null==e?void 0:e.code});$t.ssoLog.getSSOLogData("getGroupRoamingMessagesByAnchor").setError(t).end()}})}_parseMessage(e){var t=rs.CONV_GROUP,e=(4===e.Event&&(e.MsgBody.MsgType=hs.MSG_GRP_TIP),Ro(e)),t=mo.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:"in"}));return t.setElement(e.elements),t}};class ni{constructor(){this.messageHelper=bo,this.messageFactory=mo,this.messageSender=new Yo,this.messageAction=new Zo,this.messageReceiver=Qo,this.messageDataHandler=jo,this.messageHistory=si,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),Hs({auth:ti,params:ei})}}let oi="User",ii="Tag_Profile_IM_",ri=100,ai={NICK:ii+"Nick",GENDER:ii+"Gender",BIRTHDAY:ii+"BirthDay",LOCATION:ii+"Location",SELFSIGNATURE:ii+"SelfSignature",ALLOWTYPE:ii+"AllowType",LANGUAGE:ii+"Language",AVATAR:ii+"Image",MESSAGESETTINGS:ii+"MsgSettings",ADMINFORBIDTYPE:ii+"AdminForbidType",LEVEL:ii+"Level",ROLE:ii+"Role"},ci="USER_STATUS",li=1,di={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},ui=new Map([[ai.NICK,"nick"],[ai.GENDER,"gender"],[ai.BIRTHDAY,"birthday"],[ai.LOCATION,"location"],[ai.SELFSIGNATURE,"selfSignature"],[ai.ALLOWTYPE,"allowType"],[ai.LANGUAGE,"language"],[ai.AVATAR,"avatar"],[ai.MESSAGESETTINGS,"messageSettings"],[ai.ADMINFORBIDTYPE,"adminForbidType"],[ai.LEVEL,"level"],[ai.ROLE,"role"]]);var Ni,Di,Pi,_i=new class{createProfile(e,t){let s={userID:e,profileCustomField:[]};return t.forEach(e=>{var{tag:e,value:t}=e;e&&-1<e.indexOf("Tag_Profile_Custom")?s.profileCustomField.push({key:e,value:t}):ui.has(e)&&(s[ui.get(e)]=t)}),Object.assign(Object.assign({},di),s)}parseProfileItem(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}parseProfileList(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}convertParamsToProfile(t){let s=[];return Object.keys(t).forEach(e=>{s.push({tag:ai[e.toUpperCase()],value:t[e]})}),s}normalizeProfileFields(e){let n={};return e.forEach(e=>{var{tag:t,value:s}=e;if(ui.has(t)){let e=ui.get(t);n[e]=s}}),n}};let hi=$t.common["generateProtocolData"];function gi(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_get_all",t={From_Account:rn(),UserItem:[]};n.forEach(e=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});var o=hi({servcmd:e,data:t}),s=o.head.seq+e,o=yield $t.channel.sendPacket(o,{requestId:s});if(o){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n,UserProfileItem:i}=o,r=[];return i.map(e=>{var{To_Account:e,CustomSequence:t,ResultCode:s,ResultInfo:n,StandardSequence:i,ProfileItem:o}=e,o=_i.parseProfileItem(o);r.push({userId:e,customSequence:t,resultCode:s,resultInfo:n,standardSequence:i,profileItem:o})}),{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n,userProfile:r}}})}function pi(e){return Zn.getFriendMap().has(e)}let Ei=$t.utils["isEmpty"];class mi{init(){Xn.getInstance().registerApi({apiName:"getMyProfile",context:this}),Xn.getInstance().registerApi({apiName:"getUserProfile",context:this}),Xn.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=_i.createProfile.bind(_i);var e=$t["notificationCenter"];zs.getInstance().registerWorkflowStep(Es.SYNC_SERVER_INFO_AFTER_LOGIN,ms.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(zt.LOGOUT,this._reset,this),e.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}getMyProfile(){return h(this,void 0,void 0,function*(){let t=$t.ssoLog.createSSOLogData({method:"getMyProfile"});try{var s=rn(),n=yield gi([s]);if(n){let e=this._handleProfileFormResponse(n)[0];return Zn.getUserProfileMap().set(s,e),{code:0,data:e}}t.end()}catch(e){var{errorCode:n,errorInfo:s}=e,n=new Fs({functionName:"getMyProfile",code:n,message:s});throw t.setError(n).end(),e}})}getUserProfile(l){return h(this,void 0,void 0,function*(){var i=$t.ssoLog.createSSOLogData({method:"getUserProfile"});try{let e=l["userIDList"],{userIdListToRequest:t,userIdListToCache:s}=(e.length>ri&&(e=e.slice(0,ri)),this._filterRequestAndCacheUsers(e)),n=[];s.forEach(e=>{e=Zn.getUserProfile(e);n.push(e)});var o="userIDList.length:"+e.length;if(0===t.length)return i.setLogInfo({message:o}).end(),{code:0,data:n};var r=yield gi(t);if(r){let e=this._handleProfileFormResponse(r);e.forEach(e=>{pi(e.userID)&&Zn.getUserProfileMap().set(e.userID,e)});var a=e.concat(n);return i.setLogInfo({message:o}).end(),{code:0,data:a}}}catch(e){r=e["errorCode"],o=new Fs({functionName:"getUserProfile",code:r});throw i.setError(o).end(),o}})}getMyProfileCacheThenServer(){return h(this,void 0,void 0,function*(){var e=rn(),e=Zn.getUserProfileMap().has(e);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(a){return h(this,void 0,void 0,function*(){let i=$t.ssoLog.createSSOLogData({method:"updateMyProfile"}),t=rn(),s={};for(let e in a)void 0!==a[e]&&(s[e]=a[e]);let n=_i.convertParamsToProfile(s);try{let e={From_Account:t,ProfileItem:n};i.setLogInfo({message:JSON.stringify(n)}),yield function(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_set",t=hi({servcmd:e,data:n}),s=""+t.head.seq+e,i=yield $t.channel.sendPacket(t,{requestId:s});if(i){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=i;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);var o=Zn.getUserProfile(t),r=o?Object.assign(Object.assign({},o),s):_i.createProfile(t,n);return Wt(o,r,["lastUpdatedTime","profileCustomField"])||$t.notificationCenter.emitOuterEvent(Ht.PROFILE_UPDATED,{name:Ht.PROFILE_UPDATED,data:[r]}),r.lastUpdatedTime=Date.now(),Zn.getUserProfileMap().set(t,r),i.end(),{code:0,data:r}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new Fs({functionName:"updateMyProfile",code:t,message:s});throw i.setError(n).end(),n}})}updateMyNickAndAvatar(i){return h(this,void 0,void 0,function*(){var e=rn(),t=Date.now(),s=Zn.getUserProfile(e),n={};(n=s?Object.assign(s,i):_i.createProfile(e,i)).lastUpdatedTime=t,Zn.getUserProfileMap().set(e,n)})}_onProfileDataModify(n){var e,t=function(){var{Profile_Account:e,PushType:t,ProfileList:s}=n.ProfileDataMod[0];return{userId:e,pushType:t,profileList:_i.parseProfileList(s)}}();Ei(t)||({isProfileUpdated:t,profile:e}=this._handleProfileModified(t),t&&($t.notificationCenter.emitInnerEvent(zt.PROFILE_UPDATE,{name:zt.PROFILE_UPDATE,data:[e]}),$t.notificationCenter.emitOuterEvent(Ht.PROFILE_UPDATED,{name:Ht.PROFILE_UPDATED,data:[e]})))}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(zt.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(zt.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){let{userId:t,profileList:s}=e,n=Zn.getUserProfile(t);if(!n||!pi(t))return{isProfileUpdated:!1,profile:null};let i=_i.normalizeProfileFields(s),o=Object.keys(i).some(e=>n[e]!==i[e]);return o?(e=Date.now(),e=Object.assign(Object.assign(Object.assign({},n),i),{lastUpdatedTime:e}),Zn.getUserProfileMap().set(t,e),Hn.updateConversation("C2C"+t,{userProfile:e}),{isProfileUpdated:o,profile:e}):{isProfileUpdated:!1,profile:n}}_filterRequestAndCacheUsers(e){let s=[],n=[];return e.forEach(e=>{var t=Zn.getUserProfileMap().has(e);(pi(e)&&t?n:s).push(e)}),{userIdListToRequest:s,userIdListToCache:n}}_handleProfileFormResponse(e){e=e.userProfile;if(!Array.isArray(e))return[];let t=e.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!Ei(e.profileItem)),s=Date.now();return t.map(e=>{e=_i.createProfile(e.userId,e.profileItem);return e.lastUpdatedTime=s,e})}_reset(){Zn.getUserProfileMap().clear()}}let fi=new Map,Si=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=Si.length;e<t;e++)fi.set(e,Si[e]);function vi(e){if(!e)return"";var i=String(e).replace(/[=]+$/,"");let o="";if(i.length%4==1)return"";for(let e,t,s=0,n=0;t=i.charAt(n++);~t&&(e=s%4?64*e+t:t,s++%4)&&(o+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(o))}catch(e){return console.warn(e),""}}let Ii=$t.utils["isEmpty"],Ci=$t.common["generateProtocolData"];function Mi(i){return h(this,void 0,void 0,function*(){var e,t,s="im_open_status.ws_get_user_status",n=Ci({servcmd:s,data:{To_Account:i}}),s=n.head.seq+s,n=yield $t.channel.sendPacket(n,{requestId:s});if(n)return{ErrorCode:s,ErrorInfo:n,ErrorList:e=[],UserStatusList:t=[]}=n,{errorCode:s,errorInfo:n,successUserList:t.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:vi(s)}}),failureUserList:e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Ii(t)?e:t,code:s,message:n}})}})}class Oi{constructor(){this._customStatus=""}init(){var e=$t["notificationCenter"];Xn.getInstance().registerApi({apiName:"getUserStatus",context:this}),Xn.getInstance().registerApi({apiName:"setSelfStatus",context:this}),Xn.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),Xn.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),zs.getInstance().registerWorkflowStep(Es.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ms.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(zt.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(zt.LOGOUT,this._reset,this),e.subscribeInnerEvent(zt.DESTROY,this._dispose,this)}setSelfStatus(s){return h(this,void 0,void 0,function*(){let i=$t.ssoLog.createSSOLogData({method:"setSelfStatus"}),e=rn(),t=s["customStatus"];try{return yield function(i){return h(this,void 0,void 0,function*(){let e="im_open_status.ws_set_custom_status",t=Ci({servcmd:e,data:{CustomStatus:i}}),s=""+t.head.seq+e,n=yield $t.channel.sendPacket(t,{requestId:s});if(n){let{ErrorCode:e,ErrorInfo:t}=n;return{errorCode:e,errorInfo:t}}})}(t),this._customStatus=t,i.setLogInfo({message:"customStatus: "+t}).end(),{code:0,data:{userID:e,statusType:li,customStatus:t}}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new Fs({functionName:"setSelfStatus",code:t,message:s});throw i.setError(n).end(),n}})}getUserStatus(s){return h(this,void 0,void 0,function*(){var e=$t.ssoLog.createSSOLogData({method:"getUserStatus"}),{userIDList:t=[]}=s;return e.setLogInfo({moreMessage:"userIDList length: "+t.length}),this._isOnlyMeInArray(t)?this._getMyStatus():this._getUserStatus(t)})}setCustomStatus(e){e=vi(e);this._customStatus=e}subscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(oi+" subscribeUserStatus options: ",n);var{userIDList:e=[]}=n,t=(this._checkBusinessCapabilityBits("subscribeUserStatus"),this._getMaxUserCount("subscribe")),s=yield function(n){return h(this,void 0,void 0,function*(){var e=$t["channel"],t="im_open_status.ws_status_subscribe",s=Ci({servcmd:t,data:{To_Account:n}}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(oi+" subscribeUserStatus error:",e),e}})}unsubscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(oi+" unsubscribeUserStatus options: ",n),this._checkBusinessCapabilityBits("unsubscribeUserStatus");var{userIDList:e=[]}=n,t=this._getMaxUserCount("unsubscribe"),s=yield function(n){return h(this,void 0,void 0,function*(){var e=$t["channel"],t="im_open_status.ws_status_unsubscribe",s=0===n.length?{UnsubscribeAll:1}:{To_Account:n},s=Ci({servcmd:t,data:s}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(oi+" unsubscribeUserStatus error:",e),e}})}_onUserStatusUpdate(e){var{UserStatusList:e=[]}=e||{},e=e.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:vi(s)}});this._emitUserStatusUpdatedEvent(e)}_onReOnline(e){var e=vi(e.data.customStatus);this._customStatus!==e&&(this._customStatus=e,e={userID:rn(),statusType:li,customStatus:e},this._emitUserStatusUpdatedEvent(e))}_emitUserStatusUpdatedEvent(e){$t.notificationCenter.emitOuterEvent(Ht.USER_STATUS_UPDATED,{name:Ht.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){var{ErrorList:e=[]}=e;return e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:$t.utils.isEmpty(t)?e:t,code:s,message:n}})}_checkBusinessCapabilityBits(e){if(!$t.store.get("commercialConfig").get(ci))throw new Fs({functionName:e,code:gs.NO_USE,replacement1:e})}_getMaxUserCount(e){var t=$t.store.get("cloudConfig")||{},{key:e,default:s}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:ri},unsubscribe:{key:"status_unsub_count",default:ri}}[e],t=t[e]||s;return parseInt(t,10)}_getMyStatus(){var e=$t.ssoLog.getSSOLogData("getUserStatus"),t=(e.setLogInfo({moreMessage:"getUserStatus._getMyStatus"}),{userID:rn(),statusType:li,customStatus:this._customStatus});return e.end(),{code:0,data:{successUserList:[t],failureUserList:[]}}}_getUserStatus(i){return h(this,void 0,void 0,function*(){var t=$t.ssoLog.getSSOLogData("getUserStatus");t.setLogInfo({moreMessage:"getUserStatus._getUserStatus"});try{this._checkBusinessCapabilityBits("getUserStatus");var s=this._getMaxUserCount("query"),{successUserList:n,failureUserList:e}=(yield Mi(this._sliceUserIDList(i,s)))||{};return t.end(),{code:0,data:{successUserList:n,failureUserList:e}}}catch(e){s=e["errorCode"],n=new Fs({functionName:"getUserStatus",code:s});throw t.setError(n).end(),n}})}_isOnlyMeInArray(e){var t=rn();return 1===e.length&&-1<e.indexOf(t)}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(zt.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(zt.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}let Ti={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},yi={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class Ai{constructor(){this.userProfile=new mi,this.userStatus=new Oi,this.userProfile.init(),this.userStatus.init(),Hs({auth:yi,params:Ti})}}function Ri(t){var s=[];if(p(t)){var n=t.length;if(0!==n)for(let e=n-1;0<=e;e--)"1"===t[e]&&s.push(2**(n-e-1))}return s}!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(Ni=Ni||{}),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}(Di=Di||{}),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(Pi=Pi||{});class wi{constructor(){this._name="SyncConversationHandler",this._pagingStatus=Ni.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){var e=$t["notificationCenter"];zs.getInstance().registerWorkflowStep(Es.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ms.CONVERSATION_RECOVER,this._syncConversationList,this),zs.getInstance().registerWorkflowStep(Es.SYNC_SERVER_INFO_AFTER_LOGIN,ms.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),e.subscribeInnerEvent(zt.LOGOUT,this._reset,this),e.subscribeInnerEvent(zt.DESTROY,this._dispose,this),console.log(this._name+".init")}isSyncCompleted(){return this._pagingStatus===Ni.RESOLVED}_syncConversationListAfterLogin(){return h(this,void 0,void 0,function*(){return this._pagingStatus=Ni.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}_syncConversationList(){return h(this,void 0,void 0,function*(){let e=$t["ssoLog"],t=e.createSSOLogData({method:"syncConversationList"});try{let e=yield this._pagingGetConversationList(!0);this._pagingStatus=Ni.RESOLVED;var{conversationList:s=[]}=e||{};return t.setLogInfo({message:"count:"+s.length}).end(),console.log(this._name+"._syncConversationList ok, count:"+s.length),e}catch(e){var{errorCode:s,errorInfo:n}=e,s=new Fs({functionName:"syncConversationList",code:s,message:n});t.setError(s).end(),console.error(this._name+"._syncConversationList fail:",s)}})}_pagingGetConversationList(u){return h(this,void 0,void 0,function*(){try{var e,t=[],s=(this._pagingStatus=Ni.PENDING,yield function(o){return h(this,void 0,void 0,function*(){var{fromAccount:e,pagingTimeStamp:t,pagingStartIndex:s,pagingPinnedTimeStamp:n,pagingPinnedStartIndex:i}=o;return tn({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:e,StartIndex:s,TimeStamp:t,TopStartIndex:i,TopTimeStamp:n}})})}({fromAccount:rn(),pagingTimeStamp:u?this._pagingTimeStamp:0,pagingStartIndex:u?this._pagingStartIndex:0,pagingPinnedTimeStamp:u?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:u?this._pagingPinnedStartIndex:0})),{CompleteFlag:n,SessionItem:i=[],TimeStamp:o,StartIndex:r,TopTimeStamp:a,TopStartIndex:l}=s||{};if(0<i.length){let e=this._getConversationOptions(i);t.push(...e);var c=$t["notificationCenter"];c.emitInnerEvent(zt.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:e})}return this._pagingTimeStamp=o,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=l,1!==n&&(e=(yield this._pagingGetConversationList(u))["conversationList"],t.push(...e)),{conversationList:t}}catch(e){throw console.error(this._name+"._pagingGetConversationList fail:",e),e}})}_getConversationOptions(e){let{isUndefined:t}=$t["utils"],s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===Di.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}_filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===Di.C2C&&!function(e){let t;return"@TLS#ERROR"===(t=e.startsWith(hs.CONV_C2C)?e.replace(hs.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}(t)||2===e)}_assembleC2COption(e){var t,s=this._createUserprofile(e);return{conversationID:""+hs.CONV_C2C+e.userID,type:hs.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:null!=(t=e.lastMsg)&&t.elements[0]?null==(t=e.lastMsg)?void 0:t.elements[0].type:null,payload:null!=(t=e.lastMsg)&&t.elements[0]?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Pi.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null},unreadCount:0,userProfile:s,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Ri(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}_createUserprofile(e){var{userID:e,nick:t,peerAvatar:s}=e,t=[{tag:"Tag_Profile_IM_Nick",value:t},{tag:"Tag_Profile_IM_Image",value:s}];return null==(s=$t.user.userProfile)?void 0:s.createProfile(e,t)}_computeIsPeerRead(e){var{lastC2CMsgFromAccount:e,time:t,c2cPeerReadTime:s}=e;return e===rn()&&t<=s}_assembleGroupOption(e){var t;return{conversationID:""+hs.CONV_GROUP+e.groupID,type:hs.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},this._patchTypeAndPayload(e)),{cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Pi.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null}),groupProfile:{groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq},unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Ri(e.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(e.messageRemindType),subType:e.groupType}}_convertConversationKey(e){return e.map(e=>({type:e.Type,userID:e.To_Account,nick:e.C2cNick,peerAvatar:e.C2cImage,time:e.MsgTimeStamp,sequence:e.MsgSeq,lastC2CMsgFromAccount:e.LastC2cMsgFrom_Account,lastMsg:this._convertLastMsgKey(e.LastMsg),lastMessageFlag:e.LastMsgFlags,c2cPeerReadTime:e.LastC2cMsgPeerReadTime,peerReadTime:e.C2cPeerReadTime,friendRemark:e.C2cRemark,isPinned:e.TopFlags,standardMark:e.StandardMark,customMark:e.CustomMark,messageRemindType:e.MsgRecvOption,groupID:e.ToAccount,groupNick:e.GroupNick,groupImage:e.GroupImage,groupType:e.GroupType,nextMessageSeq:e.GroupNextMsgSeq,msgGroupFromAccount:e.MsgGroupFrom_Account,msgGroupFromNickName:e.MsgGroupFromNickName,MsgGroupFromCardName:e.MsgGroupFromCardName,unreadCount:e.UnreadMsgCount,noUnreadCount:e.GroupIgnoredUnreadSeqCount}))}_convertLastMsgKey(e){var t=$t["utils"]["isEmpty"];if(t(e))return null;let s="",n=null;return e.MsgBody&&(s=null==(t=e.MsgBody[0])?void 0:t.MsgType,n=this._parseContent(s,e.MsgBody[0])),{event:e.Event,elements:[{type:s,content:n,cloudCustomData:e.CloudCustomData}],revokerInfo:{revoker:null==(t=e.RevokerInfo)?void 0:t.revoker}}}_parseContent(e,t){return t&&((e=$t.message.messageFactory.getElementClass(e))?null==(e=e.parseServerPushElement(t))?void 0:e.content:t)}_amendLayersOverLimitProp(e){var t=e["LayersOverLimit"];return _(e,["LayersOverLimit"]).layersOverLimit=1===t,e}_transMsgRemindType(e){let t="";return 0===e?t=hs.MSG_REMIND_ACPT_AND_NOTE:1===e?t=hs.MSG_REMIND_DISCARD:2===e?t=hs.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=hs.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_patchTypeAndPayload(e){var t=$t["utils"]["isUndefined"],{event:e,elements:s=[]}=e.lastMsg||{};return t(e)?{type:s[0]?s[0].type:null,payload:s[0]?this._amendLayersOverLimitProp(s[0].content):null}:{type:hs.MSG_GRP_TIP,payload:{}}}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_reset(){this._pagingStatus=Ni.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();var e=$t["notificationCenter"];e.unSubscribeInnerEvent(zt.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(zt.DESTROY,this._dispose,this)}}class Li{constructor(){this.syncConversationHandler=new wi,this.syncConversationHandler.init()}}console.log("TencentCloudLiteChat.VERSION:"+He);var bi={create:function(e){var{SDKAppID:e,testEnv:t=!1,devMode:s=!1,unlimitedAVChatRoom:n=!1,instance:i}=e,o=e;if("number"!=typeof o&&(e=Number(o),Number.isNaN(e)))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(o=Number(o),Zs.has(o))return Zs.get(o);let r=null;if(i)(r=i)._workflowManager&&zs.setInstance(r._workflowManager),r._pluginManager&&r._pluginManager.installBuiltInPlugin(Wn),!i.isReady()||null!=(i=(e=zs.getInstance()).executeWorkflow)&&i.call(e,Es.SYNC_SERVER_INFO_AFTER_LOGIN);else{let e=""+(a()+a())+a()+a()+a()+a()+a()+a();$t.init({sdkAppId:o,instanceId:e,testEnv:t,devMode:s,unlimitedAVChatRoom:n}),zs.getInstance().init(),$t.message=new ni,$t.user=new Ai,$t.login=new so,$t.conversation=new Li,Kn.getInstance().installBuiltInPlugin(Wn),(r=Xn.getInstance().exposeApiForClient())._workflowManager=zs.getInstance(),r._pluginManager=Kn.getInstance()}function a(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return Zs.set(o,r),r},TSignaling:Zt,EVENT:Ht,VERSION:He,TYPES:hs};export{bi as default};
|