pope-test-lite-chat-test
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 145 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteChat={})}(this,(function(e){"use strict";class t{constructor(){this.listeners={}}on(e,t,n){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:n})}off(e,t,n){var s;t&&(this.listeners[e]=null===(s=this.listeners[e])||void 0===s?void 0:s.filter((e=>{const s=e.fn===t,i=!n||e.context===n;return!(s&&i)})))}emit(e,...t){const n=this.listeners[e];n&&n.forEach((e=>{const{fn:n,context:s}=e;n.apply(s,t)}))}once(e,t,n){const s=(...i)=>{t.apply(n,i),this.off(e,s)};this.on(e,s)}}var n;!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="C2cMsgArray",e.C2C_MODIFIED_MESSAGE="C2cMsgModNotifys",e.PROFILE_MODIFIED="ProfileDataMod",e.GROUP_REALTIME_MESSAGE="GroupMsgArray",e.GROUP_MODIFIED_MESSAGE="GroupMsgModNotifys",e.C2C_NOTIFY_MESSAGE="C2cNotifyMsgArray",e.GROUP_NOTIFY_MESSAGE="GroupTips"}(n||(n={}));const s=[{type:"event",value:100,subType:n.BUSINESS_COMMAND},{type:"hasKey",value:"C2cMsgArray",subType:n.C2C_REALTIME_MESSAGE},{type:"hasKey",value:"C2cMsgModNotifys",subType:n.C2C_MODIFIED_MESSAGE},{type:"hasKey",value:"ProfileDataMod",subType:n.PROFILE_MODIFIED},{type:"hasKey",value:"GroupMsgArray",subType:n.GROUP_REALTIME_MESSAGE},{type:"hasKey",value:"GroupMsgModNotifys",subType:n.GROUP_MODIFIED_MESSAGE},{type:"hasKey",value:"C2cNotifyMsgArray",subType:n.C2C_NOTIFY_MESSAGE},{type:"hasKey",value:"GroupTips",subType:n.GROUP_NOTIFY_MESSAGE}];var i;!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.ERROR="error"}(i||(i={}));const o={[i.SERVER_PUSH_MESSAGE]:function(e){const{EventArray:t}=(null==e?void 0:e.body)||{};return t.map((e=>{const{Event:t}=e,n=s.find((e=>"event"===e.type&&e.value===t));if(n)return{type:`${i.SERVER_PUSH_MESSAGE}:${n.subType}`,data:e};const o=s.find((t=>"hasKey"===t.type&&Object.prototype.hasOwnProperty.call(e,t.value)));return o?{type:`${i.SERVER_PUSH_MESSAGE}:${o.subType}`,data:e}:void 0}))},[i.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const r=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new t,this._innerEventEmitter=new t,this.InnerEventSubType=n}subscribeInnerEvent(e,t,n,s){var i,o;if(["string","number"].includes(typeof t)){const o=t,r=n;null===(i=this._innerEventEmitter)||void 0===i||i.on(`${e}:${o}`,r,s)}else{const s=t;null===(o=this._innerEventEmitter)||void 0===o||o.on(e,s,n)}}emitInnerEvent(e,t){var n,s;if(null===(n=this._innerEventEmitter)||void 0===n||n.emit(e,t),Object.keys(o).includes(e)){const n=null===(s=o[e])||void 0===s?void 0:s.call(o,t);null==n||n.forEach((e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))}))}}unSubscribeInnerEvent(e,t,n,s){var i,o;if(["string","number"].includes(typeof t)){const o=t,r=n;null===(i=this._innerEventEmitter)||void 0===i||i.off(`${e}:${o}`,r,s)}else{const s=t;null===(o=this._innerEventEmitter)||void 0===o||o.off(e,s,n)}}subscribeOuterEvent(e,t,n){var s;null===(s=this._outerEventEmitter)||void 0===s||s.on(e,t,n)}unSubscribeOuterEvent(e,t,n){var s;null===(s=this._outerEventEmitter)||void 0===s||s.off(e,t,n)}emitOuterEvent(e,t){var n;null===(n=this._outerEventEmitter)||void 0===n||n.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function a(e,t,n,s){return new(n||(n=Promise))((function(i,o){function r(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const c=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},l=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n};function d(e=99999999){return Math.round(Math.random()*e)}function u(e){let t,n,s=e;e.length%8!=0&&(s="0".repeat(8-e.length%8)+e);let i="";for(let e=0,{length:o}=s;e<o;e+=8)t=parseInt(s.slice(e,e+4),2),n=parseInt(s.slice(e+4,e+8),2),i+=base16Map.get(t)+base16Map.get(n);return i}const h={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},g="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),_=g&&"function"==typeof wx.createGamePortal,m="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),v="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),S="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,I="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,E=g&&"object"==typeof wx.miniapp,C="undefined"!=typeof uni,y=g||m||p||v||f||I||S,M="undefined"==typeof window&&!y&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,O="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),T="undefined"!=typeof uni?!y:"undefined"!=typeof window&&!y&&!O,D=m?qq:p?tt:v?swan:f?my:g?wx:I?uni:S?jd:{},A=T&&window&&window.navigator&&window.navigator.userAgent||"",L=/(micromessenger|webbrowser)/i.test(A),w=function(){let e="WEB";return L?e="WEB":m?e="QQ_MP":p?e="TT_MP":v?e="BAIDU_MP":f?e="ALI_MP":g?e=E?"DONUT_NATIVE_APP":"WX_MP":I?e="UNI_NATIVE_APP":M?e="NS_NATIVE_APP":O&&(e="RN_NATIVE_APP"),h[e]}(),b=/iPad/i.test(A),N=/iPhone/i.test(A)&&!b,R=/iPod/i.test(A),P=N||b||R,k=function(){const e=A.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),U=/Android/i.test(A),F=function(){const e=A.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(`${e[1]}.${e[2]}`):t||null}(),$=/Firefox/i.test(A),G=/Edge/i.test(A),q=!G&&/Chrome/i.test(A),x=/MSIE/.test(A)||A.indexOf("Trident")>-1&&A.indexOf("rv:11.0")>-1,B=function(){const e=/MSIE\s(\d+)\.\d/.exec(A);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(A)&&/rv:11.0/.test(A)&&(t=11),t}(),j=/Safari/i.test(A)&&!q&&!U&&!G,V=/Windows/i.test(A),K=/MAC OS X/i.test(A),Y=T&&"undefined"!=typeof Worker&&!x,H=U||P,W=T&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,J=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!P||e||j)}();function z(){let e="unknown";if(K&&(e="mac"),V&&(e="windows"),P&&(e="ios"),U&&(e="android"),y)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const Q=2800,X=2801,Z=60002,ee=3e3,te="application/x-www-form-urlencoded;charset=UTF-8";function ne(e){return a(this,arguments,void 0,(function*({method:e,url:t,data:n,timeout:s=ee}){return new Promise(y?(i,o)=>{D.request({url:t,data:n,method:e,timeout:s,header:{"content-type":te},success:e=>i(e.data),fail:()=>o(new Error(`{"message":"Network error","code":${Q}}`))})}:(i,o)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),o(new Error(`{"message":"Request timeout","code":${X}}`))}),s);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{i(r.responseText?JSON.parse(r.responseText):null)}catch(e){i(r.responseText)}else o(new Error(`{"message":"Network error","code":${Q}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",te),r.send(n||null)})}))}function se(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(l(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 ie(){let e,t;return{promise:new Promise(((n,s)=>{e=n,t=s})),resolve:e,reject:t}}var oe,re=Object.freeze({__proto__:null,ANDROID_VERSION:F,IE_VERSION:B,IN_ALIPAY_MINI_APP:f,IN_BAIDU_MINI_APP:v,IN_BROWSER:T,IN_DONUT_NATIVE_APP:E,IN_JD_MINI_APP:S,IN_MINI_APP:y,IN_NS_NATIVE_APP:M,IN_QQ_MINI_APP:m,IN_RN_APP:O,IN_TT_MINI_APP:p,IN_UNI_APP:C,IN_UNI_NATIVE_APP:I,IN_WX_MINI_APP:g,IN_WX_MINI_GAME:_,IOS_VERSION:k,IS_ANDROID:U,IS_CHROME:q,IS_EDGE:G,IS_FIREFOX:$,IS_IE:x,IS_IOS:P,IS_IPAD:b,IS_IPHONE:N,IS_IPOD:R,IS_MAC:K,IS_SAFARI:j,IS_WECHAT:L,IS_WIN:V,IS_WORKER_AVAILABLE:Y,MINI_APP_NAMESPACE:D,USER_AGENT:A,base16EncodeBinaryString:u,generatePromise:ie,getPlatformType:z,httpRequest:ne,isEmpty:se,isFlutterWeb:W,isH5:H,isIOSWebView:J,isPlainObject:l,isValidRequestKey:c,platform:w,randomInt:d});class ae{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t,n;try{null===(t=this._socket)||void 0===t||t.send(e)}catch(e){null===(n=this._onSendFail)||void 0===n||n.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:n,onClose:s,onError:i,onSendFail:o}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=n,this._socket.onclose=s,this._socket.onerror=i,this._onSendFail=o)}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 ce{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:n,onClose:s,onError:i,onSendFail:o}=e;this._socket.onClose(s),this._socket.onOpen(t),this._socket.onMessage(n),this._socket.onError(i),this._onSendFail=o}unbindSocketHandlers(){this._socket&&(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{})))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(oe||(oe={}));class le{constructor(e){this._url="",this._readyState=oe.DISCONNECTED,this._url=e,this._id=d(),this._emitter=new t,this._socket=g?new ce:new ae,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[oe.CONNECTED,oe.CONNECTING].includes(this._readyState)||(this._readyState=oe.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==oe.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[oe.CONNECTED,oe.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,n){this._emitter.on(e,t,n)}off(e,t,n){this._emitter.off(e,t,n)}isConnected(){return this._readyState===oe.CONNECTED}disconnect(){this._readyState=oe.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===oe.CONNECTING&&(this._readyState=oe.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=oe.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=oe.DISCONNECTED,this._emitter.emit("error",e)}_onSendFail(e){this._emitter.emit("sendFail",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()}}const de="CHINA",ue="SINGAPORE",he="KOREA",ge="GERMANY",_e="IND",me="JPN",pe="USA",ve="INDONESIA",fe={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},Se={[ue]:[[2e7,3e7],[172e7,173e7]],[he]:[[3e7,4e7],[173e7,174e7]],[ge]:[[4e7,5e7],[174e7,175e7]],[_e]:[[5e7,6e7],[175e7,176e7]],[me]:[[6e7,7e7],[176e7,177e7]],[pe]:[[7e7,8e7],[177e7,178e7]],[ve]:[[8e7,9e7],[178e7,179e7]]};function Ie(e){for(const t of Object.keys(Se))for(const[n,s]of Se[t])if(e>=n&&e<s)return t;return de}var Ee,Ce=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(y){if(f){return my.getStorageSync({key:e}).data}return D.getStorageSync(e)}return this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){const n=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},n),t))}setStorage(e,t){y?f?my.setStorageSync({key:e,data:JSON.stringify(t)}):D.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)}},ye="1.0.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(Ee||(Ee={}));let Me=Ee.INITIAL;function Oe(){const e=Math.random();return 0===e?Oe():e}function Te(e,t){const{isBinary:n=!1}=t||{},s=Ce.get("instance"),{sdkAppId:i,instanceId:o}=s,r=Oe(),a=z(),c=function(){const e=z();let t=-1;"ios"===e?t=k||-1:"android"===e&&(t=F||-1);return t}();var l;return`${e}/${n?"binfo":"info"}?${l={sdkappid:i,instanceid:o,random:r,platform:w,host:a,version:c,sdkversion:ye},Object.keys(l).map((e=>`${e}=${l[e]}`)).join("&")}`}var De=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 n=Date.now(),s=n-e;this._timeOffsetWithServer=t+s-n}};const Ae=16;var Le=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:n,context:s,isOnce:i=!1,intervalMs:o=Ae}=e,r=Math.max(o,Ae);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:o,callback:n,context:s,isOnce:i}}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 n=this._taskMap.get(e);n&&(n.intervalMs=t,n.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 we(e){return Object.assign(Object.assign({},function(){const e=Ce.get("login")||{},t=Ce.get("instance")||{};return{ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",a2:e.a2Key||void 0,tinyid:e.tinyID||void 0,status_instid:e.statusInstanceId||0,sdkappid:t.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:e.a2Key?void 0:e.userId,usersig:e.a2Key?void 0:e.userSig,sdkability:75689843,sdkability_ext:u(""),cappid:e.cappid||0,tjgID:"",seq:ke()}}()),{servcmd:e})}function be(e){const t=Array.isArray(e)?[]:Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&c(n)&&null!=e[n]&&(null===e[n]||"object"!=typeof e[n]?t[n]=e[n]:t[n]=be(e[n]));return t}function Ne(e){const{servcmd:t,data:n}=e;return be({head:we(t),body:n})}function Re(e){const{servcmd:t,data:n}=e,s=function(e){const t=Ce.get("login")||{},n=Ce.get("instance")||{};return{servcmd:e,ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:n.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:u(""),cappid:t.cappid||0,seq:ke()}}(t);return be({head:s,body:n})}let Pe=d();function ke(){return Pe=Pe<2415919103?Pe+1:d(),Pe}var Ue,Fe=Object.freeze({__proto__:null,generateCosSpecifiedHead:function(e){const{servcmd:t,data:n}=e;return be({head:function(e){const t=Ce.get("login")||{},n=Ce.get("instance")||{};return{servcmd:e,ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:n.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:u(""),cappid:t.cappid||0,seq:ke(),cs:0}}(t),body:n})},generateProtocolData:Ne,generateSSOLogProtocolData:Re,generateSequence:ke,taskScheduler:Le,timeManager:De});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(Ue||(Ue={}));const $e={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 Ge{constructor(e){this.level=Ue.info,this._canSendLog=!0,this._logCreatedAt=De.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:n=0}=e||{};this.eventType=n,this.method=t}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=De.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=De.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=De.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=De.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=Ce.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=Ue.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys($e).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const n=t;$e[n]&&(e[$e[n]]=this[n])})),e}}function qe(){const e=Ce.get("login")||{},t=Ce.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:ye,tiny_id:Number(e.tinyID),user_id:e.userId,platform:w,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var xe;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update"}(xe||(xe={}));var Be=xe;const je=20,Ve=6e4,Ke=[4,5,6],Ye=[],He=[],We="report-logger";var Je=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=je,this._maxThreshold=100,this._waitingTime=Ve,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,r.subscribeInnerEvent(Be.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Le.addTask({id:We,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=je,evt_rpt_waiting:n=Ve,evt_rpt_level:s=Ke,evt_rpt_sdkappid_bl:i=Ye,evt_rpt_tinyid_wl:o=He}=e||{};this._sdkAppIdBlackList=i,this._waitingTime=n,this._minThreshold=t,this._reportLevel=s,this._tinyIdWhiteList=o}createSSOLogData(e){const t=new Ge(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 a(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 n={Header:qe(),Event:t};yield function(e){const t="imopenstat.tim_web_report_v2",n=Re({servcmd:t,data:e}),s=`${n.head.seq}${t}`;it.sendPacket(n,{requestId:s})}(n),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(g){const n=null===(t=null===(e=wx.getAccountInfoSync)||void 0===e?void 0:e.call(wx))||void 0===t?void 0:t.miniProgram;if(n){const{appId:e,envVersion:t}=n;Ce.set("instance",{appId:e,envVersion:t})}}else T&&Ce.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=Ce.get("login")||{},{sdkAppId:n}=Ce.get("instance")||{};return this._sdkAppIdBlackList.includes(n)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter((e=>this._reportLevel.includes(e.level)))}reset(){console.log("SSO_LOG_MODULE.reset"),Le.removeTask(We),r.unSubscribeInnerEvent(Be.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this._uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=je,this._maxThreshold=100,this._waitingTime=Ve,this._logQueue=[]}};const ze=15e3,Qe="Channel",Xe="channel_schedule_task",Ze="connected",et="connecting",nt="disconnected";function st(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s>=55296&&s<=56319){const i=e.charCodeAt(++n)-56320+(s-55296<<10)+65536;t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}else s<=127?t.push(s):s<=2047?t.push(192|s>>6,128|63&s):t.push(224|s>>12,128|s>>6&63,128|63&s)}return new Uint8Array(t)}var it=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._reconnectAttempts=0,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._hasFatalError=!1,this._connectionId=-1,this._isBinarySupported=!0,this._currentConnectState=Ze}init(){Le.addTask({id:Xe,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){const t=Ce.get("instance"),{sdkAppId:n,testEnv:s}=t,i=Ie(n);return Te(s?fe.TEST[i].DEFAULT:fe.PRODUCTION[i].INITIAL.replace("*",`${n}`),{isBinary:e})}(this._isBinarySupported),r.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),this.connect()}sendPacket(e,t){var n;const{requestId:s,timeout:i=ze,canResend:o=!0}=t||{};if(se(e))return console.warn(`${Qe}.sendPacket: packet is empty `,e),null;const r=JSON.stringify(e);let a=null;if(s){const{resolve:e,reject:t,promise:n}=ie();a=n,this._pendingRequests.set(s,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:i,canResend:o})}const c=this._isBinarySupported?st(r).buffer:r;return null===(n=this._socketAdapter)||void 0===n||n.send(c),a}connect(){var e;this._socketAdapter=new le(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();const t=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId();console.log(`${Qe}._connect isWorkerEnabled: false socketID:${t} url:${this._url}`);Je.createSSOLogData({method:"wsConnect"}).setLogInfo({message:`socketID:${t} url:${this._url}`}).end()}disconnect(){var e,t;const n=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId();console.log(`${Qe}.disconnect socketID:${n}`),this._removeEventListeners(),null===(t=this._socketAdapter)||void 0===t||t.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(`${Qe}.dispose`),Le.removeTask(Xe),r.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._reconnectAttempts=0,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._hasFatalError=!1,this._url=""}_shouldSkipReconnect(e){if(e)return!1;const t=this._currentConnectState===et&&this._isReconnecting;return this._hasFatalError||!this._socketAdapter||t}reconnect(){return a(this,arguments,void 0,(function*(e=!1){var t;const n=`forcedFlag:${e}_reconnectAttempts:${this._reconnectAttempts}hasFatalError:${this._hasFatalError}isReconnecting:${this._isReconnecting}_currentConnectState:${this._currentConnectState}`;if(console.log(`Channel.reconnect ${n}`),!this._shouldSkipReconnect(e)){this._url=function(e){const t=Ce.get("instance"),{sdkAppId:n,testEnv:s}=t,i=Ie(n);if(s)return Te(fe.TEST[i].DEFAULT,{isBinary:e});const o=fe.PRODUCTION[i],r=T&&o.ANYCAST;return Te({[Ee.INITIAL]:()=>(Me=Ee.DEFAULT,o.DEFAULT),[Ee.DEFAULT]:()=>(Me=Ee.BACKUP,o.BACKUP),[Ee.BACKUP]:()=>(Me=r?Ee.ANYCAST:Ee.DEFAULT,r?o.ANYCAST:o.DEFAULT),[Ee.ANYCAST]:()=>(Me=Ee.DEFAULT,o.ANYCAST="",o.DEFAULT)}[Me](),{isBinary:e})}(this._isBinarySupported);try{if(this._isReconnecting=!0,this._handleConnectStateChange(et),this._reconnectAttempts>=3)return this._reconnectAttempts=0,void((null===(t=Ce.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)?(console.log("Network is available but connection failed, retrying..."),this.disconnect(),this.connect()):(this._isReconnecting=!1,this._handleConnectStateChange(nt)));this._reconnectAttempts+=1,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange(nt),console.warn("Reconnection failed:",e)}}}))}_addEventListeners(){var e,t,n,s,i;null===(e=this._socketAdapter)||void 0===e||e.on("connect",this._onConnect,this),null===(t=this._socketAdapter)||void 0===t||t.on("message",this._onMessage,this),null===(n=this._socketAdapter)||void 0===n||n.on("close",this._onClose,this),null===(s=this._socketAdapter)||void 0===s||s.on("error",this._onError,this),null===(i=this._socketAdapter)||void 0===i||i.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e,t,n,s,i;null===(e=this._socketAdapter)||void 0===e||e.off("connect",this._onConnect,this),null===(t=this._socketAdapter)||void 0===t||t.off("message",this._onMessage,this),null===(n=this._socketAdapter)||void 0===n||n.off("close",this._onClose,this),null===(s=this._socketAdapter)||void 0===s||s.off("error",this._onError,this),null===(i=this._socketAdapter)||void 0===i||i.off("sendFail",this._onSendFail,this)}_onClose(e){const{socketId:t,event:n}=e||{},s=Je.createSSOLogData({method:"wsOnClose"}),i=`sourceSocketID:${t} currentSocketID:${this._connectionId} code:${null==n?void 0:n.code} reason:${null==n?void 0:n.reason}`,o=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0;s.setLogInfo({message:o,moreMessage:i,code:null==n?void 0:n.code,costTime:o}).end(!0),console.log(`${Qe}._onClose ${i} connectionDuration: ${o}`),this._isReconnecting&&(this._handleConnectStateChange(nt),this._isReconnecting=!1),t===this._connectionId&&this.reconnect()}_onError(e){console.warn(`${Qe}._onError ${JSON.stringify(e)}`),this._handleConnectStateChange(nt)}_onSendFail(){this._handleConnectStateChange(nt)}_onMessage(e){let t;this._updateHeartbeatTime();try{const n=this._isBinarySupported?function(e){const t=new Uint8Array(e);let n="",s=0;const{length:i}=t;for(;s<i;){let e=t[s],o=0,r=0;if(e<=127?(o=0,r=255&e):e<=223?(o=1,r=31&e):e<=239?(o=2,r=15&e):e<=244&&(o=3,r=7&e),i-s-o>0)for(let n=0;n<o;n+=1)e=t[s+n+1],r=r<<6|63&e;else r=65533,o=i-s;n+=String.fromCodePoint(r),s+=o+1}return n}(e.data):e.data;t=JSON.parse(n)}catch(t){console.error(t);return void Je.createSSOLogData({method:"jsonParseError"}).setLogInfo({message:e.data}).end()}if(!t||!t.head)return;const{seq:n,servcmd:s}=t.head,i=`${n}${s}`;this._pendingRequests.has(i)?this._handleRequestResponse(t):this._handlePushMessage(t)}_handleRequestResponse(e){const{seq:t,servcmd:n}=e.head,{int32_error_code:s,str_error_message:i,ErrorCode:o=s,ErrorInfo:a=i}=(null==e?void 0:e.body)||{},c=`${t}${n}`,{resolve:l,reject:d,timestamp:u,headSeq:h}=this._pendingRequests.get(c);if(this._pendingRequests.delete(c),o&&0!==o)return r.emitInnerEvent("error",{errorCode:o,errorInfo:a}),void d({errorCode:o,errorInfo:a});l(e.body)}_handlePushMessage(e){const{servcmd:t}=e.head,{NeedAck:n,SessionData:s}=e.body;1===n&&this._sendAck(s),r.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;console.log(`${Qe}._checkPendingRequestsAndResend reConnectFlag:${this._isReconnecting} promiseMap.size:${this._pendingRequests.size}`),null===(e=this._pendingRequests)||void 0===e||e.forEach(((e,t)=>{var n;const{uplinkData:s,canResend:i,resolve:o,reject:r,timeout:a}=e;if(i){this._pendingRequests.set(t,{resolve:o,reject:r,timestamp:Date.now(),uplinkData:s,timeout:a,canResend:i});const e=this._isBinarySupported?st(s).buffer:s;null===(n=this._socketAdapter)||void 0===n||n.send(e)}else this._pendingRequests.delete(t)}))}_onConnect(e){const{socketId:t,event:n={}}=e||{};this._connectionId=t,this._connectionEstablishedTime=Date.now();const s=Date.now()-this._connectionStartTime,i=`${Qe}._onOpen cost:${s} ms. socketID:${t} res:${JSON.stringify(n)}`;console.log(i);Je.createSSOLogData({method:"wsOnOpen"}).setLogInfo({message:i,costTime:s}).end(),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._reconnectAttempts=0,this._isReconnecting&&(r.emitInnerEvent(Be.RECONNECTED),this._isReconnecting=!1),this._handleConnectStateChange(Ze)}_sendAck(e){const t=Ne({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(t)}_executeScheduledTaskIfReady(){return a(this,void 0,void 0,(function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()}))}_canSendHeartbeat(){var e;return(null===(e=this._socketAdapter)||void 0===e?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return a(this,void 0,void 0,(function*(){var e;const t=Ne({servcmd:"heartbeat.alive",data:{}});try{const e=`${t.head.seq}${t.head.servcmd}`;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){const n=null===(e=Ce.get("netWorkMonitor"))||void 0===e?void 0:e.isNetWorkOnline;if(console.debug(`${Qe}._sendHeartbeat failed. isNetWorkOnline:${n} error:`,t),(null==t?void 0:t.code)===Z){this._hasFatalError=!0;return Je.createSSOLogData({method:"error"}).setLogInfo({message:`code:${null==t?void 0:t.code} message:${null==t?void 0:t.message}`}).end(),void this._handleConnectStateChange(nt)}n?this.reconnect():this._handleConnectStateChange(nt)}}))}_sendHeartbeatIfReady(){return a(this,void 0,void 0,(function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)}))}_updateHeartbeatTime(){this._nextHeartbeatAt=I?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){console.warn(`${Qe}._handleNetworkStatusChange ${JSON.stringify(e)}`);const{isNetworkOnline:t,networkType:n}=e;t&&"none"!==n&&this._reconnectAttempts<3&&this._socketAdapter?(this._reconnectAttempts+=1,this.reconnect()):(this._handleConnectStateChange(nt),this._reconnectAttempts=0)}isPrivateNetWork(){const e=Ce.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){this._currentConnectState!==e&&(console.log(`${Qe}._handleConnectStateChange from ${this._currentConnectState} to ${e}`),this._currentConnectState=e,r.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:e}}))}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(e){a(this,void 0,void 0,(function*(){const t=e.split("/")[2];if(!t.startsWith("ws"))return;const n=`https://${t}/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield ne({method:"GET",url:n,data:{}})}catch(e){console.warn("diagnoseBySSO failed. error:",e)}}))}(this._url),function(e){a(this,void 0,void 0,(function*(){const t=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield ne({method:"GET",url:t,data:{}})}catch(e){console.warn("diagnoseByCDN failed. error:",e)}}))}(this._url))}_clearTimeoutRequest(){for(const[e,t]of this._pendingRequests.entries()){const{reject:n,timestamp:s,timeout:i}=t;Date.now()-s>=i&&(this._pendingRequests.delete(e),Date.now()-this._lastDiagnoseAt>=3e4&&this._diagnose(),n({errorCode:X,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;if(null===(e=Ce.get("instance"))||void 0===e?void 0:e.devMode)return void(this._isBinarySupported=!1);const t=z();(f||g&&"windows"===t||I)&&(this._isBinarySupported=!1)}};const ot={init:function(e){Ce.set("instance",e),it.init()},destroy:function(){it.dispose(),Ce.clear(),Le.dispose()},notificationCenter:r,channel:it,store:Ce,ssoLog:Je,utils:re,common:Fe};var rt,at="1.0.0";!function(e){e.SDK_READY="sdkStateReady",e.SDK_NOT_READY="sdkStateNotReady",e.SDK_DESTROY="sdkDestroy",e.MESSAGE_RECEIVED="onMessageReceived",e.ROOM_CUSTOM_DATA_RECEIVED="onRoomCustomDataReceived",e.MESSAGE_MODIFIED="onMessageModified",e.MESSAGE_REVOKED="onMessageRevoked",e.MESSAGE_READ_BY_PEER="onMessageReadByPeer",e.MESSAGE_READ_RECEIPT_RECEIVED="onMessageReadReceiptReceived",e.MESSAGE_EXTENSIONS_UPDATED="onMessageExtensionsUpdated",e.MESSAGE_EXTENSIONS_DELETED="onMessageExtensionsDeleted",e.MESSAGE_REACTIONS_UPDATED="onMessageReactionsUpdated",e.CONVERSATION_LIST_UPDATED="onConversationListUpdated",e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED="onTotalUnreadMessageCountUpdated",e.CONVERSATION_GROUP_LIST_UPDATED="onConversationGroupListUpdated",e.CONVERSATION_IN_GROUP_UPDATED="onConversationInGroupUpdated",e.GROUP_LIST_UPDATED="onGroupListUpdated",e.GROUP_ATTRIBUTES_UPDATED="groupAttributesUpdated",e.GROUP_COUNTER_UPDATED="onGroupCounterUpdated",e.TOPIC_CREATED="onTopicCreated",e.TOPIC_DELETED="onTopicDeleted",e.TOPIC_UPDATED="onTopicUpdated",e.PROFILE_UPDATED="onProfileUpdated",e.USER_STATUS_UPDATED="onUserStatusUpdated",e.BLACKLIST_UPDATED="blacklistUpdated",e.FRIEND_LIST_UPDATED="onFriendListUpdated",e.FRIEND_GROUP_LIST_UPDATED="onFriendGroupListUpdated",e.FRIEND_APPLICATION_LIST_UPDATED="onFriendApplicationListUpdated",e.MY_FOLLOWERS_LIST_UPDATED="onMyFollowersListUpdated",e.MY_FOLLOWING_LIST_UPDATED="onMyFollowingListUpdated",e.MUTUAL_FOLLOWERS_LIST_UPDATED="onMutualFollowersListUpdated",e.KICKED_OUT="kickedOut",e.ERROR="error",e.NET_STATE_CHANGE="netStateChange",e.ALL_RECEIVE_MESSAGE_OPT_UPDATED="onAllReceiveMessageOptUpdated"}(rt||(rt={}));var ct,lt=rt;!function(e){e.LOGIN="login",e.RE_LOGIN="re_login",e.BEFORE_LOGIN="before_login",e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.UNREAD_MESSAGES_SYNC_COMPLETED="unread_messages_sync_completed",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified"}(ct||(ct={}));var dt,ut=ct;!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(dt||(dt={}));var ht,gt=dt;!function(e){e.KICKED_OUT_REST_API="REST_API_Kick",e.KICKED_OUT_MULT_ACCOUNT="multipleAccount",e.KICKED_OUT_MULT_DEVICE="multipleDevice",e.KICKED_OUT_USERSIG_EXPIRED="userSigExpired",e.MSG_CUSTOM="TIMCustomElem",e.CONV_C2C="C2C"}(ht||(ht={}));var _t=ht;const mt={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022};function pt(e){var t;try{const n=Ce.getStorage("errorMessage");if(!e||!n)return"";const s=(null===(t=JSON.parse(n))||void 0===t?void 0:t.errorMessage)||{},{isIntl:i=!1,code:o,replacement1:r="",replacement2:a=""}=e;if(!o)return"";const c=i?`${o}_en`:`${o}_cn`;let l=s[s[c]?c:o]||"";return l&&(r&&(l=l.replace("$replacement1",r)),a&&(l=l.replace("$replacement2",a))),l}catch(e){return console.warn("Error parsing stored error messages:",e),""}}class vt extends Error{constructor(e){const{functionName:t="Unknown",code:n,message:s=""}=e;let i=s;n&&!s&&(i=pt(e));const o=n?`${t} failed. error: {"message": ${i}, "code": ${n}}`:`${t} failed. error: {"message": ${i}}`;super(),this.code=n,this.errorCode=n,this.errorMessage=o,this.message=o}}const ft=e=>"function"==typeof e;function St(e,t,n){const s=n||[];if(!e||!t)return!1;const i=Object.keys(e).filter((e=>!s.includes(e))),o=Object.keys(t).filter((e=>!s.includes(e)));return i.length===o.length&&i.every((s=>!!t.hasOwnProperty(s)&&("object"==typeof e[s]&&null!==e[s]?St(e[s],t[s],n):e[s]===t[s])))}function It({required:e,rules:t,range:n,value:s,allowEmpty:i,name:o,key:r,customValidator:a}){if(void 0===s){if(e){throw new vt({functionName:o,message:`[${o}] Missing required params: "${r}"`})}return}let c="";if(!t.some((e=>{return e===(t=s,Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase());var t}))){for(let e=0;e<t.length;e++){let n=t[e];n=n.replace(n[0],n[0].toUpperCase()),c+=`${n}/`}c=c.substring(0,c.length-1);const e=`[${r}] must be type of ${c}, received type: ${function(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}(s)}.`;throw new vt({functionName:o,message:e})}if(!1===i){if(Array.isArray(s)&&(0===s.length||"string"==typeof s[0]&&""===s[0].trim())){throw new vt({functionName:o,message:`cannot be empty: "${r}"`})}if("string"==typeof s&&""===s.trim()){throw new vt({functionName:o,message:`cannot be empty: "${r}"`})}}if(a&&"function"==typeof a){const e=a(s);if(!0!==e){throw new vt({functionName:o,message:`[${r}] custom validation failed: ${e||"Invalid value"}`})}}}const Et=[],Ct={},yt={};function Mt(e,t){!function(e,t){var n;if(!e)return;if(!0!==(null===(n=ot.store.get("login"))||void 0===n?void 0:n.isLoggedIn))throw new vt({code:mt.USER_NOT_LOGGED_IN,functionName:t})}(Ct[e],e),function(e,t,n){if(Array.isArray(e))for(let s=0;s<e.length;s++)It.call(this,Object.assign(Object.assign({},e[s]),{value:t[s],name:n}));else for(const s in e)It.call(this,Object.assign(Object.assign({},e[s]),{value:t[0][s],name:n,key:s}))}(yt[e],t,e),function(e){Et.forEach((t=>{const{interceptor:n,context:s}=t;n.apply(s,[e])}))}(e)}function Ot(e,t){Et.push({interceptor:e,context:t})}function Tt(e){const{params:t,auth:n}=e;t&&"object"==typeof t&&Object.assign(yt,t),n&&"object"==typeof n&&Object.assign(Ct,n)}var Dt=new class{constructor(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}installBuiltInPlugin(e){this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e,...t){this._installPlugin(e,this._externalPlugins,...t)}clear(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}_installPlugin(e,t,...n){let s=[];e&&!Array.isArray(e)&&(s=[e]),s.forEach((e=>{var s,i;t.has(e)||(e&&ft(e.install)?(t.add(e),e.install(Nt(),...n),ft(e.onAfterLogin)&&(null===(s=ot.store.get("login"))||void 0===s?void 0:s.isLogin)&&e.onAfterLogin()):ft(e)?(t.add(e),e(Nt(),...n),ft(e.onAfterLogin)&&(null===(i=ot.store.get("login"))||void 0===i?void 0:i.isLogin)&&e.onAfterLogin()):console.warn('A plugin must either be a function or an object with an "install" function.'))}))}};const At={on:ot.notificationCenter.subscribeOuterEvent.bind(ot.notificationCenter),off:ot.notificationCenter.unSubscribeOuterEvent.bind(ot.notificationCenter),destroy:function(){return a(this,void 0,void 0,(function*(){var e,t;try{(null===(e=ot.store.get("login"))||void 0===e?void 0:e.isLogin)&&(yield At.logout()),ot.notificationCenter.emitInnerEvent(ut.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{ot.notificationCenter.emitOuterEvent(lt.SDK_DESTROY,{SDKAppID:null===(t=ot.store.get("instance"))||void 0===t?void 0:t.sdkAppId}),si.clear(),Dt.clear(),ot.destroy()}}))},callExperimentalAPI:function(e,t){if(Lt[e])return Lt[e](t);return Promise.reject(new Error(`API ${e} is not found`))},use:Dt.installExternalPlugin.bind(Dt)},Lt={};function wt(e,t,n){const s=n||e;At[e]=(...e)=>(Mt(s,e),t[s].bind(t)(...e))}function bt(e,t,n){const s=n||e;Lt[e]=t[s].bind(t)}function Nt(){return Object.assign(Object.assign({InnerEvent:ut,InnerEventSubType:ot.notificationCenter.InnerEventSubType,OuterEvent:lt,SignalingEvent:gt,helper:Object.assign(Object.assign(Object.assign({},ot.utils),ot.common),{registerApi:wt,registerExperimentalAPI:bt,registerInterceptor:Ot,registerValidateConfig:Tt,ChatError:vt})},At),ot)}var Rt,Pt,kt;!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Rt||(Rt={})),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Pt||(Pt={})),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=3004]="usersigExpired",e[e.restApi=3006]="restApi"}(kt||(kt={}));const Ut={[Pt.multipleAccount]:"multipleAccount",[Pt.multipleDevice]:"multipleDevice",[Pt.restApi]:"REST_API_Kick",[kt.multipleAccount]:"multipleAccount",[kt.multipleDevice]:"multipleDevice",[kt.restApi]:"REST_API_Kick",[kt.usersigExpired]:"userSigExpired"},Ft="login_online_presence_task",{ERROR:$t,DESTROY:Gt,FORCE_OFFLINE:qt}=ut,{KICKED_OUT_MULT_ACCOUNT:xt,KICKED_OUT_MULT_DEVICE:Bt,KICKED_OUT_REST_API:jt,ACCOUNT_A2KEY_EXPIRED:Vt,MSG_A2KEY_EXPIRED:Kt}=mt;class Yt{init(){const{notificationCenter:e}=ot;e.subscribeInnerEvent(qt,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent($t,Kt,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent($t,Vt,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent($t,xt,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent($t,Bt,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent($t,jt,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Gt,this._dispose,this)}_handleForceOfflineFromServerPush(e){const{EventArray:t=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(t).forEach((e=>{const{KickoutMsgNotify:{KickType:t,NewInstInfo:n}}=e;this._processKickedOutReasonInfo({kickedOutReasonCode:t,newInstanceInfo:n})}))}_extractKickedOutMessages(e){return e.reduce(((e,t)=>[...e,...t.C2cNotifyMsgArray||[]]),[]).filter((e=>{var t;return this._isKickedOut(null===(t=null==e?void 0:e.KickoutMsgNotify)||void 0===t?void 0:t.KickType)}))}_handleForceOfflineFromResponse(e){const{errorCode:t}=e;this._processKickedOutReasonInfo({kickedOutReasonCode:t})}_processKickedOutReasonInfo(e){return a(this,void 0,void 0,(function*(){const{kickedOutReasonCode:t}=e;try{yield ot.login.loginAction.logout(Rt.KICKED_OUT)}catch(e){console.debug(e)}finally{this._logKickedOutEvent(e),ot.notificationCenter.emitOuterEvent(lt.KICKED_OUT,{data:{type:Ut[t]},name:lt.KICKED_OUT}),[Pt.restApi,Vt,Kt].includes(t)&&ot.channel.reconnect()}}))}_logKickedOutEvent(e){const{kickedOutReasonCode:t,newInstanceInfo:n={}}=e,s=ot.ssoLog.createSSOLogData({method:"kickedOut"}),i=`type:${Ut[t]} newInstanceInfo: ${JSON.stringify(n)}`;s.setLogInfo({message:i}).end(!0),console.warn(`loginModule.${i}`)}_isKickedOut(e){return[Pt.multipleAccount,Pt.multipleDevice,Pt.restApi].includes(e)}_dispose(){const{notificationCenter:e}=ot;e.unSubscribeInnerEvent(qt,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent($t,Vt,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent($t,Kt,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent($t,xt,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent($t,Bt,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent($t,jt,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Gt,this._dispose,this)}}function Ht(){return a(this,void 0,void 0,(function*(){const e="im_open_status.wslogin",t=ot.common.generateProtocolData({servcmd:e,data:{state:"Online",isWebUniapp:0,InstType:0,customInfo:""}}),n=`${t.head.seq}${e}`;try{const e=yield ot.channel.sendPacket(t,{timeout:9e4,requestId:n});if(e){const{HelloInterval:t,InstId:n,TinyId:s,TimeStamp:i,CustomStatus:o,PurchaseBits:r,A2Key:a,RichMsgAuthKey:c,ErrorCode:l,ErrorInfo:d,ActionStatus:u}=e;return{helloInterval:t,instanceID:n,tinyID:s,timeStamp:i,customStatus:o,purchaseBits:r,a2Key:a,authKey:c,errorCode:l,errorInfo:d,actionStatus:u}}}catch(e){throw console.warn(e),e}}))}class Wt{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120}init(){const{notificationCenter:e,store:t}=ot;t.set("login",{isReady:!1}),wt("login",this),wt("logout",this),wt("getLoginUser",this),wt("isReady",this),e.subscribeInnerEvent(ut.RECONNECTED,this._reLogin,this),ot.notificationCenter.subscribeInnerEvent(ut.DESTROY,this._dispose,this)}login(e){return a(this,void 0,void 0,(function*(){ot.notificationCenter.emitInnerEvent("BEFORE_LOGIN");const t=ot.ssoLog.createSSOLogData({method:"login",eventType:4});try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new vt({functionName:"login",code:mt.REPEAT_LOGIN});const t=yield this._performLogin(e);return this._validateAfterLogin(t),this._handleLoginSuccess(t),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),{code:0,data:t}}catch(e){const{errorCode:n}=e,s=new vt({functionName:"login",code:n});throw t.setError(s).end(!0),s}finally{this._latestLoginAt=0}}))}_reLogin(){return a(this,void 0,void 0,(function*(){var e;try{if(!this._isLoginIn())return;const t=ot.ssoLog.createSSOLogData({method:"reLogin"}),n=yield Ht();if(n){const{instanceID:s,customStatus:i}=n;ot.store.set("login",{statusInstanceId:s}),ot.user.userStatus.se