@tencentcloud/lite-chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 522 kB
JavaScript
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,t,s){var n;t&&(this.listeners[e]=null===(n=this.listeners[e])||void 0===n?void 0:n.filter((e=>{const n=e.fn===t,o=!s||e.context===s;return!(n&&o)})))}emit(e,...t){const s=this.listeners[e];s&&s.forEach((e=>{const{fn:s,context:n}=e;s.apply(n,t)}))}once(e,t,s){const n=(...o)=>{t.apply(s,o),this.off(e,n)};this.on(e,n)}}const 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,i=Object.freeze({__proto__:null,get ConvModifyPushType(){return n},ENUM_PLATFORM:t,IS_TOPIC_MESSAGE:2,NOT_NEED_CRC_SERVCMD:s});function r(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||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={}));const 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){var t;const s=[];return null===(t=null==e?void 0:e.C2cNotifyMsgArray)||void 0===t||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){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||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){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach((e=>{const{GroupAtTips:{TopicId:t}}=e;t?s.push(o.TOPIC_AT_TIPS):s.push(o.GROUP_AT_TIPS)})),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||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}];var c;function u(e){var t;const s=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],n=[];return s.forEach((t=>{t.Flag=e.body.Flag;const s=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(!s)return null;let o=[];"function"==typeof s.subTypeParser?o=s.subTypeParser(t):s.subType&&(o=s.subType),Array.isArray(o)?o.forEach((e=>{n.push({type:`${c.SERVER_PUSH_MESSAGE}:${e}`,data:t})})):n.push({type:`${c.SERVER_PUSH_MESSAGE}:${o}`,data:t})})),n}!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={}));const l={[c.SERVER_PUSH_MESSAGE]:u,[c.SERVER_PUSH_MESSAGE_MULTIPLE]:u,[c.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const d=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=o}subscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.on(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.on(e,n,s)}}emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(l).includes(e)){const s=null===(n=l[e])||void 0===n?void 0:n.call(l,t);null==s||s.forEach((e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))}))}}unSubscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.off(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.off(e,n,s)}}subscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.off(e,t,s)}emitOuterEvent(e,t){var s;null===(s=this._outerEventEmitter)||void 0===s||s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function h(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(s[n[o]]=e[n[o]])}return s}function g(e,t,s,n){return new(s||(s=Promise))((function(o,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const p=e=>void 0===e,_=e=>"string"==typeof e,m=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},v=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===m(e),f=e=>null!==e&&"object"==typeof e,I=e=>v(e)||f(e),S=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},E=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s};function C(e=99999999){return Math.round(Math.random()*e)}const M=(e,t,s,n)=>{if(!I(e)||!I(t))return 0;let o=0;const i=Object.keys(t);let r;for(let a=0,c=i.length;a<c;a++)if(r=i[a],!(p(t[r])||s&&s.includes(r)))if(I(e[r])&&I(t[r]))o+=M(e[r],t[r],s,n);else{if(n&&n.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],o+=1)}return o};function y(e){let t,s,n=e;e.length%8!=0&&(n="0".repeat(8-e.length%8)+e);let o="";for(let e=0,{length:i}=n;e<i;e+=8)t=parseInt(n.slice(e,e+4),2),s=parseInt(n.slice(e+4,e+8),2),o+=base16Map.get(t)+base16Map.get(s);return o}const O="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),A="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||O,T=A&&"function"==typeof wx.createGamePortal,R="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),b="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),L="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,P="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,G=A&&"object"==typeof wx.miniapp,w="undefined"!=typeof uni,U=A||R||D||b||L||P||N,k="undefined"==typeof window&&!U&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,F="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),$="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),x="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!F,q=R?qq:D?tt:b?swan:L?my:A?wx:P?uni:N?jd:{},V=x&&window&&window.navigator&&window.navigator.userAgent||"",B=/(micromessenger|webbrowser)/i.test(V),j=function(){let e="WEB";return B?e="WEB":R?e="QQ_MP":D?e="TT_MP":b?e="BAIDU_MP":L?e="ALI_MP":A?e=G?"DONUT_NATIVE_APP":"WX_MP":P?e="UNI_NATIVE_APP":k?e="NS_NATIVE_APP":F&&(e="RN_NATIVE_APP"),t[e]}(),K=/iPad/i.test(V),H=/iPhone/i.test(V)&&!K,W=/iPod/i.test(V),Y=H||K||W,z=function(){const e=V.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),J=/Android/i.test(V),Q=function(){const e=V.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(`${e[1]}.${e[2]}`):t||null}(),X=/Firefox/i.test(V),Z=/Edge/i.test(V),ee=!Z&&/Chrome/i.test(V),te=/MSIE/.test(V)||V.indexOf("Trident")>-1&&V.indexOf("rv:11.0")>-1,se=function(){const e=/MSIE\s(\d+)\.\d/.exec(V);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(V)&&/rv:11.0/.test(V)&&(t=11),t}(),ne=/Safari/i.test(V)&&!ee&&!J&&!Z,oe=/Windows/i.test(V),ie=/MAC OS X/i.test(V),re=x&&"undefined"!=typeof Worker&&!te,ae=J||Y,ce=x&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ue=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!Y||e||ne)}();function le(){let e="unknown";if(ie&&(e="mac"),oe&&(e="windows"),Y&&(e="ios"),J&&(e="android"),U)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const de=2800,he=2801,ge=3e3,pe="application/x-www-form-urlencoded;charset=UTF-8";function _e(e){return g(this,arguments,void 0,(function*({method:e,url:t,data:s,timeout:n=ge}){return new Promise(U?(o,i)=>{q.request({url:t,data:s,method:e,timeout:n,header:{"content-type":pe},success:e=>o(e.data),fail:()=>i(new Error(`{"message":"Network error","code":${de}}`))})}:(o,i)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),i(new Error(`{"message":"Request timeout","code":${he}}`))}),n);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{o(r.responseText?JSON.parse(r.responseText):null)}catch(e){o(r.responseText)}else i(new Error(`{"message":"Network error","code":${de}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",pe),r.send(s||null)})}))}function me(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(E(e)){for(const 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 ve(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const t=new Map;return e.forEach(((e,s)=>{t.set(ve(s),ve(e))})),t}if(e instanceof Set){const t=new Set;return e.forEach((e=>{t.add(ve(e))})),t}if(Array.isArray(e))return e.map((e=>ve(e)));const t=Object.getPrototypeOf(e),s=Object.create(t);return[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach((t=>{const n=Object.getOwnPropertyDescriptor(e,t);n&&(n.get||n.set?Object.defineProperty(s,t,n):s[t]=ve(e[t]))})),s}function fe(){let e,t;return{promise:new Promise(((s,n)=>{e=s,t=n})),resolve:e,reject:t}}var Ie=Object.freeze({__proto__:null,ANDROID_VERSION:Q,IE_VERSION:se,IN_ALIPAY_MINI_APP:L,IN_BAIDU_MINI_APP:b,IN_BROWSER:x,IN_DONUT_NATIVE_APP:G,IN_JD_MINI_APP:N,IN_MINI_APP:U,IN_NS_NATIVE_APP:k,IN_QQ_MINI_APP:R,IN_RN_APP:F,IN_TT_MINI_APP:D,IN_UNI_APP:w,IN_UNI_NATIVE_APP:P,IN_WX_MINI_APP:A,IN_WX_MINI_APP_DESK:O,IN_WX_MINI_GAME:T,IN_WX_MINI_PLUGIN:$,IOS_VERSION:z,IS_ANDROID:J,IS_CHROME:ee,IS_EDGE:Z,IS_FIREFOX:X,IS_IE:te,IS_IOS:Y,IS_IPAD:K,IS_IPHONE:H,IS_IPOD:W,IS_MAC:ie,IS_SAFARI:ne,IS_WECHAT:B,IS_WIN:oe,IS_WORKER_AVAILABLE:re,MINI_APP_NAMESPACE:q,USER_AGENT:V,base16EncodeBinaryString:y,deepCopyWithMethods:ve,deepMerge:M,generatePromise:fe,getPlatformType:le,getType:m,httpRequest:_e,isArray:v,isArrayOrObject:I,isEmpty:me,isFlutterWeb:ce,isH5:ae,isIOSWebView:ue,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:f,isPlainObject:E,isString:_,isUndefined:p,isValidRequestKey:S,platform:j,randomInt:C,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t}});class Se{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t,s;try{null===(t=this._socket)||void 0===t||t.send(e)}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=s,this._socket.onclose=n,this._socket.onerror=o,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 Ee{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)||void 0===t||t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(o),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)}}const Ce="CONNECT",Me="SEND",ye="DISCONNECT",Oe="OPEN",Ae="MESSAGE",Te="CLOSE",Re="ERROR",De="SEND_FAIL";class be{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){const 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,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:Me,data:e})}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;if(this._worker){const e={[Oe]:t,[Ae]:s,[Te]:n,[Re]:o,[De]:i};this._onSendFail=i,this._worker.onmessage=t=>{var s;const{type:n}=(null==t?void 0:t.data)||{};"function"==typeof e[n]&&(null===(s=e[n])||void 0===s||s.call(e,null==t?void 0:t.data))}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:ye}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Le,Ne=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(U){if(L){return my.getStorageSync({key:e}).data}return q.getStorageSync(e)}return this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){const 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?L?my.setStorageSync({key:e,data:JSON.stringify(t)}):q.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"}(Le||(Le={}));class Pe{constructor(t){this._url="",this._readyState=Le.DISCONNECTED,this._url=t,this._id=C(),this._emitter=new e,A?this._socket=new Ee:this._canUseWebWorker()?this._socket=new be:this._socket=new Se,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Le.CONNECTED,Le.CONNECTING].includes(this._readyState)||(this._readyState=Le.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Le.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Le.CONNECTED,Le.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===Le.CONNECTED}disconnect(){this._readyState=Le.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Le.CONNECTING&&(this._readyState=Le.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Le.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Le.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Le.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(){const e=Ne.get("cloudConfig")||{};return(p(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&re}}const Ge="CHINA",we="OVERSEA",Ue="SINGAPORE",ke="KOREA",Fe="GERMANY",$e="IND",xe="JPN",qe="USA",Ve="INDONESIA",Be={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"}}},je={[Ue]:[[2e7,3e7],[172e7,173e7]],[ke]:[[3e7,4e7],[173e7,174e7]],[Fe]:[[4e7,5e7],[174e7,175e7]],[$e]:[[5e7,6e7],[175e7,176e7]],[xe]:[[6e7,7e7],[176e7,177e7]],[qe]:[[7e7,8e7],[177e7,178e7]],[Ve]:[[8e7,9e7],[178e7,179e7]]};function Ke(e){var t;if(null===(t=Ne.get("instance"))||void 0===t?void 0:t.oversea)return we;for(const t of Object.keys(je))for(const[s,n]of je[t])if(e>=s&&e<n)return t;return Ge}var He,We="1.4.2";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(He||(He={}));let Ye=He.INITIAL;function ze(){const e=Math.random();return 0===e?ze():e}function Je(e,t){const{isBinary:s=!1}=t||{},n=Ne.get("instance"),{sdkAppId:o,instanceId:i}=n,r=ze(),a=le(),c=function(){const e=le();let t=-1;"ios"===e?t=z||-1:"android"===e&&(t=Q||-1);return t}(),u=(l={sdkappid:o,instanceid:i,random:r,platform:j,host:a,version:c,sdkversion:We},Object.keys(l).map((e=>`${e}=${l[e]}`)).join("&"));var l;return s?`${e}/binfo?${u}&compress=gzip`:`${e}/info?${u}`}var Qe=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){const s=Date.now(),n=s-e;this._timeOffsetWithServer=t+n-s}};const Xe=16;var Ze=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){const{id:t}=e;this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){const{id:t,callback:s,context:n,isOnce:o=!1,intervalMs:i=Xe}=e,r=Math.max(i,Xe);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:i,callback:s,context:n,isOnce:o}}addTask(e){const t=this._createTask(e);this._addTaskToScheduler(t)}addOnceTask(e){const t=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(t)}removeTask(e){const t=this._tasks.findIndex((t=>t.id===e));t>-1&&(this._tasks.splice(t,1),this._taskMap.delete(e),this._scheduleNextTask())}updateTaskInterval(e,t){const s=this._taskMap.get(e);s&&(s.intervalMs=t,s.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);const e=this._tasks[0];if(e){const t=Math.max(0,e.nextExecuteTime-Date.now());this._timer=setTimeout((()=>this._execute()),t)}}_execute(){const e=Date.now();for(;this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){const 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(e){const t=[];for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n>=55296&&n<=56319){const o=e.charCodeAt(++s)-56320+(n-55296<<10)+65536;t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}else n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):t.push(224|n>>12,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function st(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&S(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=st(e[s]));return t}function nt(e,t){if(s.includes(e))return 0;const n=et(JSON.stringify(t));let o=4294967295;const{length:i}=n;for(let e=0;e<i;e++){o^=n[e];for(let e=0;e<8;e++)1&~o?o>>>=1:o=o>>>1^3988292384}return(4294967295^o)>>>0}function ot(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ne.get("login")||{},s=Ne.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:s.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:y(""),cappid:t.cappid||0,tjgID:"",seq:at(),cs:0}}(t),o=st(s);return n.cs=nt(t,o),{head:n,body:o}}function it(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ne.get("login")||{},s=Ne.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:y(""),cappid:t.cappid||0,seq:at(),cs:0}}(t),o=st(s);return n.cs=nt(t,o),{head:n,body:o}}let rt=C();function at(){return rt=rt<2415919103?rt+1:C(),rt}function ct(){const e=Ne.get("login")||{},t=Ne.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.4.2",tiny_id:Number(e.tinyID),user_id:e.userId,platform:j,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var ut,lt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ne.get("login")||{},s=Ne.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:y(""),cappid:t.cappid||0,seq:at(),cs:0}}(t),o=st(s);return n.cs=nt(t,o),{head:n,body:o}},generateProtocolData:ot,generateSSOLogProtocolData:it,generateSequence:at,getCommonHead:ct,taskScheduler:Ze,timeManager:Qe});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(ut||(ut={}));const 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 ht{constructor(e){this.level=ut.info,this._canSendLog=!0,this._logCreatedAt=Qe.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;const{method:t,eventType:s=0,uiPlatform:n,message:o}=e||{};this.eventType=s,this.method=t,this.uiPlatform=n,this.message=o||""}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Qe.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=Qe.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=Qe.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=Qe.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())}),0)}setError(e){var t;if(!(e instanceof Error))return console.warn("SSOLogData.setError value not instanceof Error, please check!"),this;if(!this._canSendLog)return this;return(null===(t=Ne.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=ut.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys(dt).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const s=t;dt[s]&&(e[dt[s]]=this[s])})),e}}var gt;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(gt||(gt={}));var pt=gt;const _t=20,mt=6e4,vt=[4,5,6],ft=[],It=[],St="report-logger";var Et=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=_t,this._maxThreshold=100,this._waitingTime=mt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,d.subscribeInnerEvent(pt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Ze.addTask({id:St,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=_t,evt_rpt_waiting:s=mt,evt_rpt_level:n=vt,evt_rpt_sdkappid_bl:o=ft,evt_rpt_tinyid_wl:i=It}=e||{};this._sdkAppIdBlackList=o,this._waitingTime=s,this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=i}createSSOLogData(e){const t=new ht(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()&&this._logQueue.length>0&&this.uploadSSOLogData()}uploadSSOLogData(){return g(this,void 0,void 0,(function*(){if(0===this._logQueue.length)return;const e=this._logQueue.slice(),t=this._filterLogs(e);if(this._logQueue=[],0===t.length)return void(this._lastReportAt=Date.now());const s={Header:ct(),Event:t};me(s.Header.user_id)||(yield function(e){const t="imopenstat.tim_web_report_v2",s=it({servcmd:t,data:e}),n=`${s.head.seq}${t}`;qt.sendPacket(s,{requestId:n})}(s)),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(A){const s=null===(t=null===(e=wx.getAccountInfoSync)||void 0===e?void 0:e.call(wx))||void 0===t?void 0:t.miniProgram;if(s){const{appId:e,envVersion:t}=s;Ne.set("instance",{appId:e,envVersion:t})}}else x&&Ne.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=Ne.get("login")||{},{sdkAppId:s}=Ne.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter((e=>this._reportLevel.includes(e.level)))}reset(){console.log("SSO_LOG_MODULE.reset"),Ze.removeTask(St),d.unSubscribeInnerEvent(pt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=_t,this._maxThreshold=100,this._waitingTime=mt,this._logQueue=[]}};const Ct=15e3,Mt="Channel",yt="channel_schedule_task",Ot="channel_reconnect_task",At="connected",Tt="connecting",Rt="disconnected",Dt=1e3,bt="network_status_change",Lt="activity_status_change",Nt="send_fail",Pt="reconnect_failed",Gt="socket_error",wt="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},Ut(e)}function kt(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,$t={exports:{}};var xt=(Ft||(Ft=1,$t.exports=function e(t,s,n){function o(r,a){if(!s[r]){if(!t[r]){if(!a&&kt)return kt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=s[r]={exports:{}};t[r][0].call(u.exports,(function(e){return o(t[r][1][e]||e)}),u,u.exports,e,t,s,n)}return s[r].exports}for(var i=kt,r=0;r<n.length;r++)o(n[r]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var o=n.shift();if(o){if("object"!=Ut(o))throw new TypeError(o+"must be non-object");for(var i in o)t=o,s=i,Object.prototype.hasOwnProperty.call(t,s)&&(e[i]=o[i])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,s,n,o){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),o);else for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){var t,s,n,o,i,r;for(t=n=0,s=e.length;t<s;t++)n+=e[t].length;for(r=new Uint8Array(n),t=o=0,s=e.length;t<s;t++)i=e[t],r.set(i,o),o+=i.length;return r}},i={arraySet:function(e,t,s,n,o){for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,i))},s.setTyped(n)},{}],2:[function(e,t,s){var n=e("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var r=new n.Buf8(256),a=0;a<256;a++)r[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function c(e,t){if(t<65534&&(e.subarray&&i||!e.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var s="",r=0;r<t;r++)s+=String.fromCharCode(e[r]);return s}r[254]=r[254]=1,s.string2buf=function(e){var t,s,o,i,r,a=e.length,c=0;for(i=0;i<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new n.Buf8(c),i=r=0;r<c;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),s<128?t[r++]=s:(s<2048?t[r++]=192|s>>>6:(s<65536?t[r++]=224|s>>>12:(t[r++]=240|s>>>18,t[r++]=128|s>>>12&63),t[r++]=128|s>>>6&63),t[r++]=128|63&s);return t},s.buf2binstring=function(e){return c(e,e.length)},s.binstring2buf=function(e){for(var t=new n.Buf8(e.length),s=0,o=t.length;s<o;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,n,o,i,a=t||e.length,u=new Array(2*a);for(s=n=0;s<a;)if((o=e[s++])<128)u[n++]=o;else if(4<(i=r[o]))u[n++]=65533,s+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&s<a;)o=o<<6|63&e[s++],i--;1<i?u[n++]=65533:o<65536?u[n++]=o:(o-=65536,u[n++]=55296|o>>10&1023,u[n++]=56320|1023&o)}return c(u,n)},s.utf8border=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;0<=s&&128==(192&e[s]);)s--;return s<0||0===s?t:s+r[e[s]]>t?s:t}},{"./common":1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var o=65535&e,i=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;i=i+(o=o+t[n++]|0)|0,--r;);o%=65521,i%=65521}return o|i<<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 n=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();t.exports=function(e,t,s,o){var i=n,r=o+s;e^=-1;for(var a=o;a<r;a++)e=e>>>8^i[255&(e^t[a])];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,o,i,r,a,c,u,l,d,h,g,p,_,m,v,f,I,S,E,C,M,y,O,A;s=e.state,n=e.next_in,O=e.input,o=n+(e.avail_in-5),i=e.next_out,A=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,u=s.wsize,l=s.whave,d=s.wnext,h=s.window,g=s.hold,p=s.bits,_=s.lencode,m=s.distcode,v=(1<<s.lenbits)-1,f=(1<<s.distbits)-1;e:do{p<15&&(g+=O[n++]<<p,p+=8,g+=O[n++]<<p,p+=8),I=_[g&v];t:for(;;){if(g>>>=S=I>>>24,p-=S,0==(S=I>>>16&255))A[i++]=65535&I;else{if(!(16&S)){if(!(64&S)){I=_[(65535&I)+(g&(1<<S)-1)];continue t}if(32&S){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}E=65535&I,(S&=15)&&(p<S&&(g+=O[n++]<<p,p+=8),E+=g&(1<<S)-1,g>>>=S,p-=S),p<15&&(g+=O[n++]<<p,p+=8,g+=O[n++]<<p,p+=8),I=m[g&f];s:for(;;){if(g>>>=S=I>>>24,p-=S,!(16&(S=I>>>16&255))){if(!(64&S)){I=m[(65535&I)+(g&(1<<S)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(C=65535&I,p<(S&=15)&&(g+=O[n++]<<p,(p+=8)<S&&(g+=O[n++]<<p,p+=8)),c<(C+=g&(1<<S)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(g>>>=S,p-=S,(S=i-r)<C){if(l<(S=C-S)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(y=h,(M=0)===d){if(M+=u-S,S<E){for(E-=S;A[i++]=h[M++],--S;);M=i-C,y=A}}else if(d<S){if(M+=u+d-S,(S-=d)<E){for(E-=S;A[i++]=h[M++],--S;);if(M=0,d<E){for(E-=S=d;A[i++]=h[M++],--S;);M=i-C,y=A}}}else if(M+=d-S,S<E){for(E-=S;A[i++]=h[M++],--S;);M=i-C,y=A}for(;2<E;)A[i++]=y[M++],A[i++]=y[M++],A[i++]=y[M++],E-=3;E&&(A[i++]=y[M++],1<E&&(A[i++]=y[M++]))}else{for(M=i-C;A[i++]=A[M++],A[i++]=A[M++],A[i++]=A[M++],2<(E-=3););E&&(A[i++]=A[M++],1<E&&(A[i++]=A[M++]))}break}}break}}while(n<o&&i<a);n-=E=p>>3,g&=(1<<(p-=E<<3))-1,e.next_in=n,e.next_out=i,e.avail_in=n<o?o-n+5:5-(n-o),e.avail_out=i<a?a-i+257:257-(i-a),s.hold=g,s.bits=p}},{}],8:[function(e,t,s){var n=e("../utils/common"),o=e("./adler32"),i=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,u=2,l=0,d=-2,h=1,g=852,p=592;function _(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){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 n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(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=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(g),t.distcode=t.distdyn=new n.Buf32(p),t.sane=1,t.back=-1,l):d}function f(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,v(e)):d}function I(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)?d:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,f(e))):d}function S(e,t){var s,n;return e?(n=new m,(e.state=n).window=null,(s=I(e,t))!==l&&(e.state=null),s):d}var E,C,M=!0;function y(e){if(M){var t;for(E=new n.Buf32(512),C=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(c,e.lens,0,288,E,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(u,e.lens,0,32,C,0,e.work,{bits:5}),M=!1}e.lencode=E,e.lenbits=9,e.distcode=C,e.distbits=5}function O(e,t,s,o){var i,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new n.Buf8(r.wsize)),o>=r.wsize?(n.arraySet(r.window,t,s-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(o<(i=r.wsize-r.wnext)&&(i=o),n.arraySet(r.window,t,s-o,i,r.wnext),(o-=i)?(n.arraySet(r.window,t,s-o,o,0),r.wnext=o,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=i))),0}s.inflateReset=f,s.inflateReset2=I,s.inflateResetKeep=v,s.inflateInit=function(e){return S(e,15)},s.inflateInit2=S,s.inflate=function(e,t){var s,g,p,m,v,f,I,S,E,C,M,A,T,R,D,b,L,N,P,G,w,U,k,F,$=0,x=new n.Buf8(4),q=[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 d;12===(s=e.state).mode&&(s.mode=13),v=e.next_out,p=e.output,I=e.avail_out,m=e.next_in,g=e.input,f=e.avail_in,S=s.hold,E=s.bits,C=f,M=I,U=l;e:for(;;)switch(s.mode){case h:if(0===s.wrap){s.mode=13;break}for(;E<16;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}if(2&s.wrap&&35615===S){x[s.check=0]=255&S,x[1]=S>>>8&255,s.check=i(s.check,x,2,0),E=S=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&S)<<8)+(S>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&S)){e.msg="unknown compression method",s.mode=30;break}if(E-=4,w=8+(15&(S>>>=4)),0===s.wbits)s.wbits=w;else if(w>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<w,e.adler=s.check=1,s.mode=512&S?10:12,E=S=0;break;case 2:for(;E<16;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}if(s.flags=S,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=S>>8&1),512&s.flags&&(x[0]=255&S,x[1]=S>>>8&255,s.check=i(s.check,x,2,0)),E=S=0,s.mode=3;case 3:for(;E<32;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}s.head&&(s.head.time=S),512&s.flags&&(x[0]=255&S,x[1]=S>>>8&255,x[2]=S>>>16&255,x[3]=S>>>24&255,s.check=i(s.check,x,4,0)),E=S=0,s.mode=4;case 4:for(;E<16;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}s.head&&(s.head.xflags=255&S,s.head.os=S>>8),512&s.flags&&(x[0]=255&S,x[1]=S>>>8&255,s.check=i(s.check,x,2,0)),E=S=0,s.mode=5;case 5:if(1024&s.flags){for(;E<16;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}s.length=S,s.head&&(s.head.extra_len=S),512&s.flags&&(x[0]=255&S,x[1]=S>>>8&255,s.check=i(s.check,x,2,0)),E=S=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(f<(A=s.length)&&(A=f),A&&(s.head&&(w=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),n.arraySet(s.head.extra,g,m,A,w)),512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,s.length-=A),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===f)break e;for(A=0;w=g[m+A++],s.head&&w&&s.length<65536&&(s.head.name+=String.fromCharCode(w)),w&&A<f;);if(512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,w)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===f)break e;for(A=0;w=g[m+A++],s.head&&w&&s.length<65536&&(s.head.comment+=String.fromCharCode(w)),w&&A<f;);if(512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,w)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;E<16;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}if(S!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}E=S=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(;E<32;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}e.adler=s.check=_(S),E=S=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=v,e.avail_out=I,e.next_in=m,e.avail_in=f,s.hold=S,s.bits=E,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){S>>>=7&E,E-=7&E,s.mode=27;break}for(;E<3;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}switch(s.last=1&S,E-=1,3&(S>>>=1)){case 0:s.mode=14;break;case 1:if(y(s),s.mode=20,6!==t)break;S>>>=2,E-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}S>>>=2,E-=2;break;case 14:for(S>>>=7&E,E-=7&E;E<32;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}if((65535&S)!=(S>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&S,E=S=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(A=s.length){if(f<A&&(A=f),I<A&&(A=I),0===A)break e;n.arraySet(p,g,m,A,v),f-=A,m+=A,I-=A,v+=A,s.length-=A;break}s.mode=12;break;case 17:for(;E<14;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}if(s.nlen=257+(31&S),S>>>=5,E-=5,s.ndist=1+(31&S),S>>>=5,E-=5,s.ncode=4+(15&S),S>>>=4,E-=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(;E<3;){if(0===f)break e;f--,S+=g[m++]<<E,E+=8}s.lens[q[s.have++]]=7&S,S>>>=3,E-=3}for(;s.have<19;)s.lens[q[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,k={bits:s.lenbits},U=a(0,s.lens,0,19,s.lencode,0,s.work,k),s.lenbits=k.bits,U){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s