@tencentcloud/lite-chat 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/basic.d.ts +3110 -0
  3. package/basic.es.js +3 -1
  4. package/basic.js +3 -1
  5. package/package.json +3 -3
  6. package/plugins/avchatroom.es.js +1 -1
  7. package/plugins/avchatroom.js +1 -1
  8. package/plugins/cloud-search.es.js +1 -1
  9. package/plugins/cloud-search.js +1 -1
  10. package/plugins/conversation-group.d.ts +8 -0
  11. package/plugins/conversation-group.es.js +1 -0
  12. package/plugins/conversation-group.js +1 -0
  13. package/plugins/conversation.es.js +1 -1
  14. package/plugins/conversation.js +1 -1
  15. package/plugins/follow.es.js +1 -1
  16. package/plugins/follow.js +1 -1
  17. package/plugins/friend.es.js +1 -1
  18. package/plugins/friend.js +1 -1
  19. package/plugins/group.es.js +1 -1
  20. package/plugins/group.js +1 -1
  21. package/plugins/message-enhancer.es.js +3 -1
  22. package/plugins/message-enhancer.js +3 -1
  23. package/plugins/offline-message-synchronizer.d.ts +9 -0
  24. package/plugins/offline-message-synchronizer.es.js +1 -0
  25. package/plugins/offline-message-synchronizer.js +1 -0
  26. package/plugins/rich-media-message.es.js +1 -1
  27. package/plugins/rich-media-message.js +1 -1
  28. package/plugins/signaling.d.ts +8 -0
  29. package/plugins/signaling.es.js +1 -1
  30. package/plugins/signaling.js +1 -1
  31. package/plugins/topic.d.ts +8 -0
  32. package/plugins/topic.es.js +1 -0
  33. package/plugins/topic.js +1 -0
  34. package/professional.d.ts +3110 -0
  35. package/professional.es.js +5 -1
  36. package/professional.js +5 -1
  37. package/standard.es.js +5 -1
  38. package/standard.js +5 -1
  39. package/index.es.js +0 -1
  40. package/index.js +0 -1
  41. package/plugins/user-enhancer.d.ts +0 -8
package/basic.es.js CHANGED
@@ -1 +1,3 @@
1
- class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,t,s){var n;t&&(this.listeners[e]=null===(n=this.listeners[e])||void 0===n?void 0:n.filter((e=>{const n=e.fn===t,o=!s||e.context===s;return!(n&&o)})))}emit(e,...t){const s=this.listeners[e];s&&s.forEach((e=>{const{fn:s,context:n}=e;s.apply(n,t)}))}once(e,t,s){const n=(...o)=>{t.apply(s,o),this.off(e,n)};this.on(e,n)}}var t;!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"}(t||(t={}));const s=[{conditions:[{type:"event",value:100}],subType:t.BUSINESS_COMMAND},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:t.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:t.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:t.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:t.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:t.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:t.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:t.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){var s;const n=[];return null===(s=null==e?void 0:e.C2cNotifyMsgArray)||void 0===s||s.forEach((e=>{e.WithdrawC2cMsgNotify&&n.push(t.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&n.push(t.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&n.push(t.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&n.push(t.C2C_REMIND_TYPE_SYNC)})),n}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subType:t.GROUP_TIPS_NOTIFICATION},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){var s;const n=[];return null===(s=null==e?void 0:e.GroupTips)||void 0===s||s.forEach((e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)&&n.push(t.GROUP_MESSAGE_REVOKED),Array.isArray(e.MsgBody.GroupMsgReceiptList)&&n.push(t.GROUP_MESSAGE_READ_RECEIPT),Array.isArray(e.MsgBody.GroupReadInfoArray)?n.push(t.GROUP_MESSAGE_READ_SYNC):n.push(t.GROUP_SYSTEM_NOTIFICATION)})),n}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subType:t.GROUP_TIPS_NOTIFICATION},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subType:t.GROUP_AT_TIPS},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subType:t.CONV_MODIFIED},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:t.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:t.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:t.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:t.FOLLOW_LIST_UPDATED}];var n;!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.ERROR="error"}(n||(n={}));const o={[n.SERVER_PUSH_MESSAGE]:function(e){var t;const o=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],i=[];return o.forEach((t=>{t.Flag=e.body.Flag;const o=s.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(!o)return null;let r=[];"function"==typeof o.subTypeParser?r=o.subTypeParser(t):o.subType&&(r=o.subType),Array.isArray(r)?r.forEach((e=>{i.push({type:`${n.SERVER_PUSH_MESSAGE}:${e}`,data:t})})):i.push({type:`${n.SERVER_PUSH_MESSAGE}:${r}`,data:t})})),i},[n.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const i=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=t}subscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.on(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.on(e,n,s)}}emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(o).includes(e)){const s=null===(n=o[e])||void 0===n?void 0:n.call(o,t);null==s||s.forEach((e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))}))}}unSubscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.off(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.off(e,n,s)}}subscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.off(e,t,s)}emitOuterEvent(e,t){var s;null===(s=this._outerEventEmitter)||void 0===s||s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function r(e,t,s,n){return new(s||(s=Promise))((function(o,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=e=>void 0===e,c=e=>"string"==typeof e,l=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},d=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===l(e),u=e=>null!==e&&"object"==typeof e,_=e=>d(e)||u(e),h=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},g=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s};function f(e=99999999){return Math.round(Math.random()*e)}const E=(e,t,s,n)=>{if(!_(e)||!_(t))return 0;let o=0;const i=Object.keys(t);let r;for(let c=0,l=i.length;c<l;c++)if(r=i[c],!(a(t[r])||s&&s.includes(r)))if(_(e[r])&&_(t[r]))o+=E(e[r],t[r],s,n);else{if(n&&n.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],o+=1)}return o};function p(e){let t,s,n=e;e.length%8!=0&&(n="0".repeat(8-e.length%8)+e);let o="";for(let e=0,{length:i}=n;e<i;e+=8)t=parseInt(n.slice(e,e+4),2),s=parseInt(n.slice(e+4,e+8),2),o+=base16Map.get(t)+base16Map.get(s);return o}const m={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 v=Object.freeze({__proto__:null,ENUM_PLATFORM:m,NOT_NEED_CRC_SERVCMD:S});const I="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),C=I&&"function"==typeof wx.createGamePortal,y="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),O="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),T="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,N="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,R=I&&"object"==typeof wx.miniapp,D="undefined"!=typeof uni,w=I||y||M||O||T||N||A,b="undefined"==typeof window&&!w&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,k="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),P="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),L="undefined"!=typeof uni?!w:"undefined"!=typeof window&&!w&&!k,U=y?qq:M?tt:O?swan:T?my:I?wx:N?uni:A?jd:{},G=L&&window&&window.navigator&&window.navigator.userAgent||"",F=/(micromessenger|webbrowser)/i.test(G),x=function(){let e="WEB";return F?e="WEB":y?e="QQ_MP":M?e="TT_MP":O?e="BAIDU_MP":T?e="ALI_MP":I?e=R?"DONUT_NATIVE_APP":"WX_MP":N?e="UNI_NATIVE_APP":b?e="NS_NATIVE_APP":k&&(e="RN_NATIVE_APP"),m[e]}(),B=/iPad/i.test(G),$=/iPhone/i.test(G)&&!B,V=/iPod/i.test(G),q=$||B||V,W=function(){const e=G.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Y=/Android/i.test(G),K=function(){const e=G.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(`${e[1]}.${e[2]}`):t||null}(),j=/Firefox/i.test(G),H=/Edge/i.test(G),z=!H&&/Chrome/i.test(G),Z=/MSIE/.test(G)||G.indexOf("Trident")>-1&&G.indexOf("rv:11.0")>-1,J=function(){const e=/MSIE\s(\d+)\.\d/.exec(G);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(G)&&/rv:11.0/.test(G)&&(t=11),t}(),X=/Safari/i.test(G)&&!z&&!Y&&!H,Q=/Windows/i.test(G),ee=/MAC OS X/i.test(G),te=L&&"undefined"!=typeof Worker&&!Z,se=Y||q,ne=L&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,oe=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!q||e||X)}();function ie(){let e="unknown";if(ee&&(e="mac"),Q&&(e="windows"),q&&(e="ios"),Y&&(e="android"),w)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const re=2800,ae=2801,ce=3e3,le="application/x-www-form-urlencoded;charset=UTF-8";function de(e){return r(this,arguments,void 0,(function*({method:e,url:t,data:s,timeout:n=ce}){return new Promise(w?(o,i)=>{U.request({url:t,data:s,method:e,timeout:n,header:{"content-type":le},success:e=>o(e.data),fail:()=>i(new Error(`{"message":"Network error","code":${re}}`))})}:(o,i)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),i(new Error(`{"message":"Request timeout","code":${ae}}`))}),n);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{o(r.responseText?JSON.parse(r.responseText):null)}catch(e){o(r.responseText)}else i(new Error(`{"message":"Network error","code":${re}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",le),r.send(s||null)})}))}function ue(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(g(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 _e(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const t=new Map;return e.forEach(((e,s)=>{t.set(_e(s),_e(e))})),t}if(e instanceof Set){const t=new Set;return e.forEach((e=>{t.add(_e(e))})),t}if(Array.isArray(e))return e.map((e=>_e(e)));const t=Object.getPrototypeOf(e),s=Object.create(t);return[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach((t=>{const n=Object.getOwnPropertyDescriptor(e,t);n&&(n.get||n.set?Object.defineProperty(s,t,n):s[t]=_e(e[t]))})),s}function he(){let e,t;return{promise:new Promise(((s,n)=>{e=s,t=n})),resolve:e,reject:t}}var ge=Object.freeze({__proto__:null,ANDROID_VERSION:K,IE_VERSION:J,IN_ALIPAY_MINI_APP:T,IN_BAIDU_MINI_APP:O,IN_BROWSER:L,IN_DONUT_NATIVE_APP:R,IN_JD_MINI_APP:A,IN_MINI_APP:w,IN_NS_NATIVE_APP:b,IN_QQ_MINI_APP:y,IN_RN_APP:k,IN_TT_MINI_APP:M,IN_UNI_APP:D,IN_UNI_NATIVE_APP:N,IN_WX_MINI_APP:I,IN_WX_MINI_GAME:C,IN_WX_MINI_PLUGIN:P,IOS_VERSION:W,IS_ANDROID:Y,IS_CHROME:z,IS_EDGE:H,IS_FIREFOX:j,IS_IE:Z,IS_IOS:q,IS_IPAD:B,IS_IPHONE:$,IS_IPOD:V,IS_MAC:ee,IS_SAFARI:X,IS_WECHAT:F,IS_WIN:Q,IS_WORKER_AVAILABLE:te,MINI_APP_NAMESPACE:U,USER_AGENT:G,base16EncodeBinaryString:p,deepCopyWithMethods:_e,deepMerge:E,generatePromise:he,getPlatformType:ie,getType:l,httpRequest:de,isArray:d,isArrayOrObject:_,isEmpty:ue,isFlutterWeb:ne,isH5:se,isIOSWebView:oe,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:u,isPlainObject:g,isString:c,isUndefined:a,isValidRequestKey:h,platform:x,randomInt:f,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t}});class fe{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t,s;try{null===(t=this._socket)||void 0===t||t.send(e)}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=s,this._socket.onclose=n,this._socket.onerror=o,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class Ee{connectSocket(e){return this._socket=wx.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null===(t=this._socket)||void 0===t||t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(o),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{})))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const pe="CONNECT",me="SEND",Se="DISCONNECT",ve="OPEN",Ie="MESSAGE",Ce="CLOSE",ye="ERROR",Me="SEND_FAIL";class Oe{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){const t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:pe,url:e})}send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:me,data:e})}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;if(this._worker){const e={[ve]:t,[Ie]:s,[Ce]:n,[ye]:o,[Me]:i};this._onSendFail=i,this._worker.onmessage=t=>{var s;const{type:n}=(null==t?void 0:t.data)||{};"function"==typeof e[n]&&(null===(s=e[n])||void 0===s||s.call(e,null==t?void 0:t.data))}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Se}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Te,Ae=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(w){if(T){return my.getStorageSync({key:e}).data}return U.getStorageSync(e)}return this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){const s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){w?T?my.setStorageSync({key:e,data:JSON.stringify(t)}):U.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"}(Te||(Te={}));class Ne{constructor(t){this._url="",this._readyState=Te.DISCONNECTED,this._url=t,this._id=f(),this._emitter=new e,I?this._socket=new Ee:this._canUseWebWorker()?this._socket=new Oe:this._socket=new fe,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Te.CONNECTED,Te.CONNECTING].includes(this._readyState)||(this._readyState=Te.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Te.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Te.CONNECTED,Te.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===Te.CONNECTED}disconnect(){this._readyState=Te.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Te.CONNECTING&&(this._readyState=Te.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){const e=Ae.get("cloudConfig")||{};return(a(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&te}}const Re="CHINA",De="SINGAPORE",we="KOREA",be="GERMANY",ke="IND",Pe="JPN",Le="USA",Ue="INDONESIA",Ge={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"}}},Fe={[De]:[[2e7,3e7],[172e7,173e7]],[we]:[[3e7,4e7],[173e7,174e7]],[be]:[[4e7,5e7],[174e7,175e7]],[ke]:[[5e7,6e7],[175e7,176e7]],[Pe]:[[6e7,7e7],[176e7,177e7]],[Le]:[[7e7,8e7],[177e7,178e7]],[Ue]:[[8e7,9e7],[178e7,179e7]]};function xe(e){for(const t of Object.keys(Fe))for(const[s,n]of Fe[t])if(e>=s&&e<n)return t;return Re}var Be,$e="1.2.1";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(Be||(Be={}));let Ve=Be.INITIAL;function qe(){const e=Math.random();return 0===e?qe():e}function We(e,t){const{isBinary:s=!1}=t||{},n=Ae.get("instance"),{sdkAppId:o,instanceId:i}=n,r=qe(),a=ie(),c=function(){const e=ie();let t=-1;"ios"===e?t=W||-1:"android"===e&&(t=K||-1);return t}(),l=(d={sdkappid:o,instanceid:i,random:r,platform:x,host:a,version:c,sdkversion:$e},Object.keys(d).map((e=>`${e}=${d[e]}`)).join("&"));var d;return s?`${e}/binfo?${l}&compress=gzip`:`${e}/info?${l}`}var Ye=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){const s=Date.now(),n=s-e;this._timeOffsetWithServer=t+n-s}};const Ke=16;var je=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){const{id:t}=e;this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){const{id:t,callback:s,context:n,isOnce:o=!1,intervalMs:i=Ke}=e,r=Math.max(i,Ke);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:i,callback:s,context:n,isOnce:o}}addTask(e){const t=this._createTask(e);this._addTaskToScheduler(t)}addOnceTask(e){const t=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(t)}removeTask(e){const t=this._tasks.findIndex((t=>t.id===e));t>-1&&(this._tasks.splice(t,1),this._taskMap.delete(e),this._scheduleNextTask())}updateTaskInterval(e,t){const s=this._taskMap.get(e);s&&(s.intervalMs=t,s.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort(((e,t)=>e.nextExecuteTime-t.nextExecuteTime))}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);const e=this._tasks[0];if(e){const t=Math.max(0,e.nextExecuteTime-Date.now());this._timer=setTimeout((()=>this._execute()),t)}}_execute(){const e=Date.now();for(;this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){const t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function He(e){const t=[];for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n>=55296&&n<=56319){const o=e.charCodeAt(++s)-56320+(n-55296<<10)+65536;t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}else n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):t.push(224|n>>12,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function ze(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&h(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=ze(e[s]));return t}function Ze(e,t){if(S.includes(e))return 0;const s=He(JSON.stringify(t));let n=4294967295;const{length:o}=s;for(let e=0;e<o;e++){n^=s[e];for(let e=0;e<8;e++)1&~n?n>>>=1:n=n>>>1^3988292384}return(4294967295^n)>>>0}function Je(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:p(""),cappid:t.cappid||0,tjgID:"",seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}}function Xe(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:p(""),cappid:t.cappid||0,seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}}let Qe=f();function et(){return Qe=Qe<2415919103?Qe+1:f(),Qe}var st,nt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:p(""),cappid:t.cappid||0,seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}},generateProtocolData:Je,generateSSOLogProtocolData:Xe,generateSequence:et,taskScheduler:je,timeManager:Ye});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(st||(st={}));const ot={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 it{constructor(e){this.level=st.info,this._canSendLog=!0,this._logCreatedAt=Ye.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=void 0;const{method:t,eventType:s=0}=e||{};this.eventType=s,this.method=t}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Ye.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=Ye.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=Ye.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=Ye.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=Ae.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=st.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys(ot).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const s=t;ot[s]&&(e[ot[s]]=this[s])})),e}}var rt;function at(){const e=Ae.get("login")||{},t=Ae.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.2.1",tiny_id:Number(e.tinyID),user_id:e.userId,platform:x,instance_id:t.instanceId,trace_id:(new Date).getTime()}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(rt||(rt={}));var ct=rt;const lt=20,dt=6e4,ut=[4,5,6],_t=[],ht=[],gt="report-logger";var ft=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=lt,this._maxThreshold=100,this._waitingTime=dt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,i.subscribeInnerEvent(ct.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),je.addTask({id:gt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=lt,evt_rpt_waiting:s=dt,evt_rpt_level:n=ut,evt_rpt_sdkappid_bl:o=_t,evt_rpt_tinyid_wl:i=ht}=e||{};this._sdkAppIdBlackList=o,this._waitingTime=s,this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=i}createSSOLogData(e){const t=new it(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 r(this,void 0,void 0,(function*(){if(0===this._logQueue.length)return;const e=this._logQueue.slice(),t=this._filterLogs(e);if(this._logQueue=[],0===t.length)return void(this._lastReportAt=Date.now());const s={Header:at(),Event:t};yield function(e){const t="imopenstat.tim_web_report_v2",s=Xe({servcmd:t,data:e}),n=`${s.head.seq}${t}`;Lt.sendPacket(s,{requestId:n})}(s),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(I){const s=null===(t=null===(e=wx.getAccountInfoSync)||void 0===e?void 0:e.call(wx))||void 0===t?void 0:t.miniProgram;if(s){const{appId:e,envVersion:t}=s;Ae.set("instance",{appId:e,envVersion:t})}}else L&&Ae.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=Ae.get("login")||{},{sdkAppId:s}=Ae.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter((e=>this._reportLevel.includes(e.level)))}reset(){console.log("SSO_LOG_MODULE.reset"),je.removeTask(gt),i.unSubscribeInnerEvent(ct.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this._uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=lt,this._maxThreshold=100,this._waitingTime=dt,this._logQueue=[]}};const Et=15e3,pt="Channel",mt="channel_schedule_task",St="channel_reconnect_task",vt="connected",It="connecting",Ct="disconnected",yt=500,Mt="network_status_change",Ot="activity_status_change",Tt="send_fail",At="reconnect_failed",Nt="socket_error",Rt="socket_close";function Dt(e){return Dt="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},Dt(e)}function wt(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 bt,kt={exports:{}};var Pt=(bt||(bt=1,kt.exports=function e(t,s,n){function o(r,a){if(!s[r]){if(!t[r]){if(!a&&wt)return wt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=s[r]={exports:{}};t[r][0].call(l.exports,(function(e){return o(t[r][1][e]||e)}),l,l.exports,e,t,s,n)}return s[r].exports}for(var i=wt,r=0;r<n.length;r++)o(n[r]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var o=n.shift();if(o){if("object"!=Dt(o))throw new TypeError(o+"must be non-object");for(var i in o)t=o,s=i,Object.prototype.hasOwnProperty.call(t,s)&&(e[i]=o[i])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,s,n,o){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),o);else for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){var t,s,n,o,i,r;for(t=n=0,s=e.length;t<s;t++)n+=e[t].length;for(r=new Uint8Array(n),t=o=0,s=e.length;t<s;t++)i=e[t],r.set(i,o),o+=i.length;return r}},i={arraySet:function(e,t,s,n,o){for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,i))},s.setTyped(n)},{}],2:[function(e,t,s){var n=e("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var r=new n.Buf8(256),a=0;a<256;a++)r[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function c(e,t){if(t<65534&&(e.subarray&&i||!e.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var s="",r=0;r<t;r++)s+=String.fromCharCode(e[r]);return s}r[254]=r[254]=1,s.string2buf=function(e){var t,s,o,i,r,a=e.length,c=0;for(i=0;i<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new n.Buf8(c),i=r=0;r<c;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),s<128?t[r++]=s:(s<2048?t[r++]=192|s>>>6:(s<65536?t[r++]=224|s>>>12:(t[r++]=240|s>>>18,t[r++]=128|s>>>12&63),t[r++]=128|s>>>6&63),t[r++]=128|63&s);return t},s.buf2binstring=function(e){return c(e,e.length)},s.binstring2buf=function(e){for(var t=new n.Buf8(e.length),s=0,o=t.length;s<o;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,n,o,i,a=t||e.length,l=new Array(2*a);for(s=n=0;s<a;)if((o=e[s++])<128)l[n++]=o;else if(4<(i=r[o]))l[n++]=65533,s+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&s<a;)o=o<<6|63&e[s++],i--;1<i?l[n++]=65533:o<65536?l[n++]=o:(o-=65536,l[n++]=55296|o>>10&1023,l[n++]=56320|1023&o)}return c(l,n)},s.utf8border=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;0<=s&&128==(192&e[s]);)s--;return s<0||0===s?t:s+r[e[s]]>t?s:t}},{"./common":1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var o=65535&e,i=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;i=i+(o=o+t[n++]|0)|0,--r;);o%=65521,i%=65521}return o|i<<16}},{}],4:[function(e,t,s){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,s){var n=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();t.exports=function(e,t,s,o){var i=n,r=o+s;e^=-1;for(var a=o;a<r;a++)e=e>>>8^i[255&(e^t[a])];return~e}},{}],6:[function(e,t,s){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,o,i,r,a,c,l,d,u,_,h,g,f,E,p,m,S,v,I,C,y,M,O,T;s=e.state,n=e.next_in,O=e.input,o=n+(e.avail_in-5),i=e.next_out,T=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,l=s.wsize,d=s.whave,u=s.wnext,_=s.window,h=s.hold,g=s.bits,f=s.lencode,E=s.distcode,p=(1<<s.lenbits)-1,m=(1<<s.distbits)-1;e:do{g<15&&(h+=O[n++]<<g,g+=8,h+=O[n++]<<g,g+=8),S=f[h&p];t:for(;;){if(h>>>=v=S>>>24,g-=v,0==(v=S>>>16&255))T[i++]=65535&S;else{if(!(16&v)){if(!(64&v)){S=f[(65535&S)+(h&(1<<v)-1)];continue t}if(32&v){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}I=65535&S,(v&=15)&&(g<v&&(h+=O[n++]<<g,g+=8),I+=h&(1<<v)-1,h>>>=v,g-=v),g<15&&(h+=O[n++]<<g,g+=8,h+=O[n++]<<g,g+=8),S=E[h&m];s:for(;;){if(h>>>=v=S>>>24,g-=v,!(16&(v=S>>>16&255))){if(!(64&v)){S=E[(65535&S)+(h&(1<<v)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(C=65535&S,g<(v&=15)&&(h+=O[n++]<<g,(g+=8)<v&&(h+=O[n++]<<g,g+=8)),c<(C+=h&(1<<v)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(h>>>=v,g-=v,(v=i-r)<C){if(d<(v=C-v)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(M=_,(y=0)===u){if(y+=l-v,v<I){for(I-=v;T[i++]=_[y++],--v;);y=i-C,M=T}}else if(u<v){if(y+=l+u-v,(v-=u)<I){for(I-=v;T[i++]=_[y++],--v;);if(y=0,u<I){for(I-=v=u;T[i++]=_[y++],--v;);y=i-C,M=T}}}else if(y+=u-v,v<I){for(I-=v;T[i++]=_[y++],--v;);y=i-C,M=T}for(;2<I;)T[i++]=M[y++],T[i++]=M[y++],T[i++]=M[y++],I-=3;I&&(T[i++]=M[y++],1<I&&(T[i++]=M[y++]))}else{for(y=i-C;T[i++]=T[y++],T[i++]=T[y++],T[i++]=T[y++],2<(I-=3););I&&(T[i++]=T[y++],1<I&&(T[i++]=T[y++]))}break}}break}}while(n<o&&i<a);n-=I=g>>3,h&=(1<<(g-=I<<3))-1,e.next_in=n,e.next_out=i,e.avail_in=n<o?o-n+5:5-(n-o),e.avail_out=i<a?a-i+257:257-(i-a),s.hold=h,s.bits=g}},{}],8:[function(e,t,s){var n=e("../utils/common"),o=e("./adler32"),i=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,l=2,d=0,u=-2,_=1,h=852,g=592;function f(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function E(){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 p(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=_,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(h),t.distcode=t.distdyn=new n.Buf32(g),t.sane=1,t.back=-1,d):u}function m(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,p(e)):u}function S(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)?u:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,m(e))):u}function v(e,t){var s,n;return e?(n=new E,(e.state=n).window=null,(s=S(e,t))!==d&&(e.state=null),s):u}var I,C,y=!0;function M(e){if(y){var t;for(I=new n.Buf32(512),C=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(c,e.lens,0,288,I,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(l,e.lens,0,32,C,0,e.work,{bits:5}),y=!1}e.lencode=I,e.lenbits=9,e.distcode=C,e.distbits=5}function O(e,t,s,o){var i,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new n.Buf8(r.wsize)),o>=r.wsize?(n.arraySet(r.window,t,s-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(o<(i=r.wsize-r.wnext)&&(i=o),n.arraySet(r.window,t,s-o,i,r.wnext),(o-=i)?(n.arraySet(r.window,t,s-o,o,0),r.wnext=o,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=i))),0}s.inflateReset=m,s.inflateReset2=S,s.inflateResetKeep=p,s.inflateInit=function(e){return v(e,15)},s.inflateInit2=v,s.inflate=function(e,t){var s,h,g,E,p,m,S,v,I,C,y,T,A,N,R,D,w,b,k,P,L,U,G,F,x=0,B=new n.Buf8(4),$=[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 u;12===(s=e.state).mode&&(s.mode=13),p=e.next_out,g=e.output,S=e.avail_out,E=e.next_in,h=e.input,m=e.avail_in,v=s.hold,I=s.bits,C=m,y=S,U=d;e:for(;;)switch(s.mode){case _:if(0===s.wrap){s.mode=13;break}for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(2&s.wrap&&35615===v){B[s.check=0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0),I=v=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&v)){e.msg="unknown compression method",s.mode=30;break}if(I-=4,L=8+(15&(v>>>=4)),0===s.wbits)s.wbits=L;else if(L>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<L,e.adler=s.check=1,s.mode=512&v?10:12,I=v=0;break;case 2:for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(s.flags=v,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=v>>8&1),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0,s.mode=3;case 3:for(;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.head&&(s.head.time=v),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,B[2]=v>>>16&255,B[3]=v>>>24&255,s.check=i(s.check,B,4,0)),I=v=0,s.mode=4;case 4:for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.head&&(s.head.xflags=255&v,s.head.os=v>>8),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0,s.mode=5;case 5:if(1024&s.flags){for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.length=v,s.head&&(s.head.extra_len=v),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(m<(T=s.length)&&(T=m),T&&(s.head&&(L=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),n.arraySet(s.head.extra,h,E,T,L)),512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,s.length-=T),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===m)break e;for(T=0;L=h[E+T++],s.head&&L&&s.length<65536&&(s.head.name+=String.fromCharCode(L)),L&&T<m;);if(512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,L)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===m)break e;for(T=0;L=h[E+T++],s.head&&L&&s.length<65536&&(s.head.comment+=String.fromCharCode(L)),L&&T<m;);if(512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,L)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(v!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}I=v=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(;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}e.adler=s.check=f(v),I=v=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=p,e.avail_out=S,e.next_in=E,e.avail_in=m,s.hold=v,s.bits=I,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){v>>>=7&I,I-=7&I,s.mode=27;break}for(;I<3;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}switch(s.last=1&v,I-=1,3&(v>>>=1)){case 0:s.mode=14;break;case 1:if(M(s),s.mode=20,6!==t)break;v>>>=2,I-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}v>>>=2,I-=2;break;case 14:for(v>>>=7&I,I-=7&I;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if((65535&v)!=(v>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&v,I=v=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(T=s.length){if(m<T&&(T=m),S<T&&(T=S),0===T)break e;n.arraySet(g,h,E,T,p),m-=T,E+=T,S-=T,p+=T,s.length-=T;break}s.mode=12;break;case 17:for(;I<14;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(s.nlen=257+(31&v),v>>>=5,I-=5,s.ndist=1+(31&v),v>>>=5,I-=5,s.ncode=4+(15&v),v>>>=4,I-=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(;I<3;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.lens[$[s.have++]]=7&v,v>>>=3,I-=3}for(;s.have<19;)s.lens[$[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,G={bits:s.lenbits},U=a(0,s.lens,0,19,s.lencode,0,s.work,G),s.lenbits=G.bits,U){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;D=(x=s.lencode[v&(1<<s.lenbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(w<16)v>>>=R,I-=R,s.lens[s.have++]=w;else{if(16===w){for(F=R+2;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(v>>>=R,I-=R,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}L=s.lens[s.have-1],T=3+(3&v),v>>>=2,I-=2}else if(17===w){for(F=R+3;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}I-=R,L=0,T=3+(7&(v>>>=R)),v>>>=3,I-=3}else{for(F=R+7;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}I-=R,L=0,T=11+(127&(v>>>=R)),v>>>=7,I-=7}if(s.have+T>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;T--;)s.lens[s.have++]=L}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,G={bits:s.lenbits},U=a(c,s.lens,0,s.nlen,s.lencode,0,s.work,G),s.lenbits=G.bits,U){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,G={bits:s.distbits},U=a(l,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,G),s.distbits=G.bits,U){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(6<=m&&258<=S){e.next_out=p,e.avail_out=S,e.next_in=E,e.avail_in=m,s.hold=v,s.bits=I,r(e,y),p=e.next_out,g=e.output,S=e.avail_out,E=e.next_in,h=e.input,m=e.avail_in,v=s.hold,I=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;D=(x=s.lencode[v&(1<<s.lenbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(D&&!(240&D)){for(b=R,k=D,P=w;D=(x=s.lencode[P+((v&(1<<b+k)-1)>>b)])>>>16&255,w=65535&x,!(b+(R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}v>>>=b,I-=b,s.back+=b}if(v>>>=R,I-=R,s.back+=R,s.length=w,0===D){s.mode=26;break}if(32&D){s.back=-1,s.mode=12;break}if(64&D){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&D,s.mode=22;case 22:if(s.extra){for(F=s.extra;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.length+=v&(1<<s.extra)-1,v>>>=s.extra,I-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;D=(x=s.distcode[v&(1<<s.distbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(!(240&D)){for(b=R,k=D,P=w;D=(x=s.distcode[P+((v&(1<<b+k)-1)>>b)])>>>16&255,w=65535&x,!(b+(R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}v>>>=b,I-=b,s.back+=b}if(v>>>=R,I-=R,s.back+=R,64&D){e.msg="invalid distance code",s.mode=30;break}s.offset=w,s.extra=15&D,s.mode=24;case 24:if(s.extra){for(F=s.extra;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.offset+=v&(1<<s.extra)-1,v>>>=s.extra,I-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===S)break e;if(T=y-S,s.offset>T){if((T=s.offset-T)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}T>s.wnext?(T-=s.wnext,A=s.wsize-T):A=s.wnext-T,T>s.length&&(T=s.length),N=s.window}else N=g,A=p-s.offset,T=s.length;for(S<T&&(T=S),S-=T,s.length-=T;g[p++]=N[A++],--T;);0===s.length&&(s.mode=21);break;case 26:if(0===S)break e;g[p++]=s.length,S--,s.mode=21;break;case 27:if(s.wrap){for(;I<32;){if(0===m)break e;m--,v|=h[E++]<<I,I+=8}if(y-=S,e.total_out+=y,s.total+=y,y&&(e.adler=s.check=s.flags?i(s.check,g,y,p-y):o(s.check,g,y,p-y)),y=S,(s.flags?v:f(v))!==s.check){e.msg="incorrect data check",s.mode=30;break}I=v=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(v!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}I=v=0}s.mode=29;case 29:U=1;break e;case 30:U=-3;break e;case 31:return-4;default:return u}return e.next_out=p,e.avail_out=S,e.next_in=E,e.avail_in=m,s.hold=v,s.bits=I,(s.wsize||y!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&O(e,e.output,e.next_out,y-e.avail_out)?(s.mode=31,-4):(C-=e.avail_in,y-=e.avail_out,e.total_in+=C,e.total_out+=y,s.total+=y,s.wrap&&y&&(e.adler=s.check=s.flags?i(s.check,g,y,e.next_out-y):o(s.check,g,y,e.next_out-y)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),(0===C&&0===y||4===t)&&U===d&&(U=-5),U)},s.inflateEnd=function(e){if(!e||!e.state)return u;var t=e.state;return t.window&&(t.window=null),e.state=null,d},s.inflateGetHeader=function(e,t){var s;return e&&e.state&&2&(s=e.state).wrap?((s.head=t).done=!1,d):u},s.inflateSetDictionary=function(e,t){var s,n=t.length;return e&&e.state?0!==(s=e.state).wrap&&11!==s.mode?u:11===s.mode&&o(1,t,n,0)!==s.check?-3:O(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,d):u},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var n=e("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],r=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,s,c,l,d,u,_){var h,g,f,E,p,m,S,v,I,C=_.bits,y=0,M=0,O=0,T=0,A=0,N=0,R=0,D=0,w=0,b=0,k=null,P=0,L=new n.Buf16(16),U=new n.Buf16(16),G=null,F=0;for(y=0;y<=15;y++)L[y]=0;for(M=0;M<c;M++)L[t[s+M]]++;for(A=C,T=15;1<=T&&0===L[T];T--);if(T<A&&(A=T),0===T)return l[d++]=20971520,l[d++]=20971520,_.bits=1,0;for(O=1;O<T&&0===L[O];O++);for(A<O&&(A=O),y=D=1;y<=15;y++)if(D<<=1,(D-=L[y])<0)return-1;if(0<D&&(0===e||1!==T))return-1;for(U[1]=0,y=1;y<15;y++)U[y+1]=U[y]+L[y];for(M=0;M<c;M++)0!==t[s+M]&&(u[U[t[s+M]]++]=M);if(0===e?(k=G=u,m=19):1===e?(k=o,P-=257,G=i,F-=257,m=256):(k=r,G=a,m=-1),y=O,p=d,R=M=b=0,f=-1,E=(w=1<<(N=A))-1,1===e&&852<w||2===e&&592<w)return 1;for(;;){for(S=y-R,u[M]<m?(v=0,I=u[M]):u[M]>m?(v=G[F+u[M]],I=k[P+u[M]]):(v=96,I=0),h=1<<y-R,O=g=1<<N;l[p+(b>>R)+(g-=h)]=S<<24|v<<16|I,0!==g;);for(h=1<<y-1;b&h;)h>>=1;if(0!==h?(b&=h-1,b+=h):b=0,M++,0==--L[y]){if(y===T)break;y=t[s+u[M]]}if(A<y&&(b&E)!==f){for(0===R&&(R=A),p+=O,D=1<<(N=y-R);N+R<T&&!((D-=L[N+R])<=0);)N++,D<<=1;if(w+=1<<N,1===e&&852<w||2===e&&592<w)return 1;l[f=b&E]=A<<24|N<<16|p-d}}return 0!==b&&(l[p+b]=y-R<<24|64<<16),_.bits=A,0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,s){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,s){var n=e("./zlib/inflate"),o=e("./utils/common"),i=e("./utils/strings"),r=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),l=e("./zlib/gzheader"),d=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var s=n.inflateInit2(this.strm,t.windowBits);if(s!==r.Z_OK)throw new Error(a[s]);if(this.header=new l,n.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=i.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=n.inflateSetDictionary(this.strm,t.dictionary))!==r.Z_OK))throw new Error(a[s])}function _(e,t){var s=new u(t);if(s.push(e,!0),s.err)throw s.msg||a[s.err];return s.result}u.prototype.push=function(e,t){var s,a,c,l,u,_=this.strm,h=this.options.chunkSize,g=this.options.dictionary,f=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof e?_.input=i.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?_.input=new Uint8Array(e):_.input=e,_.next_in=0,_.avail_in=_.input.length;do{if(0===_.avail_out&&(_.output=new o.Buf8(h),_.next_out=0,_.avail_out=h),(s=n.inflate(_,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&g&&(s=n.inflateSetDictionary(this.strm,g)),s===r.Z_BUF_ERROR&&!0===f&&(s=r.Z_OK,f=!1),s!==r.Z_STREAM_END&&s!==r.Z_OK)return this.onEnd(s),!(this.ended=!0);_.next_out&&(0!==_.avail_out&&s!==r.Z_STREAM_END&&(0!==_.avail_in||a!==r.Z_FINISH&&a!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(c=i.utf8border(_.output,_.next_out),l=_.next_out-c,u=i.buf2string(_.output,c),_.next_out=l,_.avail_out=h-l,l&&o.arraySet(_.output,_.output,c,l,0),this.onData(u)):this.onData(o.shrinkBuf(_.output,_.next_out)))),0===_.avail_in&&0===_.avail_out&&(f=!0)}while((0<_.avail_in||0===_.avail_out)&&s!==r.Z_STREAM_END);return s===r.Z_STREAM_END&&(a=r.Z_FINISH),a===r.Z_FINISH?(s=n.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===r.Z_OK):a!==r.Z_SYNC_FLUSH||(this.onEnd(r.Z_OK),!(_.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===r.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=u,s.inflate=_,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,_(e,t)},s.ungzip=_},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),kt.exports);var Lt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=yt,this._currentConnectState=vt,this._beforeSendInterceptors=[]}init(){je.addTask({id:mt,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){const t=Ae.get("instance"),{sdkAppId:s,testEnv:n}=t,o=xe(s);return We(n?Ge.TEST[o].DEFAULT:Ge.PRODUCTION[o].INITIAL.replace("*",`${s}`),{isBinary:e})}(this._isBinarySupported),i.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),i.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s;const{requestId:n,timeout:o=Et,canResend:i=!0}=t||{};if(ue(e))return console.warn(`${pt}.sendPacket: packet is empty `,e),null;this._executeBeforeSendInterceptors(e);const r=JSON.stringify(e);let a=null;if(n){const{resolve:e,reject:t,promise:s}=he();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:o,canResend:i})}const c=this._isBinarySupported?He(r).buffer:r;return null===(s=this._socketAdapter)||void 0===s||s.send(c),a}connect(){var e;this._socketAdapter=new Ne(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();const t=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId(),s=`${pt}.connect isWorkerEnabled: false socketID:${t} url:${this._url}`;this._ssoLog({method:"connect",message:s}),console.log(s)}disconnect(){var e,t;const s=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId(),n=`${pt}.disconnect socketID:${s}`;this._ssoLog({method:"disconnect",message:n}),console.log(n),this._removeEventListeners(),null===(t=this._socketAdapter)||void 0===t||t.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(`${pt}.dispose`),je.removeTask(mt),je.removeTask(St),i.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),i.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=yt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(const t of this._beforeSendInterceptors){const{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){const e=this._currentConnectState===It&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return r(this,void 0,void 0,(function*(){const e=`${pt} reconnect isReconnecting: ${this._isReconnecting} currentConnectState: ${this._currentConnectState}`;if(this._ssoLog({method:"reconnect",message:e}),console.log(e),!this._shouldSkipReconnect()){this._url=function(e){const t=Ae.get("instance"),{sdkAppId:s,testEnv:n}=t,o=xe(s);if(n)return We(Ge.TEST[o].DEFAULT,{isBinary:e});const i=Ge.PRODUCTION[o],r=L&&i.ANYCAST;return We({[Be.INITIAL]:()=>(Ve=Be.DEFAULT,i.DEFAULT),[Be.DEFAULT]:()=>(Ve=Be.BACKUP,i.BACKUP),[Be.BACKUP]:()=>(Ve=r?Be.ANYCAST:Be.DEFAULT,r?i.ANYCAST:i.DEFAULT),[Be.ANYCAST]:()=>(Ve=Be.DEFAULT,i.ANYCAST="",i.DEFAULT)}[Ve](),{isBinary:e})}(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:Ct,reason:At}),console.warn(`${pt} reconnect failed: `,e)}}}))}_addEventListeners(){var e,t,s,n,o;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===(s=this._socketAdapter)||void 0===s||s.on("close",this._onClose,this),null===(n=this._socketAdapter)||void 0===n||n.on("error",this._onError,this),null===(o=this._socketAdapter)||void 0===o||o.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e,t,s,n,o;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===(s=this._socketAdapter)||void 0===s||s.off("close",this._onClose,this),null===(n=this._socketAdapter)||void 0===n||n.off("error",this._onError,this),null===(o=this._socketAdapter)||void 0===o||o.off("sendFail",this._onSendFail,this)}_onClose(e){const{socketId:t,event:s}=e||{},n=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,o=`${pt} onClose closeSocketID: ${t} currentSocketID: ${this._connectionId} connectionDuration: ${n} code:${null==s?void 0:s.code} reason:${null==s?void 0:s.reason}`;this._ssoLog({method:"onClose",message:o}),console.warn(o),t===this._connectionId&&this._handleConnectStateChange({state:Ct,reason:Rt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){const{socketId:t,error:s}=e||{},n=`${pt} onError sourceSocketID: ${t} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${JSON.stringify(s)}`;this._ssoLog({method:"onError",message:n}),console.warn(n),t===this._connectionId&&this._handleConnectStateChange({state:Ct,reason:Nt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){const{socketId:t,error:s}=e||{},n=`${pt} onSendFail sendFailSocketId: ${t} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${s}`;this._ssoLog({method:"onSendFail",message:n}),console.warn(n),t===this._connectionId&&this._handleConnectStateChange({state:Ct,reason:Tt}),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(e){let t,s;this._updateHeartbeatTime();try{t=this._isBinarySupported?this._isCompressedData(e.data)?(e=>{const t=new Uint8Array(e).slice(4);let s;try{s=Pt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s})(e.data):function(e){const t=new Uint8Array(e);let s="",n=0;const{length:o}=t;for(;n<o;){let e=t[n],i=0,r=0;if(e<=127?(i=0,r=255&e):e<=223?(i=1,r=31&e):e<=239?(i=2,r=15&e):e<=244&&(i=3,r=7&e),o-n-i>0)for(let s=0;s<i;s+=1)e=t[n+s+1],r=r<<6|63&e;else r=65533,i=o-n;s+=String.fromCodePoint(r),n+=i+1}return s}(e.data):e.data,s=JSON.parse(t)}catch(t){const s=e.data;return this._ssoLog({method:"jsonParseError",message:s}),void console.error(t)}if(!s||!s.head)return;const{seq:n,servcmd:o}=s.head,i=`${n}${o}`;this._pendingRequests.has(i)?this._handleRequestResponse(s):this._handlePushMessage(s)}_handleRequestResponse(e){const{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:o,ErrorCode:r=n,ErrorInfo:a=o}=(null==e?void 0:e.body)||{},c=`${t}${s}`,{resolve:l,reject:d,timestamp:u,headSeq:_}=this._pendingRequests.get(c);if(this._pendingRequests.delete(c),r&&0!==r)return i.emitInnerEvent("error",{errorCode:r,errorInfo:a}),void d({errorCode:r,errorInfo:a});l(e.body)}_handlePushMessage(e){const{servcmd:t}=e.head,{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),i.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;console.log(`${pt}._checkPendingRequestsAndResend reConnectFlag:${this._isReconnecting} promiseMap.size:${this._pendingRequests.size}`),null===(e=this._pendingRequests)||void 0===e||e.forEach(((e,t)=>{var s;const{uplinkData:n,canResend:o,resolve:i,reject:r,timeout:a}=e;if(o){this._pendingRequests.set(t,{resolve:i,reject:r,timestamp:Date.now(),uplinkData:n,timeout:a,canResend:o});const e=this._isBinarySupported?He(n).buffer:n;null===(s=this._socketAdapter)||void 0===s||s.send(e)}else this._pendingRequests.delete(t)}))}_onConnect(e){const{socketId:t,event:s={}}=e||{};this._connectionId=t,this._connectionEstablishedTime=Date.now();const n=Date.now()-this._connectionStartTime,o=`${pt} onConnect cost:${n} ms. socketID:${t} res:${JSON.stringify(s)}`;if(this._ssoLog({method:"onConnect",message:o}),console.log(o),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){const e=`${pt} reconnect success`;this._ssoLog({method:"reconnectSuccess",message:e}),console.log(e),i.emitInnerEvent(ct.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:vt})}_sendAck(e){const t=Je({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(t)}_executeScheduledTaskIfReady(){return r(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 r(this,void 0,void 0,(function*(){var e;const t=Je({servcmd:"heartbeat.alive",data:{}});try{const e=`${t.head.seq}${t.head.servcmd}`;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){const s=null===(e=Ae.get("netWorkMonitor"))||void 0===e?void 0:e.isNetWorkOnline,n=`${pt} sendHeartbeat failed. isNetWorkOnline:${s} error: ${t}`;this._ssoLog({method:"sendHeartbeatError",message:n}),console.debug(n),this._handleConnectStateChange({state:Ct,reason:Tt})}}))}_sendHeartbeatIfReady(){return r(this,void 0,void 0,(function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)}))}_updateHeartbeatTime(){this._nextHeartbeatAt=N?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){const t=`${pt} networkStatusChange ${JSON.stringify(e)}`;this._ssoLog({method:"networkStatusChange",message:t}),console.warn(t);const{isNetworkOnline:s,networkType:n}=e;s&&"none"!==n?this._handleConnectStateChange({state:vt,reason:Mt}):this._handleConnectStateChange({state:Ct,reason:Mt})}isPrivateNetWork(){const e=Ae.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){const{state:t,reason:s}=e;if(this._currentConnectState!==t){const e=`${pt}._handleConnectStateChange from ${this._currentConnectState} to ${t} reason: ${s}`;this._ssoLog({method:"handleConnectStateChange",message:e}),console.log(e),this._currentConnectState=t,i.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:t}}),t===Ct&&i.emitInnerEvent(ct.SOCKET_DISCONNECTED),t!==Ct&&t!==vt||(this._resetReconnectDelay(),je.addTask({id:St,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}}_handleActivityStatusChange(e){var t,s;const n=null===(s=null===(t=this._socketAdapter)||void 0===t?void 0:t._ws)||void 0===s?void 0:s.readyState,o=`${pt} activityStatusChange ${JSON.stringify(e)} readyState: ${n}`;this._ssoLog({method:"activityStatusChange",message:o}),console.warn(o),3===n&&this._handleConnectStateChange({state:Ct,reason:Ot})}_resetReconnectDelay(){var e;je.removeTask(St);const t=null===(e=Ae.get("activityMonitor"))||void 0===e?void 0:e.isActive;this._intendedDelay=t?yt:1e3}_scheduleReconnectWithBackoff(){var e;const t=null===(e=Ae.get("activityMonitor"))||void 0===e?void 0:e.isActive;this._intendedDelay=t?Math.min(5e3,Math.max(yt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay));const s=(new Date).toTimeString().slice(0,8),n=`${pt}.scheduleReconnectWithBackoff timeStr: ${s} intendedDelay: ${this._intendedDelay}`;this._ssoLog({method:"scheduleReconnectWithBackoff",message:n}),console.log(n),this.reconnect(),je.updateTaskInterval(St,this._intendedDelay)}_ssoLog(e){const{method:t,message:s}=e;ft.createSSOLogData({method:t}).setLogInfo({message:s}).end()}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(e){r(this,void 0,void 0,(function*(){const t=e.split("/")[2];if(!t.startsWith("ws"))return;const s=`https://${t}/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield de({method:"GET",url:s,data:{}})}catch(e){console.warn("diagnoseBySSO failed. error:",e)}}))}(this._url),function(e){r(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 de({method:"GET",url:t,data:{}})}catch(e){console.warn("diagnoseByCDN failed. error:",e)}}))}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(const[e,t]of this._pendingRequests.entries()){const{reject:s,timestamp:n,timeout:o}=t;Date.now()-n>=o&&(this._pendingRequests.delete(e),Date.now()-this._lastDiagnoseAt>=3e4&&this._diagnose(),s({errorCode:ae,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;if(null===(e=Ae.get("instance"))||void 0===e?void 0:e.devMode)return void(this._isBinarySupported=!1);const t=ie();(T||I&&"windows"===t||N)&&(this._isBinarySupported=!1)}_isCompressedData(e){const t=new Uint8Array(e);return 67===t[0]&&79===t[1]&&77===t[2]&&80===t[3]}};const Ut={init:function(e){Ae.set("instance",e),Lt.init()},destroy:function(){Lt.dispose(),Ae.clear(),je.dispose()},notificationCenter:i,channel:Lt,store:Ae,ssoLog:ft,utils:ge,common:nt,constants:v};var Gt;!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"}(Gt||(Gt={}));var Ft,xt=Gt;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated"}(Ft||(Ft={}));var Bt,$t=Ft;!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"}(Bt||(Bt={}));var Vt=Bt;const qt=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),Wt={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"};var Yt;!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(Yt||(Yt={}));const Kt={modify:$t.MESSAGE_MODIFIED,delete:$t.MESSAGE_DELETED,revoke:$t.MESSAGE_REVOKED},jt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Wt),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:Yt}),Ht={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},zt=Object.assign({},Ht),Zt=Object.assign(Object.assign(Object.assign(Object.assign({},{CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"}),{CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3}),{CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),Jt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both"}),{SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both"}),{SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd"}),{SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),Xt={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},Qt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"}),{GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom"}),{GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11}),{JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval"}),{INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess"}),{GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers"}),{GROUP_ID_PREFIX:Xt}),es=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},qt),jt),zt),Zt),Jt),Qt),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),ts={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},ss={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message"},ns={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event"},os={[ss.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:ns.USER_STATUS_UPDATE},{stepId:ns.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.CONVERSATION_RECOVER},{stepId:ns.HISTORY_MESSAGE_RECOVER,dependency:ns.CONVERSATION_RECOVER},{stepId:ns.BLACKLIST_RECOVER},{stepId:ns.FRIEND_RECOVER},{stepId:ns.GROUP_REVOKED_NOTICE_RECOVER},{stepId:ns.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ns.UNREAD_MESSAGE_SYNC,ns.CONVERSATION_RECOVER]},{stepId:ns.EMIT_C2C_MESSAGE_EVENT,dependency:[ns.UNREAD_MESSAGE_SYNC,ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[ss.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:ns.COMMERCIAL_CONFIG_UPDATE},{stepId:ns.CLOUD_CONFIG_SYNC},{stepId:ns.USER_PROFILE_SYNC},{stepId:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.FRIEND_AND_BLACKLIST_SYNC},{stepId:ns.GROUP_LIST_SYNC},{stepId:ns.CONVERSATION_LIST_SYNC},{stepId:ns.SIGNALING_MESSAGE_RECOVER,dependency:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ns.UNREAD_MESSAGE_SYNC,ns.CONVERSATION_LIST_SYNC]},{stepId:ns.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[ns.GROUP_LIST_SYNC,ns.CONVERSATION_LIST_SYNC]}],[ss.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:ns.HANDLE_C2C_NEW_MESSAGE},{stepId:ns.UNREAD_MESSAGE_SYNC},{stepId:ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ns.HANDLE_C2C_NEW_MESSAGE},{stepId:ns.EMIT_C2C_MESSAGE_EVENT,dependency:[ns.HANDLE_C2C_NEW_MESSAGE,ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:ns.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ns.UNREAD_MESSAGE_SYNC]}],[ss.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:ns.UPDATE_GROUP_NEXT_SEQUENCE,dependency:ns.HANDLE_GROUP_NEW_MESSAGE},{stepId:ns.EMIT_GROUP_MESSAGE_EVENT,dependency:[ns.HANDLE_GROUP_NEW_MESSAGE,ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}]};var is=Object.freeze({__proto__:null,ERROR_CODE:ts,InnerEvent:$t,OuterConstant:es,OuterEvent:xt,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SignalingEvent:Vt,WORKFLOW_DEFINITIONS:os,WORKFLOW_NAME:ss,WORKFLOW_STEP:ns});function rs(e){var t;try{const s=Ae.getStorage("errorMessage");if(!e||!s)return"";const n=(null===(t=JSON.parse(s))||void 0===t?void 0:t.errorMessage)||{},{isIntl:o=!1,code:i,replacement1:r="",replacement2:a=""}=e;if(!i)return"";const c=o?`${i}_en`:`${i}_cn`;let l=n[n[c]?c:i]||"";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 as extends Error{constructor(e){const{functionName:t="Unknown",code:s,message:n="",data:o=""}=e;let i=n;s&&!n&&(i=rs(e));const r=s?`${t} failed. error: {"message": ${i}, "code": ${s}}`:`${t} failed. error: {"message": ${i}}`;super(),this.code=s,this.errorCode=s,this.errorMessage=r,this.message=r,this.data=o}}function cs(e,t){var s;if(!e)return;if(!(!0===(null===(s=Ut.store.get("login"))||void 0===s?void 0:s.isLoggedIn)))throw new as({code:ts.USER_NOT_LOGGED_IN,functionName:t})}const ls=e=>"function"==typeof e;function ds(e,t,s){const n=s||[];if(!e||!t)return!1;const o=Object.keys(e).filter((e=>!n.includes(e))),i=Object.keys(t).filter((e=>!n.includes(e)));return o.length===i.length&&o.every((n=>!!t.hasOwnProperty(n)&&("object"==typeof e[n]&&null!==e[n]?ds(e[n],t[n],s):e[n]===t[n])))}function us(e,t,s){if(Array.isArray(e))for(let n=0;n<e.length;n++)_s.call(this,Object.assign(Object.assign({},e[n]),{value:t[n],name:s}));else for(const n in e)_s.call(this,Object.assign(Object.assign({},e[n]),{value:t[0][n],name:s,key:n}))}function _s({required:e,rules:t,range:s,value:n,allowEmpty:o,name:i,key:r,customValidator:a}){if(void 0===n){if(e){throw new as({functionName:i,message:`[${i}] Missing required params: "${r}"`})}return}let c="";if(!t.some((e=>{return e===(t=n,Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase());var t}))){for(let e=0;e<t.length;e++){let s=t[e];s=s.replace(s[0],s[0].toUpperCase()),c+=`${s}/`}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()}(n)}.`;throw new as({functionName:i,message:e})}if(!1===o){if(Array.isArray(n)&&(0===n.length||"string"==typeof n[0]&&""===n[0].trim())){throw new as({functionName:i,message:`${r} can not be empty.`})}if("string"==typeof n&&""===n.trim()){throw new as({functionName:i,message:`${r} can not be empty.`})}}if(a&&"function"==typeof a){const e=a(n);if(!0!==e){throw new as({functionName:i,message:`[${r}] custom validation failed: ${e||"Invalid value"}`})}}}const hs=[],gs={},fs={};function Es(e,t){cs(gs[e],e),us(fs[e],t,e),function(e){hs.forEach((t=>{const{interceptor:s,context:n}=t;s.apply(n,[e])}))}(e)}function ps(e,t){hs.push({interceptor:e,context:t})}function ms(e){const{params:t,auth:s}=e;t&&"object"==typeof t&&Object.assign(fs,t),s&&"object"==typeof s&&Object.assign(gs,s)}var Ss=new class{constructor(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e,t){e&&this._installPlugin(e,this._externalPlugins,t)}clear(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}_installPlugin(e,t,s){let n=[];n=Array.isArray(e)?e:[e],n.forEach((e=>{t.has(e)||(e&&ls(e.install)?(t.add(e),e.install(Cn(),s),ls(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):ls(e)?(t.add(e),e(Cn(),s),ls(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))}))}_isLoggedIn(){var e;return!0===(null===(e=Ut.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}};function vs(e){return Ut.store.get("commercialConfig").get(e)}const Is=new Map;var Cs=new class{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{const s=Date.now();t?(this._stepStartTimes.set(`${e}-${t}`,s),console.log(`[Workflow ${e}] Step ${t} started at ${new Date(s).toISOString()}`)):(this._workflowStartTimes.set(e,s),console.log(`[Workflow ${e}] started at ${new Date(s).toISOString()}`))},success:(e,t)=>{const s=Date.now();if(t){const n=this._stepStartTimes.get(`${e}-${t}`),o=n?s-n:0;this._stepStartTimes.delete(`${e}-${t}`),console.log(`[Workflow ${e}] Step ${t} completed successfully at ${new Date(s).toISOString()} (${o}ms)`)}else{const t=this._workflowStartTimes.get(e),n=t?s-t:0;this._workflowStartTimes.delete(e),console.log(`[Workflow ${e}] completed successfully at ${new Date(s).toISOString()} (${n}ms)`)}},error:(e,t,s)=>{const n=Date.now();if(t){const o=this._stepStartTimes.get(`${e}-${t}`),i=o?n-o:0;this._stepStartTimes.delete(`${e}-${t}`),console.error(`[Workflow ${e}] Step ${t} failed at ${new Date(n).toISOString()} (${i}ms)`,s)}else{const t=this._workflowStartTimes.get(e),o=t?n-t:0;this._workflowStartTimes.delete(e),console.error(`[Workflow ${e}] failed at ${new Date(n).toISOString()} (${o}ms)`,s)}}}}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){if(!this._handlers.has(e))return void console.debug(`Workflow '${e}' not defined in core`);if(!os[e].find((e=>e.stepId===t)))return void console.debug(`Step '${t}' not defined in workflow '${e}'`);this._handlers.get(e).set(t,n?s.bind(n):s)}executeWorkflow(e,t){return r(this,void 0,void 0,(function*(){if(!this._validateWorkflow(e))return;console.log(`[Workflow ${e}] Started execution at ${(new Date).toISOString()}`);const s=os[e],n={},o={cancelled:!1};this._activeWorkflows.set(e,{cancelToken:o});try{const i=new Map;s.forEach((e=>{i.set(e.stepId,e)}));const r={workflowName:e,pendingSteps:new Set(s.map((e=>e.stepId))),completedSteps:new Set,runningSteps:new Set,stepMap:i,stepResults:n,data:t,cancelToken:o};yield new Promise(((t,s)=>{const n=()=>{if(o.cancelled)return void t();this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:e}).filter((e=>!r.runningSteps.has(e))).forEach((o=>{r.completedSteps.has(o)||r.runningSteps.has(o)||this._executeWorkflowStep(o,r,{onComplete:()=>{if(0===r.pendingSteps.size)return void t();0===this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:e}).filter((e=>!r.runningSteps.has(e))).length&&0===r.runningSteps.size&&(console.log(`Workflow ${e} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})}))};n()})),console.log(`[Workflow ${e}] Completed execution at ${(new Date).toISOString()}`)}catch(t){console.error(`[Workflow ${e}] Failed execution at ${(new Date).toISOString()}`,t)}finally{this._activeWorkflows.delete(e)}}))}_executeWorkflowStep(e,t,s){return r(this,void 0,void 0,(function*(){const{workflowName:n,runningSteps:o,stepMap:i,stepResults:r,data:a}=t;o.add(e),this._logWorkflowExecution(n,e,"start");try{const s=i.get(e);let o=null;(null==s?void 0:s.dependency)&&(c(s.dependency)?o=r[s.dependency]:Array.isArray(s.dependency)&&(o={},s.dependency.forEach((e=>{o[e]=r[e]}))));const l=this._handlers.get(n).get(e);if(l){const t=yield Promise.resolve(l({data:a,result:o}));r[e]=t,this._logWorkflowExecution(n,e,"success")}t.completedSteps.add(e)}catch(t){const o=`[Workflow].${n}.${e}`,{errorCode:i,errorInfo:r=`${o} failed`}=t||{},a=new as({functionName:o,code:i,message:r});Ut.ssoLog.createSSOLogData({method:"Workflow"}).setLogInfo({message:`workflowName: ${n}, stepId: ${e}`}).setError(a).end(),this._logWorkflowExecution(n,e,"error",t),s.onError(t)}finally{o.delete(e),t.pendingSteps.delete(e),s.onStepComplete(),s.onComplete()}}))}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(os).forEach((e=>{this._handlers.set(e,new Map)}))}_cancelWorkFlow(e){const t=this._activeWorkflows.get(e);if(!t)return;const{cancelToken:s}=t;s.cancelled=!0,this._activeWorkflows.delete(e)}_cancelAllWorkflows(){Object.keys(os).forEach((e=>{this._cancelWorkFlow(e)}))}_validateWorkflow(e){if(!os[e])return console.debug(`Workflow '${e}' not defined`),!1;return!!this._handlers.get(e)||(console.debug(`No handlers registered for workflow '${e}'`),!1)}_getExecutableSteps(e){const{pendingSteps:t,completedSteps:s,stepMap:n,workflowName:o}=e;return Array.from(t).filter((e=>{const t=n.get(e)||{},{dependency:i,skipIfDependencyMissing:r=!0}=t;if(!i)return!0;if(c(i))return this._isStepRegistered({workflowName:o,stepId:i})?s.has(i):!r;if(d(i)){if(i.filter((e=>!this._isStepRegistered({workflowName:o,stepId:e}))).length>0&&r)return!1;for(const e of i)if(!s.has(e))return!1;return!0}return!1}))}_isStepRegistered(e){var t;const{workflowName:s,stepId:n}=e;return null===(t=this._handlers.get(s))||void 0===t?void 0:t.has(n)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}};function ys(){var e;return null===(e=Ut.store.get("login"))||void 0===e?void 0:e.userId}const Ms=e=>d(e)||u(e),Os=(e,t,s,n)=>{if(!Ms(e)||!Ms(t))return 0;let o=0;const i=Object.keys(t);let r;for(let c=0,l=i.length;c<l;c++)if(r=i[c],!(a(t[r])||s&&s.includes(r)))if(Ms(e[r])&&Ms(t[r]))o+=Os(e[r],t[r],s,n);else{if(n&&n.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],o+=1)}return o},Ts=e=>`${e}`.startsWith(Xt.COMMUNITY)&&`${e}`.includes(Xt.TOPIC),As=(e,t)=>{if(a(t))return"";switch(e){case es.MSG_TEXT:return t.text||"";case es.MSG_IMAGE:return"[Image]";case es.MSG_LOCATION:return"[Location]";case es.MSG_AUDIO:return"[Voice]";case es.MSG_VIDEO:return"[Video]";case es.MSG_FILE:return"[File]";case es.MSG_CUSTOM:return"[Custom Messages]";case es.MSG_GRP_TIP:return"[Group Notification]";case es.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case es.MSG_FACE:return"[Animated Sticker]";case es.MSG_MERGER:return"[Chat Record]";default:return""}},Ns=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_members",interval:3,count:1},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],Rs="im_sdk_config_mgr.fetch_config",Ds="im_sdk_config_mgr.push_configv2",ws="cloud-config",bs=2996;var ks=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,helper:n,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i},channel:r}=e;t.subscribeInnerEvent(Ds,this._handlePushedConfig,this),n.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),n.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Ns),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(e){var t;const s={code:0,data:""};return e?(s.data=(null===(t=this._core.store.get("cloudConfig"))||void 0===t?void 0:t[e])||"",s):s}checkMethodCallOverLimit(e){if(!this._cmdFrequencyLimitMap.has(e))return;if(!this._methodCallFrequencyMap.has(e))return void this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});const{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e);let{startTime:n,methodCallCounter:o}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(o+=1,this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:o}),o>t)throw new this._core.helper.ChatError({code:bs,replacement1:e})}_fetchCloudConfig(){return r(this,void 0,void 0,(function*(){try{const{sdkAppId:e}=this._core.store.get("instance")||{},t=this._core.helper.generateProtocolData({servcmd:Rs,data:{uint32_sdkappid:e,uint64_version:this._version}}),s=`${t.head.seq}${Rs}`;return yield this._core.channel.sendPacket(t,{requestId:s})}catch(e){throw console.warn("fetch cloudControl fail: ",e),e}}))}_handlePushedConfig(e){this._updateCloudConfig(e)}_handleLoginSuccess(){return r(this,void 0,void 0,(function*(){try{if(this._canFetch()){const e=yield this._fetchCloudConfig();this._updateCloudConfig(e)}this._core.helper.taskScheduler.addTask({id:ws,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){console.warn(e)}}))}_fetchCloudConfigIfReady(){return r(this,void 0,void 0,(function*(){if(this._canFetch())try{const e=yield this._fetchCloudConfig();this._updateCloudConfig(e)}catch(e){console.warn(e)}}))}_updateCloudConfig(e){const t=this._parseCloudConfig(e);t&&(this._core.store.set("cloudConfig",t),this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,t))}_canFetch(){const{isLoggedIn:e}=this._core.store.get("login")||{};return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){const{int32_error_code:t,str_error_message:s,str_json_config:n,uint32_expired_time:o,uint32_sdkappid:i,uint64_version:r}=e;let a=null;if(0===t){if(this._version!==r)try{a=JSON.parse(n),this._version=r}catch(e){}this._expirationTime=Date.now()+1e3*o}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return a}_parseCmdFreqLimit(){var e;let t=null===(e=this.getServerConfig("cmd_frequency_limit"))||void 0===e?void 0:e.data;const{isEmpty:s}=this._core.utils;if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}}_updateCmdFreqLimitMap(e){e.forEach((e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})}))}_reset(){this._core.helper.taskScheduler.removeTask(ws),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Ns),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(Ds,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class Ps{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&(this.low===e.low&&this.high===e.high)}toString(){const e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t=`0${t}`,e--}return e+t}}const Ls={SEARCH_GRP_SNS:new Ps(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new Ps(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new Ps(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new Ps(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new Ps(0,Math.pow(2,6)).toString(),USER_STATUS:new Ps(0,Math.pow(2,7)).toString(),CONV_MARK:new Ps(0,Math.pow(2,9)).toString(),CONV_GROUP:new Ps(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new Ps(0,Math.pow(2,11)).toString(),MSG_EXT:new Ps(0,Math.pow(2,13)).toString(),GRP_COUNTER:new Ps(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new Ps(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new Ps(Math.pow(2,7)).toString(),PLUGIN_CS:new Ps(Math.pow(2,8)).toString(),PLUGIN_PUSH:new Ps(Math.pow(2,9)).toString(),PLUGIN_BOT:new Ps(Math.pow(2,10)).toString(),MSG_REACTION:new Ps(Math.pow(2,16)).toString(),FOLLOW:new Ps(Math.pow(2,20)).toString()},Us="CommercialConfig",Gs="commercial-config";var Fs=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map}install(e){this._core=e;const{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:o,InnerEvent:i}}=e;s.subscribeInnerEvent(i.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(i.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(i.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this)}isCommercialAbilityEnabled(e){return r(this,void 0,void 0,(function*(){const t=parseInt(e,10).toString(2),{length:s}=t;let n,o=!0;for(let e=s-1,i=0;e>=0;e--,i++)if("1"===t.charAt(e)&&(n=i<32?new Ps(0,2**i).toString():new Ps(2**(i-32),0).toString(),!this._featureMap.get(n))){o=!1;break}return console.log(`${Us}.isFeatureEnabled decimalNumber:${e} key:${n} ret:${o}`),{code:0,data:{enabled:o}}}))}_fetchAndParseCommercialConfig(){return r(this,void 0,void 0,(function*(){var e;try{this._isFetching=!0;const t=this._core.helper.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null===(e=this._core.store.get("instance"))||void 0===e?void 0:e.sdkAppId}}),s=yield this._core.channel.sendPacket(t);(null==s?void 0:s.body)&&(this._parseCommercialConfig(s.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(e){console.warn("fetch commercial fail: ",e)}finally{this._isFetching=!1}}))}_syncCommercialConfig(e){return r(this,void 0,void 0,(function*(){const{purchaseBits:t}=(null==e?void 0:e.data)||{};t&&(this._parsePurchaseBits(t),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:Gs,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})}))}_canFetch(){var e;const t=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.isLoggedIn,s=Date.now()>=this._expirationTime;return t&&!this._isFetching&&s}_handlePushedConfig(e){(null==e?void 0:e.body)&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return r(this,void 0,void 0,(function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())}))}_parseCommercialConfig(e){if("object"!=typeof e)return;const{int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:o}=e;0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*o):void 0===t?(console.log(`${Us}._parseCommercialConfig failed. Invalid message format:`,e),this._expirationTime=Date.now()+36e5):(console.error(`${Us}._parseCommercialConfig errorCode:${t} errorMessage:${s}`),this._expirationTime=Date.now()+12e4)}_isValidPurchaseBits(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(e){if(this._isValidPurchaseBits(e)){this._featureMap.clear(),this._methodKeyMap.clear();let t=null;for(let s=e.length-1,n=0;s>=0;s--,n++)if(t=n<32?new Ps(0,2**n).toString():new Ps(2**(n-32),0).toString(),"1"===e[s]){this._featureMap.set(t,!0);const e=this._getKeyByValue(Ls,t);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(t,!1);const e=this._getKeyByValue(Ls,t);e&&this._methodKeyMap.set(e,!1)}}else console.warn(`${Us}.parsePurchaseBits invalid purchases:${e}`)}_getKeyByValue(e,t){const s=Object.entries(e).find((([e,s])=>s===t));return s?s[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(Gs),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear()}};var xs=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,channel:n}=this._core;t.subscribeInnerEvent(s.OVERLOAD_PUSH,this._handleOverLoadPush,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),n.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return;const{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}_handleOverLoadPush(e){const{OverLoadServCmd:t,DelaySecs:s}=e;this._serverOverloadInfoMap.set(t,{overloadStartTimestamp:Date.now(),delaySeconds:s})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};var Bs=new class{constructor(){this._core=null}install(e){return r(this,void 0,void 0,(function*(){if(this._core=e,this._canFetch()){const e=yield this._fetchErrorMessage();if(!e)return;const t=this._parseResponse(e);this._saveErrorMessage(t)}}))}_canFetch(){const e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return r(this,void 0,void 0,(function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}}))}_isExpired(e){if(!e)return!0;const{errorMessageSavedTime:t}=e;return t&&(new Date).getTime()-t>=6048e5}_parseResponse(e){if("string"==typeof e){const t=e.split(";\n"),s={},n=new RegExp(/'/g);for(let e=0;e<t.length;e++){const o=t[e].indexOf(":"),i=t[e].slice(0,o);let r=t[e].slice(o+1);if(!i.startsWith("//")){if(""===r)continue;r=r.replace(n,""),s[i]=r}}return s}}};function $s(e,t){return r(this,void 0,void 0,(function*(){const{cookie:s,syncFlag:n,syncTriggerEvent:o}=e,i="openim.getmsg",r=t.helper.generateProtocolData({servcmd:i,data:{Cookie:s,SyncFlag:n,IsOnlineSync:o,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=`${r.head.seq}${i}`;try{const e=yield t.channel.sendPacket(r,{requestId:a});if(!e)return null;const{C2CPairUnreadCount:s,C2CRemainingUnreadCount:n,EventArray:o}=e,{unreadMessageList:i,revokedMessageList:c}=function(e,t){const s=[],n=[];return null==e||e.forEach((e=>{var o,i,r;const a=function(e,t){const{From_Account:s,From_AccountHeadurl:n,From_AccountNick:o,IsNeedReadReceipt:i,MsgBody:r,MsgClientTime:a,MsgRandom:c,MsgSeq:l,MsgTimeStamp:d,SendMsgControl:u,SupportMessageExtension:_,To_Account:h,TinyId:g,MsgCheckResult:f,CloudCustomData:E,IsPeerRead:p,MsgFlagBits:m,MsgVersion:S,EventArray:v}=e;return{from:s,avatar:n,nick:o,needReadReceipt:1===i,readReceiptSentByPeer:p,clientTime:a,messageFlagBits:m,random:c,sequence:l,time:d,messageControlInfo:u,isSupportExtension:_,to:h,tinyID:g,checkResult:f,cloudCustomData:E,messageVersion:S,eventArray:v,elements:t.message.messageHelper.parseServerPushMessageElement(r)}}(e,t);if(null===(r=null===(i=null===(o=null==e?void 0:e.EventArray)||void 0===o?void 0:o[0])||void 0===i?void 0:i.hasOwnProperty)||void 0===r?void 0:r.call(i,"C2cNotifyMsgArray"))n.push(...function(e){var t;const s=[];return null===(t=e.EventArray)||void 0===t||t.forEach((e=>{var t,n;const{C2cNotifyMsgArray:o}=e,i=null===(n=null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.WithdrawC2cMsgNotify)||void 0===n?void 0:n.C2cWithdrawInfoArray;Array.isArray(i)&&s.push(...i)})),s}(e));else{const e=t.message.messageFactory.createMessage(Object.assign(Object.assign({},a),{conversationType:"C2C",flow:"in"})),{elements:n}=a;e.setElement(n),s.push(e)}})),{unreadMessageList:s,revokedMessageList:n}}(e.MsgList,t);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:c,unreadCountList:s,overflowUnreadCountList:n,cookie:null==e?void 0:e.Cookie,groupTipList:o}}catch(e){console.warn(e)}}))}var Vs,qs;!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(Vs||(Vs={})),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(qs||(qs={}));var Ws=new class{constructor(){this._unreadDBMessageMap=new Map,this._cookie=""}install(e){this._core=e;const{constants:t}=e;e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(e){return r(this,void 0,void 0,(function*(){const{isAfterReOnline:t=!1,isAfterNewMessageReceived:s=!1,isAfterLogin:n=!1}=e||{};let o=Vs.START_SYNC;const i=[],r=[],a=[],c=[];for(;this._canContinueSync({cookie:this._cookie,syncFlag:o});){const e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:o,syncTriggerEvent:s?qs.NEW_MESSAGE_RECEIVED:qs.LOGIN_SUCCESS});if(!e)break;const{unreadMessageList:n=[],revokedMessageList:l=[],overflowUnreadCountList:d,unreadCountList:u,groupTipList:_}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",o=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(n),a.push(...l),this._updateConversationUnreadOptions({unreadCountList:u,overflowUnreadCountList:d,conversationUpdateFieldList:i}),Array.isArray(_)&&r.push(..._),t){const{messages:e}=this._handleNewMessageList(n);c.push(...e)}}return t?{conversationUpdateFieldList:i,revokedMessageList:a,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r,messages:c}:{conversationUpdateFieldList:i,isInstantMessage:!n,isUnreadC2CMessage:!0,revokedMessageList:a,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r}}))}_syncUnreadDBMessageAfterLogin(){return r(this,void 0,void 0,(function*(){return this._syncUnreadMessage({isAfterLogin:!0})}))}_syncUnreadDBMessageAfterNewMessageReceived(e){return r(this,void 0,void 0,(function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})}))}_updateConversationUnreadOptions(e){const{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{constants:{OuterConstant:{CONV_C2C:o,CONV_SYSTEM:i}}}=this._core;null==t||t.forEach((e=>{const{From_Account:t,UnreadCount:s}=e;if(t!==i){const e=n.find((({conversationID:e})=>e===`${o}${t}`));e?e.unreadCount=s:n.push({conversationID:`${o}${t}`,unreadCount:s,type:o})}})),null==s||s.forEach((e=>{const{From_Account:t,LastMsgTime:s}=e;if(t!==i){n.find((({conversationID:e})=>e===`${o}${t}`))||n.push({conversationID:`${o}${t}`,type:o,lastMsgTime:s})}}))}_syncUnreadDBMessageAfterReOnline(){return r(this,void 0,void 0,(function*(){return this._syncUnreadMessage({isAfterReOnline:!0})}))}_updateMessageProfile(e){var t;const{messageDataHandler:s}=this._core.message||{},n=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:a=""}=e;if(o!==n){const t=s.getLatestMsgSentByPeer(a);if(t){const{nick:n,avatar:o}=t;i&&r?i===n&&r===o||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!1}):(e.nick=n,e.avatar=o)}}else{const e=s.getLatestMsgSentByMe(a);!e||i===e.nick&&r===e.avatar||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!0})}}_handleNewMessageList(e){const{messageDataHandler:t}=this._core.message||{},s=new Map,n=[];return e.forEach((e=>{this._updateMessageProfile(e);let o=1===e.isModified;if(t.isMessageSentByCurrentInstance(e)?e.isModified=o:o=!1,e.isOnlineMessage())e._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(e)||n.push(e);else if(!t.isInMessageList(e)){if(t.storeConversationMessage(e)){const{conversationID:t,conversationType:n,conversationSubType:o,flow:i,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=e,c=a?"":e;s.has(t)?(s.get(t).lastMessage=c,"in"===i&&(r||s.get(t).unreadCount++)):s.set(t,{conversationID:t,type:n,subType:o,unreadCount:r||"in"!==i?0:1,lastMessage:c})}t.isMessageSentByCurrentInstance(e)&&!o||n.push(e)}})),{messages:n,conversationOptions:s}}_fetchUnreadDBMessage(e){return r(this,void 0,void 0,(function*(){try{const t="unread-message-synchronizer._fetchUnreadDBMessage";console.log(`${t} options:`,e);const s=yield $s(e,this._core);if(!s)return null;const{syncFlag:n,unreadMessageList:o,revokedMessageList:i,cookie:r,unreadCountList:a,overflowUnreadCountList:c,groupTipList:l}=s;return this._parseAndSaveUnreadMessageList(o),{syncFlag:n,cookie:r,unreadMessageList:o,revokedMessageList:i,unreadCountList:a,overflowUnreadCountList:c,groupTipList:l}}catch(e){console.log(e)}}))}_canContinueSync({cookie:e,syncFlag:t}){var s;return t===Vs.START_SYNC||t===Vs.SYNCING&&!(null===(s=this._core)||void 0===s?void 0:s.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach((e=>{const{ID:t}=e;this._unreadDBMessageMap.set(t,e)}))}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}};var Ys=new class{init(e){var t;this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),document.addEventListener("visibilitychange",this._visibilityChangeHandler),null===(t=this._core)||void 0===t||t.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t;const s="visible"===document.visibilityState;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:s}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:s})}_reset(){var e;null===(e=this._core)||void 0===e||e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};var Ks=new class{init(e){var t;this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var e;const{MINI_APP_NAMESPACE:t}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};t.onAppShow((()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!0}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})})),t.onAppHide((()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!1}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})}))}_reset(){var e;null===(e=this._core)||void 0===e||e.store.clear("activityMonitor")}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};var js=new class{init(e){const{IN_WX_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?Ks.init(e):Ys.init(e))}};const Hs="none",zs="online";var Zs=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return r(this,void 0,void 0,(function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)}))}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,s;const{isConnected:n,networkType:o}=e;null===(t=this._core)||void 0===t||t.store.set("netWorkMonitor",{isNetworkOnline:n,networkType:o}),null===(s=this._core)||void 0===s||s.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:n,networkType:o})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:zs})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Hs})}_reset(){var e;this._deactivateNetworkMonitoring(),null===(e=this._core)||void 0===e||e.store.clear("netWorkMonitor")}_dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(null===(t=this._core)||void 0===t?void 0:t.InnerEvent.DESTROY,this._dispose,this),this._reset()}};var Js=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return r(this,void 0,void 0,(function*(){try{this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),wx.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}}))}_deactivateNetworkMonitoring(){null!==this._mpNetworkStatusCallback&&(wx.offNetworkStatusChange&&wx.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,s;const{isConnected:n,networkType:o}=e;null===(t=this._core)||void 0===t||t.store.set("netWorkMonitor",{isNetworkOnline:n,networkType:o}),null===(s=this._core)||void 0===s||s.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:n,networkType:o})}_reset(){var e;this._deactivateNetworkMonitoring(),null===(e=this._core)||void 0===e||e.store.clear("netWorkMonitor")}_dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(null===(t=this._core)||void 0===t?void 0:t.InnerEvent.DESTROY,this._dispose,this),this._reset()}};var Xs=new class{init(e){const{IN_WX_MINI_APP:t}=e.helper;t?Js.init(e):Zs.init(e)}};var Qs=new class{install(e){js.init(e),Xs.init(e)}};const en=new Set(["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"]),tn="tui_room_svr.*";var sn=new class{constructor(){this._transferredCommands=en}install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,helper:n}=e;t.subscribeInnerEvent(s.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),t.subscribeInnerEvent("im_open_push.msg_push",t.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),n.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),n.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(e){return r(this,void 0,void 0,(function*(){const t="transferBusinessCommand";try{const{serviceCommand:s=tn}=e||{};if(!this._isValidTransferredCommand(s))throw new this._core.helper.ChatError({code:2995,functionName:t});const n=yield function(e,t){return r(this,void 0,void 0,(function*(){const{helper:s,channel:n}=t,{serviceCommand:o=tn,data:i}=e||{};let r={};try{r="string"==typeof i?JSON.parse(i):i}catch(e){console.warn(e)}const a=s.generateProtocolData({servcmd:o,data:r}),c=`${a.head.seq}${o}`;return n.sendPacket(a,{requestId:c})}))}(e,this._core);return{code:0,data:n||{}}}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}}))}_onCloudConfigUpdate(e={}){try{if("string"!=typeof e.rtc_cmd)return;const t=JSON.parse(e.rtc_cmd);Array.isArray(t)&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){const t=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(t)}_onServerPushBusinessCommand(e){const{OuterEvent:t,notificationCenter:s}=this._core,{MsgContent:n}=e||{},{ROOM_CUSTOM_DATA_RECEIVED:o}=t;s.emitOuterEvent(o,{name:o,data:n})}_reset(){this._transferredCommands=en}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let nn=[];const on=[Bs,function(e){ks.install(e),Fs.install(e),xs.install(e)},Ws,Qs,sn];nn=on;var rn=Object.freeze({__proto__:null,ChatError:as,buildAndSendPacket:function(e){return r(this,void 0,void 0,(function*(){const{servcmd:t,data:s}=e,n=Ut.common.generateProtocolData({servcmd:t,data:s}),o=`${n.head.seq}${t}`;return Ut.channel.sendPacket(n,{requestId:o})}))},get builtInPlugins(){return nn},checkBusinessCapabilityBits:vs,deepMerge:Os,destroy:vn,exposeApiForClient:In,exposeApiForPlugin:Cn,getCurrentUserID:ys,getErrorMessage:rs,getMessagePreviewText:As,isCommunity:({type:e,groupID:t})=>e===es.GRP_COMMUNITY||`${t}`.startsWith(Xt.COMMUNITY)&&!`${t}`.includes(Xt.TOPIC),isTopic:Ts,isUnlimitedAVChatRoom:function(){var e;return!!(null===(e=Ut.store.get("instance"))||void 0===e?void 0:e.unlimitedAVChatRoom)},liteChatInstanceMap:Is,registerApi:mn,registerExperimentalAPI:Sn,registerInterceptor:ps,registerPlugin:fn,registerValidateConfig:ms,requireAuth:cs,setLogLevel:pn,statKeyFeatureUsage:En,validateAndExecute:Es,validateParameters:us,workflowManager:Cs});var an=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t){const s=this._conversationMap.get(e);s&&!ue(t)&&(Object.keys(t).forEach((e=>{s[e]=t[e]})),Ut.notificationCenter.emitInnerEvent($t.CONVERSATION_UPDATED))}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),Ut.notificationCenter.emitInnerEvent($t.CONVERSATION_UPDATED))}};var cn=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){const s=this._groupMap.get(e);s&&!ue(t)&&Object.keys(t).forEach((e=>{s[e]=t[e]}))}};var ln=new class{constructor(){this._messagesByConversation=new Map}updateMessage(e,t,s){var n;const{operation:o,updateUnreadCount:i=!0}=s,r=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(s[n[o]]=e[n[o]])}return s}(s,["operation","updateUnreadCount"]),a=[];for(const s of t){const t=null===(n=this._messagesByConversation.get(e))||void 0===n?void 0:n.get(s);if(!t)return!1;Object.keys(r).forEach((e=>{t[e]=r[e]})),a.push(t)}return this._emitMessageStoreOperationEvent(o,{conversationID:e,messageList:a,updateUnreadCount:i}),a}getMessagesByConversation(e){var t;return[...(null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){Ut.notificationCenter.emitInnerEvent(e,t)}};var dn=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},un=Object.freeze({__proto__:null,conversationStore:an,groupStore:cn,messageStore:ln,userStore:dn});const _n={on:Ut.notificationCenter.subscribeOuterEvent.bind(Ut.notificationCenter),off:Ut.notificationCenter.unSubscribeOuterEvent.bind(Ut.notificationCenter),destroy:vn,callExperimentalAPI:function(e,t){if(hn[e])return hn[e](t);return Promise.reject(new Error(`API ${e} is not found`))},use:Ss.installExternalPlugin.bind(Ss),registerPlugin:fn,setLogLevel:pn},hn={},gn={};function fn(e){console.log("registerPlugin",e)}function En(e){console.log("statTUIKeyFeatures",e)}function pn(e){console.log("setLogLevel",e),Ut&&"function"==typeof Ut.setLogLevel&&(null==Ut||Ut.setLogLevel(e))}function mn(e){const{apiName:t,context:s,methodName:n=t,matcher:o}=e;gn[t]||(gn[t]=[]),gn[t].push({context:s,methodName:n,matcher:o}),_n[t]&&1!==gn[t].length||(_n[t]=(...e)=>{Es(n,e);const s=gn[t];for(const t of s)if(!t.matcher||t.matcher(e))return t.context[t.methodName].bind(t.context)(...e)})}function Sn(e,t,s){const n=s||e;hn[e]=t[n].bind(t)}function vn(){return r(this,void 0,void 0,(function*(){var e,t;try{(null===(e=Ut.store.get("login"))||void 0===e?void 0:e.isLogin)&&(yield _n.logout()),Ut.notificationCenter.emitInnerEvent($t.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{Ut.notificationCenter.emitOuterEvent(xt.SDK_DESTROY,{SDKAppID:null===(t=Ut.store.get("instance"))||void 0===t?void 0:t.sdkAppId}),Is.clear(),Ss.clear(),Cs.destroy(),Ut.destroy()}}))}function In(){return _n}function Cn(){return Object.assign(Object.assign({InnerEvent:$t,InnerEventSubType:Ut.notificationCenter.InnerEventSubType,OuterEvent:xt,OuterConstant:es,SignalingEvent:Vt,helper:Object.assign(Object.assign(Object.assign({},Ut.utils),Ut.common),{registerApi:mn,registerExperimentalAPI:Sn,registerInterceptor:ps,registerValidateConfig:ms,checkBusinessCapabilityBits:vs,registerWorkflowStep:Cs.registerWorkflowStep.bind(Cs),ChatError:as}),apiMap:_n},Ut),{constants:Object.assign(Object.assign({},is),Ut.constants),common:Object.assign(Object.assign({},rn),Ut.common),utils:Ut.utils,appStore:un})}hn.statTUIKeyFeatures=En;var yn,Mn,On;!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(yn||(yn={})),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Mn||(Mn={})),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(On||(On={}));const Tn={[Mn.multipleAccount]:"multipleAccount",[Mn.multipleDevice]:"multipleDevice",[Mn.restApi]:"REST_API_Kick",[On.multipleAccount]:"multipleAccount",[On.multipleDevice]:"multipleDevice",[On.restApi]:"REST_API_Kick",[On.usersigExpired]:"userSigExpired"},An="login_online_presence_task",{ERROR:Nn,DESTROY:Rn,FORCE_OFFLINE:Dn}=$t,{KICKED_OUT_MULT_ACCOUNT:wn,KICKED_OUT_MULT_DEVICE:bn,KICKED_OUT_REST_API:kn,ACCOUNT_A2KEY_EXPIRED:Pn,MSG_A2KEY_EXPIRED:Ln}=ts;class Un{init(){const{notificationCenter:e}=Ut;e.subscribeInnerEvent(Dn,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(Nn,Ln,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Nn,Pn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Nn,wn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Nn,bn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Nn,kn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Rn,this._dispose,this)}_handleForceOfflineFromServerPush(e){const{EventArray:t=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(t).forEach((e=>{const{KickoutMsgNotify:{KickType:t,NewInstInfo:s}}=e;this._processKickedOutReasonInfo({kickedOutReasonCode:t,newInstanceInfo:s})}))}_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 r(this,void 0,void 0,(function*(){const{kickedOutReasonCode:t}=e;try{yield Ut.login.loginAction.logout(yn.KICKED_OUT)}catch(e){console.debug(e)}finally{this._logKickedOutEvent(e),Ut.notificationCenter.emitOuterEvent(xt.KICKED_OUT,{data:{type:Tn[t]},name:xt.KICKED_OUT}),[Mn.restApi,Pn,Ln].includes(t)&&Ut.channel.reconnect()}}))}_logKickedOutEvent(e){const{kickedOutReasonCode:t,newInstanceInfo:s={}}=e,n=Ut.ssoLog.createSSOLogData({method:"kickedOut"}),o=`type:${Tn[t]} newInstanceInfo: ${JSON.stringify(s)}`;n.setLogInfo({message:o}).end(!0),console.warn(`loginModule.${o}`)}_isKickedOut(e){return[Mn.multipleAccount,Mn.multipleDevice,Mn.restApi].includes(e)}_dispose(){const{notificationCenter:e}=Ut;e.unSubscribeInnerEvent(Dn,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(Nn,Pn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Nn,Ln,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Nn,wn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Nn,bn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Nn,kn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Rn,this._dispose,this)}}function Gn(){return r(this,void 0,void 0,(function*(){const e="im_open_status.wslogin",t=Ut.common.generateProtocolData({servcmd:e,data:{state:"Online",isWebUniapp:0,InstType:0,customInfo:""}}),s=`${t.head.seq}${e}`;try{const e=yield Ut.channel.sendPacket(t,{timeout:9e4,requestId:s});if(e){const{HelloInterval:t,InstId:s,TinyId:n,TimeStamp:o,CustomStatus:i,PurchaseBits:r,A2Key:a,RichMsgAuthKey:c,ErrorCode:l,ErrorInfo:d,ActionStatus:u}=e;return{helloInterval:t,instanceID:s,tinyID:n,timeStamp:o,customStatus:i,purchaseBits:r,a2Key:a,authKey:c,errorCode:l,errorInfo:d,actionStatus:u}}}catch(e){throw console.warn(e),e}}))}class Fn{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120}init(){const{notificationCenter:e,store:t}=Ut;t.set("login",{isReady:!1}),mn({apiName:"login",context:this}),mn({apiName:"logout",context:this}),mn({apiName:"getLoginUser",context:this}),mn({apiName:"isReady",context:this}),e.subscribeInnerEvent($t.RECONNECTED,this._reLogin,this),Ut.notificationCenter.subscribeInnerEvent($t.DESTROY,this._dispose,this)}login(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"login",eventType:4});try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new as({functionName:"login",code:ts.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:s}=e,n=new as({functionName:"login",code:s});throw t.setError(n).end(!0),n}finally{this._latestLoginAt=0}}))}_reLogin(){return r(this,void 0,void 0,(function*(){var e;try{if(!this._isLoginIn())return;const t=Ut.ssoLog.createSSOLogData({method:"reLogin"}),s=yield Gn();if(s){const{instanceID:n,customStatus:o}=s;Ut.store.set("login",{statusInstanceId:n}),Cs.executeWorkflow(ss.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:o,statusType:Ht.USER_STATUS_ONLINE});const i=`socketId:${null===(e=Ut.channel.getSocketAdapter())||void 0===e?void 0:e.getId()} instanceId:${n}`;t.setLogInfo({message:i}).end(!0)}}catch(e){console.warn(e)}}))}logout(){return r(this,arguments,void 0,(function*(e=yn.USER_INITIATED){Ut.ssoLog.createSSOLogData({method:"logout"}).setLogInfo({moreMessage:`identifier:${ys()}`}).end(!0);try{yield this._performLogout(e)}catch(e){const{errorCode:t}=e,s=new as({functionName:"logout",code:t});this._handleLogoutError(s)}finally{this._handleLogoutCompleted()}return{code:0,data:{}}}))}getLoginUser(){return this._isLoginIn()?ys():""}isReady(){var e;return null===(e=Ut.store.get("login"))||void 0===e?void 0:e.isReady}_updateAndEmitSDKReady(){Ut.store.set("login",{isReady:!0}),setTimeout((()=>{Ut.notificationCenter.emitOuterEvent(xt.SDK_READY,{name:xt.SDK_READY})}),1)}_updateAndEmitSDKNotReady(){Ut.store.set("login",{isReady:!1}),Ut.notificationCenter.emitOuterEvent(xt.SDK_NOT_READY,{name:xt.SDK_NOT_READY})}_validateAfterLogin(e){var t,s;const n="login";if(!e)throw new as({functionName:n,message:"login response is empty"});const{tinyID:o,a2Key:i}=e||{},r=Ut.ssoLog.getSSOLogData(n);if(!o){const e=new as({functionName:n,code:ts.NO_TINYID});throw null===(t=null==r?void 0:r.setError)||void 0===t||t.call(r,e).end(),e}if(!i){const e=new as({functionName:n,code:ts.NO_A2KEY});throw null===(s=null==r?void 0:r.setError)||void 0===s||s.call(r,e).end(),e}}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:rs({code:"RepeatLogin",replacement1:null===(e=Ut.store.get("login"))||void 0===e?void 0:e.userId}),repeatLogin:!0}}}_performLogin(e){return r(this,void 0,void 0,(function*(){const{userID:t,userSig:s}=e;return Ut.store.set("login",{userId:t,userSig:s}),this._latestLoginAt=Date.now(),Gn()}))}_ensureAsyncComplete(){return r(this,void 0,void 0,(function*(){yield new Promise((e=>{setTimeout((()=>e(null)),1)}))}))}_handleLoginSuccess(e){const{timeManager:t}=Ut.common,{helloInterval:s,timeStamp:n,customStatus:o,purchaseBits:i}=e,r=1e3*n;t.calculateTimeOffsetWithServer(this._latestLoginAt,r),this._helloInterval=s||120,this._updateLoginStore(e),Ut.user.userStatus.setCustomStatus(o),Cs.executeWorkflow(ss.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:i}),Ut.common.taskScheduler.addTask({id:An,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this}),this._logLoginSuccess(e)}_performLogout(e){return function(e){return r(this,void 0,void 0,(function*(){const{logoutReason:t}=e,s="im_open_status.wslogout",n=Ut.common.generateProtocolData({servcmd:s,data:{wslogout_type:t,isWebUniapp:0}}),o=`${n.head.seq}${s}`;return yield Ut.channel.sendPacket(n,{requestId:o})}))}({logoutReason:e})}_handleLogoutError(e){Ut.ssoLog.getSSOLogData("logout").setError(e).end(),console.error(`logout ${e}`)}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),Cs.reset(),Ut.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){const{a2Key:t,tinyID:s,instanceID:n,authKey:o}=e;Ut.store.set("login",{a2Key:t,tinyID:s,statusInstanceId:n,authKey:o,isLoggedIn:!0})}_logLoginSuccess(e){var t;const s=Ut.ssoLog.getSSOLogData("login"),{helloInterval:n,instanceID:o,timeStamp:i,customStatus:r}=e,a=null===(t=Ut.channel.getSocketAdapter())||void 0===t?void 0:t.getId(),c=Ut.common.timeManager.getTimeOffsetWithServer(),{appId:l,href:d}=Ut.store.get("instance")||{},u=`login._logLoginSuccess socketID:${a} scene: helloInterval:${n} instanceID:${o}\n timeStamp:${i} offset:${c} customStatus:${r} href: ${d} appId: ${l}`;console.log(`login ok. ${u}`),s.updateLogCreatedAtByTimeOffset(),s.setLogInfo({moreMessage:u}).end()}_sendOnlinePresenceRequest(){return r(this,void 0,void 0,(function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{yield function(){const e="im_open_status.wshello",t=Ut.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),s=`${t.head.seq}${e}`;return Ut.channel.sendPacket(t,{requestId:s})}()}catch(e){console.warn("Login._sendOnlinePresenceRequest error:",e)}}))}_isLoginIn(){var e;return!0===(null===(e=Ut.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){console.log("Login reset"),Ut.common.taskScheduler.removeTask(An),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,Ut.store.clear("login"),Ut.store.set("login",{isReady:!1})}_dispose(){console.log("Login dispose"),this._reset();const{notificationCenter:e}=Ut;e.unSubscribeInnerEvent($t.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent($t.DESTROY,this._dispose,this)}}const xn={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},Bn={logout:!0};class $n{constructor(){this.loginAction=new Fn,this.kickedOutHandler=new Un,this.loginAction.init(),this.kickedOutHandler.init(),ms({auth:Bn,params:xn})}}var Vn,qn,Wn;!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(Vn||(Vn={})),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(qn||(qn={})),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(Wn||(Wn={}));const Yn={1:qn.MSG_PRIORITY_HIGH,2:qn.MSG_PRIORITY_NORMAL,3:qn.MSG_PRIORITY_LOW,4:qn.MSG_PRIORITY_LOWEST},Kn=0,jn=1;var Hn;!function(e){e.IN="in",e.OUT="out"}(Hn||(Hn={}));const zn={};function Zn(e){if(!e)return 0;if(void 0===zn[e]){const t=new Date,s=`3${t.getHours()}`.slice(-2),n=`0${t.getMinutes()}`.slice(-2),o=`0${t.getSeconds()}`.slice(-2);zn[e]=parseInt([s,n,o,"0001"].join(""),10),console.log(`autoIncrementIndex start index:${zn[e]}`)}else zn[e]+=1;return zn[e]}class Jn{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=qn.MSG_PRIORITY_NORMAL,this._relayFlag=!1;const{clientTime:t=Ut.common.timeManager.getServerTimeSeconds()||0,senderTinyID:s,currentUser:n,needReadReceipt:o,isSupportExtension:i,customModerationConfigurationId:r,to:a,from:c,nick:l="",avatar:d="",time:u,messageControlInfo:_,tinyID:h,cloudCustomData:g="",messageLifeTime:f,messageVersion:E=0,conversationType:p,sequence:m,checkResult:S=0,isPlaceMessage:v=0,messageFlagBits:I,receiverList:C,isSystemMessage:y=!1,status:M=Yt.SUCCESS,revokeReason:O="",conversationSubType:T,clientSequence:A,protocol:N="JSON",revokerInfo:R={userID:"",nick:"",avatar:""},readReceiptInfo:D={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:w,groupProfile:b,atUserList:k,flow:P,isRead:L=!1}=e;var U;this.clientTime=t,this.senderTinyID=s||h,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===i||1===i,this._cmConfigID=r,this.to=a,this.nick=l,this.avatar=d,this.protocol=N,this.random=void 0===w?(U=U||99999999,Math.round(Math.random()*U)):w,this.time=u||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!!(null==_?void 0:_.excludedFromLastMessage),this._isExcludedFromUnreadCount=!!(null==_?void 0:_.excludedFromUnreadCount),this.isModified=!!E,this.cloudCustomData=g,this.messageLifeTime=f,this.from=c||null,this.sequence=m||0,this.conversationType=p||Vn.CONV_C2C,this.hasRiskContent=S>1,this.version=E,this.isPlaceMessage=v,this.isRevoked=2===v||8===I,this.isSystemMessage=y,this.readReceiptInfo=D,this.revokeReason=O,this.revokerInfo=R,this._receiverList=C,this.conversationSubType=T,this.revoker=(null==R?void 0:R.revoker)||"",this.clientSequence=A||m||0,this.status=M,this.atUserList=k||[],this.flow=P,this.isRead=L,this.reInitialize(n),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(b)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map((e=>e.transformToServerFormat())):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t,s;return this._relayFlag?{isValid:!0}:(null===(e=this._elements)||void 0===e?void 0:e.length)>0?null===(s=null===(t=this._elements[0])||void 0===t?void 0:t.validateBeforeSend)||void 0===s?void 0:s.call(t):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){const{readReceiptSentByPeer:t,timestamp:s=0}=e;this.conversationType===Vn.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===t,this.readReceiptInfo.timestamp=s)}_extractGroupInfo(e){if(!e)return;const{From_AccountNick:t,From_AccountHeadurl:s,MsgFrom_AccountExtraInfo:n}=e,{NameCard:o}=n||{};"string"==typeof t&&(this.nick=t),"string"==typeof s&&(this.avatar=s),"string"==typeof o&&(this.nameCard=o)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){let t="";const s=this.conversationType;s!==Vn.CONV_SYSTEM?(t=s===Vn.CONV_C2C?e===this.from?this.to:this.from:this.to,this.conversationID=t?`${s}${t}`:null):this.conversationID=Vn.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=Zn(e)),0===this.sequence&&this.conversationType===Vn.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===Vn.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-${this.random}`}setIsRead(e){this.isRead=e}}class Xn{static parseServerPushElement(e){const{MsgContent:t={}}=e,{Data:s,Ext:n,Desc:o}=t;return new Xn({data:s,description:o,extension:n})}constructor(e){this.type=Wn.MSG_CUSTOM;const{data:t="",description:s="",extension:n=""}=e;this.content={data:t,description:s,extension:n}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{data:n,description:o,extension:i}=s;return{MsgType:this.type,MsgContent:{Data:n,Ext:i,Desc:o}}}validateBeforeSend(){const{isEmpty:e}=Ut.utils,t=[this.content.data,this.content.description,this.content.extension].some((t=>!e(t)));return{isValid:t,error:t?null:{message:"content can not be empty"}}}}class Qn{static parseServerPushElement(e){const{MsgContent:t={Text:""}}=e,{Text:s}=t;return new Qn({text:s})}constructor(e){this.type=Wt.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e,t;return(null===(t=null===(e=this.content)||void 0===e?void 0:e.text)||void 0===t?void 0:t.length)>0?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{text:n}=s;return{MsgType:this.type,MsgContent:{Text:n}}}}class eo{constructor(){this._elementClassMap={[Wn.MSG_CUSTOM]:Xn,[Wn.MSG_TEXT]:Qn}}init(){mn({apiName:"createCustomMessage",context:this}),mn({apiName:"createTextMessage",context:this})}registerElementClass(e,t){var s;void 0!==(s=t).prototype&&"constructor"in s.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){const{from:t,flow:s=Hn.OUT}=e,{userId:n}=Ut.store.get("login")||{};this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=Hn.OUT);const o=Object.assign(Object.assign({},e),{currentUser:n});return new Jn(o)}createCustomMessage(e){const t=ys(),s=this.createMessage(Object.assign(Object.assign({},e),{from:t})),n=this._elementClassMap[Wn.MSG_CUSTOM];if(!s)return null;if(n){const t=new n(e.payload);s.setElement(t)}return s}createTextMessage(e){var t;if(!e)return null;const s="string"==typeof e.payload?e.payload:(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text)||"",n=new Qn({text:s}),o=ys(),i=Ut.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:o}));return i.setElement(n),i}_updateWithSenderInfo(e){const{nick:t,avatar:s}=e,{userId:n,tinyID:o}=Ut.store.get("login")||{},i=dn.getUserProfile(n);return e.nick=t||(null==i?void 0:i.nick)||"",e.avatar=s||(null==i?void 0:i.avatar)||"",e.tinyID=e.tinyID||o||"",e.from=n,e.status=Yt.UNSENT,e.flow=Hn.OUT,e}_isMultiEndpointSyncMessage(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===Hn.IN}_isSendByCurrentInstance(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===Hn.OUT}}function to(e){const t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function so(e){const{androidInfo:t={},androidOPPOChannelID:s=""}=e,n=t.OPPOChannelID||s;return Object.assign(Object.assign({},t),{Sound:to(t.sound||""),OPPOChannelID:n,GoogleChannelID:t.FCMChannelID||""})}function no(e){const{apnsInfo:t={},ignoreIOSBadge:s=!1,disableVoipPush:n}=e,o=!0===t.ignoreIOSBadge||!0===s?1:0;let i;return void 0!==n&&(i=!1===n?1:0),void 0!==t.disableVoipPush&&(i=!1===t.disableVoipPush?1:0),Object.assign(Object.assign({},t),{badgeMode:o,isVoipPush:i})}function oo(e){return Ut.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:no(e),AndroidInfo:so(e)}:null}function io(e){const{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:o,IsSyncMsg:i,MsgBody:r,MsgClientTime:a,MsgLifeTime:c,MsgRandom:l,MsgSeq:d,MsgTimeStamp:u,SendMsgControl:_,SupportMessageExtension:h,TinyId:g,MsgCheckResult:f,CloudCustomData:E,MsgVersion:p,MsgFlagBits:m,RevokerInfo:S}=e;let v,{From_Account:I,To_Account:C}=e;if(1===i){const e=C;C=I,I=e}if(S){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=S;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:i,clientTime:a,messageLifeTime:c,random:l,sequence:d,time:u,messageControlInfo:{excludedFromLastMessage:1===(null==_?void 0:_.NoLastMsg),excludedFromUnreadCount:1===(null==_?void 0:_.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:f,cloudCustomData:E,revokerInfo:v,messageVersion:p,messageFlagBits:m,readReceiptSentByPeer:o,elements:co(r)}}function ro(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,To_Account:a,MsgVersion:c,CloudCustomData:l}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,to:a,elements:co(s),messageVersion:c,cloudCustomData:l}}function ao(e){const{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:o,MsgClientTime:i,MsgRandom:r,MsgSeq:a,MsgTimeStamp:c,SendMsgControl:l,SupportMessageExtension:d,TinyId:u,ToGroupId:_,CloudCustomData:h,MsgVersion:g,MsgCheckResult:f,NeedReadReceipt:E,IsPlaceMsg:p,RevokerInfo:m,GroupAtInfo:S}=e;let v,I=qn.MSG_PRIORITY_NORMAL;if(Object.keys(Yn).includes(String(e.MsgPriority))&&(I=Yn[e.MsgPriority]),m){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}const C=function(e){const t=[];Array.isArray(e)&&e.forEach((e=>{e.GroupAtAllFlag===Kn?t.push(e.GroupAt_Account):e.GroupAtAllFlag===jn&&t.push(es.MSG_AT_ALL)}));return t}(S);return{clientSequence:t,from:s,groupProfile:n,clientTime:i,priority:I,random:r,sequence:a,time:c,messageControlInfo:{excludedFromLastMessage:1===(null==l?void 0:l.NoLastMsg),excludedFromUnreadCount:1===(null==l?void 0:l.NoUnread)},isSupportExtension:d,to:_,tinyID:u,cloudCustomData:h,messageVersion:g,messageCheckResult:f,needReadReceipt:E,isPlaceMessage:p,revokerInfo:v,atUserList:C,elements:co(o)}}function co(e){if(!e)return null;if(Array.isArray(e))return e.map((e=>{const t=Ut.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}));const t=Ut.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}function lo(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,GroupId:a,TopicId:c,MsgVersion:l,CloudCustomData:d}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,groupID:a,topicID:c,elements:co(s),messageVersion:l,cloudCustomData:d}}function uo({conversationUpdateFields:e,message:t}){const{conversationID:s,conversationType:n,conversationSubType:o,flow:i,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,c=a?"":t,l=!r&&i===Hn.IN;e.has(s)?(e.get(s).lastMessage=c,l&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:o,unreadCount:l?1:0,lastMessage:c})}var _o=Object.freeze({__proto__:null,autoIncrementIndex:Zn,parseServerGroupMessage:ao,parseServerPushC2CModifyMessage:ro,parseServerPushGroupModifyMessage:lo,parseServerPushMessage:io,parseServerPushMessageElement:co,updateConversationFields:uo});const{isPlainObject:ho}=Ut.utils;function go(e,t={}){const{onlineUserOnly:s,messageControlInfo:n}=t;let{offlinePushInfo:o}=t;e.conversationType===Vn.CONV_C2C&&!0===s&&(o?o.disablePush=!0:o={disablePush:!0});let i="";"string"==typeof e.cloudCustomData&&e.cloudCustomData.length>0&&(i=e.cloudCustomData);const r=[];if(n&&ho(n)){const{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&r.push("NoUnread"),!0===t&&r.push("NoLastMsg"),!0===s&&r.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:o}}function fo(e){const{webhookInfo:{disableCloudMessagePreHook:t=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(!t&&!s)return;const n=[];return t&&n.push("ForbidBeforeSendMsgCallback"),s&&n.push("ForbidAfterSendMsgCallback"),n}function Eo(e,t){return r(this,void 0,void 0,(function*(){const s=e.conversationType===Vn.CONV_GROUP?function(e,t){var s;const n=go(e,t),{onlineUserOnly:o,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:a}=n,c=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null===(s=Ut.store.get("login"))||void 0===s?void 0:s.userId,GroupId:e.to,MsgBody:c,CloudCustomData:i,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:o?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:oo(a),SendMsgControl:o?void 0:r,NeedReadReceipt:!0===e.needReadReceipt?1:0,receiverList:null,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:fo(t)}}}(e,t):function(e,t){var s;const n=go(e,t),{onlineUserOnly:o,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:a}=n,c=!0===o?0:void 0,l=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null===(s=Ut.store.get("login"))||void 0===s?void 0:s.userId,To_Account:e.to,MsgBody:l,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:c,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==c?r:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:oo(a),forbidCallbackControl:fo(t)}}}(e,t),n=Ut.common.generateProtocolData(s),o=`${n.head.seq}${n.head.servcmd}`,i=yield Ut.channel.sendPacket(n,{requestId:o});return i?{time:i.MsgTime,messageDropReason:i.MsgDropReason,sequence:i.MsgSeq}:null}))}const{isPlainObject:po}=Ut.utils,{MSG_AUDIO:mo,MSG_FILE:So,MSG_IMAGE:vo,MSG_VIDEO:Io,MSG_MERGER:Co}=es;class yo{init(){mn({apiName:"sendMessage",context:this,matcher:e=>![mo,So,vo,Io,Co].includes(e[0].type)})}sendMessage(e,t){return r(this,void 0,void 0,(function*(){const s=Ut.ssoLog.createSSOLogData({method:"sendMessage"});if(!(e instanceof Jn)){const e=new as({code:ts.MSG_INSTANCE_REQUIRED});throw s.setError(e).end(),e}const n=e.validateBeforeSend();if(!n.isValid){const{code:e,message:t=""}=n.error||{},o=new as({code:e,message:t});throw s.setError(o).end(),o}let o=!1;const{messageDataHandler:i}=Ut.message||{};try{const{messageControlInfo:n}=t||{};let r=null;if(i.addRandomOfSentMessage(e.random),e.conversationType===Vn.CONV_C2C?(o=!0===(null==t?void 0:t.onlineUserOnly),r=yield Eo(e,t)):e.conversationType===Vn.CONV_GROUP&&(r=yield Eo(e,t)),r){const{messageDropReason:a,sequence:c,time:l}=r;if(this._updateNickAndAvatarOfSentMessageByMe(e),a&&this._logRateLimitInfo(e,c),!0===e.isResend){const t=i.findMessage(e.ID);t&&(console.log(`sendMessage resend ok. ID:${t.ID}`),i.deleteConversationMessage(t))}return e.status=Yt.SUCCESS,e.time=l,e.conversationType===Vn.CONV_GROUP&&(e.sequence=c),o?e._onlineOnlyFlag=!0:(i.storeConversationMessage(e),this._applySentMessageControlInfo(e,n),this._emitOnlineMessageSent(e)),s.setLogInfo({message:`options: ${JSON.stringify(t)}`}).end(),{code:0,data:{message:e}}}}catch(t){e.status=Yt.FAIL,i.removeRandomOfSentMessage(e.random);const{errorCode:s,errorInfo:n=""}=t||{};this._hasRiskContent(s)&&(e.hasRiskContent=!0),o||this._isRejectedByRestApi(s)||i.storeConversationMessage(e);const r=new as({code:s,message:n,data:{message:e}});throw this._logSendMessageError({message:e,error:r}),r}}))}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return e>=10100&&e<=10200||e>=120001&&e<=13e4}_logSendMessageError({message:e,error:t}){const s=Ut.ssoLog.createSSOLogData({method:"sendMessage"});let n=`head.seq: type:${e.type} from:${e.from} to:${e.to}`;if(Ut.utils.IN_BROWSER){if("connection"in navigator){const e=navigator.connection;n+=` downlink:${e.downlink} effectiveType:${e.effectiveType} rtt:${e.rtt}`}if("memory"in window.performance){const e=window.performance.memory;n+=` usedJSHeapSize:${e.usedJSHeapSize} totalJSHeapSize:${e.totalJSHeapSize} jsHeapSizeLimit:${e.jsHeapSizeLimit}`}}s.setLogInfo({message:n}).setError(t).end()}_emitOnlineMessageSent(e){const t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e;Ut.notificationCenter.emitInnerEvent($t.NEW_MESSAGE,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&po(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0))}_logRateLimitInfo(e,t){const s=Ut.ssoLog.createSSOLogData({method:"messageDropReason"}),n=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:${messageDropReason}`;s.setLogInfo({message:n}).end(),console.warn(`sendMessage ${n}`)}_updateNickAndAvatarOfSentMessageByMe(e){const{messageDataHandler:t}=Ut.message||{};let s=!1;const{conversationID:n}=e,o=t.getLatestMsgSentByMe(n);if(o){const{nick:i,avatar:r}=o;i===e.nick&&r===e.avatar||(s=!0),s&&t.updateNickAndAvatarOfSentMessage({conversationID:n,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}}}class Mo{constructor(e){this.value=e,this.next=null}}class Oo{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();const t=new Mo(e);this.head?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),this.size+=1}delete(e){if(!this.head)return;if(this.head.value===e)return void(this.head=this.head.next);let t=this.head;for(;t.next;){if(t.next.value===e)return void(t.next=t.next.next);t=t.next}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,this.size-=1)}peek(){var e;return null===(e=this.head)||void 0===e?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}class To{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Oo(100),Ut.notificationCenter.subscribeInnerEvent($t.LOGOUT,this._reset,this),Ut.notificationCenter.subscribeInnerEvent($t.DESTROY,this._dispose,this)}get _messagesByConversation(){return ln.getMessages()}storeConversationMessage(e,t=!1){const{conversationID:s}=e;if(!s)return!1;if(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),this._shouldSkipStoreMessage(e,t))return!1;const n=this._getUniqueIdOfMessage(e);return this._messagesByConversation.get(s).set(n,e),this._updateLatestMessageMap(e),!0}_updateLatestMessageMap(e){const{conversationID:t}=e;"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){const s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null==n?void 0:n.has(s)){const e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var t;const{conversationID:s=""}=e,n=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(s)&&(null===(t=this._messagesByConversation.get(s))||void 0===t||t.delete(n))}modifyConversationMessage(e,t){var s;if(!this._messagesByConversation.has(e)&&!this._sparseMessagesByConversation.has(e))return{isUpdated:!1,message:null};const n=this._getUniqueIdOfMessage(t),o=this._getMessageFromLocalMessage(e,n);if(o){const{messageVersion:n,elements:i,cloudCustomData:r,checkResult:a=0}=t,c=a>1;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${o.version} remoteVersion:${n}`),o.version<n){const t=this._getUniqueIdOfMessage(o),a=_e(i);return(null===(s=this._messagesByConversation.get(e))||void 0===s?void 0:s.has(t))?ln.updateMessage(e,[t],{isModified:!0,version:n,_elements:a,payload:a[0].content,type:a[0].type,cloudCustomData:r,hasRiskContent:c,operation:Kt.modify}):(o.version=n,o._elements=a,o.payload=o._elements[0].content,o.type=o._elements[0].type,o.cloudCustomData=r,o.isModified=!0,o.hasRiskContent=c),{isUpdated:!0,message:o}}return{isUpdated:!1,message:o}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,t){var s;if(this._messagesByConversation.has(e))return null===(s=this._messagesByConversation.get(e))||void 0===s?void 0:s.get(t);if(this._sparseMessagesByConversation.has(e)){const s=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<s.length;e++)if(this._getUniqueIdOfMessage(s[e])===t)return s[e]}return null}findMessage(e){let t=null;const s=Array.from(this._messagesByConversation.values());for(const n of s){if(t=Array.from(n.values()).find((t=>t.ID===e))||null,t)break}if(!t){const s=Array.from(this._sparseMessagesByConversation.values());for(const n of s)if(t=n.get(e)||null,t)break}return t}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:e,sequence:t,random:s,revoker:n}){const o=this._messagesByConversation.get(e);let i=null;if(o){const r=Array.from(o.values());if(i=this._findMessageBySequenceAndRandom({messageList:r,random:s,sequence:t}),i){const t=this._getUniqueIdOfMessage(i);return ln.updateMessage(e,[t],{isRevoked:!0,revoker:n,operation:Kt.revoke}),i}}if(this._sparseMessagesByConversation.has(e)){const o=Array.from(this._sparseMessagesByConversation.get(e).values());if(i=this._findMessageBySequenceAndRandom({messageList:o,random:s,sequence:t}),i)return i.isRevoked=!0,i.revoker=n,i}}_findMessageBySequenceAndRandom({messageList:e,sequence:t,random:s}){for(let n=0;n<e.length;n+=1){const o=e[n];if(o.sequence===t&&(a(s)||o.random===s))return o}return null}prependLocalMessageList(e){const{messageList:t,conversationID:s}=e;if(0===t.length)return[];const n=[],o=[],i=this._messagesByConversation.get(s)||new Map;for(const e of t){const t=this._getUniqueIdOfMessage(e);i.has(t)||(n.push(e),o.push([t,e]))}if(o.length>0){const e=new Map([...o,...i.entries()]);this._messagesByConversation.set(s,e),this._updateLatestMessageSentByMe(s),this._updateLatestMessageSentByPeer(s)}return n}storeSparseMessageList(e){if(0===e.length)return;const{conversationID:t}=e[0],s=e.length;this._sparseMessagesByConversation.has(t)||this._sparseMessagesByConversation.set(t,new Map);const n=this._sparseMessagesByConversation.get(t);for(let t=0;t<s;t++){const s=e[t];n.has(s.ID)||n.set(s.ID,s)}}_updateLatestMessageSentByMe(e){var t;const s=Array.from((null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]);if(0!==s.length)for(let t=s.length-1;t>=0;t--)if("out"===s[t].flow){this._setLatestMsgSentByMe(e,s[t]);break}}_updateLatestMessageSentByPeer(e){var t;const s=Array.from((null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]);if(0!==s.length&&e.startsWith("C2C"))for(let t=s.length-1;t>=0;t--)if("in"===s[t].flow){this._setLatestMsgSentByPeer(e,s[t]);break}}_getUniqueIdOfMessage(e){const{from:t,to:s,random:n,sequence:o,time:i}=e;return`${t}-${s}-${n}-${o}-${i}`}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){const{conversationID:t="",latestAvatar:s,latestNick:n,isSentByMe:o=!0}=e,i=this._messagesByConversation.get(t);if(!i)return;const r=Array.from(i.values()),a=o?"out":"in";r.forEach((e=>{const{nick:t,avatar:o,flow:i}=e;i===a&&(t!==n&&(e.nick=n),o!==s&&(e.avatar=s))}))}isInMessageList(e){var t;const{conversationID:s}=e;if(!s)return!1;if(!this._messagesByConversation.has(s))return!1;const n=this._getUniqueIdOfMessage(e);return null===(t=this._messagesByConversation.get(s))||void 0===t?void 0:t.has(n)}isMessageSentByCurrentInstance(e){const{random:t}=e;return this._randomOfSentMessageList.has(t)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){const t=this._messagesByConversation.get(e);return t?[...t.values()]:[]}getSparseMessageList(e){const t=this._sparseMessagesByConversation.get(e);return t?[...t.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),Ut.notificationCenter.unSubscribeInnerEvent($t.LOGOUT,this._reset,this),Ut.notificationCenter.unSubscribeInnerEvent($t.DESTROY,this._dispose,this)}}function Ao(e,t){const s=an.getConversation(e);if(null==s?void 0:s.lastMessage){const{lastMessage:n}=s,{lastTime:o,lastSequence:i,version:r}=n,{time:a,sequence:c,messageVersion:l,elements:d,cloudCustomData:u}=t;o===a&&i===c&&r!==l&&(n.type=d[0].type,n.payload=d[0].content,n.messageForShow=As(n.type,n.payload),n.cloudCustomData=u,n.version=l,an.updateConversation(e,{lastMessage:n}))}}class No{init(){mn({apiName:"modifyMessage",context:this})}modifyMessage(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"modifyMessage"}),{to:s,payload:n,sequence:o,conversationType:i,random:a,time:c,from:l,type:d}=e;if(!this._canModifyMessageElement(d))return void t.setLogInfo({message:`can not modify message element. message type: ${d}`}).end();const u=e.getElements();u.length>1&&(u[0].type=d,u[0].content=n);try{let n=null,d=null;if(t.setLogInfo({message:`to:${s}`}),i===Vn.CONV_C2C?n=yield function(e){return r(this,void 0,void 0,(function*(){const t="openim.modify_c2c_msg",{from:s,to:n,version:o=0,sequence:i,random:r,time:a,type:c,cloudCustomData:l}=e,d=Ut.common.generateProtocolData({servcmd:t,data:{From_Account:s,To_Account:n,MsgVersion:o,MsgSeq:i,MsgRandom:r,MsgTime:a,MsgType:c,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:l}}),u=`${d.head.seq}${t}`,_=yield Ut.channel.sendPacket(d,{requestId:u});if(_){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=_;return{elements:co(e),messageVersion:t,cloudCustomData:s}}}))}(e):i===Vn.CONV_GROUP&&(n=yield function(e){return r(this,void 0,void 0,(function*(){const t="openim.modify_group_msg",{to:s,version:n=0,sequence:o,cloudCustomData:i}=e;let r,a=s;Ts(s)&&(a=s.split(Xt.TOPIC)[0],r=s);const c=Ut.common.generateProtocolData({servcmd:t,data:{GroupId:a,TopicId:r,MsgVersion:n,MsgSeq:o,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:i}}),l=`${c.head.seq}${t}`,d=yield Ut.channel.sendPacket(c,{requestId:l});if(d){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=d;return{elements:co(e),messageVersion:t,cloudCustomData:s}}}))}(e)),n){t.end();let r=`${i}${s}`;return s===ys()&&i===Vn.CONV_C2C&&(r=`${i}${l}`),d={conversationType:i,from:l,to:s,time:c,random:a,sequence:o,elements:null==n?void 0:n.elements,cloudCustomData:null==n?void 0:n.cloudCustomData,messageVersion:null==n?void 0:n.messageVersion,conversationID:r},this._handleModifyMessageSuccess(d),{code:0,data:{message:e}}}}catch(e){const{errorCode:t}=e||{},s=new as({functionName:"modifyMessage",code:t});throw this._logModifyMessageError(s),s}}))}_logModifyMessageError(e){Ut.ssoLog.getSSOLogData("modifyMessage").setError(e).end()}_handleModifyMessageSuccess(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Ut.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Ut.notificationCenter.emitOuterEvent(xt.MESSAGE_MODIFIED,{name:xt.MESSAGE_MODIFIED,data:[n]}),Ut.notificationCenter.emitInnerEvent($t.MESSAGE_MODIFIED,{conversationID:t,message:n}),Ao(t,e)}_canModifyMessageElement(e){return[Wn.MSG_TEXT,Wn.MSG_CUSTOM,Wn.MSG_LOCATION,Wn.MSG_FACE].includes(e)}}class Ro{init(){const{notificationCenter:e}=Ut,{InnerEventSubType:t}=e;Cs.registerWorkflowStep(ss.RECEIVE_C2C_NEW_MESSAGE,ns.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),Cs.registerWorkflowStep(ss.RECEIVE_C2C_NEW_MESSAGE,ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),Cs.registerWorkflowStep(ss.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent($t.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){Cs.executeWorkflow(ss.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){const t=e.data||{},{messageDataHandler:s}=Ut.message||{},n=[],o=new Map;return t.C2cMsgArray.forEach((e=>{const t=this._generateC2CMessage(e);this._updateMessageProfile(t);let i=1===t.isModified;if(s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t.isOnlineMessage())t._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(t)||n.push(t);else if(!s.isInMessageList(t)){s.storeConversationMessage(t)&&uo({conversationUpdateFields:o,message:t}),s.isMessageSentByCurrentInstance(t)&&!i||n.push(t)}})),{conversationUpdateFieldList:[...o.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var t;const{messages:s=[]}=(null===(t=e.result)||void 0===t?void 0:t[ns.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(s)}_emitMessageEventsAfterSyncUnreadMessage(e){var t;const{messages:s=[]}=(null===(t=e.result)||void 0===t?void 0:t[ns.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(s)}_emitMessageEvents(e){const t=(null==e?void 0:e.filter((e=>!0===(null==e?void 0:e.isModified))))||[];t.length>0&&Ut.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t});const s=null==e?void 0:e.filter((e=>!(null==e?void 0:e.isModified)));s.length>0&&Ut.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:s})}_generateC2CMessage(e){const t=Vn.CONV_C2C,s=io(e),n=Ut.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:Hn.IN})),{elements:o}=s;return n.setElement(o),n}_updateMessageProfile(e){var t;const{messageDataHandler:s}=Ut.message||{},n=null===(t=Ut.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:l=""}=e;if(o!==n){const t=s.getLatestMsgSentByPeer(l);if(t){const{nick:n,avatar:o}=t;a(i)||a(r)?(e.nick=c(n)?n:e.nick,e.avatar=c(o)?o:e.avatar):i===n&&r===o||(s.updateNickAndAvatarOfSentMessage({conversationID:l,latestNick:i,latestAvatar:r,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:l,nick:i,avatar:r}))}}else{const e=s.getLatestMsgSentByMe(l);!e||i===e.nick&&r===e.avatar||s.updateNickAndAvatarOfSentMessage({conversationID:l,latestNick:i,latestAvatar:r,isSentByMe:!0})}}_updateConversationUserProfile(e){const{conversationID:t,nick:s,avatar:n}=e,o=an.getConversation(t),{userProfile:i={}}=o||{};i.avatar===n&&i.nick===s||an.updateConversation(t,{userProfile:Object.assign(Object.assign({},i),{nick:s,avatar:n})})}_updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Ut.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Ut.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Ut.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),Ao(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach((e=>{var t;const s=Vn.CONV_C2C;let n=ro(e);const{to:o,from:i}=n;let r=`${s}${o}`;o===(null===(t=Ut.store.get("login"))||void 0===t?void 0:t.userId)&&(r=`${s}${i}`),n=Object.assign({conversationType:s,conversationID:r},n),this._updateMessageListDueToModify(n)}))}_dispose(){const{notificationCenter:e}=Ut,{InnerEventSubType:t}=e;Ut.notificationCenter.unSubscribeInnerEvent($t.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),Ut.notificationCenter.unSubscribeInnerEvent($t.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),Ut.notificationCenter.unSubscribeInnerEvent($t.DESTROY,this._dispose,this)}}class Do{init(){const{notificationCenter:e}=Ut,{InnerEventSubType:t}=e;Cs.registerWorkflowStep(ss.RECEIVE_GROUP_NEW_MESSAGE,ns.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),Cs.registerWorkflowStep(ss.RECEIVE_GROUP_NEW_MESSAGE,ns.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent($t.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){Cs.executeWorkflow(ss.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){const t=e.data||{},{messageDataHandler:s}=Ut.message,n=[],o=new Map,i=null==t?void 0:t.GroupMsgArray;return null==i||i.forEach((e=>{const t=this._generateGroupMessage(e);this.updateMessageProfile(t);let i=1===t.isModified;if(s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t.isOnlineMessage())t._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(t)||n.push(t);else if(!s.isInMessageList(t)){s.storeConversationMessage(t)&&(n.push(t),uo({conversationUpdateFields:o,message:t}))}})),{conversationUpdateFieldList:[...o.values()],messages:n}}_emitMessageEvents(e){var t;const{messages:s}=(null===(t=e.result)||void 0===t?void 0:t[ns.HANDLE_GROUP_NEW_MESSAGE])||{},n=(null==s?void 0:s.filter((e=>!0===(null==e?void 0:e.isModified))))||[];n.length>0&&Ut.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:n});const o=(null==s?void 0:s.filter((e=>!(null==e?void 0:e.isModified))))||[];o.length>0&&Ut.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:o})}_generateGroupMessage(e){const t=Vn.CONV_GROUP,s=ao(e),n=Ut.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:Hn.IN})),{elements:o}=s;return n.setElement(o),n}updateMessageProfile(e){var t;const{messageDataHandler:s}=Ut.message||{},n=null===(t=Ut.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:a=""}=e;if(o===n){const e=s.getLatestMsgSentByMe(a);!e||i===e.nick&&r===e.avatar||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!0})}}_updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Ut.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Ut.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Ao(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach((e=>{const t=Vn.CONV_GROUP;let s=lo(e);const{topicID:n,groupID:o}=s,i=n||o,r=`${t}${i}`;s=Object.assign({conversationType:t,conversationID:r,to:i},s),this._updateMessageListDueToModify(s)}))}_dispose(){const{notificationCenter:e}=Ut,{InnerEventSubType:{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}}=e;e.unSubscribeInnerEvent($t.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent($t.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent($t.DESTROY,this._dispose,this)}}class wo{constructor(){this.c2cMessageReceiver=new Ro,this.groupMessageReceiver=new Do}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}}const bo={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>function(e){var t;if("string"!=typeof(null==e?void 0:e.text)||"string"==typeof e.text&&0===(null===(t=null==e?void 0:e.text)||void 0===t?void 0:t.length))return"payload.text is invalid.";return!0}(e)}}};const ko={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};class Po{constructor(){this.messageHelper=_o,this.messageFactory=new eo,this.messageSender=new yo,this.messageAction=new No,this.messageReceiver=new wo,this.messageDataHandler=new To,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),ms({auth:ko,params:bo})}}const Lo="User",Uo="Tag_Profile_IM_",Go=100,Fo={NICK:`${Uo}Nick`,GENDER:`${Uo}Gender`,BIRTHDAY:`${Uo}BirthDay`,LOCATION:`${Uo}Location`,SELFSIGNATURE:`${Uo}SelfSignature`,ALLOWTYPE:`${Uo}AllowType`,LANGUAGE:`${Uo}Language`,AVATAR:`${Uo}Image`,MESSAGESETTINGS:`${Uo}MsgSettings`,ADMINFORBIDTYPE:`${Uo}AdminForbidType`,LEVEL:`${Uo}Level`,ROLE:`${Uo}Role`},xo="USER_STATUS",Bo=1,$o={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},Vo=new Map([[Fo.NICK,"nick"],[Fo.GENDER,"gender"],[Fo.BIRTHDAY,"birthday"],[Fo.LOCATION,"location"],[Fo.SELFSIGNATURE,"selfSignature"],[Fo.ALLOWTYPE,"allowType"],[Fo.LANGUAGE,"language"],[Fo.AVATAR,"avatar"],[Fo.MESSAGESETTINGS,"messageSettings"],[Fo.ADMINFORBIDTYPE,"adminForbidType"],[Fo.LEVEL,"level"],[Fo.ROLE,"role"]]);var qo=new class{createProfile(e,t){const s={userID:e,profileCustomField:[]};return t.forEach((e=>{const{tag:t,value:n}=e;t&&t.indexOf("Tag_Profile_Custom")>-1?s.profileCustomField.push({key:t,value:n}):Vo.has(t)&&(s[Vo.get(t)]=n)})),Object.assign(Object.assign({},$o),s)}parseProfileItem(e=[]){const t=[];return e.forEach((e=>{t.push({tag:e.Tag,value:e.Value})})),t}parseProfileList(e=[]){const t=[];return e.forEach((e=>{t.push({tag:e.Tag,value:e.ValueBytes})})),t}convertParamsToProfile(e){const t=[];return Object.keys(e).forEach((s=>{t.push({tag:Fo[s.toUpperCase()],value:e[s]})})),t}normalizeProfileFields(e){const t={};return e.forEach((e=>{const{tag:s,value:n}=e;if(Vo.has(s)){const e=Vo.get(s);t[e]=n}})),t}};const{generateProtocolData:Wo}=Ut.common;function Yo(e){return r(this,void 0,void 0,(function*(){const t="profile.portrait_get_all",s={From_Account:ys(),UserItem:[]};e.forEach((e=>{s.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})}));const n=Wo({servcmd:t,data:s}),o=`${n.head.seq}${t}`,i=yield Ut.channel.sendPacket(n,{requestId:o});if(i)return function(e){const{ActionStatus:t,ErrorCode:s,ErrorDisplay:n,ErrorInfo:o,UserProfileItem:i}=e,r=[];return i.map((e=>{const{To_Account:t,CustomSequence:s,ResultCode:n,ResultInfo:o,StandardSequence:i,ProfileItem:a}=e,c=qo.parseProfileItem(a);r.push({userId:t,customSequence:s,resultCode:n,resultInfo:o,standardSequence:i,profileItem:c})})),{actionStatus:t,errorCode:s,errorDisplay:n,errorInfo:o,userProfile:r}}(i)}))}function Ko(e){return dn.getFriendMap().has(e)}const{isEmpty:jo}=Ut.utils;class Ho{init(){mn({apiName:"getMyProfile",context:this}),mn({apiName:"getUserProfile",context:this}),mn({apiName:"updateMyProfile",context:this}),this.createProfile=qo.createProfile.bind(qo);const{notificationCenter:e}=Ut;Cs.registerWorkflowStep(ss.SYNC_SERVER_INFO_AFTER_LOGIN,ns.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent($t.LOGOUT,this._reset,this),e.subscribeInnerEvent($t.DESTROY,this._dispose,this)}getMyProfile(){return r(this,void 0,void 0,(function*(){const e=Ut.ssoLog.createSSOLogData({method:"getMyProfile"});try{const t=ys(),s=yield Yo([t]);if(s){const e=this._handleProfileFormResponse(s)[0];return dn.getUserProfileMap().set(t,e),{code:0,data:e}}e.end()}catch(t){const{errorCode:s,errorInfo:n}=t,o=new as({functionName:"getMyProfile",code:s,message:n});throw e.setError(o).end(),t}}))}getUserProfile(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"getUserProfile"});try{let{userIDList:s}=e;s.length>Go&&(s=s.slice(0,Go));const{userIdListToRequest:n,userIdListToCache:o}=this._filterRequestAndCacheUsers(s),i=[];o.forEach((e=>{const t=dn.getUserProfile(e);i.push(t)}));const r=`userIDList.length:${s.length}`;if(0===n.length)return t.setLogInfo({message:r}).end(),{code:0,data:i};const a=yield Yo(n);if(a){const e=this._handleProfileFormResponse(a);e.forEach((e=>{Ko(e.userID)&&dn.getUserProfileMap().set(e.userID,e)}));const s=e.concat(i);return t.setLogInfo({message:r}).end(),{code:0,data:s}}}catch(e){const{errorCode:s}=e,n=new as({functionName:"getUserProfile",code:s});throw t.setError(n).end(),n}}))}getMyProfileCacheThenServer(){return r(this,void 0,void 0,(function*(){const e=ys(),t=dn.getUserProfileMap().has(e);return t?{code:0,data:t}:this.getMyProfile()}))}updateMyProfile(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"updateMyProfile"}),s=ys(),n={};for(const t in e)void 0!==e[t]&&(n[t]=e[t]);const o=qo.convertParamsToProfile(n);try{const e={From_Account:s,ProfileItem:o};t.setLogInfo({message:JSON.stringify(o)}),yield function(e){return r(this,void 0,void 0,(function*(){const t="profile.portrait_set",s=Wo({servcmd:t,data:e}),n=`${s.head.seq}${t}`,o=yield Ut.channel.sendPacket(s,{requestId:n});if(o){const{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=o;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}}))}(e);const i=dn.getUserProfile(s);let a;a=i?Object.assign(Object.assign({},i),n):qo.createProfile(s,o);return!ds(i,a,["lastUpdatedTime","profileCustomField"])&&Ut.notificationCenter.emitOuterEvent(xt.PROFILE_UPDATED,{name:xt.PROFILE_UPDATED,data:[a]}),a.lastUpdatedTime=Date.now(),dn.getUserProfileMap().set(s,a),t.end(),{code:0,data:a}}catch(e){const{errorCode:s,errorInfo:n}=e,o=new as({functionName:"updateMyProfile",code:s,message:n});throw t.setError(o).end(),o}}))}updateMyNickAndAvatar(e){return r(this,void 0,void 0,(function*(){const t=ys(),s=Date.now(),n=dn.getUserProfile(t);let o={};o=n?Object.assign(n,e):qo.createProfile(t,e),o.lastUpdatedTime=s,dn.getUserProfileMap().set(t,o)}))}_onProfileDataModify(e){const t=function(e){const{Profile_Account:t,PushType:s,ProfileList:n}=e;return{userId:t,pushType:s,profileList:qo.parseProfileList(n)}}(e.ProfileDataMod[0]);if(jo(t))return;const{isProfileUpdated:s,profile:n}=this._handleProfileModified(t);s&&(Ut.notificationCenter.emitInnerEvent($t.PROFILE_UPDATE,{name:$t.PROFILE_UPDATE,data:[n]}),Ut.notificationCenter.emitOuterEvent(xt.PROFILE_UPDATED,{name:xt.PROFILE_UPDATED,data:[n]}))}_dispose(){const{notificationCenter:e}=Ut;e.unSubscribeInnerEvent($t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent($t.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent($t.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){const{userId:t,profileList:s}=e,n=dn.getUserProfile(t);if(!n||!Ko(t))return{isProfileUpdated:!1,profile:null};const o=qo.normalizeProfileFields(s),i=Object.keys(o).some((e=>n[e]!==o[e]));if(!i)return{isProfileUpdated:!1,profile:n};const r=Date.now(),a=Object.assign(Object.assign(Object.assign({},n),o),{lastUpdatedTime:r});return dn.getUserProfileMap().set(t,a),an.updateConversation(`C2C${t}`,{userProfile:a}),{isProfileUpdated:i,profile:a}}_filterRequestAndCacheUsers(e){const t=[],s=[];return e.forEach((e=>{const n=dn.getUserProfileMap().has(e);Ko(e)&&n?s.push(e):t.push(e)})),{userIdListToRequest:t,userIdListToCache:s}}_handleProfileFormResponse(e){const{userProfile:t}=e;if(!Array.isArray(t))return[];const s=t.filter((e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!jo(e.profileItem))),n=Date.now();return s.map((e=>{const t=qo.createProfile(e.userId,e.profileItem);return t.lastUpdatedTime=n,t}))}_reset(){dn.getUserProfileMap().clear()}}const zo=new Map,Zo=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=Zo.length;e<t;e++)zo.set(e,Zo[e]);function Jo(e){if(!e)return"";const t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let e,n,o=0,i=0;n=t.charAt(i++);~n&&(e=o%4?64*e+n:n,o++%4)?s+=String.fromCharCode(255&e>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);try{return decodeURIComponent(escape(s))}catch(e){return console.warn(e),""}}const{isEmpty:Xo}=Ut.utils,{generateProtocolData:Qo}=Ut.common;function ei(e){return r(this,void 0,void 0,(function*(){const t="im_open_status.ws_get_user_status",s=Qo({servcmd:t,data:{To_Account:e}}),n=`${s.head.seq}${t}`,o=yield Ut.channel.sendPacket(s,{requestId:n});if(o)return function(e){const{ErrorCode:t,ErrorInfo:s,ErrorList:n=[],UserStatusList:o=[]}=e,i=o.map((e=>{const{To_Account:t,Status:s,CustomStatus:n}=e;return{userID:t,statusType:s,customStatus:Jo(n)}})),r=n.map((e=>{const{To_Account:t,Invalid_Account:s,ErrorCode:n,ErrorInfo:o}=e;return{userID:Xo(s)?t:s,code:n,message:o}}));return{errorCode:t,errorInfo:s,successUserList:i,failureUserList:r}}(o)}))}class ti{constructor(){this._customStatus=""}init(){const{notificationCenter:e}=Ut;mn({apiName:"getUserStatus",context:this}),mn({apiName:"setSelfStatus",context:this}),mn({apiName:"subscribeUserStatus",context:this}),mn({apiName:"unsubscribeUserStatus",context:this}),Cs.registerWorkflowStep(ss.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ns.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent($t.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent($t.LOGOUT,this._reset,this),e.subscribeInnerEvent($t.DESTROY,this._dispose,this)}setSelfStatus(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"setSelfStatus"}),s=ys(),{customStatus:n}=e;try{return yield function(e){return r(this,void 0,void 0,(function*(){const t="im_open_status.ws_set_custom_status",s=Qo({servcmd:t,data:{CustomStatus:e}}),n=`${s.head.seq}${t}`,o=yield Ut.channel.sendPacket(s,{requestId:n});if(o){const{ErrorCode:e,ErrorInfo:t}=o;return{errorCode:e,errorInfo:t}}}))}(n),this._customStatus=n,t.setLogInfo({message:`customStatus: ${n}`}).end(),{code:0,data:{userID:s,statusType:Bo,customStatus:n}}}catch(e){const{errorCode:s,errorInfo:n}=e,o=new as({functionName:"setSelfStatus",code:s,message:n});throw t.setError(o).end(),o}}))}getUserStatus(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.createSSOLogData({method:"getUserStatus"}),{userIDList:s=[]}=e;return t.setLogInfo({moreMessage:`userIDList length: ${s.length}`}),this._isOnlyMeInArray(s)?this._getMyStatus():this._getUserStatus(s)}))}setCustomStatus(e){const t=Jo(e);this._customStatus=t}subscribeUserStatus(e){return r(this,void 0,void 0,(function*(){try{console.log(`${Lo} subscribeUserStatus options: `,e);const{userIDList:t=[]}=e;this._checkBusinessCapabilityBits("subscribeUserStatus");const s=this._getMaxUserCount("subscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return r(this,void 0,void 0,(function*(){const{channel:t}=Ut,s="im_open_status.ws_status_subscribe",n=Qo({servcmd:s,data:{To_Account:e}}),o=`${n.head.seq}${s}`;return yield t.sendPacket(n,{requestId:o})}))}(n);return{code:0,data:{failureUserList:this._parseResponse(o)}}}catch(e){throw console.error(`${Lo} subscribeUserStatus error:`,e),e}}))}unsubscribeUserStatus(e){return r(this,void 0,void 0,(function*(){try{console.log(`${Lo} unsubscribeUserStatus options: `,e),this._checkBusinessCapabilityBits("unsubscribeUserStatus");const{userIDList:t=[]}=e,s=this._getMaxUserCount("unsubscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return r(this,void 0,void 0,(function*(){const{channel:t}=Ut,s="im_open_status.ws_status_unsubscribe";let n={};n=0===e.length?{UnsubscribeAll:1}:{To_Account:e};const o=Qo({servcmd:s,data:n}),i=`${o.head.seq}${s}`;return yield t.sendPacket(o,{requestId:i})}))}(n);return{code:0,data:{failureUserList:this._parseResponse(o)}}}catch(e){throw console.error(`${Lo} unsubscribeUserStatus error:`,e),e}}))}_onUserStatusUpdate(e){const{UserStatusList:t=[]}=e||{},s=t.map((e=>{const{To_Account:t,Status:s,CustomStatus:n}=e;return{userID:t,statusType:s,customStatus:Jo(n)}}));this._emitUserStatusUpdatedEvent(s)}_onReOnline(e){const t=Jo(e.data.customStatus);if(this._customStatus===t)return;this._customStatus=t;const s={userID:ys(),statusType:Bo,customStatus:t};this._emitUserStatusUpdatedEvent(s)}_emitUserStatusUpdatedEvent(e){Ut.notificationCenter.emitOuterEvent(xt.USER_STATUS_UPDATED,{name:xt.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){const{ErrorList:t=[]}=e;return t.map((e=>{const{To_Account:t,Invalid_Account:s,ErrorCode:n,ErrorInfo:o}=e;return{userID:Ut.utils.isEmpty(s)?t:s,code:n,message:o}}))}_checkBusinessCapabilityBits(e){if(!Ut.store.get("commercialConfig").get(xo))throw new as({functionName:e,code:ts.NO_USE,replacement1:e})}_getMaxUserCount(e){const t=Ut.store.get("cloudConfig")||{},s={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:Go},unsubscribe:{key:"status_unsub_count",default:Go}},{key:n,default:o}=s[e],i=t[n]||o;return parseInt(i,10)}_getMyStatus(){const e=Ut.ssoLog.getSSOLogData("getUserStatus");e.setLogInfo({moreMessage:"getUserStatus._getMyStatus"});const t={userID:ys(),statusType:Bo,customStatus:this._customStatus};return e.end(),{code:0,data:{successUserList:[t],failureUserList:[]}}}_getUserStatus(e){return r(this,void 0,void 0,(function*(){const t=Ut.ssoLog.getSSOLogData("getUserStatus");t.setLogInfo({moreMessage:"getUserStatus._getUserStatus"});try{this._checkBusinessCapabilityBits("getUserStatus");const s=this._getMaxUserCount("query"),n=this._sliceUserIDList(e,s),o=yield ei(n),{successUserList:i,failureUserList:r}=o||{};return t.end(),{code:0,data:{successUserList:i,failureUserList:r}}}catch(e){const{errorCode:s}=e,n=new as({functionName:"getUserStatus",code:s});throw t.setError(n).end(),n}}))}_isOnlyMeInArray(e){const t=ys();return 1===e.length&&e.indexOf(t)>-1}_dispose(){const{notificationCenter:e}=Ut;e.unSubscribeInnerEvent($t.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent($t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent($t.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}const si={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},ni={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class oi{constructor(){this.userProfile=new Ho,this.userStatus=new ti,this.userProfile.init(),this.userStatus.init(),ms({auth:ni,params:si})}}console.log(`TencentCloudLiteChat.VERSION:${$e}`);var ii={create:function(e){const{SDKAppID:t,testEnv:s=!1,devMode:n=!1,unlimitedAVChatRoom:o=!1}=e;let i=t;if(!function(e){if("number"==typeof e)return!0;const t=Number(e);return!Number.isNaN(t)}(i))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(i=Number(i),Is.has(i))return Is.get(i);const r=function(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}();Ut.init({sdkAppId:i,instanceId:r,testEnv:s,devMode:n,unlimitedAVChatRoom:o}),Cs.init(),Ut.message=new Po,Ut.user=new oi,Ut.login=new $n,Ss.installBuiltInPlugin(nn);const a=In();return Is.set(i,a),a},TSignaling:Vt,EVENT:xt,VERSION:$e,TYPES:es};export{ii as default};
1
+ class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,s,n){s&&(this.listeners[e]=null==(e=this.listeners[e])?void 0:e.filter(e=>{var t=e.fn===s,e=!n||e.context===n;return!(t&&e)}))}emit(e,...s){e=this.listeners[e];e&&e.forEach(e=>{var{fn:e,context:t}=e;e.apply(t,s)})}once(t,s,n){let i=(...e)=>{s.apply(n,e),this.off(t,i)};this.on(t,i)}}let t={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},s=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var n;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(n=n||{});var o,c,i=Object.freeze({__proto__:null,get ConvModifyPushType(){return n},ENUM_PLATFORM:t,IS_TOPIC_MESSAGE:2,NOT_NEED_CRC_SERVCMD:s});function r(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_TIPS_NOTIFICATION):s.push(o.GROUP_TIPS_NOTIFICATION)}),s}!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message"}(o=o||{});let a=[{conditions:[{type:"event",value:100}],subType:o.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:o.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:o.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:o.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:o.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:o.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:o.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:o.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:o.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:o.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.C2cNotifyMsgArray)&&t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(o.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(o.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(o.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(o.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(o.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(o.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(o.TOPIC_MESSAGE_READ_SYNC):s.push(o.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(o.TOPIC_SYSTEM_NOTIFICATION):s.push(o.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:r},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.GroupTips)&&t.forEach(e=>{var e=e["GroupAtTips"]["TopicId"];e?s.push(o.TOPIC_AT_TIPS):s.push(o.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){let t,s=[];return null!=(t=null==e?void 0:e.RecentContactMod)&&t.forEach(e=>{switch(e.PushType){case n.CONV_MARK_UPDATED:s.push(o.CONVERSATION_MARK_UPDATED);break;case n.CONV_GROUP_ADDED:s.push(o.CONVERSATION_GROUP_ADD);break;case n.CONV_GROUP_DELETED:s.push(o.CONVERSATION_GROUP_DELETED);break;case n.CONV_GROUP_UPDATED:s.push(o.CONVERSATION_GROUP_UPDATED);break;default:s.push(o.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:o.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:o.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:o.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:o.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:o.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:o.ALL_MESSAGE_READ}];function l(n){let e,t=Array.isArray(null==(e=null==n?void 0:n.body)?void 0:e.EventArray)?n.body.EventArray:[],i=[];return t.forEach(t=>{t.Flag=n.body.Flag;var e=a.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!e)return null;let s=[];"function"==typeof e.subTypeParser?s=e.subTypeParser(t):e.subType&&(s=e.subType),Array.isArray(s)?s.forEach(e=>{i.push({type:c.SERVER_PUSH_MESSAGE+":"+e,data:t})}):i.push({type:c.SERVER_PUSH_MESSAGE+":"+s,data:t})}),i}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(c=c||{});let d={[c.SERVER_PUSH_MESSAGE]:l,[c.SERVER_PUSH_MESSAGE_MULTIPLE]:l,[c.ERROR]:function(e){var t=e["errorCode"];return[{type:"error:"+t,data:e}]}},u=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=o}subscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.on(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.on(s,e,i)}}emitInnerEvent(t,s){var e;if(null!=(e=this._innerEventEmitter)&&e.emit(t,s),Object.keys(d).includes(t)){let e=null==(t=d[t])?void 0:t.call(d,s);null!=e&&e.forEach(e=>{var t;e&&null!=(t=this._innerEventEmitter)&&t.emit(e.type,e.data)})}}unSubscribeInnerEvent(s,n,i,o){var r,t;if(["string","number"].includes(typeof n)){let e=n,t=i;null!=(r=this._innerEventEmitter)&&r.off(s+":"+e,t,o)}else{let e=n;null!=(t=this._innerEventEmitter)&&t.off(s,e,i)}}subscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null!=(n=this._outerEventEmitter)&&n.off(e,t,s)}emitOuterEvent(e,t){var s;null!=(s=this._outerEventEmitter)&&s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function _(e,t){var s={};for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}function h(e,r,a,l){return new(a=a||Promise)(function(s,t){function n(e){try{o(l.next(e))}catch(e){t(e)}}function i(e){try{o(l.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?s(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,i)}o((l=l.apply(e,r||[])).next())})}let g=e=>void 0===e,p=e=>"string"==typeof e,E=e=>{return null==(e=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))?void 0:e[1].toLowerCase()},f=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===E(e),m=e=>null!==e&&"object"==typeof e,S=e=>f(e)||m(e),v=e=>{return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},I=e=>{if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t};function C(e=99999999){return Math.round(Math.random()*e)}let M=(s,n,i,o)=>{if(!S(s)||!S(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(S(s[a])&&S(n[a]))r+=M(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r};function O(s){let n,i,o=s,r="";for(let e=0,t=(o=s.length%8!=0?"0".repeat(8-s.length%8)+s:o)["length"];e<t;e+=8)n=parseInt(o.slice(e,e+4),2),i=parseInt(o.slice(e+4,e+8),2),r+=base16Map.get(n)+base16Map.get(i);return r}let T="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),y="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||T,A=y&&"function"==typeof wx.createGamePortal,R="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,L="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,b=y&&"object"==typeof wx.miniapp,k="undefined"!=typeof uni,U=y||R||N||D||P||L||w,G="undefined"==typeof window&&!U&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,F="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),x="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),V="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!F,B=R?qq:N?tt:D?swan:P?my:y?wx:L?uni:w?jd:{},$=V&&window&&window.navigator&&window.navigator.userAgent||"",q=/(micromessenger|webbrowser)/i.test($),W=function(){let e="WEB";return q?e="WEB":R?e="QQ_MP":N?e="TT_MP":D?e="BAIDU_MP":P?e="ALI_MP":y?e=b?"DONUT_NATIVE_APP":"WX_MP":L?e="UNI_NATIVE_APP":G?e="NS_NATIVE_APP":F&&(e="RN_NATIVE_APP"),t[e]}(),Y=/iPad/i.test($),K=/iPhone/i.test($)&&!Y,H=/iPod/i.test($),j=K||Y||H,z=function(){var e=$.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Z=/Android/i.test($),J=function(){var e,t,s=$.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),X=/Firefox/i.test($),Q=/Edge/i.test($),ee=!Q&&/Chrome/i.test($),te=/MSIE/.test($)||-1<$.indexOf("Trident")&&-1<$.indexOf("rv:11.0"),se=function(){var e=/MSIE\s(\d+)\.\d/.exec($);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test($)&&/rv:11.0/.test($)?11:t}(),ne=/Safari/i.test($)&&!ee&&!Z&&!Q,oe=/Windows/i.test($),ie=/MAC OS X/i.test($),re=V&&"undefined"!=typeof Worker&&!te,ae=Z||j,ce=V&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,le=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator["standalone"],!(!j||e||ne))}();function de(){let e="unknown";if(ie&&(e="mac"),oe&&(e="windows"),j&&(e="ios"),Z&&(e="android"),U)try{var t=wx.getSystemInfoSync()["platform"];void 0!==t&&(e=t)}catch(e){console.error(e)}return e}let ue=2800,_e=2801,he=3e3,ge="application/x-www-form-urlencoded;charset=UTF-8";function pe(e){return h(this,arguments,void 0,function*({method:i,url:o,data:r,timeout:a=he}){return new Promise(U?(t,e)=>{B.request({url:o,data:r,method:i,timeout:a,header:{"content-type":ge},success:e=>t(e.data),fail:()=>e(new Error(`{"message":"Network error","code":${ue}}`))})}:(t,e)=>{let s=new XMLHttpRequest,n=setTimeout(()=>{s.abort(),e(new Error(`{"message":"Request timeout","code":${_e}}`))},a);s.onreadystatechange=function(){if(4===s.readyState)if(clearTimeout(n),200===s.status||304===s.status)try{t(s.responseText?JSON.parse(s.responseText):null)}catch(e){t(s.responseText)}else e(new Error(`{"message":"Network error","code":${ue}}`))},s.open(i,o,!0),s.setRequestHeader("Content-type",ge),s.send(r||null)})})}function Ee(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(I(e)){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return("[object Map]"===Object.prototype.toString.call(e)||"[object Set]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e))&&0===e.size}function fe(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(fe(t),fe(e))}),s}if(n instanceof Set){let t=new Set;return n.forEach(e=>{t.add(fe(e))}),t}if(Array.isArray(n))return n.map(e=>fe(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]=fe(n[e]))}),s}function me(){let s,n;return{promise:new Promise((e,t)=>{s=e,n=t}),resolve:s,reject:n}}var Se=Object.freeze({__proto__:null,ANDROID_VERSION:J,IE_VERSION:se,IN_ALIPAY_MINI_APP:P,IN_BAIDU_MINI_APP:D,IN_BROWSER:V,IN_DONUT_NATIVE_APP:b,IN_JD_MINI_APP:w,IN_MINI_APP:U,IN_NS_NATIVE_APP:G,IN_QQ_MINI_APP:R,IN_RN_APP:F,IN_TT_MINI_APP:N,IN_UNI_APP:k,IN_UNI_NATIVE_APP:L,IN_WX_MINI_APP:y,IN_WX_MINI_APP_DESK:T,IN_WX_MINI_GAME:A,IN_WX_MINI_PLUGIN:x,IOS_VERSION:z,IS_ANDROID:Z,IS_CHROME:ee,IS_EDGE:Q,IS_FIREFOX:X,IS_IE:te,IS_IOS:j,IS_IPAD:Y,IS_IPHONE:K,IS_IPOD:H,IS_MAC:ie,IS_SAFARI:ne,IS_WECHAT:q,IS_WIN:oe,IS_WORKER_AVAILABLE:re,MINI_APP_NAMESPACE:B,USER_AGENT:$,base16EncodeBinaryString:O,deepCopyWithMethods:fe,deepMerge:M,generatePromise:me,getPlatformType:de,getType:E,httpRequest:pe,isArray:f,isArrayOrObject:S,isEmpty:Ee,isFlutterWeb:ce,isH5:ae,isIOSWebView:le,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(+e)||"object"==typeof e&&e.constructor===Number),isObject:m,isPlainObject:I,isString:p,isUndefined:g,isValidRequestKey:v,platform:W,randomInt:C,randomString:function(){let t="";for(let e=32;0<e;--e)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t}});class ve{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t;try{null!=(t=this._socket)&&t.send(e)}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=e,this._socket.onmessage=t,this._socket.onclose=s,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class Ie{connectSocket(e){return this._socket=wx.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null!=(t=this._socket)&&t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){var{onOpen:e,onMessage:t,onClose:s,onError:n,onSendFail:i}=e;this._socket.onClose(s),this._socket.onOpen(e),this._socket.onMessage(t),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}let Ce="CONNECT",Me="SEND",Oe="DISCONNECT",Te="OPEN",ye="MESSAGE",Ae="CLOSE",Re="ERROR",Ne="SEND_FAIL";class De{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){var t=new Blob(["\n let _socket = null;\n\n self.onmessage = (event) => {\n const { type, url, data } = event.data;\n\n switch (type) {\n case 'CONNECT':\n connectSocket(url);\n break;\n case 'SEND':\n send(data);\n break;\n case 'DISCONNECT':\n disconnect();\n break;\n }\n };\n\n function connectSocket(url) {\n _socket = new WebSocket(url);\n _socket.binaryType = 'arraybuffer';\n bindSocketHandlers();\n return _socket;\n }\n\n function send(packet) {\n try {\n _socket?.send(packet);\n } catch (error) {\n self.postMessage({\n type: 'SEND_FAIL', \n error: {\n message: error.message,\n name: error.name,\n },\n });\n }\n }\n\n function bindSocketHandlers() {\n if (_socket) {\n _socket.onopen = (event) => {\n self.postMessage({\n type: 'OPEN',\n data: {\n type: event.type,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onmessage = (event) => {\n self.postMessage({ \n type: 'MESSAGE',\n data: event.data,\n });\n };\n\n _socket.onclose = (event) => {\n self.postMessage({ \n type: 'CLOSE', \n data: { \n code: event.code,\n reason: event.reason,\n timeStamp: event.timeStamp,\n },\n });\n };\n\n _socket.onerror = (error) => {\n self.postMessage({\n type: 'ERROR',\n data: {\n message: error.message,\n name: error.name\n },\n });\n };\n }\n }\n\n function unbindSocketHandlers() {\n if (_socket) {\n _socket.onopen = null;\n _socket.onmessage = null;\n _socket.onclose = null;\n _socket.onerror = null;\n }\n }\n\n function disconnect() {\n if (_socket) {\n _socket.close();\n _socket = null;\n }\n }\n"],{type:"application/javascript"});this._worker=new Worker(URL.createObjectURL(t)),this._worker.postMessage({type:Ce,url:e})}send(e){var t;try{null!=(t=this._worker)&&t.postMessage({type:Me,data:e})}catch(e){null!=(t=this._onSendFail)&&t.call(this,e)}}bindSocketHandlers(e){var{onOpen:t,onMessage:n,onClose:i,onError:o,onSendFail:r}=e;if(this._worker){let s={[Te]:t,[ye]:n,[Ae]:i,[Re]:o,[Ne]:r};this._onSendFail=r,this._worker.onmessage=e=>{var t=((null==e?void 0:e.data)||{})["type"];"function"==typeof s[t]&&null!=(t=s[t])&&t.call(s,null==e?void 0:e.data)}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Oe}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Pe,we=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return U?P?my.getStorageSync({key:e}).data:B.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){var s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){U?P?my.setStorageSync({key:e,data:JSON.stringify(t)}):B.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(Pe=Pe||{});class Le{constructor(t){this._url="",this._readyState=Pe.DISCONNECTED,this._url=t,this._id=C(),this._emitter=new e,y?this._socket=new Ie:this._canUseWebWorker()?this._socket=new De:this._socket=new ve,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Pe.CONNECTED,Pe.CONNECTING].includes(this._readyState)||(this._readyState=Pe.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Pe.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Pe.CONNECTED,Pe.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===Pe.CONNECTED}disconnect(){this._readyState=Pe.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Pe.CONNECTING&&(this._readyState=Pe.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Pe.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){var e=we.get("cloudConfig")||{};return(g(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&re}}let be="CHINA",ke="OVERSEA",Ue="SINGAPORE",Ge="KOREA",Fe="GERMANY",xe="IND",Ve="JPN",Be="USA",$e="INDONESIA",qe={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},We={[Ue]:[[2e7,3e7],[172e7,173e7]],[Ge]:[[3e7,4e7],[173e7,174e7]],[Fe]:[[4e7,5e7],[174e7,175e7]],[xe]:[[5e7,6e7],[175e7,176e7]],[Ve]:[[6e7,7e7],[176e7,177e7]],[Be]:[[7e7,8e7],[177e7,178e7]],[$e]:[[8e7,9e7],[178e7,179e7]]};function Ye(t){var e;if(null!=(e=we.get("instance"))&&e.oversea)return ke;for(let e of Object.keys(We))for(var[s,n]of We[e])if(t>=s&&t<n)return e;return be}var Ke,He="1.4.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(Ke=Ke||{});let je=Ke.INITIAL;function ze(){var e=Math.random();return 0===e?ze():e}function Ze(e,t){var s,{isBinary:t=!1}=t||{},{sdkAppId:n,instanceId:i}=we.get("instance"),o=ze(),r=de(),a=function(){var e=de();let t=-1;return"ios"===e?t=z||-1:"android"===e&&(t=J||-1),t}(),n=(s={sdkappid:n,instanceid:i,random:o,platform:W,host:r,version:a,sdkversion:He},Object.keys(s).map(e=>e+"="+s[e]).join("&"));return t?e+`/binfo?${n}&compress=gzip`:e+"/info?"+n}var Je=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){var s=Date.now();this._timeOffsetWithServer=t+(s-e)-s}};let Xe=16;var Qe=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){var t=e["id"];this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){var{id:e,callback:t,context:s,isOnce:n=!1,intervalMs:i=Xe}=e,o=Math.max(i,Xe);return{id:e,nextExecuteTime:Date.now()+o,intervalMs:i,callback:t,context:s,isOnce:n}}addTask(e){e=this._createTask(e);this._addTaskToScheduler(e)}addOnceTask(e){e=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(e)}removeTask(t){var e=this._tasks.findIndex(e=>e.id===t);-1<e&&(this._tasks.splice(e,1),this._taskMap.delete(t),this._scheduleNextTask())}updateTaskInterval(e,t){e=this._taskMap.get(e);e&&(e.intervalMs=t,e.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);var e=this._tasks[0];e&&(e=Math.max(0,e.nextExecuteTime-Date.now()),this._timer=setTimeout(()=>this._execute(),e))}_execute(){for(var e=Date.now();this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){var t=this._tasks[0];try{t.context?t.callback.call(t.context):t.callback(),t.isOnce?this.removeTask(t.id):(t.nextExecuteTime=e+t.intervalMs,this._sort())}catch(e){console.warn(`Task ${t.id} execution failed:`,e),t.isOnce&&this.removeTask(t.id)}}this._scheduleNextTask()}};function et(t){var s=[];for(let e=0;e<t.length;e+=1){var n,i=t.charCodeAt(e);55296<=i&&i<=56319?(n=t.charCodeAt(++e)-56320+(i-55296<<10)+65536,s.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)):i<=127?s.push(i):i<=2047?s.push(192|i>>6,128|63&i):s.push(224|i>>12,128|i>>6&63,128|63&i)}return new Uint8Array(s)}function st(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&v(t)&&null!=e[t]&&(null===e[t]||"object"!=typeof e[t]?s[t]=e[t]:s[t]=st(e[t]));return s}function nt(e,t){if(s.includes(e))return 0;var n=et(JSON.stringify(t));let i=4294967295;var o=n["length"];for(let e=0;e<o;e++){i^=n[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return(4294967295^i)>>>0}function ot(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,tjgID:"",seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}}function it(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}}let rt=C();function at(){return rt=rt<2415919103?rt+1:C()}function ct(){var e=we.get("login")||{},t=we.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.4.0",tiny_id:Number(e.tinyID),user_id:e.userId,platform:W,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var lt,ht,dt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){var t,{servcmd:e,data:s}=e,n=(n=e,t=we.get("login")||{},i=we.get("instance")||{},{servcmd:n,ver:"v4",platform:W,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:i.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:O(""),cappid:t.cappid||0,seq:at(),cs:0}),i=st(s);return n.cs=nt(e,i),{head:n,body:i}},generateProtocolData:ot,generateSSOLogProtocolData:it,generateSequence:at,getCommonHead:ct,taskScheduler:Qe,timeManager:Je});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(lt=lt||{});let ut={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class _t{constructor(e){this.level=lt.info,this._canSendLog=!0,this._logCreatedAt=Je.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=void 0;var{method:e,eventType:t=0,uiPlatform:s,message:n}=e||{};this.eventType=t,this.method=e,this.uiPlatform=s,this.message=n||""}setMoreMessage(e){this.moreMessage=this.moreMessage+" "+e}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Je.getTimeOffsetWithServer()}end(e=!1){var t;this._canSendLog&&(t=Je.getServerTimeMs(),0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:`+t),e?(this._canSendLog=!1,this.timestamp=Je.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout(()=>{this._canSendLog=!1,this.timestamp=Je.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())},0))}setError(e){var t;return e instanceof Error?this._canSendLog&&(null!=(t=we.get("netWorkMonitor"))&&t.isNetworkOnline&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage)&&this.setMoreMessage(e.errorMessage),this.level=lt.error):console.warn("SSOLogData.setError value not instanceof Error, please check!"),this}setLogInfo(t){return Object.keys(t).forEach(e=>{Object.keys(ut).includes(e)&&(this[e]=t[e])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){let t={};return Object.keys(this).forEach(e=>{ut[e]&&(t[ut[e]]=this[e])}),t}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(ht=ht||{});var gt=ht;let pt=20,Et=6e4,ft=[4,5,6],mt=[],St=[],vt="report-logger";var It=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=pt,this._maxThreshold=100,this._waitingTime=Et,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,u.subscribeInnerEvent(gt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Qe.addTask({id:vt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){var{evt_rpt_threshold:e=pt,evt_rpt_waiting:t=Et,evt_rpt_level:s=ft,evt_rpt_sdkappid_bl:n=mt,evt_rpt_tinyid_wl:i=St}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=t,this._minThreshold=e,this._reportLevel=s,this._tinyIdWhiteList=i}createSSOLogData(e){var t=new _t(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately())&&this.uploadSSOLogData()}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&0<this._logQueue.length&&this.uploadSSOLogData()}uploadSSOLogData(){return h(this,void 0,void 0,function*(){var e,t;0!==this._logQueue.length&&(t=this._logQueue.slice(),t=this._filterLogs(t),this._logQueue=[],0===t.length||Ee((t={Header:ct(),Event:t}).Header.user_id)||(e=(t=it({servcmd:e="imopenstat.tim_web_report_v2",data:t})).head.seq+e,yield void Bt.sendPacket(t,{requestId:e})),this._lastReportAt=Date.now())})}_savePlatFormInfo(){var e,t;if(y){var s=null==(t=null==(e=wx.getAccountInfoSync)?void 0:e.call(wx))?void 0:t.miniProgram;if(s){let{appId:e,envVersion:t}=s;we.set("instance",{appId:e,envVersion:t})}}else V&&we.set("instance",{href:window.location.href})}_filterLogs(e){var t=(we.get("login")||{})["tinyID"],s=(we.get("instance")||{})["sdkAppId"];return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}reset(){console.log("SSO_LOG_MODULE.reset"),Qe.removeTask(vt),u.unSubscribeInnerEvent(gt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=pt,this._maxThreshold=100,this._waitingTime=Et,this._logQueue=[]}};let Ct=15e3,Mt="Channel",Ot="channel_schedule_task",Tt="channel_reconnect_task",yt="connected",At="connecting",Rt="disconnected",Nt=500,Dt="network_status_change",Pt="activity_status_change",wt="send_fail",Lt="reconnect_failed",bt="socket_error",kt="socket_close";function Ut(e){return(Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Gt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ft,qt,xt={exports:{}},Vt=(Ft||(xt.exports=function s(n,i,o){function r(t,e){if(!i[t]){if(!n[t]){if(!e&&Gt)return Gt(t);if(a)return a(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e=i[t]={exports:{}};n[t][0].call(e.exports,function(e){return r(n[t][1][e]||e)},e,e.exports,s,n,i,o)}return i[t].exports}for(var a=Gt,e=0;e<o.length;e++)r(o[e]);return r}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array,i=(s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var i=n.shift();if(i){if("object"!=Ut(i))throw new TypeError(i+"must be non-object");for(var o in i)t=i,s=o,Object.prototype.hasOwnProperty.call(t,s)&&(e[o]=i[o])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)},{arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){for(var t,s,n,i,o=t=0,r=e.length;o<r;o++)t+=e[o].length;for(i=new Uint8Array(t),o=s=0,r=e.length;o<r;o++)n=e[o],i.set(n,s),s+=n.length;return i}}),o={arraySet:function(e,t,s,n,i){for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(n)},{}],2:[function(e,t,s){var l=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var c=new l.Buf8(256),n=0;n<256;n++)c[n]=252<=n?6:248<=n?5:240<=n?4:224<=n?3:192<=n?2:1;function u(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(e,t));for(var s="",n=0;n<t;n++)s+=String.fromCharCode(e[n]);return s}c[254]=c[254]=1,s.string2buf=function(e){for(var t,s,n,i,o=e.length,r=0,a=0;a<o;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),r+=s<128?1:s<2048?2:s<65536?3:4;for(t=new l.Buf8(r),a=i=0;i<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<o&&56320==(64512&(n=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(n-56320),a++),s<128?t[i++]=s:(s<2048?t[i++]=192|s>>>6:(s<65536?t[i++]=224|s>>>12:(t[i++]=240|s>>>18,t[i++]=128|s>>>12&63),t[i++]=128|s>>>6&63),t[i++]=128|63&s);return t},s.buf2binstring=function(e){return u(e,e.length)},s.binstring2buf=function(e){for(var t=new l.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){for(var s,n,i,o=t||e.length,r=new Array(2*o),a=s=0;a<o;)if((n=e[a++])<128)r[s++]=n;else if(4<(i=c[n]))r[s++]=65533,a+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&a<o;)n=n<<6|63&e[a++],i--;1<i?r[s++]=65533:n<65536?r[s++]=n:(n-=65536,r[s++]=55296|n>>10&1023,r[s++]=56320|1023&n)}return u(r,s)},s.utf8border=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+c[e[s]]>t?s:t}},{"./common":Ft=1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var i=65535&e,o=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;o=o+(i=i+t[n++]|0)|0,--r;);i%=65521,o%=65521}return i|o<<16}},{}],4:[function(e,t,s){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,s){var a=function(){for(var e=[],t=0;t<256;t++){for(var s=t,n=0;n<8;n++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}();t.exports=function(e,t,s,n){var i=a,o=n+s;e^=-1;for(var r=n;r<o;r++)e=e>>>8^i[255&(e^t[r])];return~e}},{}],6:[function(e,t,s){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,o,r,a,l=e.state,c=e.next_in,u=e.input,d=c+(e.avail_in-5),_=e.next_out,h=e.output,g=_-(t-e.avail_out),p=_+(e.avail_out-257),E=l.dmax,m=l.wsize,S=l.whave,f=l.wnext,v=l.window,I=l.hold,C=l.bits,M=l.lencode,O=l.distcode,T=(1<<l.lenbits)-1,y=(1<<l.distbits)-1;e:do{for(C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=M[I&T];;){if(I>>>=n=s>>>24,C-=n,0==(n=s>>>16&255))h[_++]=65535&s;else{if(!(16&n)){if(!(64&n)){s=M[(65535&s)+(I&(1<<n)-1)];continue}if(32&n){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(i=65535&s,(n&=15)&&(C<n&&(I+=u[c++]<<C,C+=8),i+=I&(1<<n)-1,I>>>=n,C-=n),C<15&&(I+=u[c++]<<C,C+=8,I+=u[c++]<<C,C+=8),s=O[I&y];;){if(I>>>=n=s>>>24,C-=n,!(16&(n=s>>>16&255))){if(!(64&n)){s=O[(65535&s)+(I&(1<<n)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(o=65535&s,C<(n&=15)&&(I+=u[c++]<<C,(C+=8)<n)&&(I+=u[c++]<<C,C+=8),E<(o+=I&(1<<n)-1)){e.msg="invalid distance too far back",l.mode=30;break e}if(I>>>=n,C-=n,(n=_-g)<o){if(S<(n=o-n)&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=v,(r=0)===f){if(r+=m-n,n<i){for(i-=n;h[_++]=v[r++],--n;);r=_-o,a=h}}else if(f<n){if(r+=m+f-n,(n-=f)<i){for(i-=n;h[_++]=v[r++],--n;);if(r=0,f<i){for(i-=n=f;h[_++]=v[r++],--n;);r=_-o,a=h}}}else if(r+=f-n,n<i){for(i-=n;h[_++]=v[r++],--n;);r=_-o,a=h}for(;2<i;)h[_++]=a[r++],h[_++]=a[r++],h[_++]=a[r++],i-=3;i&&(h[_++]=a[r++],1<i)&&(h[_++]=a[r++])}else{for(r=_-o;h[_++]=h[r++],h[_++]=h[r++],h[_++]=h[r++],2<(i-=3););i&&(h[_++]=h[r++],1<i)&&(h[_++]=h[r++])}break}}break}}while(c<d&&_<p);c-=i=C>>3,I&=(1<<(C-=i<<3))-1,e.next_in=c,e.next_out=_,e.avail_in=c<d?d-c+5:5-(c-d),e.avail_out=_<p?p-_+257:257-(_-p),l.hold=I,l.bits=C}},{}],8:[function(e,t,s){var P=e("../utils/common"),w=e("./adler32"),L=e("./crc32"),b=e("./inffast"),k=e("./inftrees"),U=0,G=-2,F=1,n=852,i=592;function x(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function o(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new P.Buf16(320),this.work=new P.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function r(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=F,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new P.Buf32(n),t.distcode=t.distdyn=new P.Buf32(i),t.sane=1,t.back=-1,U):G}function a(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,r(e)):G}function l(e,t){var s,n;return!e||!e.state||(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?G:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,a(e))}function c(e,t){var s;return e?(s=new o,(e.state=s).window=null,(s=l(e,t))!==U&&(e.state=null),s):G}var V,B,q=!0;function $(e,t,s,n){var i,e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new P.Buf8(e.wsize)),n>=e.wsize?(P.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):(n<(i=e.wsize-e.wnext)&&(i=n),P.arraySet(e.window,t,s-n,i,e.wnext),(n-=i)?(P.arraySet(e.window,t,s-n,n,0),e.wnext=n,e.whave=e.wsize):(e.wnext+=i,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=i))),0}s.inflateReset=a,s.inflateReset2=l,s.inflateResetKeep=r,s.inflateInit=function(e){return c(e,15)},s.inflateInit2=c,s.inflate=function(e,t){var s,n,i,o,r,a,l,c,u,d,_,h,g,p,E,m,S,f,v,I,C,M,O,T,y=0,A=new P.Buf8(4),R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return G;12===(s=e.state).mode&&(s.mode=13),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,d=a,_=l,M=U;e:for(;;)switch(s.mode){case F:if(0===s.wrap)s.mode=13;else{for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(2&s.wrap&&35615===c)A[s.check=0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0),u=c=0,s.mode=2;else if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31)e.msg="incorrect header check",s.mode=30;else if(8!=(15&c))e.msg="unknown compression method",s.mode=30;else{if(u-=4,C=8+(15&(c>>>=4)),0===s.wbits)s.wbits=C;else if(C>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<C,e.adler=s.check=1,s.mode=512&c?10:12,u=c=0}}break;case 2:for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(s.flags=c,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=c>>8&1),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0,s.mode=3;case 3:for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.head&&(s.head.time=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,s.check=L(s.check,A,4,0)),u=c=0,s.mode=4;case 4:for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.head&&(s.head.xflags=255&c,s.head.os=c>>8),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0,s.mode=5;case 5:if(1024&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.length=c,s.head&&(s.head.extra_len=c),512&s.flags&&(A[0]=255&c,A[1]=c>>>8&255,s.check=L(s.check,A,2,0)),u=c=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=a<(h=s.length)?a:h)&&(s.head&&(C=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),P.arraySet(s.head.extra,n,o,h,C)),512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.name+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break e;for(h=0;C=n[o+h++],s.head&&C&&s.length<65536&&(s.head.comment+=String.fromCharCode(C)),C&&h<a;);if(512&s.flags&&(s.check=L(s.check,n,h,o)),a-=h,o+=h,C)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;u<16;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}u=c=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}e.adler=s.check=x(c),u=c=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last)c>>>=7&u,u-=7&u,s.mode=27;else{for(;u<3;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}switch(s.last=1&c,--u,3&(c>>>=1)){case 0:s.mode=14;break;case 1:N=D=void 0;var N,D=s;if(q){for(V=new P.Buf32(512),B=new P.Buf32(32),N=0;N<144;)D.lens[N++]=8;for(;N<256;)D.lens[N++]=9;for(;N<280;)D.lens[N++]=7;for(;N<288;)D.lens[N++]=8;for(k(1,D.lens,0,288,V,0,D.work,{bits:9}),N=0;N<32;)D.lens[N++]=5;k(2,D.lens,0,32,B,0,D.work,{bits:5}),q=!1}if(D.lencode=V,D.lenbits=9,D.distcode=B,D.distbits=5,s.mode=20,6!==t)break;c>>>=2,u-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}c>>>=2,u-=2}break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&c,u=c=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;P.arraySet(i,n,o,h,r),a-=h,o+=h,l-=h,r+=h,s.length-=h}else s.mode=12;break;case 17:for(;u<14;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(s.nlen=257+(31&c),c>>>=5,u-=5,s.ndist=1+(31&c),c>>>=5,u-=5,s.ncode=4+(15&c),c>>>=4,u-=4,286<s.nlen||30<s.ndist){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;u<3;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.lens[R[s.have++]]=7&c,c>>>=3,u-=3}for(;s.have<19;)s.lens[R[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,O={bits:s.lenbits},M=k(0,s.lens,0,19,s.lencode,0,s.work,O),s.lenbits=O.bits,M){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;m=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(S<16)c>>>=E,u-=E,s.lens[s.have++]=S;else{if(16===S){for(T=E+2;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c>>>=E,u-=E,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}C=s.lens[s.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===S){for(T=E+3;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}C=0,h=3+(7&(c>>>=E)),c>>>=3,u=u-E-3}else{for(T=E+7;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}C=0,h=11+(127&(c>>>=E)),c>>>=7,u=u-E-7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=C}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,O={bits:s.lenbits},M=k(1,s.lens,0,s.nlen,s.lencode,0,s.work,O),s.lenbits=O.bits,M){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,O={bits:s.distbits},M=k(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,O),s.distbits=O.bits,M){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(6<=a&&258<=l){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,b(e,_),r=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,c=s.hold,u=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;m=(y=s.lencode[c&(1<<s.lenbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(m&&!(240&m)){for(f=E,v=m,I=S;m=(y=s.lencode[I+((c&(1<<f+v)-1)>>f)])>>>16&255,S=65535&y,!(f+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}c>>>=f,u-=f,s.back+=f}if(c>>>=E,u-=E,s.back+=E,s.length=S,0===m){s.mode=26;break}if(32&m){s.back=-1,s.mode=12;break}if(64&m){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&m,s.mode=22;case 22:if(s.extra){for(T=s.extra;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;m=(y=s.distcode[c&(1<<s.distbits)-1])>>>16&255,S=65535&y,!((E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(!(240&m)){for(f=E,v=m,I=S;m=(y=s.distcode[I+((c&(1<<f+v)-1)>>f)])>>>16&255,S=65535&y,!(f+(E=y>>>24)<=u);){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}c>>>=f,u-=f,s.back+=f}if(c>>>=E,u-=E,s.back+=E,64&m){e.msg="invalid distance code",s.mode=30;break}s.offset=S,s.extra=15&m,s.mode=24;case 24:if(s.extra){for(T=s.extra;u<T;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,u-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===l)break e;if(s.offset>(h=_-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}g=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),p=s.window}else p=i,g=r-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;i[r++]=p[g++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;i[r++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;u<32;){if(0===a)break e;a--,c|=n[o++]<<u,u+=8}if(_-=l,e.total_out+=_,s.total+=_,_&&(e.adler=s.check=(s.flags?L:w)(s.check,i,_,r-_)),_=l,(s.flags?c:x(c))!==s.check){e.msg="incorrect data check",s.mode=30;break}u=c=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;u<32;){if(0===a)break e;a--,c+=n[o++]<<u,u+=8}if(c!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}u=c=0}s.mode=29;case 29:M=1;break e;case 30:M=-3;break e;case 31:return-4;default:return G}return e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=c,s.bits=u,(s.wsize||_!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&$(e,e.output,e.next_out,_-e.avail_out)?(s.mode=31,-4):(d-=e.avail_in,_-=e.avail_out,e.total_in+=d,e.total_out+=_,s.total+=_,s.wrap&&_&&(e.adler=s.check=(s.flags?L:w)(s.check,i,_,e.next_out-_)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),M=(0==d&&0===_||4===t)&&M===U?-5:M)},s.inflateEnd=function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,U):G},s.inflateGetHeader=function(e,t){return e&&e.state&&2&(e=e.state).wrap?((e.head=t).done=!1,U):G},s.inflateSetDictionary=function(e,t){var s,n=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?G:11===s.mode&&w(1,t,n,0)!==s.check?-3:$(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,U)},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var b=e("../utils/common"),k=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],U=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],G=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],F=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,s,n,i,o,r,a){for(var l,c,u,d,_,h,g,p,E,m=a.bits,S=0,f=0,v=0,I=0,C=0,M=0,O=0,T=0,y=0,A=0,R=null,N=0,D=new b.Buf16(16),P=new b.Buf16(16),w=null,L=0,S=0;S<=15;S++)D[S]=0;for(f=0;f<n;f++)D[t[s+f]]++;for(C=m,I=15;1<=I&&0===D[I];I--);if(I<C&&(C=I),0===I)i[o++]=20971520,i[o++]=20971520,a.bits=1;else{for(v=1;v<I&&0===D[v];v++);for(C<v&&(C=v),S=T=1;S<=15;S++)if((T=(T<<1)-D[S])<0)return-1;if(0<T&&(0===e||1!==I))return-1;for(P[1]=0,S=1;S<15;S++)P[S+1]=P[S]+D[S];for(f=0;f<n;f++)0!==t[s+f]&&(r[P[t[s+f]]++]=f);if(h=0===e?(R=w=r,19):1===e?(R=k,N-=257,w=U,L-=257,256):(R=G,w=F,-1),S=v,_=o,O=f=A=0,u=-1,d=(y=1<<(M=C))-1,1===e&&852<y||2===e&&592<y)return 1;for(;;){for(E=r[f]<h?(p=0,r[f]):r[f]>h?(p=w[L+r[f]],R[N+r[f]]):(p=96,0),l=1<<(g=S-O),v=c=1<<M;i[_+(A>>O)+(c-=l)]=g<<24|p<<16|E,0!==c;);for(l=1<<S-1;A&l;)l>>=1;if(0!==l?A=(A&l-1)+l:A=0,f++,0==--D[S]){if(S===I)break;S=t[s+r[f]]}if(C<S&&(A&d)!==u){for(_+=v,T=1<<(M=S-(O=0===O?C:O));M+O<I&&!((T-=D[M+O])<=0);)M++,T<<=1;if(y+=1<<M,1===e&&852<y||2===e&&592<y)return 1;i[u=A&d]=C<<24|M<<16|_-o}}0!==A&&(i[_+A]=S-O<<24|64<<16),a.bits=C}return 0}},{"../utils/common":1}],10:[function(e,t,s){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,s){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,s){var d=e("./zlib/inflate"),_=e("./utils/common"),h=e("./utils/strings"),g=e("./zlib/constants"),n=e("./zlib/messages"),i=e("./zlib/zstream"),o=e("./zlib/gzheader"),p=Object.prototype.toString;function r(e){if(!(this instanceof r))return new r(e);this.options=_.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new i,this.strm.avail_out=0,d.inflateInit2(this.strm,t.windowBits));if(e!==g.Z_OK)throw new Error(n[e]);if(this.header=new o,d.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=h.string2buf(t.dictionary):"[object ArrayBuffer]"===p.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=d.inflateSetDictionary(this.strm,t.dictionary))!==g.Z_OK)throw new Error(n[e])}function a(e,t){t=new r(t);if(t.push(e,!0),t.err)throw t.msg||n[t.err];return t.result}r.prototype.push=function(e,t){var s,n,i,o,r,a=this.strm,l=this.options.chunkSize,c=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?g.Z_FINISH:g.Z_NO_FLUSH,"string"==typeof e?a.input=h.binstring2buf(e):"[object ArrayBuffer]"===p.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new _.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=d.inflate(a,g.Z_NO_FLUSH))===g.Z_NEED_DICT&&c?d.inflateSetDictionary(this.strm,c):s)===g.Z_BUF_ERROR&&!0===u&&(s=g.Z_OK,u=!1),s!==g.Z_STREAM_END&&s!==g.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==g.Z_STREAM_END&&(0!==a.avail_in||n!==g.Z_FINISH&&n!==g.Z_SYNC_FLUSH)||("string"===this.options.to?(i=h.utf8border(a.output,a.next_out),o=a.next_out-i,r=h.buf2string(a.output,i),a.next_out=o,a.avail_out=l-o,o&&_.arraySet(a.output,a.output,i,o,0),this.onData(r)):this.onData(_.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(u=!0),(0<a.avail_in||0===a.avail_out)&&s!==g.Z_STREAM_END);return(n=s===g.Z_STREAM_END?g.Z_FINISH:n)===g.Z_FINISH?(s=d.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===g.Z_OK):n!==g.Z_SYNC_FLUSH||(this.onEnd(g.Z_OK),!(a.avail_out=0))},r.prototype.onData=function(e){this.chunks.push(e)},r.prototype.onEnd=function(e){e===g.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=_.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=r,s.inflate=a,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,a(e,t)},s.ungzip=a},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),xt.exports),Bt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=Nt,this._currentConnectState=yt,this._beforeSendInterceptors=[]}init(){Qe.addTask({id:Ot,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){var{sdkAppId:t,testEnv:s}=we.get("instance"),n=Ye(t);return Ze(s?qe.TEST[n].DEFAULT:qe.PRODUCTION[n].INITIAL.replace("*",""+t),{isBinary:e})}(this._isBinarySupported),u.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s,{requestId:n,timeout:i=Ct,canResend:o=!0}=t||{};if(Ee(e))return console.warn(Mt+".sendPacket: packet is empty ",e),null;this._executeBeforeSendInterceptors(e);var r=JSON.stringify(e);let a=null;if(n){let{resolve:e,reject:t,promise:s}=me();a=s,this._pendingRequests.set(n,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:i,canResend:o})}t=this._isBinarySupported?et(r).buffer:r;return null!=(s=this._socketAdapter)&&s.send(t),a}connect(){this._socketAdapter=new Le(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Mt+`.connect isWorkerEnabled: false socketID:${e} url:`+this._url;this._ssoLog({method:"connect",message:e}),console.log(e)}disconnect(){var e=null==(e=this._socketAdapter)?void 0:e.getId(),e=Mt+".disconnect socketID:"+e;this._ssoLog({method:"disconnect",message:e}),console.log(e),this._removeEventListeners(),null!=(e=this._socketAdapter)&&e.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(Mt+".dispose"),Qe.removeTask(Ot),Qe.removeTask(Tt),u.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),u.unSubscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.disconnect(),this._socketAdapter=null,this._isReconnecting=!1,this._isHeartbeatInProgress=!1,this._pendingRequests.clear(),this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._intendedDelay=Nt,this._url=""}registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}_executeBeforeSendInterceptors(e){for(var t of this._beforeSendInterceptors){var{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}_shouldSkipReconnect(){var e=this._currentConnectState===At&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return h(this,void 0,void 0,function*(){var e=`${Mt} reconnect isReconnecting: ${this._isReconnecting} currentConnectState: `+this._currentConnectState;if(this._ssoLog({method:"reconnect",message:e}),console.log(e),!this._shouldSkipReconnect()){this._url=function(e){var{sdkAppId:t,testEnv:s}=we.get("instance"),t=Ye(t);if(s)return Ze(qe.TEST[t].DEFAULT,{isBinary:e});let n=qe.PRODUCTION[t],i=V&&n.ANYCAST;return Ze({[Ke.INITIAL]:()=>(je=Ke.DEFAULT,n.DEFAULT),[Ke.DEFAULT]:()=>(je=Ke.IPV6,n.IPV6),[Ke.IPV6]:()=>(je=Ke.BACKUP,n.BACKUP),[Ke.BACKUP]:()=>(je=i?Ke.ANYCAST:Ke.DEFAULT,i?n.ANYCAST:n.DEFAULT),[Ke.ANYCAST]:()=>(je=Ke.DEFAULT,n.ANYCAST="",n.DEFAULT)}[je](),{isBinary:e})}(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:Rt,reason:Lt}),console.warn(Mt+" reconnect failed: ",e)}}})}_addEventListeners(){var e;null!=(e=this._socketAdapter)&&e.on("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.on("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.on("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.on("error",this._onError,this),null!=(e=this._socketAdapter)&&e.on("sendFail",this._onSendFail,this)}_removeEventListeners(){var e;null!=(e=this._socketAdapter)&&e.off("connect",this._onConnect,this),null!=(e=this._socketAdapter)&&e.off("message",this._onMessage,this),null!=(e=this._socketAdapter)&&e.off("close",this._onClose,this),null!=(e=this._socketAdapter)&&e.off("error",this._onError,this),null!=(e=this._socketAdapter)&&e.off("sendFail",this._onSendFail,this)}_onClose(e){var{socketId:e,event:t}=e||{},s=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,s=`${Mt} onClose closeSocketID: ${e} currentSocketID: ${this._connectionId} connectionDuration: ${s} code:${null==t?void 0:t.code} reason:`+(null==t?void 0:t.reason);this._ssoLog({method:"onClose",message:s}),console.warn(s),e===this._connectionId&&this._handleConnectStateChange({state:Rt,reason:kt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){var{socketId:e,error:t}=e||{},t=`${Mt} onError sourceSocketID: ${e} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+JSON.stringify(t);this._ssoLog({method:"onError",message:t}),console.warn(t),e===this._connectionId&&this._handleConnectStateChange({state:Rt,reason:bt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){var{socketId:e,error:t}=e||{},t=`${Mt} onSendFail sendFailSocketId: ${e} currentSocketID:${this._connectionId} isReconnecting: ${this._isReconnecting} error: `+t;this._ssoLog({method:"onSendFail",message:t}),console.warn(t),e===this._connectionId&&this._handleConnectStateChange({state:Rt,reason:wt}),this._isReconnecting&&(this._isReconnecting=!1)}_onMessage(t){let s,e;this._updateHeartbeatTime();try{s=this._isBinarySupported?(this._isCompressedData(t.data)?e=>{var t=new Uint8Array(e).slice(4);let s;try{s=Vt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s}:function(e){var i=new Uint8Array(e);let o="",r=0;for(var a=i["length"];r<a;){let t=i[r],s=0,n=0;if(t<=127?(s=0,n=255&t):t<=223?(s=1,n=31&t):t<=239?(s=2,n=15&t):t<=244&&(s=3,n=7&t),0<a-r-s)for(let e=0;e<s;e+=1)t=i[r+e+1],n=n<<6|63&t;else n=65533,s=a-r;o+=String.fromCodePoint(n),r+=s+1}return o})(t.data):t.data,e=JSON.parse(s)}catch(s){let e=t.data;return this._ssoLog({method:"jsonParseError",message:e}),void console.error(s)}var n;e&&e.head&&({seq:t,servcmd:n}=e.head,this._pendingRequests.has(""+t+n)?this._handleRequestResponse(e):this._handlePushMessage(e))}_handleRequestResponse(e){var{seq:t,servcmd:s}=e.head,{int32_error_code:n,str_error_message:i,ErrorCode:n=n,ErrorInfo:i=i}=(null==e?void 0:e.body)||{},t=""+t+s,{resolve:s,reject:o}=this._pendingRequests.get(t);this._pendingRequests.delete(t),n&&0!==n?(u.emitInnerEvent("error",{errorCode:n,errorInfo:i}),o({errorCode:n,errorInfo:i})):s(e.body)}_handlePushMessage(e){var t=e.head["servcmd"],{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),u.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;console.log(`${Mt}._checkPendingRequestsAndResend reConnectFlag:${this._isReconnecting} promiseMap.size:`+this._pendingRequests.size),null!=(e=this._pendingRequests)&&e.forEach((e,t)=>{var{uplinkData:s,canResend:n,resolve:i,reject:o,timeout:r}=e;if(n){this._pendingRequests.set(t,{resolve:i,reject:o,timestamp:Date.now(),uplinkData:s,timeout:r,canResend:n});let e=this._isBinarySupported?et(s).buffer:s;null!=(i=this._socketAdapter)&&i.send(e)}else this._pendingRequests.delete(t)})}_onConnect(e){var{socketId:e,event:t={}}=e||{},s=(this._connectionId=e,this._connectionEstablishedTime=Date.now(),Date.now()-this._connectionStartTime),s=Mt+` onConnect cost:${s} ms. socketID:${e} res:`+JSON.stringify(t);if(this._ssoLog({method:"onConnect",message:s}),console.log(s),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){let e=Mt+" reconnect success";this._ssoLog({method:"reconnectSuccess",message:e}),console.log(e),u.emitInnerEvent(gt.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:yt})}_sendAck(e){e=ot({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(e)}_executeScheduledTaskIfReady(){return h(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}_canSendHeartbeat(){var e;return(null==(e=this._socketAdapter)?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}_sendHeartbeat(){return h(this,void 0,void 0,function*(){var e,t=ot({servcmd:"heartbeat.alive",data:{}});try{let e=""+t.head.seq+t.head.servcmd;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){var s=null==(e=we.get("netWorkMonitor"))?void 0:e.isNetWorkOnline,s=Mt+` sendHeartbeat failed. isNetWorkOnline:${s} error: `+t;this._ssoLog({method:"sendHeartbeatError",message:s}),console.debug(s),this._handleConnectStateChange({state:Rt,reason:wt})}})}_sendHeartbeatIfReady(){return h(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=L?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){var t=Mt+" networkStatusChange "+JSON.stringify(e),{isNetworkOnline:t,networkType:e}=(this._ssoLog({method:"networkStatusChange",message:t}),console.warn(t),e);t&&"none"!==e?this._handleConnectStateChange({state:yt,reason:Dt}):this._handleConnectStateChange({state:Rt,reason:Dt})}isPrivateNetWork(){var e=we.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){var{state:t,reason:s}=e;if(this._currentConnectState!==t){let e=`${Mt}._handleConnectStateChange from ${this._currentConnectState} to ${t} reason: `+s;this._ssoLog({method:"handleConnectStateChange",message:e}),console.log(e),this._currentConnectState=t,u.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:t}}),t===Rt&&u.emitInnerEvent(gt.SOCKET_DISCONNECTED),t!==Rt&&t!==yt||(this._resetReconnectDelay(),Qe.addTask({id:Tt,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this}))}}_handleActivityStatusChange(e){var t=null==(t=null==(t=this._socketAdapter)?void 0:t._ws)?void 0:t.readyState,e=`${Mt} activityStatusChange ${JSON.stringify(e)} readyState: `+t;this._ssoLog({method:"activityStatusChange",message:e}),console.warn(e),3===t&&this._handleConnectStateChange({state:Rt,reason:Pt})}_resetReconnectDelay(){Qe.removeTask(Tt);var e=null==(e=we.get("activityMonitor"))?void 0:e.isActive;this._intendedDelay=e?Nt:1e3}_scheduleReconnectWithBackoff(){var e=null==(e=we.get("activityMonitor"))?void 0:e.isActive,e=(this._intendedDelay=e?Math.min(5e3,Math.max(Nt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay)),(new Date).toTimeString().slice(0,8)),e=Mt+`.scheduleReconnectWithBackoff timeStr: ${e} intendedDelay: `+this._intendedDelay;this._ssoLog({method:"scheduleReconnectWithBackoff",message:e}),console.log(e),this.reconnect(),Qe.updateTaskInterval(Tt,this._intendedDelay)}_ssoLog(e){var{method:e,message:t}=e;It.createSSOLogData({method:e}).setLogInfo({message:t}).end()}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(t){h(this,void 0,void 0,function*(){var e=t.split("/")[2];if(e.startsWith("ws")){e=`https://${e}/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield pe({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseBySSO failed. error:",e)}}})}(this._url),function(t){h(this,void 0,void 0,function*(){var e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${t.slice(t.indexOf("info?")+5)}&reqtime=`+Date.now();try{yield pe({method:"GET",url:e,data:{}})}catch(e){console.warn("diagnoseByCDN failed. error:",e)}})}(this._url),this._beforeSendInterceptors=[])}_clearTimeoutRequest(){for(var[e,t]of this._pendingRequests.entries()){var{reject:t,timestamp:s,timeout:n}=t;Date.now()-s>=n&&(this._pendingRequests.delete(e),3e4<=Date.now()-this._lastDiagnoseAt&&this._diagnose(),t({errorCode:_e,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;(null!=(e=we.get("instance"))&&e.devMode||(e=de(),P)||y&&"windows"===e||L)&&(this._isBinarySupported=!1)}_isCompressedData(e){e=new Uint8Array(e);return 67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}};let $t={init:function(e){we.set("instance",e),Bt.init()},destroy:function(){Bt.dispose(),we.clear(),Qe.dispose()},notificationCenter:u,channel:Bt,store:we,ssoLog:It,utils:Se,common:dt,constants:i};!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"}(qt=qt||{});var Wt,Yt=qt;!function(e){e.LOGOUT="logout",e.DESTROY="destroy",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.PROFILE_UPDATE="profile_updated",e.ERROR="error",e.RECONNECTED="reconnected",e.FORCE_OFFLINE="im_open_status.stat_forceoffline",e.COMMERCIAL_CONFIG_PUSH="im_sdk_config_mgr.push_imsdk_purchase_bitsv2",e.OVERLOAD_PUSH="OverLoadPush.notify2",e.NEW_MESSAGE="new_message",e.MESSAGE_PUSH="im_open_push.msg_push",e.MESSAGE_DELETED="message_deleted",e.MESSAGE_REVOKED="message_revoked",e.MESSAGE_MODIFIED="message_modified",e.SOCKET_DISCONNECTED="socket_disconnected",e.CONVERSATION_UPDATED="conversation_updated",e.TOPIC_MESSAGE_DELETED="topic_message_deleted",e.TOPIC_MESSAGE_REVOKED="topic_message_revoked",e.TOPIC_MESSAGE_MODIFIED="topic_message_modified",e.TOPIC_NEW_MESSAGE="topic_new_message",e.QUALITY_STAT="quality_stat",e.SYNC_CONVERSATION_LIST="sync_conversation_list"}(Wt=Wt||{});var Kt,Jt,Qt,Ht=Wt,jt=(!function(e){e.NEW_INVITATION_RECEIVED="newInvitationReceived",e.INVITEE_ACCEPTED="ts_invitee_accepted",e.INVITEE_REJECTED="ts_invitee_rejected",e.INVITATION_CANCELLED="ts_invitation_cancelled",e.INVITATION_TIMEOUT="ts_invitation_timeout",e.INVITATION_MODIFIED="ts_invitation_modified"}(Kt=Kt||{}),Kt);let zt=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),Zt={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem"},Xt=(!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(Jt=Jt||{}),{modify:Ht.MESSAGE_MODIFIED,delete:Ht.MESSAGE_DELETED,revoke:Ht.MESSAGE_REVOKED}),es=(!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Qt=Qt||{}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Zt),{MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest"}),{RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",MSG_AT_ALL:"__kImSDK_MesssageAtALL__"}),{MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard"}),{MessageStatus:Jt,Direction:Qt})),ts={[Xt.modify]:Ht.TOPIC_MESSAGE_MODIFIED,[Xt.delete]:Ht.TOPIC_MESSAGE_DELETED,[Xt.revoke]:Ht.TOPIC_MESSAGE_REVOKED},ss={GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,USER_NOT_FOUND:"@TLS#NOT_FOUND"},ns=Object.assign({},ss),os={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},is=Object.assign(Object.assign(Object.assign(Object.assign({},os),{CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3}),{CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),rs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both"}),{SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both"}),{SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd"}),{SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),as={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},cs={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},ls={JOINED:1,QUITTED:2,KICKED:3,ADMIN_SET:4,ADMIN_CANCELED:5,GROUP_PROFILE_UPDATED:6,GROUP_MEMBER_PROFILE_UPDATED:7,TOPIC_PROFILE_UPDATED:8},ds=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},as),{GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom"}),{GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11}),{JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval"}),{INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess"}),{GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers"}),{GROUP_ID_PREFIX:cs,GROUP_TIPS_OPERATION_TYPE:ls}),us=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},zt),es),ns),is),rs),ds),{IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"}),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),_s={NO_SDKAPPID:2e3,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,NOT_MY_FRIEND:2700,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,NO_USE:3122,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022},hs={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},gs={SYNC_SERVER_INFO_AFTER_RE_ONLINE:"sync-server-info-after-re-online",SYNC_SERVER_INFO_AFTER_LOGIN:"sync-server-info-after-login",RECEIVE_C2C_NEW_MESSAGE:"receive-c2c-new-message",RECEIVE_GROUP_NEW_MESSAGE:"receive-group-new-message"},ps={USER_STATUS_UPDATE:"user-status-update",CONVERSATION_RECOVER:"conversation-recover",HISTORY_MESSAGE_RECOVER:"history-message-recover",BLACKLIST_RECOVER:"blacklist-recover",FRIEND_RECOVER:"friend-recover",GROUP_ATTRIBUTE_CACHE_CLEAR:"group-attribute-cache-clear",UNREAD_MESSAGE_RECOVER:"unread-message-recover",HANDLE_NEW_MESSAGE:"handle-new-message",HANDLE_CONVERSATION_PROFILE_UPDATED:"handle-conversation-profile-updated",COMMERCIAL_CONFIG_UPDATE:"commercial-config-update",UNREAD_MESSAGE_SYNC:"unread-message-sync",FRIEND_AND_BLACKLIST_SYNC:"friend-and-blacklist-sync",SIGNALING_MESSAGE_RECOVER:"signaling-message-recover",GROUP_LIST_SYNC:"group-list-sync",CONVERSATION_LIST_SYNC:"conversation-list-sync",USER_PROFILE_SYNC:"user-profile-sync",CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED:"conversation-update-after-unread-sync-finished",CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED:"conversation-update-after-group-list-sync-finished",HANDLE_C2C_NEW_MESSAGE:"handle-c2c-new-message",HANDLE_GROUP_NEW_MESSAGE:"handle-group-new-message",CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE:"create-or-update-conversation-by-receive-new-message",HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD:"handle-group-tips-from-sync-unread",HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD:"handle-c2c-revoked-message-from-sync-unread",GROUP_REVOKED_NOTICE_RECOVER:"group-revoked-notice-recover",CLOUD_CONFIG_SYNC:"cloud-config-sync",UPDATE_GROUP_NEXT_SEQUENCE:"update-group-next-sequence",EMIT_C2C_MESSAGE_EVENT:"emit-c2c-message-event",EMIT_GROUP_MESSAGE_EVENT:"emit-group-message-event",CONVERSATION_GROUP_LIST_SYNC:"conversation-group-list-sync",CONVERSATION_GROUP_UPDATE:"conversation-group-update",UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED:"update-topic-after-unread-sync-finished",UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE:"update-topic-by-received-new-message",TOPIC_REQUEST_INFO_RESET:"topic-request-info-reset",QUALITY_REPORT:"quality-report",GROUP_TIPS_RECOVER:"group-tips-recover"},Es={[gs.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:ps.USER_STATUS_UPDATE},{stepId:ps.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.CONVERSATION_RECOVER},{stepId:ps.HISTORY_MESSAGE_RECOVER,dependency:ps.CONVERSATION_RECOVER},{stepId:ps.BLACKLIST_RECOVER},{stepId:ps.FRIEND_RECOVER},{stepId:ps.GROUP_REVOKED_NOTICE_RECOVER,dependency:ps.HISTORY_MESSAGE_RECOVER},{stepId:ps.GROUP_TIPS_RECOVER,dependency:ps.HISTORY_MESSAGE_RECOVER},{stepId:ps.TOPIC_REQUEST_INFO_RESET},{stepId:ps.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ps.UNREAD_MESSAGE_SYNC,ps.CONVERSATION_RECOVER]},{stepId:ps.EMIT_C2C_MESSAGE_EVENT,dependency:[ps.UNREAD_MESSAGE_SYNC,ps.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1}],[gs.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:ps.COMMERCIAL_CONFIG_UPDATE},{stepId:ps.CLOUD_CONFIG_SYNC},{stepId:ps.USER_PROFILE_SYNC},{stepId:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.FRIEND_AND_BLACKLIST_SYNC},{stepId:ps.GROUP_LIST_SYNC},{stepId:ps.CONVERSATION_LIST_SYNC},{stepId:ps.SIGNALING_MESSAGE_RECOVER,dependency:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[ps.UNREAD_MESSAGE_SYNC]},{stepId:ps.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ps.UNREAD_MESSAGE_SYNC,ps.CONVERSATION_LIST_SYNC]},{stepId:ps.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[ps.GROUP_LIST_SYNC,ps.CONVERSATION_LIST_SYNC]},{stepId:ps.CONVERSATION_GROUP_LIST_SYNC},{stepId:ps.CONVERSATION_GROUP_UPDATE,dependency:[ps.CONVERSATION_LIST_SYNC,ps.CONVERSATION_GROUP_LIST_SYNC]},{stepId:ps.QUALITY_REPORT}],[gs.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:ps.HANDLE_C2C_NEW_MESSAGE},{stepId:ps.UNREAD_MESSAGE_SYNC},{stepId:ps.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ps.HANDLE_C2C_NEW_MESSAGE},{stepId:ps.EMIT_C2C_MESSAGE_EVENT,dependency:[ps.HANDLE_C2C_NEW_MESSAGE,ps.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:ps.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ps.UNREAD_MESSAGE_SYNC]}],[gs.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:ps.HANDLE_GROUP_NEW_MESSAGE},{stepId:ps.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ps.HANDLE_GROUP_NEW_MESSAGE},{stepId:ps.UPDATE_GROUP_NEXT_SEQUENCE,dependency:ps.HANDLE_GROUP_NEW_MESSAGE},{stepId:ps.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:ps.HANDLE_GROUP_NEW_MESSAGE},{stepId:ps.EMIT_GROUP_MESSAGE_EVENT,dependency:[ps.HANDLE_GROUP_NEW_MESSAGE,ps.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}]},fs={REACT:"atomicx_react",VUE3:"atomicx_vue3"},ms={[fs.REACT+"_web"]:40,[fs.REACT+"_h5"]:41,[fs.VUE3+"_web"]:42,[fs.VUE3+"_h5"]:43},Ss={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},vs={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"};var Is=Object.freeze({__proto__:null,ERROR_CODE:_s,InnerEvent:Ht,OuterConstant:us,OuterEvent:Yt,QUALITY_METRICS:Ss,SDK_EDITION:hs,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:vs,SignalingEvent:jt,UIKIT_PREFIX:fs,UI_PLATFORM:ms,WORKFLOW_DEFINITIONS:Es,WORKFLOW_NAME:gs,WORKFLOW_STEP:ps});function Cs(t){var s;try{var n=we.getStorage("errorMessage");if(!t||!n)return"";var i=(null==(s=JSON.parse(n))?void 0:s.errorMessage)||{},{isIntl:o=!1,code:r,replacement1:a="",replacement2:l=""}=t;if(!r)return"";var c=o?r+"_en":r+"_cn";let e=i[i[c]?c:r]||"";return e=e&&(a&&(e=e.replace("$replacement1",a)),l)?e.replace("$replacement2",l):e}catch(t){return console.warn("Error parsing stored error messages:",t),""}}class Ms extends Error{constructor(e){var{functionName:t="Unknown",code:s,message:n="",data:i=""}=e;let o=n;s&&!n&&(o=Cs(e));n=s?`${t} failed. error: {"message": ${o}, "code": ${s}}`:`${t} failed. error: {"message": ${o}}`;super(),this.code=s,this.errorCode=s,this.errorMessage=n,this.message=n,this.data=i}}function Os(e,t){if(e&&!0!==(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn))throw new Ms({code:_s.USER_NOT_LOGGED_IN,functionName:t})}let Ts=e=>"function"==typeof e;function ys(t,s,n){let i=n||[];var e,o;return!(!t||!s)&&(e=Object.keys(t).filter(e=>!i.includes(e)),o=Object.keys(s).filter(e=>!i.includes(e)),e.length===o.length)&&e.every(e=>!!s.hasOwnProperty(e)&&("object"==typeof t[e]&&null!==t[e]?ys(t[e],s[e],n):t[e]===s[e]))}function As(t,s,n){if(Array.isArray(t))for(let e=0;e<t.length;e++)Rs.call(this,Object.assign(Object.assign({},t[e]),{value:s[e],name:n}));else for(var e in t)Rs.call(this,Object.assign(Object.assign({},t[e]),{value:s[0][e],name:n,key:e}))}function Rs({required:e,rules:n,value:t,allowEmpty:i,name:o,key:r,customValidator:a}){if(void 0===t){if(e)throw new Ms({functionName:o,message:`[${o}] Missing required params: "${r}"`})}else{let s="";if(!n.some(e=>{return e===Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()})){for(let t=0;t<n.length;t++){let e=n[t];e=e.replace(e[0],e[0].toUpperCase()),s+=e+"/"}let e=`[${r}] must be type of ${s=s.substring(0,s.length-1)}, received type: ${Reflect.apply(Object.prototype.toString,t,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new Ms({functionName:o,message:e})}if(!1===i){if(Array.isArray(t)&&(0===t.length||"string"==typeof t[0]&&""===t[0].trim()))throw new Ms({functionName:o,message:r+" can not be empty."});if("string"==typeof t&&""===t.trim())throw new Ms({functionName:o,message:r+" can not be empty."})}if(a&&"function"==typeof a){let e=a(t);if(!0!==e)throw new Ms({functionName:o,message:`[${r}] custom validation failed: `+(e||"Invalid value")})}}}let Ns=[],Ds={},Ps={};function ws(e,t){var s;Os(Ds[e],e),As(Ps[e],t,e),s=e,Ns.forEach(e=>{var{interceptor:e,context:t}=e;e.apply(t,[s])})}function Ls(e,t){Ns.push({interceptor:e,context:t})}function bs(e){var{params:e,auth:t}=e;e&&"object"==typeof e&&Object.assign(Ps,e),t&&"object"==typeof t&&Object.assign(Ds,t)}var ks=new class{constructor(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new WeakSet,this._externalPlugins=new WeakSet}_installPlugin(e,t){var s=[];let n=(s=f(e)?e:[e]).findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=-1<n?s.splice(n,1):[];s.forEach(e=>{t.has(e)||(e&&Ts(e.install)?(t.add(e),Ts(e.getInstalledSubPlugins)?e.install(Wn(),i):e.install(Wn()),Ts(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):Ts(e)?(t.add(e),e(Wn()),Ts(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isLoggedIn(){var e;return!0===(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn)}};function Us(e){return $t.store.get("commercialConfig").get(e)}let Gs=new Map;var Fs=new class{constructor(){this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{var s=Date.now();t?(this._stepStartTimes.set(e+"-"+t,s),console.log(`[Workflow ${e}] Step ${t} started at `+new Date(s).toISOString())):(this._workflowStartTimes.set(e,s),console.log(`[Workflow ${e}] started at `+new Date(s).toISOString()))},success:(s,e)=>{var n=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?n-t:0;this._stepStartTimes.delete(s+"-"+e),console.log(`[Workflow ${s}] Step ${e} completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}else{let e=this._workflowStartTimes.get(s),t=e?n-e:0;this._workflowStartTimes.delete(s),console.log(`[Workflow ${s}] completed successfully at ${new Date(n).toISOString()} (${t}ms)`)}},error:(s,e,n)=>{var i=Date.now();if(e){var t=this._stepStartTimes.get(s+"-"+e),t=t?i-t:0;this._stepStartTimes.delete(s+"-"+e),console.error(`[Workflow ${s}] Step ${e} failed at ${new Date(i).toISOString()} (${t}ms)`,n)}else{let e=this._workflowStartTimes.get(s),t=e?i-e:0;this._workflowStartTimes.delete(s),console.error(`[Workflow ${s}] failed at ${new Date(i).toISOString()} (${t}ms)`,n)}}}}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){this._handlers.has(e)?Es[e].find(e=>e.stepId===t)?this._handlers.get(e).set(t,n?s.bind(n):s):console.debug(`Step '${t}' not defined in workflow '${e}'`):console.debug(`Workflow '${e}' not defined in core`)}executeWorkflow(r,s){return h(this,void 0,void 0,function*(){if(this._validateWorkflow(r)){console.log(`[Workflow ${r}] Started execution at `+(new Date).toISOString());let e=Es[r],o={cancelled:!1};this._activeWorkflows.set(r,{cancelToken:o});try{let t=new Map,i=(e.forEach(e=>{t.set(e.stepId,e)}),{workflowName:r,pendingSteps:new Set(e.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:t,stepResults:{},data:s,cancelToken:o});yield new Promise((t,s)=>{let n=()=>{o.cancelled?t():this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).forEach(e=>{i.completedSteps.has(e)||i.runningSteps.has(e)||this._executeWorkflowStep(e,i,{onComplete:()=>{0===i.pendingSteps.size?t():0===this._getExecutableSteps({pendingSteps:i.pendingSteps,completedSteps:i.completedSteps,stepMap:i.stepMap,workflowName:r}).filter(e=>!i.runningSteps.has(e)).length&&0===i.runningSteps.size&&(console.log(`Workflow ${r} completed with some steps skipped due to dependency failures`),t())},onError:s,onStepComplete:n})})};n()}),console.log(`[Workflow ${r}] Completed execution at `+(new Date).toISOString())}catch(e){console.error(`[Workflow ${r}] Failed execution at `+(new Date).toISOString(),e)}finally{this._activeWorkflows.delete(r)}}})}_executeWorkflowStep(a,l,c){return h(this,void 0,void 0,function*(){let{workflowName:o,runningSteps:e,stepMap:s,stepResults:n,data:i}=l;e.add(a),this._logWorkflowExecution(o,a,"start");try{let e=s.get(a),t=null;null!=e&&e.dependency&&(p(e.dependency)?t=n[e.dependency]:Array.isArray(e.dependency)&&(t={},e.dependency.forEach(e=>{t[e]=n[e]})));var r=this._handlers.get(o).get(a);if(r){let e=yield Promise.resolve(r({data:i,result:t}));n[a]=e,this._logWorkflowExecution(o,a,"success")}l.completedSteps.add(a)}catch(e){let t=`[Workflow].${o}.`+a,{errorCode:s,errorInfo:n=t+" failed"}=e||{},i=new Ms({functionName:t,code:s,message:n});$t.ssoLog.createSSOLogData({method:"Workflow"}).setLogInfo({message:`workflowName: ${o}, stepId: `+a}).setError(i).end(),this._logWorkflowExecution(o,a,"error",e),c.onError(e)}finally{e.delete(a),l.pendingSteps.delete(a),c.onStepComplete(),c.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(Es).forEach(e=>{this._handlers.set(e,new Map)})}_cancelWorkFlow(e){var t=this._activeWorkflows.get(e);t&&(t=t["cancelToken"],t.cancelled=!0,this._activeWorkflows.delete(e))}_cancelAllWorkflows(){Object.keys(Es).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return Es[e]?!!this._handlers.get(e)||(console.debug(`No handlers registered for workflow '${e}'`),!1):(console.debug(`Workflow '${e}' not defined`),!1)}_getExecutableSteps(e){let{pendingSteps:t,completedSteps:s,stepMap:n,workflowName:i}=e;return Array.from(t).filter(e=>{var{dependency:t,skipIfDependencyMissing:e=!0}=n.get(e)||{};if(!t)return!0;if(p(t))return this._isStepRegistered({workflowName:i,stepId:t})?s.has(t):!e;if(f(t)){if(0<t.filter(e=>!this._isStepRegistered({workflowName:i,stepId:e})).length&&e)return!1;for(let e of t)if(!s.has(e))return!1;return!0}return!1})}_isStepRegistered(e){var{workflowName:e,stepId:t}=e;return null==(e=this._handlers.get(e))?void 0:e.has(t)}_logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}};let xs=({type:e,groupID:t})=>e===us.GRP_COMMUNITY||(""+t).startsWith(cs.COMMUNITY)&&!(""+t).includes(cs.TOPIC),Vs=(e="")=>{e=e.startsWith("GROUP")?e.replace("GROUP",""):e;return e.startsWith(cs.COMMUNITY)&&(""+e).includes(cs.TOPIC)},Bs="openim",$s="million_group_open_http_svc";function qs(s){return h(this,void 0,void 0,function*(){var{servcmd:e,data:t}=Ws(e=s.data)||Ys(e)?function(e){let{servcmd:t,data:s}=e;var n,i,o;return Ys(s)?({servcmd:e,data:n}=e,{GroupId:i=""}=n,[i]=(o=i).split(cs.TOPIC),{servcmd:Ks(e),data:Object.assign(Object.assign({},n),{GroupId:i,TopicId:o})}):{servcmd:t=Ws(s)?Ks(t):t,data:s}}(s):s,t=$t.common.generateProtocolData({servcmd:e,data:t}),e=""+t.head.seq+e;return $t.channel.sendPacket(t,{requestId:e})})}function Ws(e){var{Type:e,GroupId:t,GroupIdList:s=[]}=e,t=t||s[0]||"";return xs({type:e,groupID:t})}function Ys(e){var{GroupId:e=""}=e;return Vs(e)}function Ks(e){return e.includes(Bs)?e:(e=e.split(".")[1],$s+"."+e)}function Hs(){var e;return null==(e=$t.store.get("login"))?void 0:e.userId}let js=e=>f(e)||m(e),zs=(s,n,i,o)=>{if(!js(s)||!js(n))return 0;let r=0;var a,l=Object.keys(n);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(g(n[a])||i&&i.includes(a)))if(js(s[a])&&js(n[a]))r+=zs(s[a],n[a],i,o);else{if(o&&o.includes(n[a]))continue;s[a]!==n[a]&&(s[a]=n[a],r+=1)}return r},Zs=(e,t)=>{if(g(t))return"";switch(e){case us.MSG_TEXT:return t.text||"";case us.MSG_IMAGE:return"[Image]";case us.MSG_LOCATION:return"[Location]";case us.MSG_AUDIO:return"[Voice]";case us.MSG_VIDEO:return"[Video]";case us.MSG_FILE:return"[File]";case us.MSG_CUSTOM:return"[Custom Messages]";case us.MSG_GRP_TIP:return"[Group Notification]";case us.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case us.MSG_FACE:return"[Animated Sticker]";case us.MSG_MERGER:return"[Chat Record]";default:return""}},Js=[{cmd:"ws_get_user_status",interval:5,count:20},{cmd:"ws_status_subscribe",interval:5,count:20},{cmd:"ws_status_unsubscribe",interval:5,count:20},{cmd:"get_group_self_member_info",interval:5,count:20},{cmd:"modify_group_base_info",interval:1,count:8},{cmd:"get_members",interval:3,count:1},{cmd:"get_pendency",interval:1,count:15},{cmd:"set_group_attr",interval:5,count:10},{cmd:"modify_group_attr",interval:5,count:10},{cmd:"delete_group_attr",interval:5,count:10},{cmd:"clear_group_attr",interval:5,count:10},{cmd:"get_group_attr",interval:5,count:20},{cmd:"update_group_counter",interval:5,count:20},{cmd:"get_group_counter",interval:5,count:20},{cmd:"get_topic",interval:1,count:10},{cmd:"read_all_unread_msg",interval:1,count:1},{cmd:"query",interval:5,count:20}],Xs="im_sdk_config_mgr.fetch_config",Qs="im_sdk_config_mgr.push_configv2",en="cloud-config",tn=2996;var sn=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){var{notificationCenter:e,InnerEvent:t,helper:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i},channel:o}=this._core=e;e.subscribeInnerEvent(Qs,this._handlePushedConfig,this),s.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Js),o.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(e){var t,s={code:0,data:""};return e&&(s.data=(null==(t=this._core.store.get("cloudConfig"))?void 0:t[e])||""),s}checkMethodCallOverLimit(e){if(this._cmdFrequencyLimitMap.has(e))if(this._methodCallFrequencyMap.has(e)){var{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e),{startTime:n,methodCallCounter:i}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:i+=1}),t<i)throw new this._core.helper.ChatError({code:tn,replacement1:e})}else this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1})}_fetchCloudConfig(){return h(this,void 0,void 0,function*(){try{var e=(this._core.store.get("instance")||{})["sdkAppId"],t=this._core.helper.generateProtocolData({servcmd:Xs,data:{uint32_sdkappid:e,uint64_version:this._version}}),s=""+t.head.seq+Xs;return yield this._core.channel.sendPacket(t,{requestId:s})}catch(e){throw console.warn("fetch cloudControl fail: ",e),e}})}_handlePushedConfig(e){this._updateCloudConfig(e)}_handleLoginSuccess(){return h(this,void 0,void 0,function*(){try{var e;this._canFetch()&&(e=yield this._fetchCloudConfig(),this._updateCloudConfig(e)),this._core.helper.taskScheduler.addTask({id:en,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(e){console.warn(e)}})}_fetchCloudConfigIfReady(){return h(this,void 0,void 0,function*(){if(this._canFetch())try{var e=yield this._fetchCloudConfig();this._updateCloudConfig(e)}catch(e){console.warn(e)}})}_updateCloudConfig(e){e=this._parseCloudConfig(e);e&&(this._core.store.set("cloudConfig",e),this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,e))}_canFetch(){var e=(this._core.store.get("login")||{})["isLoggedIn"];return e&&!this._isFetching&&Date.now()>=this._expirationTime}_parseCloudConfig(e){var{int32_error_code:t,str_json_config:s,uint32_expired_time:n,uint64_version:i}=e;let o=null;if(0===t){if(this._version!==i)try{o=JSON.parse(s),this._version=i}catch(e){}this._expirationTime=Date.now()+1e3*n}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return o}_parseCmdFreqLimit(){var e,t=null==(e=this.getServerConfig("cmd_frequency_limit"))?void 0:e.data,s=this._core.utils["isEmpty"];if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(en),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Js),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(Qs,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class nn{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}let on={SEARCH_GRP_SNS:new nn(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new nn(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new nn(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new nn(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new nn(0,Math.pow(2,6)).toString(),USER_STATUS:new nn(0,Math.pow(2,7)).toString(),CONV_MARK:new nn(0,Math.pow(2,9)).toString(),CONV_GROUP:new nn(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new nn(0,Math.pow(2,11)).toString(),MSG_EXT:new nn(0,Math.pow(2,13)).toString(),GRP_COUNTER:new nn(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new nn(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new nn(Math.pow(2,7)).toString(),PLUGIN_CS:new nn(Math.pow(2,8)).toString(),PLUGIN_PUSH:new nn(Math.pow(2,9)).toString(),PLUGIN_BOT:new nn(Math.pow(2,10)).toString(),MSG_REACTION:new nn(Math.pow(2,16)).toString(),FOLLOW:new nn(Math.pow(2,20)).toString()},rn="CommercialConfig",an="commercial-config";var _n,hn,cn=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map}install(e){var{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:i,InnerEvent:o}}=this._core=e;s.subscribeInnerEvent(o.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(o.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(o.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,i.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this)}isCommercialAbilityEnabled(e){return h(this,void 0,void 0,function*(){var s=parseInt(e,10).toString(2),n=s["length"];let i,o=!0;for(let e=n-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(i=(t<32?new nn(0,2**t):new nn(2**(t-32),0)).toString(),!this._featureMap.get(i))){o=!1;break}return console.log(`${rn}.isFeatureEnabled decimalNumber:${e} key:${i} ret:`+o),{code:0,data:{enabled:o}}})}_fetchAndParseCommercialConfig(){return h(this,void 0,void 0,function*(){var e;try{this._isFetching=!0;var t=this._core.helper.generateProtocolData({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null==(e=this._core.store.get("instance"))?void 0:e.sdkAppId}}),s=yield this._core.channel.sendPacket(t);null!=s&&s.body&&(this._parseCommercialConfig(s.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(e){console.warn("fetch commercial fail: ",e)}finally{this._isFetching=!1}})}_syncCommercialConfig(t){return h(this,void 0,void 0,function*(){var e=((null==t?void 0:t.data)||{})["purchaseBits"];e&&(this._parsePurchaseBits(e),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:an,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}_canFetch(){var e=null==(e=this._core.store.get("login"))?void 0:e.isLoggedIn,t=Date.now()>=this._expirationTime;return e&&!this._isFetching&&t}_handlePushedConfig(e){null!=e&&e.body&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}_fetchCommercialConfigIfReady(){return h(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){var t,s,n,i;"object"==typeof e&&({int32_error_code:t,str_error_message:s,str_purchase_bits:n,uint32_expired_time:i}=e,0===t?(this._parsePurchaseBits(n),this._expirationTime=Date.now()+1e3*i):void 0===t?(console.log(rn+"._parseCommercialConfig failed. Invalid message format:",e),this._expirationTime=Date.now()+36e5):(console.error(rn+`._parseCommercialConfig errorCode:${t} errorMessage:`+s),this._expirationTime=Date.now()+12e4))}_isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}_parsePurchaseBits(s){if(this._isValidPurchaseBits(s)){this._featureMap.clear(),this._methodKeyMap.clear();var n;for(let e=s.length-1,t=0;0<=e;e--,t++)if(n=(t<32?new nn(0,2**t):new nn(2**(t-32),0)).toString(),"1"===s[e]){this._featureMap.set(n,!0);let e=this._getKeyByValue(on,n);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(n,!1);let e=this._getKeyByValue(on,n);e&&this._methodKeyMap.set(e,!1)}}else console.warn(rn+".parsePurchaseBits invalid purchases:"+s)}_getKeyByValue(e,t){e=Object.entries(e).find(([,e])=>e===t);return e?e[0]:void 0}_handleLogout(){this._reset()}_dispose(){this._reset(),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._core.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}_reset(){this._core.helper.taskScheduler.removeTask(an),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear()}},ln=new class{constructor(){this._core=null,this._serverOverloadInfoMap=new Map}install(e){this._core=e;var{notificationCenter:e,InnerEvent:t,channel:s}=this._core;e.subscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),s.registerBeforeSendInterceptor(this.checkServerOverload,this)}checkServerOverload(e){if(this._serverOverloadInfoMap.has(e)){var{overloadStartTimestamp:t,delaySeconds:s}=this._serverOverloadInfoMap.get(e);if(Date.now()-t<=1e3*s)throw new this._core.helper.ChatError({functionName:e,message:"service is busy, please try again later"});this._serverOverloadInfoMap.delete(e)}}_handleOverLoadPush(e){var{OverLoadServCmd:e,DelaySecs:t}=e;this._serverOverloadInfoMap.set(e,{overloadStartTimestamp:Date.now(),delaySeconds:t})}_reset(){this._serverOverloadInfoMap.clear()}_dispose(){this._reset();var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.OVERLOAD_PUSH,this._handleOverLoadPush,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}},dn=new class{constructor(){this._core=null}install(e){return h(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){let e=yield this._fetchErrorMessage();var t;e&&(t=this._parseResponse(e),this._saveErrorMessage(t))}})}_canFetch(){var e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}_saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}_fetchErrorMessage(){return h(this,void 0,void 0,function*(){try{return yield this._core.helper.httpRequest({method:"GET",url:"https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.6/tim-error-message.txt"})}catch(e){console.error(e)}})}_isExpired(e){return!e||(e=e["errorMessageSavedTime"],e&&6048e5<=(new Date).getTime()-e)}_parseResponse(e){if("string"==typeof e){var s=e.split(";\n"),n={},i=new RegExp(/'/g);for(let t=0;t<s.length;t++){var o=s[t].indexOf(":"),r=s[t].slice(0,o);let e=s[t].slice(o+1);r.startsWith("//")||""!==e&&(e=e.replace(i,""),n[r]=e)}return n}}};function un(i,l){return h(this,void 0,void 0,function*(){let{cookie:e,syncFlag:t,syncTriggerEvent:s}=i,n="openim.getmsg",r=l.helper.generateProtocolData({servcmd:n,data:{Cookie:e,SyncFlag:t,IsOnlineSync:s,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=""+r.head.seq+n;try{let e=yield l.channel.sendPacket(r,{requestId:a});if(!e)return null;let{C2CPairUnreadCount:t,C2CRemainingUnreadCount:s,EventArray:n}=e,{unreadMessageList:i,revokedMessageList:o}=function(e,v){let n=[],i=[];return null!=e&&e.forEach(f=>{var e,t,s=function(){var{From_Account:e,From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,To_Account:d,TinyId:_,MsgCheckResult:h,CloudCustomData:g,IsPeerRead:p,MsgFlagBits:E,MsgVersion:m,EventArray:S}=f;return{from:e,avatar:t,nick:s,needReadReceipt:1===n,readReceiptSentByPeer:p,clientTime:o,messageFlagBits:E,random:r,sequence:a,time:l,messageControlInfo:c,isSupportExtension:u,to:d,tinyID:_,checkResult:h,cloudCustomData:g,messageVersion:m,eventArray:S,elements:v.message.messageHelper.parseServerPushMessageElement(i)}}();if(null!=(t=null==(e=null==(e=null==f?void 0:f.EventArray)?void 0:e[0])?void 0:e.hasOwnProperty)&&t.call(e,"C2cNotifyMsgArray"))i.push(...function(){let e,t=[];return null!=(e=f.EventArray)&&e.forEach(e=>{var e=e["C2cNotifyMsgArray"],e=null==(e=null==(e=null==e?void 0:e[0])?void 0:e.WithdrawC2cMsgNotify)?void 0:e.C2cWithdrawInfoArray;Array.isArray(e)&&t.push(...e)}),t}());else{let e=v.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:"C2C",flow:"in"})),t=s["elements"];e.setElement(t),n.push(e)}}),{unreadMessageList:n,revokedMessageList:i}}(e.MsgList,l);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:o,unreadCountList:t,overflowUnreadCountList:s,cookie:null==e?void 0:e.Cookie,groupTipList:n}}catch(e){console.warn(e)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(_n=_n||{}),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(hn=hn||{});var gn=new class{constructor(){this._unreadDBMessageMap=new Map,this._cookie=""}install(e){var t=(this._core=e)["constants"];e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterReOnline,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.RECEIVE_C2C_NEW_MESSAGE,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterNewMessageReceived,this),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_LOGIN,t.WORKFLOW_STEP.UNREAD_MESSAGE_SYNC,this._syncUnreadDBMessageAfterLogin,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_syncUnreadMessage(t){return h(this,void 0,void 0,function*(){let{isAfterReOnline:r=!1,isAfterNewMessageReceived:a=!1,isAfterLogin:e=!1}=t||{},l=_n.START_SYNC;for(var c=[],u=[],d=[],_=[];this._canContinueSync({cookie:this._cookie,syncFlag:l});){let e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:l,syncTriggerEvent:a?hn.NEW_MESSAGE_RECEIVED:hn.LOGIN_SUCCESS});if(!e)break;let{unreadMessageList:t=[],revokedMessageList:s=[],overflowUnreadCountList:n,unreadCountList:i,groupTipList:o}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",l=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(t),d.push(...s),this._updateConversationUnreadOptions({unreadCountList:i,overflowUnreadCountList:n,conversationUpdateFieldList:c}),Array.isArray(o)&&u.push(...o),r){let e=this._handleNewMessageList(t)["messages"];_.push(...e)}}return r?{conversationUpdateFieldList:c,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u,messages:_}:{conversationUpdateFieldList:c,isInstantMessage:!e,isUnreadC2CMessage:!0,revokedMessageList:d,unreadMessageMap:this._unreadDBMessageMap,groupTipList:u}})}_syncUnreadDBMessageAfterLogin(){return h(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return h(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}_updateConversationUnreadOptions(e){let{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{OuterConstant:{CONV_C2C:i,CONV_SYSTEM:o}}=this._core["constants"];null!=t&&t.forEach(e=>{let{From_Account:t,UnreadCount:s}=e;if(t!==o){let e=n.find(({conversationID:e})=>e===""+i+t);e?e.unreadCount=s:n.push({conversationID:""+i+t,unreadCount:s,type:i})}}),null!=s&&s.forEach(e=>{let{From_Account:t,LastMsgTime:s}=e;t===o||n.find(({conversationID:e})=>e===""+i+t)||n.push({conversationID:""+i+t,type:i,lastMsgTime:s})})}_syncUnreadDBMessageAfterReOnline(){return h(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}_updateMessageProfile(n){var e;let i=(this._core.message||{})["messageDataHandler"],t=null==(e=this._core.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;o&&r?o===e&&r===t||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}):(n.nick=e,n.avatar=t)}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_handleNewMessageList(e){let t=(this._core.message||{})["messageDataHandler"],l=new Map,s=[];return e.forEach(a=>{this._updateMessageProfile(a);let e=1===a.isModified;if(t.isMessageSentByCurrentInstance(a)?a.isModified=e:e=!1,a.isOnlineMessage())a._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(a)||s.push(a);else if(!t.isInMessageList(a)){if(t.storeConversationMessage(a)){let{conversationID:e,conversationType:t,conversationSubType:s,flow:n,_isExcludedFromUnreadCount:i,_isExcludedFromLastMessage:o}=a,r=o?"":a;l.has(e)?(l.get(e).lastMessage=r,"in"!==n||i||l.get(e).unreadCount++):l.set(e,{conversationID:e,type:t,subType:s,unreadCount:i||"in"!==n?0:1,lastMessage:r})}t.isMessageSentByCurrentInstance(a)&&!e||s.push(a)}}),{messages:s,conversationOptions:l}}_fetchUnreadDBMessage(l){return h(this,void 0,void 0,function*(){try{console.log("unread-message-synchronizer._fetchUnreadDBMessage options:",l);var e,t,s,n,i,o,r,a=yield un(l,this._core);return a?({syncFlag:e,unreadMessageList:t,revokedMessageList:s,cookie:n,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}=a,this._parseAndSaveUnreadMessageList(t),{syncFlag:e,cookie:n,unreadMessageList:t,revokedMessageList:s,unreadCountList:i,overflowUnreadCountList:o,groupTipList:r}):null}catch(e){console.log(e)}})}_canContinueSync({cookie:e,syncFlag:t}){return t===_n.START_SYNC||t===_n.SYNCING&&!(null!=(t=this._core)&&t.helper.isEmpty(e))}_parseAndSaveUnreadMessageList(e){e.forEach(e=>{var t=e["ID"];this._unreadDBMessageMap.set(t,e)})}_reset(){this._cookie="",this._unreadDBMessageMap.clear()}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}},pn=new class{init(e){this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),document.addEventListener("visibilitychange",this._visibilityChangeHandler),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_handleVisibilityChange(){var e,t="visible"===document.visibilityState;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:t}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:t})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){document.removeEventListener("visibilitychange",this._visibilityChangeHandler);var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},En=new class{init(e){this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0})}_bindAppActivityEvent(){var e=((null==(e=this._core)?void 0:e.utils)||{})["MINI_APP_NAMESPACE"];e.onAppShow(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!0}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),e.onAppHide(()=>{var e;null!=(e=this._core)&&e.store.set("activityMonitor",{isActive:!1}),null!=(e=this._core)&&e.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})}_reset(){var e;null!=(e=this._core)&&e.store.clear("activityMonitor")}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}},fn=new class{init(e){var{IN_WX_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?En:pn).init(e)}};let mn="none",Sn="online";var vn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){navigator.onLine?this._onOnline():this._onOffline(),this._onOnlineCallback=this._onOnline.bind(this),this._onOfflineCallback=this._onOffline.bind(this),window.addEventListener("online",this._onOnlineCallback),window.addEventListener("offline",this._onOfflineCallback)})}_deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:Sn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:mn})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},In=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return h(this,void 0,void 0,function*(){try{this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),wx.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}_deactivateNetworkMonitoring(){null!==this._mpNetworkStatusCallback&&(wx.offNetworkStatusChange&&wx.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null)}_onNetworkStatusChange(e){var t,{isConnected:e,networkType:s}=e;null!=(t=this._core)&&t.store.set("netWorkMonitor",{isNetworkOnline:e,networkType:s}),null!=(t=this._core)&&t.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:e,networkType:s})}_reset(){var e;this._deactivateNetworkMonitoring(),null!=(e=this._core)&&e.store.clear("netWorkMonitor")}_dispose(){var e;null!=(e=this._core)&&e.notificationCenter.unSubscribeInnerEvent(null==(e=this._core)?void 0:e.InnerEvent.DESTROY,this._dispose,this),this._reset()}},Cn=new class{init(e){var t=e.helper["IN_WX_MINI_APP"];(t?In:vn).init(e)}},Mn=new class{install(e){fn.init(e),Cn.init(e)}};let On=new Set(["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"]),Tn="tui_room_svr.*";var yn=new class{constructor(){this._transferredCommands=On}install(e){var{notificationCenter:e,InnerEvent:t,helper:s}=this._core=e;e.subscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.subscribeInnerEvent(t.LOGOUT,this._reset,this),e.subscribeInnerEvent(t.DESTROY,this._dispose,this),e.subscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),s.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),s.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}transferBusinessCommand(s){return h(this,void 0,void 0,function*(){var t="transferBusinessCommand";try{var{serviceCommand:e=Tn}=s||{};if(this._isValidTransferredCommand(e))return{code:0,data:(yield function(o,r){return h(this,void 0,void 0,function*(){var{helper:e,channel:t}=r,{serviceCommand:s=Tn,data:n}=o||{};let i={};try{i="string"==typeof n?JSON.parse(n):n}catch(e){console.warn(e)}n=e.generateProtocolData({servcmd:s,data:i}),e=""+n.head.seq+s;return t.sendPacket(n,{requestId:e})})}(s,this._core))||{}};throw new this._core.helper.ChatError({code:2995,functionName:t})}catch(e){throw console.warn(e),new this._core.helper.ChatError({code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,data:{},functionName:t})}})}_onCloudConfigUpdate(e={}){try{var t;"string"==typeof e.rtc_cmd&&(t=JSON.parse(e.rtc_cmd),Array.isArray(t))&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}_isValidTransferredCommand(e=""){e=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(e)}_onServerPushBusinessCommand(e){var{OuterEvent:t,notificationCenter:s}=this._core,e=(e||{})["MsgContent"],t=t["ROOM_CUSTOM_DATA_RECEIVED"];s.emitOuterEvent(t,{name:t,data:e})}_reset(){this._transferredCommands=On}_dispose(){var{notificationCenter:e,InnerEvent:t}=this._core;this._reset(),e.unSubscribeInnerEvent(t.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),e.unSubscribeInnerEvent("im_open_push.msg_push",e.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this)}};let An=1,Rn=300;var Nn=new class{constructor(){this._lastMessageSequenceMapOnDisconnect=new Map}install(e){var{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:i}}=this._core=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),e.notificationCenter.subscribeInnerEvent(i.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(e){let t=((null==e?void 0:e.result)||{})["conversationList"],{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){let e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}_recoverGroupHistoryMessage(e){return h(this,void 0,void 0,function*(){let i=this._core["OuterConstant"],o=[],r=[];return yield Promise.all(null==e?void 0:e.map(n=>h(this,void 0,void 0,function*(){var{groupProfile:{groupID:e}={},lastMessage:{lastSequence:t}={}}=n,e=""+i.CONV_GROUP+e,s=this._getLocalLastMessageSequence(e);this._shouldRecoverHistory({localLastMessageSequence:s,serverLastMessageSequence:t})&&(yield this._recoverHistoryForConversation({conversationID:e,localLastMessageSequence:s,serverLastMessageSequence:t,groupTipList:r})),o.push(e.replace(i.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:o,groupTipList:r}})}_recoverHistoryForConversation(e){return h(this,arguments,void 0,function*({conversationID:f,localLastMessageSequence:v,serverLastMessageSequence:I,groupTipList:C}){try{let{utils:{isArray:e,isObject:t,isEmpty:s},OuterEvent:n,OuterConstant:i,notificationCenter:o,message:r,appStore:a,common:{getMessagePreviewText:l}}=this._core,c=I-v,u=Math.min(20,c),d={},_=yield r.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:f,sequence:v+u,direction:i.Direction.FORWARD,count:u}),{nextReqMessageIDFromServer:h,hasNoMoreHistoryMessage:g,messageList:p,serverGroupTipList:E}=_,m=(e(E)&&C.push(...E),g&&h<0),S=[];if(e(p)&&(p.forEach(e=>{r.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===i.CONV_SYSTEM&&(e.isSystemMessage=!1),r.messageDataHandler.storeConversationMessage(e)&&!s(e.payload)&&(S.push(e),e._isExcludedFromLastMessage||(d.lastMessage=Object.assign({},e)))}),0<S.length)&&o.emitOuterEvent(n.MESSAGE_RECEIVED,{name:n.MESSAGE_RECEIVED,data:S}),!m&&0<p.length){let e=p[p.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:f,localLastMessageSequence:e,serverLastMessageSequence:I,groupTipList:C})}t(d.lastMessage)&&(d.lastMessage.messageForShow=l(d.lastMessage.type,d.lastMessage.payload),a.conversationStore.updateConversation(f,d))}catch(v){console.debug("Recovery failed for conversation:",f,v)}})}_updateLastMessageSequenceMapOnDisconnect(){let e=this._core["message"],n=e.messageDataHandler.getContinuousMessagesByConversation();for(let[t,s]of n)if(!t.startsWith("C2C")){let e=Array.from(s.values());var i;0<(null==e?void 0:e.length)&&(i=e[e.length-1].sequence,this._lastMessageSequenceMapOnDisconnect.set(t,i))}}_getLocalLastMessageSequence(e){var t=this._core["message"];return this._lastMessageSequenceMapOnDisconnect.has(e)?this._lastMessageSequenceMapOnDisconnect.get(e):null==(e=(t=t.messageDataHandler.getLocalMessageList(e))[t.length-1])?void 0:e.sequence}_shouldRecoverHistory(e){var t,{localLastMessageSequence:e,serverLastMessageSequence:s}=e;return"number"==typeof e&&"number"==typeof s&&(t=s-e,0!==s)&&0<e&&t>=An&&t<Rn}};let Dn=hs.STANDARD,Pn=[],wn=[dn,function(e){sn.install(e),cn.install(e),ln.install(e)},gn,Mn,yn,Nn];Dn=hs.BASIC,Pn=wn;var Yn,Kn,Hn,uo,_o,ho,fo,Ln=Object.freeze({__proto__:null,ChatError:Ms,buildAndSendPacket:qs,get builtInPlugins(){return Pn},checkBusinessCapabilityBits:Us,deepMerge:zs,getCurrentUserID:Hs,getErrorMessage:Cs,getMessagePreviewText:Zs,isC2CConv:e=>p(e)&&e.slice(0,3)===os.CONV_C2C,isCommunity:xs,isGroupConv:e=>p(e)&&e.slice(0,5)===os.CONV_GROUP,isTopic:Vs,isUnlimitedAVChatRoom:function(){var e;return!(null==(e=$t.store.get("instance"))||!e.unlimitedAVChatRoom)},liteChatInstanceMap:Gs,registerInterceptor:Ls,registerValidateConfig:bs,requireAuth:Os,get sdkEdition(){return Dn},updateGroupAtInfo:(t,s)=>{var{CONV_AT_ME:n,CONV_AT_ALL:i,CONV_AT_ALL_AT_ME:o}=us;if(!function(t,e){let{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:i}=us,{groupID:o,sequence:r}=t,a=!1;return xs({groupID:o})&&e.forEach(e=>{e.messageSequence===r&&(e.atTypeArray.includes(s)&&t.groupAtType.includes(n)&&(e.atTypeArray=[i]),e.atTypeArray.includes(n)&&t.groupAtType.includes(s)&&(e.atTypeArray=[i],e.__random=t.__random,e.__sequence=t.__sequence),a=!0)}),a}(t,s)){let e=[...t.groupAtType];e.includes(n)&&e.includes(i)&&(e=[o]);n={from:t.from,groupID:t.groupID,topicID:t.topicID,messageSequence:t.sequence,atTypeArray:e,__random:t.__random,__sequence:t.__sequence};s.push(n)}},validateAndExecute:ws,validateParameters:As,workflowManager:Fs}),bn=new class{constructor(){this._conversationMap=new Map}getConversationMap(){return this._conversationMap}getConversation(e){return this._conversationMap.get(e)}updateConversation(e,t,s={emit:!0,needSort:!1}){let{emit:n,needSort:i}=s,o=this._conversationMap.get(e);o&&!Ee(t)&&(Object.keys(t).forEach(e=>{o[e]=t[e]}),n)&&$t.notificationCenter.emitInnerEvent(Ht.CONVERSATION_UPDATED,{needSort:i})}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),$t.notificationCenter.emitInnerEvent(Ht.CONVERSATION_UPDATED))}},kn=new class{constructor(){this._groupMap=new Map}getGroupMap(){return this._groupMap}getGroup(e){return this._groupMap.get(e)}updateGroup(e,t){let s=this._groupMap.get(e);s&&!Ee(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},Un=new class{constructor(){this._messagesByConversation=new Map}updateMessage(s,t,e){let n,{operation:i,updateUnreadCount:o=!0}=e,r=_(e,["operation","updateUnreadCount"]),a=[];for(let e of t){let t=null==(n=this._messagesByConversation.get(s))?void 0:n.get(e);if(!t)return!1;Object.keys(r).forEach(e=>{t[e]=r[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(i,{conversationID:s,messageList:a,updateUnreadCount:o}),a}getMessagesByConversation(e){return[...(null==(e=this._messagesByConversation.get(e))?void 0:e.values())||[]]}getMessages(){return this._messagesByConversation}_emitMessageStoreOperationEvent(e,t){var s=t["conversationID"];Vs(s)?$t.notificationCenter.emitInnerEvent(ts[e],t):$t.notificationCenter.emitInnerEvent(e,t)}},Gn=new class{constructor(){this.userProfileMap=new Map,this.friendMap=new Map}getUserProfileMap(){return this.userProfileMap}getFriendMap(){return this.friendMap}getUserProfile(e){return this.userProfileMap.get(e)}getFriend(e){return this.friendMap.get(e)}},Fn=Object.freeze({__proto__:null,conversationStore:bn,groupStore:kn,messageStore:Un,userStore:Gn});let xn={on:$t.notificationCenter.subscribeOuterEvent.bind($t.notificationCenter),off:$t.notificationCenter.unSubscribeOuterEvent.bind($t.notificationCenter),destroy:function(){return h(this,void 0,void 0,function*(){var e,t;try{null!=(e=$t.store.get("login"))&&e.isLogin&&(yield xn.logout()),$t.notificationCenter.emitInnerEvent(Ht.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{$t.notificationCenter.emitOuterEvent(Yt.SDK_DESTROY,{SDKAppID:null==(t=$t.store.get("instance"))?void 0:t.sdkAppId}),Gs.clear(),ks.clear(),Fs.destroy(),$t.destroy()}})},callExperimentalAPI:function(e,t){return Vn[e]?Vn[e](t):Promise.reject(new Error(`API ${e} is not found`))},use:ks.installExternalPlugin.bind(ks),registerPlugin:function(e){console.log("registerPlugin",e)},setLogLevel:function(e){console.log("setLogLevel",e),!$t||"function"!=typeof $t.setLogLevel||null!=$t&&$t.setLogLevel(e)}},Vn={},Bn={};function $n(e){let{apiName:n,context:t,methodName:i=n,matcher:s}=e;Bn[n]||(Bn[n]=[]),Bn[n].push({context:t,methodName:i,matcher:s}),xn[n]&&1!==Bn[n].length||(xn[n]=(...t)=>{ws(i,t);var s=Bn[n];for(let e of s)if(!e.matcher||e.matcher(t))return e.context[e.methodName].bind(e.context)(...t)})}function qn(e,t,s){s=s||e;Vn[e]=t[s].bind(t)}function Wn(){return Object.assign(Object.assign({InnerEvent:Ht,InnerEventSubType:$t.notificationCenter.InnerEventSubType,OuterEvent:Yt,OuterConstant:us,SignalingEvent:jt,helper:Object.assign(Object.assign(Object.assign({},$t.utils),$t.common),{registerApi:$n,registerExperimentalAPI:qn,registerInterceptor:Ls,registerValidateConfig:bs,checkBusinessCapabilityBits:Us,registerWorkflowStep:Fs.registerWorkflowStep.bind(Fs),ChatError:Ms}),apiMap:xn},$t),{constants:Object.assign(Object.assign({},Is),$t.constants),common:Object.assign(Object.assign({},Ln),$t.common),utils:$t.utils,appStore:Fn})}Vn.statTUIKeyFeatures=function(e){console.log("statTUIKeyFeatures",e)},function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Yn=Yn||{}),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Kn=Kn||{}),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Hn=Hn||{});let jn={[Kn.multipleAccount]:"multipleAccount",[Kn.multipleDevice]:"multipleDevice",[Kn.restApi]:"REST_API_Kick",[Hn.multipleAccount]:"multipleAccount",[Hn.multipleDevice]:"multipleDevice",[Hn.restApi]:"REST_API_Kick",[Hn.usersigExpired]:"userSigExpired"},zn="login_online_presence_task",{ERROR:Zn,DESTROY:Jn,FORCE_OFFLINE:Xn}=Ht,{KICKED_OUT_MULT_ACCOUNT:Qn,KICKED_OUT_MULT_DEVICE:eo,KICKED_OUT_REST_API:to,ACCOUNT_A2KEY_EXPIRED:so,MSG_A2KEY_EXPIRED:no}=_s;class oo{init(){var e=$t["notificationCenter"];e.subscribeInnerEvent(Xn,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(Zn,no,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Zn,so,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Zn,Qn,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Zn,eo,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Zn,to,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Jn,this._dispose,this)}_handleForceOfflineFromServerPush(e){var{EventArray:e=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(e).forEach(e=>{var{KickType:e,NewInstInfo:t}=e["KickoutMsgNotify"];this._processKickedOutReasonInfo({kickedOutReasonCode:e,newInstanceInfo:t})})}_extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{return this._isKickedOut(null==(e=null==e?void 0:e.KickoutMsgNotify)?void 0:e.KickType)})}_handleForceOfflineFromResponse(e){e=e.errorCode;this._processKickedOutReasonInfo({kickedOutReasonCode:e})}_processKickedOutReasonInfo(t){return h(this,void 0,void 0,function*(){var e=t["kickedOutReasonCode"];try{this._logKickedOutEvent(t),yield $t.login.loginAction.logout(Yn.KICKED_OUT)}catch(e){console.debug(e)}finally{$t.notificationCenter.emitOuterEvent(Yt.KICKED_OUT,{data:{type:jn[e]},name:Yt.KICKED_OUT}),[Kn.restApi,so,no].includes(e)&&$t.channel.reconnect()}})}_logKickedOutEvent(e){var{kickedOutReasonCode:e,newInstanceInfo:t={}}=e,s=$t.ssoLog.createSSOLogData({method:"kickedOut"}),e=`type:${jn[e]} newInstanceInfo: `+JSON.stringify(t);s.setLogInfo({message:e}).end(!0),console.warn("loginModule."+e)}_isKickedOut(e){return[Kn.multipleAccount,Kn.multipleDevice,Kn.restApi].includes(e)}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Xn,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(Zn,so,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Zn,no,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Zn,Qn,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Zn,eo,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Zn,to,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Jn,this._dispose,this)}}function io(){return h(this,void 0,void 0,function*(){let e="im_open_status.wslogin",t=$t.common.generateProtocolData({servcmd:e,data:{state:"Online",isWebUniapp:0,InstType:0,customInfo:""}}),s=""+t.head.seq+e;try{let d=yield $t.channel.sendPacket(t,{timeout:9e4,requestId:s});if(d){let{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:o,A2Key:r,RichMsgAuthKey:a,ErrorCode:l,ErrorInfo:c,ActionStatus:u}=d;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:o,a2Key:r,authKey:a,errorCode:l,errorInfo:c,actionStatus:u}}}catch(e){throw console.warn(e),e}})}class ro{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120}init(){var{notificationCenter:e,store:t}=$t;t.set("login",{isReady:!1}),$n({apiName:"login",context:this}),$n({apiName:"logout",context:this}),$n({apiName:"getLoginUser",context:this}),$n({apiName:"isReady",context:this}),e.subscribeInnerEvent(Ht.RECONNECTED,this._reLogin,this),$t.notificationCenter.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}login(s){return h(this,void 0,void 0,function*(){let e=this._getUiPlatform(),t=($t.store.get("instance")||{})["sdkEdition"],n=$t.ssoLog.createSSOLogData({method:"login",eventType:4,uiPlatform:e,message:t});try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new Ms({functionName:"login",code:_s.REPEAT_LOGIN});let e=yield this._performLogin(s);return this._validateAfterLogin(e),this._handleLoginSuccess(e),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),{code:this._latestLoginAt=0,data:e}}catch(e){let t=e["errorCode"],s=(t!==_s.REPEAT_LOGIN&&(this._latestLoginAt=0),new Ms({functionName:"login",code:t}));throw n.setError(s).end(!0),s}})}_getUiPlatform(){var{store:e,utils:{IN_BROWSER:t,isH5:s}}=$t,e=(null==(e=e.get("instance"))?void 0:e.scene)||"";let n=e;return t&&(n=e+"_web",s)&&(n=e+"_h5"),ms[n]}_reLogin(){return h(this,void 0,void 0,function*(){var e,t,s,n,i,o;try{this._isLoginIn()&&(t=$t.ssoLog.createSSOLogData({method:"reLogin"}),s=yield io())&&({instanceID:n,customStatus:i}=s,$t.store.set("login",{statusInstanceId:n}),Fs.executeWorkflow(gs.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:i,statusType:ss.USER_STATUS_ONLINE}),o=`socketId:${null==(e=$t.channel.getSocketAdapter())?void 0:e.getId()} instanceId:`+n,t.setLogInfo({message:o}).end(!0))}catch(e){console.warn(e)}})}logout(){return h(this,arguments,void 0,function*(s=Yn.USER_INITIATED){let e=$t.ssoLog.createSSOLogData({method:"logout"});e.setLogInfo({moreMessage:"identifier:"+Hs()});try{yield this._performLogout(s),e.end(!0),$t.ssoLog.uploadSSOLogData()}catch(s){let e=s["errorCode"],t=new Ms({functionName:"logout",code:e});this._handleLogoutError(t)}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?Hs():""}isReady(){var e;return null==(e=$t.store.get("login"))?void 0:e.isReady}_updateAndEmitSDKReady(){$t.store.set("login",{isReady:!0}),setTimeout(()=>{$t.notificationCenter.emitOuterEvent(Yt.SDK_READY,{name:Yt.SDK_READY})},1)}_updateAndEmitSDKNotReady(){$t.store.set("login",{isReady:!1}),$t.notificationCenter.emitOuterEvent(Yt.SDK_NOT_READY,{name:Yt.SDK_NOT_READY})}_validateAfterLogin(e){var t,s="login";if(!e)throw new Ms({functionName:s,message:"login response is empty"});var{tinyID:e,a2Key:n}=e||{},i=$t.ssoLog.getSSOLogData(s);if(!e){let e=new Ms({functionName:s,code:_s.NO_TINYID});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}if(!n){let e=new Ms({functionName:s,code:_s.NO_A2KEY});throw null!=(t=null==i?void 0:i.setError)&&t.call(i,e).end(),e}}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:Cs({code:"RepeatLogin",replacement1:null==(e=$t.store.get("login"))?void 0:e.userId}),repeatLogin:!0}}}_performLogin(s){return h(this,void 0,void 0,function*(){var{userID:e,userSig:t}=s;return $t.store.set("login",{userId:e,userSig:t}),this._latestLoginAt=Date.now(),io()})}_ensureAsyncComplete(){return h(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){var t=$t.common["timeManager"],{helloInterval:s,timeStamp:n,customStatus:i,purchaseBits:o}=e;t.calculateTimeOffsetWithServer(this._latestLoginAt,1e3*n),this._helloInterval=s||120,this._updateLoginStore(e),$t.user.userStatus.setCustomStatus(i),Fs.executeWorkflow(gs.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:o}),$t.common.taskScheduler.addTask({id:zn,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this}),this._logLoginSuccess(e)}_performLogout(e){return function(s){return h(this,void 0,void 0,function*(){var e=s["logoutReason"],t="im_open_status.wslogout",e=$t.common.generateProtocolData({servcmd:t,data:{wslogout_type:e,isWebUniapp:0}}),t=e.head.seq+t;return yield $t.channel.sendPacket(e,{requestId:t})})}({logoutReason:e})}_handleLogoutError(e){$t.ssoLog.getSSOLogData("logout").setError(e).end(),console.error("logout "+e)}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),Fs.reset(),$t.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){var{a2Key:e,tinyID:t,instanceID:s,authKey:n}=e;$t.store.set("login",{a2Key:e,tinyID:t,statusInstanceId:s,authKey:n,isLoggedIn:!0})}_logLoginSuccess(e){var t=$t.ssoLog.getSSOLogData("login"),{helloInterval:e,instanceID:s,timeStamp:n,customStatus:i}=e,o=null==(o=$t.channel.getSocketAdapter())?void 0:o.getId(),r=$t.common.timeManager.getTimeOffsetWithServer(),{appId:a,href:l}=$t.store.get("instance")||{},o=`login._logLoginSuccess socketID:${o} scene: helloInterval:${e} instanceID:${s}
2
+ timeStamp:${n} offset:${r} customStatus:${i} href: ${l} appId: `+a;console.log("login ok. "+o),t.updateLogCreatedAtByTimeOffset(),t.setLogInfo({moreMessage:o}).end()}_sendOnlinePresenceRequest(){return h(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{e="im_open_status.wshello",t=$t.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),e=t.head.seq+e,yield $t.channel.sendPacket(t,{requestId:e})}catch(e){console.warn("Login._sendOnlinePresenceRequest error:",e)}var e,t})}_isLoginIn(){var e;return!0===(null==(e=$t.store.get("login"))?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){console.log("Login reset"),$t.common.taskScheduler.removeTask(zn),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,$t.store.clear("login"),$t.store.set("login",{isReady:!1})}_dispose(){console.log("Login dispose"),this._reset();var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Ht.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this)}}let ao={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},co={logout:!0};class lo{constructor(){this.loginAction=new ro,this.kickedOutHandler=new oo,this.loginAction.init(),this.kickedOutHandler.init(),bs({auth:co,params:ao})}}!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(uo=uo||{}),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(_o=_o||{}),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_IMAGE="TIMImageElem",e.MSG_AUDIO="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_GRP_TIP="TIMGroupTipElem",e.MSG_GRP_SYS_NOTICE="TIMGroupSystemNoticeElem",e.MSG_MERGER="TIMRelayElem"}(ho=ho||{});let go={1:_o.MSG_PRIORITY_HIGH,2:_o.MSG_PRIORITY_NORMAL,3:_o.MSG_PRIORITY_LOW,4:_o.MSG_PRIORITY_LOWEST},po=0,Eo=1,mo=(!function(e){e.IN="in",e.OUT="out"}(fo=fo||{}),2),So={};function vo(e){var t,s,n;return e?(void 0===So[e]?(t=("3"+(n=new Date).getHours()).slice(-2),s=("0"+n.getMinutes()).slice(-2),n=("0"+n.getSeconds()).slice(-2),So[e]=parseInt([t,s,n,"0001"].join(""),10),console.log("autoIncrementIndex start index:"+So[e])):So[e]+=1,So[e]):0}class Io{constructor(e){this.ID="",this.random=0,this.sequence=0,this.nameCard="",this.isRead=!1,this.isPeerRead=!1,this.isDeleted=!1,this.isResend=!1,this.hasRiskContent=!1,this._onlineOnlyFlag=!1,this.atUserList=[],this._groupAtInfoList=[],this.isBroadcastMessage=!1,this.priority=_o.MSG_PRIORITY_NORMAL,this._relayFlag=!1;var t,{clientTime:s=$t.common.timeManager.getServerTimeSeconds()||0,senderTinyID:n,currentUser:i,needReadReceipt:o,isSupportExtension:r,customModerationConfigurationId:a,to:l,from:c,nick:u="",avatar:d="",time:_,messageControlInfo:h,tinyID:g,cloudCustomData:p="",messageLifeTime:E,messageVersion:m=0,conversationType:S,sequence:f,checkResult:v=0,isPlaceMessage:I=0,messageFlagBits:C,receiverList:M,isSystemMessage:O=!1,status:T=Jt.SUCCESS,revokeReason:y="",conversationSubType:A,clientSequence:R,protocol:N="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:P={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:w,groupProfile:L,atUserList:b,flow:k,isRead:U=!1}=e;this.clientTime=s,this.senderTinyID=n||g,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===r||1===r,this._cmConfigID=a,this.to=l,this.nick=u,this.avatar=d,this.protocol=N,this.random=void 0===w?(t=t||99999999,Math.round(Math.random()*t)):w,this.time=_||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!(null==h||!h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!(null==h||!h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=p,this.messageLifeTime=E,this.from=c||null,this.sequence=f||0,this.conversationType=S||uo.CONV_C2C,this.hasRiskContent=1<v,this.version=m,this.isPlaceMessage=I,this.isRevoked=2===I||8===C,this.isSystemMessage=O,this.readReceiptInfo=P,this.revokeReason=y,this.revokerInfo=D,this._receiverList=M,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=R||f||0,this.status=T,this.atUserList=b||[],this.flow=k,this.isRead=U,this.reInitialize(i),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(L)}getElements(){return this._elements}isOnlineMessage(){return 0===this.messageLifeTime}setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}setRelayFlag(e){this._relayFlag=e}validateBeforeSend(){var e,t;return this._relayFlag?{isValid:!0}:0<(null==(e=this._elements)?void 0:e.length)?null==(t=null==(e=this._elements[0])?void 0:e.validateBeforeSend)?void 0:t.call(e):{isValid:!1}}_updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}_initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===uo.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}_extractGroupInfo(e){var t,s;e&&({From_AccountNick:e,From_AccountHeadurl:t,MsgFrom_AccountExtraInfo:s}=e,s=(s||{})["NameCard"],"string"==typeof e&&(this.nick=e),"string"==typeof t&&(this.avatar=t),"string"==typeof s)&&(this.nameCard=s)}reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}_concatConversationID(e){var t=this.conversationType;t!==uo.CONV_SYSTEM?(e=t!==uo.CONV_C2C||e===this.from?this.to:this.from,this.conversationID=e?""+t+e:null):this.conversationID=uo.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=vo(e)),0===this.sequence&&this.conversationType===uo.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===uo.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}setIsRead(e){this.isRead=e}}class Co{static parseServerPushElement(e){var{MsgContent:e={}}=e,{Data:e,Ext:t,Desc:s}=e;return new Co({data:e,description:s,extension:t})}constructor(e){this.type=ho.MSG_CUSTOM;var{data:e="",description:t="",extension:s=""}=e;this.content={data:e,description:t,extension:s}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},{data:e,description:t,extension:s}=e?this.payload:this.content;return{MsgType:this.type,MsgContent:{Data:e,Ext:s,Desc:t}}}validateBeforeSend(){let t=$t.utils["isEmpty"],e=[this.content.data,this.content.description,this.content.extension].some(e=>!t(e));return{isValid:e,error:e?null:{message:"content can not be empty"}}}}class Mo{static parseServerPushElement(e){var{MsgContent:e={Text:""}}=e,e=e["Text"];return new Mo({text:e})}constructor(e){this.type=Zt.MSG_TEXT,this.content={text:e.text||""}}validateBeforeSend(){var e;return 0<(null==(e=null==(e=this.content)?void 0:e.text)?void 0:e.length)?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}transformToServerFormat(e){var{isMergerMessage:e=!1}=e||{},e=(e?this.payload:this.content)["text"];return{MsgType:this.type,MsgContent:{Text:e}}}}var Oo=new class{constructor(){this._elementClassMap={[ho.MSG_CUSTOM]:Co,[ho.MSG_TEXT]:Mo}}init(){$n({apiName:"createCustomMessage",context:this}),$n({apiName:"createTextMessage",context:this})}registerElementClass(e,t){void 0!==t.prototype&&"constructor"in t.prototype&&(this._elementClassMap[e]=t)}getElementClass(e){return this._elementClassMap[e]}createMessage(e){var{from:t,flow:s=fo.OUT}=e,n=($t.store.get("login")||{})["userId"],t=(this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=fo.OUT),Object.assign(Object.assign({},e),{currentUser:n}));return new Io(t)}createCustomMessage(t){let e=Hs(),s=this.createMessage(Object.assign(Object.assign({},t),{from:e})),n=this._elementClassMap[ho.MSG_CUSTOM];if(!s)return null;if(n){let e=new n(t.payload);s.setElement(e)}return s}createTextMessage(e){var t,s;return e?(t="string"==typeof e.payload?e.payload:(null==(t=null==e?void 0:e.payload)?void 0:t.text)||"",t=new Mo({text:t}),s=Hs(),(e=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:s}))).setElement(t),e):null}_updateWithSenderInfo(e){var{nick:t,avatar:s}=e,{userId:n,tinyID:i}=$t.store.get("login")||{},o=Gn.getUserProfile(n);return e.nick=t||(null==o?void 0:o.nick)||"",e.avatar=s||(null==o?void 0:o.avatar)||"",e.tinyID=e.tinyID||i||"",e.from=n,e.status=Jt.UNSENT,e.flow=fo.OUT,e}_isMultiEndpointSyncMessage(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===fo.IN}_isSendByCurrentInstance(e){var{from:e,flow:t,currentUser:s}=e;return e===s&&t===fo.OUT}};let To={PushFlag:0,Title:"",Desc:"",Ext:"",ApnsInfo:{Sound:"",BadgeMode:0,IsVoipPush:void 0,Image:"",InterruptionLevel:"active",ContentAvailable:0},AndroidInfo:{Sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},yo={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Ao={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Ro(n,i){return Object.keys(i).forEach(e=>{var{range:t,defaultValue:s}=i[e];n[e]=t.includes(n[e])?n[e]:s}),n}function No(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Do(e){var{androidInfo:e={},androidOPPOChannelID:t=""}=e,t=e.OPPOChannelID||t,e=Ro(e,yo),{sound:s="",FCMChannelID:n=""}=e,e=_(e,["sound","FCMChannelID"]);return Object.assign(Object.assign({},e),{Sound:No(s),OPPOChannelID:t,GoogleChannelID:n})}function Po(e){var{apnsInfo:e={},ignoreIOSBadge:t=!1,disableVoipPush:s}=e,e=Ro(e,Ao),{ignoreIOSBadge:n,disableVoipPush:i,enableIOSBackgroundNotification:o}=e,e=_(e,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),n=!0===n||!0===t?1:0;let r;return g(s)||(r=!1===s?1:0),g(i)||(r=!1===i?1:0),Object.assign(Object.assign({},e),{BadgeMode:n,IsVoipPush:r,ContentAvailable:o?1:0})}function wo(e){return $t.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Po(e),AndroidInfo:Do(e)}:To}function Lo(e){let{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:i,IsSyncMsg:o,MsgBody:r,MsgClientTime:a,MsgLifeTime:l,MsgRandom:c,MsgSeq:u,MsgTimeStamp:d,SendMsgControl:_,SupportMessageExtension:h,TinyId:g,MsgCheckResult:p,CloudCustomData:E,MsgVersion:m,MsgFlagBits:S,RevokerInfo:f}=e,v,{From_Account:I,To_Account:C}=e;if(1===o){let e=C;C=I,I=e}if(f){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=f;v={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:I,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:o,clientTime:a,messageLifeTime:l,random:c,sequence:u,time:d,messageControlInfo:{excludedFromLastMessage:1===(null==_?void 0:_.NoLastMsg),excludedFromUnreadCount:1===(null==_?void 0:_.NoUnread)},isSupportExtension:h,to:C,tinyID:g,checkResult:p,cloudCustomData:E,revokerInfo:v,messageVersion:m,messageFlagBits:S,readReceiptSentByPeer:i,elements:Go(r)}}function bo(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,To_Account:r,MsgVersion:a,CloudCustomData:l}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,to:r,elements:Go(t),messageVersion:a,cloudCustomData:l}}function ko(e){let{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:i,MsgClientTime:o,MsgRandom:r,MsgSeq:a,MsgTimeStamp:l,SendMsgControl:c,SupportMessageExtension:u,TinyId:d,CloudCustomData:_,MsgVersion:h,MsgCheckResult:g,NeedReadReceipt:p,IsPlaceMsg:E,RevokerInfo:m,GroupAtInfo:S}=e,f,v=_o.MSG_PRIORITY_NORMAL;if(Object.keys(go).includes(String(e.MsgPriority))&&(v=go[e.MsgPriority]),m){let{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=m;f={reason:e,revoker:t,revokerFromUin:s,userID:t}}var I=function(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===po?t.push(e.GroupAt_Account):e.GroupAtAllFlag===Eo&&t.push(us.MSG_AT_ALL)}),t}(S);return{clientSequence:t,from:s,groupProfile:n,clientTime:o,priority:v,random:r,sequence:a,time:l,messageControlInfo:{excludedFromLastMessage:1===(null==c?void 0:c.NoLastMsg),excludedFromUnreadCount:1===(null==c?void 0:c.NoUnread)},isSupportExtension:u,tinyID:d,cloudCustomData:_,messageVersion:h,messageCheckResult:g,needReadReceipt:p,isPlaceMessage:E,revokerInfo:f,atUserList:I,elements:Go(i),to:Uo(e)}}function Uo(e){var{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=$t,{ToGroupId:e,GroupInfo:{MillionGroupFlag:n=0,TopicId:i}={}}=e;return n!==s||t(i)?e:i}function Go(e){var t;return e?Array.isArray(e)?e.map(e=>{var t=$t.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}):null==(t=$t.message.messageFactory.getElementClass(e.MsgType))?void 0:t.parseServerPushElement(e):null}function Fo(e){var{From_Account:e,MsgBody:t,MsgClientTime:s,MsgRandom:n,MsgSeq:i,MsgTimeStamp:o,GroupId:r,TopicId:a,MsgVersion:l,CloudCustomData:c}=e;return{from:e,clientTime:s,random:n,sequence:i,time:o,groupID:r,topicID:a,elements:Go(t),messageVersion:l,cloudCustomData:c}}function xo({conversationUpdateFields:e,message:t}){var{conversationID:s,conversationType:n,conversationSubType:i,flow:o,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,a=a?"":t,t=!r&&o===fo.IN;e.has(s)?(e.get(s).lastMessage=a,t&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:i,unreadCount:t?1:0,lastMessage:a})}function Vo(e){return e.filter(e=>{var t=!Ee(null==e?void 0:e.getElements()),s=1===(null==e?void 0:e.isPlaceMessage);return t||$t.ssoLog.createSSOLogData({method:"emptyMessageBody"}).setLogInfo({message:`from:${e.from} to:${e.to} sequence:`+e.sequence}).end(),t&&!s})}var Bo=Object.freeze({__proto__:null,autoIncrementIndex:vo,filterValidMessages:Vo,parseServerGroupMessage:ko,parseServerPushC2CModifyMessage:bo,parseServerPushGroupModifyMessage:Fo,parseServerPushMessage:Lo,parseServerPushMessageElement:Go,updateConversationFields:xo});let $o=$t.utils["isPlainObject"];function qo(e,t={}){let{onlineUserOnly:s,messageControlInfo:n}=t,i=t["offlinePushInfo"],o=(e.conversationType===uo.CONV_C2C&&!0===s&&(i?i.disablePush=!0:i={disablePush:!0}),"");"string"==typeof e.cloudCustomData&&0<e.cloudCustomData.length&&(o=e.cloudCustomData);var r=[];if(n&&$o(n)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&r.push("NoUnread"),!0===t&&r.push("NoLastMsg"),!0===s&&r.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:o,messageControlInfo:r,offlinePushInfo:i}}function Wo(e){var t,{webhookInfo:{disableCloudMessagePreHook:e=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(e||s)return t=[],e&&t.push("ForbidBeforeSendMsgCallback"),s&&t.push("ForbidAfterSendMsgCallback"),t}function Yo(t,s){return h(this,void 0,void 0,function*(){var e=yield qs((t.conversationType===uo.CONV_GROUP?function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=qo(e,t),a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return f(e._receiverList)&&0<e._receiverList.length&&(l=e._receiverList,50<e._receiverList.length)&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit")),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null==(s=$t.store.get("login"))?void 0:s.userId,GroupId:e.to,MsgBody:a,CloudCustomData:i,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:n?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:wo(r),SendMsgControl:n?void 0:o,NeedReadReceipt:!0===e.needReadReceipt?1:0,To_Account:l,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,ForbidCallbackControl:Wo(t)}}}:function(e,t){var s,{onlineUserOnly:n,cloudCustomData:i,messageControlInfo:o,offlinePushInfo:r}=qo(e,t),n=!0===n?0:void 0,a=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null==(s=$t.store.get("login"))?void 0:s.userId,To_Account:e.to,MsgBody:a,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:n,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==n?o:void 0,MsgClientTime:e.clientTime,IsNeedReadReceipt:!0===e.needReadReceipt?1:0,SupportMessageExtension:!0===e.isSupportExtension?1:0,IsRelayMsg:!0===e._relayFlag?1:0,CustomModerationConfigID:e._cmConfigID,OfflinePushInfo:wo(r),forbidCallbackControl:Wo(t)}}})(t,s));return e?{time:e.MsgTime,messageDropReason:e.MsgDropReason,sequence:e.MsgSeq}:null})}let Ko=$t.utils["isPlainObject"],{MSG_AUDIO:Ho,MSG_FILE:jo,MSG_IMAGE:zo,MSG_VIDEO:Zo,MSG_MERGER:Jo}=us;class Xo{init(){$n({apiName:"sendMessage",context:this,matcher:e=>![Ho,jo,zo,Zo,Jo].includes(e[0].type)})}sendMessage(u,t){return h(this,void 0,void 0,function*(){let n=$t.ssoLog.createSSOLogData({method:"sendMessage"}),{TOTAL_COUNT:e,SEND_COST:r,SUCCESS_COUNT:a,FAILED_COUNT:o}=vs;if(!(u instanceof Io)){let e=new Ms({code:_s.MSG_INSTANCE_REQUIRED});throw n.setError(e).end(),e}let i=u.validateBeforeSend();if(!i.isValid){let{code:e,message:t=""}=i.error||{},s=new Ms({code:e,message:t});throw n.setError(s).end(),s}this._reportMessageSendQuality({name:e,message:u});let l=!1;var c=($t.message||{})["messageDataHandler"];try{let n=(t||{})["messageControlInfo"],i=null,o=(c.addRandomOfSentMessage(u.random),Date.now());if(u.conversationType===uo.CONV_C2C?(l=!0===(null==t?void 0:t.onlineUserOnly),i=yield Yo(u,t)):u.conversationType===uo.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(u),i=yield Yo(u,t)),i){let{messageDropReason:e,sequence:t,time:s}=i;if(this._updateNickAndAvatarOfSentMessageByMe(u),e&&this._logRateLimitInfo(u,t),this._reportMessageSendQuality({name:a,message:u}),this._reportMessageSendQuality({name:r,message:u,startTs:o}),!0===u.isResend){let e=c.findMessage(u.ID);e&&(console.log("sendMessage resend ok. ID:"+e.ID),c.deleteConversationMessage(e))}return u.status=Jt.SUCCESS,u.time=s,u.conversationType===uo.CONV_GROUP&&(u.sequence=t),l?u._onlineOnlyFlag=!0:(c.storeConversationMessage(u),this._applySentMessageControlInfo(u,n),this._emitOnlineMessageSent(u)),{code:0,data:{message:u}}}}catch(e){u.status=Jt.FAIL,c.removeRandomOfSentMessage(u.random);let{errorCode:t,errorMessage:s="",errorInfo:n=s}=e||{},i=(this._hasRiskContent(t)&&(u.hasRiskContent=!0),l||this._isRejectedByRestApi(t)||c.storeConversationMessage(u),this._reportMessageSendQuality({name:o,message:u,error:e}),new Ms({code:t,message:n,data:{message:u}}));throw this._logSendMessageError({message:u,error:i}),i}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return 10100<=e&&e<=10200||120001<=e&&e<=13e4}_logSendMessageError({message:e,error:t}){var s=$t.ssoLog.createSSOLogData({method:"sendMessage"});let n=`head.seq: type:${e.type} from:${e.from} to:`+e.to;if($t.utils.IN_BROWSER){if("connection"in navigator){let e=navigator.connection;n+=` downlink:${e.downlink} effectiveType:${e.effectiveType} rtt:`+e.rtt}if("memory"in window.performance){let e=window.performance.memory;n+=` usedJSHeapSize:${e.usedJSHeapSize} totalJSHeapSize:${e.totalJSHeapSize} jsHeapSizeLimit:`+e.jsHeapSizeLimit}}s.setLogInfo({message:n}).setError(t).end()}_emitOnlineMessageSent(e){var t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,i=Vs(s)?Ht.TOPIC_NEW_MESSAGE:Ht.NEW_MESSAGE;$t.notificationCenter.emitInnerEvent(i,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&Ko(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0)}_logRateLimitInfo(e,t){var s=$t.ssoLog.createSSOLogData({method:"messageDropReason"}),e=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:`+messageDropReason;s.setLogInfo({message:e}).end(),console.warn("sendMessage "+e)}_updateNickAndAvatarOfSentMessageByMe(e){var t=($t.message||{})["messageDataHandler"];let s=!1;var n,i=e["conversationID"],o=t.getLatestMsgSentByMe(i);o&&({nick:o,avatar:n}=o,s=o!==e.nick||n!==e.avatar||s)&&t.updateNickAndAvatarOfSentMessage({conversationID:i,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}_validateBeforeSendGroupMessage(i){return h(this,void 0,void 0,function*(){var{to:t,from:s}=i;let n=t,e=kn.getGroup(n);if(xs({groupID:n})&&null!=e&&e.isSupportTopic)throw new Ms({code:_s.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(Vs(t)&&([n]=t.split(cs.TOPIC),e=kn.getGroup(n)),!e&&"function"==typeof(null==xn?void 0:xn.getGroupProfile)){let e=yield xn.getGroupProfile({groupID:n});if((null==(t=null==(t=null==e?void 0:e.data)?void 0:t.group)?void 0:t.type)===us.GRP_AVCHATROOM){let e=Cs({code:_s.MSG_SEND_FAIL_NOT_IN_AV,replacement1:s,replacement2:n});throw new Ms({code:_s.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){$t.notificationCenter.emitInnerEvent(Ht.QUALITY_STAT,{label:Ss.MESSAGE_SEND_SUCCESS_RATE,data:e})}}class Qo{constructor(e){this.value=e,this.next=null}}class ei{constructor(e){this.head=null,this.tail=null,this.size=0,this.capacity=e}append(e){this.size>=this.capacity&&this.removeHead();e=new Qo(e);this.head?this.tail.next=e:this.head=e,this.tail=e,this.size+=1}delete(t){if(this.head)if(this.head.value===t)this.head=this.head.next;else{let e=this.head;for(;e.next;){if(e.next.value===t)return void(e.next=e.next.next);e=e.next}}}has(e){if(!this.head)return!1;let t=this.head,s=!1;for(;t;)t.value===e&&(s=!0),t=t.next;return s}removeHead(){this.head&&(this.head===this.tail?(this.head=null,this.tail=null):this.head=this.head.next,--this.size)}peek(){var e;return null==(e=this.head)?void 0:e.value}length(){return this.size}isEmpty(){return 0===this.size}isFull(){return this.size===this.capacity}clear(){this.head=null,this.tail=null,this.size=0}}var ti=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new ei(100),$t.notificationCenter.subscribeInnerEvent(Ht.LOGOUT,this._reset,this),$t.notificationCenter.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}get _messagesByConversation(){return Un.getMessages()}storeConversationMessage(e,t=!1){var s=e["conversationID"];return!!s&&(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),!this._shouldSkipStoreMessage(e,t))&&(t=this._getUniqueIdOfMessage(e),this._messagesByConversation.get(s).set(t,e),this._updateLatestMessageMap(e),!0)}_updateLatestMessageMap(e){var t=e["conversationID"];"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}_shouldSkipStoreMessage(e,t){var s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null!=n&&n.has(s)){let e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}deleteConversationMessage(e){var{conversationID:t=""}=e,e=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(t)&&null!=(t=this._messagesByConversation.get(t))&&t.delete(e)}modifyConversationMessage(a,t){var l;if(this._messagesByConversation.has(a)||this._sparseMessagesByConversation.has(a)){let e=this._getUniqueIdOfMessage(t),r=this._getMessageFromLocalMessage(a,e);if(r){let{messageVersion:s,elements:n,cloudCustomData:i,checkResult:e=0}=t,o=1<e;if(console.log(`conversationToMessageMap modifyConversationMessage localVersion:${r.version} remoteVersion:`+s),r.version<s){let e=this._getUniqueIdOfMessage(r),t=fe(n);return null!=(l=this._messagesByConversation.get(a))&&l.has(e)?Un.updateMessage(a,[e],{isModified:!0,version:s,_elements:t,payload:t[0].content,type:t[0].type,cloudCustomData:i,hasRiskContent:o,operation:Xt.modify}):(r.version=s,r._elements=t,r.payload=r._elements[0].content,r.type=r._elements[0].type,r.cloudCustomData=i,r.isModified=!0,r.hasRiskContent=o),{isUpdated:!0,message:r}}return{isUpdated:!1,message:r}}}return{isUpdated:!1,message:null}}_getMessageFromLocalMessage(e,s){var t;if(this._messagesByConversation.has(e))return null==(t=this._messagesByConversation.get(e))?void 0:t.get(s);if(this._sparseMessagesByConversation.has(e)){let t=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<t.length;e++)if(this._getUniqueIdOfMessage(t[e])===s)return t[e]}return null}findMessage(t){let s=null,e=Array.from(this._messagesByConversation.values());for(var n of e)if(s=Array.from(n.values()).find(e=>e.ID===t)||null)break;if(!s){let e=Array.from(this._sparseMessagesByConversation.values());for(var i of e)if(s=i.get(t)||null,s)break}return s}deleteConversationMessageList(e){this._messagesByConversation.has(e)&&(this._messagesByConversation.delete(e),this._latestMessageSentByMeMap.delete(e),this._latestMessageSentByPeerMap.delete(e)),this._sparseMessagesByConversation.has(e)&&this._sparseMessagesByConversation.delete(e)}revokeMessage({conversationID:t,sequence:s,random:n,revoker:i}){let e=this._messagesByConversation.get(t),o=null;if(e){var r=Array.from(e.values());if(o=this._findMessageBySequenceAndRandom({messageList:r,random:n,sequence:s})){let e=this._getUniqueIdOfMessage(o);return Un.updateMessage(t,[e],{isRevoked:!0,revoker:i,operation:Xt.revoke}),o}}if(this._sparseMessagesByConversation.has(t)){let e=Array.from(this._sparseMessagesByConversation.get(t).values());if(o=this._findMessageBySequenceAndRandom({messageList:e,random:n,sequence:s}))return o.isRevoked=!0,o.revoker=i,o}}_findMessageBySequenceAndRandom({messageList:t,sequence:s,random:n}){for(let e=0;e<t.length;e+=1){var i=t[e];if(i.sequence===s&&(g(n)||i.random===n))return i}return null}prependLocalMessageList(e){let{messageList:s,conversationID:t}=e;if(0===s.length)return[];var n=[],i=[],o=this._messagesByConversation.get(t)||new Map;for(let t of s){let e=this._getUniqueIdOfMessage(t);o.has(e)||(n.push(t),i.push([e,t]))}if(0<i.length){let e=new Map([...i,...o.entries()]);this._messagesByConversation.set(t,e),this._updateLatestMessageSentByMe(t),this._updateLatestMessageSentByPeer(t)}return n}storeSparseMessageList(n){if(0!==n.length){let e=n[0]["conversationID"],s=n.length;this._sparseMessagesByConversation.has(e)||this._sparseMessagesByConversation.set(e,new Map);var i=this._sparseMessagesByConversation.get(e);for(let t=0;t<s;t++){let e=n[t];i.has(e.ID)||i.set(e.ID,e)}}}_updateLatestMessageSentByMe(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length)for(let e=s.length-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(t,s[e]);break}}_updateLatestMessageSentByPeer(t){var e,s=Array.from((null==(e=this._messagesByConversation.get(t))?void 0:e.values())||[]);if(0!==s.length&&t.startsWith("C2C"))for(let e=s.length-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(t,s[e]);break}}_getUniqueIdOfMessage(e){var{from:e,to:t,random:s,sequence:n,time:i}=e;return e+`-${t}-${s}-${n}-`+i}_setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}addRandomOfSentMessage(e){this._randomOfSentMessageList.append(e)}removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}updateNickAndAvatarOfSentMessage(e){let{conversationID:t="",latestAvatar:o,latestNick:r,isSentByMe:s=!0}=e,n=this._messagesByConversation.get(t);if(n){let e=Array.from(n.values()),i=s?"out":"in";e.forEach(e=>{var{nick:t,avatar:s,flow:n}=e;n===i&&(t!==r&&(e.nick=r),s!==o)&&(e.avatar=o)})}}isInMessageList(e){var t=e["conversationID"];return!!t&&!!this._messagesByConversation.has(t)&&(e=this._getUniqueIdOfMessage(e),null==(t=this._messagesByConversation.get(t))?void 0:t.has(e))}isMessageSentByCurrentInstance(e){e=e.random;return this._randomOfSentMessageList.has(e)}getContinuousMessagesByConversation(){return this._messagesByConversation}getLocalMessageList(e){e=this._messagesByConversation.get(e);return e?[...e.values()]:[]}getSparseMessageList(e){e=this._sparseMessagesByConversation.get(e);return e?[...e.values()]:[]}_reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}_dispose(){this._reset(),$t.notificationCenter.unSubscribeInnerEvent(Ht.LOGOUT,this._reset,this),$t.notificationCenter.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this)}};function si(e,t){var s,n,i,o,r,a,l,c=bn.getConversation(e);null!=c&&c.lastMessage&&(c=c["lastMessage"],{lastTime:s,lastSequence:n,version:i}=c,{time:t,sequence:o,messageVersion:r,elements:a,cloudCustomData:l}=t,s===t)&&n===o&&i!==r&&(c.type=a[0].type,c.payload=a[0].content,c.messageForShow=Zs(c.type,c.payload),c.cloudCustomData=l,c.version=r,bn.updateConversation(e,{lastMessage:c}))}class ni{init(){$n({apiName:"modifyMessage",context:this})}modifyMessage(u){return h(this,void 0,void 0,function*(){let n=$t.ssoLog.createSSOLogData({method:"modifyMessage"}),{to:i,payload:e,sequence:o,conversationType:r,random:a,time:l,from:c,type:t}=u;if(this._canModifyMessageElement(t)){var s=u.getElements();1<s.length&&(s[0].type=t,s[0].content=e);try{let t=null,s;if(n.setLogInfo({message:"to:"+i}),r===uo.CONV_C2C?t=yield function(u){return h(this,void 0,void 0,function*(){let{from:e,to:t,version:s=0,sequence:n,random:i,time:o,type:r,cloudCustomData:a}=u,l={From_Account:e,To_Account:t,MsgVersion:s,MsgSeq:n,MsgRandom:i,MsgTime:o,MsgType:r,MsgBody:u.transformElementsToServerFormat(),CloudCustomData:a},c=yield qs({servcmd:"openim.modify_c2c_msg",data:l});if(c){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=c;return{elements:Go(e),messageVersion:t,cloudCustomData:s}}})}(u):r===uo.CONV_GROUP&&(t=yield function(r){return h(this,void 0,void 0,function*(){let{to:e,version:t=0,sequence:s,cloudCustomData:n}=r,i={GroupId:e,MsgVersion:t,MsgSeq:s,MsgBody:r.transformElementsToServerFormat(),CloudCustomData:n},o=yield qs({servcmd:"openim.modify_group_msg",data:i});if(o){let{MsgBody:e,MsgVersion:t,CloudCustomData:s}=o;return{elements:Go(e),messageVersion:t,cloudCustomData:s}}})}(u)),t){n.end();let e=""+r+i;return i===Hs()&&r===uo.CONV_C2C&&(e=""+r+c),s={conversationType:r,from:c,to:i,time:l,random:a,sequence:o,elements:null==t?void 0:t.elements,cloudCustomData:null==t?void 0:t.cloudCustomData,messageVersion:null==t?void 0:t.messageVersion,conversationID:e},this._handleModifyMessageSuccess(s),{code:0,data:{message:u}}}}catch(e){let t=(e||{})["errorCode"],s=new Ms({functionName:"modifyMessage",code:t});throw this._logModifyMessageError(s),s}}else n.setLogInfo({message:"can not modify message element. message type: "+t}).end()})}_logModifyMessageError(e){$t.ssoLog.getSSOLogData("modifyMessage").setError(e).end()}_handleModifyMessageSuccess(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent(Yt.MESSAGE_MODIFIED,{name:Yt.MESSAGE_MODIFIED,data:[n]}),$t.notificationCenter.emitInnerEvent(Ht.MESSAGE_MODIFIED,{conversationID:t,message:n}),si(t,e)}_canModifyMessageElement(e){return[ho.MSG_TEXT,ho.MSG_CUSTOM,ho.MSG_LOCATION,ho.MSG_FACE].includes(e)}}class oi{init(){var e=$t["notificationCenter"],t=e["InnerEventSubType"];Fs.registerWorkflowStep(gs.RECEIVE_C2C_NEW_MESSAGE,ps.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),Fs.registerWorkflowStep(gs.RECEIVE_C2C_NEW_MESSAGE,ps.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),Fs.registerWorkflowStep(gs.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ps.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){Fs.executeWorkflow(gs.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){let t=e.data||{},s=($t.message||{})["messageDataHandler"],n=[],i=new Map;return t.C2cMsgArray.forEach(e=>{e=this._generateC2CMessage(e);this._updateMessageProfile(e);let t=1===e.isModified;s.isMessageSentByCurrentInstance(e)?e.isModified=t:t=!1,e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||(s.storeConversationMessage(e)&&xo({conversationUpdateFields:i,message:e}),s.isMessageSentByCurrentInstance(e)&&!t)||n.push(e)}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEventsAfterReceiveNewMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[ps.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(e)}_emitMessageEventsAfterSyncUnreadMessage(e){var{messages:e=[]}=(null==(e=e.result)?void 0:e[ps.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(e)}_emitMessageEvents(e){var t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)));0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateC2CMessage(e){var t=uo.CONV_C2C,e=Lo(e),t=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:fo.IN})),e=e["elements"];return t.setElement(e),t}_updateMessageProfile(n){var e;let i=($t.message||{})["messageDataHandler"],t=null==(e=$t.store.get("login"))?void 0:e.userId,{from:s,nick:o,avatar:r,conversationID:a=""}=n;if(s!==t){let s=i.getLatestMsgSentByPeer(a);if(s){let{nick:e,avatar:t}=s;g(o)||g(r)?(n.nick=p(e)?e:n.nick,n.avatar=p(t)?t:n.avatar):o===e&&r===t||(i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:a,nick:o,avatar:r}))}}else{let e=i.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||i.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}}_updateConversationUserProfile(e){var{conversationID:e,nick:t,avatar:s}=e,{userProfile:n={}}=bn.getConversation(e)||{};n.avatar===s&&n.nick===t||bn.updateConversation(e,{userProfile:Object.assign(Object.assign({},n),{nick:t,avatar:s})})}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),$t.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),si(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t=uo.CONV_C2C,e=bo(e),{to:s,from:n}=e;let i=""+t+s;s===(null==(s=$t.store.get("login"))?void 0:s.userId)&&(i=""+t+n),e=Object.assign({conversationType:t,conversationID:i},e),this._updateMessageListDueToModify(e)})}_dispose(){var e=$t["notificationCenter"],e=e["InnerEventSubType"];$t.notificationCenter.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,e.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),$t.notificationCenter.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,e.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),$t.notificationCenter.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this)}}class ii{init(){var e=$t["notificationCenter"],t=e["InnerEventSubType"];Fs.registerWorkflowStep(gs.RECEIVE_GROUP_NEW_MESSAGE,ps.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),Fs.registerWorkflowStep(gs.RECEIVE_GROUP_NEW_MESSAGE,ps.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&Fs.executeWorkflow(gs.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){let t=e.data||{},s=$t.message["messageDataHandler"],n=[],i=new Map,o=null==t?void 0:t.GroupMsgArray;return null!=o&&o.forEach(e=>{var t;1!==e.GroupInfo.NotVisible&&(e=this._generateGroupMessage(e),this.updateMessageProfile(e),t=1===e.isModified,s.isMessageSentByCurrentInstance(e)&&(e.isModified=t),e.isOnlineMessage()?(e._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(e)||n.push(e)):s.isInMessageList(e)||s.storeConversationMessage(e)&&(n.push(e),xo({conversationUpdateFields:i,message:e})))}),{conversationUpdateFieldList:[...i.values()],messages:n}}_emitMessageEvents(e){var e=((null==(e=e.result)?void 0:e[ps.HANDLE_GROUP_NEW_MESSAGE])||{})["messages"],t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[],t=(0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t}),(null==e?void 0:e.filter(e=>!(null!=e&&e.isModified)))||[]);0<t.length&&$t.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:t})}_generateGroupMessage(e){var t=uo.CONV_GROUP,e=ko(e),t=$t.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:fo.IN})),e=e["elements"];return t.setElement(e),t}updateMessageProfile(i){var e;let t=($t.message||{})["messageDataHandler"],s=null==(e=$t.store.get("login"))?void 0:e.userId,{from:n,nick:o,avatar:r,conversationID:a="",_elements:l}=i;if(n===s){let e=t.getLatestMsgSentByMe(a);!e||o===e.nick&&r===e.avatar||t.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:o,latestAvatar:r,isSentByMe:!0})}else if(n===us.CONV_SYSTEM){let{operationType:e,memberInfoList:t,operatorInfo:s}=l,n={};if(Ee(t)?Ee(s)||(n=s):[ls.JOINED,ls.KICKED,ls.ADMIN_SET,ls.ADMIN_CANCELED].includes(e)&&(n=Object.assign({},t[0])),!Ee(n)){let{nick:e="",avatar:t=""}=n;i.nick=e,i.avatar=t}}}_updateMessageListDueToModify(e){var t=e["conversationID"],{isUpdated:s,message:n}=$t.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&$t.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),si(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{var t=uo.CONV_GROUP,{topicID:s,groupID:n}=e=Fo(e),s=s||n,e=Object.assign({conversationType:t,conversationID:""+t+s,to:s},e);this._updateMessageListDueToModify(e)})}_dispose(){var e=$t["notificationCenter"],{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}=e["InnerEventSubType"];e.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var{GroupId:e,GroupType:t}=(null==(e=null==(e=null==e?void 0:e.GroupMsgArray)?void 0:e[0])?void 0:e.GroupInfo)||{},t=t===as.GRP_AVCHATROOM;return!(!kn.getGroup(e)&&t)}}var ri=new class{constructor(){this.c2cMessageReceiver=new oi,this.groupMessageReceiver=new ii}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};let ai={createCustomMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1},cloudCustomData:{required:!1,rules:["string"],allowEmpty:!1},priority:{required:!1,rules:["string"],allowEmpty:!1},customModerationConfigurationID:{required:!1,rules:["string"],allowEmpty:!1}},sendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],createTextMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!e.startsWith("C2C")&&!e.startsWith("GROUP"))||"conversationType is invalid."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null==(e=null==e?void 0:e.text)?void 0:e.length))||"payload.text is invalid."}}}},ci={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var li=new class{getGroupRoamingMessagesByAnchor(s){return h(this,void 0,void 0,function*(){try{var r=$t.ssoLog.createSSOLogData({method:"getGroupRoamingMessagesByAnchor"}),{conversationID:t,count:e,direction:a,sequence:l}=s,c=t.replace(os.CONV_GROUP,""),u=[];let o=l;if(a===Qt.BACKWARD){if("number"!=typeof l)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};o=l+e-1}var d=yield function(n){return h(this,void 0,void 0,function*(){var{groupID:e,count:t,messageSequence:s}=n,e={GroupId:e,ReqMsgNumber:t,WithRecalledMsg:1,Version:1};return s&&(e.ReqMsgSeq=s),yield qs({servcmd:"group_open_http_svc.group_msg_get",data:e})})}({groupID:c,count:e,messageSequence:o});if(d){let{RspMsgList:t=[],NextReqMsgSeq:e=0,IsFinished:s,InvisibleMsgSeq:n}=d;r.setLogInfo({message:`groupID:${c} sequence:${l} reqSeq:${o} direction:${a}
3
+ complete:${s} nextSequence:${e} remoteMsgCount:${t.length} invisibleSequenceList:`+n}).end();var _=[];for(let e=0;e<t.length;e++){var g=t[e],p=(g.From_Account===us.CONV_SYSTEM&&u.push(g),this._parseMessage(g));_.push(p)}_.reverse();let i=s===mo;return a===Qt.BACKWARD&&(i=_[_.length-1].sequence>=l),{messageList:Vo(_),invisibleSequenceList:n,nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:i,serverGroupTipList:u}}}catch(e){t=new Ms({code:null==e?void 0:e.code});$t.ssoLog.getSSOLogData("getGroupRoamingMessagesByAnchor").setError(t).end()}})}_parseMessage(e){var t=os.CONV_GROUP,e=(4===e.Event&&(e.MsgBody.MsgType=us.MSG_GRP_TIP),ko(e)),t=Oo.createMessage(Object.assign(Object.assign({},e),{conversationType:t,flow:"in"}));return t.setElement(e.elements),t}};class di{constructor(){this.messageHelper=Bo,this.messageFactory=Oo,this.messageSender=new Xo,this.messageAction=new ni,this.messageReceiver=ri,this.messageDataHandler=ti,this.messageHistory=li,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),bs({auth:ci,params:ai})}}let ui="User",_i="Tag_Profile_IM_",hi=100,gi={NICK:_i+"Nick",GENDER:_i+"Gender",BIRTHDAY:_i+"BirthDay",LOCATION:_i+"Location",SELFSIGNATURE:_i+"SelfSignature",ALLOWTYPE:_i+"AllowType",LANGUAGE:_i+"Language",AVATAR:_i+"Image",MESSAGESETTINGS:_i+"MsgSettings",ADMINFORBIDTYPE:_i+"AdminForbidType",LEVEL:_i+"Level",ROLE:_i+"Role"},pi="USER_STATUS",Ei=1,fi={userID:"",nick:"",gender:"Gender_Type_Unknown",birthday:0,location:"",selfSignature:"",allowType:"AllowType_Type_AllowAny",language:0,avatar:"",messageSettings:0,adminForbidType:"AdminForbid_Type_None",level:0,role:0,lastUpdatedTime:0,profileCustomField:[]},mi=new Map([[gi.NICK,"nick"],[gi.GENDER,"gender"],[gi.BIRTHDAY,"birthday"],[gi.LOCATION,"location"],[gi.SELFSIGNATURE,"selfSignature"],[gi.ALLOWTYPE,"allowType"],[gi.LANGUAGE,"language"],[gi.AVATAR,"avatar"],[gi.MESSAGESETTINGS,"messageSettings"],[gi.ADMINFORBIDTYPE,"adminForbidType"],[gi.LEVEL,"level"],[gi.ROLE,"role"]]);var Ui,Gi,Fi,Si=new class{createProfile(e,t){let s={userID:e,profileCustomField:[]};return t.forEach(e=>{var{tag:e,value:t}=e;e&&-1<e.indexOf("Tag_Profile_Custom")?s.profileCustomField.push({key:e,value:t}):mi.has(e)&&(s[mi.get(e)]=t)}),Object.assign(Object.assign({},fi),s)}parseProfileItem(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}parseProfileList(e=[]){let t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}convertParamsToProfile(t){let s=[];return Object.keys(t).forEach(e=>{s.push({tag:gi[e.toUpperCase()],value:t[e]})}),s}normalizeProfileFields(e){let n={};return e.forEach(e=>{var{tag:t,value:s}=e;if(mi.has(t)){let e=mi.get(t);n[e]=s}}),n}};let vi=$t.common["generateProtocolData"];function Ii(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_get_all",t={From_Account:Hs(),UserItem:[]};n.forEach(e=>{t.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});var o=vi({servcmd:e,data:t}),s=o.head.seq+e,o=yield $t.channel.sendPacket(o,{requestId:s});if(o){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n,UserProfileItem:i}=o,r=[];return i.map(e=>{var{To_Account:e,CustomSequence:t,ResultCode:s,ResultInfo:n,StandardSequence:i,ProfileItem:o}=e,o=Si.parseProfileItem(o);r.push({userId:e,customSequence:t,resultCode:s,resultInfo:n,standardSequence:i,profileItem:o})}),{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n,userProfile:r}}})}function Ci(e){return Gn.getFriendMap().has(e)}let Mi=$t.utils["isEmpty"];class Oi{init(){$n({apiName:"getMyProfile",context:this}),$n({apiName:"getUserProfile",context:this}),$n({apiName:"updateMyProfile",context:this}),this.createProfile=Si.createProfile.bind(Si);var e=$t["notificationCenter"];Fs.registerWorkflowStep(gs.SYNC_SERVER_INFO_AFTER_LOGIN,ps.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(Ht.LOGOUT,this._reset,this),e.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}getMyProfile(){return h(this,void 0,void 0,function*(){let t=$t.ssoLog.createSSOLogData({method:"getMyProfile"});try{var s=Hs(),n=yield Ii([s]);if(n){let e=this._handleProfileFormResponse(n)[0];return Gn.getUserProfileMap().set(s,e),{code:0,data:e}}t.end()}catch(e){var{errorCode:n,errorInfo:s}=e,n=new Ms({functionName:"getMyProfile",code:n,message:s});throw t.setError(n).end(),e}})}getUserProfile(l){return h(this,void 0,void 0,function*(){var i=$t.ssoLog.createSSOLogData({method:"getUserProfile"});try{let e=l["userIDList"],{userIdListToRequest:t,userIdListToCache:s}=(e.length>hi&&(e=e.slice(0,hi)),this._filterRequestAndCacheUsers(e)),n=[];s.forEach(e=>{e=Gn.getUserProfile(e);n.push(e)});var o="userIDList.length:"+e.length;if(0===t.length)return i.setLogInfo({message:o}).end(),{code:0,data:n};var r=yield Ii(t);if(r){let e=this._handleProfileFormResponse(r);e.forEach(e=>{Ci(e.userID)&&Gn.getUserProfileMap().set(e.userID,e)});var a=e.concat(n);return i.setLogInfo({message:o}).end(),{code:0,data:a}}}catch(e){r=e["errorCode"],o=new Ms({functionName:"getUserProfile",code:r});throw i.setError(o).end(),o}})}getMyProfileCacheThenServer(){return h(this,void 0,void 0,function*(){var e=Hs(),e=Gn.getUserProfileMap().has(e);return e?{code:0,data:e}:this.getMyProfile()})}updateMyProfile(a){return h(this,void 0,void 0,function*(){let i=$t.ssoLog.createSSOLogData({method:"updateMyProfile"}),t=Hs(),s={};for(let e in a)void 0!==a[e]&&(s[e]=a[e]);let n=Si.convertParamsToProfile(s);try{let e={From_Account:t,ProfileItem:n};i.setLogInfo({message:JSON.stringify(n)}),yield function(n){return h(this,void 0,void 0,function*(){let e="profile.portrait_set",t=vi({servcmd:e,data:n}),s=""+t.head.seq+e,i=yield $t.channel.sendPacket(t,{requestId:s});if(i){let{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=i;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);var o=Gn.getUserProfile(t),r=o?Object.assign(Object.assign({},o),s):Si.createProfile(t,n);return ys(o,r,["lastUpdatedTime","profileCustomField"])||$t.notificationCenter.emitOuterEvent(Yt.PROFILE_UPDATED,{name:Yt.PROFILE_UPDATED,data:[r]}),r.lastUpdatedTime=Date.now(),Gn.getUserProfileMap().set(t,r),i.end(),{code:0,data:r}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new Ms({functionName:"updateMyProfile",code:t,message:s});throw i.setError(n).end(),n}})}updateMyNickAndAvatar(i){return h(this,void 0,void 0,function*(){var e=Hs(),t=Date.now(),s=Gn.getUserProfile(e),n={};(n=s?Object.assign(s,i):Si.createProfile(e,i)).lastUpdatedTime=t,Gn.getUserProfileMap().set(e,n)})}_onProfileDataModify(n){var e,t=function(){var{Profile_Account:e,PushType:t,ProfileList:s}=n.ProfileDataMod[0];return{userId:e,pushType:t,profileList:Si.parseProfileList(s)}}();Mi(t)||({isProfileUpdated:t,profile:e}=this._handleProfileModified(t),t&&($t.notificationCenter.emitInnerEvent(Ht.PROFILE_UPDATE,{name:Ht.PROFILE_UPDATE,data:[e]}),$t.notificationCenter.emitOuterEvent(Yt.PROFILE_UPDATED,{name:Yt.PROFILE_UPDATED,data:[e]})))}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Ht.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){let{userId:t,profileList:s}=e,n=Gn.getUserProfile(t);if(!n||!Ci(t))return{isProfileUpdated:!1,profile:null};let i=Si.normalizeProfileFields(s),o=Object.keys(i).some(e=>n[e]!==i[e]);return o?(e=Date.now(),e=Object.assign(Object.assign(Object.assign({},n),i),{lastUpdatedTime:e}),Gn.getUserProfileMap().set(t,e),bn.updateConversation("C2C"+t,{userProfile:e}),{isProfileUpdated:o,profile:e}):{isProfileUpdated:!1,profile:n}}_filterRequestAndCacheUsers(e){let s=[],n=[];return e.forEach(e=>{var t=Gn.getUserProfileMap().has(e);(Ci(e)&&t?n:s).push(e)}),{userIdListToRequest:s,userIdListToCache:n}}_handleProfileFormResponse(e){e=e.userProfile;if(!Array.isArray(e))return[];let t=e.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!Mi(e.profileItem)),s=Date.now();return t.map(e=>{e=Si.createProfile(e.userId,e.profileItem);return e.lastUpdatedTime=s,e})}_reset(){Gn.getUserProfileMap().clear()}}let Ti=new Map,yi=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=yi.length;e<t;e++)Ti.set(e,yi[e]);function Ai(e){if(!e)return"";var i=String(e).replace(/[=]+$/,"");let o="";if(i.length%4==1)return"";for(let e,t,s=0,n=0;t=i.charAt(n++);~t&&(e=s%4?64*e+t:t,s++%4)&&(o+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(o))}catch(e){return console.warn(e),""}}let Ri=$t.utils["isEmpty"],Ni=$t.common["generateProtocolData"];function Di(i){return h(this,void 0,void 0,function*(){var e,t,s="im_open_status.ws_get_user_status",n=Ni({servcmd:s,data:{To_Account:i}}),s=n.head.seq+s,n=yield $t.channel.sendPacket(n,{requestId:s});if(n)return{ErrorCode:s,ErrorInfo:n,ErrorList:e=[],UserStatusList:t=[]}=n,{errorCode:s,errorInfo:n,successUserList:t.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Ai(s)}}),failureUserList:e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:Ri(t)?e:t,code:s,message:n}})}})}class Pi{constructor(){this._customStatus=""}init(){var e=$t["notificationCenter"];$n({apiName:"getUserStatus",context:this}),$n({apiName:"setSelfStatus",context:this}),$n({apiName:"subscribeUserStatus",context:this}),$n({apiName:"unsubscribeUserStatus",context:this}),Fs.registerWorkflowStep(gs.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ps.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(Ht.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(Ht.LOGOUT,this._reset,this),e.subscribeInnerEvent(Ht.DESTROY,this._dispose,this)}setSelfStatus(s){return h(this,void 0,void 0,function*(){let i=$t.ssoLog.createSSOLogData({method:"setSelfStatus"}),e=Hs(),t=s["customStatus"];try{return yield function(i){return h(this,void 0,void 0,function*(){let e="im_open_status.ws_set_custom_status",t=Ni({servcmd:e,data:{CustomStatus:i}}),s=""+t.head.seq+e,n=yield $t.channel.sendPacket(t,{requestId:s});if(n){let{ErrorCode:e,ErrorInfo:t}=n;return{errorCode:e,errorInfo:t}}})}(t),this._customStatus=t,i.setLogInfo({message:"customStatus: "+t}).end(),{code:0,data:{userID:e,statusType:Ei,customStatus:t}}}catch(e){let{errorCode:t,errorInfo:s}=e,n=new Ms({functionName:"setSelfStatus",code:t,message:s});throw i.setError(n).end(),n}})}getUserStatus(s){return h(this,void 0,void 0,function*(){var e=$t.ssoLog.createSSOLogData({method:"getUserStatus"}),{userIDList:t=[]}=s;return e.setLogInfo({moreMessage:"userIDList length: "+t.length}),this._isOnlyMeInArray(t)?this._getMyStatus():this._getUserStatus(t)})}setCustomStatus(e){e=Ai(e);this._customStatus=e}subscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(ui+" subscribeUserStatus options: ",n);var{userIDList:e=[]}=n,t=(this._checkBusinessCapabilityBits("subscribeUserStatus"),this._getMaxUserCount("subscribe")),s=yield function(n){return h(this,void 0,void 0,function*(){var e=$t["channel"],t="im_open_status.ws_status_subscribe",s=Ni({servcmd:t,data:{To_Account:n}}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(ui+" subscribeUserStatus error:",e),e}})}unsubscribeUserStatus(n){return h(this,void 0,void 0,function*(){try{console.log(ui+" unsubscribeUserStatus options: ",n),this._checkBusinessCapabilityBits("unsubscribeUserStatus");var{userIDList:e=[]}=n,t=this._getMaxUserCount("unsubscribe"),s=yield function(n){return h(this,void 0,void 0,function*(){var e=$t["channel"],t="im_open_status.ws_status_unsubscribe",s=0===n.length?{UnsubscribeAll:1}:{To_Account:n},s=Ni({servcmd:t,data:s}),t=s.head.seq+t;return yield e.sendPacket(s,{requestId:t})})}(this._sliceUserIDList(e,t));return{code:0,data:{failureUserList:this._parseResponse(s)}}}catch(e){throw console.error(ui+" unsubscribeUserStatus error:",e),e}})}_onUserStatusUpdate(e){var{UserStatusList:e=[]}=e||{},e=e.map(e=>{var{To_Account:e,Status:t,CustomStatus:s}=e;return{userID:e,statusType:t,customStatus:Ai(s)}});this._emitUserStatusUpdatedEvent(e)}_onReOnline(e){var e=Ai(e.data.customStatus);this._customStatus!==e&&(this._customStatus=e,e={userID:Hs(),statusType:Ei,customStatus:e},this._emitUserStatusUpdatedEvent(e))}_emitUserStatusUpdatedEvent(e){$t.notificationCenter.emitOuterEvent(Yt.USER_STATUS_UPDATED,{name:Yt.USER_STATUS_UPDATED,data:e})}_sliceUserIDList(e,t){return e.slice(0,t)}_parseResponse(e){var{ErrorList:e=[]}=e;return e.map(e=>{var{To_Account:e,Invalid_Account:t,ErrorCode:s,ErrorInfo:n}=e;return{userID:$t.utils.isEmpty(t)?e:t,code:s,message:n}})}_checkBusinessCapabilityBits(e){if(!$t.store.get("commercialConfig").get(pi))throw new Ms({functionName:e,code:_s.NO_USE,replacement1:e})}_getMaxUserCount(e){var t=$t.store.get("cloudConfig")||{},{key:e,default:s}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:hi},unsubscribe:{key:"status_unsub_count",default:hi}}[e],t=t[e]||s;return parseInt(t,10)}_getMyStatus(){var e=$t.ssoLog.getSSOLogData("getUserStatus"),t=(e.setLogInfo({moreMessage:"getUserStatus._getMyStatus"}),{userID:Hs(),statusType:Ei,customStatus:this._customStatus});return e.end(),{code:0,data:{successUserList:[t],failureUserList:[]}}}_getUserStatus(i){return h(this,void 0,void 0,function*(){var t=$t.ssoLog.getSSOLogData("getUserStatus");t.setLogInfo({moreMessage:"getUserStatus._getUserStatus"});try{this._checkBusinessCapabilityBits("getUserStatus");var s=this._getMaxUserCount("query"),{successUserList:n,failureUserList:e}=(yield Di(this._sliceUserIDList(i,s)))||{};return t.end(),{code:0,data:{successUserList:n,failureUserList:e}}}catch(e){s=e["errorCode"],n=new Ms({functionName:"getUserStatus",code:s});throw t.setError(n).end(),n}})}_isOnlyMeInArray(e){var t=Hs();return 1===e.length&&-1<e.indexOf(t)}_dispose(){var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Ht.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(Ht.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}let wi={getUserProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},updateMyProfile:{nick:{required:!1,rules:["string"],allowEmpty:!0},avatar:{required:!1,rules:["string"],allowEmpty:!0},gender:{required:!1,rules:["string"],allowEmpty:!0},selfSignature:{required:!1,rules:["string"],allowEmpty:!0},allowType:{required:!1,rules:["string"],allowEmpty:!0},birthday:{required:!1,rules:["number"],allowEmpty:!1},language:{required:!1,rules:["string"],allowEmpty:!0},messageSettings:{required:!1,rules:["string"],allowEmpty:!0},adminForbidType:{required:!1,rules:["string"],allowEmpty:!0},level:{required:!1,rules:["number"],allowEmpty:!1},role:{required:!1,rules:["number"],allowEmpty:!0},profileCustomField:{required:!1,rules:["array"],allowEmpty:!0}},setSelfStatus:{customStatus:{required:!0,rules:["string"],allowEmpty:!0}},getUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},subscribeUserStatus:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},unsubscribeUserStatus:{userIDList:{required:!1,rules:["array"],allowEmpty:!0}}},Li={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class bi{constructor(){this.userProfile=new Oi,this.userStatus=new Pi,this.userProfile.init(),this.userStatus.init(),bs({auth:Li,params:wi})}}function ki(t){var s=[];if(p(t)){var n=t.length;if(0!==n)for(let e=n-1;0<=e;e--)"1"===t[e]&&s.push(2**(n-e-1))}return s}!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(Ui=Ui||{}),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}(Gi=Gi||{}),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(Fi=Fi||{});class xi{constructor(){this._name="SyncConversationHandler",this._pagingStatus=Ui.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){var e=$t["notificationCenter"];Fs.registerWorkflowStep(gs.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ps.CONVERSATION_RECOVER,this._syncConversationList,this),Fs.registerWorkflowStep(gs.SYNC_SERVER_INFO_AFTER_LOGIN,ps.CONVERSATION_LIST_SYNC,this._syncConversationList,this),e.subscribeInnerEvent(Ht.LOGOUT,this._reset,this),e.subscribeInnerEvent(Ht.DESTROY,this._dispose,this),console.log(this._name+".init")}isSyncCompleted(){return this._pagingStatus===Ui.RESOLVED}_syncConversationList(){return h(this,void 0,void 0,function*(){let e=$t["ssoLog"],t=e.createSSOLogData({method:"syncConversationList"});try{let e=yield this._pagingGetConversationList(!0);this._pagingStatus=Ui.RESOLVED;var{conversationList:s=[]}=e||{};return t.setLogInfo({message:"count:"+s.length}).end(),console.log(this._name+"._syncConversationList ok, count:"+s.length),e}catch(e){var{errorCode:s,errorInfo:n}=e,s=new Ms({functionName:"syncConversationList",code:s,message:n});t.setError(s).end(),console.error(this._name+"._syncConversationList fail:",s)}})}_pagingGetConversationList(u){return h(this,void 0,void 0,function*(){try{var e,t=[],s=(this._pagingStatus=Ui.PENDING,yield function(o){return h(this,void 0,void 0,function*(){var{fromAccount:e,pagingTimeStamp:t,pagingStartIndex:s,pagingPinnedTimeStamp:n,pagingPinnedStartIndex:i}=o;return qs({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:e,StartIndex:s,TimeStamp:t,TopStartIndex:i,TopTimeStamp:n}})})}({fromAccount:Hs(),pagingTimeStamp:u?this._pagingTimeStamp:0,pagingStartIndex:u?this._pagingStartIndex:0,pagingPinnedTimeStamp:u?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:u?this._pagingPinnedStartIndex:0})),{CompleteFlag:n,SessionItem:i=[],TimeStamp:o,StartIndex:r,TopTimeStamp:a,TopStartIndex:l}=s||{};if(0<i.length){let e=this._getConversationOptions(i);t.push(...e);var c=$t["notificationCenter"];c.emitInnerEvent(Ht.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:e})}return this._pagingTimeStamp=o,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=l,1!==n&&(e=(yield this._pagingGetConversationList(u))["conversationList"],t.push(...e)),{conversationList:t}}catch(e){throw console.error(this._name+"._pagingGetConversationList fail:",e),e}})}_getConversationOptions(e){let{isUndefined:t}=$t["utils"],s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===Gi.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}_filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===Gi.C2C&&!function(e){let t;return"@TLS#ERROR"===(t=e.startsWith(us.CONV_C2C)?e.replace(us.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}(t)||2===e)}_assembleC2COption(e){var t,s=this._createUserprofile(e);return{conversationID:""+us.CONV_C2C+e.userID,type:us.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:null!=(t=e.lastMsg)&&t.elements[0]?null==(t=e.lastMsg)?void 0:t.elements[0].type:null,payload:null!=(t=e.lastMsg)&&t.elements[0]?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Fi.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null},unreadCount:0,userProfile:s,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:ki(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}_createUserprofile(e){var{userID:e,nick:t,peerAvatar:s}=e,t=[{tag:"Tag_Profile_IM_Nick",value:t},{tag:"Tag_Profile_IM_Image",value:s}];return null==(s=$t.user.userProfile)?void 0:s.createProfile(e,t)}_computeIsPeerRead(e){var{lastC2CMsgFromAccount:e,time:t,c2cPeerReadTime:s}=e;return e===Hs()&&t<=s}_assembleGroupOption(e){var t;return{conversationID:""+us.CONV_GROUP+e.groupID,type:us.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},this._patchTypeAndPayload(e)),{cloudCustomData:(null==(t=e.lastMsg)?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===Fi.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null==(t=null==(t=e.lastMsg)?void 0:t.revokerInfo)?void 0:t.revoker)||null}),groupProfile:{groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq},unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:ki(e.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(e.messageRemindType),subType:e.groupType}}_convertConversationKey(e){return e.map(e=>({type:e.Type,userID:e.To_Account,nick:e.C2cNick,peerAvatar:e.C2cImage,time:e.MsgTimeStamp,sequence:e.MsgSeq,lastC2CMsgFromAccount:e.LastC2cMsgFrom_Account,lastMsg:this._convertLastMsgKey(e.LastMsg),lastMessageFlag:e.LastMsgFlags,c2cPeerReadTime:e.LastC2cMsgPeerReadTime,peerReadTime:e.C2cPeerReadTime,friendRemark:e.C2cRemark,isPinned:e.TopFlags,standardMark:e.StandardMark,customMark:e.CustomMark,messageRemindType:e.MsgRecvOption,groupID:e.ToAccount,groupNick:e.GroupNick,groupImage:e.GroupImage,groupType:e.GroupType,nextMessageSeq:e.GroupNextMsgSeq,msgGroupFromAccount:e.MsgGroupFrom_Account,msgGroupFromNickName:e.MsgGroupFromNickName,MsgGroupFromCardName:e.MsgGroupFromCardName,unreadCount:e.UnreadMsgCount,noUnreadCount:e.GroupIgnoredUnreadSeqCount}))}_convertLastMsgKey(e){var t=$t["utils"]["isEmpty"];if(t(e))return null;let s="",n=null;return e.MsgBody&&(s=null==(t=e.MsgBody[0])?void 0:t.MsgType,n=this._parseContent(s,e.MsgBody[0])),{event:e.Event,elements:[{type:s,content:n,cloudCustomData:e.CloudCustomData}],revokerInfo:{revoker:null==(t=e.RevokerInfo)?void 0:t.revoker}}}_parseContent(e,t){return t&&((e=$t.message.messageFactory.getElementClass(e))?null==(e=e.parseServerPushElement(t))?void 0:e.content:t)}_amendLayersOverLimitProp(e){var t=e["LayersOverLimit"];return _(e,["LayersOverLimit"]).layersOverLimit=1===t,e}_transMsgRemindType(e){let t="";return 0===e?t=us.MSG_REMIND_ACPT_AND_NOTE:1===e?t=us.MSG_REMIND_DISCARD:2===e?t=us.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=us.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_patchTypeAndPayload(e){var t=$t["utils"]["isUndefined"],{event:e,elements:s=[]}=e.lastMsg||{};return t(e)?{type:s[0]?s[0].type:null,payload:s[0]?this._amendLayersOverLimitProp(s[0].content):null}:{type:us.MSG_GRP_TIP,payload:{}}}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_reset(){this._pagingStatus=Ui.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();var e=$t["notificationCenter"];e.unSubscribeInnerEvent(Ht.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(Ht.DESTROY,this._dispose,this)}}class Vi{constructor(){this.syncConversationHandler=new xi,this.syncConversationHandler.init()}}console.log("TencentCloudLiteChat.VERSION:"+He);var Bi={create:function(e){var{SDKAppID:e,testEnv:t=!1,devMode:s=!1,unlimitedAVChatRoom:n=!1,scene:i="",oversea:o=!1}=e;if("number"!=typeof e&&(r=Number(e),Number.isNaN(r)))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(e=Number(e),Gs.has(e))return Gs.get(e);var r=""+(a()+a())+a()+a()+a()+a()+a()+a();function a(){return(65536*(1+Math.random())|0).toString(16).substring(1)}$t.init({sdkAppId:e,instanceId:r,testEnv:t,devMode:s,unlimitedAVChatRoom:n,scene:i,sdkEdition:Dn,oversea:o}),Fs.init(),$t.message=new di,$t.user=new bi,$t.login=new lo,$t.conversation=new Vi,ks.installBuiltInPlugin(Pn);t=xn;return Gs.set(e,t),t},TSignaling:jt,EVENT:Yt,VERSION:He,TYPES:us};export{Bi as default};