UNPKG

@tencentcloud/lite-chat

Version:

Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut

1 lines 513 kB
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 r=(...e)=>{s.apply(n,e),this.off(t,r)};this.on(t,r)}}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 u(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],r=[];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=>{r.push({type:c.SERVER_PUSH_MESSAGE+":"+e,data:t})}):r.push({type:c.SERVER_PUSH_MESSAGE+":"+s,data:t})}),r}!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 l={[c.SERVER_PUSH_MESSAGE]:u,[c.SERVER_PUSH_MESSAGE_MULTIPLE]:u,[c.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},d=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=o}subscribeInnerEvent(s,n,r,i){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=r;null!=(o=this._innerEventEmitter)&&o.on(s+":"+e,t,i)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,r)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(l).includes(t)){let e=null==(t=l[t])?void 0:t.call(l,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,r,i){var o,t;if(["string","number"].includes(typeof n)){let e=n,t=r;null!=(o=this._innerEventEmitter)&&o.off(s+":"+e,t,i)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,r)}}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 h(e,t){var s={};for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(s[r[n]]=e[r[n]]);return s}function g(e,o,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{i(l.next(e))}catch(e){t(e)}}function r(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,r)}i((l=l.apply(e,o||[])).next())})}let p=e=>void 0===e,_=e=>"string"==typeof e,m=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[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=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},E=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,r,i)=>{if(!I(s)||!I(n))return 0;let o=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(p(n[a])||r&&r.includes(a)))if(I(s[a])&&I(n[a]))o+=M(s[a],n[a],r,i);else{if(i&&i.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],o+=1)}return o};function y(s){let n,r,i=s,o="";for(let e=0,t=(i=s.length%8!=0?"0".repeat(8-s.length%8)+s:i)["length"];e<t;e+=8)n=parseInt(i.slice(e,e+4),2),r=parseInt(i.slice(e+4,e+8),2),o+=base16Map.get(n)+base16Map.get(r);return o}let 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),L="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),b="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,w=A&&"object"==typeof wx.miniapp,G="undefined"!=typeof uni,U=A||R||D||L||b||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),q="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!F,x=R?qq:D?tt:L?swan:b?my:A?wx:P?uni:N?jd:{},V=q&&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":L?e="BAIDU_MP":b?e="ALI_MP":A?e=w?"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(){var e=V.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),J=/Android/i.test(V),Q=function(){var e,t,s=V.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(V),Z=/Edge/i.test(V),ee=!Z&&/Chrome/i.test(V),te=/MSIE/.test(V)||-1<V.indexOf("Trident")&&-1<V.indexOf("rv:11.0"),se=function(){var e=/MSIE\s(\d+)\.\d/.exec(V);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test(V)&&/rv:11.0/.test(V)?11:t}(),ne=/Safari/i.test(V)&&!ee&&!J&&!Z,oe=/Windows/i.test(V),ie=/MAC OS X/i.test(V),re=q&&"undefined"!=typeof Worker&&!te,ae=J||Y,ce=q&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ue=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!Y||e||ne))}();function le(){let e="unknown";if(ie&&(e="mac"),oe&&(e="windows"),Y&&(e="ios"),J&&(e="android"),U)try{var t=wx.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}let 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:r,url:i,data:o,timeout:a=ge}){return new Promise(U?(t,e)=>{x.request({url:i,data:o,method:r,timeout:a,header:{"content-type":pe},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${de}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${he}}`))},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":${de}}`))},s.open(r,i,!0),s.setRequestHeader("Content-type",pe),s.send(o||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(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 ve(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(ve(t),ve(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(ve(e))}),t}if(Array.isArray(n))return n.map(e=>ve(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]=ve(n[e]))}),s}function fe(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var Ie=Object.freeze({__proto__:null,ANDROID_VERSION:Q,IE_VERSION:se,IN_ALIPAY_MINI_APP:b,IN_BAIDU_MINI_APP:L,IN_BROWSER:q,IN_DONUT_NATIVE_APP:w,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:G,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:x,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)||"object"==typeof e&&e.constructor===Number),isObject:f,isPlainObject:E,isString:_,isUndefined:p,isValidRequestKey:S,platform:j,randomInt:C,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[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;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:r}=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=r)}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)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:r}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=r}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",ye="DISCONNECT",Oe="OPEN",Ae="MESSAGE",Te="CLOSE",Re="ERROR",De="SEND_FAIL";class Le{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:r,onError:i,onSendFail:o}=e;if(this._worker){let s={[Oe]:t,[Ae]:n,[Te]:r,[Re]:i,[De]:o};this._onSendFail=o,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:ye}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var be,Ne=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return U?b?my.getStorageSync({key:e}).data:x.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?b?my.setStorageSync({key:e,data:JSON.stringify(t)}):x.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"}(be=be||{});class Pe{constructor(t){this._url="",this._readyState=be.DISCONNECTED,this._url=t,this._id=C(),this._emitter=new e,A?this._socket=new Ee:this._canUseWebWorker()?this._socket=new Le:this._socket=new Se,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[be.CONNECTED,be.CONNECTING].includes(this._readyState)||(this._readyState=be.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==be.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[be.CONNECTED,be.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===be.CONNECTED}disconnect(){this._readyState=be.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===be.CONNECTING&&(this._readyState=be.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=be.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=be.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=be.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=Ne.get("cloudConfig")||{};return(p(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&re}}let we="CHINA",Ge="OVERSEA",Ue="SINGAPORE",ke="KOREA",Fe="GERMANY",$e="IND",qe="JPN",xe="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",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",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",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.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",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.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]],[qe]:[[6e7,7e7],[176e7,177e7]],[xe]:[[7e7,8e7],[177e7,178e7]],[Ve]:[[8e7,9e7],[178e7,179e7]]};function Ke(t){var e;if(null!=(e=Ne.get("instance"))&&e.oversea)return Ge;for(let e of Object.keys(je))for(var[s,n]of je[e])if(t>=s&&t<n)return e;return we}var He,We="1.5.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.BACKUP_WEB_ONLY="BACKUP_WEB_ONLY",e.BACKUP_CN="BACKUP_CN",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(He=He||{});let Ye=He.INITIAL;function ze(){var e=Math.random();return 0===e?ze():e}function Je(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:r}=Ne.get("instance"),i=ze(),o=le(),a=function(){var e=le();let t=-1;return"ios"===e?t=z||-1:"android"===e&&(t=Q||-1),t}(),n=(s={sdkappid:n,instanceid:r,random:i,platform:j,host:o,version:a,sdkversion:We},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}function Qe(e){var{sdkAppId:t,testEnv:s}=Ne.get("instance"),t=Ke(t);if(s)return Je(Be.TEST[t].DEFAULT,{isBinary:e});let n=Be.PRODUCTION[t],r=q&&n.ANYCAST,i=q,o=!!n.BACKUP_CN;return Je({[He.INITIAL]:()=>(Ye=He.DEFAULT,n.DEFAULT),[He.DEFAULT]:()=>(Ye=He.IPV6,n.IPV6),[He.IPV6]:()=>(Ye=He.BACKUP,n.BACKUP),[He.BACKUP]:()=>{return i?(Ye=He.BACKUP_WEB_ONLY,e=n.BACKUP_WEB_ONLY,t=Math.floor(10001*Math.random())+1e4,e.replace("*",String(t))):o?(Ye=He.BACKUP_CN,n.BACKUP_CN):r?(Ye=He.ANYCAST,n.ANYCAST):n.DEFAULT;var e,t},[He.BACKUP_WEB_ONLY]:()=>o?(Ye=He.BACKUP_CN,n.BACKUP_CN):r?(Ye=He.ANYCAST,n.ANYCAST):n.DEFAULT,[He.BACKUP_CN]:()=>(Ye=r?He.ANYCAST:He.DEFAULT,n[Ye]),[He.ANYCAST]:()=>(Ye=He.DEFAULT,n.ANYCAST="",n.DEFAULT)}[Ye](),{isBinary:e})}var Xe=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 Ze=16;var et=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:r=Ze}=e,i=Math.max(r,Ze);return{id:e,nextExecuteTime:Date.now()+i,intervalMs:r,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 st(t){var s=[];for(let e=0;e<t.length;e+=1){var n,r=t.charCodeAt(e);55296<=r&&r<=56319?(n=t.charCodeAt(++e)-56320+(r-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):r<=127?s.push(r):r<=2047?s.push(192|r>>6,128|63&r):s.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(s)}function nt(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&S(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=nt(e[t]));return s}function ot(e,t){if(s.includes(e))return 0;var n=st(JSON.stringify(t));let r=4294967295;var i=n["length"];for(let e=0;e<i;e++){r^=n[e];for(let e=0;e<8;e++)1&~r?r>>>=1:r=r>>>1^3988292384}return(4294967295^r)>>>0}function it(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=Ne.get("login")||{},r=Ne.get("instance")||{},{servcmd:n,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:r.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:ct(),cs:0}),r=nt(s);return n.cs=ot(e,r),{head:n,body:r}}function rt(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=Ne.get("login")||{},r=Ne.get("instance")||{},{servcmd:n,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:r.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:ct(),cs:0}),r=nt(s);return n.cs=ot(e,r),{head:n,body:r}}let at=C();function ct(){return at=at<2415919103?at+1:C()}function ut(){var e=Ne.get("login")||{},t=Ne.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.5.0",tiny_id:Number(e.tinyID),user_id:e.userId,platform:j,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var lt,pt,dt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=Ne.get("login")||{},r=Ne.get("instance")||{},{servcmd:n,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:r.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:ct(),cs:0}),r=nt(s);return n.cs=ot(e,r),{head:n,body:r}},generateProtocolData:it,generateSSOLogProtocolData:rt,generateSequence:ct,getCommonHead:ut,taskScheduler:et,timeManager:Xe});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(lt=lt||{});let ht={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 gt{constructor(e){this.level=lt.info,this._canSendLog=!0,this._logCreatedAt=Xe.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+=Xe.getTimeOffsetWithServer()}end(e=!1){var t;this._canSendLog&&(t=Xe.getServerTimeMs(),0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:`+t),e?(this._canSendLog=!1,this.timestamp=Xe.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout(()=>{this._canSendLog=!1,this.timestamp=Xe.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())},0))}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=Ne.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(ht).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{ht[e]&&(t[ht[e]]=this[e])}),t}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(pt=pt||{});var _t=pt;let mt=20,vt=6e4,ft=[4,5,6],It=[],St=[],Et="report-logger";var Ct=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=mt,this._maxThreshold=100,this._waitingTime=vt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,d.subscribeInnerEvent(_t.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),et.addTask({id:Et,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=mt,evt_rpt_waiting:t=vt,evt_rpt_level:s=ft,evt_rpt_sdkappid_bl:n=It,evt_rpt_tinyid_wl:r=St}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=r}createSSOLogData(e){var t=new gt(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 g(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||me((t={Header:ut(),Event:t}).Header.user_id)||(e=(t=rt({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void Vt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(A){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;Ne.set("instance",{appId:e,envVersion:t})}}else q&&Ne.set("instance",{href:window.location.href})}_filterLogs(e){var t=(Ne.get("login")||{})["tinyID"],s=(Ne.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"),et.removeTask(Et),d.unSubscribeInnerEvent(_t.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=mt,this._maxThreshold=100,this._waitingTime=vt,this._logQueue=[]}};let Mt=15e3,yt="Channel",Ot="channel_schedule_task",At="channel_reconnect_task",Tt="connected",Rt="connecting",Dt="disconnected",Lt=1e3,bt="network_status_change",Nt="activity_status_change",Pt="send_fail",wt="reconnect_failed",Gt="socket_error",Ut="socket_close";function kt(e){return(kt="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 Ft(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 $t,Ht,qt={exports:{}},xt=($t||(qt.exports=function s(n,r,i){function o(t,e){if(!r[t]){if(!n[t]){if(!e&&Ft)return Ft(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=r[t]={exports:{}};n[t][0].call(e.exports,function(e){return o(n[t][1][e]||e)},e,e.exports,s,n,r,i)}return r[t].exports}for(var a=Ft,e=0;e<i.length;e++)o(i[e]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,r=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var r=n.shift();if(r){if("object"!=kt(r))throw new TypeError(r+"must be non-object");for(var i in r)t=r,s=i,Object.prototype.hasOwnProperty.call(t,s)&&(e[i]=r[i])}}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,r){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),r);else for(var i=0;i<n;i++)e[r+i]=t[s+i]},flattenChunks:function(e){for(var t,s,n,r,i=t=0,o=e.length;i<o;i++)t+=e[i].length;for(r=new Uint8Array(t),i=s=0,o=e.length;i<o;i++)n=e[i],r.set(n,s),s+=n.length;return r}}),i={arraySet:function(e,t,s,n,r){for(var i=0;i<n;i++)e[r+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,r)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,i))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),r=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var u=new l.Buf8(256),n=0;n<256;n++)u[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function c(e,t){if(t<65534&&(e.subarray&&i||!e.subarray&&r))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}u[254]=u[254]=1,s.string2buf=function(e){for(var t,s,n,r,i=e.length,o=0,a=0;a<i;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<i&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),o+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(o),a=r=0;r<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<i&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),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 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,r,i=t||e.length,o=new Array(2*i),a=s=0;a<i;)if((n=e[a++])<128)o[s++]=n;else if(4<(r=u[n]))o[s++]=65533,a+=r-1;else{for(n&=2===r?31:3===r?15:7;1<r&&a<i;)n=n<<6|63&e[a++],r--;1<r?o[s++]=65533:n<65536?o[s++]=n:(n-=65536,o[s++]=55296|n>>10&1023,o[s++]=56320|1023&n)}return c(o,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+u[e[s]]>t?s:t}},{"./common":$t=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var r=65535&e,i=e>>>16&65535,o=0;0!==s;){for(s-=o=2e3<s?2e3:s;i=i+(r=r+t[n++]|0)|0,--o;);r%=65521,i%=65521}return r|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 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 r=a,i=n+s;e^=-1;for(var o=n;o<i;o++)e=e>>>8^r[255&(e^t[o])];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,r,i,o,a,l=e.state,u=e.next_in,c=e.input,d=u+(e.avail_in-5),h=e.next_out,g=e.output,p=h-(t-e.avail_out),_=h+(e.avail_out-257),m=l.dmax,v=l.wsize,f=l.whave,I=l.wnext,S=l.window,E=l.hold,C=l.bits,M=l.lencode,y=l.distcode,O=(1<<l.lenbits)-1,A=(1<<l.distbits)-1;e:do{for(C<15&&(E+=c[u++]<<C,C+=8,E+=c[u++]<<C,C+=8),s=M[E&O];;){if(E>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))g[h++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=M[(65535&s)+(E&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(r=65535&s,(n&=15)&&(C<n&&(E+=c[u++]<<C,C+=8),r+=E&(1<<n)-1,E>>>=n,C-=n),C<15&&(E+=c[u++]<<C,C+=8,E+=c[u++]<<C,C+=8),s=y[E&A];;){if(E>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=y[(65535&s)+(E&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(i=65535&s,C<(n&=15)&&(E+=c[u++]<<C,(C+=8)<n)&&(E+=c[u++]<<C,C+=8),m<(i+=E&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=n,C-=n,(n=h-p)<i){if(f<(n=i-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=S,(o=0)===I){if(o+=v-n,n<r){for(r-=n;g[h++]=S[o++],--n;);o=h-i,a=g}}else if(I<n){if(o+=v+I-n,(n-=I)<r){for(r-=n;g[h++]=S[o++],--n;);if(o=0,I<r){for(r-=n=I;g[h++]=S[o++],--n;);o=h-i,a=g}}}else if(o+=I-n,n<r){for(r-=n;g[h++]=S[o++],--n;);o=h-i,a=g}for(;2<r;)g[h++]=a[o++],g[h++]=a[o++],g[h++]=a[o++],r-=3;r&&(g[h++]=a[o++],1<r)&&(g[h++]=a[o++])}else{for(o=h-i;g[h++]=g[o++],g[h++]=g[o++],g[h++]=g[o++],2<(r-=3););r&&(g[h++]=g[o++],1<r)&&(g[h++]=g[o++])}break}}break}}while(u<d&&h<_);u-=r=C>>3,E&=(1<<(C-=r<<3))-1,e.next_in=u,e.next_out=h,e.avail_in=u<d?d-u+5:5-(u-d),e.avail_out=h<_?_-h+257:257-(h-_),l.hold=E,l.bits=C}},{}],8:[function(e,t,s){var N=e("../utils/common"),L=e("./adler32"),P=e("./crc32"),w=e("./inffast"),G=e("./inftrees"),U=0,k=-2,F=1,n=852,r=592;function q(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function i(){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 o(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 N.Buf32(n),t.distcode=t.distdyn=new N.Buf32(r),t.sane=1,t.back=-1,U):k}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,o(e)):k}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))?k:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function u(e,t){var s;return e?(s=new i,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):k}var x,V,B=!0;function j(e,t,s,n){var r,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new N.Buf8(e.wsize)),n>=e.wsize?(N.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(r=e.wsize-e.wnext)&&(r=n),N.arraySet(e.window,t,s-n,r,e.wnext),(n-=r)?(N.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=r,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=r))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=o,s.inflateInit=function(e){return u(e,15)},s.inflateInit2=u,s.inflate=function(e,t){var s,n,r,i,o,a,l,u,c,d,h,g,p,_,m,v,f,I,S,E,C,M,y,O,A=0,T=new N.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 k;12===(s=e.state).mode&&(s.mode=13),o=e.next_out,r=e.output,l=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,u=s.hold,c=s.bits,d=a,h=l,M=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;c<16;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}if(2&s.wrap&&35615===u)T[s.check=0]=255&u,T[1]=u>>>8&255,s.check=P(s.check,T,2,0),c=u=0,s.mode=2;else if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&u)<<8)+(u>>8))%31)e.msg="incorrect header check",s.mode=30;else if(8!=(15&u))e.msg="unknown compression method",s.mode=30;else{if(c-=4,C=8+(15&(u>>>=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&u?10:12,c=u=0}}break;case 2:for(;c<16;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}if(s.flags=u,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=u>>8&1),512&s.flags&&(T[0]=255&u,T[1]=u>>>8&255,s.check=P(s.check,T,2,0)),c=u=0,s.mode=3;case 3:for(;c<32;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}s.head&&(s.head.time=u),512&s.flags&&(T[0]=255&u,T[1]=u>>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,s.check=P(s.check,T,4,0)),c=u=0,s.mode=4;case 4:for(;c<16;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}s.head&&(s.head.xflags=255&u,s.head.os=u>>8),512&s.flags&&(T[0]=255&u,T[1]=u>>>8&255,s.check=P(s.check,T,2,0)),c=u=0,s.mode=5;case 5:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}s.length=u,s.head&&(s.head.extra_len=u),512&s.flags&&(T[0]=255&u,T[1]=u>>>8&255,s.check=P(s.check,T,2,0)),c=u=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((g=a<(g=s.length)?a:g)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),N.arraySet(s.head.extra,n,i,g,C)),512&s.flags&&(s.check=P(s.check,n,g,i)),a-=g,i+=g,s.length-=g),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;for(g=0;C=n[i+g++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&g<a;);if(512&s.flags&&(s.check=P(s.check,n,g,i)),a-=g,i+=g,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(g=0;C=n[i+g++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&g<a;);if(512&s.flags&&(s.check=P(s.check,n,g,i)),a-=g,i+=g,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;c<16;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}if(u!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}c=u=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(;c<32;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}e.adler=s.check=q(u),c=u=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=o,e.avail_out=l,e.next_in=i,e.avail_in=a,s.hold=u,s.bits=c,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last)u>>>=7&c,c-=7&c,s.mode=27;else{for(;c<3;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}switch(s.last=1&u,--c,3&(u>>>=1)){case 0:s.mode=14;break;case 1:D=b=void 0;var D,b=s;if(B){for(x=new N.Buf32(512),V=new N.Buf32(32),D=0;D<144;)b.lens[D++]=8;for(;D<256;)b.lens[D++]=9;for(;D<280;)b.lens[D++]=7;for(;D<288;)b.lens[D++]=8;for(G(1,b.lens,0,288,x,0,b.work,{bits:9}),D=0;D<32;)b.lens[D++]=5;G(2,b.lens,0,32,V,0,b.work,{bits:5}),B=!1}if(b.lencode=x,b.lenbits=9,b.distcode=V,b.distbits=5,s.mode=20,6!==t)break;u>>>=2,c-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}u>>>=2,c-=2}break;case 14:for(u>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&u,c=u=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(g=s.length){if(0===(g=l<(g=a<g?a:g)?l:g))break e;N.arraySet(r,n,i,g,o),a-=g,i+=g,l-=g,o+=g,s.length-=g}else s.mode=12;break;case 17:for(;c<14;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}if(s.nlen=257+(31&u),u>>>=5,c-=5,s.ndist=1+(31&u),u>>>=5,c-=5,s.ncode=4+(15&u),u>>>=4,c-=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(;c<3;){if(0===a)break e;a--,u+=n[i++]<<c,c+=8}s.lens[R[s.have++]]=7&u,u>>>=3,c-=3}for(;s.have<19;)s.lens[R[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,y={bits:s.lenbits},M=G(0,s.lens,0,19,s.lencode,0,s.work,y),s.lenbits=y.bits,M){e.msg="invalid code lengths set