@tencentcloud/web-push 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +89 -3
- package/index.esm.js +10 -15550
- package/index.umd.js +1 -1
- package/package.json +1 -1
package/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WebPushSDK={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}};n.exports=function(){const e=e=>void 0===e,s=e=>"string"==typeof e,n=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},o=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===n(e),i=e=>null!==e&&"object"==typeof e,r=e=>o(e)||i(e),a=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},c=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 u(e=99999999){return Math.round(Math.random()*e)}const l=(t,s,n,o)=>{if(!r(t)||!r(s))return 0;let i=0;const a=Object.keys(s);let c;for(let u=0,d=a.length;u<d;u++)if(c=a[u],!(e(s[c])||n&&n.includes(c)))if(r(t[c])&&r(s[c]))i+=l(t[c],s[c],n,o);else{if(o&&o.includes(s[c]))continue;t[c]!==s[c]&&(t[c]=s[c],i+=1)}return i};function d(e){let t,s,n=e;e.length%8!=0&&(n="0".repeat(8-e.length%8)+e);let o="";for(let i=0,{length:r}=n;i<r;i+=8)t=parseInt(n.slice(i,i+4),2),s=parseInt(n.slice(i+4,i+8),2),o+=base16Map.get(t)+base16Map.get(s);return o}const h={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},p=["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 g,_;(_=g||(g={}))[_.DEBUG=0]="DEBUG",_[_.INFO=1]="INFO",_[_.WARN=2]="WARN",_[_.ERROR=3]="ERROR",_[_.NONE=4]="NONE";const m="LiteChat",f={[g.DEBUG]:console.debug,[g.INFO]:console.info,[g.WARN]:console.warn,[g.ERROR]:console.error},v={[g.INFO]:4,[g.WARN]:5,[g.ERROR]:6},I=1e3,E=2,S=5e3,y=50;var C;!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"}(C||(C={}));var M=Object.freeze({__proto__:null,CONSOLE_METHOD:f,CloudConfigReportLevelMap:v,get ConvModifyPushType(){return C},DEFAULT_GLOBAL_MAX_TOTAL_COUNT:y,DEFAULT_GLOBAL_THROTTLE_TIME:S,DEFAULT_SINGLE_MAX_TOTAL_COUNT:E,DEFAULT_SINGLE_THROTTLE_TIME:I,ENUM_PLATFORM:h,IS_TOPIC_MESSAGE:2,get LogLevel(){return g},NOT_NEED_CRC_SERVCMD:p,SDK_NAME:m});const A="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)&&"undefined"===wx.getSystemInfoSync().uniPlatform,b="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||A,T=b&&"function"==typeof wx.createGamePortal,O="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),D=w&&"function"==typeof tt.onShow,R="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),L="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),N="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,P="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,k=b&&"object"==typeof wx.miniapp,G="undefined"!=typeof uni,U=b||O||w||R||L||P||N,F="undefined"==typeof window&&!U&&void 0!==t&&void 0!==t.NativeScriptGlobals,x=void 0!==t&&(void 0!==t.nativeModuleProxy||void 0!==t.ReactNative),$="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),q="undefined"!=typeof uni?!U:"undefined"!=typeof window&&!U&&!x,B=O?qq:w?tt:R?swan:L?my:b?wx:P?uni:N?jd:{},V=q&&window&&window.navigator&&window.navigator.userAgent||"",W=/(micromessenger|webbrowser)/i.test(V),j=function(){let e="WEB";return W?e="WEB":O?e="QQ_MP":w?e="TT_MP":R?e="BAIDU_MP":L?e="ALI_MP":b?e=k?"DONUT_NATIVE_APP":"WX_MP":P?e="UNI_NATIVE_APP":F?e="NS_NATIVE_APP":x&&(e="RN_NATIVE_APP"),h[e]}(),H=/iPad/i.test(V),K=/iPhone/i.test(V)&&!H,Y=/iPod/i.test(V),z=K||H||Y,Z=function(){const e=V.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),J=/Android/i.test(V),X=function(){const e=V.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(`${e[1]}.${e[2]}`):t||null}(),Q=/Firefox/i.test(V),ee=/Edge/i.test(V),te=!ee&&/Chrome/i.test(V),se=/MSIE/.test(V)||V.indexOf("Trident")>-1&&V.indexOf("rv:11.0")>-1,ne=function(){const e=/MSIE\s(\d+)\.\d/.exec(V);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(V)&&/rv:11.0/.test(V)&&(t=11),t}(),oe=/Safari/i.test(V)&&!te&&!J&&!ee,ie=/Windows/i.test(V),re=/MAC OS X/i.test(V),ae=q&&"undefined"!=typeof Worker&&!se,ce=J||z,ue=q&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,le=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!z||e||oe)}();function de(){let e="unknown";if(re&&(e="mac"),ie&&(e="windows"),z&&(e="ios"),J&&(e="android"),U)try{const{platform:t}=B.getSystemInfoSync();void 0!==t&&(e=t)}catch(t){console.error(t)}return e}function he(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(s[n[o]]=e[n[o]])}return s}function pe(e,t,s,n){return new(s||(s=Promise))(function(o,i){function r(e){try{c(n.next(e))}catch(t){i(t)}}function a(e){try{c(n.throw(e))}catch(t){i(t)}}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 ge=2800,_e=2801,me=3e3,fe="application/x-www-form-urlencoded;charset=UTF-8";function ve(e){return pe(this,arguments,void 0,function*({method:e,url:t,data:s,timeout:n=me}){return new Promise(U?(o,i)=>{B.request({url:t,data:s,method:e,timeout:n,header:{"content-type":fe},success:e=>o(e.data),fail:()=>i(new Error(`{"message":"Network error","code":${ge}}`))})}:(o,i)=>{const r=new XMLHttpRequest,a=setTimeout(()=>{r.abort(),i(new Error(`{"message":"Request timeout","code":${_e}}`))},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":${ge}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",fe),r.send(s||null)})})}function Ie(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(c(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 Ee(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(Ee(s),Ee(e))}),t}if(e instanceof Set){const t=new Set;return e.forEach(e=>{t.add(Ee(e))}),t}if(Array.isArray(e))return e.map(e=>Ee(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]=Ee(e[t]))}),s}function Se(e,t,s){const n=new WeakSet,o=(e,s)=>{if(t&&(s=t(e,s)),void 0===s)return"undefined";if(null===s)return null;if(Number.isNaN(s))return"NaN";if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if("function"==typeof s)return`[Function: ${s.name||"anonymous"}]`;if("symbol"==typeof s)return s.toString();if("bigint"==typeof s)return`${s.toString()}n`;if("object"==typeof s&&null!==s){if(n.has(s))return"[Circular]";n.add(s)}return s instanceof Date?s.toISOString():s instanceof Error?{name:s.name,message:s.message,stack:s.stack}:s instanceof Map?{dataType:"Map",value:Array.from(s.entries())}:s instanceof Set?{dataType:"Set",value:Array.from(s.values())}:s};try{return JSON.stringify(e,o,s)}catch(i){return console.error("Failed to stringify:",i),""}}function ye(){let e,t;return{promise:new Promise((s,n)=>{e=s,t=n}),resolve:e,reject:t}}var Ce,Me=Object.freeze({__proto__:null,ANDROID_VERSION:X,IE_VERSION:ne,IN_ALIPAY_MINI_APP:L,IN_BAIDU_MINI_APP:R,IN_BROWSER:q,IN_DONUT_NATIVE_APP:k,IN_JD_MINI_APP:N,IN_MINI_APP:U,IN_NS_NATIVE_APP:F,IN_QQ_MINI_APP:O,IN_RN_APP:x,IN_TT_MINI_APP:w,IN_TT_MINI_GAME:D,IN_UNI_APP:G,IN_UNI_NATIVE_APP:P,IN_WX_MINI_APP:b,IN_WX_MINI_APP_DESK:A,IN_WX_MINI_GAME:T,IN_WX_MINI_PLUGIN:$,IOS_VERSION:Z,IS_ANDROID:J,IS_CHROME:te,IS_EDGE:ee,IS_FIREFOX:Q,IS_IE:se,IS_IOS:z,IS_IPAD:H,IS_IPHONE:K,IS_IPOD:Y,IS_MAC:re,IS_SAFARI:oe,IS_WECHAT:W,IS_WIN:ie,IS_WORKER_AVAILABLE:ae,MINI_APP_NAMESPACE:B,USER_AGENT:V,base16EncodeBinaryString:d,deepCopyWithMethods:Ee,deepMerge:l,generatePromise:ye,getPlatformType:de,getType:n,httpRequest:ve,isArray:o,isArrayOrObject:r,isEmpty:Ie,isFlutterWeb:ue,isH5:ce,isIOSWebView:le,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:i,isPlainObject:c,isString:s,isUndefined:e,isUniIOSApp:function(){return P&&"ios"===uni.getDeviceInfo().platform.toLocaleLowerCase()},isValidRequestKey:a,platform:j,randomInt:u,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t},safeStringify:Se});class Ae{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(s=>{const{fn:n,context:o}=s;try{n.apply(o,t)}catch(i){console.warn(`Error in event handler for ${e} error: ${Se(i)}`)}})}once(e,t,s){const n=(...o)=>{t.apply(s,o),this.off(e,n)};this.on(e,n)}}!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",e.GROUP_MESSAGE_PINNED="group_message_pinned"}(Ce||(Ce={}));const be=[16,17];function Te(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{var t;2===e.GroupInfo.MillionGroupFlag?s.push(Ce.TOPIC_TIPS_NOTIFICATION):be.includes(null===(t=null==e?void 0:e.MsgBody)||void 0===t?void 0:t.OpType)?s.push(Ce.GROUP_MESSAGE_PINNED):s.push(Ce.GROUP_TIPS_NOTIFICATION)}),s}const Oe=[{conditions:[{type:"event",value:100}],subType:Ce.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:Ce.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:Ce.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:Ce.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:Ce.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:Ce.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:Ce.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:Ce.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:Ce.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:Ce.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.C2cNotifyMsgArray)||void 0===t||t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(Ce.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(Ce.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(Ce.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(Ce.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:Te},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(Ce.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(Ce.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(Ce.TOPIC_MESSAGE_READ_SYNC):s.push(Ce.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(Ce.TOPIC_SYSTEM_NOTIFICATION):s.push(Ce.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:Te},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{const{GroupAtTips:{TopicId:t}}=e;t?s.push(Ce.TOPIC_AT_TIPS):s.push(Ce.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{switch(e.PushType){case C.CONV_MARK_UPDATED:s.push(Ce.CONVERSATION_MARK_UPDATED);break;case C.CONV_GROUP_ADDED:s.push(Ce.CONVERSATION_GROUP_ADD);break;case C.CONV_GROUP_DELETED:s.push(Ce.CONVERSATION_GROUP_DELETED);break;case C.CONV_GROUP_UPDATED:s.push(Ce.CONVERSATION_GROUP_UPDATED);break;default:s.push(Ce.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:Ce.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:Ce.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:Ce.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:Ce.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:Ce.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:Ce.ALL_MESSAGE_READ}];var we;function De(e){var t;const s=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],n=[];return s.forEach(t=>{t.Flag=e.body.Flag;const s=Oe.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!s)return null;let o=[];"function"==typeof s.subTypeParser?o=s.subTypeParser(t):s.subType&&(o=s.subType),Array.isArray(o)?o.forEach(e=>{n.push({type:`${we.SERVER_PUSH_MESSAGE}:${e}`,data:t})}):n.push({type:`${we.SERVER_PUSH_MESSAGE}:${o}`,data:t})}),n}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(we||(we={}));const Re={[we.SERVER_PUSH_MESSAGE]:De,[we.SERVER_PUSH_MESSAGE_MULTIPLE]:De,[we.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}},Le=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._filteredCallbackMap=new Map,this._outerEventEmitter=new Ae,this._innerEventEmitter=new Ae,this.InnerEventSubType=Ce}subscribeInnerEvent(e,t,s,n,o){var i;let r,a,c,u;["string","number"].includes(typeof t)?(c=`${e}:${t}`,u=s,a=n,r=o):(c=e,u=t,a=s,r="function"==typeof n?n:void 0),r?this._subscribeWithFilter(c,u,a,r):null===(i=this._innerEventEmitter)||void 0===i||i.on(c,u,a)}emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(Re).includes(e)){const s=null===(n=Re[e])||void 0===n?void 0:n.call(Re,t);null==s||s.forEach(e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))})}}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)}unSubscribeInnerEvent(e,t,s,n){if(["string","number"].includes(typeof t)){const o=s,i=`${e}:${t}`;this._unsubscribeEvent(i,o,n)}else{const n=t;this._unsubscribeEvent(e,n,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}_subscribeWithFilter(e,t,s,n){var o;const i=e=>{n.call(s,e)&&t.call(s,e)};this._filteredCallbackMap.has(e)||this._filteredCallbackMap.set(e,[]),this._filteredCallbackMap.get(e).push({originalCallback:t,filteredCallback:i,filter:n,context:s}),null===(o=this._innerEventEmitter)||void 0===o||o.on(e,i,s)}_unsubscribeEvent(e,t,s){var n,o;const i=this._filteredCallbackMap.get(e);if(i){const o=i.findIndex(e=>e.originalCallback===t&&e.context===s);if(-1!==o){const{filteredCallback:t}=i[o];return null===(n=this._innerEventEmitter)||void 0===n||n.off(e,t,s),i.splice(o,1),void(0===i.length&&this._filteredCallbackMap.delete(e))}}null===(o=this._innerEventEmitter)||void 0===o||o.off(e,t,s)}};class Ne{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(n){null===(s=this._onSendFail)||void 0===s||s.call(this,n)}}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 Pe{connectSocket(e){return this._socket=B.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 ke="CONNECT",Ge="SEND",Ue="DISCONNECT",Fe="OPEN",xe="MESSAGE",$e="CLOSE",qe="ERROR",Be="SEND_FAIL";class Ve{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:ke,url:e})}send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:Ge,data:e})}catch(n){null===(s=this._onSendFail)||void 0===s||s.call(this,n)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;if(this._worker){const e={[Fe]:t,[xe]:s,[$e]:n,[qe]:o,[Be]: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:Ue}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var We,je=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){return U?L?my.getStorageSync({key:e}).data:B.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){const s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}setStorage(e,t){U?L?my.setStorageSync({key:e,data:JSON.stringify(t)}):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"}(We||(We={}));class He{constructor(e){this._url="",this._readyState=We.DISCONNECTED,this._url=e,this._id=u(),this._emitter=new Ae,b||P||D?this._socket=new Pe:this._canUseWebWorker()?this._socket=new Ve:this._socket=new Ne,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[We.CONNECTED,We.CONNECTING].includes(this._readyState)||(this._readyState=We.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==We.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[We.CONNECTED,We.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===We.CONNECTED}disconnect(){this._readyState=We.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===We.CONNECTING&&(this._readyState=We.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=We.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=We.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=We.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){const t=je.get("cloudConfig")||{};return(e(t.isWorkerEnabled)||"1"===t.isWorkerEnabled)&&ae}}const Ke="CHINA",Ye="OVERSEA",ze="SINGAPORE",Ze="KOREA",Je="GERMANY",Xe="IND",Qe="JPN",et="USA",st="INDONESIA",nt={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},ot={[ze]:[[2e7,3e7],[172e7,173e7]],[Ze]:[[3e7,4e7],[173e7,174e7]],[Je]:[[4e7,5e7],[174e7,175e7]],[Xe]:[[5e7,6e7],[175e7,176e7]],[Qe]:[[6e7,7e7],[176e7,177e7]],[et]:[[7e7,8e7],[177e7,178e7]],[st]:[[8e7,9e7],[178e7,179e7]]};function it(e){var t;if(null===(t=je.get("instance"))||void 0===t?void 0:t.oversea)return Ye;for(const s of Object.keys(ot))for(const[t,n]of ot[s])if(e>=t&&e<n)return s;return Ke}var rt,at="4.2.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.BACKUP_WEB_ONLY="BACKUP_WEB_ONLY",e.BACKUP_CN="BACKUP_CN",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(rt||(rt={}));let ct=rt.INITIAL;function ut(){const e=Math.random();return 0===e?ut():e}function lt(e,t){const{isBinary:s=!1}=t||{},n=je.get("instance"),{sdkAppId:o,instanceId:i}=n,r=ut(),a=de(),c=function(){const e=de();let t=-1;return"ios"===e?t=Z||-1:"android"===e&&(t=X||-1),t}(),u=(l={sdkappid:o,instanceid:i,random:r,platform:j,host:a,version:c,sdkversion:at},Object.keys(l).map(e=>`${e}=${l[e]}`).join("&"));var l;return s?`${e}/binfo?${u}&compress=gzip`:`${e}/info?${u}`}function dt(e){const t=je.get("instance"),{sdkAppId:s,testEnv:n}=t,o=it(s);if(n)return lt(nt.TEST[o].DEFAULT,{isBinary:e});const i=nt.PRODUCTION[o],r=q&&i.ANYCAST,a=q,c=!!i.BACKUP_CN;return lt({[rt.INITIAL]:()=>(ct=rt.DEFAULT,i.DEFAULT),[rt.DEFAULT]:()=>(ct=rt.IPV6,i.IPV6),[rt.IPV6]:()=>(ct=rt.BACKUP,i.BACKUP),[rt.BACKUP]:()=>a?(ct=rt.BACKUP_WEB_ONLY,function(e){const t=Math.floor(10001*Math.random())+1e4;return e.replace("*",String(t))}(i.BACKUP_WEB_ONLY)):c?(ct=rt.BACKUP_CN,i.BACKUP_CN):r?(ct=rt.ANYCAST,i.ANYCAST):i.DEFAULT,[rt.BACKUP_WEB_ONLY]:()=>c?(ct=rt.BACKUP_CN,i.BACKUP_CN):r?(ct=rt.ANYCAST,i.ANYCAST):i.DEFAULT,[rt.BACKUP_CN]:()=>(ct=r?rt.ANYCAST:rt.DEFAULT,i[ct]),[rt.ANYCAST]:()=>(ct=rt.DEFAULT,i.ANYCAST="",i.DEFAULT)}[ct](),{isBinary:e})}var ht=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 pt=16;var gt=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=pt}=e,r=Math.max(i,pt);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 s=this._tasks[0];try{s.context?s.callback.call(s.context):s.callback(),s.isOnce?this.removeTask(s.id):(s.nextExecuteTime=e+s.intervalMs,this._sort())}catch(t){console.warn(`Task ${s.id} execution failed:`,t),s.isOnce&&this.removeTask(s.id)}}this._scheduleNextTask()}};function _t(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 mt(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&a(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=mt(e[s]));return t}function ft(e,t){if(p.includes(e))return 0;const s=_t(JSON.stringify(t));let n=4294967295;const{length:o}=s;for(let i=0;i<o;i++){n^=s[i];for(let e=0;e<8;e++)1&~n?n>>>=1:n=n>>>1^3988292384}return(4294967295^n)>>>0}function vt(e){const{servcmd:t,data:s}=e,n=function(e){const t=je.get("login")||{},s=je.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:d(""),cappid:s.applicationID||0,tjgID:"",seq:St(),cs:0}}(t),o=mt(s);return n.cs=ft(t,o),{head:n,body:o}}function It(e){const{servcmd:t,data:s}=e,n=function(e){const t=je.get("login")||{},s=je.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:d(""),cappid:s.applicationID||0,seq:St(),cs:0}}(t),o=mt(s);return n.cs=ft(t,o),{head:n,body:o}}let Et=u();function St(){return Et=Et<2415919103?Et+1:u(),Et}function yt(){var e;const t=je.get("login")||{},s=je.get("instance")||{};return{sdk_type:30,sdk_app_id:s.sdkAppId,sdk_version:"4.2.0",tiny_id:Number(t.tinyID),user_id:t.userId||(null===(e=je.get("webPush"))||void 0===e?void 0:e.userId),platform:j,instance_id:s.instanceId,trace_id:(new Date).getTime()}}var Ct,Mt=Object.freeze({__proto__:null,calcBodyCRC:ft,filterProtocolDataInvalidFields:mt,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=je.get("login")||{},s=je.get("instance")||{};return{servcmd:e,ver:"v4",platform:j,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:d(""),cappid:s.applicationID||0,seq:St(),cs:0}}(t),o=mt(s);return n.cs=ft(t,o),{head:n,body:o}},generateProtocolData:vt,generateSSOLogProtocolData:It,generateSequence:St,getCommonHead:yt,taskScheduler:gt,timeManager:ht});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(Ct||(Ct={}));const At={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 bt{constructor(e){this.level=Ct.info,this._canSendLog=!0,this._logCreatedAt=ht.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=this._getUiPlatform(),this._sdkEdition=this._getSDKEdition();const{method:t,eventType:s=0,message:n="",costTime:o=0,error:i,moreMessage:r="",code:a=0}=e||{};this.eventType=s,this.method=t,this.message=n,this.costTime=o,this.moreMessage=r,this.code=a,i&&this.setError(i)}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=ht.getTimeOffsetWithServer()}end(e=!1){this._canSendLog&&(this._canSendLog=!1,this.timestamp=ht.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()),e&&this._ssoLogModule.uploadSSOLogData())}setError(e){var t;return e instanceof Error?this._canSendLog?((null===(t=je.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=Ct.error,this):this:(console.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}setLogInfo(e){return Object.keys(e).forEach(t=>{Object.keys(At).includes(t)&&(this[t]=e[t])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach(t=>{const s=t;At[s]&&(e[At[s]]=this[s])}),e}_getUiPlatform(){var e;const t=null===(e=je.get("instance"))||void 0===e?void 0:e.scene;if("string"==typeof t){const e=Number(t);return isNaN(e)?void 0:e}}_getSDKEdition(){var e;return null===(e=je.get("instance"))||void 0===e?void 0:e.sdkEdition}}var Tt;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(Tt||(Tt={}));var Ot=Tt;const wt=20,Dt=6e4,Rt=[4,5,6],Lt=[],Nt=[],Pt="report-logger";var kt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=wt,this._maxThreshold=100,this._waitingTime=Dt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=g.DEBUG,this._throttleConfig={global:{throttleTime:S,maxCount:y},single:{throttleTime:I,maxCount:E}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,Le.subscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),gt.addTask({id:Pt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=wt,evt_rpt_waiting:s=Dt,evt_rpt_level:n=Rt,evt_rpt_sdkappid_bl:o=Lt,evt_rpt_tinyid_wl:i=Nt,evt_rpt_global_throttle_time:r=S,evt_rpt_global_throttle_count:a=y,evt_rpt_single_throttle_time:c=I,evt_rpt_single_throttle_count:u=E}=e||{};this._sdkAppIdBlackList=o,this._waitingTime=s,this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=i,this._throttleConfig={global:{throttleTime:r,maxCount:a},single:{throttleTime:c,maxCount:u}}}createSSOLogData(e){const t=new bt(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())}setLogLevel(e){[g.DEBUG,g.ERROR,g.INFO,g.NONE,g.WARN].includes(e)&&(this._logLevel=e)}debug(e,t="",s){this._log(g.DEBUG,e,t,s)}info(e,t="",s){this._log(g.INFO,e,t,s)}warn(e,t="",s){this._log(g.WARN,e,t,s)}error(e,t="",s){this._log(g.ERROR,e,t,s)}_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 pe(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:yt(),Event:t};Ie(s.Header.user_id)||(yield function(e){const t="imopenstat.tim_web_report_v2",s=It({servcmd:t,data:e}),n=`${s.head.seq}${t}`;ss.sendPacket(s,{requestId:n})}(s)),this._lastReportAt=Date.now()})}_savePlatFormInfo(){var e,t;if(b){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;je.set("instance",{appId:e,envVersion:t})}}else q&&je.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=je.get("login")||{},{sdkAppId:s}=je.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}_checkThrottle(e){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(e)}_checkGlobalThrottle(){const e=Date.now();if(e-this._globalThrottle.startTime>=this._throttleConfig.global.throttleTime)this._globalThrottle.count=1,this._globalThrottle.startTime=e;else if(this._globalThrottle.count++,this._globalThrottle.count>this._throttleConfig.global.maxCount)return!0;return!1}_checkSingleThrottle(e){const t=Date.now(),s=this._singleThrottleMap.get(e);return s?t-s.startTime>=this._throttleConfig.single.throttleTime?(s.count=1,s.startTime=t,!1):s.count>=this._throttleConfig.single.maxCount||(s.count++,!1):(this._singleThrottleMap.set(e,{count:1,startTime:t}),!1)}_shouldLog(e){return e>=this._logLevel&&this._logLevel!==g.NONE}_shouldReport(e){return this._reportLevel.includes(v[e])}_formatLog(e,t,s){const n=new Date,o=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}:${n.getMilliseconds()}`,i=`<${g[e]}>`;return se||U?[`${m} [${o}] ${i} [${t}] ${s}`]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",m,"",`[${o}] ${i} [${t}] ${s}`]}_log(e,t,s,n){if(!this._shouldLog(e))return;const o=this._formatLog(e,t,s);if(f[e].apply(console,o),this._shouldReport(e)){const e=this._getThrottleKey(t,s,n);this._checkThrottle(e)||this.createSSOLogData(Object.assign(Object.assign({message:s},n),{method:t})).end()}}_getThrottleKey(e,t,s){const n=`${e}${t}${Se(Object.assign(Object.assign({},s),{costTime:""}))}`,o=_t(JSON.stringify(n));let i=4294967295;const{length:r}=o;for(let a=0;a<r;a++){i^=o[a];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return`${(4294967295^i)>>>0}`}reset(){console.log("SSO_LOG_MODULE.reset"),gt.removeTask(Pt),Le.unSubscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=wt,this._maxThreshold=100,this._waitingTime=Dt,this._logQueue=[],this._logLevel=g.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}};const Gt=15e3,Ut="Channel",Ft="channel_schedule_task",xt="channel_reconnect_task",$t="connected",qt="connecting",Bt="disconnected",Vt=1e3,Wt="network_status_change",jt="activity_status_change",Ht="send_fail",Kt="reconnect_failed",Yt="socket_error",zt="socket_close";function Zt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Jt(e){return(Jt="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 Xt(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 Qt,es={exports:{}},ts=(Qt||(Qt=1,function(e){e.exports=function e(t,s,n){function o(r,a){if(!s[r]){if(!t[r]){if(!a&&Xt)return Xt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=s[r]={exports:{}};t[r][0].call(u.exports,function(e){return o(t[r][1][e]||e)},u,u.exports,e,t,s,n)}return s[r].exports}for(var i=Xt,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"!=Jt(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(u){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(u){i=!1}for(var r=new n.Buf8(256),a=0;a<256;a++)r[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function c(e,t){if(t<65534&&(e.subarray&&i||!e.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var s="",r=0;r<t;r++)s+=String.fromCharCode(e[r]);return s}r[254]=r[254]=1,s.string2buf=function(e){var t,s,o,i,r,a=e.length,c=0;for(i=0;i<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new n.Buf8(c),i=r=0;r<c;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),s<128?t[r++]=s:(s<2048?t[r++]=192|s>>>6:(s<65536?t[r++]=224|s>>>12:(t[r++]=240|s>>>18,t[r++]=128|s>>>12&63),t[r++]=128|s>>>6&63),t[r++]=128|63&s);return t},s.buf2binstring=function(e){return c(e,e.length)},s.binstring2buf=function(e){for(var t=new n.Buf8(e.length),s=0,o=t.length;s<o;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,n,o,i,a=t||e.length,u=new Array(2*a);for(s=n=0;s<a;)if((o=e[s++])<128)u[n++]=o;else if(4<(i=r[o]))u[n++]=65533,s+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&s<a;)o=o<<6|63&e[s++],i--;1<i?u[n++]=65533:o<65536?u[n++]=o:(o-=65536,u[n++]=55296|o>>10&1023,u[n++]=56320|1023&o)}return c(u,n)},s.utf8border=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;0<=s&&128==(192&e[s]);)s--;return s<0||0===s?t:s+r[e[s]]>t?s:t}},{"./common":1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var o=65535&e,i=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;i=i+(o=o+t[n++]|0)|0,--r;);o%=65521,i%=65521}return o|i<<16}},{}],4:[function(e,t,s){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,s){var n=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();t.exports=function(e,t,s,o){var i=n,r=o+s;e^=-1;for(var a=o;a<r;a++)e=e>>>8^i[255&(e^t[a])];return-1^e}},{}],6:[function(e,t,s){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,o,i,r,a,c,u,l,d,h,p,g,_,m,f,v,I,E,S,y,C,M,A,b;s=e.state,n=e.next_in,A=e.input,o=n+(e.avail_in-5),i=e.next_out,b=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,u=s.wsize,l=s.whave,d=s.wnext,h=s.window,p=s.hold,g=s.bits,_=s.lencode,m=s.distcode,f=(1<<s.lenbits)-1,v=(1<<s.distbits)-1;e:do{g<15&&(p+=A[n++]<<g,g+=8,p+=A[n++]<<g,g+=8),I=_[p&f];t:for(;;){if(p>>>=E=I>>>24,g-=E,0==(E=I>>>16&255))b[i++]=65535&I;else{if(!(16&E)){if(!(64&E)){I=_[(65535&I)+(p&(1<<E)-1)];continue t}if(32&E){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}S=65535&I,(E&=15)&&(g<E&&(p+=A[n++]<<g,g+=8),S+=p&(1<<E)-1,p>>>=E,g-=E),g<15&&(p+=A[n++]<<g,g+=8,p+=A[n++]<<g,g+=8),I=m[p&v];s:for(;;){if(p>>>=E=I>>>24,g-=E,!(16&(E=I>>>16&255))){if(!(64&E)){I=m[(65535&I)+(p&(1<<E)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(y=65535&I,g<(E&=15)&&(p+=A[n++]<<g,(g+=8)<E&&(p+=A[n++]<<g,g+=8)),c<(y+=p&(1<<E)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(p>>>=E,g-=E,(E=i-r)<y){if(l<(E=y-E)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(M=h,(C=0)===d){if(C+=u-E,E<S){for(S-=E;b[i++]=h[C++],--E;);C=i-y,M=b}}else if(d<E){if(C+=u+d-E,(E-=d)<S){for(S-=E;b[i++]=h[C++],--E;);if(C=0,d<S){for(S-=E=d;b[i++]=h[C++],--E;);C=i-y,M=b}}}else if(C+=d-E,E<S){for(S-=E;b[i++]=h[C++],--E;);C=i-y,M=b}for(;2<S;)b[i++]=M[C++],b[i++]=M[C++],b[i++]=M[C++],S-=3;S&&(b[i++]=M[C++],1<S&&(b[i++]=M[C++]))}else{for(C=i-y;b[i++]=b[C++],b[i++]=b[C++],b[i++]=b[C++],2<(S-=3););S&&(b[i++]=b[C++],1<S&&(b[i++]=b[C++]))}break}}break}}while(n<o&&i<a);n-=S=g>>3,p&=(1<<(g-=S<<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=p,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,u=2,l=0,d=-2,h=1,p=852,g=592;function _(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(p),t.distcode=t.distdyn=new n.Buf32(g),t.sane=1,t.back=-1,l):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):d}function I(e,t){var s,n;return e&&e.state?(n=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?d:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,v(e))):d}function E(e,t){var s,n;return e?(n=new m,(e.state=n).window=null,(s=I(e,t))!==l&&(e.state=null),s):d}var S,y,C=!0;function M(e){if(C){var t;for(S=new n.Buf32(512),y=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,S,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(u,e.lens,0,32,y,0,e.work,{bits:5}),C=!1}e.lencode=S,e.lenbits=9,e.distcode=y,e.distbits=5}function A(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=v,s.inflateReset2=I,s.inflateResetKeep=f,s.inflateInit=function(e){return E(e,15)},s.inflateInit2=E,s.inflate=function(e,t){var s,p,g,m,f,v,I,E,S,y,C,b,T,O,w,D,R,L,N,P,k,G,U,F,x=0,$=new n.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return d;12===(s=e.state).mode&&(s.mode=13),f=e.next_out,g=e.output,I=e.avail_out,m=e.next_in,p=e.input,v=e.avail_in,E=s.hold,S=s.bits,y=v,C=I,G=l;e:for(;;)switch(s.mode){case h:if(0===s.wrap){s.mode=13;break}for(;S<16;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(2&s.wrap&&35615===E){$[s.check=0]=255&E,$[1]=E>>>8&255,s.check=i(s.check,$,2,0),S=E=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&E)<<8)+(E>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&E)){e.msg="unknown compression method",s.mode=30;break}if(S-=4,k=8+(15&(E>>>=4)),0===s.wbits)s.wbits=k;else if(k>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<k,e.adler=s.check=1,s.mode=512&E?10:12,S=E=0;break;case 2:for(;S<16;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(s.flags=E,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=E>>8&1),512&s.flags&&($[0]=255&E,$[1]=E>>>8&255,s.check=i(s.check,$,2,0)),S=E=0,s.mode=3;case 3:for(;S<32;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.head&&(s.head.time=E),512&s.flags&&($[0]=255&E,$[1]=E>>>8&255,$[2]=E>>>16&255,$[3]=E>>>24&255,s.check=i(s.check,$,4,0)),S=E=0,s.mode=4;case 4:for(;S<16;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.head&&(s.head.xflags=255&E,s.head.os=E>>8),512&s.flags&&($[0]=255&E,$[1]=E>>>8&255,s.check=i(s.check,$,2,0)),S=E=0,s.mode=5;case 5:if(1024&s.flags){for(;S<16;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.length=E,s.head&&(s.head.extra_len=E),512&s.flags&&($[0]=255&E,$[1]=E>>>8&255,s.check=i(s.check,$,2,0)),S=E=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(v<(b=s.length)&&(b=v),b&&(s.head&&(k=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),n.arraySet(s.head.extra,p,m,b,k)),512&s.flags&&(s.check=i(s.check,p,b,m)),v-=b,m+=b,s.length-=b),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===v)break e;for(b=0;k=p[m+b++],s.head&&k&&s.length<65536&&(s.head.name+=String.fromCharCode(k)),k&&b<v;);if(512&s.flags&&(s.check=i(s.check,p,b,m)),v-=b,m+=b,k)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===v)break e;for(b=0;k=p[m+b++],s.head&&k&&s.length<65536&&(s.head.comment+=String.fromCharCode(k)),k&&b<v;);if(512&s.flags&&(s.check=i(s.check,p,b,m)),v-=b,m+=b,k)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;S<16;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(E!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}S=E=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(;S<32;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}e.adler=s.check=_(E),S=E=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=f,e.avail_out=I,e.next_in=m,e.avail_in=v,s.hold=E,s.bits=S,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){E>>>=7&S,S-=7&S,s.mode=27;break}for(;S<3;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}switch(s.last=1&E,S-=1,3&(E>>>=1)){case 0:s.mode=14;break;case 1:if(M(s),s.mode=20,6!==t)break;E>>>=2,S-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}E>>>=2,S-=2;break;case 14:for(E>>>=7&S,S-=7&S;S<32;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if((65535&E)!=(E>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&E,S=E=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(b=s.length){if(v<b&&(b=v),I<b&&(b=I),0===b)break e;n.arraySet(g,p,m,b,f),v-=b,m+=b,I-=b,f+=b,s.length-=b;break}s.mode=12;break;case 17:for(;S<14;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(s.nlen=257+(31&E),E>>>=5,S-=5,s.ndist=1+(31&E),E>>>=5,S-=5,s.ncode=4+(15&E),E>>>=4,S-=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(;S<3;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.lens[q[s.have++]]=7&E,E>>>=3,S-=3}for(;s.have<19;)s.lens[q[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,U={bits:s.lenbits},G=a(0,s.lens,0,19,s.lencode,0,s.work,U),s.lenbits=U.bits,G){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[E&(1<<s.lenbits)-1])>>>16&255,R=65535&x,!((w=x>>>24)<=S);){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(R<16)E>>>=w,S-=w,s.lens[s.have++]=R;else{if(16===R){for(F=w+2;S<F;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(E>>>=w,S-=w,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}k=s.lens[s.have-1],b=3+(3&E),E>>>=2,S-=2}else if(17===R){for(F=w+3;S<F;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}S-=w,k=0,b=3+(7&(E>>>=w)),E>>>=3,S-=3}else{for(F=w+7;S<F;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}S-=w,k=0,b=11+(127&(E>>>=w)),E>>>=7,S-=7}if(s.have+b>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;b--;)s.lens[s.have++]=k}}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,U={bits:s.lenbits},G=a(c,s.lens,0,s.nlen,s.lencode,0,s.work,U),s.lenbits=U.bits,G){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,U={bits:s.distbits},G=a(u,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,U),s.distbits=U.bits,G){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<=v&&258<=I){e.next_out=f,e.avail_out=I,e.next_in=m,e.avail_in=v,s.hold=E,s.bits=S,r(e,C),f=e.next_out,g=e.output,I=e.avail_out,m=e.next_in,p=e.input,v=e.avail_in,E=s.hold,S=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;D=(x=s.lencode[E&(1<<s.lenbits)-1])>>>16&255,R=65535&x,!((w=x>>>24)<=S);){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(D&&!(240&D)){for(L=w,N=D,P=R;D=(x=s.lencode[P+((E&(1<<L+N)-1)>>L)])>>>16&255,R=65535&x,!(L+(w=x>>>24)<=S);){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}E>>>=L,S-=L,s.back+=L}if(E>>>=w,S-=w,s.back+=w,s.length=R,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;S<F;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.length+=E&(1<<s.extra)-1,E>>>=s.extra,S-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;D=(x=s.distcode[E&(1<<s.distbits)-1])>>>16&255,R=65535&x,!((w=x>>>24)<=S);){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(!(240&D)){for(L=w,N=D,P=R;D=(x=s.distcode[P+((E&(1<<L+N)-1)>>L)])>>>16&255,R=65535&x,!(L+(w=x>>>24)<=S);){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}E>>>=L,S-=L,s.back+=L}if(E>>>=w,S-=w,s.back+=w,64&D){e.msg="invalid distance code",s.mode=30;break}s.offset=R,s.extra=15&D,s.mode=24;case 24:if(s.extra){for(F=s.extra;S<F;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}s.offset+=E&(1<<s.extra)-1,E>>>=s.extra,S-=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===I)break e;if(b=C-I,s.offset>b){if((b=s.offset-b)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}b>s.wnext?(b-=s.wnext,T=s.wsize-b):T=s.wnext-b,b>s.length&&(b=s.length),O=s.window}else O=g,T=f-s.offset,b=s.length;for(I<b&&(b=I),I-=b,s.length-=b;g[f++]=O[T++],--b;);0===s.length&&(s.mode=21);break;case 26:if(0===I)break e;g[f++]=s.length,I--,s.mode=21;break;case 27:if(s.wrap){for(;S<32;){if(0===v)break e;v--,E|=p[m++]<<S,S+=8}if(C-=I,e.total_out+=C,s.total+=C,C&&(e.adler=s.check=s.flags?i(s.check,g,C,f-C):o(s.check,g,C,f-C)),C=I,(s.flags?E:_(E))!==s.check){e.msg="incorrect data check",s.mode=30;break}S=E=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;S<32;){if(0===v)break e;v--,E+=p[m++]<<S,S+=8}if(E!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}S=E=0}s.mode=29;case 29:G=1;break e;case 30:G=-3;break e;case 31:return-4;default:return d}return e.next_out=f,e.avail_out=I,e.next_in=m,e.avail_in=v,s.hold=E,s.bits=S,(s.wsize||C!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&A(e,e.output,e.next_out,C-e.avail_out)?(s.mode=31,-4):(y-=e.avail_in,C-=e.avail_out,e.total_in+=y,e.total_out+=C,s.total+=C,s.wrap&&C&&(e.adler=s.check=s.flags?i(s.check,g,C,e.next_out-C):o(s.check,g,C,e.next_out-C)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),(0===y&&0===C||4===t)&&G===l&&(G=-5),G)},s.inflateEnd=function(e){if(!e||!e.state)return d;var t=e.state;return t.window&&(t.window=null),e.state=null,l},s.inflateGetHeader=function(e,t){var s;return e&&e.state&&2&(s=e.state).wrap?((s.head=t).done=!1,l):d},s.inflateSetDictionary=function(e,t){var s,n=t.length;return e&&e.state?0!==(s=e.state).wrap&&11!==s.mode?d:11===s.mode&&o(1,t,n,0)!==s.check?-3:A(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,l):d},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,u,l,d,h){var p,g,_,m,f,v,I,E,S,y=h.bits,C=0,M=0,A=0,b=0,T=0,O=0,w=0,D=0,R=0,L=0,N=null,P=0,k=new n.Buf16(16),G=new n.Buf16(16),U=null,F=0;for(C=0;C<=15;C++)k[C]=0;for(M=0;M<c;M++)k[t[s+M]]++;for(T=y,b=15;1<=b&&0===k[b];b--);if(b<T&&(T=b),0===b)return u[l++]=20971520,u[l++]=20971520,h.bits=1,0;for(A=1;A<b&&0===k[A];A++);for(T<A&&(T=A),C=D=1;C<=15;C++)if(D<<=1,(D-=k[C])<0)return-1;if(0<D&&(0===e||1!==b))return-1;for(G[1]=0,C=1;C<15;C++)G[C+1]=G[C]+k[C];for(M=0;M<c;M++)0!==t[s+M]&&(d[G[t[s+M]]++]=M);if(0===e?(N=U=d,v=19):1===e?(N=o,P-=257,U=i,F-=257,v=256):(N=r,U=a,v=-1),C=A,f=l,w=M=L=0,_=-1,m=(R=1<<(O=T))-1,1===e&&852<R||2===e&&592<R)return 1;for(;;){for(I=C-w,d[M]<v?(E=0,S=d[M]):d[M]>v?(E=U[F+d[M]],S=N[P+d[M]]):(E=96,S=0),p=1<<C-w,A=g=1<<O;u[f+(L>>w)+(g-=p)]=I<<24|E<<16|S,0!==g;);for(p=1<<C-1;L&p;)p>>=1;if(0!==p?(L&=p-1,L+=p):L=0,M++,0==--k[C]){if(C===b)break;C=t[s+d[M]]}if(T<C&&(L&m)!==_){for(0===w&&(w=T),f+=A,D=1<<(O=C-w);O+w<b&&!((D-=k[O+w])<=0);)O++,D<<=1;if(R+=1<<O,1===e&&852<R||2===e&&592<R)return 1;u[_=L&m]=T<<24|O<<16|f-l}}return 0!==L&&(u[f+L]=C-w<<24|64<<16),h.bits=T,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"),u=e("./zlib/gzheader"),l=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(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 u,n.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=i.string2buf(t.dictionary):"[object ArrayBuffer]"===l.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 h(e,t){var s=new d(t);if(s.push(e,!0),s.err)throw s.msg||a[s.err];return s.result}d.prototype.push=function(e,t){var s,a,c,u,d,h=this.strm,p=this.options.chunkSize,g=this.options.dictionary,_=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof e?h.input=i.binstring2buf(e):"[object ArrayBuffer]"===l.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new o.Buf8(p),h.next_out=0,h.avail_out=p),(s=n.inflate(h,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&g&&(s=n.inflateSetDictionary(this.strm,g)),s===r.Z_BUF_ERROR&&!0===_&&(s=r.Z_OK,_=!1),s!==r.Z_STREAM_END&&s!==r.Z_OK)return this.onEnd(s),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&s!==r.Z_STREAM_END&&(0!==h.avail_in||a!==r.Z_FINISH&&a!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(c=i.utf8border(h.output,h.next_out),u=h.next_out-c,d=i.buf2string(h.output,c),h.next_out=u,h.avail_out=p-u,u&&o.arraySet(h.output,h.output,c,u,0),this.onData(d)):this.onData(o.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(_=!0)}while((0<h.avail_in||0===h.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),!(h.avail_out=0))},d.prototype.onData=function(e){this.chunks.push(e)},d.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=d,s.inflate=h,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},s.ungzip=h},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")}(es)),es.exports),ss=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=Vt,this._currentConnectState=$t,this._beforeSendInterceptors=[]}init(){gt.addTask({id:Ft,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){const t=je.get("instance"),{sdkAppId:s,testEnv:n,disableIndependentDomain:o}=t,i=it(s);let r="";return n?r=nt.TEST[i].DEFAULT:o?(r=nt.PRODUCTION[i].DEFAULT,ct=rt.DEFAULT):r=nt.PRODUCTION[i].INITIAL.replace("*",`${s}`),lt(r,{isBinary:e})}(this._isBinarySupported),Le.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),Le.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var s;const{requestId:n,timeout:o=Gt,canResend:i=!0}=t||{};if(Ie(e))return kt.warn("sendPacket",`${Ut}.sendPacket: packet is empty `),null;this._executeBeforeSendInterceptors(e),this._currentConnectState===Bt&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Ht});const r=JSON.stringify(e);let a=null;if(n){const{resolve:t,reject:s,promise:c}=ye();a=c,this._pendingRequests.set(n,{resolve:t,reject:s,timestamp:Date.now(),uplinkData:r,timeout:o,canResend:i,requestHead:null==e?void 0:e.head})}const c=this._isBinarySupported?_t(r).buffer:r;return null===(s=this._socketAdapter)||void 0===s||s.send(c),a}connect(){var e;this._socketAdapter=new He(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=`${Ut}.connect isWorkerEnabled: false socketID:${t} url:${this._url}`;this._connectionId=t,this._ssoLog({method:"connect",message:s})}disconnect(){var e,t;const s=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId(),n=`${Ut}.disconnect socketID:${s}`;this._ssoLog({method:"disconnect",message:n}),this._removeEventListeners(),null===(t=this._socketAdapter)||void 0===t||t.disconnect()}getSocketAdapter(){return this._socketAdapter}dispose(){console.log(`${Ut}.dispose`),gt.removeTask(Ft),gt.removeTask(xt),Le.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),Le.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=Vt,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===qt&&this._isReconnecting;return!this._socketAdapter||e}reconnect(){return pe(this,void 0,void 0,function*(){const e=`${Ut}.reconnect isReconnecting: ${this._isReconnecting} currentConnectState: ${this._currentConnectState}`;if(this._ssoLog({method:"reconnect",message:e}),!this._shouldSkipReconnect()){this._url=dt(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(t){this._isReconnecting=!1,this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Kt}),console.warn(`${Ut}.reconnect failed: `,t)}}})}_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=`${Ut}.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}),t===this._connectionId&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:zt}),this._isReconnecting&&(this._isReconnecting=!1)}_onError(e){const{socketId:t,error:s}=e||{},n=`${Ut}.onError sourceSocketID: ${t} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${JSON.stringify(s)}`;this._ssoLog({method:"onError",message:n}),t===this._connectionId&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:Yt}),this._isReconnecting&&(this._isReconnecting=!1)}_onSendFail(e){const{socketId:t,error:s}=e||{},n=`${Ut}.onSendFail sendFailSocketId: ${t} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${s}`;this._ssoLog({method:"onSendFail",message:n}),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=ts.inflate(t,{to:"string"})}catch(n){console.error("inflate error",n)}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(r){const t=e.data;return void this._ssoLog({method:"jsonParseError",message: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){var t,s;const{seq:n,servcmd:o}=e.head,{int32_error_code:i,str_error_message:r}=(null==e?void 0:e.body)||{},a=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.ErrorCode)||i,c=(null===(s=null==e?void 0:e.body)||void 0===s?void 0:s.ErrorInfo)||r,u=`${n}${o}`,{resolve:l,reject:d,timestamp:h,headSeq:p,requestHead:g}=this._pendingRequests.get(u);if(this._pendingRequests.delete(u),a&&0!==a)return Le.emitInnerEvent("error",{errorCode:a,errorInfo:c,requestHead:g}),void d({errorCode:a,errorInfo:c});l(e.body)}_handlePushMessage(e){const{servcmd:t}=e.head,{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),Le.emitInnerEvent(t,e)}_checkPendingRequestsAndResend(){var e;kt.debug("_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?_t(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=`${Ut}.onConnect cost:${n} ms. socketID:${t} res:${JSON.stringify(s)}`;if(this._ssoLog({method:"onConnect",message:o}),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){const e=`${Ut}.reconnect success`;this._ssoLog({method:"reconnectSuccess",message:e}),Le.emitInnerEvent(Ot.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:$t,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}_sendAck(e){const t=vt({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(t)}_executeScheduledTaskIfReady(){return pe(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 pe(this,void 0,void 0,function*(){var e;const t=vt({servcmd:"heartbeat.alive",data:{}});try{const e=`${t.head.seq}${t.head.servcmd}`;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(s){const t=null===(e=je.get("netWorkMonitor"))||void 0===e?void 0:e.isNetWorkOnline,n=`${Ut}.sendHeartbeat failed. isNetWorkOnline:${t} error: ${s}`;this._ssoLog({method:"sendHeartbeatError",message:n}),this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}_sendHeartbeatIfReady(){return pe(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}_updateHeartbeatTime(){this._nextHeartbeatAt=P?Date.now()+5e3:Date.now()+1e4}_handleNetworkStatusChange(e){const t=`${Ut}.networkStatusChange ${JSON.stringify(e)}`;this._ssoLog({method:"networkStatusChange",message:t});const{isNetworkOnline:s,networkType:n}=e;s&&"none"!==n?this._handleConnectStateChange({state:$t,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Wt}):this._handleConnectStateChange({state:Bt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:Wt})}isPrivateNetWork(){const e=je.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}_handleConnectStateChange(e){const{state:t,shouldAttemptReconnect:s,shouldEmitEvent:n,reason:o}=e,i=`${Ut}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${s} shouldEmitEvent: ${n} reason: ${o}`;this._currentConnectState!==t&&(this._ssoLog({method:"handleConnectStateChange",message:i}),n&&(kt.info("_handleConnectStateChange",` from ${this._currentConnectState} to ${t}`),Le.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:t}}),this._currentConnectState=t,t===Bt&&Le.emitInnerEvent(Ot.SOCKET_DISCONNECTED)),s&&(this._resetReconnectDelay(),gt.addTask({id:xt,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=`${Ut}.activityStatusChange ${JSON.stringify(e)} readyState: ${n}`;this._ssoLog({method:"activityStatusChange",message:o}),3===n&&this._handleConnectStateChange({state:Bt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:jt})}_resetReconnectDelay(){var e;kt.debug(`${Ut}._resetReconnectDelay`),gt.removeTask(xt);const t=null===(e=je.get("activityMonitor"))||void 0===e?void 0:e.isActive;this._intendedDelay=t?Vt:1e3}_scheduleReconnectWithBackoff(){var e;const t=null===(e=je.get("activityMonitor"))||void 0===e?void 0:e.isActive;this._intendedDelay=t?Math.min(5e3,Math.max(Vt,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay));const s=(new Date).toTimeString().slice(0,8),n=`${Ut}.scheduleReconnectWithBackoff timeStr: ${s} intendedDelay: ${this._intendedDelay}`;kt.debug(n),this.reconnect(),gt.updateTaskInterval(xt,this._intendedDelay)}_ssoLog(e){const{method:t,message:s}=e;kt.info(t,s)}_diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(e){pe(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 ve({method:"GET",url:s,data:{}})}catch(n){kt.warn("diagnoseBySSO",`diagnoseBySSO failed. error:${n.message}`)}})}(this._url),function(e){pe(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 ve({method:"GET",url:t,data:{}})}catch(s){kt.warn(`diagnoseByCDN', 'diagnoseByCDN failed. error:${s.message}`)}})}(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:_e,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}_updateIsBinarySupported(){var e;if(null===(e=je.get("instance"))||void 0===e?void 0:e.devMode)return void(this._isBinarySupported=!1);const t=de();(L||b&&"windows"===t||P)&&(this._isBinarySupported=!1)}_isCompressedData(e){const t=new Uint8Array(e);return 67===t[0]&&79===t[1]&&77===t[2]&&80===t[3]}};const ns={init:function(e){je.set("instance",e),ss.init()},destroy:function(){ss.dispose(),je.clear(),gt.dispose()},notificationCenter:Le,channel:ss,store:je,ssoLog:kt,utils:Me,common:Mt,constants:M},os=e=>"function"==typeof e;function is(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]?is(e[n],t[n],s):e[n]===t[n]))}var rs;!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",e.SERVER_CONFIG_UPDATED="onServerConfigUpdated",e.PINNED_GROUP_MESSAGE_UPDATED="onPinnedGroupMessageUpdated"}(rs||(rs={}));var as,cs=rs;!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"}(as||(as={}));var us,ls=as;!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"}(us||(us={}));var ds=us;const hs=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),ps={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 gs;!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(gs||(gs={}));const _s={modify:ls.MESSAGE_MODIFIED,delete:ls.MESSAGE_DELETED,revoke:ls.MESSAGE_REVOKED};var ms;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(ms||(ms={}));const fs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ps),{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:gs,Direction:ms}),vs={[_s.modify]:ls.TOPIC_MESSAGE_MODIFIED,[_s.delete]:ls.TOPIC_MESSAGE_DELETED,[_s.revoke]:ls.TOPIC_MESSAGE_REVOKED},Is={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"},Es=Object.assign({},Is),Ss={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},ys=Object.assign(Object.assign(Object.assign(Object.assign({},Ss),{CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3}),{CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8}),{READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage"}),Cs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay"}),{ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny"}),{SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both"}),{SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both"}),{SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd"}),{SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single"}),{FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut"}),Ms={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},As={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},bs={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},Ts=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ms),{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:As,GROUP_TIPS_OPERATION_TYPE:bs}),Os={IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"},ws=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},hs),fs),Es),ys),Cs),Ts),Os),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"}),Ds={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,INVALID_OPERATION:2905,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},Rs={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3"},Ls={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",RECEIVE_GROUP_TIPS_NOTIFICATION:"receive-group-tips-notification"},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",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",HANDLE_GROUP_TIPS_NOTIFICATION:"handle-group-tips-notification"},Ps={[Ls.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,dependency:Ns.HISTORY_MESSAGE_RECOVER},{stepId:Ns.GROUP_TIPS_RECOVER,dependency:Ns.HISTORY_MESSAGE_RECOVER},{stepId:Ns.TOPIC_REQUEST_INFO_RESET},{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}],[Ls.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.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,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]},{stepId:Ns.CONVERSATION_GROUP_LIST_SYNC},{stepId:Ns.CONVERSATION_GROUP_UPDATE,dependency:[Ns.CONVERSATION_LIST_SYNC,Ns.CONVERSATION_GROUP_LIST_SYNC]},{stepId:Ns.QUALITY_REPORT}],[Ls.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]}],[Ls.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.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,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}],[Ls.RECEIVE_GROUP_TIPS_NOTIFICATION]:[{stepId:Ns.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:Ns.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:Ns.HANDLE_GROUP_TIPS_NOTIFICATION}]},ks={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},Gs={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"},Us=["login","getMyProfile","getUserProfile","updateMyProfile","setSelfStatus","getUserStatus","subscribeUserStatus","unsubscribeUserStatus","modifyMessage","deleteGroupMember","dismissGroup","getGroupMemberList","getGroupOnlineMemberCount","joinGroup","markGroupMemberList","quitGroup","searchCloudMessages","searchCloudGroups","searchCloudGroupMembers","searchCloudUsers","getMyFollowingList","getMyFollowersList","getMutualFollowersList","followUser","unfollowUser","getUserFollowInfo","checkFollowType","getFriendProfile","addFriend","deleteFriend","updateFriend","checkFriend","setFriendApplicationRead","createFriendGroup","deleteFriendGroup","addToFriendGroup","removeFromFriendGroup","renameFriendGroup","changeGroupOwner","createGroup","dismissGroup","getGroupList","getGroupOnlineMemberCount","getGroupProfile","searchGroupByID","updateGroupProfile","handleGroupApplication","deleteGroupAttributes","getGroupAttributes","initGroupAttributes","setGroupAttributes","addGroupMember","deleteGroupMember","getGroupMemberList","getGroupMemberProfile","setGroupMemberMuteTime","setGroupMemberNameCard","setGroupMemberRole","deleteMessage","revokeMessage","setMessageExtensions","getMessageExtensions","deleteMessageExtensions","getMessageList","addMessageReaction","removeMessageReaction","clearHistoryMessage","invite","accept","cancel","reject","modifyInvitation","deleteConversation","pinConversation","setMessageRead","setAllMessageRead","getConversationList","getTotalUnreadMessageCount","renameConversationGroup","deleteConversationGroup","markConversation","setConversationCustomData","deleteConversationsFromGroup","addConversationsToGroup","createConversationGroup"];var Fs,xs,$s,qs=Object.freeze({__proto__:null,ERROR_CODE:Ds,InnerEvent:ls,NEED_LOG_API:Us,OuterConstant:ws,OuterEvent:cs,PUSH:Os,QUALITY_METRICS:ks,SDK_EDITION:Rs,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:Gs,SignalingEvent:ds,WEB_PUSH_ACCOUNT_TYPE:1,WORKFLOW_DEFINITIONS:Ps,WORKFLOW_NAME:Ls,WORKFLOW_STEP:Ns});!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(Fs||(Fs={})),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(xs||(xs={})),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}($s||($s={}));const Bs={[xs.multipleAccount]:"multipleAccount",[xs.multipleDevice]:"multipleDevice",[xs.restApi]:"REST_API_Kick",[$s.multipleAccount]:"multipleAccount",[$s.multipleDevice]:"multipleDevice",[$s.restApi]:"REST_API_Kick",[$s.usersigExpired]:"userSigExpired"},Vs="login_online_presence_task",{ERROR:Ws,DESTROY:js,FORCE_OFFLINE:Hs}=ls,{KICKED_OUT_MULT_ACCOUNT:Ks,KICKED_OUT_MULT_DEVICE:Ys,KICKED_OUT_REST_API:zs,ACCOUNT_A2KEY_EXPIRED:Zs,MSG_A2KEY_EXPIRED:Js}=Ds;class Xs{init(){const{notificationCenter:e}=ns;e.subscribeInnerEvent(Hs,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(Ws,Js,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),e.subscribeInnerEvent(Ws,Zs,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),e.subscribeInnerEvent(Ws,Ks,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Ws,Ys,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Ws,zs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(js,this._dispose,this)}_handleForceOfflineFromServerPush(e){var t;if(!0===(null===(t=ns.store.get("login"))||void 0===t?void 0:t.isLoggedIn)){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 pe(this,void 0,void 0,function*(){const{kickedOutReasonCode:t}=e,{ssoLog:s,utils:{safeStringify:n}}=ns;try{this._logKickedOutEvent(e),this._shouldLogoutAfterKickedOut(t)&&(yield ns.login.loginAction.logout(Fs.KICKED_OUT))}catch(o){s.debug("_processKickedOutReasonInfo",` fail ${n(o)}`)}finally{ns.notificationCenter.emitOuterEvent(cs.KICKED_OUT,{data:{type:Bs[t]},name:cs.KICKED_OUT})}})}_logKickedOutEvent(e){const{kickedOutReasonCode:t,newInstanceInfo:s={}}=e,n=`type:${Bs[t]} newInstanceInfo: ${JSON.stringify(s)}`;ns.ssoLog.warn("kickedOut",n)}_isKickedOut(e){return[xs.multipleAccount,xs.multipleDevice,xs.restApi].includes(e)}_isChatLoginEvent(e){const{requestHead:t}=e||{};return 1!==(null==t?void 0:t.idtype)}_shouldLogoutAfterKickedOut(e){return![$s.usersigExpired,xs.restApi].includes(e)}_dispose(){const{notificationCenter:e}=ns;e.unSubscribeInnerEvent(Hs,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(Ws,Zs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Ws,Js,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Ws,Ks,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Ws,Ys,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Ws,zs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(js,this._dispose,this)}}function Qs(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.wslogin",s=ns.common.generateProtocolData({servcmd:t,data:{State:"Online",is_web_uniapp:0,InstType:0,CustomInfo:e}}),n=`${s.head.seq}${t}`,o=yield ns.channel.sendPacket(s,{timeout:9e4,requestId:n});if(o){const{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:r,A2Key:a,RichMsgAuthKey:c,ErrorCode:u,ErrorInfo:l,ActionStatus:d}=o;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:r,a2Key:a,authKey:c,errorCode:u,errorInfo:l,actionStatus:d}}})}function en(e){var t;try{const s=je.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 u=n[n[c]?c:i]||"";return u&&(r&&(u=u.replace("$replacement1",r)),a&&(u=u.replace("$replacement2",a))),u}catch(s){return console.warn("Error parsing stored error messages:",s),""}}class tn extends Error{constructor(e){const{functionName:t="Unknown",code:s,message:n="",data:o="",moreMessage:i=""}=e;let r=n;s&&!n&&(r=en(e));let a=s?`${t} failed. error: {"message": ${r}, "code": ${s}}`:`${t} failed. error: {"message": ${r}}`;a=`${a} ${i}`,super(),this.code=s,this.errorCode=s,this.errorMessage=r,this.message=a,this.data=o}}function sn(e,t){var s;if(e&&!0!==(null===(s=ns.store.get("login"))||void 0===s?void 0:s.isLoggedIn))throw new tn({code:Ds.USER_NOT_LOGGED_IN,functionName:t})}function nn(e,t,s){if(Array.isArray(e))for(let n=0;n<e.length;n++)on.call(this,Object.assign(Object.assign({},e[n]),{value:t[n],name:s}));else for(const n in e)on.call(this,Object.assign(Object.assign({},e[n]),{value:t[0][n],name:s,key:n}))}function on({required:e,rules:t,range:s,value:n,allowEmpty:o,name:i,key:r,customValidator:a}){if(void 0===n){if(e)throw new tn({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 s=0;s<t.length;s++){let e=t[s];e=e.replace(e[0],e[0].toUpperCase()),c+=`${e}/`}c=c.substring(0,c.length-1);const e=`[${r}] must be type of ${c}, received type: ${u=n,Reflect.apply(Object.prototype.toString,u,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}.`;throw new tn({functionName:i,message:e})}var u;if(!1===o){if(Array.isArray(n)&&(0===n.length||"string"==typeof n[0]&&""===n[0].trim()))throw new tn({functionName:i,message:`${r} can not be empty.`});if("string"==typeof n&&""===n.trim())throw new tn({functionName:i,message:`${r} can not be empty.`})}if(a&&"function"==typeof a){const e=a(n);if(!0!==e)throw new tn({functionName:i,message:`[${r}] custom validation failed: ${e||"Invalid value"}`})}}const rn=[],an={},cn={};function un(e,t){var s;sn(an[e],e),nn(cn[e],t,e),s=e,rn.forEach(e=>{const{interceptor:t,context:n}=e;t.apply(n,[s])})}function ln(e,t){rn.push({interceptor:e,context:t})}function dn(e){const{params:t,auth:s}=e;t&&"object"==typeof t&&Object.assign(cn,t),s&&"object"==typeof s&&Object.assign(an,s)}function hn(e){return ns.store.get("commercialConfig").get(e)}class pn{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),ns.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] Step ${t} started at ${new Date(s).toISOString()}`)):(this._workflowStartTimes.set(e,s),ns.ssoLog.debug("_executeWorkflowStep",`[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}`),ns.ssoLog.debug("_executeWorkflowStep",`[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),ns.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] completed successfully at ${new Date(s).toISOString()} (${n}ms)`)}},error:(e,t,s)=>{const{ssoLog:n,utils:{safeStringify:o}}=ns,i=Date.now();if(t){const r=this._stepStartTimes.get(`${e}-${t}`),a=r?i-r:0;this._stepStartTimes.delete(`${e}-${t}`),n.error("_executeWorkflowStep",`[Workflow ${e}] Step ${t} failed at ${new Date(i).toISOString()} (${a}ms) ${o(s)}`,{error:s})}else{const t=this._workflowStartTimes.get(e),r=t?i-t:0;this._workflowStartTimes.delete(e),n.error("_executeWorkflowStep",`[Workflow ${e}] failed at ${new Date(i).toISOString()} (${r}ms) ${o(s)}`,{error:s})}}}}static getInstance(){return pn._instance||(pn._instance=new pn),pn._instance}static setInstance(e){pn._instance=e}init(){this._initializeWorkflows()}registerWorkflowStep(e,t,s,n){if(!this._handlers.has(e))return void ns.ssoLog.debug("registerWorkflowStep",`Workflow '${e}' not defined in core`);if(!Ps[e].find(e=>e.stepId===t))return void ns.ssoLog.debug("registerWorkflowStep",`Step '${t}' not defined in workflow '${e}'`);const o=this._handlers.get(e);o.has(t)||o.set(t,n?s.bind(n):s)}executeWorkflow(e,t){return pe(this,void 0,void 0,function*(){if(!this._validateWorkflow(e))return;ns.ssoLog.debug("executeWorkflow",`[Workflow ${e}] Started execution at ${(new Date).toISOString()}`);const s=Ps[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=()=>{o.cancelled?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:()=>{0!==r.pendingSteps.size?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&&(ns.ssoLog.debug("executeWorkflow",`Workflow ${e} completed with some steps skipped due to dependency failures`),t()):t()},onError:s,onStepComplete:n})})};n()}),ns.ssoLog.debug("executeWorkflow",`[Workflow ${e}] Completed execution at ${(new Date).toISOString()}`)}catch(i){ns.ssoLog.error("executeWorkflow",`[Workflow ${e}] Failed execution at ${(new Date).toISOString()}`,{error:i})}finally{this._activeWorkflows.delete(e)}})}_executeWorkflowStep(e,t,n){return pe(this,void 0,void 0,function*(){const{workflowName:o,runningSteps:i,stepMap:r,stepResults:a,data:c}=t;i.add(e),this._logWorkflowExecution(o,e,"start");try{const n=r.get(e);let i=null;(null==n?void 0:n.dependency)&&(s(n.dependency)?i=a[n.dependency]:Array.isArray(n.dependency)&&(i={},n.dependency.forEach(e=>{i[e]=a[e]})));const u=this._handlers.get(o).get(e);if(u){const t=yield Promise.resolve(u({data:c,result:i}));a[e]=t,this._logWorkflowExecution(o,e,"success")}t.completedSteps.add(e)}catch(u){const t=`[Workflow].${o}.${e}`,{errorCode:s,errorInfo:i=`${t} failed`}=u||{},r=new tn({functionName:t,code:s,message:i});ns.ssoLog.error(t,i,{error:r}),this._logWorkflowExecution(o,e,"error",u),n.onError(u)}finally{i.delete(e),t.pendingSteps.delete(e),n.onStepComplete(),n.onComplete()}})}reset(){this._cancelAllWorkflows()}destroy(){this.reset(),this._handlers.clear()}_initializeWorkflows(){Object.keys(Ps).forEach(e=>{this._handlers.has(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(Ps).forEach(e=>{this._cancelWorkFlow(e)})}_validateWorkflow(e){return!!Ps[e]&&!!this._handlers.get(e)}_getExecutableSteps(e){const{pendingSteps:t,completedSteps:n,stepMap:i,workflowName:r}=e;return Array.from(t).filter(e=>{const t=i.get(e)||{},{dependency:a,skipIfDependencyMissing:c=!0}=t;if(!a)return!0;if(s(a))return this._isStepRegistered({workflowName:r,stepId:a})?n.has(a):!c;if(o(a)){if(a.filter(e=>!this._isStepRegistered({workflowName:r,stepId:e})).length>0&&c)return!1;for(const e of a)if(!n.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)}}const gn=new Map,_n=({type:e,groupID:t})=>e===ws.GRP_COMMUNITY||`${t}`.startsWith(As.COMMUNITY)&&!`${t}`.includes(As.TOPIC),mn=(e="")=>{const t=e.startsWith("GROUP")?e.replace("GROUP",""):e;return t.startsWith(As.COMMUNITY)&&`${t}`.includes(As.TOPIC)},fn="openim",vn="million_group_open_http_svc";function In(e){return pe(this,void 0,void 0,function*(){const{servcmd:t,data:s}=function(e){const{data:t}=e;return En(t)||Sn(t)}(e)?function(e){let{servcmd:t,data:s}=e;return Sn(s)?function(e){const{servcmd:t,data:s}=e;let{GroupId:n=""}=s;const o=n;return[n]=o.split(As.TOPIC),{servcmd:yn(t),data:Object.assign(Object.assign({},s),{GroupId:n,TopicId:o})}}(e):(En(s)&&(t=yn(t)),{servcmd:t,data:s})}(e):e,n=ns.common.generateProtocolData({servcmd:t,data:s}),o=`${n.head.seq}${t}`;return ns.channel.sendPacket(n,{requestId:o})})}function En(e){const{Type:t,GroupId:s,GroupIdList:n=[]}=e,o=s||n[0]||"";return _n({type:t,groupID:o})}function Sn(e){const{GroupId:t=""}=e;return mn(t)}function yn(e){if(e.includes(fn))return e;const t=e.split(".")[1];return`${vn}.${t}`}function Cn(){var e;return null===(e=ns.store.get("login"))||void 0===e?void 0:e.userId}const Mn=e=>o(e)||i(e),An=(t,s,n,o)=>{if(!Mn(t)||!Mn(s))return 0;let i=0;const r=Object.keys(s);let a;for(let c=0,u=r.length;c<u;c++)if(a=r[c],!(e(s[a])||n&&n.includes(a)))if(Mn(t[a])&&Mn(s[a]))i+=An(t[a],s[a],n,o);else{if(o&&o.includes(s[a]))continue;t[a]!==s[a]&&(t[a]=s[a],i+=1)}return i},bn=(t,s)=>{if(e(s))return"";switch(t){case ws.MSG_TEXT:return s.text||"";case ws.MSG_IMAGE:return"[Image]";case ws.MSG_LOCATION:return"[Location]";case ws.MSG_AUDIO:return"[Voice]";case ws.MSG_VIDEO:return"[Video]";case ws.MSG_FILE:return"[File]";case ws.MSG_CUSTOM:return"[Custom Messages]";case ws.MSG_GRP_TIP:return"[Group Notification]";case ws.MSG_GRP_SYS_NOTICE:return"[Group System Message]";case ws.MSG_FACE:return"[Animated Sticker]";case ws.MSG_MERGER:return"[Chat Record]";default:return""}},Tn=[{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_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}],On="im_sdk_config_mgr.fetch_config",wn="im_sdk_config_mgr.push_configv2",Dn="cloud-config",Rn=2996,Ln=new class{init(e){this.core=e}};function Nn(e){return pe(this,void 0,void 0,function*(){const{sdkAppId:t}=Ln.core.store.get("instance")||{},s=Ln.core.helper.generateProtocolData({servcmd:On,data:{uint32_sdkappid:t,uint64_version:e}}),n=`${s.head.seq}${On}`;return Ln.core.channel.sendPacket(s,{requestId:n})})}var Pn=new class{constructor(){this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map}install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,helper:n,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i},channel:r}=e;t.subscribeInnerEvent(wn,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(Tn),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}getServerConfig(e){return pe(this,void 0,void 0,function*(){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:Rn,replacement1:e})}_handlePushedConfig(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.info("_handlePushedConfig",s(e)),yield this._updateCloudConfig(e)})}_handleLoginSuccess(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;try{if(this._canFetch()){const s=yield Nn(this._version);e.info("_fetchCloudConfigIfLogin",t(s)),yield this._updateCloudConfig(s)}this._core.helper.taskScheduler.addTask({id:Dn,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(s){e.error("_fetchCloudConfigIfLogin",t(s))}})}_fetchCloudConfigIfReady(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;if(this._canFetch())try{const s=yield Nn(this._version);e.info("_fetchCloudConfigIfReady",t(s)),yield this._updateCloudConfig(s)}catch(s){e.error("_fetchCloudConfigIfReady",t(s))}})}_updateCloudConfig(e){return pe(this,void 0,void 0,function*(){const t=this._parseCloudConfig(e);t&&(this._core.store.set("cloudConfig",t),yield this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,t),this._core.notificationCenter.emitOuterEvent(this._core.OuterEvent.SERVER_CONFIG_UPDATED,{name:this._core.OuterEvent.SERVER_CONFIG_UPDATED,data:{config: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(c){}this._expirationTime=Date.now()+1e3*o}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return a}_parseCmdFreqLimit(){return pe(this,void 0,void 0,function*(){var e;let t=null===(e=yield 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(n){console.warn(n)}})}_updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}_reset(){this._core.helper.taskScheduler.removeTask(Dn),this._core.store.clear("cloudConfig"),this._updateCmdFreqLimitMap(Tn),this._methodCallFrequencyMap.clear(),this._expirationTime=0,this._version=0,this._isFetching=!1}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(wn,this._handlePushedConfig,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}};class kn{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 Gn={SEARCH_GRP_SNS:new kn(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new kn(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new kn(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new kn(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new kn(0,Math.pow(2,6)).toString(),USER_STATUS:new kn(0,Math.pow(2,7)).toString(),CONV_MARK:new kn(0,Math.pow(2,9)).toString(),CONV_GROUP:new kn(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new kn(0,Math.pow(2,11)).toString(),MSG_EXT:new kn(0,Math.pow(2,13)).toString(),GRP_COUNTER:new kn(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new kn(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new kn(Math.pow(2,7)).toString(),PLUGIN_CS:new kn(Math.pow(2,8)).toString(),PLUGIN_PUSH:new kn(Math.pow(2,9)).toString(),PLUGIN_BOT:new kn(Math.pow(2,10)).toString(),MSG_REACTION:new kn(Math.pow(2,16)).toString(),FOLLOW:new kn(Math.pow(2,20)).toString()},Un="CommercialConfig",Fn="commercial-config";var xn,$n,qn=new class{constructor(){this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map,this._purchaseBits="0"}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),e.helper.registerExperimentalAPI("queryCommercialAbility",this)}isCommercialAbilityEnabled(e){return pe(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 kn(0,2**i).toString():new kn(2**(i-32),0).toString(),!this._featureMap.get(n))){o=!1;break}return this._core.ssoLog.debug("isFeatureEnabled",`${Un}.isFeatureEnabled decimalNumber:${e} key:${n} ret:${o}`),{code:0,data:{enabled:o}}})}queryCommercialAbility(){return this._purchaseBits}_fetchAndParseCommercialConfig(){return pe(this,void 0,void 0,function*(){var e;const{ssoLog:t,utils:{safeStringify:s},common:{buildAndSendPacket:n}}=this._core;try{this._isFetching=!0;const t=yield n({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}});(null==t?void 0:t.body)&&(this._parseCommercialConfig(t.body),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(o){t.error("_fetchAndParseCommercialConfig",s(o))}finally{this._isFetching=!1}})}_syncCommercialConfig(e){return pe(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:Fn,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 pe(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}_parseCommercialConfig(e){const{ssoLog:t}=this._core;if("object"!=typeof e)return;const{int32_error_code:s,str_error_message:n,str_purchase_bits:o,uint32_expired_time:i}=e;0===s?(this._parsePurchaseBits(o),this._expirationTime=Date.now()+1e3*i):void 0===s?(t.warn("_parseCommercialConfig",`${Un}._parseCommercialConfig failed. Invalid message format:`,e),this._expirationTime=Date.now()+36e5):(t.warn("_parseCommercialConfig",`${Un}._parseCommercialConfig errorCode:${s} errorMessage:${n}`),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){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(this._isValidPurchaseBits(e)){this._purchaseBits=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 kn(0,2**n).toString():new kn(2**(n-32),0).toString(),"1"===e[s]){this._featureMap.set(t,!0);const e=this._getKeyByValue(Gn,t);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(t,!1);const e=this._getKeyByValue(Gn,t);e&&this._methodKeyMap.set(e,!1)}}else t.warn("_parsePurchaseBits",`${Un}.parsePurchaseBits invalid purchases:${s(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(Fn),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear(),this._purchaseBits="0"}},Bn=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)}},Vn=new class{constructor(){this.name="ConfigCenter"}install(e){Ln.init(e),Pn.install(e),qn.install(e),Bn.install(e)}},Wn=new class{constructor(){this.name="ErrorMessage",this._core=null}install(e){return pe(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 pe(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(_){console.error(_)}})}_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 jn(e,t){return pe(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:u,MsgTimeStamp:l,SendMsgControl:d,SupportMessageExtension:h,To_Account:p,TinyId:g,MsgCheckResult:_,CloudCustomData:m,IsPeerRead:f,MsgFlagBits:v,MsgVersion:I,EventArray:E}=e;return{from:s,avatar:n,nick:o,needReadReceipt:1===i,readReceiptSentByPeer:f,clientTime:a,messageFlagBits:v,random:c,sequence:u,time:l,messageControlInfo:d,isSupportExtension:h,to:p,tinyID:g,checkResult:_,cloudCustomData:m,messageVersion:I,eventArray:E,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(c){console.warn(c)}})}!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}(xn||(xn={})),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}($n||($n={}));var Hn=new class{constructor(){this.name="UnreadMessageSynchronizer",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 pe(this,void 0,void 0,function*(){const{isAfterReOnline:t=!1,isAfterNewMessageReceived:s=!1,isAfterLogin:n=!1}=e||{};let o=xn.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?$n.NEW_MESSAGE_RECEIVED:$n.LOGIN_SUCCESS});if(!e)break;const{unreadMessageList:n=[],revokedMessageList:u=[],overflowUnreadCountList:l,unreadCountList:d,groupTipList:h}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",o=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(n),a.push(...u),this._updateConversationUnreadOptions({unreadCountList:d,overflowUnreadCountList:l,conversationUpdateFieldList:i}),Array.isArray(h)&&r.push(...h),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 pe(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}_syncUnreadDBMessageAfterNewMessageReceived(e){return pe(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;t!==i&&(n.find(({conversationID:e})=>e===`${o}${t}`)||n.push({conversationID:`${o}${t}`,type:o,lastMsgTime:s}))})}_syncUnreadDBMessageAfterReOnline(){return pe(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 pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;try{const n="unread-message-synchronizer._fetchUnreadDBMessage";t.debug("_fetchUnreadDBMessage",`${n} options:${s(e)}`);const o=yield jn(e,this._core);if(!o)return null;const{syncFlag:i,unreadMessageList:r,revokedMessageList:a,cookie:c,unreadCountList:u,overflowUnreadCountList:l,groupTipList:d}=o;return this._parseAndSaveUnreadMessageList(r),{syncFlag:i,cookie:c,unreadMessageList:r,revokedMessageList:a,unreadCountList:u,overflowUnreadCountList:l,groupTipList:d}}catch(n){console.log(n)}})}_canContinueSync({cookie:e,syncFlag:t}){var s;return t===xn.START_SYNC||t===xn.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()}},Kn=new class{init(e){var t;this._core=e,this._visibilityChangeHandler=this._handleVisibilityChange.bind(this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null===document||void 0===document||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()}},Yn=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,t,s,n,o;const{MINI_APP_NAMESPACE:i,IN_TT_MINI_GAME:r,IN_WX_MINI_GAME:a}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};r||a?(null===(t=null==i?void 0:i.onShow)||void 0===t||t.call(i,()=>{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})}),null===(s=null==i?void 0:i.onHide)||void 0===s||s.call(i,()=>{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})})):(null===(n=null==i?void 0:i.onAppShow)||void 0===n||n.call(i,()=>{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})}),null===(o=null==i?void 0:i.onAppHide)||void 0===o||o.call(i,()=>{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()}},zn=new class{init(e){const{IN_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?Yn.init(e):Kn.init(e))}};const Zn="none",Jn="online";var Xn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return pe(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:Jn})}_onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Zn})}_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()}},Qn=new class{init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}_activateNetworkMonitoring(){return pe(this,void 0,void 0,function*(){try{const{utils:{MINI_APP_NAMESPACE:e}}=this._core;this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),e.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(_){console.error(_)}})}_deactivateNetworkMonitoring(){if(null!==this._mpNetworkStatusCallback){const{utils:{MINI_APP_NAMESPACE:e}}=this._core;e.offNetworkStatusChange&&e.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()}},eo=new class{init(e){const{IN_MINI_APP:t}=e.utils;t?Qn.init(e):Xn.init(e)}},to=new class{constructor(){this.name="SystemStateMonitor"}install(e){zn.init(e),eo.init(e)}};const so=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.*"]),no="tui_room_svr.*";var oo=new class{constructor(){this.name="BusinessCommandTransfer",this._transferredCommands=so}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 pe(this,void 0,void 0,function*(){const t="transferBusinessCommand";try{const{serviceCommand:s=no}=e||{};if(!this._isValidTransferredCommand(s))throw new this._core.helper.ChatError({code:2995,functionName:t});return{code:0,data:(yield function(e,t){return pe(this,void 0,void 0,function*(){const{helper:s,channel:n}=t,{serviceCommand:o=no,data:i}=e||{};let r={};try{r="string"==typeof i?JSON.parse(i):i}catch(u){console.warn(u)}const a=s.generateProtocolData({servcmd:o,data:r}),c=`${a.head.seq}${o}`;return n.sendPacket(a,{requestId:c})})}(e,this._core))||{}}}catch(s){throw console.warn(s),new this._core.helper.ChatError({code:null==s?void 0:s.errorCode,message:null==s?void 0:s.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(t){console.log(t)}}_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=so}_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)}};const io=1,ro=2,ao=3,co=4,uo=5,lo="TIMCustomElem",ho="C2C",po="GROUP",go="invite",_o="accept",mo="cancel",fo="reject",vo="modifyInvitation",Io="signaling",Eo=8010,So="signaling-timeout";function yo(e){return e.filter(e=>{if(e.type===lo){const{cloudCustomData:t="",payload:{data:s=""}={}}=e,n=t.match(/"type":"tsignaling"/),o=s.match(/inviteID/),i=s.match(/actionType/);return n||o&&i}return!1})}function Co(e){const{data:t}=e.payload;try{return JSON.parse(t)}catch(s){return console.error(s),null}}function Mo(e,t){return e.toString(16).padStart(t,"0")}function Ao(e){if(e<0||e>53)throw new Error("Number of digits must be between 0 and 53");if(e<=30)return Math.floor(Math.random()*(1<<e));const t=e-30;return Math.floor(Math.random()*(1<<t))*(1<<30)+Math.floor(Math.random()*(1<<30))}var bo=new class{constructor(){this._onlineSignalingMap=new Map,this._isSignalingListening=!1}init(e){this._core=e,e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this)}getOnlineSignalingMap(){return this._onlineSignalingMap}hasSignaling(e){return this._onlineSignalingMap.has(e)}getSignaling(e){return this._onlineSignalingMap.get(e)}saveSignaling(e,t){return this._onlineSignalingMap.set(e,t)}removeSignaling(e){return this._onlineSignalingMap.delete(e)}isInvitationValid(e){const t=`${Io}.isInvitationValid`,{inviteID:s,groupID:n,inviter:o}=e,i=o===this._core.common.getCurrentUserID();if(!this._onlineSignalingMap.has(s))return!1;const{inviteeList:r}=this._onlineSignalingMap.get(s);if(console.log(`${t} inviteID:${s} inviteeList:${r} groupID:${n}`),n){if(i)return r.length>0;const e=this._core.common.getCurrentUserID();return r.includes(e)}return!0}updateSignaling(e){const t=`${Io}.updateSignaling`,{inviteID:s,inviter:n,inviteeList:o,groupID:i}=e;if(console.log(`${t} inviteID:${s} inviter:${n} groupID:${i}`),i&&this.hasSignaling(s)){const e=o[0],{inviteeList:n}=this._onlineSignalingMap.get(s);n.includes(e)&&(n.splice(n.indexOf(e),1),console.log(`${t} remove ${e}. localInviteeList.length:${n.length}`)),0===n.length&&this.removeSignaling(s)}else this.removeSignaling(s)}setSignalingListenStatus(e){this._isSignalingListening=e}getSignalingListenStatus(){return this._isSignalingListening}_dispose(){var e,t;this._reset(),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._isSignalingListening=!1}_reset(){this._onlineSignalingMap.clear()}},To=new class{init(e){this._core=e}createInviteSignaling(e){const t=this._generateInviteID(),s=this._createInviteSignalingData(Object.assign(Object.assign({},e),{inviteID:t})),{groupID:n,inviteeList:o}=s,i=n||o[0];return{signaling:this._createSignaling(s,i),signalingData:s,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}createAcceptSignaling(e){const t=this._createAcceptSignalingData(e),{groupID:s,inviter:n}=t,o=s||n;return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}createCancelSignaling(e){const t=this._createCancelSignalingData(e),{groupID:s,inviteeList:n}=t,o=s||n[0];return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}createRejectSignaling(e){const t=this._createRejectSignalingData(e),{groupID:s,inviter:n}=t,o=s||n;return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}createTimeoutSignaling(e){const{isInviter:t=!1}=e,s=this._createTimeoutSignalingData(e),{groupID:n,inviteeList:o,inviter:i}=s,r=n||(t?o[0]:i);return{signaling:this._createSignaling(s,r),signalingData:s,signalingExtensionOptions:this._createSignalingExtensionOptions(s)}}_createSignalingExtensionOptions(e){var t,s;const{data:n="",onlineUserOnly:o,inviteID:i="",offlinePushInfo:r,actionType:a}=e,c=(null===(s=null===(t=bo.getSignaling(i))||void 0===t?void 0:t.signaling)||void 0===s?void 0:s._onlineOnlyFlag)||!1;return{onlineUserOnly:o||c,offlinePushInfo:r,messageControlInfo:this._createMessageControlInfo(n,a)}}_createMessageControlInfo(e,t){const s=t===uo&&!!e.match(/excludeTimeoutSignalingFromHistoryMessage/),n=!!e.match(/excludeFromHistoryMessage/)||!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return{excludedFromContentModeration:!0,excludedFromUnreadCount:s||n,excludedFromLastMessage:s||n}}_createInviteSignalingData(e){const t=`${Io}._createInviteSignalingData`,{userID:s,timeout:n=0,groupID:o="",inviteeList:i=[]}=e,r=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:io,inviter:r,inviteeList:o?i:[s],timeout:n});return console.log(`${t} signalingData:`,a),a}_createAcceptSignalingData(e){const t=`${Io}._createAcceptSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviter:o,groupID:i}=bo.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:ao,groupID:i,inviter:o,inviteeList:[n]});return console.log(`${t} signalingData:`,r),r}_createCancelSignalingData(e){const t=`${Io}._createCancelSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviteeList:o,groupID:i}=bo.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:ro,groupID:i,inviter:n,inviteeList:o});return console.log(`${t} signalingData:`,r),r}_createRejectSignalingData(e){const t=`${Io}._createRejectSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviter:o,groupID:i}=bo.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:co,groupID:i,inviter:o,inviteeList:[n]});return console.log(`${t} signalingData:`,r),r}_createTimeoutSignalingData(e){const t=`${Io}._createTimeoutSignalingData`,{isInviter:s=!1,inviteID:n}=e,{inviteeList:o,inviter:i}=bo.getSignaling(n),r=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:uo,inviter:i,inviteeList:s?o:[r]});return console.log(`${t} signalingData:`,a),a}_createSignaling(e,t){var s,n,o;const{groupID:i=""}=e,r={to:t,conversationType:i?po:ho,priority:"High",payload:{data:JSON.stringify(e)}};return null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageFactory)||void 0===o?void 0:o.createCustomMessage(r)}_generateInviteID(){return[Mo(Ao(32),8),Mo(Ao(16),4),Mo(16384|Ao(12),4),Mo(32768|Ao(14),4),Mo(Ao(48),12)].join("-")}_generateBaseSignalData(e){const{data:t="",inviteID:s="",groupID:n=""}=e;return{businessID:1,timeout:0,data:t,inviteID:s,groupID:n}}},Oo=new class{constructor(){this._isProcessingSignaling=!1}init(e){this._core=e,e.helper.registerApi({apiName:"invite",context:this}),e.helper.registerApi({apiName:"accept",context:this}),e.helper.registerApi({apiName:"cancel",context:this}),e.helper.registerApi({apiName:"reject",context:this}),e.helper.registerApi({apiName:"modifyInvitation",context:this}),e.helper.registerApi({apiName:"getSignalingInfo",context:this}),e.helper.registerApi({apiName:"addSignalingListener",context:this}),e.helper.registerApi({apiName:"removeSignalingListener",context:this}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this)}invite(e){return pe(this,void 0,void 0,function*(){var t;try{this._validateBeforeInvite(e);const{signaling:s,signalingData:n,signalingExtensionOptions:o}=To.createInviteSignaling(e),i=yield this._sendSignaling(s,o);if(0===(null==i?void 0:i.code)){const{inviteID:e,timeout:o}=n;return bo.saveSignaling(e,Object.assign(Object.assign({},n),{signaling:s})),o>0&&(null===(t=this._core)||void 0===t||t.helper.taskScheduler.addOnceTask({id:`${So}-${e}`,intervalMs:1e3*(o+5),callback:this.handleInvitationExpiryTimer.bind(this,e)})),Object.assign(Object.assign({},i),{inviteID:e})}return i}catch(s){throw s}})}accept(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeAccept(t),this._isProcessingSignaling=!0;const{signaling:s,signalingData:n,signalingExtensionOptions:o}=To.createAcceptSignaling(e),i=yield this._sendSignaling(s,o);return 0===(null==i?void 0:i.code)?(bo.updateSignaling(n),Object.assign(Object.assign({},i),{inviteID:t})):i}catch(t){throw t}finally{this._isProcessingSignaling=!1}})}cancel(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeCancel(t),this._isProcessingSignaling=!0;const{signaling:s,signalingExtensionOptions:n}=To.createCancelSignaling(e),o=yield this._sendSignaling(s,n);return 0===(null==o?void 0:o.code)?(bo.removeSignaling(t),Object.assign(Object.assign({},o),{inviteID:t})):o}catch(t){throw t}finally{this._isProcessingSignaling=!1}})}reject(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeReject(t),this._isProcessingSignaling=!0;const{signaling:s,signalingExtensionOptions:n}=To.createRejectSignaling(e),o=yield this._sendSignaling(s,n);return 0===(null==o?void 0:o.code)?(bo.removeSignaling(t),Object.assign(Object.assign({},o),{inviteID:t})):o}catch(t){throw t}finally{this._isProcessingSignaling=!1}})}modifyInvitation(e){return pe(this,void 0,void 0,function*(){var t,s;const{inviteID:n,data:o}=e;let i="";try{this._validateBeforeModifyInvitation(n);const e=bo.getSignaling(n),{signaling:r}=e,a=he(e,["signaling"]);i=r.payload.data,a.data=o,r.payload.data=JSON.stringify(a);const c=yield null===(s=null===(t=this._core)||void 0===t?void 0:t.message.messageAction)||void 0===s?void 0:s.modifyMessage(r);return bo.hasSignaling(n)&&bo.saveSignaling(n,Object.assign(Object.assign({},a),{signaling:r})),c}catch(r){if(i){const{signaling:e}=bo.getSignaling(n);e.payload.data=i}throw r}})}getSignalingInfo(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(0===yo([e]).length)return;const n=Co(e),o={businessID:n.businessID||1,inviteID:n.inviteID,groupID:n.groupID||"",inviter:n.inviter||"",inviteeList:n.inviteeList||[],data:n.data||"",actionType:n.actionType||io,timeout:n.timeout||0};return t.debug(`${Io} getSignalingInfo ${s(o)}`),o}addSignalingListener(e,t,s){var n,o;e===(null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED)&&bo.setSignalingListenStatus(!0),null===(o=this._core)||void 0===o||o.notificationCenter.subscribeOuterEvent(e,t,s)}removeSignalingListener(e,t,s){var n,o;e===(null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED)&&bo.setSignalingListenStatus(!1),null===(o=this._core)||void 0===o||o.notificationCenter.unSubscribeOuterEvent(e,t,s)}handleInvitationExpiryTimer(e){const t=bo.getOnlineSignalingMap(),s=this._core.common.getCurrentUserID();if(!t.has(e))return;const n=t.get(e).inviter===s;this._sendTimeoutNotice({inviteID:e,isInviter:n})}_sendSignaling(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;return null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(e,t)})}_sendTimeoutNotice(e){return pe(this,void 0,void 0,function*(){var t,s,n;this._core.ssoLog.debug("_sendTimeoutNotice",`${Io}._sendTimeoutNotice params:${JSON.stringify(e)}`);const{isInviter:o,inviteID:i}=e,{signaling:r,signalingData:a,signalingExtensionOptions:c}=To.createTimeoutSignaling(e),u=yield this._sendSignaling(r,c);if(0===(null==u?void 0:u.code)){const{data:e,groupID:c,inviteeList:u,inviter:l}=a;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(null===(s=this._core)||void 0===s?void 0:s.SignalingEvent.INVITATION_TIMEOUT,{name:null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.INVITATION_TIMEOUT,data:{data:e,groupID:c,inviteID:i,inviteeList:u,inviter:l,isSelfTimeout:!0,message:r}}),o?bo.removeSignaling(i):bo.updateSignaling(a)}})}_validateInviteId(e,t){if(!bo.hasSignaling(t))throw new this._core.helper.ChatError({functionName:e,code:Eo})}_validateProcessStatus(e){if(this._isProcessingSignaling)throw new this._core.helper.ChatError({functionName:e,message:"processing other signaling operations"})}_validateBeforeInvite(e){const t=go,{userID:s}=e,n=this._core.common.getCurrentUserID();if(s===n)throw new this._core.helper.ChatError({functionName:t,message:`cannot invite yourself, currentUserId:${n}, inviteeId:${s}`})}_validateBeforeAccept(e){const t=_o;this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviteeList:n}=bo.getSignaling(e);if(!n.includes(s)){const n=`userID:${s} not in inviteeList. inviteID:${e}`;throw new this._core.helper.ChatError({functionName:t,message:n})}}_validateBeforeCancel(e){const t=mo;this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviter:n}=bo.getSignaling(e);if(n!==s){const e=`unmatched inviter:${n} and my userID:${s}`;throw new this._core.helper.ChatError({functionName:t,message:e})}}_validateBeforeReject(e){const t=fo;this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviteeList:n}=bo.getSignaling(e);if(!n.includes(s)){const n=`userID:${s} not in inviteeList. inviteID:${e}`;throw new this._core.helper.ChatError({functionName:t,message:n})}}_validateBeforeModifyInvitation(e){const t=vo;this._validateInviteId(t,e)}_dispose(){var e,t;this._reset(),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this)}_reset(){this._isProcessingSignaling=!1}},wo=new class{constructor(){this._actionProcessor=new Map([[io,this._onNewInvitationReceived.bind(this)],[co,this._onInviteeRejected.bind(this)],[ao,this._onInviteeAccepted.bind(this)],[ro,this._onInvitationCancelled.bind(this)],[uo,this._onInvitationTimeout.bind(this)]])}init(e){this._core=e,e.notificationCenter.subscribeOuterEvent(e.OuterEvent.MESSAGE_RECEIVED,this._handleMessageReceived,this),e.notificationCenter.subscribeOuterEvent(e.OuterEvent.MESSAGE_MODIFIED,this._handleMessageModified,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}handleActionSignaling(e){e.forEach(e=>{const t=Co(e);if(t){const s=this._actionProcessor.get(t.actionType);null==s||s(t,e)}})}_handleMessageReceived(e){if(!bo.getSignalingListenStatus())return;const t=yo(e.data);0!==t.length&&this.handleActionSignaling(t)}_handleMessageModified(e){if(!bo.getSignalingListenStatus())return;const t=yo(e.data);t.length>0&&t.forEach(e=>{const t=Co(e);t&&this._onInvitationModified(t,e)})}_onNewInvitationReceived(e,t){var s,n;const o=`${Io}._onNewInvitationReceived`,{inviteID:i,inviteeList:r,groupID:a}=e,c=this._core.common.getCurrentUserID();if(this._core.ssoLog.debug("_onNewInvitationReceived",`${o} signalingData:${JSON.stringify(e)}}`),a&&!r.includes(c))return;let{timeout:u}=e;const l=Date.now()/1e3-t.time;u>0&&l>0&&u>l&&(u-=l);const d=bo.getSignaling(i);d!==e&&(d||bo.saveSignaling(i,Object.assign(Object.assign({},e),{signaling:t})),u>0&&(null===(s=this._core)||void 0===s||s.helper.taskScheduler.addOnceTask({id:`${So}-${i}`,intervalMs:1e3*u,callback:Oo.handleInvitationExpiryTimer.bind(Oo,i)})),this._emitEvent({name:null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{inviteeList:r})}))}_onInviteeRejected(e){var t;const s=`${Io}._onInviteeRejected`,{inviteID:n,inviter:o,groupID:i,inviteeList:r}=e,a=bo.hasSignaling(n);this._core.ssoLog.debug("_onInviteeRejected",`${s} inviteID:${n} hasInviteID:${a} inviter:${o} groupID:${i}`),a&&(bo.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITEE_REJECTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{invitee:r[0]})}))}_onInviteeAccepted(e){var t;const s=`${Io}._onInviteeAccepted`,{inviteID:n,inviter:o,groupID:i,inviteeList:r}=e,a=bo.hasSignaling(n);this._core.ssoLog.debug("_onInviteeAccepted",`${s} inviteID:${n} hasInviteID:${a} inviter:${o} groupID:${i}`),a&&(bo.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITEE_ACCEPTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{invitee:r[0]})}))}_onInvitationCancelled(e){var t;const s=`${Io}._onInvitationCancelled`,{inviteID:n,inviter:o,groupID:i}=e,r=bo.hasSignaling(n);this._core.ssoLog.debug("_onInvitationCancelled",`${s} inviteID:${n} hasInviteID:${r} inviter:${o} groupID:${i}`),r&&(bo.removeSignaling(n),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITATION_CANCELLED,data:this._generateBaseEmitData(e)}))}_onInvitationTimeout(e){var t;const s=`${Io}._onInvitationTimeout`,{inviteID:n,inviteeList:o}=e,i=bo.hasSignaling(n);this._core.ssoLog.debug("_onInvitationTimeout",`${s} inviteID:${n} hasInviteID:${i} data:${e.data}`),i&&(bo.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITATION_TIMEOUT,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{inviteeList:o,isSelfTimeout:!1})}))}_onInvitationModified(e,t){var s;const n=`${Io}._onInvitationModified`,{inviteID:o,data:i}=e,r=bo.hasSignaling(o);this._core.ssoLog.debug("_onInvitationModified",`${n} inviteID:${o} data:${i}`),r&&(bo.saveSignaling(o,Object.assign(Object.assign({},e),{signaling:t})),this._emitEvent({name:null===(s=this._core)||void 0===s?void 0:s.SignalingEvent.INVITATION_MODIFIED,data:{inviteID:o,data:i}}))}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}_generateBaseEmitData(e){const{inviteID:t,inviter:s,groupID:n,data:o}=e;return{inviteID:t,inviter:s,groupID:n,data:o||""}}_dispose(){var e,t,s;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_RECEIVED,this._handleMessageReceived,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_MODIFIED,this._handleMessageModified,this),null===(s=this._core)||void 0===s||s.notificationCenter.unSubscribeOuterEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}},Do=new class{constructor(){this._offlineSignalingMap=new Map}init(e){this._core=e;const{notificationCenter:t,helper:s,constants:{InnerEvent:n,WORKFLOW_STEP:o,WORKFLOW_NAME:i}}=e;t.subscribeInnerEvent(n.DESTROY,this._dispose,this),t.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.registerWorkflowStep(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.SIGNALING_MESSAGE_RECOVER,this._handleC2COfflineMessage,this)}_handleC2COfflineMessage(e){const{result:{unreadMessageMap:t}={}}=e||{};if(0===(null==t?void 0:t.size)||!bo.getSignalingListenStatus())return;const s=yo([...t.values()]);if(0!==s.length&&(s.forEach(e=>{this._handleC2CActionType(e)}),this._offlineSignalingMap.size>0)){const e=this._sortOfflineSignalingByTime();wo.handleActionSignaling(e)}}_handleC2CActionType(e){const t=Co(e);if(!t)return;const{actionType:s}=t;s===io?this._saveValidOfflineInvite(t,e):this._removeOfflineInvite(t)}_saveValidOfflineInvite(e,t){const{inviteID:s,inviteeList:n=[],timeout:o=0}=e,i=this._core.common.getCurrentUserID();if(!n.includes(i))return;const r=Date.now()/1e3-t.time;o>0&&r>o&&0!==o||this._offlineSignalingMap.set(s,Object.assign(Object.assign({},e),{signalingList:[t]}))}_removeOfflineInvite(e){const{inviteID:t=""}=e;this._offlineSignalingMap.has(t)&&this._offlineSignalingMap.delete(t)}_sortOfflineSignalingByTime(){let e=[];return this._offlineSignalingMap.forEach(t=>{e=[...e,...t.signalingList]}),e.sort((e,t)=>e.time-t.time)}_dispose(){var e,t;this._reset(),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)}_reset(){this._offlineSignalingMap.clear()}};const Ro={invite:{userID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0},timeout:{required:!1,rules:["number"],allowEmpty:!1},onlineUserOnly:{required:!1,rules:["boolean"],allowEmpty:!1},offlinePushInfo:{required:!1,rules:["object"],allowEmpty:!1}},cancel:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},accept:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},reject:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},modifyInvitation:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}}},Lo={invite:!0,cancel:!0,accept:!0,reject:!0,modifyInvitation:!0};var No=new class{constructor(){this.name="Signaling"}install(e){Oo.init(e),wo.init(e),To.init(e),bo.init(e),Do.init(e),e.helper.registerValidateConfig({auth:Lo,params:Ro})}};const Po=new class{init(e){this.core=e}};var ko,Go;!function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem"}(ko||(ko={})),function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Go||(Go={}));const Uo="MSG_REACTION",Fo="MSG_EXT",xo=0,$o=1,qo={ZH_CN:"zh (cmn-Hans-CN)",EN_US:"en-US",YUE_HK:"yue-Hant-HK",JA_JP:"ja-JP",ZH_PY:"zh-PY"},Bo="16k_zh",Vo="16k_en",Wo="16k_yue",jo="16k_ja",Ho="16k_zh-PY",Ko={[qo.ZH_CN]:Bo,[qo.EN_US]:Vo,[qo.YUE_HK]:Wo,[qo.JA_JP]:jo,[qo.ZH_PY]:Ho},Yo=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/,zo={READ:0,UNREAD:1},Zo=1,Jo=2,Xo=3,Qo=1,ei=2;var ti;!function(e){e.IN="in",e.OUT="out"}(ti||(ti={}));const si=16,ni=17,oi=2116,ii=2500,ri="C2C",ai="GROUP",ci=20;function ui(e){return pe(this,void 0,void 0,function*(){var t,s;const{appStore:n,utils:{isEmpty:o},common:{getCurrentUserID:i},notificationCenter:r,OuterEvent:a}=Po.core,{messageList:c,conversationID:u}=e,l=n.conversationStore.getConversationMap();let d=null===(t=l.get(u))||void 0===t?void 0:t.peerReadTime;if(!d){const e=u.replace(ri,""),t=yield function(e){return pe(this,void 0,void 0,function*(){const t={To_Account:e};return Po.core.common.buildAndSendPacket({servcmd:"openim.get_peer_read_time",data:t})})}([e]);if(t){const{ReadTime:e}=t;d=null==e?void 0:e[0],l.has(u)&&(l.get(u).peerReadTime=d)}}if(l.has(u)){const e=null===(s=l.get(u))||void 0===s?void 0:s.lastMessage;o(e)||e.fromAccount===i()&&e.lastTime<=d&&!e.isPeerRead&&(e.isPeerRead=!0,n.conversationStore.updateConversation(u,{lastMessage:e}))}const h=[];c.forEach(e=>{e.time<=d&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,h.push(e))}),r.emitOuterEvent(a.MESSAGE_READ_BY_PEER,{name:a.MESSAGE_READ_BY_PEER,data:h})})}function li(e){return pe(this,void 0,void 0,function*(){var t;const{message:s,user:n,appStore:o,constants:{OuterConstant:i}}=Po.core,r=o.conversationStore.getConversationMap();if(r.has(e)){const s=null===(t=r.get(e))||void 0===t?void 0:t.userProfile;if(s&&e.startsWith(i.CONV_C2C)){const{avatar:t,nick:n}=s;Po.core.message.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:e,latestAvatar:t,latestNick:n,isSentByMe:!1})}}const{data:a}=(yield n.userProfile.getMyProfile())||{};if(a){const{avatar:t,nick:n}=a;s.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:e,latestAvatar:t,latestNick:n,isSentByMe:!0})}})}function di(e){let t;const{message:s}=Po.core,{conversationID:n,messageID:o}=e;return t=s.messageDataHandler.getLocalMessageList(n).find(e=>e.ID===o),t||(t=s.messageDataHandler.getSparseMessageList(n).find(e=>e.ID===o)),t}function hi(e){return e.map(e=>{const{from:t,to:s,cloudCustomData:n,avatar:o,nick:i,ID:r,clientSequence:a,clientTime:c,messageRandom:u,messageSequence:l,time:d}=e;return{ClientSeq:a,CloudCustomData:n,From_Account:t,From_AccountHeadurl:o,From_AccountNick:i,Id:r,MsgBody:JSON.parse(JSON.stringify(e.transformElementsToServerFormat())),MsgClientTime:c,MsgRandom:u,Random:u,MsgSeq:l,MsgTimeStamp:d,ReceiverId:s,SenderId:t,To_Account:s}})}function pi(e){var t;const{From_Account:s,From_AccountHeadurl:n,From_AccountNick:o,GroupId:i,MsgClientTime:r,ClientSeq:a,To_Account:c,MsgTimeStamp:u,TinyId:l,MsgRandom:d,MsgSeq:h}=e;return{from:s,avatar:n,nick:o,clientTime:r,time:u,tinyID:l,random:d,sequence:h,to:c,groupID:i,clientSequence:a,_elements:null===(t=e.MsgBody)||void 0===t?void 0:t.map(e=>{const{MsgType:t}=e;return Po.core.message.messageFactory.getElementClass(t).parseServerPushElement(e)})}}var gi=new class{constructor(){this._reactionsMap=new Map}init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{MESSAGE_PUSH:n},InnerEventSubType:{MESSAGE_REACTION_UPDATED:o,MESSAGE_REACTION_UPDATED_SYNC:i}}=e;t.registerApi({apiName:"addMessageReaction",context:this}),t.registerApi({apiName:"removeMessageReaction",context:this}),t.registerApi({apiName:"getMessageReactions",context:this}),t.registerApi({apiName:"getAllUserListOfMessageReaction",context:this}),s.subscribeInnerEvent(n,o,this._handleReactionUpdated,this),s.subscribeInnerEvent(n,i,this._handleReactionSync,this)}addMessageReaction(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,ssoLog:n,helper:o}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:i,ID:r,conversationType:a,from:c,to:u,clientSequence:l,random:d,time:h,sequence:p}=e,g=`conversationID:${i} messageID:${r} reactionID:${t}`;try{return this._recordMessageReactedByMe(r,t),a===s.CONV_C2C?yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{from:n,to:o,clientSequence:i,random:r,time:a,reactionID:c}=e,u={From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,Reaction:c,Add_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_add",data:u})})}({from:c,to:u,clientSequence:l,random:d,time:h,reactionID:t},this._core):a===s.CONV_GROUP&&(yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{to:n,reactionID:o,sequence:i}=e,r={GroupId:n,MsgSeq:i,Reaction:o,Add_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_add",data:r})})}({to:u,reactionID:t,sequence:p},this._core)),{code:0,successLog:{message:g}}}catch(_){this._removeMyReactionRecord(r,t);const{errorCode:e}=_||{};throw new o.ChatError({functionName:"addMessageReaction",code:e,moreMessage:g})}})}removeMessageReaction(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,helper:n}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:o,ID:i,conversationType:r,from:a,to:c,clientSequence:u,random:l,time:d,sequence:h}=e,p=`conversationID:${o} messageID:${i} reactionID:${t}`;try{return this._removeMyReactionRecord(i,t),r===s.CONV_C2C?yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{from:n,to:o,clientSequence:i,random:r,time:a,reactionID:c}=e,u={From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,Reaction:c,Del_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_del",data:u})})}({from:a,to:c,clientSequence:u,random:l,time:d,reactionID:t},this._core):r===s.CONV_GROUP&&(yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{to:n,reactionID:o,sequence:i}=e,r={GroupId:n,MsgSeq:i,Reaction:o,Del_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_del",data:r},t)})}({to:c,reactionID:t,sequence:h},this._core)),{code:0,successLog:{message:p}}}catch(g){const{errorCode:e}=g||{};throw new n.ChatError({functionName:"removeMessageReaction",code:e,moreMessage:p})}})}getAllUserListOfMessageReaction(e){return pe(this,void 0,void 0,function*(){this._validateMessageReactionBusinessCapability();const{message:t,reactionID:s,nextSeq:n=0}=e,o=e.count>100?100:e.count,{conversationID:i}=t,{ssoLog:r,helper:a,constants:c}=this._core;try{let e=null;if(e=i.startsWith(c.OuterConstant.CONV_C2C)?yield function(e){return pe(this,void 0,void 0,function*(){const{message:t,nextSeq:s,reactionID:n,count:o}=e,{from:i,to:r,clientSequence:a,random:c,time:u}=t,l={Reaction:n,NextSeq:s,Count:o,From_Account:i,To_Account:r,MsgKey:`${a}_${c}_${u}`};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_iterate",data:l})})}({message:t,reactionID:s,nextSeq:n,count:o}):yield function(e){return pe(this,void 0,void 0,function*(){const{message:t,nextSeq:s,reactionID:n,count:o}=e,{sequence:i,to:r}=t,a={Reaction:n,NextSeq:s,GroupId:r,Count:o,MsgSeq:i};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_iterate",data:a})})}({message:t,reactionID:s,nextSeq:n,count:o}),e){const{Reaction_Account:t,NextSeq:s}=e;return{code:0,data:{nextSeq:s,isCompleted:0===n,userList:yield this._getUserProfileList(t)}}}}catch(u){const{errorCode:e}=u||{};throw new a.ChatError({functionName:"getAllUserListOfMessageReaction",code:e})}})}getMessageReactions(e){return pe(this,void 0,void 0,function*(){const{constants:t}=this._core;this._validateMessageReactionBusinessCapability();const{messageList:s,maxUserCountPerReaction:n=10}=e,o=s[0];let i=null;const r=new Map,{from:a,to:c,conversationType:u}=o,l=this._generateMessageKeyList(s,r);u===t.OuterConstant.CONV_C2C?i=yield function(e){return pe(this,void 0,void 0,function*(){const{from:t,to:s,messageKeyList:n,maxUserCountPerReaction:o}=e,i={From_Account:t,To_Account:s,MsgKeyList:n,Count:o};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_multi_stat",data:i})})}({from:a,to:c,messageKeyList:l,maxUserCountPerReaction:n}):u===t.OuterConstant.CONV_GROUP&&(i=yield function(e){return pe(this,void 0,void 0,function*(){const{groupId:t,messageSequenceList:s,maxUserCountPerReaction:n}=e,o={GroupId:t,MsgSeqList:s,Count:n};return Po.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_multi_stat",data:o})})}({groupId:c,messageSequenceList:l,maxUserCountPerReaction:n}));const{Results:d=[]}=i||{},h=this._extractUserIDsFromReactionResults(d),p=yield this._getUserProfileMap(h);return{code:0,data:{resultList:d.map(e=>{const{ReactionList:t,MsgSeq:s,MsgKey:n}=e;return{messageID:this._generateMessageID({messageSequence:s,messageKey:n,messageIDMap:r}),reactionList:t.map(e=>{const{Reaction:t,Count:s,Reaction_Account:n,ReactedByMe:o}=e;return{reactionID:t,totalUserCount:s,partialUserList:this._generatePartialUserInfo({userIDList:n,userProfileMap:p}),reactedByMyself:1===o}})}})}}})}dispose(){this._reactionsMap.clear()}_extractUserIDsFromReactionResults(e){const t=[];return null==e||e.forEach(e=>{const{ReactionList:s=[]}=e;s.forEach(e=>{e.Reaction_Account&&t.push(...e.Reaction_Account)})}),t}_getUserProfileList(e){return pe(this,void 0,void 0,function*(){var t;try{const s=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:e});return s?s.data:[]}catch(s){return[]}})}_getUserProfileMap(e){return pe(this,void 0,void 0,function*(){const t=new Map;return(yield this._getUserProfileList(e)).forEach(e=>{const{nick:s,avatar:n,userID:o}=e;t.set(o,{nick:s,avatar:n,userID:o})}),t})}_recordMessageReactedByMe(e,t){const s=`${e}-${t}`;this._reactionsMap.has(s)?this._reactionsMap.get(s).reactedByMe=!0:this._reactionsMap.set(s,{reactedByMe:!0})}_removeMyReactionRecord(e,t){const s=`${e}-${t}`;this._reactionsMap.has(s)&&(this._reactionsMap.get(s).reactedByMe=!1)}_recordMessageReactionInfo(e){const{messageID:t,reactionID:s,reactionInfo:n}=e,o=`${t}-${s}`,i=this._reactionsMap.get(o)||{};this._reactionsMap.set(o,Object.assign(Object.assign({},i),n))}_validateMessageReactionBusinessCapability(){const{helper:e,constants:t}=this._core;if(!e.checkBusinessCapabilityBits(Uo))throw new e.ChatError({functionName:"addMessageReaction",code:t.ERROR_CODE.NO_USE,replacement1:"addMessageReaction"})}_handleReactionUpdated(e){const{MsgReactionNotifyList:t}=e,{notificationCenter:s,constants:n}=this._core;t.forEach(e=>pe(this,void 0,void 0,function*(){const{C2CMsgInfo:t,GroupMsgInfo:o,MsgReactionSummary:i}=e,{TinyId:r,MsgClientTime:a,MsgRandom:c}=Object.assign(Object.assign({},t),o),u=`${r}-${a}-${c}`,l=this._extractUserIDsFromReactionResults([{ReactionList:i}]),d=yield this._getUserProfileMap(l),h=i.map(e=>{var t;const{Reaction:s,Reaction_Account:n}=e,o=this._generatePartialUserInfo({userIDList:n,userProfileMap:d}),i=n?e.Count:0,r=(null===(t=this._reactionsMap.get(`${u}-${s}`))||void 0===t?void 0:t.reactedByMe)||!1;return this._recordMessageReactionInfo({messageID:u,reactionID:s,reactionInfo:{reactionID:s,totalUserCount:i,partialUserList:o}}),{reactionID:s,totalUserCount:i,partialUserList:o,reactedByMyself:r}});s.emitOuterEvent(n.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:n.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:u,reactionList:h}})}))}_handleReactionSync(e){var t;const{notificationCenter:s,constants:n}=this._core,{C2CMsgInfo:o={},GroupMsgInfo:i={},Reaction:r,OperateType:a}=e.MsgReactionNotify,{TinyId:c="",MsgClientTime:u=0,MsgRandom:l=0}=Object.assign(Object.assign({},o),i),d=`${c}-${u}-${l}`,h=`${d}-${r}`;if(1===a?this._recordMessageReactedByMe(d,r):this._removeMyReactionRecord(d,r),null===(t=this._reactionsMap.get(h))||void 0===t?void 0:t.reactionID){const e=this._reactionsMap.get(h);e.reactedByMyself=1===a,s.emitOuterEvent(n.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:n.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:d,reactionList:[e]}})}}_generatePartialUserInfo({userIDList:e,userProfileMap:t}){const s=[];return null==e||e.forEach(e=>{t.has(e)&&s.push(t.get(e))}),s}_generateMessageID(e){const{messageSequence:t,messageKey:s,messageIDMap:n}=e;return s?n.get(s):n.get(t)}_generateMessageKeyList(e,t){const{constants:s}=this._core,n=e[0],{conversationType:o}=n;let i=[];return o===s.OuterConstant.CONV_C2C?i=e.map(e=>{const{clientSequence:s,random:n,time:o,ID:i}=e,r=`${s}_${n}_${o}`;return t.set(r,i),r}):o===s.OuterConstant.CONV_GROUP&&(i=e.map(e=>{const{ID:s,sequence:n}=e;return t.set(n,s),n})),i}},_i=new class{init(e){this._core=e;const{helper:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:n,GROUP_MESSAGE_READ_RECEIPT:o},notificationCenter:i}=e;t.registerApi({apiName:"sendMessageReadReceipt",context:this}),t.registerApi({apiName:"getMessageReadReceiptList",context:this}),t.registerApi({apiName:"getGroupMessageReadMemberList",context:this}),i.subscribeInnerEvent(s,n,this._handleC2CMessageReadReceipt,this),i.subscribeInnerEvent(s,o,this._handleGroupMessageReadReceipt,this)}sendMessageReadReceipt(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=this._core,n=this._filterValidMessageSendByOther(e);if(0===n.length)throw new t.ChatError({code:s.ERROR_CODE.READ_RECEIPT_MSG_LIST_EMPTY});try{const{conversationType:e}=n[0];return e===s.OuterConstant.CONV_C2C?yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Po.core,n={Peer_Account:e[0].conversationID.replace(s.OuterConstant.CONV_C2C,""),C2CMsgInfo:e.map(e=>{const{from:t,to:s,sequence:n,random:o,time:i,clientTime:r}=e;return{From_Account:t,To_Account:s,MsgSeq:n,MsgRandom:o,MsgTime:i,MsgClientTime:r}})};return t.buildAndSendPacket({servcmd:"openim.c2c_msg_read_receipt",data:n})})}(n):yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Po.core,n={GroupId:e[0].conversationID.replace(s.OuterConstant.CONV_GROUP,""),MsgSeqList:e.map(e=>({MsgSeq:e.sequence}))};return t.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_receipt",data:n})})}(n),{code:0,data:{}}}catch(o){const{errorCode:e,errorInfo:s}=o;throw new t.ChatError({code:e,message:s})}})}getMessageReadReceiptList(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=this._core;try{const{conversationType:t}=e[0];if(t===s.OuterConstant.CONV_GROUP){const t=this._filterValidMessageSendByMe(e);if((null==t?void 0:t.length)>0){const s=yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Po.core,n={GroupId:e[0].conversationID.replace(s.OuterConstant.CONV_GROUP,""),MsgSeqList:e.map(e=>({MsgSeq:e.sequence}))};return t.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt",data:n})})}(t),{GroupMsgReceiptList:n}=s||{};this._updateGroupMessagesReadReceiptInfo({messageList:e,readReceiptList:n})}}return{code:0,data:{messageList:e}}}catch(n){const{errorCode:e,errorInfo:s}=n;throw new t.ChatError({code:e,message:s})}})}getGroupMessageReadMemberList(e){return pe(this,void 0,void 0,function*(){const{constants:t,common:s}=this._core,{message:n,filter:o=zo.READ,cursor:i=""}=e,{conversationID:r,sequence:a,ID:c}=n,u=r.replace(t.OuterConstant.CONV_GROUP,""),l=e.count>=100?100:e.count;try{const e=yield function(e){return pe(this,void 0,void 0,function*(){const{sequence:t,groupID:s,filter:n,cursor:o,count:i}=e,r={MsgSeq:t,GroupId:s,Filter:n,Cursor:o,Num:i};return Po.core.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt_detail",data:r})})}({groupID:u,sequence:a,filter:o,cursor:i,count:l});if(e){const{Cursor:t,IsFinish:s,UnreadList:n,ReadList:i}=e,r={cursor:t,isCompleted:1===s,messageID:c,unreadUserIDList:[],readUserIDList:[]};return o===zo.READ?r.readUserIDList=i.map(e=>e.Read_Account):o===zo.UNREAD&&(r.unreadUserIDList=n.map(e=>e.Unread_Account)),{code:0,data:r}}}catch(d){const{errorCode:e,errorInfo:t}=d;throw new s.ChatError({code:e,message:t})}})}_handleC2CMessageReadReceipt(e){const t=[],{constants:s,helper:n}=this._core,{C2cMsgInfo:o,PeerReadTime:i,Peer_Account:r}=e;if(n.isEmpty(o))return;const a=`${s.OuterConstant.CONV_C2C}${r}`;null==o||o.forEach(e=>{const{TinyId:s,MsgClientTime:n,MsgRandom:o}=e,c=`${s}-${n}-${o}`,u=di({conversationID:a,messageID:c});u&&!u.readReceiptInfo.isPeerRead&&(u.readReceiptInfo.isPeerRead=!0,u.readReceiptInfo.timestamp=i,t.push({userID:r,messageID:c,isPeerRead:!0,timestamp:i}))}),this._emitReadReceiptEventIfNeed(t)}_updateGroupMessagesReadReceiptInfo(e){const{messageList:t,readReceiptList:s}=e,n=new Map;t.forEach(e=>{n.set(e.sequence,e)}),null==s||s.forEach(e=>{if(0===e.Code){const{MsgSeq:t,ReadNum:s,UnreadNum:o}=e,i=n.get(t);i&&(i.readReceiptInfo.readCount=s,i.readReceiptInfo.unreadCount=o)}})}_handleGroupMessageReadReceipt(e){const t=[],{constants:s}=this._core,{GroupTips:n}=e;n.forEach(e=>{const{MsgBody:{GroupMsgReceiptList:n},GroupInfo:{GroupId:o}}=e,i=`${s.OuterConstant.CONV_GROUP}${o}`;null==n||n.forEach(e=>{const{TinyId:s,MsgClientTime:n,MsgRandom:r,ReadNum:a,UnreadNum:c}=e,u=`${s}-${n}-${r}`,l=di({conversationID:i,messageID:u}),d={groupID:o,messageID:u,readCount:0,unreadCount:0};l&&("number"==typeof a&&(l.readReceiptInfo.readCount=a,d.readCount=a),"number"==typeof c&&(l.readReceiptInfo.unreadCount=c,d.unreadCount=c),t.push(d))})}),this._emitReadReceiptEventIfNeed(t)}_emitReadReceiptEventIfNeed(e){const{notificationCenter:t,OuterEvent:s}=this._core;e.length>0&&t.emitOuterEvent(s.MESSAGE_READ_RECEIPT_RECEIVED,{name:s.MESSAGE_READ_RECEIPT_RECEIVED,data:e})}_filterValidMessageSendByOther(e){return this._filterNeedReadReceiptMessages(e).filter(e=>{const{from:t}=e;return t!==this._core.common.getCurrentUserID()})}_filterValidMessageSendByMe(e){const{OuterConstant:t}=this._core.constants;return this._filterNeedReadReceiptMessages(e).filter(e=>{const{from:s,status:n}=e;return s===this._core.common.getCurrentUserID()&&n===t.MessageStatus.SUCCESS})}_filterNeedReadReceiptMessages(e){return e.filter(e=>!0===e.needReadReceipt)}dispose(){const{InnerEvent:{MESSAGE_PUSH:e},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:t,GROUP_MESSAGE_READ_RECEIPT:s},notificationCenter:n}=this._core;n.unSubscribeInnerEvent(e,t,this._handleC2CMessageReadReceipt,this),n.unSubscribeInnerEvent(e,s,this._handleGroupMessageReadReceipt,this)}};function mi(e,t,s){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:n}}=Po.core,{from:o,to:i,clientSequence:r,random:a,time:c}=e;return n({servcmd:"openim_msg_ext_http_svc.set_key_values",data:{From_Account:o,To_Account:i,MsgKey:`${r}_${a}_${c}`,OperateType:s,ExtensionList:t}})})}function fi(e,t,s){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:n}}=Po.core,{to:o,sequence:i}=e;return n({servcmd:"openim_msg_ext_http_svc.group_set_key_values",data:{GroupId:o,MsgSeq:i,OperateType:s,ExtensionList:t}})})}var vi=new class{constructor(){this._messageExtensionsMap=new Map,this._extensionsLatestSequenceMap=new Map,this._completedFetchExtensions=new Set}init(e){this._core=e;const{notificationCenter:t,helper:{registerApi:s},InnerEvent:{MESSAGE_PUSH:n,LOGOUT:o},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:i}}=e;s({apiName:"setMessageExtensions",context:this}),s({apiName:"getMessageExtensions",context:this}),s({apiName:"deleteMessageExtensions",context:this}),t.subscribeInnerEvent(n,i,this._handleMessageExtensionsNotify,this),t.subscribeInnerEvent(o,this.reset,this)}setMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("setMessageExtensions");const{constants:{OuterConstant:s},ssoLog:n}=this._core,{ID:o,conversationID:i,sequence:r,time:a,conversationType:c}=e;let u=t;t.length>20&&(u=t.slice(0,20),n.warn("setMessageExtensions","the length of extensions cannot exceed 20"));const l=this._generateServerExtensions(e,u),d=`convID:${i} messageID:${o} sequence:${r} time:${a} count:${u.length}`;try{let t;if(c===s.CONV_C2C?t=yield mi(e,l,Zo):c===s.CONV_GROUP&&(t=yield fi(e,l,Zo)),t){const{resultList:s,successCount:n,failureCount:o}=this._handleModifyMessageExtensions(e,t);return{code:0,data:{extensions:s},successLog:{message:`${d} successCount:${n} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(h){const{errorCode:e}=h;throw new this._core.helper.ChatError({functionName:"setMessageExtensions",code:e,moreMessage:d})}})}getMessageExtensions(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t}}=this._core;this._validateMessageExtensionBusinessCapability("getMessageExtensions");const{conversationID:s,ID:n,sequence:o,time:i}=e,r=`convID:${s} messageID:${n} sequence:${o} time:${i}`;try{let s;this._completedFetchExtensions.has(n)&&(s=this._extensionsLatestSequenceMap.get(n));const o=yield this._fetchMessageExtensions(e,s);return t(s)&&o.length>1&&this._completedFetchExtensions.add(n),{code:0,data:{extensions:o},successLog:{message:r}}}catch(a){const{errorCode:e,errorInfo:t=""}=a||{};throw new this._core.common.ChatError({code:e,message:t,moreMessage:r})}})}deleteMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("deleteMessageExtensions");const{utils:{isEmpty:s},constants:{OuterConstant:n}}=this._core,{conversationType:o,conversationID:i,sequence:r,ID:a,time:c}=e;let u=Xo;const l=[];s(t)||(u=Jo,null==t||t.forEach(e=>{l.push({key:e,value:"",seq:0})}));const d=`convID:${i} messageID:${a} sequence:${r} time:${c} operateType:${u}`,h=this._generateServerExtensions(e,l);try{let t;if(o===n.CONV_C2C?t=yield mi(e,h,u):o===n.CONV_GROUP&&(t=yield fi(e,h,u)),t){const{resultList:s,successCount:n,failureCount:o}=this._handleModifyMessageExtensions(e,t);return{code:0,data:{extensions:s},successLog:{message:`${d}successCount:${n} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(p){const{errorCode:e}=p;throw new this._core.helper.ChatError({functionName:"deleteMessageExtensions",code:e,moreMessage:d})}})}reset(){this._messageExtensionsMap.clear(),this._extensionsLatestSequenceMap.clear(),this._completedFetchExtensions.clear()}dispose(){this.reset();const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,LOGOUT:s},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:n}}=this._core;e.unSubscribeInnerEvent(t,n,this._handleMessageExtensionsNotify,this),e.subscribeInnerEvent(s,this.reset,this)}_handleModifyMessageExtensions(e,t){const{ID:s}=e,{Seq:n}=t,o=t.ExtensionList||[],i=[];let r=0,a=0,c=[];return o.forEach(e=>{const{ErrorCode:t,Extension:s}=e,{Key:n,Value:o,Seq:u}=s;i.push({code:t,key:n,value:o}),0===t?r++:a++,c.push({key:n,value:o,seq:u})}),this._extensionsLatestSequenceMap.set(s,n),c.length>0&&this._updateLocalExtensions(e.ID,c),{resultList:i,successCount:r,failureCount:a}}_updateLocalExtensions(e,t){this._messageExtensionsMap.has(e)||this._messageExtensionsMap.set(e,new Map);const s=this._messageExtensionsMap.get(e);null==t||t.forEach(e=>{const{key:t,seq:n,value:o=""}=e;null==s||s.set(t,{value:o,seq:n})})}_fetchMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){const{constants:{OuterConstant:s},utils:{isEmpty:n}}=this._core;try{let o;const{conversationType:i,ID:r}=e;if(i===s.CONV_C2C?o=yield function(e,t){const{common:{buildAndSendPacket:s}}=Po.core,{from:n,to:o,clientSequence:i,random:r,time:a}=e;return s({servcmd:"openim_msg_ext_http_svc.get_key_values",data:{From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,StartSeq:t}})}(e,t):i===s.CONV_GROUP&&(o=yield function(e,t){const{common:{buildAndSendPacket:s}}=Po.core,{to:n,sequence:o}=e;return s({servcmd:"openim_msg_ext_http_svc.group_get_key_values",data:{GroupId:n,MsgSeq:o,StartSeq:t}})}(e,t)),o){const{LatestSeq:t,ClearSeq:s,CompleteFlag:i}=o,a=(o.ExtensionList||[]).map(e=>({key:e.Key,value:e.Value,seq:e.Seq}));if(this._updateLocalExtensions(r,a),this._clearLocationExtensions(r,s),this._extensionsLatestSequenceMap.set(r,t),1!==i){const t=a[a.length-1].seq+1;return this._fetchMessageExtensions(e,t)}const c=[];if(this._messageExtensionsMap.has(r)){const e=this._messageExtensionsMap.get(r);null==e||e.forEach((e,t)=>{const{value:s}=e;n(s)||c.push({key:t,value:s})})}return c}}catch(o){throw o}})}_clearLocationExtensions(e,t){if(!(t<=0)&&this._messageExtensionsMap.has(e)){const s=this._messageExtensionsMap.get(e);null==s||s.forEach((e,n)=>{e.seq<=t&&s.delete(n)})}}_generateServerExtensions(e,t){const{ID:s}=e;if(this._messageExtensionsMap.has(s)){const e=this._messageExtensionsMap.get(s);return t.map(t=>{var s;const{key:n,value:o}=t;let i=0;return(null==e?void 0:e.has(n))&&(i=null===(s=e.get(n))||void 0===s?void 0:s.seq),{Key:n,Value:o,Seq:i}})}return t.map(e=>({Key:e.key,Value:e.value,Seq:0}))}_validateMessageExtensionBusinessCapability(e){const{helper:t,constants:s}=this._core;if(!t.checkBusinessCapabilityBits(Fo))throw new t.ChatError({functionName:e,code:s.ERROR_CODE.NO_USE,replacement1:e})}_handleMessageExtensionsNotify(e){const{SetKVInfo:t,DeleteKVInfo:s,ClearKVInfo:n,MsgOptType:o,TinyId:i,MsgLastSeq:r,ExtensionC2cMsgInfo:a,ExtensionGroupMsgInfo:c}=(null==e?void 0:e.MsgExtensionNotify)||{},u=a||c||{},{MsgClientTime:l,MsgRandom:d}=u,h=`${i}-${l}-${d}`;this._extensionsLatestSequenceMap.set(h,r),o===Zo?this._handleMessageExtensionsUpdated({messageID:h,updateMessageExtensionsInfo:t}):o===Jo?this._handleMessageExtensionsDeleted({messageID:h,deleteMessageExtensionsInfo:s}):o===Xo&&this._handleMessageExtensionsCleared({messageID:h,clearMessageExtensionsInfo:n})}_handleMessageExtensionsUpdated(e){const{notificationCenter:t,OuterEvent:s}=this._core,{messageID:n,updateMessageExtensionsInfo:o=[]}=e,i=[];o.forEach(e=>{const{MsgKeyValue:t=[]}=e,s=t.map(e=>(i.push({key:e.Key,value:e.Value}),{key:e.Key,value:e.Value,seq:e.Seq}));this._updateLocalExtensions(n,s)}),t.emitOuterEvent(s.MESSAGE_EXTENSIONS_UPDATED,{name:s.MESSAGE_EXTENSIONS_UPDATED,data:{messageID:n,extensions:i}})}_handleMessageExtensionsDeleted(e){const{notificationCenter:t,OuterEvent:s}=this._core,{messageID:n,deleteMessageExtensionsInfo:o=[]}=e,i=[];o.forEach(e=>{const{MsgKeyValue:t=[]}=e,s=t.map(e=>(i.push(e.Key),{key:e.Key,seq:e.Seq}));this._updateLocalExtensions(n,s)}),t.emitOuterEvent(s.MESSAGE_EXTENSIONS_DELETED,{name:s.MESSAGE_EXTENSIONS_DELETED,data:{messageID:n,keyList:i}})}_handleMessageExtensionsCleared(e){const{notificationCenter:t,OuterEvent:{MESSAGE_EXTENSIONS_DELETED:s},utils:{isEmpty:n}}=this._core,{messageID:o,clearMessageExtensionsInfo:i=[]}=e,r=[];i.forEach(e=>{const{ClearMsgSeq:t}=e;this._messageExtensionsMap.has(o)&&(this._messageExtensionsMap.get(o)||[]).forEach((e,s)=>{e.seq<=t&&!n(e.value)&&r.push(s)}),this._clearLocationExtensions(o,t)}),t.emitOuterEvent(s,{name:s,data:{messageID:o,keyList:r}})}};const Ii={key:"message",required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const{constants:{OuterConstant:t}}=Po.core;return e.status!==t.MessageStatus.SUCCESS?"message is not success":!0===e.isSupportExtension||"message is not support extension"}},Ei={setMessageExtensions:[Ii,{key:"extensions",required:!0,rules:["array"],allowEmpty:!1}],getMessageExtensions:[Ii],deleteMessageExtensions:[Ii]},Si=Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:[{required:!0,rules:["array"],allowEmpty:!1}],revokeMessage:[{required:!0,rules:["object"],allowEmpty:!1}],resendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],getMessageList:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},nextReqMessageID:{required:!1,rules:["string"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},getMessageListHopping:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},sequence:{required:!1,rules:["number"],allowEmpty:!0},direction:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},createTextAtMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>"GROUP"===e||"conversationType should be GROUP."},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const t="string"==typeof(null==(s=e)?void 0:s.text)&&("string"!=typeof s.text||0!==(null===(n=null==s?void 0:s.text)||void 0===n?void 0:n.length))||"payload.text is invalid.";var s,n;return!0!==t?t:!((null==e?void 0:e.atUserList)&&!Array.isArray(e.atUserList))||"atUserList should be an array or undefind."}}},findMessage:[{required:!0,rules:["string"],allowEmpty:!1}],translateText:{sourceTextList:{required:!0,rules:["array"],allowEmpty:!1},sourceLanguage:{required:!0,rules:["string"],allowEmpty:!1},targetLanguage:{required:!0,rules:["string"],allowEmpty:!1}},createForwardMessage:{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}},createLocationMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const{utils:{isString:t,isNumber:s}}=Po.core;return t(null==e?void 0:e.description)?s(null==e?void 0:e.longitude)?!!s(null==e?void 0:e.latitude)||"payload.latitude must be a number.":"payload.longitude must be a number.":"payload.description must be a string."}}}},{addMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],removeMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],getMessageReactions:{messageList:{required:!0,rules:["array"],allowEmpty:!1},maxUserCountPerReaction:{required:!1,rules:["number"],allowEmpty:!0,customValidator:e=>"number"!=typeof e?"maxUserCountPerReaction is invalid.":!(e<0||e>10)||"maxUserCountPerReaction should between [0, 10]."}},getAllUserListOfMessageReaction:{message:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>"success"===e.status||"message is invalid."},reactionID:{required:!0,rules:["string"],allowEmpty:!1},nextSeq:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}}}),{sendMessageReadReceipt:[{required:!0,rules:["array"],allowEmpty:!1}],getMessageReadReceiptList:[{required:!0,rules:["array"],allowEmpty:!1}],getGroupMessageReadMemberList:{message:{required:!0,rules:["object"],allowEmpty:!1},filter:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0},cursor:{required:!1,rules:["string"],allowEmpty:!0}}}),Ei),{pinGroupMessage:{groupID:{required:!0,rules:["string"],allowEmpty:!1},message:{required:!0,rules:["object"],allowEmpty:!1},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},getPinnedGroupMessageList:[{key:"groupID",required:!0,rules:["string"],allowEmpty:!1}]}),yi=Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:!0,revokeMessage:!0,resendMessage:!0,getMessageList:!0,getMessageListHopping:!0,createTextAtMessage:!0,findMessage:!0,translateText:!0,createForwardMessage:!0,createLocationMessage:!0},{addMessageReaction:!0,removeMessageReaction:!0,getMessageReactions:!0,getAllUserListOfMessageReaction:!0}),{sendMessageReadReceipt:!0,getMessageReadReceiptList:!0,getGroupMessageReadMemberList:!0}),{setMessageExtensions:!0,getMessageExtensions:!0,deleteMessageExtensions:!0}),{pinGroupMessage:!0,getPinnedGroupMessageList:!0});class Ci{constructor(e){this._core=e}deleteMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,messageIdentifiers:s}=e,n={From_Account:this._core.common.getCurrentUserID(),To_Account:t,MsgKeyList:s};return this._core.common.buildAndSendPacket({servcmd:"openim.delete_c2c_msg_ramble",data:n})})}revokeMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,from:s,sequence:n,time:o,random:i}=e,r={MsgInfo:{From_Account:s,To_Account:t,MsgSeq:n,MsgRandom:i,MsgTimeStamp:o}};return this._core.common.buildAndSendPacket({servcmd:"openim.msgwithdraw",data:r})})}}class Mi{constructor(e){this._core=e}deleteMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,messageIdentifiers:s}=e,n={GroupId:t,Deleter_Account:this._core.common.getCurrentUserID(),Seqs:s};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_ramble_msg_by_seq",data:n})})}revokeMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,sequence:s}=e,n={GroupId:t,MsgSeqList:[{MsgSeq:s}]};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_recall",data:n})})}}class Ai{constructor(e){this._core=e}generateRevokeMessage(e){const{conversationID:t,sequence:s,random:n,tinyID:o,clientTime:i,revokeReason:r,revoker:a}=e;let c={};const{messageDataHandler:u}=this._core.message;return c=u.revokeMessage({conversationID:t,sequence:s,random:n,revoker:a}),c||(c={conversationID:t,sequence:s},o&&i&&n&&(c.ID=`${o}-${i}-${n}`)),c.revoker=a,c.revokeReason=r,c.revokerInfo={userID:a,nick:"",avatar:""},c}updateRevokerInfo(e){return pe(this,void 0,void 0,function*(){const t=e.map(e=>e.revoker);try{const s=yield this._fetchUserInfos(t);s&&e.forEach(e=>{const{revoker:t}=e;s[t]&&(e.revokerInfo.nick=s[t].nick||"",e.revokerInfo.avatar=s[t].avatar||"",e.revokerInfo.userID=t)})}catch(s){console.debug(s)}})}_fetchUserInfos(e){return pe(this,void 0,void 0,function*(){var t,s;const n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:e});return(null==n?void 0:n.data)?null===(s=n.data)||void 0===s?void 0:s.reduce((e,{userID:t,nick:s,avatar:n})=>(e[t]={nick:s||"",avatar:n||""},e),{}):null})}}var bi=new class{constructor(){this._core=null,this._c2cMessageAction=null,this._groupMessageAction=null}init(e){this._core=e,this._groupMessageAction=new Mi(e),this._c2cMessageAction=new Ci(e),this._messageHelper=new Ai(e);const{helper:t}=e;t.registerApi({apiName:"deleteMessage",context:this}),t.registerApi({apiName:"revokeMessage",context:this}),t.registerApi({apiName:"resendMessage",context:this}),t.registerApi({apiName:"findMessage",context:this})}deleteMessage(e){return pe(this,void 0,void 0,function*(){let t=[],s=[];const{conversationID:n,conversationType:o}=e[0],i=n.replace(o,"");if("@TIM#SYSTEM"===o)throw new this._core.helper.ChatError({code:oi});if(e.forEach(e=>{const{conversationID:i,conversationType:r,status:a,_onlineOnlyFlag:c,sequence:u,random:l,time:d}=e||{};if("success"===a&&i===n&&r===o){if(!c){const e="C2C"===r?`${u}_${l}_${d}`:String(u);t.push(e)}s.push(e)}}),0===t.length)return this._handleDeleteMessageSuccess(s),{code:0,data:{messageList:s}};t.length>30&&(t=t.slice(0,30),s=s.slice(0,30));try{return"C2C"===o?yield this._c2cMessageAction.deleteMessage({to:i,messageIdentifiers:t}):yield this._groupMessageAction.deleteMessage({to:i,messageIdentifiers:t}),this._handleDeleteMessageSuccess(s),{code:0,data:{messageList:s}}}catch(r){const{errorCode:e}=r;throw new this._core.helper.ChatError({functionName:"deleteMessage",code:e})}})}revokeMessage(e){return pe(this,void 0,void 0,function*(){var t;const{conversationType:s,isRevoked:n,ID:o,type:i,from:r,to:a}=e;let c=null;const u=`type:${i} from:${r} to:${a} ID:${o}`;if("@TIM#SYSTEM"===s)throw new this._core.helper.ChatError({message:"system message cannot be revoked"});if(n)throw new this._core.helper.ChatError({message:"message has been revoked",moreMessage:u});try{if(c="C2C"===s?yield this._c2cMessageAction.revokeMessage(e):yield this._groupMessageAction.revokeMessage(e),c){const{RecallRetList:s}=c,n=(null===(t=null==s?void 0:s[0])||void 0===t?void 0:t.RetCode)||0;if(0!==n)throw new this._core.helper.ChatError({code:n,moreMessage:u});return e.isRevoked=!0,yield this._handleRevokeMessageSuccess(e),{code:0,data:{message:e},successLog:{message:u}}}}catch(l){const{errorCode:e}=l;throw new this._core.helper.ChatError({functionName:"revokeMessage",code:e,moreMessage:u})}})}resendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n;return e.isResend=!0,e.status="unSend",null===(n=null===(s=this._core)||void 0===s?void 0:s.apiMap)||void 0===n?void 0:n.sendMessage(e,t)})}findMessage(e){return this._core.message.messageDataHandler.findMessage(e)}_handleDeleteMessageSuccess(e){if(0===e.length)return;const{message:{messageDataHandler:t},common:{isTopic:s},notificationCenter:n,InnerEvent:o}=this._core;e.forEach(e=>{e.isDeleted=!0;const s=t.getLocalMessageList(e.conversationID);null==s||s.forEach(t=>{t.ID===e.ID&&(t.isDeleted=!0)})});const{conversationID:i=""}=e[0];s(i)?n.emitInnerEvent(o.TOPIC_MESSAGE_DELETED,i):n.emitInnerEvent(o.MESSAGE_DELETED,i)}_handleRevokeMessageSuccess(e){return pe(this,void 0,void 0,function*(){var t;const s=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,{conversationID:n,sequence:o,random:i}=e;this._core.message.messageDataHandler.revokeMessage({conversationID:n,sequence:o,random:i,revoker:s}),yield this._messageHelper.updateRevokerInfo([e])})}};class Ti{static parseServerPushElement(e){const{MsgContent:t={}}=e,{Index:s,Data:n}=t;return new Ti({index:s,data:n})}constructor(e){this.type=ko.MSG_FACE;const{index:t,data:s}=e;this.content={index:t,data:s}}validateBeforeSend(){var e,t;return"number"==typeof(null===(e=this.content)||void 0===e?void 0:e.index)&&"string"==typeof(null===(t=this.content)||void 0===t?void 0:t.data)?{isValid:!0}:{isValid:!1,error:{message:"content is invalid"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{index:n,data:o}=s;return{MsgType:this.type,MsgContent:{Index:n,Data:o}}}}class Oi{static parseServerPushElement(e){const{MsgContent:t={}}=e,{Desc:s,Longitude:n,Latitude:o}=t;return new Oi({description:s,longitude:n,latitude:o})}constructor(e){this.type=ko.MSG_LOCATION;const{description:t,longitude:s,latitude:n}=e;this.content={description:t,longitude:s,latitude:n}}validateBeforeSend(){return{isValid:!0}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{description:n,longitude:o,latitude:i}=s;return{MsgType:this.type,MsgContent:{Desc:n,Longitude:o,Latitude:i}}}}var wi=new class{init(e){this._core=e,e.message.messageFactory.registerElementClass(ko.MSG_FACE,Ti),e.message.messageFactory.registerElementClass(ko.MSG_LOCATION,Oi),e.helper.registerApi({apiName:"createFaceMessage",context:this}),e.helper.registerApi({apiName:"createTextAtMessage",context:this}),e.helper.registerApi({apiName:"createForwardMessage",context:this}),e.helper.registerApi({apiName:"createLocationMessage",context:this})}createFaceMessage(e){if(!e)return null;const{index:t,data:s}=(null==e?void 0:e.payload)||{},n=new Ti({index:t,data:s}),o=this._core.common.getCurrentUserID(),i=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:o}));return i.setElement(n),i}createTextAtMessage(e){const{atUserList:t}=(null==e?void 0:e.payload)||{},s=this._core.apiMap.createTextMessage(e),{OuterConstant:n}=this._core;if(!s)return null;if(Array.isArray(t)){const e=[],o=[];t.forEach(t=>{t!==n.MSG_AT_ALL?(e.push({GroupAtAllFlag:xo,GroupAt_Account:t}),o.push(t)):(e.push({GroupAtAllFlag:$o}),o.push(n.MSG_AT_ALL))}),s._groupAtInfoList=e,s.atUserList=o}return s}createForwardMessage(e){const{helper:t,OuterConstant:s}=this._core,{to:n,conversationType:o,priority:i,payload:r,needReadReceipt:a,receiverList:c,cloudCustomData:u="",isSupportExtension:l=!1}=e;if(!Array.isArray(r._elements))throw new t.ChatError({functionName:"createForwardMessage",code:2454});if(r.type===s.MSG_GRP_TIP)throw new t.ChatError({functionName:"createForwardMessage",code:2453});const d=this._core.common.getCurrentUserID(),h=this._core.message.messageFactory.createMessage({to:n,from:d,conversationType:o,isPlaceMessage:0,priority:i,payload:r,needReadReceipt:a,isSupportExtension:l,cloudCustomData:u,receiverList:c});return h.setRelayFlag(!0),h.setElement(r._elements[0]),h}createLocationMessage(e){if(!e)return null;const{description:t,longitude:s,latitude:n}=(null==e?void 0:e.payload)||{},o=new Oi({description:t,longitude:s,latitude:n}),i=this._core.common.getCurrentUserID(),r=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:i}));return r.setElement(o),r}};let Di=class{init(e){this._messageHelper=new Ai(e),this._core=e;const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{C2C_REVOKED_MESSAGE:n},helper:{registerWorkflowStep:o},constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:r}}=e;t.subscribeInnerEvent(s,n,this._handleC2CNotifyMessage,this),o(i.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,this._handleC2CRevokeMessagesFromUnreadMessageSync,this)}_handleC2CNotifyMessage(e){const{C2cNotifyMsgArray:t}=e;null==t||t.forEach(e=>{Object.keys(e).includes("WithdrawC2cMsgNotify")&&this._handleC2CRevokeMessage(e)})}_handleC2CRevokeMessage(e){return pe(this,void 0,void 0,function*(){try{const{WithdrawC2cMsgNotify:{C2cWithdrawInfoArray:t}}=e;yield this._parseAndEmitC2CRevokedMessages(t)}catch(t){console.debug(t)}})}_parseAndEmitC2CRevokedMessages(e){return pe(this,void 0,void 0,function*(){const t=[],{notificationCenter:s,OuterEvent:n,common:{getCurrentUserID:o}}=this._core;e.forEach(e=>{var s;const{MsgRand:n,MsgSeq:i,To_Account:r,From_Account:a,RevokerInfo:{Revoker_Account:c,Revoke_Reason:u}}=e,l=o()===a?`C2C${r}`:`C2C${a}`,d=(null===(s=null==e?void 0:e.RevokerInfo)||void 0===s?void 0:s.Reason)||u,h=this._messageHelper.generateRevokeMessage({conversationID:l,sequence:i,random:n,revoker:c,revokeReason:d});t.push(h)}),t.length>0&&(yield this._messageHelper.updateRevokerInfo(t),s.emitOuterEvent(n.MESSAGE_REVOKED,{name:n.MESSAGE_REVOKED,data:t}))})}_handleC2CRevokeMessagesFromUnreadMessageSync(e){return pe(this,void 0,void 0,function*(){const{revokedMessageList:t}=e.result;yield this._parseAndEmitC2CRevokedMessages(t)})}dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{C2C_REVOKED_MESSAGE:s}}=this._core;e.unSubscribeInnerEvent(t,s,this._handleC2CNotifyMessage,this)}},Ri=class{init(e){this._messageHelper=new Ai(e),this._core=e;const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{GROUP_MESSAGE_REVOKED:n}}=e;t.subscribeInnerEvent(s,n,this._handleGroupNotifyMessage,this)}_handleGroupNotifyMessage(e){const{GroupTips:t}=e;null==t||t.forEach(e=>{var t;Array.isArray(null===(t=null==e?void 0:e.MsgBody)||void 0===t?void 0:t.GroupWithdrawInfoArray)&&this._handleGroupRevokeMessage(e)})}_handleGroupRevokeMessage(e){return pe(this,void 0,void 0,function*(){try{const{RevokerInfo:t,MsgBody:{GroupWithdrawInfoArray:s},GroupInfo:n}=e,o=[],i=[],{notificationCenter:r,OuterEvent:a,utils:{isEmpty:c},common:{isCommunity:u}}=this._core;let l=!1;n&&(l=u({groupID:n.GroupId})||!c(n.TopicId)),s.forEach(e=>{const{Random:s,MsgSeq:r,GroupId:a,MsgClientTime:c,TinyId:u,TopicId:d,RevokerInfo:{Revoker_Account:h=(null==t?void 0:t.Revoker_Account)||"",Reason:p=(null==t?void 0:t.Reason)||""}}=e,g=d?`GROUP${d}`:`GROUP${a}`,_=this._messageHelper.generateRevokeMessage({conversationID:g,sequence:r,random:s,tinyID:u,clientTime:c,revoker:h,revokeReason:p});l?(_.revokerInfo.nick=n.From_AccountNick,_.revokerInfo.avatar=n.From_AccountHeadurl,o.push(_)):i.push(_)}),i.length>0&&(yield this._messageHelper.updateRevokerInfo(i),o.push(...i)),0!==o.length&&r.emitOuterEvent(a.MESSAGE_REVOKED,{name:a.MESSAGE_REVOKED,data:o})}catch(t){console.debug(t)}})}dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{GROUP_MESSAGE_REVOKED:s}}=this._core;e.unSubscribeInnerEvent(t,s,this._handleGroupNotifyMessage,this)}};var Li=new class{constructor(){this._c2cMessageReceiver=new Di,this._groupMessageReceiver=new Ri}init(e){this._c2cMessageReceiver.init(e),this._groupMessageReceiver.init(e)}dispose(){this._c2cMessageReceiver.dispose(),this._groupMessageReceiver.dispose()}};class Ni{constructor(e){this._core=e;const{constants:t}=e;this._messageHelper=new Ai(e),e.helper.registerWorkflowStep(t.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,t.WORKFLOW_STEP.GROUP_REVOKED_NOTICE_RECOVER,this._recoverGroupRevokeNotice,this)}getRoamingMessagesByAnchor(e){return this._core.message.messageHistory.getGroupRoamingMessagesByAnchor(e)}_recoverGroupRevokeNotice(e){const{recoverRevokeNoticeGroupIDList:t=[]}=e.result,s=this._filterValidGroupIDList(t);if(0===s.length)return;const n=Math.min(Math.ceil(s.length/10),5);Promise.all(Array.from({length:n},(e,t)=>{const n=10*t,o=Math.min(n+10,s.length);return this._fetchGroupRevokeNotice(s.slice(n,o))})).catch(e=>console.error(e))}_fetchGroupRevokeNotice(e){return pe(this,void 0,void 0,function*(){var t;try{const s=yield function(e){return pe(this,void 0,void 0,function*(){const{appStore:t,constants:{OuterConstant:s},common:n}=Po.core,o=t.groupStore.getGroupMap(),i={NotifyReqList:e.map(e=>{const t=o.get(e);return{NotifyType:1,Limit:20,Type:n.isCommunity({type:t.type,groupID:e})?s.GRP_COMMUNITY:void 0,GroupId:e,BeginTime:(null==t?void 0:t._lastRevokedTime)||0,EndTime:1e3*Po.core.common.timeManager.getServerTimeMs()}})||[]};return n.buildAndSendPacket({servcmd:"group_open_http_svc.batch_get_group_notify",data:i})})}(e);if(s){const e=[];null===(t=null==s?void 0:s.NotifyRspList)||void 0===t||t.forEach(t=>{const{GroupId:s,NotifyMsgList:n}=t,o=this._parseServerRevokeMessageList({groupID:s,serverRevokeMessageList:n});e.push(...o)}),0!==e.length&&(yield this._emitMessageRevokedEvent(e))}}catch(s){console.error(s)}})}_parseServerRevokeMessageList(e){const{serverRevokeMessageList:t,groupID:s}=e,n=[];return null==t||t.forEach(e=>{const{ClientTime:t,MsgSeq:o,Random:i,RevokerInfo:{Revoker_Account:r="",Reason:a=""}}=e,c=`GROUP${s}`,u=this._messageHelper.generateRevokeMessage({conversationID:c,sequence:o,random:i,clientTime:t,revoker:r,revokeReason:a});n.push(u)}),n}_filterValidGroupIDList(e){const{constants:{OuterConstant:t}}=this._core,s=this._core.appStore.groupStore.getGroupMap();return(null==e?void 0:e.filter(e=>{if(!s.has(e))return!1;const n=s.get(e);return(null==n?void 0:n.type)!==t.GRP_AVCHATROOM&&!(null==n?void 0:n.isSupportTopic)}))||[]}_emitMessageRevokedEvent(e){return pe(this,void 0,void 0,function*(){const{notificationCenter:t,OuterEvent:s}=this._core;yield this._messageHelper.updateRevokerInfo(e),t.emitOuterEvent(s.MESSAGE_REVOKED,{name:s.MESSAGE_REVOKED,data:e})})}}class Pi{constructor(e){this._historyMessageListFetchAnchors=new Map,this._core=e,this._messageHelper=new Ai(e)}getRoamingMessagesByAnchor(e){return pe(this,void 0,void 0,function*(){var t;try{const{conversationID:s,count:n,messageID:o,time:i,direction:r}=e;let a=i,c="";if(!i){const e=o?this._core.message.messageDataHandler.findMessage(o):null;if(a=(null==e?void 0:e.time)||0,o&&this._historyMessageListFetchAnchors.has(s)){const e=this._historyMessageListFetchAnchors.get(s);a=e.lastMessageTime,c=e.messageKey}}const u=s.replace(ri,""),l=yield function(e){return pe(this,void 0,void 0,function*(){const{peerAccount:t,count:s,lastMessageTime:n,messageKey:o,direction:i}=e,r={Peer_Account:t,MaxCnt:s,WithRecalledMsg:1,LastMsgTime:n,MsgKey:o,GetDirection:i};return Po.core.common.buildAndSendPacket({servcmd:"openim.getroammsg",data:r})})}({count:n,lastMessageTime:a,messageKey:c,peerAccount:u,direction:r});if(l){const{MsgList:e=[],Complete:n,MsgKey:o,LastMsgTime:i}=l;this._historyMessageListFetchAnchors.set(s,{messageKey:o,lastMessageTime:i});const r=[];for(let t=0;t<e.length;t++){const s=e[t],n=this._parseMessage(s);r.push(n)}const a=this._core.message.messageHelper.filterValidMessages(r);return{messageList:a,nextReqMessageIDFromServer:null===(t=a[0])||void 0===t?void 0:t.ID,lastMessageTime:i,hasNoMoreHistoryMessage:1===n}}}catch(s){throw new this._core.helper.ChatError({code:null==s?void 0:s.code})}})}clearHistoryMessageListFetchAnchors(e){this._historyMessageListFetchAnchors.delete(e)}reset(){this._historyMessageListFetchAnchors.clear()}_parseMessage(e){const t=ri,s=this._core.message.messageHelper.parseServerPushMessage(e),n=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:"in"}));return n.setElement(s.elements),n}}var ki=new class{constructor(){this._clearedConversations=new Set,this._fetchedCompleteConversations=new Set}init(e){this._core=e,this._groupMessageHistory=new Ni(e),this._c2cMessageHistory=new Pi(e),this._messageHelper=new Ai(e),e.helper.registerApi({apiName:"getMessageList",context:this}),e.helper.registerApi({apiName:"getMessageListHopping",context:this}),e.helper.registerApi({apiName:"clearHistoryMessage",context:this})}getMessageList(e){return pe(this,void 0,void 0,function*(){try{let{conversationID:t,nextReqMessageID:s}=e;const n=ci;if("@TIM#SYSTEM"===t)return{code:0,data:{messageList:[],isCompleted:!1,nextMessageSeq:""}};const o=this._getAvailableLocalMessagesCount({conversationID:t,nextReqMessageID:s});if(this._needFetchHistoryMessageList({conversationID:t,availableLocalMessagesCount:o,targetCount:n})){let e=null;if(t.startsWith(ai)?e=yield this._groupMessageHistory.getRoamingMessagesByAnchor({conversationID:t,sequence:Number(s),count:n,direction:Go.FORWARD}):t.startsWith(ri)&&(e=yield this._c2cMessageHistory.getRoamingMessagesByAnchor({conversationID:t,messageID:s,count:n,direction:Go.FORWARD})),e){const{nextReqMessageIDFromServer:n,hasNoMoreHistoryMessage:i,messageList:r}=e,a=this._core.message.messageDataHandler.prependLocalMessageList({messageList:r,conversationID:t});!function(e){const{appStore:t,message:s,OuterConstant:n}=Po.core,o=t.conversationStore.getConversation(e),i=s.messageDataHandler.getLocalMessageList(e);if(!o||0===i.length||e===n.CONV_SYSTEM)return;const r=[];for(let c=0;c<i.length;c++)"in"!==i[c].flow?"out"!==i[c].flow||i[c].isRead||i[c].setIsRead(!0):r.push(i[c]);let a=0;if(o.type===n.CONV_C2C){const e=r.slice(-o.unreadCount).filter(e=>e.isRevoked).length;a=r.length-o.unreadCount-e}else a=r.length-o.unreadCount;for(let c=0;c<a&&!r[c].isRead;c++)r[c].setIsRead(!0)}(t),yield li(t),t.startsWith(ri)&&(yield ui({messageList:r,conversationID:t}));const c=this._core.message.messageDataHandler.getLocalMessageList(t).slice(0,a.length+o),u=c.filter(e=>e.isRevoked);yield this._messageHelper.updateRevokerInfo(u),i&&this._fetchedCompleteConversations.add(t);const l={nextReqMessageID:i?"":String(n),messageList:c,isCompleted:i},d=c.map(e=>e.sequence);return{code:0,data:l,successLog:{message:`conversationID: ${t} nextReqMessageID: ${s} availableLocalMessagesCount: ${o} sequenceList: ${JSON.stringify(d)}`}}}return{code:0,data:{messageList:[],isCompleted:!1,nextReqMessageID:""}}}return{code:0,data:yield this._getMessageListFromMemory({conversationID:t,nextReqMessageID:s,count:n}),successLog:{message:`conversationID: ${t} nextReqMessageID: ${s} availableLocalMessagesCount: ${o}}`}}}catch(t){throw new this._core.helper.ChatError({code:null==t?void 0:t.code})}})}getMessageListHopping(e){return pe(this,void 0,void 0,function*(){var t,s;const{conversationID:n,sequence:o,time:i,direction:r=Go.FORWARD}=e,{isEmpty:a}=this._core.helper;if(![Go.BACKWARD,Go.FORWARD].includes(r))throw new this._core.helper.ChatError({message:"direction must be 0 or 1"});let{count:c=ci}=e;c=c>ci?ci:c;let u=null;if(n.startsWith(ai)){if(u=yield this._groupMessageHistory.getRoamingMessagesByAnchor({conversationID:n,sequence:o,count:c,direction:r}),u){const{nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:n,messageList:i,invisibleSequenceList:c}=u;if(this._core.message.messageDataHandler.storeSparseMessageList(i),r===Go.FORWARD){const t=n&&e<1;return{code:0,data:{messageList:i,isCompleted:t,nextMessageSeq:t?"":e}}}if(r===Go.BACKWARD){if(a(i)&&a(c))return{code:0,data:{messageList:[],isCompleted:!0,nextMessageSeq:""}};const e=(null===(t=null==i?void 0:i[i.length-1])||void 0===t?void 0:t.sequence)||0,r=(null===(s=null==c?void 0:c[c.length-1])||void 0===s?void 0:s.sequence)||0;return{code:0,data:{messageList:i.filter(e=>e.sequence>=o),isCompleted:!n,nextMessageSeq:n?Math.max(e,r)+1:""}}}return{code:0,data:u}}}else if(n.startsWith(ri)&&(u=yield this._c2cMessageHistory.getRoamingMessagesByAnchor({conversationID:n,count:c+1,time:i,direction:r}),u)){const{messageList:e,lastMessageTime:t,hasNoMoreHistoryMessage:s}=u;return s||(r===Go.FORWARD?e.shift():e.pop()),this._core.message.messageDataHandler.storeSparseMessageList(e),{code:0,data:{messageList:e,isCompleted:s,nextMessageTime:s?"":t}}}})}clearHistoryMessage(e){return pe(this,void 0,void 0,function*(){var t;const{appStore:s,common:{ChatError:n,getCurrentUserID:o},OuterConstant:{CONV_C2C:i,CONV_GROUP:r},message:a,apiMap:c}=this._core,u=s.conversationStore.getConversation(e);if(!u)throw new n({code:ii});const l={fromAccount:o()},{type:d}=u;d===i?(l.type=Qo,l.toAccount=e.replace(i,"")):d===r&&(l.type=ei,l.toGroupID=e.replace(r,""));try{return yield null===(t=null==c?void 0:c.setMessageRead)||void 0===t?void 0:t.call(c,{conversationID:e}),(yield function(e){return pe(this,void 0,void 0,function*(){const{fromAccount:t,type:s,toAccount:n,toGroupID:o}=e,i={From_Account:t,Type:s,To_Account:n,ToGroupid:o};return Po.core.common.buildAndSendPacket({servcmd:"recentcontact.clear_msg",data:i})})}(l))&&(a.messageDataHandler.deleteConversationMessageList(e),this._clearedConversations.add(e),this._fetchedCompleteConversations.delete(e),this._c2cMessageHistory.clearHistoryMessageListFetchAnchors(e),this._updateConversationLastMessage(e)),{code:0,data:{conversationID:e},successLog:{message:`convID:${e}`}}}catch(h){const{errorCode:t}=h;throw new this._core.helper.ChatError({functionName:"clearHistoryMessage",code:t,moreMessage:`convID:${e}`})}})}_updateConversationLastMessage(e){const{appStore:t}=this._core;t.conversationStore.updateConversation(e,{lastMessage:this._generateLastMessage()},{needSort:!0})}_getAvailableLocalMessagesCount({conversationID:e,nextReqMessageID:t}){const s=this._core.message.messageDataHandler.getLocalMessageList(e),{length:n}=s;if(!t)return n;let o=-1;return(null==e?void 0:e.startsWith(ri))?o=s.findIndex(e=>e.ID===t):(null==e?void 0:e.startsWith(ai))&&(o=s.findIndex(e=>t.includes("-")?e.ID===t:String(e.sequence)===t)),-1===o?0:o}_needFetchHistoryMessageList({conversationID:e,availableLocalMessagesCount:t,targetCount:s}){return!!this._clearedConversations.has(e)||t<s&&!this._fetchedCompleteConversations.has(e)}_getMessageListFromMemory(e){return pe(this,arguments,void 0,function*({conversationID:e,nextReqMessageID:t,count:s}){const n=this._core.message.messageDataHandler.getLocalMessageList(e),o=n.length;let i=o,r={isCompleted:!1,nextReqMessageID:"",messageList:[]},a=0,c=o;return t?t&&(c=n.findIndex(s=>e.startsWith(ri)?s.ID===t:String(s.sequence)===t),a=c>s?c-s:0,i=c):a=o>s?o-s:0,r.nextReqMessageID=0===a?"":this._generateNextReqMessageID({conversationID:e,targetIndex:a}),r.messageList=n.slice(a,c),r.isCompleted=i<=s,e.startsWith(ri)&&(yield li(e),yield ui({messageList:r.messageList,conversationID:e})),r})}_generateNextReqMessageID({conversationID:e,targetIndex:t}){const s=this._core.message.messageDataHandler.getLocalMessageList(e);return e.startsWith("C2C")?s[t].ID:String(s[t].sequence)}_generateLastMessage(){return{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}}reset(){this._clearedConversations.clear(),this._fetchedCompleteConversations.clear(),this._c2cMessageHistory.reset()}dispose(){this.reset()}},Gi=new class{constructor(){this._core=null}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"translateText",context:this})}translateText(e){return pe(this,void 0,void 0,function*(){try{const{sourceLanguage:t,sourceTextList:s,targetLanguage:n}=e,o=yield function(e,t){return pe(this,void 0,void 0,function*(){var s,n;const{sourceTextList:o,sourceLanguage:i,targetLanguage:r}=e,{store:a,common:c}=t,u={SourceText:o,Source:i,Target:r,FromAccount:null===(s=a.get("login"))||void 0===s?void 0:s.tinyID,SDKAppID:null===(n=a.get("instance"))||void 0===n?void 0:n.sdkAppId},l=yield c.buildAndSendPacket({servcmd:"im_open_translate.ws_batch_trans_text",data:u});if(l){const{CmdErrorCode:e,TargetText:t}=l;return{cmdErrorCode:e,translatedTextList:t}}})}({sourceLanguage:t,sourceTextList:s,targetLanguage:n},this._core);if(o){const{cmdErrorCode:{ErrorCode:e,ErrorInfo:t},translatedTextList:s}=o;if(0===e)return{code:0,data:{translatedTextList:s}};throw{errorCode:e,errorInfo:t,message:t}}}catch(t){const{errorCode:e,errorInfo:s}=t||{};throw new this._core.helper.ChatError({functionName:"translateText",code:e,message:s})}})}},Ui=new class{init(e){this._core=e,e.helper.registerApi({apiName:"convertVoiceToText",context:this})}convertVoiceToText(e){return pe(this,void 0,void 0,function*(){var t;const{message:s,language:n=qo.ZH_PY}=e;let{url:o}=s.payload||{};const i=this._core.common.getCurrentUserID();s.from===i&&"out"===s.flow&&(o=s.payload.remoteAudioUrl),this._validateVoiceFormat(o);const r=(null===(t=Yo.exec(o))||void 0===t?void 0:t[1])||"mp3",a=Ko[n]||Ho;try{const e=yield function(e){var t;const{store:s,common:n}=Po.core,{url:o,format:i,serverLanguageType:r}=e,a={BytesUrl:o,BytesEngServiceType:r,BytesVoiceFormat:i,Uint32Sdkappid:null===(t=s.get("instance"))||void 0===t?void 0:t.sdkAppId,Uint64SourceType:0};return n.buildAndSendPacket({servcmd:"im_open_speech.ws_sentence_recognition",data:a})}({url:o,format:r,serverLanguageType:a});if(e){const{CmdErrorCode:t,BytesResult:s}=e;if(0===t.ErrorCode)return{code:0,data:{result:s}};throw{code:t.ErrorCode,message:t.ErrorInfo}}}catch(c){const{code:e,message:t}=c||{};throw new this._core.common.ChatError({functionName:"convertVoiceToText",code:e,message:t})}})}_validateVoiceFormat(e){if(!Yo.test(e))throw new this._core.common.ChatError({code:2119})}};class Fi{constructor(e){const{constants:t,common:s,utils:n}=Po.core,{CONV_C2C:o,CONV_GROUP:i}=t.OuterConstant,{ID:r,tinyID:a,from:c,to:u,clientTime:l=s.timeManager.getServerTimeSeconds()||0,random:d,sequence:h,cloudCustomData:p="",nick:g="",avatar:_="",clientSequence:m,conversationType:f,groupID:v,_elements:I,time:E}=e;this.ID=r||`${a}-${l}-${d}`,this.messageRandom=d,this.from=c,this.messageSender=c,this.time=E,this.messageSequence=h,this.clientSequence=m||h,this.clientTime=l,this.cloudCustomData=p,this.messageReceiver=u,this.avatar=_,this.nick=g;const S=n.deepCopyWithMethods(I);S.forEach(e=>{e.payload=e.content,delete e.content}),this.messageBody=S,r?f.startsWith(o)?this.receiverUserID=u:f.startsWith(i)&&(this.receiverGroupID=u):v?(this.receiverGroupID=v,this.messageReceiver=v):u&&(this.receiverUserID=u,this.messageReceiver=u)}transformElementsToServerFormat(){return this.messageBody?Array.isArray(this.messageBody)?this.messageBody.map(e=>e.transformToServerFormat({isMergerMessage:!0})):this.messageBody.transformToServerFormat({isMergerMessage:!0}):null}}class xi{static parseServerPushElement(e){const{MsgContent:t}=e,{MsgList:s=[],CompatibleText:n,AbstractList:o,Title:i,PbMsgKey:r,JsonMsgKey:a}=t||{},c=s.map(e=>pi(e));return new xi({messageList:c,title:i,abstractList:o,compatibleText:n,pbDownloadKey:r,downloadKey:a})}constructor(e){this.type=Po.core.constants.OuterConstant.MSG_MERGER;const{messageList:t,title:s,abstractList:n,compatibleText:o,pbDownloadKey:i="",downloadKey:r="",version:a=0,layersOverLimit:c=!1}=e,u=[];t.forEach(e=>{if(e){const t=new Fi(e);u.push(t)}}),this.content={messageList:u,title:s,abstractList:n,compatibleText:o,version:a,downloadKey:r,pbDownloadKey:i,layersOverLimit:c}}validateBeforeSend(){const{isEmpty:e}=Po.core.helper;return e(this.content.messageList)?{isValid:!1,error:{message:"content is invalid"}}:{isValid:!0}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{abstractList:n,compatibleText:o,downloadKey:i,layersOverLimit:r,pbDownloadKey:a,title:c,version:u,messageList:l}=s;return{MsgType:this.type,MsgContent:{AbstractList:n,CompatibleText:o,JsonMsgKey:i,LayersOverLimit:r,PbMsgKey:a,Title:c,Version:u,MsgList:hi(l)}}}}var $i=new class{init(e){this._core=e;const{message:t,helper:s,constants:{OuterConstant:n}}=e;t.messageFactory.registerElementClass(n.MSG_MERGER,xi),s.registerApi({apiName:"createMergerMessage",context:this}),s.registerApi({apiName:"sendMessage",context:this,matcher:e=>e[0].type===n.MSG_MERGER}),s.registerApi({apiName:"downloadMergerMessage",context:this})}createMergerMessage(e){const{common:t}=this._core;if(!e)return null;const s=new xi(e.payload),n=t.getCurrentUserID(),o=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:n}));return o.setRelayFlag(!0),o.setElement(s),o}sendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;try{const r=function(e){let t="utf-8";Po.core.helper.IN_BROWSER&&document&&(t=document.charset.toLowerCase());let s,n=0,o=0;if(o=e.length,"utf-8"===t||"utf8"===t)for(let i=0;i<o;i++)s=e.codePointAt(i),s<=127?n+=1:s<=2047?n+=2:s<=65535?n+=3:(n+=4,i++);else if("utf-16"===t||"utf16"===t)for(let i=0;i<o;i++)s=e.codePointAt(i),s<=65535?n+=2:(n+=4,i++);else n=e.replace(/[^\x00-\xff]/g,"aa").length;return n}(JSON.stringify(e));let a=e,c=null;if(r>11264){a=this._core.utils.deepCopyWithMethods(e);try{const{JsonMsgKey:e,PbMsgKey:t}=yield function(e){return pe(this,void 0,void 0,function*(){const{payload:{messageList:t}}=e,s={MsgList:hi(t)};return Po.core.common.buildAndSendPacket({servcmd:"im_long_msg.save_relay_json_msg",data:s})})}(a),{payload:s}=a;c=new xi(Object.assign(Object.assign({},s),{messageList:[],downloadKey:e,pbDownloadKey:t})),a.setElement(c)}catch(i){console.error(i)}}const{data:{message:u}}=yield null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(a,t);return c&&u.setElement(e._elements),{code:0,data:{message:u}}}catch(i){const{errorCode:e}=i;throw new this._core.helper.ChatError({code:e})}})}downloadMergerMessage(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,s=e.payload,{downloadKey:n,pbDownload:o,type:i,messageList:r}=s,a=he(s,["downloadKey","pbDownload","type","messageList"]);try{const s=yield function(e){return pe(this,void 0,void 0,function*(){return Po.core.common.buildAndSendPacket({servcmd:"im_long_msg.get_relay_json_msg",data:{JsonMsgKey:e}})})}(n),{MsgList:o}=s||{},i=null==o?void 0:o.map(e=>{const t=pi(e);return new Fi(t)});return"function"==typeof e.isOnlineMessage?e.setElement({type:e.type,content:Object.assign({messageList:i},a)}):(e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""),t.info("downloadMergerMessage",` success downloadKey:${n}`),e}catch(c){const{errorCode:e}=c;throw new this._core.helper.ChatError({functionName:"downloadMergerMessage",code:e,moreMessage:n})}})}},qi=new class{init(e){this._core=e,this._core.helper.registerExperimentalAPI("sendComboMessage",this)}sendComboMessage(e){return pe(this,void 0,void 0,function*(){const{appStore:t,message:s,common:{getCurrentUserID:n},utils:{isArray:o}}=this._core,{GroupId:i,To_Account:r}=e;e.From_Account=e.From_Account||n();let a=null;if(i){a=this._generateGroupMessage(Object.assign(Object.assign({},e),{ToGroupId:i}));const s=t.userStore.getUserProfile(n());a.level=(null==s?void 0:s.level)||0,o(r)&&r.length>0&&(a._receiverList=r)}else r&&(a=this._generateC2CMessage(e));return s.messageSender.sendMessage(a,e)})}_generateC2CMessage(e){const{message:t,OuterConstant:{CONV_C2C:s}}=this._core,n=s,o=t.messageHelper.parseServerPushMessage(e),i=t.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:n,flow:ti.OUT})),{elements:r}=o;return i.setElement(r),i}_generateGroupMessage(e){const{message:t,OuterConstant:{CONV_GROUP:s}}=this._core,n=s,o=t.messageHelper.parseServerGroupMessage(e),i=t.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:n,flow:ti.OUT})),{elements:r}=o;return i.setElement(r),i}},Bi=new class{init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{MESSAGE_PUSH:n},InnerEventSubType:{GROUP_MESSAGE_PINNED:o}}=e;s.subscribeInnerEvent(n,o,this._handleGroupMessagePinned,this),t.registerApi({apiName:"pinGroupMessage",context:this}),t.registerApi({apiName:"getPinnedGroupMessageList",context:this})}pinGroupMessage(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,common:{isTopic:s},OuterConstant:{GROUP_ID_PREFIX:n},helper:{ChatError:o}}=this._core;let{groupID:i,message:r,isPinned:a}=e;const{sequence:c}=r;try{return yield function(e){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:t,getCurrentUserID:s}}=Po.core,{groupID:n,sequence:o,isPinned:i}=e,r=s(),a=i?"group_open_http_svc.pin_message":"group_open_http_svc.unpin_message",c={GroupId:n,MsgSeq:o};return i?c.Pinner_Account=r:c.UnPinner_Account=r,t({servcmd:a,data:c})})}({groupID:i,sequence:c,isPinned:a}),{code:0,data:{}}}catch(u){const{errorCode:e,errorInfo:t}=u||{};throw new o({code:e,message:t})}})}getPinnedGroupMessageList(e){return pe(this,void 0,void 0,function*(){let t=[];try{const s=yield function(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{common:{buildAndSendPacket:s}}=Po.core;return s({servcmd:"group_open_http_svc.get_pinned_messages",data:{GroupId:t}})})}({groupID:e});if(s){const{PinnedMsgList:n=[]}=s;t=yield this._updatePinnedMessageInfo({serverPinnedMessageList:n,groupID:e})}return{code:0,data:{messageList:t}}}catch(s){throw s}})}_handleGroupMessagePinned(e){const{message:{messageHelper:t,messageFactory:s},notificationCenter:n,OuterEvent:o,OuterConstant:i}=this._core;e.GroupTips.forEach(e=>{const{ToGroupId:r,MsgBody:{PinnedMsg:a,OpType:c,MsgOperatorMemberExtraInfo:u,SdkGroupMessageId:l}}=e,{UserId:d,NickName:h="",ImageUrl:p=""}=u;let g=null,_=!1;if(c===si){_=!0;const e=t.parseServerGroupMessage(a);g=s.createMessage(Object.assign(Object.assign({},e),{conversationType:i.CONV_GROUP,flow:"in"})),g.setElement(e.elements),g.pinnerInfo={userID:d,nick:h,avatar:p}}else if(c===ni){const{ClientTime:e,Random:t,SenderTinyId:s,ServerTime:n,MsgSeq:o}=l;g={ID:`${s}-${e}-${t}`,sequence:o,random:t,time:n,clientTime:e}}g&&n.emitOuterEvent(o.PINNED_GROUP_MESSAGE_UPDATED,{name:o.PINNED_GROUP_MESSAGE_UPDATED,data:{groupID:r,message:g,isPinned:_,operatorInfo:{userID:d,nick:h,avatar:p}}})})}_findMessageBySequence(e,t){const{message:{messageDataHandler:s}}=this._core;return[...s.getLocalMessageList(e),...s.getSparseMessageList(e)].find(e=>e.sequence===t)}_updatePinnedMessageInfo(e){return pe(this,arguments,void 0,function*({serverPinnedMessageList:e,groupID:t}){const{OuterConstant:{CONV_GROUP:s},utils:{isEmpty:n}}=this._core,o=[],i=[],r=[],a=new Map,c=`${s}${t}`;for(let l=0;l<e.length;l++){const t=e[l],{Pinner_Account:s,MsgSeq:n}=t,u=this._findMessageBySequence(c,n);i.push(s),a.set(n,s),u?o.push(u):r.push(n)}const u=yield this._fetchPinnedMessageInfo({conversationID:c,messageSequenceList:r,pinnerIDList:i});if(u){const{pinnerInfoMap:e,messageList:t}=u;return o.push(...t),o.forEach(t=>{const{sequence:s}=t,n=a.get(s),o=e[n]||{userID:n,nick:"",avatar:""};t.pinnerInfo=o}),o.sort((e,t)=>e.sequence-t.sequence),o}return[]})}_fetchPinnedMessageInfo(e){return pe(this,void 0,void 0,function*(){var t,s;const{message:{messageHistory:n},user:{userProfile:o},utils:{isArray:i}}=this._core,{conversationID:r,messageSequenceList:a,pinnerIDList:c}=e,u=yield Promise.all([this._fetchMessageBySequence({conversationID:r,messageSequenceList:a}),null==o?void 0:o.getUserProfile({userIDList:c})]);if(i(u)){const e={};return((null===(t=u[1])||void 0===t?void 0:t.data)||[]).forEach(t=>{const{userID:s,nick:n="",avatar:o=""}=t;e[s]={userID:s,nick:n,avatar:o}}),{messageList:(null===(s=u[0])||void 0===s?void 0:s.messageList)||[],pinnerInfoMap:e}}})}_fetchMessageBySequence(e){return pe(this,void 0,void 0,function*(){const{utils:{isEmpty:t},message:{messageHistory:s}}=this._core,{conversationID:n,messageSequenceList:o}=e;return t(o)?[]:s.getGroupRoamingMessagesByAnchor({conversationID:n,messageSequenceList:o,getType:3})})}},Vi=new class{constructor(){this.name="MessageEnhancer"}install(e){this._core=e,Po.init(e),bi.init(e),wi.init(e),Li.init(e),ki.init(e),gi.init(e),Gi.init(e),Ui.init(e),_i.init(e),$i.init(e),vi.init(e),qi.init(e),Bi.init(e),e.helper.registerValidateConfig({auth:yi,params:Si}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this.dispose,this)}dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this.dispose,this),Li.dispose(),ki.dispose(),_i.dispose(),vi.dispose()}_reset(){ki.reset()}},Wi=new class{constructor(){this._name="WebRequest"}init(e){this._core=e}request(e,t){return pe(this,void 0,void 0,function*(){var s;const{isEmpty:n}=null===(s=this._core)||void 0===s?void 0:s.utils,{downloadUrl:o="",method:i="PUT",url:r,qs:a,headers:c={},resources:u,dataType:l="text",uploadByIP:d,uploadIP:h}=e;let p=r;if(a){const e=this._queryString(a);e&&(p+=`${p.includes("?")?"&":"?"}${e}`)}const g=new XMLHttpRequest;g.open(i.toUpperCase(),p,!0),g.responseType=l;const _=Object.assign({},c);if(d&&h&&(_.host=h),!n(_))for(const e in _)_.hasOwnProperty(e)&&!["content-length","user-agent","origin","host"].includes(e.toLowerCase())&&g.setRequestHeader(e,_[e]);return g.onload=()=>{const s=this._getResponseBody(g,o,d&&h),n=this._buildResponse(g,s);if(200===g.status)t(null,n);else{if(h&&!p.includes(h))return e.url=this._domainName2IP(p,h),e.uploadByIP=!0,this.request(e,t);t({code:g.status,message:JSON.stringify(g.responseText)},n)}},g.onerror=()=>{const e=this._getResponseBody(g,o,d&&h),s=this._buildResponse(g,e),n={code:g.status,message:0===g.status?"CORS blocked or network error":JSON.stringify(g.responseText)};t(n,s)},e.onProgress&&g.upload&&(g.upload.onprogress=t=>{const{total:s,loaded:n}=t,o=Math.min(Math.floor(100*n/s),100);e.onProgress({total:s,loaded:n,percent:o/100})}),g.send(u),g})}_buildResponse(e,t){const s={};return e.getAllResponseHeaders().trim().split("\n").forEach(e=>{if(e){const[t,n]=e.split(":").map(e=>e.trim());s[t.toLowerCase()]=n}}),{statusCode:e.status,statusMessage:e.statusText,headers:s,data:t}}_getResponseBody(e,t,s){return 200===e.status&&t?{location:t,uploadIP:s}:{response:e.responseText,uploadIP:s}}_queryString(e,t="&",s="="){var n;const{isEmpty:o,isPlainObject:i}=null===(n=this._core)||void 0===n?void 0:n.utils;return o(e)?"":i(e)?Object.keys(e).map(n=>{const o=encodeURIComponent(n)+s;return Array.isArray(e[n])?e[n].map(e=>o+encodeURIComponent(e)).join(t):o+encodeURIComponent(e[n])}).filter(Boolean).join(t):void 0}_domainName2IP(e,t){return e.replace(/^http(s)?:\/\/(.*?)\//,`https://${t}/`)}};const ji=["unknown","image","video","audio","log"];var Hi=new class{init(e){this._core=e}request(e,t){var s;const{MINI_APP_NAMESPACE:n,IN_ALIPAY_MINI_APP:o,isUniIOSApp:i}=null===(s=this._core)||void 0===s?void 0:s.utils,{resources:r="",headers:a={},url:c,downloadUrl:u=""}=e;let l=c,d=null;const h=u?u.match(/^(https?:\/\/[^/]+\/)([^/]*\/?)(.*)$/):null;if(!h)return void console.warn("message Invalid download URL format");const p=decodeURIComponent(h[3]),g=p.includes("?")?p.split("?")[0]:p||"",_={key:e.fileKey||g,success_action_status:200,"Content-Type":""},m={};if(i()){const[e,t]=c.split("?sign=");t&&(l=`${e}?sign=${encodeURIComponent(t)}`,m.sign=decodeURIComponent(t),m.signature=decodeURIComponent(t))}let f={url:l,header:a,name:"file",filePath:r,formData:Object.assign(Object.assign({},_),m),timeout:e.timeout||3e5};if(o){const t=he(f,["name"]);f=Object.assign(Object.assign({},t),{fileName:"file",fileType:e.fileType?ji[e.fileType]:"image"})}return d=n.uploadFile(Object.assign(Object.assign({},f),{success:e=>{this._handleResponse({response:e,downloadUrl:u,callback:t})},fail:e=>{this._handleResponse({response:e,downloadUrl:u,callback:t})}})),d.onProgressUpdate&&d.onProgressUpdate(t=>{e.onProgress&&e.onProgress({total:t.totalBytesExpectedToSend||0,loaded:t.totalBytesSent||0,percent:t.progress?Math.floor(t.progress)/100:0})}),d}_handleResponse(e){const{downloadUrl:t,response:s,callback:n}=e,o={};if(s.header)for(const r in s.header)s.header.hasOwnProperty(r)&&(o[r.toLowerCase()]=s.header[r]);const i=+s.statusCode;200===i?n(null,{statusCode:i,headers:o,data:Object.assign(Object.assign({},s.data),{location:t})}):n({code:i,message:JSON.stringify(s.data)},{statusCode:i,headers:o,data:void 0})}};function Ki(e){return"file"===(t=e,Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase());var t}function Yi(e){const t=e||99999999;return Math.round(Math.random()*t)}function zi(e,t=!0,s=!0){const n=Date.now();return t?s?n-e+" ms":`${Math.round((n-e)/1e3)} s`:s?n-e:Math.round((n-e)/1e3)}function Zi(e){return`${Array.from({length:8},()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1)).join("")}-${e}`}function Ji(e,t){return Math.round(Number(e)*10**t)/10**t}function Xi(e){const t=1024,s=1048576;return e<t?`${e}B`:e<s?`${Math.floor(e/t)}KB`:`${Math.floor(e/s)}MB`}function Qi(e){return e<=1048576?`${Ji(e/1024,1)}KB/s`:`${Ji(e/1048576,1)}MB/s`}const er="TIMImageElem",tr="TIMSoundElem",sr="TIMFileElem",nr="TIMVideoFileElem",or="RichMediaMessagePlugin",ir=["rich.my-imcloud.com","imrich.qcloud.com"],rr=1,ar=2,cr=3,ur=255;var lr;!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(lr||(lr={}));const dr={wechat:/^(wxfile:\/\/tmp_|http:\/\/temp\/|cloud:\/\/temp-)/,alipay:/^(https:\/\/resource\/|alipayfile:\/\/tmp\/)/,baidu:/^(http:\/\/tmp\/|swanfile:\/\/tmp_)/,bytedance:/^(ttfile:\/\/tmp_|\/(var|tmp)\/|tttemp:\/\/)/,qq:/^(qqfile:\/\/tmp_|http:\/\/qtemp\/)/},hr=Symbol("isCustomUpload");var pr,gr=new class{init(e){this._core=e}addAuthToUrl(e=""){if(this._isMiniProgramTempFile(e))return e;const t=(s=e)?s.startsWith("https://")?s:s.startsWith("http://")?s.replace("http://","https://"):s:"";var s;return this.processResourceUrl(t)}removeAuthToUrl(e){return function(e,t){const[s,n]=e.split("?");if(!n)return s;const o=n.split("&").reduce((e,s)=>{const[n,o]=s.split("=");return n&&n!==t&&(e[n]=o||""),e},{}),i=Object.keys(o).map(e=>`${e}${o[e]?`=${o[e]}`:""}`).join("&");return i?`${s}?${i}`:s}(e,"authKey")}_isMiniProgramTempFile(e){return!!this.getPlatformFlags().IN_MINI_APP&&Object.values(dr).some(t=>t.test(e))}extractFileFromInput(e){const{utils:{isArray:t}}=this._core;return Ki(e)?e:function(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}(e)&&"undefined"!=typeof uni?t(e.tempFiles)&&e.tempFiles.length>0?e.tempFiles[0]:t(e.files)?e.files[0]:e.tempFile?e.tempFile:null:e instanceof HTMLInputElement&&e.files&&e.files.length>0?e.files[0]:null}probeImageWidthHeight(e){return pe(this,void 0,void 0,function*(){var t;const{IN_MINI_APP:s,IN_BROWSER:n}=(null===(t=this._core)||void 0===t?void 0:t.utils)||{};return this._shouldSkipProbing()?{width:0,height:0}:n?this._probeImageDimensionsWeb(e):s?this._probeImageDimensionsMiniApp(e):void 0})}isSimpleCos(){var e;const t=(null===(e=this._core)||void 0===e?void 0:e.store.get("cloudConfig"))||{},{simple_cos:s}=t;return"0"!==s}getFileDNList(){var e;let t=ir;const s=(null===(e=this._core)||void 0===e?void 0:e.store.get("cloudConfig"))||{},{file_dn_list:n}=s;if(void 0===n)return t;try{JSON.parse(n).forEach(e=>{t.includes(e)||t.push(e)})}catch(o){console.warn(o),t=ir}return t}getPlatform(){var e;return null===(e=this._core)||void 0===e?void 0:e.utils.platform}generateUUID(e,t){var s;let n=`${this.getSDKAppID()}-${this.getCurrentUserID()}-${null===(s=this._core)||void 0===s?void 0:s.utils.randomString()}`;if(t)return`${n}.${t}`;const o=e.name||e.value||e.url||e.tempFilePath,i=o&&o.slice(o.lastIndexOf(".")+1);return i&&(n=`${n}.${i}`),n}processResourceUrl(e){if(!e)return"";let t=e;const s=this.getFileDownloadProxy(),n=this.getAuthKey(),o=this.getFileDNList();return s&&(e.startsWith("http://")?t=e.replace(/^http:\/\/[^/]+/,s):e.startsWith("https://")&&(t=e.replace(/^https:\/\/[^/]+/,s))),n&&-1===t.indexOf("authKey=")&&function(e,t){let s=!1;if(e){const n=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),o=n&&n[2]||"";if(o.includes("rich-dev"))return!0;for(let e=0;e<t.length;e++)if(o.endsWith(t[e])){s=!0;break}}return s}(t,o)&&(t=t.indexOf("?")>-1?`${t}&authKey=${n}`:`${t}?authKey=${n}`),t}getCurrentUserID(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.userId}getSDKAppID(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.sdkAppId}getFileDownloadProxy(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.fileDownloadProxy)||""}getFileUploadProxy(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.fileUploadProxy)||""}getAuthKey(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.authKey)||""}isPrivateNetWork(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.proxyServer}getPlatformFlags(){var e;const{IN_BROWSER:t,IN_MINI_APP:s,IN_RN_APP:n,IN_UNI_NATIVE_APP:o}=null===(e=this._core)||void 0===e?void 0:e.utils;return{IN_BROWSER:t,IN_MINI_APP:s,IN_RN_APP:n,IN_UNI_NATIVE_APP:o}}isEmpty(e){var t;const{isEmpty:s}=null===(t=this._core)||void 0===t?void 0:t.utils;return s(e)}generateURL(e,t){const{needAddAuthToUrl:s=!0}=t||{};return s?this.addAuthToUrl(e):e}_probeImageDimensionsMiniApp(e){var t;const{MINI_APP_NAMESPACE:s}=(null===(t=this._core)||void 0===t?void 0:t.utils)||{};return new Promise(t=>{s.getImageInfo({src:e,success:e=>t({width:e.width,height:e.height}),fail:()=>t({width:0,height:0})})})}_shouldSkipProbing(){var e;const{IN_RN_APP:t,IS_IE:s,IE_VERSION:n,IN_WX_MINI_GAME:o}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};return t||s&&9===n||o}_probeImageDimensionsWeb(e){return new Promise(t=>{const s=new Image,n=()=>{s.onload=null,s.onerror=null,s.src=""};s.onload=()=>{t({width:s.width,height:s.height}),n()},s.onerror=()=>{t({width:0,height:0}),n()},s.src=e})}},_r={exports:{}},mr=Zt((pr||(pr=1,function(e){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(e,t){var s=e[0],n=e[1],o=e[2],i=e[3];n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[0]-680876936|0)<<7|s>>>25)+n|0)&n|~s&o)+t[1]-389564586|0)<<12|i>>>20)+s|0)&s|~i&n)+t[2]+606105819|0)<<17|o>>>15)+i|0)&i|~o&s)+t[3]-1044525330|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[4]-176418897|0)<<7|s>>>25)+n|0)&n|~s&o)+t[5]+1200080426|0)<<12|i>>>20)+s|0)&s|~i&n)+t[6]-1473231341|0)<<17|o>>>15)+i|0)&i|~o&s)+t[7]-45705983|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[8]+1770035416|0)<<7|s>>>25)+n|0)&n|~s&o)+t[9]-1958414417|0)<<12|i>>>20)+s|0)&s|~i&n)+t[10]-42063|0)<<17|o>>>15)+i|0)&i|~o&s)+t[11]-1990404162|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[12]+1804603682|0)<<7|s>>>25)+n|0)&n|~s&o)+t[13]-40341101|0)<<12|i>>>20)+s|0)&s|~i&n)+t[14]-1502002290|0)<<17|o>>>15)+i|0)&i|~o&s)+t[15]+1236535329|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[1]-165796510|0)<<5|s>>>27)+n|0)&o|n&~o)+t[6]-1069501632|0)<<9|i>>>23)+s|0)&n|s&~n)+t[11]+643717713|0)<<14|o>>>18)+i|0)&s|i&~s)+t[0]-373897302|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[5]-701558691|0)<<5|s>>>27)+n|0)&o|n&~o)+t[10]+38016083|0)<<9|i>>>23)+s|0)&n|s&~n)+t[15]-660478335|0)<<14|o>>>18)+i|0)&s|i&~s)+t[4]-405537848|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[9]+568446438|0)<<5|s>>>27)+n|0)&o|n&~o)+t[14]-1019803690|0)<<9|i>>>23)+s|0)&n|s&~n)+t[3]-187363961|0)<<14|o>>>18)+i|0)&s|i&~s)+t[8]+1163531501|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[13]-1444681467|0)<<5|s>>>27)+n|0)&o|n&~o)+t[2]-51403784|0)<<9|i>>>23)+s|0)&n|s&~n)+t[7]+1735328473|0)<<14|o>>>18)+i|0)&s|i&~s)+t[12]-1926607734|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[5]-378558|0)<<4|s>>>28)+n|0)^n^o)+t[8]-2022574463|0)<<11|i>>>21)+s|0)^s^n)+t[11]+1839030562|0)<<16|o>>>16)+i|0)^i^s)+t[14]-35309556|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[1]-1530992060|0)<<4|s>>>28)+n|0)^n^o)+t[4]+1272893353|0)<<11|i>>>21)+s|0)^s^n)+t[7]-155497632|0)<<16|o>>>16)+i|0)^i^s)+t[10]-1094730640|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[13]+681279174|0)<<4|s>>>28)+n|0)^n^o)+t[0]-358537222|0)<<11|i>>>21)+s|0)^s^n)+t[3]-722521979|0)<<16|o>>>16)+i|0)^i^s)+t[6]+76029189|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[9]-640364487|0)<<4|s>>>28)+n|0)^n^o)+t[12]-421815835|0)<<11|i>>>21)+s|0)^s^n)+t[15]+530742520|0)<<16|o>>>16)+i|0)^i^s)+t[2]-995338651|0)<<23|n>>>9)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[0]-198630844|0)<<6|s>>>26)+n|0)|~o))+t[7]+1126891415|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[14]-1416354905|0)<<15|o>>>17)+i|0)|~s))+t[5]-57434055|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[12]+1700485571|0)<<6|s>>>26)+n|0)|~o))+t[3]-1894986606|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[10]-1051523|0)<<15|o>>>17)+i|0)|~s))+t[1]-2054922799|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[8]+1873313359|0)<<6|s>>>26)+n|0)|~o))+t[15]-30611744|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[6]-1560198380|0)<<15|o>>>17)+i|0)|~s))+t[13]+1309151649|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[4]-145523070|0)<<6|s>>>26)+n|0)|~o))+t[11]-1120210379|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[2]+718787259|0)<<15|o>>>17)+i|0)|~s))+t[9]-343485551|0)<<21|n>>>11)+o|0,e[0]=s+e[0]|0,e[1]=n+e[1]|0,e[2]=o+e[2]|0,e[3]=i+e[3]|0}function n(e){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return s}function o(e){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return s}function i(e){var t,o,i,r,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)s(l,n(e.substring(t-64,t)));for(o=(e=e.substring(t-64)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(s(l,i),t=0;t<16;t+=1)i[t]=0;return r=(r=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),c=parseInt(r[1],16)||0,i[14]=a,i[15]=c,s(l,i),l}function r(e){var t,n,i,r,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)s(l,o(e.subarray(t-64,t)));for(n=(e=t-64<u?e.subarray(t-64):new Uint8Array(0)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)i[t>>2]|=e[t]<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(s(l,i),t=0;t<16;t+=1)i[t]=0;return r=(r=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),c=parseInt(r[1],16)||0,i[14]=a,i[15]=c,s(l,i),l}function a(e){var s,n="";for(s=0;s<4;s+=1)n+=t[e>>8*s+4&15]+t[e>>8*s&15];return n}function c(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function u(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function l(e,t){var s,n=e.length,o=new ArrayBuffer(n),i=new Uint8Array(o);for(s=0;s<n;s+=1)i[s]=e.charCodeAt(s);return t?i:o}function d(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function h(e,t,s){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e)),n.set(new Uint8Array(t),e.byteLength),n}function p(e){var t,s=[],n=e.length;for(t=0;t<n-1;t+=2)s.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,s)}function g(){this.reset()}return c(i("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(s,n){var o,i,r,a,c=this.byteLength,u=t(s,c),l=c;return n!==e&&(l=t(n,c)),u>l?new ArrayBuffer(0):(o=l-u,i=new ArrayBuffer(o),r=new Uint8Array(i),a=new Uint8Array(this,u,o),r.set(a),i)}}(),g.prototype.append=function(e){return this.appendBinary(u(e)),this},g.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,o=this._buff.length;for(t=64;t<=o;t+=64)s(this._hash,n(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},g.prototype.end=function(e){var t,s,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<o;t+=1)i[t>>2]|=n.charCodeAt(t)<<(t%4<<3);return this._finish(i,o),s=c(this._hash),e&&(s=p(s)),this.reset(),s},g.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},g.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},g.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},g.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},g.prototype._finish=function(e,t){var n,o,i,r=t;if(e[r>>2]|=128<<(r%4<<3),r>55)for(s(this._hash,e),r=0;r<16;r+=1)e[r]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),i=parseInt(n[1],16)||0,e[14]=o,e[15]=i,s(this._hash,e)},g.hash=function(e,t){return g.hashBinary(u(e),t)},g.hashBinary=function(e,t){var s=c(i(e));return t?p(s):s},g.ArrayBuffer=function(){this.reset()},g.ArrayBuffer.prototype.append=function(e){var t,n=h(this._buff.buffer,e),i=n.length;for(this._length+=e.byteLength,t=64;t<=i;t+=64)s(this._hash,o(n.subarray(t-64,t)));return this._buff=t-64<i?new Uint8Array(n.buffer.slice(t-64)):new Uint8Array(0),this},g.ArrayBuffer.prototype.end=function(e){var t,s,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<o;t+=1)i[t>>2]|=n[t]<<(t%4<<3);return this._finish(i,o),s=c(this._hash),e&&(s=p(s)),this.reset(),s},g.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},g.ArrayBuffer.prototype.getState=function(){var e=g.prototype.getState.call(this);return e.buff=d(e.buff),e},g.ArrayBuffer.prototype.setState=function(e){return e.buff=l(e.buff,!0),g.prototype.setState.call(this,e)},g.ArrayBuffer.prototype.destroy=g.prototype.destroy,g.ArrayBuffer.prototype._finish=g.prototype._finish,g.ArrayBuffer.hash=function(e,t){var s=c(r(new Uint8Array(e)));return t?p(s):s},g}()}(_r)),_r.exports)),fr=new class{constructor(){this.uploadFileTryCount=0,this.maxRetries=1,this.systemClockOffset=0,this.httpRequest=null,this.uploadFileType="",this.duration=900,this.fetchCosTryCount=0}init(e){var t;this._core=e;const{IN_MINI_APP:s}=e.utils;this.httpRequest=s?Hi:Wi,null===(t=this.httpRequest)||void 0===t||t.init(e)}uploadToCOS(e){return pe(this,void 0,void 0,function*(){const t=`${or} uploadToCOS`,{ssoLog:s,utils:{safeStringify:n}}=this._core,{file:o}=e;this.uploadFileType=e.uploadFileType,s.debug("uploadToCOS",`${t} options:${n(e)}`);try{const n=Date.now(),i=yield this._createCosOptions(e),r=i.fileExistsInCOS?{data:{location:i.downloadUrl}}:yield this._uploadFile(i);this._handleUploadError(r,e);const a=this._createUploadResult(o,r),c=Date.now()-n,u=`size:${Xi(o.size)} time:${c}ms speed:${Qi(1e3*o.size/c)}`;return s.debug("uploadToCOS",`${t} ok. name:${o.name} ${u}`),{uploadOptions:i,response:a}}catch(i){throw s.warn("uploadToCOS",`${t} failed, error:${n(i)}`),i}})}_handleUploadError(e,t){var s,n;const{ChatError:o}=null===(s=this._core)||void 0===s?void 0:s.helper;if(403===e.statusCode)throw t.url,(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.uploadIP)&&e.data.uploadIP,new o({message:"Upload failed with status 403"})}_createUploadResult(e,t){return{fileName:e.name,fileSize:e.size,fileType:e.type.slice(e.type.indexOf("/")+1).toLowerCase(),location:t.data.location||"",uploadTime:zi(Date.now(),!1),uploadSpeed:Qi(1e3*e.size/zi(Date.now(),!1))}}_createCosOptions(e){return pe(this,void 0,void 0,function*(){const{fileName:t,resources:s,uploadMethod:n}=yield this._prepareUploadParams(e),o=this._isC2CConversation(e.message.conversationID)?1:2;try{const i=yield this._fetchCosSignatureUrl({fileType:this.uploadFileType,fileName:t,uploadMethod:n,duration:this.duration,userID:e.message.from,conversationType:o}),{uploadUrl:r,downloadUrl:a,requestSnapshotUrl:c,thumbUrl:u,largeUrl:l,fileKey:d,existFlag:h}=i,p=!gr.isPrivateNetWork()&&i.uploadIP;return{url:this._getRawOrUploadProxyUrl(r),fileType:this.uploadFileType,fileName:t,resources:s,downloadUrl:a,requestSnapshotUrl:c,thumbUrl:u,largeUrl:l,fileKey:d,uploadIP:p||"",fileExistsInCOS:1===h,onProgress:t=>this._handleUploadProgress(t,e)}}catch(i){throw console.error("Failed to create COS pre-signed URL options:",i),i}})}_prepareUploadParams(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s,isEmpty:n}}=this._core;t.debug("_prepareUploadParams",` prepareUploadParams:${s(e)}`);const{file:o}=e,{IN_MINI_APP:i,IN_RN_APP:r}=gr.getPlatformFlags(),a=i||r,c=a&&e.message.type!==sr,{name:u}=o,l=u.slice(u.lastIndexOf(".")),d=`${Yi(999999)}${l}`,h=c?o.name:d,p=yield this._generateHashFileName(o);return{fileName:n(p)?Zi(h):`${p}${l}`,resources:a?o.url:o,uploadMethod:a?1:0}})}_generateHashFileName(e){return pe(this,void 0,void 0,function*(){const{utils:{IN_MINI_APP:t,IN_BROWSER:s,IN_UNI_NATIVE_APP:n,isArray:o},ssoLog:i}=this._core,r=Date.now();let a="";return s&&(a=yield this._generateHashFileNameInWeb(e)),t&&(o(e.tempFiles)&&(e=e.tempFiles[0]),n||(a=yield this._generateFileNameInMiniProgram(e)),n&&(a=yield this._generateFileNameInUNINativeApp(e))),i.info("_generateHashFileName",`hashFileName:${a} costTime:${Date.now()-r}`),a})}_generateHashFileNameInWeb(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;let n="";try{n=yield new Promise((s,n)=>{const o=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;o||(t.warn("_generateHashFileNameInWeb","Browser does not support file slicing"),s(""));const i=10485760,r=Math.ceil(e.size/i);let a=0;const c=new mr.ArrayBuffer,u=new FileReader,l=setTimeout(()=>{u.abort(),t.warn("_generateHashFileNameInWeb","File hash generation timeout"),s("")},2e3);function d(){const t=a*i,s=t+i>=e.size?e.size:t+i;u.readAsArrayBuffer(o.call(e,t,s))}u.onload=e=>{t.debug("_generateHashFileNameInWeb",`read chunk nr ${a+1} of ${r}`),c.append(e.target.result),a++,a<r?d():(t.debug("_generateHashFileNameInWeb","finished loading"),clearTimeout(l),s(c.end()))},u.onerror=e=>{clearTimeout(l),n(e)},d()})}catch(o){t.warn("_generateHashFileNameInWeb",s(o))}return n})}_generateFileNameInMiniProgram(e){return pe(this,void 0,void 0,function*(){const{utils:{MINI_APP_NAMESPACE:t,safeStringify:s,isEmpty:n},ssoLog:o}=this._core;let i="";if(n(e.url))return o.warn("_generateFileNameInMiniProgram","file.url is empty"),i;if("function"!=typeof(null==t?void 0:t.getFileSystemManager))return o.warn("_generateFileNameInUNINativeApp","getFileSystemManager is not a function"),i;try{i=yield new Promise((s,n)=>{t.getFileSystemManager().getFileInfo({filePath:e.url,success:e=>{s(e.digest)},fail:e=>{n(e)}})})}catch(r){o.warn("_generateFileNameInMiniProgram",s(r))}return i})}_generateFileNameInUNINativeApp(e){return pe(this,void 0,void 0,function*(){var t;const{utils:{safeStringify:s,isEmpty:n},ssoLog:o}=this._core;let i="";if(n(e.url))return o.warn("_generateFileNameInUNINativeApp","file.url is empty"),i;if("function"!=typeof(null===(t=null===plus||void 0===plus?void 0:plus.io)||void 0===t?void 0:t.getFileInfo))return o.warn("_generateFileNameInUNINativeApp","plus.io.getFileInfo is not a function"),i;try{i=yield new Promise((t,s)=>{plus.io.getFileInfo({filePath:e.url,success:e=>{t(e.digest)},fail:e=>{s(e)}})})}catch(r){o.warn("_generateFileNameInMiniProgram",s(r))}return i})}_handleUploadProgress(e,t){if("function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(s){throw console.warn("Upload progress callback error:",s),s}}_fetchCosSignatureUrl(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core,n=gr.isSimpleCos(),o=this._prepareCosRequestData(e),i=n?"im_cos_msg.simple_sig":"im_cos_msg.pre_sig";try{const e=yield function(e,t,s){return pe(this,void 0,void 0,function*(){try{const{helper:n,channel:o}=s,i=n.generateCosSpecifiedData({servcmd:e,data:t}),r=`${i.head.seq}${e}`;return yield o.sendPacket(i,{requestId:r})}catch(n){throw console.warn("getCosSig error:",n),n}})}(i,o,this._core);this.fetchCosTryCount=0;const r=this._processResponse(e);return t.debug("_fetchCosSignatureUrl",` ok. isSimpleCos:${n} data:${s(r)}`),r||{}}catch(r){if(this.fetchCosTryCount<1)return this.fetchCosTryCount++,this._fetchCosSignatureUrl(e);throw this.fetchCosTryCount=0,r}})}_processResponse(e){var t;const s=gr.isSimpleCos(),n=s?null===(t=null==e?void 0:e.rpt_pre_sig)||void 0===t?void 0:t[0]:e;if(!n)return{};if(s){const{str_final_ip:e,rpt_pre_sig:t,uint32_file_id:s,uint32_exist_flag:o,str_download_url:i,str_upload_url:r,str_snapshot_url:a,str_file_key:c}=n;return{uploadIP:e,preSig:t,fileID:s,existFlag:o,downloadUrl:i,uploadUrl:r,requestSnapshotUrl:a,fileKey:c}}const{upload_url:o,download_url:i,snapshot_url:r,thumb_url:a,large_url:c,file_key:u}=n;return{uploadUrl:o,downloadUrl:i,requestSnapshotUrl:r,thumbUrl:a,largeUrl:c,fileKey:u}}_prepareCosRequestData(e){return gr.isSimpleCos()?{uint32_upload_method:e.uploadMethod,uint32_platform:gr.getPlatform(),uint32_sdkappid:gr.getSDKAppID(),str_user_id:e.userID,uint32_scene:e.conversationType,rpt_upload_object:[{uint32_file_id:1,uint32_file_type:e.fileType,str_file_name:e.fileName}]}:{file_type:e.fileType,file_name:e.fileName,upload_method:e.uploadMethod,Duration:e.duration}}_uploadFile(e){return pe(this,void 0,void 0,function*(){return new Promise((t,s)=>{this.httpRequest.request(e,(n,o)=>{n&&this.uploadFileTryCount<this.maxRetries&&this.shouldRetry(n)?(this.uploadFileTryCount++,this._uploadFile(e).then(t).catch(s)):(this.uploadFileTryCount=0,n?s(n):t(o))})})})}shouldRetry(e){return!(!e||5!==Math.floor(e.statusCode/100)&&(!this.isTimeRelatedError(e)||!this._isClockOutOfSync(e)||(this._syncSystemClock(e),0)))}isTimeRelatedError(e){var t,s;try{const n=null===(t=e.error)||void 0===t?void 0:t.Code,o=null===(s=e.error)||void 0===s?void 0:s.Message;return"RequestTimeTooSkewed"===n||"AccessDenied"===n&&"Request has expired"===o}catch(n){return!1}}_isClockOutOfSync(e){var t,s,n;const o=(null===(t=e.headers)||void 0===t?void 0:t.date)||(null===(s=e.headers)||void 0===s?void 0:s.Date)||(null===(n=e.error)||void 0===n?void 0:n.ServerTime);if(!o)return!1;const i=Date.now(),r=Date.parse(o);return Math.abs(i+this.systemClockOffset-r)>=3e4}_syncSystemClock(e){var t,s,n;const o=(null===(t=e.headers)||void 0===t?void 0:t.date)||(null===(s=e.headers)||void 0===s?void 0:s.Date)||(null===(n=e.error)||void 0===n?void 0:n.ServerTime);if(o){const e=Date.now(),t=Date.parse(o);this.systemClockOffset=t-e}}_getRawOrUploadProxyUrl(e){const t=gr.getFileUploadProxy();let s=e;return t&&(s=e.replace(/^https:\/\/[^/]+/,t)),s}_isC2CConversation(e){return"C2C"===e.slice(0,3)}};const vr=2108,Ir=2251,Er=2252,Sr=["jpg","jpeg","gif","png","bmp","image","webp"],yr=20971520,Cr={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255};class Mr{constructor(e,t){this.instanceID=Yi(9999999),this.sizeType=e.type||0,this.type=0,this.size=e.size||0,this.width=e.width||0,this.height=e.height||0,this.imageUrl=gr.addAuthToUrl(e.imageUrl||e.url||""),this.url=gr.addAuthToUrl(e.url||t)}setSizeType(e){this.sizeType=e}setType(e){this.type=e}setImageUrl(e){e&&(this.imageUrl=gr.addAuthToUrl(e))}getImageUrl(){return this.imageUrl}}function Ar(e){const{originUrl:t,originWidth:s,originHeight:n,min:o=198}=e,i=parseInt(s)||0,r=parseInt(n)||0,a={url:void 0,width:0,height:0};if((i<=r?i:r)<=o)a.url=t,a.width=i,a.height=r;else{r<=i?(a.width=Math.ceil(i*o/r),a.height=o):(a.width=o,a.height=Math.ceil(r*o/i));const e=t&&t.indexOf("?")>-1?`${t}&`:`${t}?`;a.url=198===o?`${e}imageView2/3/w/198/h/198`:`${e}imageView2/3/w/720/h/720`}return void 0===t?he(a,["url"]):a}class br{constructor(e){this._imageMemoryURL="",this._percent=0,this.type=er;const{uuid:t,file:s,imageFormat:n,imageInfoArray:o=[],isCustomUpload:i=!1}=e;this._imageMemoryURL=this.createImageDataAsURL(s),this.content={imageFormat:n,uuid:t,imageInfoArray:[]},this[hr]=i,this.initImageInfoArray(o),this.autoFixUrl()}static parseServerPushElement(e){const{MsgContent:t}=e,{ImageFormat:s,ImageInfoArray:n,UUID:o}=t,i=n.map(e=>({size:e.Size,type:e.Type,width:e.Width,height:e.Height,url:e.URL}));return new br({imageFormat:s,imageInfoArray:i,uuid:o})}createImageDataAsURL(e){let t="";const{IN_MINI_APP:s,IN_RN_APP:n,IN_BROWSER:o}=gr.getPlatformFlags();return e?((s||n)&&(t=e.url),o&&(t=window.URL.createObjectURL(e)),t):t}initImageInfoArray(e=[]){const t={type:0,size:0,width:0,height:0,url:""};for(let s=0;s<3;s++){const n=e[s]||Object.assign({},t),o=new Mr(n,this._imageMemoryURL);o.setSizeType(s+1),o.setType(s),this.addImageInfo(o)}this.updateAccessSideImageInfoArray()}autoFixUrl(){const e=["http","https"];this.content.imageInfoArray.forEach(t=>{if(!t.url||""===t.imageUrl)return;const[s,...n]=t.imageUrl.split("://"),o=n.join("://");e.includes(s)||t.setImageUrl(`https://${o}`)})}updatePercent(e){this._percent=Math.min(e,1)}updateImageFormat(e){this.content.imageFormat=Cr[e.toUpperCase()]||Cr.UNKNOWN}addImageInfo(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}updateImageInfoArray(e){const t=this.content.imageInfoArray.length;let s;for(let n=0;n<t;n++)s=this.content.imageInfoArray[n],e[n].size&&(s.size=e[n].size),e[n].url&&s.setImageUrl(e[n].url),e[n].width&&(s.width=e[n].width),e[n].height&&(s.height=e[n].height)}updateAccessSideImageInfoArray(){const[e]=this.content.imageInfoArray;e&&0!==e.width&&0!==e.height&&(function(e){const t=e[2];e[2]=e[1],e[1]=t;for(let s=0;s<e.length;s++)e[s].setType(s)}(this.content.imageInfoArray),Object.assign(this.content.imageInfoArray[2],Ar({originWidth:e.width,originHeight:e.height,min:720})))}validateBeforeSend(){if(this[hr])return delete this[hr],{isValid:!0};const[e]=this.content.imageInfoArray,t=!!e&&""!==e.imageUrl&&0!==e.size;return{isValid:t,error:t?null:{message:"content can not be empty"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,imageFormat:o,imageInfoArray:i}=s;return{MsgType:this.type,MsgContent:{ImageFormat:o,ImageInfoArray:this.parseImageInfoArray(i),UUID:n}}}parseImageInfoArray(e){return e.map(e=>({InstanceId:e.instanceID,Type:e.sizeType,MsgType:e.type,Size:e.size,Width:e.width,Height:e.height,URL:gr.removeAuthToUrl(e.imageUrl)}))}}var Tr=new class{constructor(){this._messageOptionsMap=new Map}init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createImageMessage",context:this}),n.registerExperimentalAPI("createImageMessage",this,"createCustomUploadImageMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(er,br),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createImageMessage(e){var t,s,n;try{const o=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,i=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:o})),r=this._processImage(e);e.payload.file=r;const a={imageFormat:Cr.UNKNOWN,uuid:gr.generateUUID(r),file:r,imageInfoArray:[]},c=new br(a);return i.setElement(c),this._messageOptionsMap.set(i.clientSequence,e),i}catch(o){throw o}}createCustomUploadImageMessage(e){var t,s,n,o;const{store:i,utils:{isEmpty:r}}=this._core,a=null===(t=i.get("login"))||void 0===t?void 0:t.userId,c=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:a})),{largeImageUuid:u,largeFileSize:l,largeImageWidth:d,largeImageHeight:h,largeImageUrl:p,originImageUuid:g,originFileSize:_,originImageWidth:m,originImageHeight:f,originImageUrl:v,thumbImageUuid:I,thumbFileSize:E,thumbImageWidth:S,thumbImageHeight:y,thumbImageUrl:C}=(null===(o=null==e?void 0:e.payload)||void 0===o?void 0:o.file)||{};if(r(v)||r(g))throw new Error("createImageMessageExperimental originImageUrl or originImageUuid is empty");const M=new br({imageFormat:Cr.UNKNOWN,uuid:g,imageInfoArray:[{instanceID:g,size:_,width:m,height:f,imageUrl:v,url:v},{instanceID:u,size:l,width:d,height:h,imageUrl:p,url:p},{instanceID:I,size:E,width:S,height:y,imageUrl:C,url:C}],isCustomUpload:!0});return c.setElement(M),this._messageOptionsMap.set(c.clientSequence,e),c._skipUpload=!0,c}upload(e){return pe(this,void 0,void 0,function*(){const t=e.getElements()[0],{file:s}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadImage(s);const n=yield this._performImageUpload(t,e,s),o=this._generateImageInfo(n);return t.updateImageFormat(null==n?void 0:n.fileType),t.updateImageInfoArray(o),e})}_performImageUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:rr,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{uploadOptions:i,response:r}=yield fr.uploadToCOS(o);return this._parseResponse(i,r)})}_generateImageInfo(e){const{location:t,fileSize:s,width:n,height:o,smallImageUrl:i,smallImageWidth:r,smallImageHeight:a,largeImageUrl:c,largeImageWidth:u,largeImageHeight:l,imageInfoArray:d}=e,h=gr.addAuthToUrl(t),p={size:s,url:h,width:n,height:o};return(null==d?void 0:d.length)>0?this._processImageInfoArray(d,s):i&&c?[Object.assign({},p),{largeImageUrl:c,largeImageWidth:u,largeImageHeight:l},{smallImageUrl:i,smallImageWidth:r,smallImageHeight:a}]:[Object.assign({},p),this._generateThumbInfo(h,n,o,720),this._generateThumbInfo(h,n,o,198)]}_generateThumbInfo(e,t,s,n){return Ar({originUrl:e,originWidth:t,originHeight:s,min:n})}_processImageInfoArray(e,t){let s,n,o;for(const i of e)1===i.type?(n=i,n.size=t):2===i.type?(o=i,o.size=t):(s=i,s.size=t);return[Object.assign({},s),Object.assign({},o),Object.assign({},n)]}_parseResponse(e,t){return pe(this,void 0,void 0,function*(){try{const{thumbUrl:s,largeUrl:n,downloadUrl:o}=e;if(s&&n&&(yield this._getImageInfoByUrl(s,t,"thumb"),yield this._getImageInfoByUrl(n,t,"large")),gr.isSimpleCos()&&!gr.isPrivateNetWork()&&(yield this._getImageInfoArray(o,t),null==t?void 0:t.uploadIP)){const e=this._extractDomainFromUrl(o);e&&(yield this._getDownloadIP(e,t))}return t}catch(s){throw s}})}_extractDomainFromUrl(e){var t;try{const t=e.match(/:\/\/([^\/]+)/);return t?t[1]:null}catch(s){return null===(t=this._core)||void 0===t||t.ssoLog.warn("_extractDomainFromUrl",`Failed to extract domain from URL:${s.message}`),null}}_getImageInfoByUrl(e,t,s){return pe(this,void 0,void 0,function*(){var n;try{const n=gr.addAuthToUrl(e),{width:o=0,height:i=0}=yield gr.probeImageWidthHeight(n);t.width=o,t.height=i,"thumb"===s?(t.smallImageUrl=e,t.smallImageWidth=o,t.smallImageHeight=i):(t.largeImageUrl=e,t.largeImageWidth=o,t.largeImageHeight=i)}catch(o){null===(n=this._core)||void 0===n||n.ssoLog.warn("_getImageInfoByUrl",`Failed to get ${s} image info:${o.message}`)}})}_validateBeforeUploadImage(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper;if(!e)throw new s({code:Ir});this._checkImageType(e),this._checkImageSize(e)}_processImage(e){var t;try{const{IN_MINI_APP:s}=null===(t=this._core)||void 0===t?void 0:t.utils;let{file:n}=e.payload;return n=s?this._processMiniAppImageFile(n):this._processWebImageFile(n),n}catch(s){throw s}}_processMiniAppImageFile(e){Ki(e)&&console.warn("FileUnsupportedInMiniApp","createImageMessage");const t=e.tempFiles[0].path||e.tempFiles[0].tempFilePath;return{url:t,name:t.slice(t.lastIndexOf("/")+1),size:e.tempFiles&&e.tempFiles[0].size||1,type:t.slice(t.lastIndexOf(".")+1).toLowerCase()}}_processWebImageFile(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper,n=gr.extractFileFromInput(e);if(!n)throw new s({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return n}_getDownloadIP(e,t){return pe(this,void 0,void 0,function*(){const s=`${or} getDownloadIP domainName: ${e}`;try{const n=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const{helper:s,channel:n}=t,o="im_cos_msg.get_final_ip",i={str_domain:e},r=s.generateProtocolData({servcmd:o,data:i}),a=`${r.head.seq}${o}`;return yield n.sendPacket(r,{requestId:a})}catch(s){throw console.warn("getFinalIP error:",s),s}})}(e,this._core);if(!n||!n.str_final_ip)return;console.log(`${s} ok. downloadIP:${n}`);const o=t.location.split("/");o[0]=n.str_final_ip,t.location=o.join("/")}catch(n){console.warn(n)}})}_getImageInfoArray(e,t){return pe(this,void 0,void 0,function*(){try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const{helper:s,channel:n}=t,o="im_cos_msg.get_imageinfo",i={str_image_url:e},r=s.generateProtocolData({servcmd:o,data:i}),a=`${r.head.seq}${o}`;return yield n.sendPacket(r,{requestId:a})}catch(s){throw console.warn("getImageInfo error:",s),s}})}(e,this._core);return t.imageInfoArray=this._processImageInfoResponse(s),t}catch(s){throw t.imageInfoArray=void 0,s}})}_processImageInfoResponse(e){if(!e)return[];const{rpt_msg_image_info:t}=e;return t.map(e=>({type:e.uint32_image_type,url:e.str_url,width:e.uint32_width,height:e.uint32_height,imageFormat:e.str_image_format}))}_checkImageType(e){const{utils:t,helper:s}=this._core;let n="";if(t.IN_MINI_APP&&(n=e.url.slice(e.url.lastIndexOf(".")+1)),t.IN_BROWSER&&(n=e.name.slice(e.name.lastIndexOf(".")+1)),Sr.indexOf(n.toLowerCase())<0)throw new s.ChatError({code:Er})}_checkImageSize(e){const{utils:t,helper:s}=this._core;let n=0;if(t.IN_MINI_APP,n=e.size,0===n)throw new s.ChatError({code:vr});if(n>=yr)throw new s.ChatError({message:`File size exceeds limit: ${Xi(yr)}`})}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const Or=2108,wr=2401,Dr="2.5.0",Rr="1.18.0",Lr=104857600;function Nr(e,t){const s=e.split("."),n=t.split("."),o=Math.max(s.length,n.length);for(;s.length<o;)s.push("0");for(;n.length<o;)n.push("0");for(let i=0;i<o;i++){const e=parseInt(s[i]),t=parseInt(n[i]);if(e>t)return 1;if(e<t)return-1}return 0}const Pr=new class{init(e){this.core=e}};var kr;class Gr{constructor(e){this.type=sr,this.uploadProgress=0,this[kr]=!1;const t=this._getFileInfo(e);this[hr]=e.isCustomUpload||!1,this.content={downloadFlag:2,fileUrl:gr.generateURL(e.url||e.fileUrl,{needAddAuthToUrl:!this[hr]})||"",uuid:e.uuid,fileName:t.name||"",fileSize:t.size||0}}static parseServerPushElement(e){const{MsgContent:t}=e,{Download_Flag:s,Url:n,FileName:o,FileSize:i,UUID:r}=t;return new Gr({downloadFlag:s,url:n,fileName:o,fileSize:i,uuid:r})}updatePercent(e){this.uploadProgress=Math.min(e,1)}updateFileUrl(e){this.content.fileUrl=e}validateBeforeSend(){if(this[hr])return{isValid:!0};const e=""!==this.content.fileUrl&&""!==this.content.fileName&&this.content.fileSize>0;return{isValid:e,error:e?null:{message:"content can not be empty"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,downloadFlag:o,fileUrl:i,fileName:r,fileSize:a}=s;return{MsgType:this.type,MsgContent:{Download_Flag:o,Url:gr.removeAuthToUrl(i),FileName:r,FileSize:a,UUID:n}}}_getFileInfo(e){const{utils:{IN_UNI_NATIVE_APP:t}}=Pr.core;if(e.fileName&&e.fileSize)return{size:e.fileSize,name:e.fileName};const{file:s}=e;return s?(t&&this._processNativeAppFile(s),{size:s.size,name:s.name}):{size:0,name:""}}_processNativeAppFile(e){if(e.path&&e.path.includes(".")){const t=e.path.slice(e.path.lastIndexOf(".")+1).toLowerCase();e.type=t,e.name||(e.name=`${Yi(999999)}.${t}`)}e.name||(e.type="",e.name=e.path.slice(e.path.lastIndexOf("/")+1).toLowerCase()),e.suffix&&(e.type=e.suffix),e.url||(e.url=e.path)}}kr=hr;var Ur=new class{constructor(){this._messageOptionsMap=new Map}init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createFileMessage",context:this}),n.registerExperimentalAPI("createFileMessage",this,"createCustomUploadFileMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(sr,Gr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createFileMessage(e){var t,s,n;try{this._checkVersion();const o=this._processFile(e.payload.file);e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={uuid:gr.generateUUID(o),file:o},c=new Gr(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(o){throw o}}createCustomUploadFileMessage(e){var t,s,n;try{const{store:o,message:i,utils:{isEmpty:r}}=this._core,a=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{url:c,uuid:u,fileSize:l,fileName:d=""}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{};if(r(c))throw new Error("url is required");const h=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:a})),p=new Gr({url:c,uuid:u,file:{size:l,name:d},isCustomUpload:!0});return h.setElement(p),h}catch(o){throw o}}upload(e){return pe(this,void 0,void 0,function*(){const{file:t}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadFile(t);const s=e.getElements()[0],n=yield this._performFileUpload(s,e,t),o=gr.addAuthToUrl(null==n?void 0:n.location);return s.updateFileUrl(o),e})}_validateBeforeUploadFile(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper;if(!e)throw new s({code:wr});if(e.size>Lr)throw new s({message:`File size exceeds limit: ${Xi(Lr)}`});if(0===e.size)throw new s({code:Or})}_performFileUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:ur,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i}=yield fr.uploadToCOS(o);return i})}_processFile(e){var t,s;const{IN_BROWSER:n,IN_RN_APP:o,IN_WX_MINI_APP:i,IN_QQ_MINI_APP:r,IN_UNI_NATIVE_APP:a}=null===(t=this._core)||void 0===t?void 0:t.utils,{ChatError:c}=null===(s=this._core)||void 0===s?void 0:s.helper;if(n||a){const t=gr.extractFileFromInput(e);if(!t)throw new c({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return t}if(i||r){const{tempFiles:t}=e;return Object.assign(Object.assign({},t[0]),{url:t[0].path})}return o?Object.assign(Object.assign({},e),{url:e.uri}):e}_checkVersion(){var e,t;const{MINI_APP_NAMESPACE:s,IN_MINI_APP:n,IN_WX_MINI_APP:o,IN_QQ_MINI_APP:i,IN_UNI_NATIVE_APP:r}=null===(e=this._core)||void 0===e?void 0:e.utils,{ChatError:a}=null===(t=this._core)||void 0===t?void 0:t.helper;if(n){if(!(o||i||r))throw new a({message:"Unsupported mini app environment"});const e=s.getSystemInfoSync().SDKVersion;if(o&&Nr(e,Dr)<0)throw new a({message:`WXChooseMessageFile requires SDK version ${Dr} or higher`});if(i&&Nr(e,Rr)<0)throw new a({message:`QQChooseMessageFile requires SDK version ${Rr} or higher`})}}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const Fr=2108,xr=2352,$r=["mp4","quicktime","mov"],qr=104857600;var Br;class Vr{constructor(e){this.type=nr,this.uploadProgress=0,this[Br]=!1;const t="number"==typeof(null==e?void 0:e.videoSecond)?null==e?void 0:e.videoSecond:0;this[hr]=e.isCustomUpload||!1,this.content={remoteVideoUrl:gr.addAuthToUrl(e.remoteVideoUrl||e.videoUrl||""),videoFormat:e.videoFormat,videoSecond:parseInt(null==t?void 0:t.toString(),10),videoSize:e.videoSize,videoUrl:gr.addAuthToUrl(e.videoUrl),videoDownloadFlag:2,videoUUID:e.videoUUID,thumbUUID:e.thumbUUID,thumbFormat:e.thumbFormat,thumbWidth:e.thumbWidth,snapshotWidth:e.thumbWidth,thumbHeight:e.thumbHeight,snapshotHeight:e.thumbHeight,thumbSize:e.thumbSize,snapshotSize:e.thumbSize,thumbDownloadFlag:2,thumbUrl:gr.addAuthToUrl(e.thumbUrl),snapshotUrl:gr.addAuthToUrl(e.thumbUrl)}}static parseServerPushElement(e){const{MsgContent:t}=e,{VideoUrl:s,VideoFormat:n,VideoSecond:o,VideoSize:i,VideoDownloadFlag:r,VideoUUID:a,ThumbUUID:c,ThumbFormat:u,ThumbWidth:l,SnapshotWidth:d,ThumbHeight:h,SnapshotHeight:p,ThumbSize:g,SnapshotSize:_,ThumbDownloadFlag:m,ThumbUrl:f,SnapshotUrl:v}=t;return new Vr({videoUrl:s,videoFormat:n,videoSecond:o,videoSize:i,videoDownloadFlag:r,videoUUID:a,thumbUUID:c,thumbFormat:u,thumbWidth:l,snapshotWidth:d,thumbHeight:h,snapshotHeight:p,thumbSize:g,snapshotSize:_,thumbDownloadFlag:m,thumbUrl:f,snapshotUrl:v})}updatePercent(e){this.uploadProgress=Math.min(e,1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=e)}updateSnapshotInfo(e){const{snapshotUrl:t,snapshotWidth:s,snapshotHeight:n}=e;gr.isEmpty(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),gr.isEmpty(s)||(this.content.thumbWidth=this.content.snapshotWidth=Number(s)),gr.isEmpty(n)||(this.content.thumbHeight=this.content.snapshotHeight=Number(n))}validateBeforeSend(){if(this[hr])return{isValid:!0};const e=""!==this.content.remoteVideoUrl;return{isValid:e,error:e?null:{message:"content can not be empty"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{remoteVideoUrl:n,videoFormat:o,videoSecond:i,videoSize:r,videoDownloadFlag:a,videoUUID:c,thumbUUID:u,thumbFormat:l,thumbWidth:d,snapshotWidth:h,thumbHeight:p,snapshotHeight:g,thumbSize:_,snapshotSize:m,thumbDownloadFlag:f,thumbUrl:v,snapshotUrl:I}=s;return{MsgType:this.type,MsgContent:{VideoUrl:gr.removeAuthToUrl(n),VideoFormat:o,VideoSecond:i,VideoSize:r,VideoDownloadFlag:a,VideoUUID:c,ThumbUUID:u,ThumbFormat:l,ThumbWidth:d,SnapshotWidth:h,ThumbHeight:p,SnapshotHeight:g,ThumbSize:_,SnapshotSize:m,ThumbDownloadFlag:f,ThumbUrl:gr.removeAuthToUrl(v),SnapshotUrl:gr.removeAuthToUrl(I)}}}}Br=hr;var Wr,jr=new class{constructor(){this._messageOptionsMap=new Map}init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createVideoMessage",context:this}),n.registerExperimentalAPI("createVideoMessage",this,"createCustomUploadVideoMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(nr,Vr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createVideoMessage(e){var t,s,n;try{const o=this._processVideo(e);e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={videoFormat:o.videoFile.type,videoSecond:Ji(o.videoFile.second,0),videoSize:o.videoFile.size,remoteVideoUrl:"",videoUrl:o.videoFile.url,videoUUID:gr.generateUUID(o.videoFile),thumbUUID:gr.generateUUID(o.videoFile,"jpg"),thumbWidth:o.width||200,thumbHeight:o.height||200,thumbUrl:o.thumbUrl,thumbSize:o.thumbSize,thumbFormat:"jpg"},c=new Vr(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(o){throw o}}createCustomUploadVideoMessage(e){var t,s,n;try{const{store:o,message:i}=this._core;this._validateCustomUploadVideoMessage(e);const r=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{videoUrl:a,videoUuid:c,duration:u,snapshotUrl:l,snapshotUuid:d,videoFileSize:h,videoType:p,snapshotWidth:g,snapshotHeight:_,snapshotFileSize:m,snapshotType:f="jpg"}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{},v=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:r})),I=new Vr({videoFormat:p,videoSecond:u||0,videoSize:h,remoteVideoUrl:a,videoUrl:a,videoUUID:c,thumbUUID:d,thumbWidth:g||200,thumbHeight:_||200,thumbUrl:l,thumbSize:m,thumbFormat:f,isCustomUpload:!0});return v.setElement(I),this._messageOptionsMap.set(v.clientSequence,e),v}catch(o){throw o}}upload(e){return pe(this,void 0,void 0,function*(){const t=e.getElements()[0],{file:s}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadVideo(s);const n=yield this._performVideoUpload(t,e,s),{location:o,snapshotInfo:i}=n,r=gr.addAuthToUrl(o);return t.updateVideoUrl(r),gr.isEmpty(i)||t.updateSnapshotInfo(i),e})}_validateBeforeUploadVideo(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper;if(e.videoFile.size>qr)throw new s({message:`File size exceeds limit: ${Xi(qr)}`});if(0===e.videoFile.size)throw new s({code:Fr});if(-1===$r.indexOf(e.videoFile.type))throw new s({code:xr})}_validateCustomUploadVideoMessage(e){var t;const{utils:{isEmpty:s,isNumber:n}}=this._core,{videoUrl:o,videoUuid:i,duration:r,snapshotUrl:a,snapshotUuid:c}=(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.file)||{};if(s(o)||s(i)||!n(r)||s(a)||s(c))throw new Error("Invalid video message options: missing required fields (videoUrl, videoUuid, duration, snapshotUrl, snapshotUuid)")}_performVideoUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:ar,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i,uploadOptions:r}=yield fr.uploadToCOS(o);return{snapshotInfo:yield this._getSnapshotInfoByUrl(r.requestSnapshotUrl),location:i.location}})}_processVideo(e){var t,s;try{const{ChatError:n}=null===(t=this._core)||void 0===t?void 0:t.helper,{IN_MINI_APP:o,IN_BROWSER:i}=null===(s=this._core)||void 0===s?void 0:s.utils;let{file:r}=e.payload,a={};if(o&&(a=this._processMiniVideoFile(r),r.name=a.name,r.url=a.url,r.type=a.type),i){const e=gr.extractFileFromInput(r);if(!e)throw new n({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});r=e,a=this._processWebVideoFile(r)}return r.videoFile=a,r.thumbUrl="",r.thumbSize=0,r}catch(n){throw console.warn(`${or} _processFile error:`,n),n}}_processMiniVideoFile(e){var t,s;const{IN_ALIPAY_MINI_APP:n,IN_UNI_NATIVE_APP:o}=null===(t=this._core)||void 0===t?void 0:t.utils,{ChatError:i}=null===(s=this._core)||void 0===s?void 0:s.helper;if(n)throw new i({message:"VideoUnsupportedInAlipay"});if(Ki(e))throw new i({message:"FileUnsupportedInMiniApp"});Array.isArray(e.tempFiles)&&(e=e.tempFiles[0]);let r=e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase();return o&&(r=e.fileType||r),{url:e.tempFilePath,name:e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),size:e.size||1,second:e.duration||0,type:r}}_processWebVideoFile(e){const{name:t,size:s=1,duration:n=0,type:o}=e,i=o.split("/")[1];return{url:window.URL.createObjectURL(e),name:t,size:s,second:n,type:i}}_getSnapshotInfoByUrl(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core;try{t.debug("_getSnapshotInfoByUrl",`${or} _getSnapshotInfoByUrl url:${e}`);const s={version:1,platform:gr.getPlatform(),cover_name:Zi(Yi(99999)),snapshot_url:e},n=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const s="im_cos_msg.video_cover",{helper:n,channel:o}=t,i=n.generateCosSpecifiedData({servcmd:s,data:e}),r=`${i.head.seq}${s}`;return yield o.sendPacket(i,{requestId:r})}catch(s){throw console.warn("getSnapshotInfo error:",s),s}})}(s,this._core),{download_url:o}=n||{};if(t.debug("_getSnapshotInfoByUrl",`${or} _getSnapshotInfoByUrl OK snapshotUrl:${o}`),gr.isEmpty(o))return{};const i=gr.addAuthToUrl(o),{width:r=0,height:a=0}=yield gr.probeImageWidthHeight(i);return{snapshotUrl:i,snapshotWidth:r,snapshotHeight:a}}catch(s){throw s}})}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};class Hr{constructor(e){this.uploadProgress=0,this.type=tr,this[Wr]=!1,this[hr]=e.isCustomUpload||!1,this.content={downloadFlag:2,second:e.second,size:e.size,url:gr.generateURL(e.url,{needAddAuthToUrl:!this[hr]}),remoteAudioUrl:gr.addAuthToUrl(e.url||""),uuid:e.uuid}}static parseServerPushElement(e){const{MsgContent:t}=e,{Url:s,Download_Flag:n,Second:o,Size:i,UUID:r}=t;return new Hr({url:s,downloadFlag:n,second:o,size:i,uuid:r})}updatePercent(e){this.uploadProgress=Math.min(e,1)}updateAudioUrl(e){this.content.remoteAudioUrl=e}validateBeforeSend(){if(this[hr])return{isValid:!0};const e=""!==this.content.remoteAudioUrl;return{isValid:e,error:e?null:{message:"content can not be empty"}}}transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,downloadFlag:o,remoteAudioUrl:i,size:r,second:a}=s;return{MsgType:this.type,MsgContent:{Url:gr.removeAuthToUrl(i),Download_Flag:o,Second:a,Size:r,UUID:n}}}}Wr=hr;const Kr=2108,Yr=2300,zr=20971520;var Zr=new class{constructor(){this._messageOptionsMap=new Map}init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createAudioMessage",context:this}),n.registerExperimentalAPI("createAudioMessage",this,"createCustomUploadAudioMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(tr,Hr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}createAudioMessage(e){var t,s,n;try{let{file:o}=e.payload;o=this._processAudioFile(e.payload.file),e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={second:Math.floor((o.duration||o.second)/1e3),size:o.fileSize||o.size||1,url:o.tempFilePath||o.uri||o.url,uuid:gr.generateUUID(o)},c=new Hr(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(o){throw o}}createCustomUploadAudioMessage(e){var t,s,n;try{this._validateCustomUploadOptions(e);const{store:o,message:i}=this._core,r=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{url:a,uuid:c,duration:u,fileSize:l}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{},d=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:r})),h=new Hr({second:u,size:l||1,url:a,uuid:c,isCustomUpload:!0});return d.setElement(h),this._messageOptionsMap.set(d.clientSequence,e),d}catch(o){throw o}}upload(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("upload",`${or} uploadAudio message:${s(e)}`);const{file:n}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadAudio(n);const o=e.getElements()[0],i=yield this._performAudioUpload(o,e,n),r=gr.addAuthToUrl(null==i?void 0:i.location);return o.updateAudioUrl(r),e})}_validateBeforeUploadAudio(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper;if(!e)throw new s({code:Yr});if(e.size>zr)throw new s({message:`File size exceeds limit: ${Xi(zr)}`});if(0===e.size)throw new s({code:Kr})}_performAudioUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:cr,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i}=yield fr.uploadToCOS(o);return i})}_processAudioFile(e){var t;const{IN_MINI_APP:s,IN_BROWSER:n}=null===(t=this._core)||void 0===t?void 0:t.utils;return s?this._processMiniFile(e):n?this._processWebFile(e):void 0}_processMiniFile(e){return{url:e.tempFilePath,name:e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),size:e.fileSize,second:e.duration,type:e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase()}}_processWebFile(e){if(e.tempFilePath||e.uri)return e;const t=URL.createObjectURL(e);return e.tempFilePath=t,e}_validateCustomUploadOptions(e){var t;const{utils:{isEmpty:s}}=this._core,{url:n,uuid:o,duration:i}=(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.file)||{};if(s(n)||s(o)||s(i))throw new Error("Invalid audio message options")}_reset(){this._messageOptionsMap.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const Jr={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},onProgress:{required:!1,rules:["function"],allowEmpty:!1}},Xr={createImageMessage:Jr,createAudioMessage:Jr,createVideoMessage:Jr,createFileMessage:Jr},Qr={createImageMessage:!0,createAudioMessage:!0,createVideoMessage:!0,createFileMessage:!0},ea={[er]:Tr,[sr]:Ur,[nr]:jr,[tr]:Zr};var ta=new class{constructor(){this.name="RichMediaMessage"}install(e){this._core=e;const{constants:{OuterConstant:{MSG_AUDIO:t,MSG_FILE:s,MSG_IMAGE:n,MSG_VIDEO:o}}}=e;Pr.init(e),Tr.init(e),Ur.init(e),jr.init(e),Zr.init(e),fr.init(e),gr.init(e),e.helper.registerApi({apiName:"sendMessage",context:this,matcher:e=>[t,s,n,o].includes(e[0].type)}),e.helper.registerValidateConfig({auth:Qr,params:Xr})}sendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;try{return this._isCustomUpload(e)||(yield this._upload(e)),yield null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(e,t)}catch(i){throw i}})}_upload(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(t.debug("_upload",` uploadFile message:${s(e)}`),!0!==e._relayFlag)try{const s=ea[e.type];s&&(yield s.upload(e),t.info("_upload",` type:${e.type}`))}catch(n){throw e.status=lr.FAIL,n instanceof Error&&(n.data={message:e}),this._core.message.messageDataHandler.storeConversationMessage(e),n}})}_isCustomUpload(e){var t,s;return!0===(null===(s=null===(t=e._elements)||void 0===t?void 0:t[0])||void 0===s?void 0:s[hr])}};const sa=new class{init(e){this.core=e}},na=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=sa;return s(e)&&e.slice(0,3)===t.CONV_C2C},oa=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=sa;return s(e)&&e.slice(0,5)===t.CONV_GROUP},ia=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=sa;return s(e)&&e===t.CONV_SYSTEM},ra=e=>({lastTime:(null==e?void 0:e.time)||(null==e?void 0:e.lastTime)||0,lastSequence:(null==e?void 0:e.sequence)||(null==e?void 0:e.lastSequence)||0,fromAccount:(null==e?void 0:e.from)||(null==e?void 0:e.fromAccount)||"",messageForShow:sa.core.common.getMessagePreviewText(null==e?void 0:e.type,null==e?void 0:e.payload),payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",onlineOnlyFlag:(null==e?void 0:e._onlineOnlyFlag)||!1,nick:(null==e?void 0:e.nick)||"",nameCard:(null==e?void 0:e.nameCard)||"",version:(null==e?void 0:e.version)||0,isPeerRead:(null==e?void 0:e.isPeerRead)||!1,revoker:(null==e?void 0:e.revoker)||null});function aa(e){const{OuterConstant:t}=sa.core;let s="";return 0===e?s=t.MSG_REMIND_ACPT_AND_NOTE:1===e?s=t.MSG_REMIND_DISCARD:2===e?s=t.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(s=t.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),s}function ca(e){const{OuterConstant:t}=sa.core;let s;return e.startsWith(t.CONV_C2C)&&(s=e.replace(t.CONV_C2C,"")),"@TLS#ERROR"===s||"@TLS#NOT_FOUND"===s}function ua(e,t){const{helper:s}=sa.core,n=new s.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(`${e} fail:`,n),n}class la{constructor(e){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=ra(e.lastMessage),this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark=e.remark||"",this.isPinned=e.isPinned||!1,this.messageRemindType=e.messageRemindType,this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this.draftText=e.draftText||"",this.userProfile=e.userProfile,this.groupProfile=e.groupProfile,this.subType=e.subType||"",this._isInfoCompleted=!1,this._init()}_init(){const{core:{OuterConstant:e,utils:{isUndefined:t}}}=sa;t(this.userProfile)&&this.type===e.CONV_C2C?this.userProfile={}:t(this.groupProfile)&&this.type===e.CONV_GROUP&&(this.groupProfile={}),this.subType&&this.type===e.CONV_GROUP&&(this.subType=this.groupProfile.type||"")}updateUnreadCount(e){const{core:{OuterConstant:t,utils:{isUndefined:s}}}=sa,{nextUnreadCount:n,isFromGetConversations:o,isUnreadC2CMessage:i}=e;s(n)||(this.subType!==t.GRP_AVCHATROOM?o&&this.type===t.CONV_GROUP||i&&this.type===t.CONV_C2C?this.unreadCount=n:this.unreadCount+=n:this.unreadCount=0)}updateLastMessage(e){this.lastMessage=ra(e)}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked(e){const{core:{OuterConstant:t}}=sa,{sequence:s,time:n}=e;return this.type===t.CONV_C2C&&s===this.lastMessage.lastSequence&&n===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&s===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}setDraftText(e){this.draftText=e}updateGroupAtInfoList(e){const{core:{common:{updateGroupAtInfo:t}}}=sa;t(e,this.groupAtInfoList)}clearGroupAtInfoList(){this.groupAtInfoList.length=0}getProfileCompleted(){return this._isInfoCompleted}setProfileCompleted(){this._isInfoCompleted=!0}}var da,ha,pa;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON"}(da||(da={})),function(e){e[e.ONLY_CONVERSATIONID=1]="ONLY_CONVERSATIONID"}(ha||(ha={})),function(e){e[e.CONV_NOT_FOUND=2500]="CONV_NOT_FOUND",e[e.USER_OR_GRP_NOT_FOUND=2501]="USER_OR_GRP_NOT_FOUND",e[e.CONV_UN_RECORDED_TYPE=2502]="CONV_UN_RECORDED_TYPE"}(pa||(pa={}));const ga=0,_a=1;var ma=new class{constructor(){this._name="ConversationDataHandler",this._totalUnreadCount=0,this._groupAtTipsList=[]}init(e){this._core=e;const{helper:t,notificationCenter:s,appStore:{conversationStore:n},constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i},InnerEvent:{SYNC_CONVERSATION_LIST:r,MESSAGE_PUSH:a,NEW_MESSAGE:c,MESSAGE_DELETED:u,MESSAGE_REVOKED:l,MESSAGE_MODIFIED:d,CONVERSATION_UPDATED:h,LOGOUT:p,DESTROY:g},InnerEventSubType:{C2C_MESSAGE_PEER_READ:_}}=e;this._conversationStore=n,t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,this._handleGroupListSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),t.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_GROUP_NEW_MESSAGE,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_RE_ONLINE,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_GROUP_TIPS_NOTIFICATION,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this);const{InnerEventSubType:{GROUP_AT_TIPS:m}}=s;s.subscribeInnerEvent(r,this._handleConversationSynced,this),s.subscribeInnerEvent(c,this._handleNewMessage,this),s.subscribeInnerEvent(a,m,this._handleNewGroupAtTips,this),s.subscribeInnerEvent(u,this._handleMessageDeleted,this),s.subscribeInnerEvent(l,this._handleMessageRevoked,this),s.subscribeInnerEvent(d,this._handleMessageModified,this),s.subscribeInnerEvent(h,this._handleConversationUpdated,this),s.subscribeInnerEvent(a,_,this._handleMessageRead,this),s.subscribeInnerEvent(p,this._reset,this),s.subscribeInnerEvent(g,this._dispose,this),e.ssoLog.debug(`${this._name}.init`)}_handleConversationSynced(e){this.updateLocalConversationList({conversationUpdateFieldList:e.conversationUpdateFieldList||[],isFromGetConversations:!0,updateUnreadCount:!0}),this.emitConversationListUpdate()}_handleUnreadSyncFinished(e){const{constants:{WORKFLOW_STEP:t}}=this._core,{conversationUpdateFieldList:s=[],groupTipList:n=[],isUnreadC2CMessage:o}=e.result[t.UNREAD_MESSAGE_SYNC]||{};let i=!1;s.forEach(e=>{const{conversationID:t,unreadCount:s}=e,n=this.getLocalConversation(t);n&&n.unreadCount!==s&&(n.updateUnreadCount({nextUnreadCount:s,isUnreadC2CMessage:o}),i=!0)}),i&&this.emitConversationListUpdate(),this._handleGroupAtTipsSynced(n)}_handleGroupAtTipsSynced(e){var t;for(let s=0;s<e.length;s++)if(12===e[s].Event){if(null===(t=e[s].GroupTips[0].MsgBody)||void 0===t?void 0:t.TopicId)continue;this._handleNewGroupAtTips(e[s])}}_handleGroupListSyncFinished(e){var t;const{constants:{WORKFLOW_STEP:s}}=this._core,n=e.result[s.GROUP_LIST_SYNC]||[],{OuterConstant:{CONV_GROUP:o}}=this._core;let i=!1;for(let r=0;r<n.length;r++){const e=n[r],s=`${o}${e.groupID}`;if(!this.hasLocalConversation(s))continue;const a=this.getLocalConversation(s);a.groupProfile=JSON.parse(JSON.stringify(e)),a.lastMessage.lastSequence<e.nextMessageSeq&&(a.lastMessage.lastSequence=e.nextMessageSeq-1),a.subType||(a.subType=e.type),(null===(t=e._groupAtInfoList)||void 0===t?void 0:t.length)>0&&this._handleNewGroupAtTips({GroupTips:e._groupAtInfoList}),i=!0}i&&this.emitConversationListUpdate()}_handleNewMessage(e){const{conversationUpdateFieldList:t=[],isInstantMessage:s=!0,isUnreadC2CMessage:n=!1,updateUnreadCount:o=!0}=e.result||{};if(0===t.length)return;const{common:{isTopic:i}}=this._core;i(t[0].conversationID)||(this.updateLocalConversationList({conversationUpdateFieldList:t,isInstantMessage:s,isUnreadC2CMessage:n,isFromGetConversations:!1,updateUnreadCount:o}),t.filter(e=>this._isConversationNeedShow(e.conversationID)).length>0&&this.emitConversationListUpdate())}_handleNewGroupAtTips(e){const{GroupTips:t=[]}=e;t.forEach(e=>{const{GroupAtTips:t,MsgBody:s,MsgRandom:n,ClientSeq:o}=e;let i={};t?i=this._convertGroupAtTipsKey(t):s?i=Object.assign({},this._convertGroupAtTipsKey(s)):e.groupAtType&&(i=Object.assign({},e)),i.__random=n,i.__sequence=o,this._groupAtTipsList.push(i)}),console.log(`${this._name}._handleNewGroupAtTips groupAtTipsList: ${JSON.stringify(this._groupAtTipsList)}`),this._updateGroupAtInfoList()}_convertGroupAtTipsKey(e){const{From_Account:t,GroupId:s,MsgSeq:n,GroupAtType:o}=e;return{from:t,groupID:s,sequence:n,groupAtType:o}}_updateGroupAtInfoList(){if(0===this._groupAtTipsList.length)return;const{common:e,OuterConstant:t}=this._core,s=e.getCurrentUserID();let n=!1;this._groupAtTipsList.forEach(e=>{const{groupID:o,from:i}=e;if(i!==s){const s=this.getLocalConversation(`${t.CONV_GROUP}${o}`);s&&(s.updateGroupAtInfoList(e),n=!0)}}),n&&this.emitConversationListUpdate(),this._groupAtTipsList.length=0}_handleMessageDeleted(e){var t,s;console.log(`${this._name}._handleMessageDeleted, conversationID:`,e);const{message:{messageDataHandler:n},OuterConstant:o}=this._core,i=(null==n?void 0:n.getLocalMessageList(e))||[];let r={};for(let u=(i.length||0)-1;u>=0;u--)if(!i[u].isDeleted){r=i[u];break}const a=this.getLocalConversation(e);if(!a)return;let c=!1;a.lastMessage.lastSequence===r.sequence&&a.lastMessage.lastTime===r.time||((null===(s=null===(t=this._core)||void 0===t?void 0:t.helper)||void 0===s?void 0:s.isEmpty(r))&&(r=void 0),a.updateLastMessage(r),c=!0),e.startsWith(o.CONV_C2C)&&this.updateUnreadCount(e),c&&(this.emitConversationListUpdate(),console.log(`${this._name}._handleMessageDeleted. update conversationID:${e} with lastMessage:`,a.lastMessage))}_handleMessageRevoked(e){const{messageList:t=[],updateUnreadCount:s=!0}=e;if(console.log(`${this._name}._handleMessageRevoked messageList:${t.length}`),0===t.length)return;let n=null,o=!1;t.forEach(e=>{n=this.getLocalConversation(e.conversationID),n&&(s&&n.reduceUnreadCount()&&(o=!0),n.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(n.setLastMessageRevoked(!0),n.setLastMessageRevoker(e.revoker),o=!0))}),o&&this.emitConversationListUpdate()}_handleMessageModified(e){console.log(`${this._name}._handleMessageModified`,JSON.stringify(e));const{conversationID:t,messageList:s}=e,n=this.getLocalConversation(t),{utils:{isEmpty:o},common:{getMessagePreviewText:i}}=this._core;if(o(n))return;const{lastMessage:r}=n;if(r){const e=(null==s?void 0:s[0])||{};r.lastTime===e.time&&r.lastSequence===e.sequence&&r.version!==e.version&&(r.type=e.type,r.payload=e.payload,r.messageForShow=i(e.type,e.payload),r.cloudCustomData=e.cloudCustomData,r.version=e.version,this.emitConversationListUpdate(),console.log(`${this._name} conversationID:${t} lastMessage updated`))}}_handleConversationUpdated(e){this.emitConversationListUpdate(null==e?void 0:e.needSort)}updateLocalConversationList(e){const{isFromGetConversations:t}=e,{newConversationList:s}=this._getTmpConversationListMapping(e);this._sortConversationList(),t||this._updateNewConversationProfile(s),this._core.ssoLog.debug("updateLocalConversationList",` newConversationList: ${s.length}`)}_getTmpConversationListMapping(e){const{OuterConstant:t}=this._core,{conversationUpdateFieldList:s,isFromGetConversations:n,isInstantMessage:o,isUnreadC2CMessage:i=!1,updateUnreadCount:r}=e,a=[],c=null==s?void 0:s.length;for(let u=0;u<c;u++){const e=new la(s[u]),{conversationID:c,type:l}=e;if(!ca(c))if(this.hasLocalConversation(c)){const a=this.getLocalConversation(c);if(n){this.setLocalConversation(c,e),l===t.CONV_C2C?e.unreadCount=(null==a?void 0:a.unreadCount)||0:l===t.CONV_GROUP&&(e.groupProfile=JSON.parse(JSON.stringify(null==a?void 0:a.groupProfile)));continue}this._mergeConversationInfo({conversationID:c,tmpConversation:e,lastMessage:s[u].lastMessage,isFromGetConversations:n,isInstantMessage:o}),this._patchLastMessage({conversationID:c,lastMessage:s[u].lastMessage,isInstantMessage:o}),!0===r&&(null==a||a.updateUnreadCount({nextUnreadCount:e.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:i}))}else a.push(e),this.setLocalConversation(c,e)}return{newConversationList:a}}_mergeConversationInfo(e){const{conversationID:t,tmpConversation:s,lastMessage:n,isFromGetConversations:o,isInstantMessage:i}=e,r=this.getLocalConversation(t),a=["unreadCount","allowType","adminForbidType","payload"];!1===i&&a.push("lastMessage"),o&&a.push("isPinned");const{utils:{isUndefined:c,isEmpty:u},common:{deepMerge:l}}=this._core;c(i)&&n&&null===(null==r?void 0:r.lastMessage.payload)&&(r.lastMessage.payload=n.payload),u(null==r?void 0:r.lastMessage.revoker)||(r.lastMessage.revoker=null),l(r,s,a,[null,void 0,"",0,NaN])}_patchLastMessage(e){const{OuterConstant:t}=this._core,{conversationID:s,lastMessage:n,isInstantMessage:o}=e,i=this.getLocalConversation(s);if(i&&n){const{payload:e,nameCard:s,nick:r,cloudCustomData:a=""}=n;o&&(e&&(i.lastMessage.payload=e),i.type===t.CONV_GROUP&&(i.lastMessage.nameCard=s,i.lastMessage.nick=r)),i.lastMessage.cloudCustomData!==a&&(i.lastMessage.cloudCustomData=a)}}_sortConversationList(){const{utils:{isEmpty:e}}=this._core,t=[...this._conversationStore.getConversationMap()],s=[],n=[],o=[],i=[];t.forEach(t=>{!0===t[1].isPinned?e(t[1].lastMessage.lastTime)?n.push(t):s.push(t):e(t[1].lastMessage.lastTime)?i.push(t):o.push(t)});const r=s.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime).concat(n).concat(o.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(i);this._updateConversationMapFromList(r)}_updateNewConversationProfile(e){if(0===e.length)return;const t=[],s=[],{OuterConstant:{CONV_GROUP:n,CONV_C2C:o}}=this._core;e.forEach(e=>{const{conversationID:i,type:r}=e;if(r===o){const e=i.replace(o,"");t.push(e)}else if(r===n){const e=i.replace(n,"");s.push(e)}}),t.length>0&&this._updateC2CConversation(t),s.length>0&&this._updateGroupConversation(s)}_updateC2CConversation(e){var t;const{OuterConstant:{CONV_C2C:s},appStore:{userStore:n},user:o}=this._core;let i=!1;null===(t=o.userProfile)||void 0===t||t.getUserProfile({userIDList:e}).then(e=>{((null==e?void 0:e.data)||[]).forEach(e=>{var t;const{userID:o}=e,r=this.getLocalConversation(`${s}${o}`);if(r){const s=(null===(t=n.getFriend(o))||void 0===t?void 0:t.remark)||"";r.remark=s,r.userProfile=e,i=!0}}),i&&this.emitConversationListUpdate()}).catch(e=>{})}_updateGroupConversation(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:{CONV_GROUP:t},appStore:{groupStore:s},utils:{isEmpty:n,safeStringify:o},ssoLog:i,apiMap:{getGroupProfile:r}}=this._core;let a=!1;try{yield Promise.all(e.map(e=>pe(this,void 0,void 0,function*(){const o=s.getGroup(e),i=this.getLocalConversation(`${t}${e}`);o&&i&&(i.groupProfile=o,a=!0),n(o)&&i&&"function"==typeof r&&(yield r({groupID:e}))}))),a&&this.emitConversationListUpdate()}catch(c){i.debug("_updateGroupConversation",o(c))}})}_handleMessageRead(e){const{OuterConstant:{CONV_C2C:t}}=this._core,{C2cNotifyMsgArray:s=[]}=e||{};s.forEach(e=>{const{To_Account:s,UinPairReadArray:n=[]}=(null==e?void 0:e.C2cReadedReceipt)||{};null==n||n.forEach(e=>{const{LastReadTime:n}=e,o=`${t}${s}`;this._updateConversationReadInfo({conversationID:o,peerReadTime:n}),this._updateMessageListPeerRead({conversationID:o,peerReadTime:n})})})}_updateConversationReadInfo(e){const{appStore:t,utils:{isEmpty:s},common:{getCurrentUserID:n}}=this._core,{conversationID:o,peerReadTime:i}=e,r=t.conversationStore.getConversationMap();if(r.has(o)){const e=r.get(o);e.peerReadTime=i;const a=null==e?void 0:e.lastMessage;s(a)||a.fromAccount===n()&&a.lastTime<=i&&!a.isPeerRead&&(a.isPeerRead=!0,t.conversationStore.updateConversation(o,{lastMessage:a}))}}_updateMessageListPeerRead(e){const{notificationCenter:t,OuterEvent:s,message:n}=this._core,{conversationID:o,peerReadTime:i}=e,r=n.messageDataHandler.getLocalMessageList(o),a=n.messageDataHandler.getSparseMessageList(o),c=[];r.forEach(e=>{e.time<=i&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,c.push(e))}),a.forEach(e=>{e.time<=i&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,c.push(e))}),t.emitOuterEvent(s.MESSAGE_READ_BY_PEER,{name:s.MESSAGE_READ_BY_PEER,data:c})}_isConversationNeedShow(e){var t,s;const{OuterConstant:{CONV_GROUP:n,GRP_ROOM:o,GRP_LIVE:i},utils:{isUndefined:r}}=this._core,a=this.getLocalConversation(e);if(r(a))return!0;const c=a.type===n&&(null===(t=a.groupProfile)||void 0===t?void 0:t.type)===o,u=a.type===n&&(null===(s=a.groupProfile)||void 0===s?void 0:s.type)===i;return!(c||u)}updateUnreadCount(e,t=!0){var s,n;let o=!1;const i=this.getLocalConversation(e),r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageDataHandler)||void 0===n?void 0:n.getLocalMessageList(e);if(!i)return o;const a=i.unreadCount,c=null==r?void 0:r.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;return console.log(`${this._name}._updateUnreadCount conversationID:${e} currentUnreadCount:${a} newUnreadCount:${c}`),a!==c&&(i.unreadCount=c,o=!0,!0===t&&this.emitConversationListUpdate()),o}emitConversationListUpdate(e=!1){e&&this._sortConversationList();const{OuterEvent:{CONVERSATION_LIST_UPDATED:t}}=this._core,s=this.getLocalConversationList();this._emitEvent({name:t,data:s}),this._emitTotalUnreadCountUpdate()}_emitTotalUnreadCountUpdate(){var e;const t=this.getTotalUnreadMessageCount();this._totalUnreadCount!==t&&(this._core.ssoLog.debug("_emitTotalUnreadCountUpdate",` from ${this._totalUnreadCount} to ${t}`),this._totalUnreadCount=t,this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.OuterEvent.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,data:t}))}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}getTotalUnreadMessageCount(){const{OuterConstant:e,utils:{isEmpty:t}}=this._core,s=this.getLocalConversationList();let n=0;return s.forEach(s=>{s.type!==e.CONV_SYSTEM&&(t(s.messageRemindType)||s.messageRemindType===e.MSG_REMIND_ACPT_AND_NOTE)&&(n+=s.unreadCount)}),n}getLocalConversationList(){return[...this._conversationStore.getConversationMap().values()].filter(e=>this._isConversationNeedShow(e.conversationID))}hasLocalConversation(e){return this._conversationStore.getConversationMap().has(e)}getLocalConversation(e){return this._conversationStore.getConversationMap().get(e)}setLocalConversation(e,t){return this._conversationStore.getConversationMap().set(e,t)}deleteLocalConversation(e){this._conversationStore.getConversationMap().delete(e)}_updateConversationMapFromList(e){this._clearConversationMap();for(const[t,s]of e)this.setLocalConversation(t,s)}_clearConversationMap(){this._conversationStore.getConversationMap().clear()}patchMessageRemindType(e,t){let s=!1;e.forEach(e=>{const n=this.getLocalConversation(e);(null==n?void 0:n.messageRemindType)!==t&&(n.messageRemindType=t,s=!0)}),console.log(`${this._name}.patchMessageRemindType conversationIDList:${e} messageRemindType:${t} hasUpdated:${s}`),s&&this.emitConversationListUpdate()}markMessageAsRead(e){const{message:{messageDataHandler:t}}=this._core,{conversationID:s,lastReadTime:n=0,lastReadSequence:o=0}=e,i=null==t?void 0:t.getLocalMessageList(s);if(0===i.length)return;const{length:r}=i;for(let a=r-1;a>=0;a--){const e=i[a],t=n&&e.time>n,s=o&&e.sequence>o;if(!t&&!s){if("in"===e.flow&&e.isRead)break;e.setIsRead(!0)}}}appendToPinnedConversation(e){const t=[...this._conversationStore.getConversationMap().entries()],s=t.findIndex(e=>!1===e[1].isPinned);t.splice(s,0,[e.conversationID,e]),this._updateConversationMapFromList(t),this.emitConversationListUpdate()}_reset(){this._clearConversationMap(),this._totalUnreadCount=0,this._groupAtTipsList=[]}_dispose(){const{notificationCenter:e,InnerEvent:{NEW_MESSAGE:t,MESSAGE_DELETED:s,MESSAGE_REVOKED:n,MESSAGE_MODIFIED:o,CONVERSATION_UPDATED:i,LOGOUT:r,DESTROY:a,SYNC_CONVERSATION_LIST:c}}=this._core,{InnerEventSubType:{GROUP_AT_TIPS:u}}=e;e.unSubscribeInnerEvent(t,this._handleNewMessage,this),e.unSubscribeInnerEvent(t,u,this._handleNewGroupAtTips,this),e.unSubscribeInnerEvent(s,this._handleMessageDeleted,this),e.unSubscribeInnerEvent(n,this._handleMessageRevoked,this),e.unSubscribeInnerEvent(o,this._handleMessageModified,this),e.unSubscribeInnerEvent(i,this._handleConversationUpdated,this),e.unSubscribeInnerEvent(c,this._handleConversationSynced,this),e.unSubscribeInnerEvent(r,this._reset,this),e.unSubscribeInnerEvent(a,this._dispose,this)}},fa=new class{constructor(){this._name="GetConversationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getConversationList",context:this})}getConversationList(e){return pe(this,void 0,void 0,function*(){return{code:0,data:{conversationList:this._getConversationList(e),isSyncCompleted:this._core.conversation.syncConversationHandler.isSyncCompleted()}}})}_getConversationList(e){const{utils:{isUndefined:t,isArray:s,isPlainObject:n}}=this._core;if(t(e))return ma.getLocalConversationList();if(s(e))return 0===e.length?[]:ma.getLocalConversationList().filter(t=>e.includes(t.conversationID));if(n(e)){const{type:t,markType:s,groupName:n,hasUnreadCount:o,hasGroupAtInfo:i}=e;return ma.getLocalConversationList().filter(e=>this._filterType(e,t)&&this._filterMarkType(e,s)&&this._filterGroupName(e,n)&&this._filterUnreadCount(e,o)&&this._filterGroupAtInfo(e,i))}return[]}_filterType(e,t){const{OuterConstant:s}=this._core;return t!==s.CONV_C2C&&t!==s.CONV_GROUP||e.type===t}_filterGroupName(e,t){const{utils:{isString:s}}=this._core;return!s(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}_filterMarkType(e,t){const{utils:{isNumber:s}}=this._core;return!s(t)||(0===t?0===e.markList.length:e.markList.includes(t))}_filterUnreadCount(e,t){let s=!0;return!0===t?s=e.unreadCount>=1:!1===t&&(s=0===e.unreadCount),s}_filterGroupAtInfo(e,t){let s=!0;return!0===t?s=e.groupAtInfoList.length>=1:!1===t&&(s=0===e.groupAtInfoList.length),s}},va=new class{constructor(){this._name="GetC2CMessageRemindType"}init(e){this._core=e}get(e){return pe(this,void 0,void 0,function*(){try{const{common:t}=this._core,s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{toAccount:s,userIDList:n}=e,o={To_Account:s,Peer_Account:n};return t.common.buildAndSendPacket({servcmd:"openim.get_c2c_peer_mute_notifications",data:o})})}({toAccount:t.getCurrentUserID(),userIDList:e},this._core),{MuteNotificationsList:n=[]}=s||{};n.forEach(e=>{const{Peer_Account:t,MuteNotifications:s}=e,n=`${this._core.OuterConstant.CONV_C2C}${t}`,o=aa(s);ma.patchMessageRemindType([n],o)})}catch(t){console.error(`${this._name}.get fail:`,t)}})}},Ia=new class{constructor(){this._name="GetGroupMessageRemindType"}init(e){this._core=e}get(e){return pe(this,void 0,void 0,function*(){if(0!==e.length)try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupIDList:s,responseFilter:n}=e,o={GroupIdList:s,ResponseFilter:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}({groupIDList:e,responseFilter:{MemberInfoFilter:["MsgFlag"]}},this._core),{GroupInfo:s=[]}=t||{};s.forEach(e=>{var t;const{GroupId:s,MemberList:n}=e,o=(null===(t=n[0])||void 0===t?void 0:t.MsgFlag)||"",i=`${this._core.OuterConstant.CONV_GROUP}${s}`;ma.patchMessageRemindType([i],o)})}catch(t){console.error(`${this._name}.get fail:`,t)}})}},Ea=new class{constructor(){this._name="GetConversationProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getConversationProfile",context:this})}getConversationProfile(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,GRP_AVCHATROOM:n},appStore:{groupStore:o},utils:{isEmpty:i}}=this._core,r={code:0,data:{}};let a=ma.getLocalConversation(e);if(ia(e))return r.data.conversation=a,r;let c=!1;const u=na(e)?t:s;if(i(a)&&(c=!0,a=new la({conversationID:e,type:u})),console.log(`${this._name}.getConversationProfile conversationID:${e} isNewConversation:${c}`),r.data.conversation=a,null==a?void 0:a.getProfileCompleted())return r;if(u===t){const s=e.replace(t,"");yield this._handleC2CConversation(a,s),c&&(yield va.get([s]))}if(u===s){const t=e.replace(s,"");if(!o.getGroup(t))return r;yield this._handleGroupConversation(a,t),c&&a.groupProfile.type!==n&&(yield Ia.get([t]))}return r})}_handleC2CConversation(e,t){return pe(this,void 0,void 0,function*(){var s,n;const{user:o,helper:i,utils:{isEmpty:r},appStore:{conversationStore:a,userStore:c}}=this._core,{conversationID:u}=e,l=yield null===(s=o.userProfile)||void 0===s?void 0:s.getUserProfile({userIDList:[t]});if(0===(null==l?void 0:l.data.length))throw new i.ChatError({code:pa.USER_OR_GRP_NOT_FOUND});e.userProfile=null==l?void 0:l.data[0];const d=null===(n=c.getFriend(t))||void 0===n?void 0:n.remark;r(d)||e.remark===d||(e.remark=d),e.setProfileCompleted();const h=ma.hasLocalConversation(u);console.log(`${this._name}._handleC2CConversation conversationID:${u} hasLocalConversation: ${h}`),h?a.updateConversation(u,e):ma.appendToPinnedConversation(e)})}_handleGroupConversation(e,t){return pe(this,void 0,void 0,function*(){const{apiMap:{getGroupProfile:s},appStore:{conversationStore:n}}=this._core,{conversationID:o}=e,i=yield s({groupID:t});e.groupProfile=null==i?void 0:i.data.group,e.setProfileCompleted();const r=ma.hasLocalConversation(o);console.log(`${this._name}._handleGroupConversation conversationID:${o} hasLocalConversation: ${r}`),r?n.updateConversation(o,e):ma.appendToPinnedConversation(e)})}},Sa=new class{init(e){const{helper:t}=e;t.registerApi({apiName:"getTotalUnreadMessageCount",context:this})}getTotalUnreadMessageCount(){return ma.getTotalUnreadMessageCount()}},ya=new class{constructor(){this._serverGroupConversationLastReadSeqMap=new Map,this._name="SetMessageRead"}init(e){this._core=e;const{helper:t,common:{isTopic:s},notificationCenter:n,InnerEvent:{MESSAGE_PUSH:o},InnerEventSubType:{ALL_MESSAGE_READ:i}}=e;t.registerApi({apiName:"setMessageRead",context:this,matcher:e=>!s(e[0].conversationID)}),t.registerApi({apiName:"setAllMessageRead",context:this}),n.subscribeInnerEvent(o,i,this._handleAllMessageRead,this)}handleC2CMessageReadSync(e){const{helper:{isEmpty:t},OuterConstant:s}=this._core;e.forEach(e=>{const{ReadC2cMsgNotify:n}=e;if(!t(n)){const{UinPairReadArray:e=[]}=n;e.forEach(e=>{const{From_Account:t,LastReadTime:n}=e,o=`${s.CONV_C2C}${t}`;console.log(`${this._name}.handleC2CMessageReadSync conversationID:${o} lastReadTime:${n}`),ma.markMessageAsRead({conversationID:o,lastReadTime:n}),ma.updateUnreadCount(o)})}})}handleGroupMessageReadSync(e){const{OuterConstant:t,utils:{isUndefined:s}}=this._core;e.forEach(e=>{const{GroupReadInfoArray:n}=e.MsgBody;s(n)||n.forEach(e=>{const{GroupId:s,LastReadMsgSeq:n}=e,o=`${t.CONV_GROUP}${s}`;console.log(`${this._name}.handleGroupMessageReadSync conversationID:${o} lastReadSequence:${n}`),ma.markMessageAsRead({conversationID:o,lastReadSequence:n}),ma.updateUnreadCount(o),this._clearGroupAtInfoList(o)})})}setMessageRead(e){return pe(this,void 0,void 0,function*(){var t,s;const{OuterConstant:n}=this._core,{conversationID:o}=e,i={code:0,data:{}},r=ma.getLocalConversation(o);let a=`${this._name}.setMessageRead conversationID:${o} unreadCount:${(null==r?void 0:r.unreadCount)||0}`;if(i.successLog={message:a},!r)return i;const c=!(null===(s=null===(t=this._core)||void 0===t?void 0:t.helper)||void 0===s?void 0:s.isEmpty(r.groupAtInfoList));if(r.type===n.CONV_GROUP&&c&&this._deleteGroupAtTips(o),0===r.unreadCount)return i;const{helper:{ChatError:u}}=this._core;try{if(r.type===n.CONV_C2C){const e=this._getLocalMessageMaxTime(r);yield this._setC2CMessageRead(o,e),a+=`lastMessageTime:${e}`}if(r.type===n.CONV_GROUP){const e=this._getLocalMessageMaxSequence(r);yield this._setGroupMessageRead(o,e),a+=`lastMessageSequence:${e}`}}catch(l){const{errorCode:e,errorInfo:t}=l;throw new u({functionName:"setMessageRead",code:e,message:t,moreMessage:a})}return r.type===n.CONV_SYSTEM&&(r.unreadCount=0),ma.emitConversationListUpdate(),Object.assign(Object.assign({},i),{successLog:{message:a}})})}setAllMessageRead(){return pe(this,arguments,void 0,function*(e={}){const{OuterConstant:{READ_ALL_MSG:t},utils:{safeStringify:s}}=this._core;let n=`scope:${e.scope}`;e.scope||(e.scope=t);const{scope:o}=e,i=this._generateSetAllMessageReadRequestData(o);if(i.allC2CMessageReadStatus===ga&&0===i.groupMessageReadInfoList.length)return{code:0};try{const e=yield function(e){return pe(this,void 0,void 0,function*(){const{allC2CMessageReadStatus:t,groupMessageReadInfoList:s}=e,n={C2CReadAllMsg:t,GroupReadInfo:s};return sa.core.common.buildAndSendPacket({servcmd:"openim.read_all_unread_msg",data:n})})}(i);if(e){const{GroupReadInfoArray:t,C2CReadAllMsg:o}=e,i=this._parseGroupReadInfo(t);this._updateAllConversationReadStatus({allC2CMessageReadStatus:o})>0&&ma.emitConversationListUpdate(),n+=`failureGroupInfoList:${s(i)}`}return{code:0,successLog:{message:n}}}catch(r){const{errorCode:e}=r;throw new this._core.helper.ChatError({functionName:"setAllMessageRead",code:e,moreMessage:n})}})}_handleAllMessageRead(e){const{GroupReadInfoArray:t,C2CReadAllMsg:s}=e;this._parseGroupReadInfo(t),this._updateAllConversationReadStatus({allC2CMessageReadStatus:s})>0&&ma.emitConversationListUpdate()}_updateAllConversationReadStatus(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s},appStore:n}=this._core,o=n.conversationStore.getConversationMap(),{allC2CMessageReadStatus:i}=e;let r=0;for(const[a,c]of o)if(c.unreadCount>=1){if(i===_a&&c.type===t){const e=this._getLocalMessageMaxTime(c);ma.markMessageAsRead({conversationID:a,lastReadTime:e})}else if(c.type===s){const e=a.replace(s,"");if(this._serverGroupConversationLastReadSeqMap.has(e)){const t=this._serverGroupConversationLastReadSeqMap.get(e);ma.markMessageAsRead({conversationID:a,lastReadSequence:t})}}ma.updateUnreadCount(a,!1)&&(r+=1)}return r}_generateSetAllMessageReadRequestData(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,READ_ALL_C2C_MSG:n},appStore:o}=this._core,i={allC2CMessageReadStatus:ga,groupMessageReadInfoList:[]},r=o.conversationStore.getConversationMap();for(const[,a]of r){const{type:o,unreadCount:r}=a;if(this._shouldSetAllMessageRead({scope:e,type:o,unreadCount:r}))if(o===t&&i.allC2CMessageReadStatus===ga){if(i.allC2CMessageReadStatus=_a,e===n)break}else if(o===s){const e=this._getLocalMessageMaxSequence(a),{groupID:t}=a.groupProfile;i.groupMessageReadInfoList.push({GroupId:t,MsgSeq:e})}}return i}_parseGroupReadInfo(e){const{utils:{isUndefined:t}}=this._core,s=[];return null==e||e.forEach(e=>{const{GroupId:n,MsgSeq:o,RetCode:i,LastReadMsgSeq:r}=e;t(i)?this._serverGroupConversationLastReadSeqMap.set(n,r):(this._serverGroupConversationLastReadSeqMap.set(n,o),0!==i&&s.push(`${n}-${o}-${i}`))}),s}_deleteGroupAtTips(e){return pe(this,void 0,void 0,function*(){console.log(`${this._name}._deleteGroupAtTips conversationID:${e}`);const t=ma.getLocalConversation(e);if(!t)return;const s=(null==t?void 0:t.groupAtInfoList)||[];if(0!==s.length)try{const{common:{getCurrentUserID:t,isCommunity:n},OuterConstant:{CONV_GROUP:o,CONV_AT_ALL:i}}=this._core;let r=[...s];if(n({groupID:e.replace(o,"")})&&(r=s.filter(e=>!e.atTypeArray.includes(i)),0===r.length))return void this._clearGroupAtInfoList(e,!1);const a=r.map(e=>({From_Account:e.from,To_Account:t(),MsgSeq:e.__sequence,MsgRandom:e.__random,GroupId:e.groupID}));yield function(e,t){return pe(this,void 0,void 0,function*(){const{messageListToDelete:s}=e,n={DelMsgList:s};return t.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:n})})}({messageListToDelete:a},this._core),console.log(`${this._name}._deleteGroupAtTips ok. count:${s.length}`),this._clearGroupAtInfoList(e)}catch(n){console.error(`${this._name}._deleteGroupAtTips fail:`,n)}})}_clearGroupAtInfoList(e,t=!0){const s=ma.getLocalConversation(e);s&&(s.groupAtInfoList.length>0&&(s.clearGroupAtInfoList(),console.log(`${this._name}._clearGroupAtInfoList conversationID:${e} needEmitConversationUpdate:${t}`)),t&&ma.emitConversationListUpdate())}_getLocalMessageMaxTime(e){var t;const{conversationID:s}=e,n=this._core.message.messageDataHandler.getLocalMessageList(s),o=Math.max(...n.map(e=>e.time));let i=(null===(t=null==e?void 0:e.lastMessage)||void 0===t?void 0:t.lastTime)||0;return o>i&&(console.log(`${this._name}._getLocalMessageMaxTime update lastMessageTime from ${i} to ${o}`),i=o),i}_getLocalMessageMaxSequence(e){var t;const{conversationID:s}=e,n=this._core.message.messageDataHandler.getLocalMessageList(s),o=Math.max(...n.map(e=>e.sequence));let i=(null===(t=null==e?void 0:e.lastMessage)||void 0===t?void 0:t.lastSequence)||0;return o>i&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${i} to ${o}`),i=o),i}_setC2CMessageRead(e,t){return pe(this,void 0,void 0,function*(){try{yield function(e,t){return pe(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"openim.msgreaded",data:e})})}({C2CMsgReaded:{Cookie:"",C2CMsgReadedItem:[{To_Account:e.replace("C2C",""),LastedMsgTime:t,Receipt:1}]}},this._core),console.log(`${this._name}._setC2CMessageRead ok, lastReadTime:${t}`),ma.markMessageAsRead({conversationID:e,lastReadTime:t}),ma.updateUnreadCount(e)}catch(s){throw console.warn(`${this._name}._setC2CMessageRead fail:`,s),s}})}_setGroupMessageRead(e,t){return pe(this,void 0,void 0,function*(){try{yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,lastMessageSequence:n}=e,o={GroupId:s,MsgReadedSeq:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.msg_read_report",data:o})})}({groupID:e.replace("GROUP",""),lastMessageSequence:t},this._core),console.log(`${this._name}._setGroupMessageRead ok, lastReadSequence:${t}`),ma.markMessageAsRead({conversationID:e,lastReadSequence:t}),ma.updateUnreadCount(e)}catch(s){throw console.warn(`${this._name}._setGroupMessageRead fail:`,s),s}})}_shouldSetAllMessageRead(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,READ_ALL_MSG:n,READ_ALL_C2C_MSG:o,READ_ALL_GROUP_MSG:i}}=this._core,{type:r,scope:a,unreadCount:c}=e;return!(c<=0||(r!==t||![n,o].includes(a))&&(r!==s||![n,i].includes(a)))}},Ca=new class{constructor(){this._name="PinConversation"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"pinConversation",context:this})}handleConversationPinned(e,t){const{utils:{isArray:s}}=this._core;if(!s(e))return;const{OuterConstant:n}=this._core;let o=!1;e.forEach(e=>{const{Type:s,To_Account:i,GroupId:r}=e;let a;1===s?a=ma.getLocalConversation(`${n.CONV_C2C}${i}`):2===s&&(a=ma.getLocalConversation(`${n.CONV_GROUP}${r}`)),a&&(console.log(`${this._name}.handleConversationPinned conversationID:${a.conversationID} localPinned:${a.isPinned} remotePinned:${t}`),t&&!a.isPinned&&(a.isPinned=!0,o=!0),!t&&a.isPinned&&(a.isPinned=!1,o=!0))}),o&&ma.emitConversationListUpdate(!0)}pinConversation(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t,common:s,helper:{ChatError:n}}=this._core,{conversationID:o,isPinned:i}=e,r={code:0,data:{conversationID:o}},a=ma.getLocalConversation(o);if(a&&a.isPinned===i)return r;if(ia(o))return a&&(a.isPinned=i),ma.emitConversationListUpdate(!0),r;const c=`conversationID:${o} isPinned:${i}`;try{let e=null;if(na(o)?e={Type:1,To_Account:o.replace(t.CONV_C2C,"")}:oa(o)&&(e={Type:2,GroupId:o.replace(t.CONV_GROUP,"")}),yield function(e,t){return pe(this,void 0,void 0,function*(){const{fromAccount:s,operationType:n,itemList:o}=e,i={From_Account:s,OperationType:n,RecentContactItem:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.top",data:i})})}({fromAccount:s.getCurrentUserID(),operationType:!0===i?1:2,itemList:[e]},this._core)){if(a)a.isPinned!==i&&(a.isPinned=i);else{const e=new la({conversationID:o,type:na(o)?t.CONV_C2C:t.CONV_GROUP,isPinned:i});ma.setLocalConversation(o,e)}ma.emitConversationListUpdate(!0)}return Object.assign(Object.assign({},r),{successLog:{message:c}})}catch(u){const{errorCode:e,errorInfo:t}=u;throw new n({functionName:"pinConversation",code:e,message:t,moreMessage:c})}})}},Ma=new class{constructor(){this._name="DeleteConversation"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteConversation",context:this})}handleConversationDeleted(e){const{utils:{isArray:t}}=this._core;if(!t(e))return;const{OuterConstant:s}=this._core,n=[];e.forEach(e=>{const{Type:t,Peer_Account:o,GroupId:i}=e;1===t&&n.push(`${s.CONV_C2C}${o}`),2===t&&n.push(`${s.CONV_GROUP}${i}`)}),console.log(`${this._name}.handleConversationDeleted conversationIDList:${n}`),this._deleteLocalConversationList(n)}deleteConversation(e){return pe(this,void 0,void 0,function*(){const{utils:{isString:t}}=this._core;if(t(e))return void(yield this._deleteConversation({conversationIDList:[e],flag:ha.ONLY_CONVERSATIONID}));const s=Object.assign({},e);s.conversationIDList.length>100&&(s.conversationIDList=s.conversationIDList.slice(0,100)),yield this._deleteConversation(s)})}_deleteConversation(e){return pe(this,void 0,void 0,function*(){const{conversationIDList:t,clearHistoryMessage:s=!0,flag:n=0}=e,{helper:{ChatError:o}}=this._core,i=`conversationIDList:${t} clearHistoryMessage:${s}`;try{const e=yield Promise.all([this._deleteConversationFromLocal(t),this._deleteConversationFromServer(t,s)]),o=[...e[0],...e[1]];if(0===o.length)throw new this._core.helper.ChatError({code:pa.CONV_NOT_FOUND});return{code:0,data:n===ha.ONLY_CONVERSATIONID?{conversationID:o[0]}:{conversationIDList:o},successLog:{message:i}}}catch(r){const{errorCode:e,errorInfo:t}=r;throw new o({code:e,message:t,moreMessage:i})}})}_deleteConversationFromLocal(e){const{OuterConstant:t}=this._core;return e.filter(e=>{var s;if(!ma.hasLocalConversation(e))return!1;const n=null===(s=ma.getLocalConversation(e))||void 0===s?void 0:s.type;return n!==t.CONV_GROUP||this._hasLocalGroup(e)?n===t.CONV_SYSTEM&&(this._deleteLocalConversation(e),!0):(this._deleteLocalConversation(e),!0)})}_deleteConversationFromServer(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,common:n}=this._core,o={fromAccount:n.getCurrentUserID(),conversationList:[],clearHistoryMessage:t?1:0};if(e.forEach(e=>{var t;if(ma.hasLocalConversation(e)){const n=(null===(t=ma.getLocalConversation(e))||void 0===t?void 0:t.type)||"",i=e.replace(n,"");n===s.CONV_C2C?o.conversationList.push({To_Account:i,Type:1}):n===s.CONV_GROUP&&this._hasLocalGroup(e)&&o.conversationList.push({ToGroupid:i,Type:2})}}),0===o.conversationList.length)return[];const i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{fromAccount:s,conversationList:n,clearHistoryMessage:o}=e,i={From_Account:s,ContactItem:n,ClearRamble:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.batch_delete",data:i})})}(o,this._core);if(i){const{ResultItem:e=[]}=i,t=[];return e.length>0&&e.forEach(e=>{if(0===e.ResultCode){const n=1===e.Type?`${s.CONV_C2C}${e.To_Account}`:`${s.CONV_GROUP}${e.ToGroupid}`;t.push(n)}}),this._deleteLocalConversationList(t),t}return[]})}_deleteLocalConversationList(e){let t=!1;e.forEach(e=>{ma.hasLocalConversation(e)&&(this._deleteLocalConversation(e,!1),t=!0)}),console.log(`${this._name}._deleteLocalConversationList isUpdate:${t}`),t&&ma.emitConversationListUpdate()}_deleteLocalConversation(e,t=!0){const s=ma.hasLocalConversation(e);console.log(`${this._name}._deleteLocalConversation conversationID:${e} has:${s}`),s&&(ma.deleteLocalConversation(e),this._deleteConversationLocalMessage(e),t&&ma.emitConversationListUpdate())}_hasLocalGroup(e){const{OuterConstant:{CONV_GROUP:t},appStore:{groupStore:s}}=this._core,n=e.replace(t,"");return!!s.getGroup(n)}_deleteConversationLocalMessage(e){console.log(`${this._name}._deleteConversationLocalMessage conversationID:${e}`),this._core.message.messageDataHandler.deleteConversationMessageList(e)}},Aa=new class{constructor(){this._name="SetConversationDraft"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setConversationDraft",context:this})}setConversationDraft(e){return pe(this,void 0,void 0,function*(){const{conversationID:t,draftText:s}=e;if(console.log(`${this._name} conversationID:${t} draftText:${s}`),!ma.hasLocalConversation(t))throw new this._core.helper.ChatError({code:pa.CONV_NOT_FOUND});const n=ma.getLocalConversation(t);return null==n||n.setDraftText(s),ma.emitConversationListUpdate(),{code:0,data:{conversation:n}}})}},ba=new class{constructor(){this._name="SetC2CMessageRemindType"}init(e){this._core=e}set(e,t){return pe(this,void 0,void 0,function*(){e.length>30&&(console.warn(`${this._name}.set userIDList length:${e.length} exceeds limit 30`),e.splice(30));const s=function(){const{MSG_REMIND_ACPT_AND_NOTE:e,MSG_REMIND_DISCARD:t,MSG_REMIND_ACPT_NOT_NOTE:s}=sa.core.OuterConstant;return{[e]:0,[t]:1,[s]:2}}()[t],n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{userIDList:s,receiveMessageOption:n}=e,o={Peer_Account:s,Mute_Notifications:n};return t.common.buildAndSendPacket({servcmd:"openim.set_c2c_peer_mute_notifications",data:o})})}({userIDList:e,receiveMessageOption:s},this._core),{ErrorList:o=[]}=n||{},i=[];o.forEach(t=>{const{Peer_Account:s,ErrorCode:n}=t;i.push({userID:s,code:n});const o=e.indexOf(s);o>-1&&e.splice(o,1)});const r=[],a=[],{OuterConstant:c}=this._core;return e.forEach(e=>{a.push(`${c.CONV_C2C}${e}`),r.push({userID:e})}),ma.patchMessageRemindType(a,t),{code:0,data:{successUserIDList:r,failureUserIDList:i}}})}},Ta=new class{constructor(){this._name="SetGroupMessageRemindType"}init(e){this._core=e}set(e,t){return pe(this,void 0,void 0,function*(){const{common:{getCurrentUserID:s,isTopic:n},OuterConstant:o}=this._core;if(yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userID:n,receiveMessageOption:o}=e,i={GroupId:s,Member_Account:n,MsgFlag:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:i})})}({groupID:e,userID:s(),receiveMessageOption:t},this._core),!n(e)){const s=`${o.CONV_GROUP}${e}`;ma.patchMessageRemindType([s],t)}return{code:0,data:{groupID:e,messageRemindType:t}}})}},Oa=new class{constructor(){this._name="SetMessageRemindType"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setMessageRemindType",context:this})}handleC2CMessageRemindTypeSync(e){const{helper:{isEmpty:t},OuterConstant:s,ssoLog:n}=this._core;e.forEach(e=>{const{MuteNotificationsSync:o}=e;if(!t(o)){const{To_Account:e,MuteNotifications:t}=o,i=e.map(e=>`${s.CONV_C2C}${e}`),r=aa(t);n.debug(`${this._name}.handleC2CMessageRemindTypeSync conversationIDList:${i} messageRemindType:${r}`),ma.patchMessageRemindType(i,r)}})}setMessageRemindType(e){return pe(this,void 0,void 0,function*(){const t="setMessageRemindType",{groupID:s,userIDList:n,messageRemindType:o}=e,{helper:i,utils:{isUndefined:r},ssoLog:a}=this._core;try{if(!r(s))return a.debug(`${this._name}.${t} groupID:${s} messageRemindType:${o}`),yield Ta.set(s,o);if(!r(n))return a.debug(`${this._name}.${t} userIDList:${n} messageRemindType:${o}`),yield ba.set(n,o);throw new i.ChatError({functionName:t,message:"userIDList or groupID is required"})}catch(c){const e=new i.ChatError({functionName:t,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo});throw console.error(`${this._name}.${t} fail:`,e),e}})}},wa=new class{init(e){e.ssoLog.debug("ConversationAction.init"),this._core=e,fa.init(e),Ea.init(e),Sa.init(e),ya.init(e),Ca.init(e),Ma.init(e),Aa.init(e),Oa.init(e);const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s,DESTROY:n}}=this._core,{InnerEventSubType:{CONV_MODIFIED:o,C2C_MESSAGE_READ_SYNC:i,GROUP_MESSAGE_READ_SYNC:r,C2C_REMIND_TYPE_SYNC:a}}=t;t.subscribeInnerEvent(s,o,this._onConversationModified,this),t.subscribeInnerEvent(s,i,this._onC2CMessageReadSync,this),t.subscribeInnerEvent(s,a,this._onC2CMessageRemindTypeSync,this),t.subscribeInnerEvent(s,r,this._onGroupMessageReadSync,this),t.subscribeInnerEvent(n,this._dispose,this)}_onConversationModified(e){const{constants:{ConvModifyPushType:t}}=this._core,{RecentContactMod:s=[]}=e;s.forEach(e=>{const{PushType:s}=e;if(s===t.CONV_DELETED){const{RecentContactList:t}=e.RecentContactDeleteItem;Ma.handleConversationDeleted(t)}if(s===t.CONV_PINED){const{RecentContactList:t}=e.RecentContactTopItem;Ca.handleConversationPinned(t,!0)}if(s===t.CONV_UNPINED){const{RecentContactList:t}=e.RecentContactTopItem;Ca.handleConversationPinned(t,!1)}})}_onC2CMessageReadSync(e){const{C2cNotifyMsgArray:t=[]}=e;ya.handleC2CMessageReadSync(t)}_onC2CMessageRemindTypeSync(e){const{C2cNotifyMsgArray:t=[]}=e;Oa.handleC2CMessageRemindTypeSync(t)}_onGroupMessageReadSync(e){const{GroupTips:t=[]}=e;ya.handleGroupMessageReadSync(t)}_dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core,{InnerEventSubType:{CONV_MODIFIED:n,C2C_MESSAGE_READ_SYNC:o,GROUP_MESSAGE_READ_SYNC:i,C2C_REMIND_TYPE_SYNC:r}}=e;e.unSubscribeInnerEvent(t,n,this._onConversationModified,this),e.unSubscribeInnerEvent(t,o,this._onC2CMessageReadSync,this),e.unSubscribeInnerEvent(t,r,this._onC2CMessageRemindTypeSync,this),e.unSubscribeInnerEvent(t,i,this._onGroupMessageReadSync,this),e.unSubscribeInnerEvent(s,this._dispose,this)}},Da=new class{init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setAllReceiveMessageOpt",context:this})}setAllReceiveMessageOpt(e){return pe(this,void 0,void 0,function*(){try{const{OuterConstant:{MSG_REMIND_ACPT_NOT_NOTE:t}}=this._core,{messageRemindType:s=t,isRepeated:n=!0}=e,{startTime:o=0,endTime:i=0}=this._calcStartAndEndTime(e),r=yield function(e){return pe(this,void 0,void 0,function*(){const{common:t}=sa.core,{startTime:s,endTime:n,isRepeated:o,messageRemindType:i}=e,r={StartTime:s,EndTime:n,IsRepeated:o,Level:i};return t.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_set_do_not_disturb",data:r})})}({messageRemindType:this._getType(s),startTime:o,endTime:i,isRepeated:n?da.ON:da.OFF});return{code:0,data:{errorCode:r.ErrorCode,errorInfo:r.ErrorInfo}}}catch(t){ua("setAllReceiveMessageOpt",t)}})}_calcStartAndEndTime(e){const{startHour:t=0,startMinute:s=0,startSecond:n=0,duration:o=0,isRepeated:i=!0}=e,r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,s,n),c=Math.round(a.getTime()/1e3);let u=c+o;return i&&o>=86400&&(u=c+86400),{startTime:c,endTime:u}}_getType(e){const{OuterConstant:t}=this._core;return{[t.MSG_REMIND_ACPT_AND_NOTE]:0,[t.MSG_REMIND_DISCARD]:1,[t.MSG_REMIND_ACPT_NOT_NOTE]:2}[e]}},Ra=new class{init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:n}=e;t.registerApi({apiName:"getAllReceiveMessageOpt",context:this}),s.subscribeInnerEvent(n.MESSAGE_PUSH,s.InnerEventSubType.ALL_RECEIVE_MESSAGE_OPTION,this.onAllReceiveMsgOptionNotify,this)}onAllReceiveMsgOptionNotify(e){const t=this._handleResult(e),{notificationCenter:s,OuterEvent:{ALL_RECEIVE_MESSAGE_OPT_UPDATED:n}}=this._core;s.emitOuterEvent(n,{name:n,data:t})}getAllReceiveMessageOpt(){return pe(this,void 0,void 0,function*(){try{const e=yield function(){return pe(this,void 0,void 0,function*(){const{common:e}=sa.core,t={To_Account:e.getCurrentUserID()};return e.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_get_do_not_disturb",data:t})})}();return{code:0,data:this._handleResult(e)}}catch(_){ua("getAllReceiveMessageOpt",_)}})}_handleResult(e){const{OuterConstant:t}=this._core,{MSG_REMIND_ACPT_AND_NOTE:s,MSG_REMIND_DISCARD:n,MSG_REMIND_ACPT_NOT_NOTE:o}=t,i={0:s,1:n,2:o},{Level:r,StartTime:a,EndTime:c,IsRepeated:u}=e;return{messageRemindType:i[r]||s,startTime:a,endTime:c,isRepeated:u===da.ON}}},La=new class{init(e){e.ssoLog.debug("ReceiveMessageOptions.init"),this._core=e,ba.init(e),Ta.init(e),va.init(e),Ia.init(e),Da.init(e),Ra.init(e)}};const Na=e=>!na(e)&&!oa(e)&&!ia(e),Pa={getConversationProfile:[{key:"conversationID",required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Na(e)||"conversationID is invalid."}],setMessageRead:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Na(e)||"conversationID is invalid."}},pinConversation:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Na(e)||"conversationID is invalid."},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},deleteConversation:[{key:"options",required:!0,rules:["string","object"],allowEmpty:!1,customValidator:e=>{const{core:{utils:{isArray:t,isObject:s,isString:n}}}=sa;if(!n(e)&&!s(e))return"options is String or Object.";if(n(e)&&Na(e))return"conversationID is invalid.";if(s(e)){if(!t(e.conversationIDList))return"conversationIDList is not Array.";if(0===e.conversationIDList.length)return"conversationIDList is empty.";if(e.conversationIDList.some(e=>{if(Na(e))return!0}))return"conversationIDList includes invalid conversationID.";if(e.clearHistoryMessage&&"boolean"!=typeof e.clearHistoryMessage)return"clearHistoryMessage is not Boolean."}return!0}}],setConversationDraft:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!na(e)&&!oa(e))||"conversationID is invalid."},draftText:{required:!0,rules:["string"],allowEmpty:!0}},setAllReceiveMessageOpt:{messageRemindType:{required:!1,rules:["string"],allowEmpty:!0},startHour:{required:!1,rules:["number"],allowEmpty:!0},startMinute:{required:!1,rules:["number"],allowEmpty:!0},startSecond:{required:!1,rules:["number"],allowEmpty:!0},duration:{required:!1,rules:["number"],allowEmpty:!0},isRepeated:{required:!1,rules:["boolean"],allowEmpty:!0}}},ka={getConversationList:!0,getConversationProfile:!0,getTotalUnreadCount:!0,setMessageRead:!0,pinConversation:!0,deleteConversation:!0,setConversationDraft:!0,setMessageRemindType:!0,getAllReceiveMessageOpt:!0,setAllReceiveMessageOpt:!0};var Ga=new class{constructor(){this.name="Conversation"}install(e){sa.init(e),wa.init(e),La.init(e),ma.init(e),e.helper.registerValidateConfig({auth:ka,params:Pa})}};const Ua=new class{init(e){this.core=e}},Fa="AVChatRoom",xa="AV_HISTORY_MSG",$a="GRP_COUNTER",qa="Set",Ba="Increase",Va="Decrease",Wa=0,ja=1,Ha=2,Ka=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],Ya=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],za=["Role","JoinTime","MsgFlag","MsgSeq"],Za=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],Ja=0,Xa=1,Qa="notStart",ec="resolved",tc="rejected",sc=10018,nc=11e3,oc=2,ic=["Owner","Admin","Member"],rc=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],ac=0,cc=1,uc=2,lc=4,dc=1,hc=2,pc=3,gc=4,_c=5,mc=1,fc=0,vc=4,Ic=6,Ec=400,Sc=300,yc={from:!0,groupID:!0,groupName:!0,to:!0},Cc={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},Mc=2,Ac=4,bc=5,Tc=7,Oc=8,wc=15,Dc=20,Rc=21,Lc=2600,Nc=2602,Pc=2603,kc=2620,Gc=2621,Uc=2623,Fc=2660,xc=2661,$c=2681,qc=2683,Bc=2684,Vc=2685,Wc=2687,jc=3122,Hc=10018,Kc=e=>e===Ua.core.OuterConstant.GRP_PUBLIC,Yc=e=>e===Ua.core.OuterConstant.GRP_AVCHATROOM,zc=(e,t)=>{const{isArray:s}=Ua.core.utils;if(!s(e)||!s(t))return!1;let n=!1;return t.forEach(({key:t,value:s})=>{const o=e.find(e=>e.key===t);o?o.value!==s&&(o.value=s,n=!0):(e.push({key:t,value:s}),n=!0)}),n},Zc=e=>{const t=[];if(!e)return t;for(let s=0,n=e.length;s<n;s++){const{Key:n,Value:o}=e[s];t.push({key:n,value:o})}return t},Jc=e=>{const t=[];for(let s=0,n=e.length;s<n;s++){const{key:n,value:o}=e[s];t.push({Key:n,Value:o})}return t};function Xc(e,t){const{helper:s}=Ua.core;if(!s.checkBusinessCapabilityBits(t))throw new s.ChatError({functionName:e,code:jc,replacement1:e})}function Qc(e,t){const{helper:s}=Ua.core,n=new s.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(`${e} fail:`,n),n}const eu=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];class tu{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._groupAtInfoList=[],this._initGroup(e)}_initGroup(e){const{utils:{isString:t}}=Ua.core;for(const s in e)eu.indexOf(s)<0||("selfInfo"!==s?"isSupportTopic"!==s?"muteAllMembers"===s&&t(e[s])?this.muteAllMembers="On"===e[s]:this[s]=e[s]:this.isSupportTopic=1===e[s]:this.updateSelfInfo(e[s]))}updateGroup(e){const{utils:{isArray:t,isUndefined:s,isNumber:n,isString:o},common:{deepMerge:i}}=Ua.core;e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);const r=JSON.parse(JSON.stringify(e));r.lastMsgTime&&(this.lastMessage.lastTime=r.lastMsgTime),o(r.muteAllMembers)&&(r.muteAllMembers="On"===r.muteAllMembers),r.groupCustomField&&zc(this.groupCustomField,r.groupCustomField),s(r.isSupportTopic)||(this.isSupportTopic=n(r.isSupportTopic)?1===r.isSupportTopic:r.isSupportTopic),i(this,r,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),t(r.members)&&r.members.length>0&&r.members.forEach(e=>{e.userID===this.selfInfo.userID&&i(this.selfInfo,e,["sequence"])})}updateSelfInfo(e){const{nameCard:t,joinTime:s,role:n,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:r}=e,{common:{deepMerge:a}}=Ua.core;a(this.selfInfo,{nameCard:t,joinTime:s,role:n,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:r},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}var su=new class{constructor(){this._name="GroupDataHandler"}init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap()}hasLocalGroup(e){return this._groupMap.has(e)}getLocalGroup(e){return this._groupMap.get(e)}updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let s;e.forEach(e=>{var t;s=e.groupID,this.hasLocalGroup(s)?null===(t=this.getLocalGroup(s))||void 0===t||t.updateGroup(e):this._groupMap.set(s,new tu(e))});const n=t();for(const[,o]of this._groupMap)o.selfInfo.userID=n,"Owner"===o.selfInfo.role&&(o.ownerID=n)}deleteLocalGroup(e){this._groupMap.delete(e)}getLocalGroupList(){const{OuterConstant:{GRP_ROOM:e,GRP_LIVE:t}}=this._core;return[...this._groupMap.values()].filter(s=>{const{type:n}=s;return n!==e&&n!==t})}clearLocalGroup(){this._groupMap.clear()}emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:s}=this._core;s.emitOuterEvent(t,{name:t,data:e})}updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core,n=`${s}${e}`;if(t.getConversation(n)){const s=this.getLocalGroup(e);t.updateConversation(n,{groupProfile:s})}}reset(){this.clearLocalGroup()}};function nu(e,t){return pe(this,void 0,void 0,function*(){const{type:s,limit:n,offset:o,supportTopic:i=0,memberAccount:r,responseFilter:a}=e,c={Type:s,Limit:n,Offset:o,Member_Account:r,ResponseFilter:a,SupportTopic:i,NeedAppDefineData:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:c})})}const ou=function(e,t){return{code:0,data:e||{},successLog:t}};var iu=new class{constructor(){this._name="GetGroupList",this._pagingStatus=Qa,this.PAGING_GRP_COUNT_LIMIT=200}init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_LOGIN,n.GROUP_LIST_SYNC,this._syncGroupList,this)}getGroupList(){return pe(this,arguments,void 0,function*(e=!1){if(e){const e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),su.updateLocalGroup(e),su.getLocalGroupList()}if(this._core.ssoLog.debug("getGroupList",`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===tc||this._pagingStatus===Qa)return this._syncGroupList().then(()=>{const e=su.getLocalGroupList();return ou({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw e});const t=su.getLocalGroupList();return ou({groupList:t,isSyncCompleted:this._isSyncCompleted()},{message:`return group count:${t.length}`})})}_syncGroupList(){return pe(this,void 0,void 0,function*(){this._pagingStatus===Qa&&su.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=ec,this._groupListTreeShaking(t),su.updateLocalGroup(t);const s=su.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",`${this._name}._syncGroupList ok, count:${s.length}`),su.emitGroupListUpdate(),s}catch(s){throw this._pagingStatus=tc,s}})}_pagingGetGroupList(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{isCommunityRelay:s=!1,groupList:n}=e;let o,{limit:i,offset:r}=e;const a=[...Ka];s&&(o=this._core.OuterConstant.GRP_COMMUNITY,a.push("AtInfoList"));try{const e=yield nu({type:o,limit:i,offset:r,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:a,SelfInfoFilter:[...za]}},this._core),{GroupIdList:c=[],TotalCount:u=0}=e||{},l=this._convertGroupKey(c);n.push(...l);const d=r+i,h=!(u>d),p=`offset:${r} limit:${i} total:${u} isCompleted:${h} current:${n.length} isCommunityRelay:${s}`;return t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. ${p}`),s?h?n:(r=d,this._pagingGetGroupList({isCommunityRelay:!0,limit:i,offset:r,groupList:n})):h?(t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList start to get community list`),r=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:i,offset:r,groupList:n})):(r=d,this._pagingGetGroupList({limit:i,offset:r,groupList:n}))}catch(c){if(c.ErrorCode===sc)return t.warn("_pagingGetGroupList",`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${i}`),i=50,this._pagingGetGroupList({isCommunityRelay:s,limit:i,offset:r,groupList:n});if(s)return c.code===nc&&t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. community unavailable`),n;throw c}})}_pagingGetJoinedCommunityList(e){return pe(this,void 0,void 0,function*(){const{common:{getCurrentUserID:t},OuterConstant:s,ssoLog:n}=this._core,{groupList:o}=e;let{limit:i,offset:r}=e;try{const e=yield nu({limit:i,offset:r,type:s.GRP_COMMUNITY,memberAccount:t(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...Ka],SelfInfoFilter:[...za]}},this._core),{GroupIdList:a=[],TotalCount:c=0}=e||{},u=this._convertGroupKey(a);o.push(...u);const l=r+i,d=!(c>l),h=`offset:${r} limit:${i} total:${c} isCompleted:${d} current:${o.length}`;return n.debug("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList ok. ${h}`),d?o:(r=l,this._pagingGetJoinedCommunityList({limit:i,offset:r,groupList:o}))}catch(a){if(a.code===Hc)return n.warn("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList response size exceeds the limit, request count:${i}`),i=50,this._pagingGetJoinedCommunityList({limit:i,offset:r,groupList:o});throw a}})}_groupListTreeShaking(e){const t=new Map([...su.getLocalGroupList()]);for(let n=0,o=e.length;n<o;n++)t.delete(e[n].groupID);const s=[...t.keys()];for(let n=0,o=s.length;n<o;n++)su.deleteLocalGroup(s[n])}_isSyncCompleted(){return this._pagingStatus===ec}_convertGroupKey(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppDefinedData:n,ApplyJoinOption:o,CreateTime:i,FaceUrl:r,GroupId:a,Introduction:c,InviteJoinOption:u,LastInfoTime:l,LastMsgTime:d,MemberNum:h,MaxMemberNum:p,MuteAllMember:g,Name:_,NextMsgSeq:m,Notification:f,Owner_Account:v,Type:I,LastRecallTime:E,SelfInfo:S,AtInfoList:y=[],SupportTopic:C}=e[s],M=Zc(n),A=this._convertSelfInfo(S),b=this._convertAtInfoList(a,y);t.push({groupCustomField:M,joinOption:o,createTime:i,avatar:r,groupID:a,introduction:c,inviteOption:u,lastInfoTime:l,lastMsgTime:d,memberCount:h,maxMemberCount:p,muteAllMembers:g,name:_,nextMessageSeq:m,notification:f,ownerID:v,type:I,selfInfo:A,_lastRevokedTime:E,_groupAtInfoList:b,isSupportTopic:C})}return t}_convertSelfInfo(e){const{JoinTime:t,MsgFlag:s,MsgSeq:n,NoUnreadSeqList:o,Role:i}=e;return{joinTime:t,messageRemindType:s,readedSequence:n,excludedUnreadSequenceList:o,role:i}}_convertAtInfoList(e,t){if(0===t.length)return[];const s=[];return t.forEach(t=>{const{AtFlagList:n,AtMsgSeq:o,From_Account:i}=t;s.push({groupID:e,groupAtType:n,sequence:o,from:i})}),s}},ru=new class{constructor(){this._name="CreateGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}createGroup(e){return pe(this,void 0,void 0,function*(){var t;this._preCheckParams(e);const{helper:{ChatError:s}}=this._core;try{const{utils:{isEmpty:s},common:{getCurrentUserID:n}}=this._core,o=yield function(e,t){return pe(this,void 0,void 0,function*(){const{name:s,type:n,groupID:o,introduction:i,notification:r,avatar:a,maxMemberNum:c,joinOption:u,inviteOption:l,memberList:d,groupCustomField:h,isSupportTopic:p}=e;let g;d&&(g=d.map(e=>{const{userID:t,memberCustomField:s}=e;return{Member_Account:t,AppMemberDefinedData:s?Jc(s):void 0}}));const _={Name:s,Type:n,GroupId:o,Introduction:i,Notification:r,FaceUrl:a,MaxMemberCount:c,ApplyJoinOption:u,InviteJoinOption:l,MemberList:g,AppDefinedData:h,SupportTopic:p,webPushFlag:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:_})})}(Object.assign(Object.assign({},e),{ownerID:n()}),this._core),{GroupId:i,OverJoinedGroupLimit_Account:r=[]}=o||{},a=`${this._name}.createGroup ok, type:${e.type} groupID:${i} overLimitUserIDList:${r}`;s(e.memberList)||s(r)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter(e=>r.includes(e.userID))),su.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:i})]);const c=su.getLocalGroup(i);return this._notNeedSendCustomMessage(e)||(this._sendCustomMessage(i,e.type),su.emitGroupListUpdate()),ou({group:c},{message:a})}catch(n){const{errorCode:t,errorInfo:o}=n;throw new s({functionName:"createGroup",code:t,message:o,moreMessage:` groupID:${e.groupID}`})}})}_preCheckParams(e){const{type:t,groupID:s}=e,{utils:{isEmpty:n,isUndefined:o},common:{isCommunity:i}}=this._core,r=!n(s);if(!(()=>{const{GRP_PUBLIC:e,GRP_WORK:t,GRP_MEETING:s,GRP_AVCHATROOM:n,GRP_COMMUNITY:o}=Ua.core.OuterConstant;return[e,t,s,n,o]})().includes(t))throw new this._core.helper.ChatError({code:Lc});if(!i({type:t})){if(r&&i({groupID:s}))throw new this._core.helper.ChatError({code:Nc});o(e.isSupportTopic)||(e.isSupportTopic=void 0)}if(this._canIUseMemberList(t)||o(e.memberList)||(e.memberList=void 0),this._canIUseJoinOption(t)||o(e.joinOption)||(e.joinOption=void 0),i({type:t})){if(r&&!i({groupID:s}))throw new this._core.helper.ChatError({code:Nc});e.isSupportTopic=this._canIUseTopic(e)?1:0}}_canIUseMemberList(e){return!Yc(e)}_canIUseJoinOption(e){return Kc(e)||this._core.common.isCommunity({type:e})}_canIUseTopic(e){const{isSupportTopic:t}=e;return!0===t}_notNeedSendCustomMessage(e){const{type:t,isSupportTopic:s}=e,{OuterConstant:{GRP_AVCHATROOM:n,GRP_COMMUNITY:o}}=this._core;return t===n||t===o&&1===s}_sendCustomMessage(e,t){var s,n,o,i,r,a;const{OuterConstant:c}=this._core;let u="Create Group",l=Ja;t===c.GRP_COMMUNITY&&(u="Create Community",l=Xa);const d={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:u,cmd:l,opUser:this._core.store.get("login").userId,version:4})}},h=null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageFactory)||void 0===o?void 0:o.createCustomMessage(d);null===(a=null===(r=null===(i=this._core)||void 0===i?void 0:i.message)||void 0===r?void 0:r.messageSender)||void 0===a||a.sendMessage(h,{})}},au=new class{constructor(){this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}}init(e){this._core=e;const{helper:t,constants:s}=e;t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}clearLocalMainSequence(){this._groupAttributesCache.forEach(e=>{e.localMainSequence=0})}isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:s,isUndefined:n}}=this._core;return!n(t)&&!s(t.groupAttributeOption)}handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:s}=e,{serverMainSequence:n,groupAttributeList:o=[],operation:i}=s;this._core.ssoLog.debug("handleGroupAttributesUpdated",`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${i}`);const{utils:{isUndefined:r}}=this._core;r(i)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:n,groupAttributeList:o,operation:i}),this.emitGroupAttributesUpdated(t))}initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:s,values:new Map}),this._core.ssoLog.debug("initGroupAttributesCache",`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${s}`)}hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:s,groupAttributeList:n,operation:o}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:i}=e;o!==_c&&s-i!==1||(e.serverMainSequence=s,e.localMainSequence=s,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:n,operation:o})),s-i>1&&(e.serverMainSequence=s),this._groupAttributesCache.set(t,e),this._core.ssoLog.debug("refreshGroupAttributesCache",`${this._name}.refreshGroupAttributesCache. operation:${o} localMainSequence:${i} serverMainSequence:${s}`)}}_updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:s=[],operation:n}=e;n!==pc?n!==gc?(n===dc&&t.values.clear(),s.forEach(e=>{const{key:s,value:n,sequence:o}=e;t.values.set(s,{value:n,sequence:o})})):s.forEach(e=>{t.values.delete(e.key)}):t.values.clear()}getGroupAttributesCacheValues(e){var t;const{groupID:s,keyList:n=[]}=e,o={};if(this.hasGroupAttributesCache(s)){const{values:e}=this.getGroupAttributesCache(s);if(0===n.length){for(const s of e.keys())o[s]=(null===(t=e.get(s))||void 0===t?void 0:t.value)||"";return o}return n.forEach(t=>{var s;e.has(t)&&(o[t]=(null===(s=e.get(t))||void 0===s?void 0:s.value)||"")}),o}return o}saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}emitGroupAttributesUpdated(e){var t;const s=this.getGroupAttributesCacheValues({groupID:e}),{updatedKeyList:n,deletedKeyList:o}=this._computeValuesChangedData(s);this._core.ssoLog.debug("emitGroupAttributesUpdated",`${this._name}.emitGroupAttributesUpdated update count:${n.length}, delete count:${o.length}`),0===n.length&&0===o.length||this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:s,updatedKeyList:n,deletedKeyList:o}})}_computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,s=[],n=[];return Object.keys(e).forEach(t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&s.push(t)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(s=>{t(e[s])&&n.push(s)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:s,deletedKeyList:n}}_emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}},cu=new class{constructor(){this._name="DismissGroup"}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}dismissGroup(e){return pe(this,void 0,void 0,function*(){const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:s})})}(e,this._core);const{type:t}=su.getLocalGroup(e);return su.deleteLocalGroup(e),su.emitGroupListUpdate(),au.deleteGroupAttributesCache(e),ou({groupID:e,type:t},{message:e})}catch(s){const{errorCode:e,errorInfo:n}=s;throw new t({functionName:"dismissGroup",code:e,message:n})}})}},uu=new class{constructor(){this._name="GetGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}getGroupProfile(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupCustomFieldFilter:s}=e,n={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...Ka],AppDefinedDataFilter_Group:s,MemberInfoFilter:[...Za]}},{helper:{ChatError:o}}=this._core;try{const e=yield this.getGroupProfileAdvance(n),{successGroupList:s,failureGroupList:o}=e;if(o.length>0)throw o[0];let i;return!su.hasLocalGroup(t)&&Yc(s[0].type)?i=new tu(s[0]):(su.updateLocalGroup(s),i=su.getLocalGroup(t)),i.isSupportTopic||su.updateConversationGroupProfile(t),ou({group:i},{message:`groupID:${t}`})}catch(i){const{code:e,message:t}=i;throw new o({functionName:"getGroupProfile",code:e,message:t})}})}getGroupProfileAdvance(e){return pe(this,void 0,void 0,function*(){const{groupIDList:t}=e,{common:{isCommunity:s}}=this._core,n=t.filter(e=>!s({groupID:e})),o=t.filter(e=>s({groupID:e}));n.length>50&&(n.length=50),o.length>50&&(o.length=50);const i=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:n})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:o,isCommunityProfile:!0}))]),r=[],a=[];return i.forEach(e=>{r.push(...e.successGroupList),a.push(...e.failureGroupList)}),{successGroupList:r,failureGroupList:a}})}_getGroupProfileAdvance(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{isUndefined:s}}=this._core,{isCommunityProfile:n=!1}=e,o=he(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupIDList:s,responseFilter:n}=e,o={GroupIdList:s,ResponseFilter:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}(o,this._core),{GroupInfo:n=[]}=e||{},i=this._convertGroupProfileKey(n),r=i.filter(e=>s(e.errorCode)||0===e.errorCode),a=i.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return t.debug("_getGroupProfileAdvance",`${this._name}._getGroupProfileAdvance ok, groupID:${o.groupIDList.join(",")}`),{successGroupList:r,failureGroupList:a}}catch(i){if(n)return{successGroupList:[],failureGroupList:[]};throw i}})}_convertGroupProfileKey(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppDefinedData:n,ApplyJoinOption:o,CreateTime:i,FaceUrl:r,GroupId:a,InfoSeq:c,Introduction:u,InviteJoinOption:l,LastInfoTime:d,LastMsgTime:h,MaxMemberNum:p,MemberNum:g,MuteAllMember:_,Name:m,NextMsgSeq:f,Notification:v,Owner_Account:I,ShutUpAllMember:E,ShutUpUntil:S,Type:y,MemberList:C,ErrorCode:M,ErrorInfo:A}=e[s],b=Zc(n),T=this._convertMembers(C);t.push({groupCustomField:b,joinOption:o,createTime:i,avatar:r,groupID:a,infoSequence:c,introduction:u,inviteOption:l,lastInfoTime:d,lastMsgTime:h,maxMemberCount:p,memberCount:g,muteAllMembers:_,name:m,nextMessageSeq:f,notification:v,ownerID:I,shutUpAllMember:E,muteUntil:S,type:y,members:T,errorCode:M,errorInfo:A})}return t}_convertMembers(e){if(!e)return[];const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,MsgFlag:r,MsgSeq:a,NameCard:c,Role:u}=e[s],l=Zc(n);t.push({memberCustomField:l,joinTime:o,userID:i,messageRemindType:r,sequence:a,nameCard:c,role:u})}return t}},lu=new class{constructor(){this._groupCountersMap=new Map}init(e){this._core=e}getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}updateLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:o,groupCounterSeq:i}=this.getLocalGroupCounters(t);if(n>0&&n<i)return;s.forEach(t=>{const{Key:s,Value:n=0}=t;e.set(s,n)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:e,avChatRoomKey:o})}}initGroupCountersCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:s})}getLocalCounters(e,t){const s={};if(!this._hasLocalGroupCounters(e))return s;const{counters:n}=this.getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{n.has(e)&&(s[e]=n.get(e))});else for(const o of n.keys())s[o]=n.get(o);return s}deleteLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:o}=this.getLocalGroupCounters(t);s.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:e,avChatRoomKey:o})}}setGroupCounters(e,t){if(!this._hasLocalGroupCounters(e))return;const s=this.getLocalGroupCounters(e),{counters:n}=s;let o=!1;Object.entries(t).forEach(([e,t])=>{n.has(e)&&n.get(e)!==t&&(n.set(e,t),o=!0)}),o&&this._groupCountersMap.set(e,Object.assign(Object.assign({},s),{lastUpdateTime:Date.now(),counters:n}))}_hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}reset(){this._groupCountersMap.clear()}},du=new class{constructor(){this._name="JoinGroup"}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"joinGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}joinGroup(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{helper:{ChatError:s},OuterConstant:n,ssoLog:o}=this._core;try{if(su.hasLocalGroup(t))try{return yield uu.getGroupProfile({groupID:t}),ou({status:n.JOIN_STATUS_ALREADY_IN_GROUP,group:su.getLocalGroup(t)},{message:`groupID:${t} joinedStatus:${n.JOIN_STATUS_ALREADY_IN_GROUP}`})}catch(i){return o.warn("joinGroup",`${this._name}.joinGroup ${t} was unjoined, start to join!`),su.deleteLocalGroup(t),yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(r){const{errorCode:e,errorInfo:n}=r;throw new s({functionName:"joinGroup",code:e,message:n,moreMessage:`groupID:${t}`})}})}_applyJoinGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t,helper:s,ssoLog:n}=this._core,{groupID:o}=e,i=Object.assign({},e),r=s.checkBusinessCapabilityBits(xa);r&&(i.historyMessageFlag=1);const a=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,applyMessage:n,historyMessageFlag:o}=e,i={GroupId:s,ApplyMsg:n,HugeGroupHistoryMsgFlag:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:i})})}(i,this._core),{Type:c,JoinedStatus:u,LongPollingKey:l,StartSeq:d,HugeGroupFlag:h,AVChatRoomKey:p,RspMsgList:g=[]}=a||{},_=`groupID:${o} joinedStatus:${u} longPollingKey:${l} startSeq:${d} avChatRoomFlag:${h} canGetAVChatRoomHistoryMsg:${r}, historyMessageCount:${g.length}`;n.debug("_applyJoinGroup",`${this._name}._applyJoinGroup ok, ${_}`);let m=new tu({groupID:o,type:c});if(u===t.JOIN_STATUS_WAIT_APPROVAL)return ou({status:t.JOIN_STATUS_WAIT_APPROVAL,group:m});if(u===t.JOIN_STATUS_SUCCESS){try{m=(yield uu.getGroupProfile({groupID:o})).data.group}catch(f){n.warn("_applyJoinGroup",`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${o}, errorCode:${null==f?void 0:f.code}`)}return this._handleJoinResult({group:m,avChatRoomFlag:h,longPollingKey:l,startSequence:d,avChatRoomKey:p,historyMessageList:g})}throw new this._core.helper.ChatError({code:Fc})})}_handleJoinResult(e){const{group:t,avChatRoomFlag:s,avChatRoomKey:n}=e;return 1===s?(au.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:n}),lu.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:n}),ou(e)):(su.updateLocalGroup([t]),su.emitGroupListUpdate(),ou({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t},{message:`groupID:${t.groupID}`}))}},hu=new class{constructor(){this._name="QuitGroup"}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"quitGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}quitGroup(e){return pe(this,void 0,void 0,function*(){if(!su.hasLocalGroup(e))throw new this._core.helper.ChatError({code:Uc});const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:s})})}(e,this._core);const{type:t}=su.getLocalGroup(e);return su.deleteLocalGroup(e),su.emitGroupListUpdate(),au.deleteGroupAttributesCache(e),ou({groupID:e,type:t},{message:`groupID:${e}`})}catch(s){const{errorCode:n,errorInfo:o}=s;throw new t({functionName:"quitGroup",code:n,message:o,moreMessage:`groupID:${e}`})}})}},pu=new class{constructor(){this._name="SearchGroup"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}searchGroupByID(e){return pe(this,void 0,void 0,function*(){try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupIdList:[e],GroupBasePublicInfoFilter:[...Ya]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:s})})}(e,this._core),{GroupInfo:s=[]}=t||{},{AppDefinedData:n=[],ApplyJoinOption:o,CreateTime:i,FaceUrl:r,Introduction:a,InviteJoinOption:c,MaxMemberNum:u,MemberNum:l,Name:d,Owner_Account:h,Type:p,ErrorCode:g,ErrorInfo:_}=s[0];if(0!==g)throw new this._core.helper.ChatError({code:g,message:_});const m=Zc(n),f=new tu({groupID:e,name:d,avatar:r,introduction:a,joinOption:o,inviteOption:c,maxMemberCount:u,memberCount:l,type:p,ownerID:h,createTime:i,groupCustomField:m});return ou({group:f})}catch(t){const{errorCode:e,errorInfo:s}=t;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:e,message:s})}})}},gu=new class{constructor(){this._name="UpdateGroupProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}updateGroupProfile(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{utils:{isUndefined:s},ssoLog:n,helper:o}=this._core;let i=su.getLocalGroup(t);if(i){const{type:o}=i;this._canIUseJoinOption(o)||s(e.joinOption)||(n.warn("updateGroupProfile",`${this._name}.updateGroupProfile groupID:${t} joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}s(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,name:n,avatar:o,introduction:i,notification:r,muteAllMembers:a,joinOption:c,inviteOption:u,groupCustomField:l}=e,d={GroupId:s,Name:n,FaceUrl:o,Introduction:i,Notification:r,ShutUpAllMember:a,ApplyJoinOption:c,InviteJoinOption:u,AppDefinedData:l?Jc(l):void 0};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:d})})}(e,this._core),i?(i.updateGroup(e),su.emitGroupListUpdate()):i=new tu(e),ou({group:i},{message:`groupID:${t}`})}catch(r){const{errorCode:e,errorInfo:s}=r;throw new o.ChatError({code:e,message:s,moreMessage:`groupID:${t}`})}})}_canIUseJoinOption(e){return Kc(e)||this._core.common.isCommunity({type:e})}},_u=new class{constructor(){this._name="ChangeGroupOwner"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}changeGroupOwner(e){return pe(this,void 0,void 0,function*(){const t="changeGroupOwner",{groupID:s,newOwnerID:n}=e,o=su.getLocalGroup(s),{helper:i,OuterConstant:r,common:{getCurrentUserID:a}}=this._core;if((null==o?void 0:o.type)===r.GRP_AVCHATROOM)throw new i.ChatError({functionName:t,code:kc});if(n===a())throw new i.ChatError({functionName:t,code:Gc});try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,newOwnerID:n}=e,o={GroupId:s,NewOwner_Account:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:o})})}(e,this._core),o.ownerID=n,su.emitGroupListUpdate(),ou({group:o})}catch(c){throw new i.ChatError({functionName:t,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo})}})}},mu=new class{constructor(){this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}getGroupOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const t="getGroupOnlineMemberCount";if(!su.hasLocalGroup(e))return ou({memberCount:0});const s=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:n=0,memberCount:o=0}=t||{};if(s-n<=6e4)return ou({memberCount:o})}try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:s})})}(e,this._core),{OnlineMemberNum:n=0}=s||{};this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:n});const o=`${this._name}.${t} ok. groupID:${e} memberCount:${n}`;return ou({memberCount:n},{message:o})}catch(n){throw new this._core.helper.ChatError({functionName:t,code:null==n?void 0:n.errorCode,message:null==n?void 0:n.errorInfo})}})}},fu=new class{init(e,t){e.ssoLog.debug("GroupAction.init"),iu.init(e),ru.init(e),cu.init(e,t),du.init(e,t),hu.init(e,t),pu.init(e),uu.init(e),gu.init(e),_u.init(e),mu.init(e,t)}dismissGroup(e){return cu.dismissGroup(e)}joinGroup(e){return du.joinGroup(e)}quitGroup(e){return hu.quitGroup(e)}getGroupOnlineMemberCount(e){return mu.getGroupOnlineMemberCount(e)}},vu=new class{constructor(){this._name="GetGroupApplicationList"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}getGroupApplicationList(){return pe(this,void 0,void 0,function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);this._core.ssoLog.debug("getGroupApplicationList",`${this._name}.${e} ok.`);const s=this._handleGroupApplicationResult([...t[0],...t[1]]);return ou({applicationList:s})}catch(t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}})}_getGroupApplicationList(e){return pe(this,void 0,void 0,function*(){const{type:t,startTime:s=0,limit:n=20}=e||{},{common:o}=this._core;let i;try{i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{type:s,startTime:n,limit:o,handleAccount:i}=e,r={Type:s,StartTime:n,Limit:o,Handle_Account:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:r})})}({type:t,startTime:s,limit:n,handleAccount:o.getCurrentUserID()},this._core)}catch(u){if(11e3!==(null==u?void 0:u.errorCode))throw u;i={}}const{NextStartTime:r=0,PendencyList:a=[]}=i||{};if(0===r)return a;const c=yield this._getGroupApplicationList(Object.assign(Object.assign({},e),{startTime:r}));return[...a,...c]})}_handleGroupApplicationResult(e){const t=[];return e.forEach(e=>{const s=this._convertApplicationData(e),{handled:n}=s,o=he(s,["handled"]);0===n&&t.push(o)}),t}_convertApplicationData(e){const{Handled:t,AddTime:s,ApplyInviteMsg:n,Authentication:o,FromUserNickName:i,From_Account:r,GroupId:a,GroupName:c,PendencyType:u,To_Account:l}=e;return{handled:t,messageKey:s,applicant:r,applicantNick:i,groupID:a,groupName:c,authentication:o,applicationType:u,userID:l,note:n}}},Iu=new class{constructor(){this._name="HandleGroupApplication"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}handleGroupApplication(e){return pe(this,void 0,void 0,function*(){const{application:t}=e,s=this._handleParams(e);try{(null==t?void 0:t.applicationType)===oc?yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,handleAction:n,handleMessage:o,applicant:i,authentication:r,invitee:a}=e,c={GroupId:s,HandleMsg:n,ApprovalMsg:o,Applicant_Account:i,Authentication:r,Invited_Account:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:c})})}(s,this._core):yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,handleAction:n,handleMessage:o,applicant:i,authentication:r,messageKey:a}=e,c={GroupId:s,HandleMsg:n,ApprovalMsg:o,Applicant_Account:i,Authentication:r,MsgKey:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:c})})}(s,this._core);const e=su.getLocalGroup(s.groupID);return ou({group:e})}catch(n){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==n?void 0:n.errorCode,message:null==n?void 0:n.errorInfo})}})}_handleParams(e){var t;const{handleAction:s,handleMessage:n,message:o,application:i}=e;let r,a,c,u,l;if(o){const{payload:e}=o||{};r=e.operatorID,a=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,c=e.authentication,u=e.messageKey}else r=(null==i?void 0:i.applicant)||"",a=(null==i?void 0:i.groupID)||"",c=(null==i?void 0:i.authentication)||"",u=(null==i?void 0:i.messageKey)||0;return(null==i?void 0:i.applicationType)===oc&&(l=i.userID),{handleAction:s,handleMessage:n,applicant:r,invitee:l,groupID:a,authentication:c,messageKey:u}}},Eu=new class{init(e){e.ssoLog.debug("GroupApplication.init"),vu.init(e),Iu.init(e)}};let Su=class{constructor(e){this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)}updateMember(e){const{core:{utils:{isUndefined:t},common:{deepMerge:s}}}=Ua;t(e.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*e.muteTime)/1e3)),t(e.onlineStatus)||(this.isOnline="Online"===e.onlineStatus);const n=[null,void 0,"",0,NaN];e.memberCustomField&&zc(this.memberCustomField,e.memberCustomField),s(this,e,["memberCustomField","marks","onlineStatus","muteTime"],n)}};function yu(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userID:n,muteTime:o,role:i,nameCard:r,memberCustomField:a}=e;let c;a&&(c=Jc(a));const u={GroupId:s,Member_Account:n,ShutUpTime:o,Role:i,NameCard:r,AppMemberDefinedData:c};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:u})})}var Cu=new class{constructor(){this._name="GetGroupMemberList"}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="getGroupMemberList",{groupID:s,offset:n=0,count:o=100,role:i="",filter:r=""}=e,a=su.getLocalGroup(s),c=o>100?100:o,u={groupID:s,offset:n,limit:c,memberRoleFilter:ic.includes(i)?[i]:void 0,memberInfoFilter:rc};try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{isCommunity:s}=t.common,{groupID:n,offset:o,limit:i,memberRoleFilter:r,memberInfoFilter:a}=e,c={GroupId:n,Limit:i,MemberRoleFilter:r,MemberInfoFilter:a};return s({groupID:n})?c.Next=String(o):c.Offset=o,t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:c})})}(u,this._core),{MemberList:o,MemberNum:i,Next:r}=e||{},l=`${this._name}.${t} ok, totalMemberCount:${i} next:${r}`,{utils:{isArray:d,isEmpty:h},common:{isCommunity:p}}=this._core;if(a&&(a.memberCount=i),!d(o)||0===o.length)return ou({memberList:[],offset:0},{message:l});let g=n+c;p({groupID:s})&&(g=h(r)?0:r),o.length<c&&(g=0);let _=this._convertMemberInfo(o);_=yield this._patchAvatarAndNick(_);const m=this._generateGroupMember(_);return ou({memberList:m,offset:g},{message:l})}catch(l){throw new this._core.helper.ChatError({functionName:t,code:null==l?void 0:l.errorCode,message:null==l?void 0:l.errorInfo})}})}_convertMemberInfo(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,OnlineStatus:r,Role:a,ShutUpUntil:c,NameCard:u}=e[s],l=Zc(n);t.push({userID:i,joinTime:o,onlineStatus:r,role:a,muteUntil:c,memberCustomField:l,nameCard:u})}return t}_patchAvatarAndNick(e){return pe(this,void 0,void 0,function*(){var t;const s=e.map(e=>e.userID),n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:s}),o=(null==n?void 0:n.data)||[],i=new Map(o.map(e=>[e.userID,e]));return e.forEach(e=>{if(i.has(e.userID)){const{nick:t="",avatar:s=""}=i.get(e.userID);e.nick=t,e.avatar=s}}),e})}_generateGroupMember(e){const t=[];for(let s=0,n=e.length;s<n;s++){const n=new Su(e[s]);t.push(n)}return t}},Mu=new class{constructor(){this._name="GetGroupMemberProfile"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}getGroupMemberProfile(e){return pe(this,void 0,void 0,function*(){const t="getGroupMemberProfile",{groupID:s,userIDList:n,memberCustomFieldFilter:o}=e,i=su.getLocalGroup(s),{helper:r,utils:{isArray:a},ssoLog:c}=this._core;if(i&&Yc(i.type))throw new r.ChatError({functionName:t,replacement1:t,code:Wc});n.length>50&&(c.warn("getGroupMemberProfile",`${this._name}.${t} userIDList length:${n.length} exceeds limit 50`),n.splice(50));const u=`userIDList length:${n.length} groupID:${s}`;try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,memberInfoFilter:o,memberCustomFieldFilter:i}=e,r={GroupId:s,Member_List_Account:n,MemberInfoFilter:o,AppDefinedDataFilter_GroupMember:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:r})})}({groupID:s,userIDList:n,memberCustomFieldFilter:o,memberInfoFilter:[...rc]},this._core),{MemberList:t}=e||{};if(!a(t)||0===t.length)return ou({memberList:[]});let i=this._convertMemberInfo(t);i=yield this._getMemberAvatarAndNick(i);const r=this._generateGroupMember(i);return ou({memberList:r},{message:u})}catch(l){throw new r.ChatError({functionName:t,code:null==l?void 0:l.errorCode,message:null==l?void 0:l.errorInfo,moreMessage:u})}})}_convertMemberInfo(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,OnlineStatus:r,Role:a,ShutUpUntil:c,NameCard:u}=e[s],l=Zc(n);t.push({userID:i,joinTime:o,onlineStatus:r,role:a,muteUntil:c,memberCustomField:l,nameCard:u})}return t}_getMemberAvatarAndNick(e){return pe(this,void 0,void 0,function*(){var t;const s=e.map(e=>e.userID),n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:s}),o=(null==n?void 0:n.data)||[],i=new Map(o.map(e=>[e.userID,e]));return e.forEach(e=>{if(i.has(e.userID)){const{nick:t="",avatar:s=""}=i.get(e.userID);e.nick=t,e.avatar=s}}),e})}_generateGroupMember(e){const t=[];for(let s=0,n=e.length;s<n;s++){const n=new Su(e[s]);t.push(n)}return t}},Au=new class{constructor(){this._name="AddGroupMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}addGroupMember(e){return pe(this,void 0,void 0,function*(){const t="addGroupMember",{groupID:s,userIDList:n}=e,o=su.getLocalGroup(s),{helper:i}=this._core;if(o&&Yc(o.type))throw new i.ChatError({functionName:t,code:xc});const r=n.map(e=>({Member_Account:e}));try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n}=e,o={GroupId:s,MemberList:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:o})})}({groupID:s,userIDList:r},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:n,successUserIDList:i,existedUserIDList:a,overLimitUserIDList:c}=this._handleResult(t);return ou({failureUserIDList:n,successUserIDList:i,existedUserIDList:a,overLimitUserIDList:c,group:o},{message:` groupID:${s} successUserIDList:${i} failureUserIDList:${n} existedUserIDList:${a} overLimitUserIDList:${c}`})}catch(a){throw new i.ChatError({functionName:t,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}_handleResult(e){const t=[],s=[],n=[],o=[];return e.forEach(e=>{const{Result:i,Member_Account:r}=e;i===ac?t.push(r):i===cc?s.push(r):i===uc?n.push(r):i===lc&&o.push(r)}),{failureUserIDList:t,successUserIDList:s,existedUserIDList:n,overLimitUserIDList:o}}},bu=new class{constructor(){this._name="DeleteGroupMember"}init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Fa)})}deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupMember",{groupID:s,userIDList:n}=e,o=su.getLocalGroup(s),{helper:i,utils:{isUndefined:r},ssoLog:a}=this._core;if(r(o))throw new i.ChatError({functionName:t,code:Pc});n.length>20&&(a.warn("deleteGroupMember",`${this._name}.${t} userIDList length:${n.length} exceeds limit 20`),n.splice(20));try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,reason:o}=e,i={GroupId:s,MemberToDel_Account:n,Reason:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:i})})}({groupID:s,userIDList:n},this._core),ou({group:o,userIDList:n},{message:`groupID:${s} userIDList length:${n.length}`})}catch(c){throw new i.ChatError({functionName:t,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo})}})}},Tu=new class{constructor(){this._name="SetGroupMemberMuteTime"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}setGroupMemberMuteTime(e){return pe(this,void 0,void 0,function*(){const{helper:t}=this._core,{groupID:s,userID:n,muteTime:o}=e,i=` groupID:${s} userID:${n} muteTime:${o}`;this._preCheckSettingMuteParams(e);try{yield yu(e,this._core);const t=su.getLocalGroup(s),r=new Su({userID:n,muteTime:o});return ou({group:t,member:r},{message:i})}catch(r){throw new t.ChatError({functionName:"setGroupMemberMuteTime",code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo,moreMessage:i})}})}_preCheckSettingMuteParams(e){const{userID:t}=e,{store:s,helper:n}=this._core;if(t===s.get("login").userId)throw new n.ChatError({functionName:"setGroupMemberMuteTime",code:Vc})}},Ou=new class{constructor(){this._name="SetGroupMemberRole"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}setGroupMemberRole(e){return pe(this,void 0,void 0,function*(){const t="setGroupMemberRole",{helper:s}=this._core,{groupID:n,userID:o,role:i}=e,r=`${this._name}.${t} ok, groupID:${n} userID:${o} role:${i}`;this._preCheckSettingRoleParams(e);try{yield yu(e,this._core);const t=su.getLocalGroup(n),s=new Su({userID:o,role:i});return ou({group:t,member:s},{message:r})}catch(a){throw new s.ChatError({functionName:t,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo,moreMessage:r})}})}_preCheckSettingRoleParams(e){var t;const{groupID:s,userID:n,role:o}=e,{store:i,helper:r,OuterConstant:a,common:{isCommunity:c}}=this._core,u=su.getLocalGroup(s);if((null===(t=null==u?void 0:u.selfInfo)||void 0===t?void 0:t.role)!==a.GRP_MBR_ROLE_OWNER)throw new r.ChatError({functionName:"setGroupMemberRole",code:$c});if(n===i.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberRole",code:Bc});const l=[...ic];if(c({groupID:s})&&l.push(a.GRP_MBR_ROLE_CUSTOM),!l.includes(o))throw new r.ChatError({functionName:"setGroupMemberRole",code:qc})}},wu=new class{constructor(){this._name="SetGroupMemberNameCard"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}setGroupMemberNameCard(e){return pe(this,void 0,void 0,function*(){const t="setGroupMemberNameCard",{helper:s,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingNameCardParams(e);try{const{groupID:s,userID:o=n(),nameCard:i}=e,r={groupID:s,userID:o,nameCard:i};yield yu(r,this._core);const a=`${this._name}.${t} ok, groupID:${s} userID:${o} nameCard:${i}`,c=su.getLocalGroup(s),u=new Su({userID:o,nameCard:i});return ou({group:c,member:u},{message:a})}catch(o){throw new s.ChatError({functionName:t,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo,moreMessage:logText})}})}_preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:s}=this._core,n=su.getLocalGroup(t);if(Yc(null==n?void 0:n.type))throw new s.ChatError({functionName:"setGroupMemberNameCard",code:Wc})}},Du=new class{constructor(){this._name="SetGroupMemberCustomField"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}setGroupMemberCustomField(e){return pe(this,void 0,void 0,function*(){const t="setGroupMemberCustomField",{helper:s,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingCustomFiledParams(e);const{groupID:o,userID:i=n(),memberCustomField:r}=e,a=`${this._name}.${t} ok, groupID:${o}userID:${i} memberCustomField:${JSON.stringify(r)}`;try{const e={groupID:o,userID:i,memberCustomField:r};yield yu(e,this._core);const t=su.getLocalGroup(o),s=new Su({userID:i,memberCustomField:r});return ou({group:t,member:s},{message:a})}catch(c){throw new s.ChatError({functionName:t,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo,moreMessage:a})}})}_preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:s}=this._core,n=su.getLocalGroup(t);if(Yc(null==n?void 0:n.type))throw new s.ChatError({functionName:"setGroupMemberCustomField",code:Wc})}},Ru=new class{init(e,t){e.ssoLog.debug("GroupMember.init"),Cu.init(e,t),Mu.init(e),Au.init(e),bu.init(e,t),Tu.init(e),Ou.init(e),wu.init(e),Du.init(e)}getGroupMemberList(e){return Cu.getGroupMemberList(e)}deleteGroupMember(e){return bu.deleteGroupMember(e)}},Lu=new class{init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupCounters",context:this})}getGroupCounters(e){return pe(this,void 0,void 0,function*(){const t="getGroupCounters";try{Xc(t,$a);const{groupID:s,keyList:n=[]}=e,{avChatRoomKey:o,lastUpdateTime:i}=lu.getLocalGroupCounters(s);if(!(Date.now()-i>=this._getExpireTime()))return{code:0,data:{counters:lu.getLocalCounters(s,n)}};const r=yield function(e){return pe(this,void 0,void 0,function*(){const{groupID:t,GroupCounterKeys:s,avChatRoomKey:n}=e,{common:o}=Ua.core,i={GroupId:t,keyList:s,BytesKey:n};return o.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:i})})}({groupID:s,keyList:n,avChatRoomKey:o}),{GroupCounter:a=[],GroupCounterSeq:c}=r;return lu.updateLocalGroupCounters({groupID:s,counterList:a,groupCounterSeq:c}),{code:0,data:{counters:lu.getLocalCounters(s,n)}}}catch(s){Qc(t,s)}})}_getExpireTime(){const{store:e,utils:{isUndefined:t}}=this._core,s=e.get("cloudConfig")||{},{grp_counter_expire_time:n}=s;return t(n)?3e4:Number(n)}},Nu=new class{init(e){const{helper:t}=e;t.registerApi({apiName:"setGroupCounters",context:this}),t.registerApi({apiName:"increaseGroupCounter",context:this}),t.registerApi({apiName:"decreaseGroupCounter",context:this})}setGroupCounters(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation(qa,e)})}increaseGroupCounter(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation(Ba,e)})}decreaseGroupCounter(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation(Va,e)})}_handleCounterOperation(e,t){return pe(this,void 0,void 0,function*(){const s=`${e}GroupCounter`;try{Xc(s,$a);const{groupID:n,key:o,value:i=0}=t,{avChatRoomKey:r}=lu.getLocalGroupCounters(n),a=e===qa?this._convertObjectToList(t.counters):[{Key:o,Value:i}],c=yield this._updateGroupCounters({groupID:n,counterList:a,avChatRoomKey:r,mode:e});return lu.setGroupCounters(n,c),{code:0,data:{counters:c}}}catch(n){Qc(s,n)}})}_updateGroupCounters(e){return pe(this,void 0,void 0,function*(){const t=yield function(e){const{groupID:t,counterList:s,mode:n,avChatRoomKey:o}=e,{common:i}=Ua.core,r={GroupId:t,GroupCounter:s,Mode:n,BytesKey:o};return i.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:r})}(e),{GroupCounter:s=[]}=t,n={};return s.forEach(e=>{const{Key:t,Value:s=0}=e;n[t]=s}),n})}_convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}},Pu=new class{init(e){this._core=e,Lu.init(e),Nu.init(e)}isGroupCounterUpdated(e){const{elements:{groupCounterInfo:t}}=e,{utils:{isEmpty:s}}=this._core;return!s(t)}handleGroupCounterUpdated(e){const{to:t,elements:{groupCounterInfo:s}}=e;s.forEach(e=>{const{type:s,groupCounterSeq:n,counterList:o=[]}=e;s!==Wa&&s!==Ha||this._processAndNotifyCounterUpdate(t,n,o),s===ja&&lu.deleteLocalGroupCounters({groupID:t,groupCounterSeq:n,counterList:o})})}_processAndNotifyCounterUpdate(e,t,s){const{OuterEvent:n,notificationCenter:o}=this._core;lu.updateLocalGroupCounters({groupID:e,groupCounterSeq:t,counterList:s}),s.forEach(({Key:t,Value:s=0})=>{o.emitOuterEvent(n.GROUP_COUNTER_UPDATED,{name:n.GROUP_COUNTER_UPDATED,data:{groupID:e,key:t,value:s}})})}reset(){lu.reset()}},ku=new class{constructor(){this._name="InitGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}initGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:s}=e,{serverMainSequence:n,avChatRoomKey:o}=au.getGroupAttributesCache(t),i=au.convertKeyValueMapToList(s);try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i}=e,r={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:r})})}({groupID:t,avChatRoomKey:o,groupAttributeList:i,mainSequence:n},this._core),{AttrMainSeq:r,GroupAttr:a}=e||{},c=a.map(e=>{const{Key:t,seq:n}=e;return{key:t,value:s[t],sequence:n}});return au.saveGroupAttributesCacheValuesCopy(t),au.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:c,operation:dc}),au.emitGroupAttributesUpdated(t),ou({groupAttributes:s},{message:` groupID:${t} serverMainSequence:${r}`})}catch(r){throw new this._core.helper.ChatError({functionName:"initGroupAttributes",code:null==r?void 0:r.errorCode,message:null==r?void 0:r.errorInfo})}})}},Gu=new class{constructor(){this._name="SetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this})}setGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:s}=e,{serverMainSequence:n,avChatRoomKey:o,values:i}=au.getGroupAttributesCache(t),r=au.convertKeyValueMapToList(s).map(e=>{var t;const{key:s,value:n}=e;return{key:s,value:n,seq:(null===(t=i.get(e.key))||void 0===t?void 0:t.sequence)||0}});try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i}=e,r={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:r})})}({groupID:t,avChatRoomKey:o,groupAttributeList:r,mainSequence:n},this._core),{AttrMainSeq:i,GroupAttr:a}=e||{},c=a.map(e=>{const{Key:t,seq:n}=e;return{key:t,value:s[t],sequence:n}});return au.saveGroupAttributesCacheValuesCopy(t),au.refreshGroupAttributesCache({groupID:t,serverMainSequence:i,groupAttributeList:c,operation:hc}),au.emitGroupAttributesUpdated(t),ou({groupAttributes:s},{message:` groupID:${t} serverMainSequence:${i}`})}catch(a){throw new this._core.helper.ChatError({functionName:"setGroupAttributes",code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}},Uu=new class{constructor(){this._name="DeleteGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this})}deleteGroupAttributes(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupAttributes",{groupID:s,keyList:n=[]}=e;try{let e;e=0===n.length?yield this._clearGroupAttributes(s):yield this._deleteGroupAttributes(s,n);const{resultList:o,serverMainSequence:i,operation:r,groupAttributeList:a}=e||{},c=`${this._name}.${t} ok. groupID:${s} operation: ${r}`;return au.saveGroupAttributesCacheValuesCopy(s),au.refreshGroupAttributesCache({groupID:s,serverMainSequence:i,groupAttributeList:a,operation:r}),au.emitGroupAttributesUpdated(s),ou({keyList:o},{message:c})}catch(o){throw new this._core.helper.ChatError({functionName:t,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo})}})}_deleteGroupAttributes(e,t){return pe(this,void 0,void 0,function*(){const{serverMainSequence:s,avChatRoomKey:n,values:o}=au.getGroupAttributesCache(e),i=[],r=[];t.forEach(e=>{if(o.has(e)){const{sequence:t=0}=o.get(e)||{};r.push({key:e,seq:t}),i.push(e)}});const a=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i}=e,r={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:r})})}({groupID:e,avChatRoomKey:n,groupAttributeList:r,mainSequence:s},this._core),{AttrMainSeq:c}=a||{};return{resultList:i,serverMainSequence:c,groupAttributeList:r,operation:gc}})}_clearGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{serverMainSequence:t,avChatRoomKey:s,values:n}=au.getGroupAttributesCache(e),o=[...n.keys()],i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,avChatRoomKey:o}=e,i={GroupId:s,AttrMainSeq:n,BytesKey:o,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:i})})}({groupID:e,avChatRoomKey:s,mainSequence:t},this._core),{AttrMainSeq:r}=i||{};return{resultList:o,serverMainSequence:r,operation:pc}})}},Fu=new class{constructor(){this._name="GetGroupAttributes"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this})}getGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{avChatRoomKey:s,lastUpdateTime:n,localMainSequence:o,serverMainSequence:i}=au.getGroupAttributesCache(t),{helper:{ChatError:r}}=this._core,a=`groupID:${t} localMainSequence:${o} serverMainSequence:${i} keyList:${e.keyList}`;if(Date.now()-n>=3e4||o<i)try{const n=yield this.getGroupAttributesFromServer({groupID:t,avChatRoomKey:s}),o=au.getGroupAttributesCacheValues(e),{serverGroupAttributeList:i=[]}=n||{};return ou({groupAttributes:o},{message:a,moreMessage:`from server, count:${i.length}`})}catch(u){throw new r({functionName:"getGroupAttributes",code:null==u?void 0:u.errorCode,message:null==u?void 0:u.errorInfo})}const c=au.getGroupAttributesCacheValues(e);return ou({groupAttributes:c},{message:a,moreMessage:"from cache"})})}getGroupAttributesFromServer(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t},ssoLog:s}=this._core,{groupID:n,avChatRoomKey:o}=e,i=t(o)?fc:mc,r=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,groupType:n,avChatRoomKey:o}=e,i={GroupId:s,GroupType:n,Key:o};return t.common.buildAndSendPacket({servcmd:"group_open_attr_http_svc.get_group_attr",data:i})})}({groupID:n,avChatRoomKey:o,groupType:i},this._core),{AttrMainSeq:a=0,GroupAttrAry:c}=r||{};s.debug("getGroupAttributesFromServer",`${this._name}._getGroupAttributesFromServer ok. groupID:${n} serverMainSequence:${a}`);const u=c.map(e=>{const{key:t,value:s,seq:n}=e;return{key:t,value:s,sequence:n}});return au.refreshGroupAttributesCache({groupID:n,serverMainSequence:a,groupAttributeList:u,operation:_c}),{serverGroupAttributeList:c}})}},xu=new class{init(e){e.ssoLog.debug("GroupAttribute.init"),ku.init(e),Gu.init(e),Uu.init(e),Fu.init(e),au.init(e)}isGroupAttributesUpdated(e){return au.isGroupAttributesUpdated(e)}handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:s}}=e,{groupAttributeOption:n}=s,{serverMainSequence:o,withChangedAttributeInfo:i}=n,{localMainSequence:r}=au.getGroupAttributesCache(t),a=o-r;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${i} diffSequence:${a}`),0!==a)if(au.saveGroupAttributesCacheValuesCopy(t),1!==i||1!==a){if(au.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=au.getGroupAttributesCache(t);Fu.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{au.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else au.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:n})}reset(){au.reset()}};function $u(e,t="tips"){const{ClientSeq:s,From_Account:n,MsgClientTime:o,MsgPriority:i,MsgRandom:r,MsgSeq:a,MsgTimeStamp:c,TinyId:u,ToGroupId:l,GroupInfo:d,MsgBody:h}=e;return{clientSequence:s,from:n,clientTime:o,priority:i,random:r,sequence:a,time:c,tinyID:u,to:l,groupProfile:function(e){const{GroupCode:t,GroupId:s,GroupName:n,GroupType:o,MsgFrom_AccountExtraInfo:i,From_Account:r,To_Account:a}=e;return{groupCode:t,groupID:s,groupName:n,type:o,messageFromAccountExtraInformation:i,from:r,to:a}}(d),elements:"tips"===t?qu(h):Vu(h)}}function qu(e){const t={};return Object.keys(e).forEach(s=>{var n,o;switch(s){case"MemberNum":t.memberCount=e[s];break;case"OpType":t.operationType=e[s];break;case"Operator_Account":t.operatorID=e[s];break;case"List_Account":t.userIDList=e[s];break;case"MsgMemberExtraInfo":t.memberInfoList=null===(n=e[s])||void 0===n?void 0:n.map(e=>Bu(e));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=Bu(e[s]);break;case"MsgGroupNewInfo":t.newGroupProfile=function(e){const t={};return Object.keys(e).forEach(s=>{switch(s){case"GroupIntroduction":t.introduction=e[s];break;case"GroupName":t.groupName=e[s];break;case"GroupFaceUrl":t.avatar=e[s];break;case"GroupNotification":t.notification=e[s];break;case"ApplyJoinOption":t.joinOption=e[s];break;case"InviteJoinOption":t.inviteOption=e[s];break;case"ShutupAll":t.muteAllMembers=e[s];break;case"Owner_Account":t.ownerID=e[s];break;case"GroupAttrOption":t.groupAttributeOption=function(e){const{BytesChangedKeys:t,GroupAttrSeq:s,OpType:n,PushChangedAttrValFlag:o,GroupAttrInfo:i}=e;return{changedKeyList:t,groupAttributeList:i.map(e=>{const{Key:t,Val:s,SubKeySeq:n}=e;return{key:t,value:s,sequence:n}}),serverMainSequence:s,operation:n,withChangedAttributeInfo:o}}(e[s])}}),t}(e[s]);break;case"MsgMemberInfo":t.msgMemberInfo=null===(o=e[s])||void 0===o?void 0:o.map(e=>function(e){const{ShutupTime:t,User_Account:s}=e;return{muteTime:t,userID:s}}(e));break;case"OnlineMemberInfo":t.onlineMemberInfo=function(e){const{ExpireTime:t,OnlineMemberNum:s}=e;return{expireTime:t,onlineMemberNum:s}}(e[s]);break;case"GroupCounterInfo":t.groupCounterInfo=e[s].map(e=>{const{GroupCounterSeq:t,GroupCounter:s,Type:n}=e;return{type:n,groupCounterSeq:t,counterList:s}})}}),t}function Bu(e){const{ImageUrl:t,NickName:s,Role:n,UserId:o}=e;return{avatar:t,nick:s,role:n,userID:o}}function Vu(e){const t={};return Object.keys(e).forEach(s=>{switch(s){case"MsgKey":t.messageKey=e[s];break;case"Operator_Account":t.operatorID=e[s];break;case"ReportType":t.operationType=e[s];break;case"Authentication":t.authentication=e[s];break;case"MsgFlag":t.messageRemindType=e[s];break;case"UserDefinedField":t.userDefinedField=e[s];break;case"RemarkInfo":t.remarkInfo=e[s];break;case"BanDuration":t.duration=e[s];break;case"MuteTime":t.muteTime=e[s]}}),t}class Wu{constructor(e){this.type=Ua.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(e)}static parseServerPushElement(e){const t=qu(e);return new Wu(t)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"groupProfile":this._initGroupProfile(e[t]);break;case"operatorInfo":this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"newGroupProfile":this._initNewGroupProfile(e[t]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[t]=e[t]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];yc[n]&&(this.content.groupProfile[n]=e[n])}}_initOperatorInfo(e){this.content.operatorInfo={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];this.content.operatorInfo[n]=e[n]}}_updateMemberList(e){this.content.memberList?this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})}):this.content.memberList=e}_initNewGroupProfile(e){this.content.newGroupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];"muteAllMembers"!==n?this.content.newGroupProfile[n]=e[n]:this.content.newGroupProfile.muteAllMembers=1===e.muteAllMembers}}}var ju=new class{constructor(){this._name="GroupTipsNotification"}init(e){this._core=e;const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n}}=e,{message:{messageFactory:o},OuterConstant:i}=e;null==o||o.registerElementClass(i.MSG_GRP_TIP,Wu),t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.GROUP_TIPS_RECOVER,this._handleGroupTipsRecover,this),t.registerWorkflowStep(s.RECEIVE_GROUP_TIPS_NOTIFICATION,n.HANDLE_GROUP_TIPS_NOTIFICATION,this.onNewGroupTips,this)}onNewGroupTips(e){const{data:t}=e||{},{messageList:s,conversationUpdateFieldList:n}=this._handleGroupTips(t),{notificationCenter:o,OuterEvent:i,appStore:{conversationStore:r}}=this._core;return null==n||n.forEach(e=>{const{conversationID:t,lastMessage:s,unreadCount:n}=e,{unreadCount:o=0}=r.getConversation(t)||{};r.updateConversation(t,{lastMessage:s,unreadCount:n+o})}),s.length>0&&(o.emitOuterEvent(i.MESSAGE_RECEIVED,{name:i.MESSAGE_RECEIVED,data:s}),this._handleGroupTipMessage(s)),{conversationUpdateFieldList:n}}_handleGroupTips(e,t=!0){const{Event:s,GroupTips:n}=e,o=new Map,i=[],r=[];for(let a=0,c=n.length;a<c;a++){const e=$u(n[a],"tips");if(s===Ic){if(xu.isGroupAttributesUpdated(e)){xu.handleGroupAttributesUpdated(e);continue}if(Pu.isGroupCounterUpdated(e)){Pu.handleGroupCounterUpdated(e);continue}}const{groupProfile:{groupID:i}}=e;if(!su.hasLocalGroup(i))continue;const c=this._assembleMessage(e);if(s===Ic&&(c._onlineOnlyFlag=!0,r.push(c)),s===vc){if(!this._core.message.messageDataHandler.storeConversationMessage(c)&&t)continue;r.push(c)}this._handleConversationOptions(o,c)}return i.push(...o.values()),{conversationUpdateFieldList:i,messageList:r}}_assembleMessage(e){const{OuterConstant:t,message:{messageFactory:s}}=this._core;e.flow="in",e.conversationType=t.CONV_GROUP;const n=s.createMessage(e);this._patchNickAndAvatar(e.elements,n);const o=new Wu(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));return n.setElement(o),n.isSystemMessage=!1,n}_patchNickAndAvatar(e,t){const{utils:{isEmpty:s},OuterConstant:{GROUP_TIPS_OPERATION_TYPE:n}}=this._core,{operationType:o,memberInfoList:i,operatorInfo:r}=e;let a={};if(s(i)?s(r)||(a=r):o!==n.JOINED&&o!==n.KICKED&&o!==n.ADMIN_SET&&o!==n.ADMIN_CANCELED||(a=Object.assign({},i[0])),!s(a)){const{nick:e="",avatar:s=""}=a;t.nick=e,t.avatar=s}}_handleConversationOptions(e,t){const{common:{getMessagePreviewText:s},utils:{isObject:n}}=this._core,{conversationID:o,conversationType:i}=t;let r;if(e.has(o))r=e.get(o),"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||r.unreadCount++),r.type=i,r.lastMessage=t._isExcludedFromLastMessage?"":Object.assign({},t);else{let e=0;"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1)),r={conversationID:o,unreadCount:e,type:i,lastMessage:t._isExcludedFromLastMessage?"":Object.assign({},t)}}n(r.lastMessage)&&(r.lastMessage.messageForShow=s(r.lastMessage.type,r.lastMessage.payload)),e.set(o,r)}_handleGroupTipMessage(e){const{OuterConstant:{GROUP_TIPS_OPERATION_TYPE:t}}=this._core;e.forEach(e=>{const{operationType:s}=e.payload;switch(s){case t.JOINED:this._handleNewMemberJoined(e);break;case t.QUITTED:this._handleMemberQuitted(e);break;case t.KICKED:this._handleMemberKicked(e);break;case t.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(e)}})}_handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}_handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}_handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}_handleGroupProfileUpdated(e){var t;const{newGroupProfile:s,groupProfile:n,operatorInfo:o}=e.payload,{groupID:i}=n,r=su.getLocalGroup(i);Object.keys(s).forEach(e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(i,s);break;case"groupName":r.name=s[e];break;default:r[e]=s[e]}});const{utils:{isUndefined:a}}=this._core;a(o)||(null===(t=null==r?void 0:r.selfInfo)||void 0===t?void 0:t.userID)!==o.userID||Object.keys(o).forEach(e=>{"nameCard"===e&&r.updateSelfInfo({nameCard:o[e]}),"role"===e&&this._updateSelfRole(r,o[e])}),su.emitGroupListUpdate(),su.updateConversationGroupProfile(i)}_handleGroupOwnerChanged(e,t){const{common:s,OuterConstant:n}=this._core,o=su.getLocalGroup(e),i=s.getCurrentUserID(),{ownerID:r}=t;i===r&&o.updateGroup({ownerID:r,selfInfo:{role:n.GRP_MBR_ROLE_OWNER}})}_updateSelfRole(e,t){const{OuterConstant:s}=this._core;let n=s.GRP_MBR_ROLE_MEMBER;t===Ec?n=s.GRP_MBR_ROLE_OWNER:t===Sc&&(n=s.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:n})}_handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:s}}=e.payload,n=su.getLocalGroup(s),{utils:{isNumber:o}}=this._core;n&&o(t)&&n.memberCount!==t&&(n.memberCount=t,su.emitGroupListUpdate(),su.updateConversationGroupProfile(s))}_handleGroupTipsRecover(e){const{utils:{isArray:t}}=this._core,{groupTipList:s}=(null==e?void 0:e.result)||{};t(s)&&s.forEach(e=>{const{messageList:t}=this._handleGroupTips({Event:e.Event,GroupTips:[e]},!1);this._handleGroupTipMessage(t)})}};class Hu{constructor(e){this.type=Ua.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}static parseServerPushElement(e){const t=Vu(e);return new Hu(t)}_initContent(e){Object.keys(e).forEach(t=>{switch(t){case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this._initGroupProfile(e[t]);break;case"memberInfoList":break;default:this.content[t]=e[t]}})}_initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];Cc[n]&&(this.content.groupProfile[n]=e[n])}}}var Ku=new class{constructor(){this._name="GroupSystemNotification"}init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:{MSG_GRP_SYS_NOTICE:s}}=e;null==t||t.registerElementClass(s,Hu)}onNewGroupSystemNotification(e){const{GroupTips:t=[],isInstantMessage:s=!0}=e;this._core.ssoLog.debug("onNewGroupSystemNotification",` count:${t.length} isInstantMessage:${s}`);const{conversationUpdateFieldList:n,messageList:o}=this._handleGroupSystemNotification(t,s),{notificationCenter:i,OuterEvent:r}=this._core;n.length>0&&this._handleGroupSysTemMessage(s,o),!0===s&&o.length>0&&i.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:o})}_handleGroupSystemNotification(e,t){const s=[];let n={};for(let o=0;o<e.length;o++){const i=$u(e[o],"system"),{elements:{operationType:r}}=i;if(r===wc)continue;const a=this._assembleMessage(i);this._core.message.messageDataHandler.storeConversationMessage(a)&&(s.push(a),n=this._handleConversationOptions(a,t))}return n.lastMessage=s[s.length-1],{conversationUpdateFieldList:s.length>0?[n]:[],messageList:s}}_assembleMessage(e){const{message:{messageFactory:t},OuterConstant:s,utils:{randomInt:n}}=this._core;e.flow="in",e.conversationType=s.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=s.CONV_SYSTEM;const o=t.createMessage(e),i=new Hu(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));o.setElement(i),o.isSystemMessage=!0;const r=1===o.sequence&&1===o.random,a=2===o.sequence&&2===o.random;return(r||a)&&(o.sequence=n(),o.random=n(),o.generateMessageID()),o}_handleConversationOptions(e,t){const{OuterConstant:s}=this._core,n={conversationID:s.CONV_SYSTEM,unreadCount:0,type:s.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&n.unreadCount++,n}_handleGroupSysTemMessage(e,t){e&&t.forEach(e=>{const{operationType:t}=e.payload;switch(t){case Mc:this._handleGroupJoinResult(e);break;case Ac:this._handleMemberKicked(e);break;case bc:this._handleGroupDismissed(e);break;case Tc:this._handleGroupInvitedResult(e);break;case Oc:this._handleGroupQuitResult(e);break;case Dc:this._handleMessageRemindTypeSynced(e);break;case Rc:this._handleAVChatRoomMemberBanned(e)}})}_handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:s,type:n}=t,o=su.hasLocalGroup(s);this._core.ssoLog.debug("_handleGroupJoinResult",` groupID:${s} type:${n} hasLocalGroup:${o}`),o||Yc(n)||(su.updateLocalGroup([Object.assign({},t)]),su.emitGroupListUpdate())}_handleMemberKicked(e){const{groupProfile:{groupID:t,type:s}}=e.payload;su.hasLocalGroup(t)&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupDismissed(e){const{groupProfile:{groupID:t,type:s}}=e.payload;su.hasLocalGroup(t)&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}_handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:s}=t,n=su.hasLocalGroup(s);this._core.ssoLog.debug("_handleGroupInvitedResult",` groupID:${s} hasLocalGroup:${n}`),n||uu.getGroupProfile({groupID:s}).then(e=>{const{data:{group:t}}=e;su.updateLocalGroup([Object.assign({},t)]),su.emitGroupListUpdate()})}_handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:s}}=e.payload,n=su.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupQuitResult",` groupID:${t} type:${s} hasLocalGroup:${n}`),n&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}_handleMessageRemindTypeSynced(e){const{groupProfile:{groupID:t},messageRemindType:s}=e.payload;this._updateConversationProfile(t,{messageRemindType:s})}_handleAVChatRoomMemberBanned(e){const{groupProfile:{groupID:t,type:s}}=e.payload;this._deleteLocalGroup(t,s)}_deleteLocalGroup(e,t){if(Yc(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core;t.deleteConversation(`${s}${e}`)}su.deleteLocalGroup(e),su.emitGroupListUpdate()}_updateConversationProfile(e,t){const{appStore:{conversationStore:s},OuterConstant:{CONV_GROUP:n}}=this._core,o=`${n}${e}`;s.getConversation(o)&&s.updateConversation(o,t)}},Yu=new class{init(e){this._core=e,e.ssoLog.debug("GroupNotificationHandler.init"),ju.init(e),Ku.init(e);const{notificationCenter:t,InnerEvent:s}=e,{InnerEventSubType:n}=t;t.subscribeInnerEvent(s.MESSAGE_PUSH,n.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),t.subscribeInnerEvent(s.MESSAGE_PUSH,n.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this)}_onNewGroupTipsNotification(e){const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s}}=this._core;t.executeWorkflow(s.RECEIVE_GROUP_TIPS_NOTIFICATION,e)}_onNewGroupSystemNotification(e){Ku.onNewGroupSystemNotification(e)}_dispose(){const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:s}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}};const zu={required:!0,rules:["string"],allowEmpty:!1},Zu={required:!0,rules:["number"],allowEmpty:!1},Ju={required:!0,rules:["array"],allowEmpty:!1},Xu={required:!0,rules:["object"],allowEmpty:!1},Qu={createGroup:{name:zu,type:zu},dismissGroup:[Object.assign({key:"groupID"},zu)],joinGroup:{groupID:zu,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},zu)],searchGroupByID:[Object.assign({key:"groupID"},zu)],getGroupProfile:{groupID:zu,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:zu,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:zu,newOwnerID:zu},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},zu)],handleGroupApplication:{handleAction:zu},getGroupMemberList:{groupID:zu},getGroupMemberProfile:{groupID:zu,userIDList:Ju,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:zu,userIDList:Ju},deleteGroupMember:{groupID:zu,userIDList:Ju},setGroupMemberMuteTime:{groupID:zu,userID:zu,muteTime:Object.assign(Object.assign({},Zu),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:zu,userID:zu,role:zu},setGroupMemberNameCard:{groupID:zu,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:zu},setGroupMemberCustomField:{groupID:zu,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:Ju},markGroupMemberList:{groupID:zu,markType:Object.assign(Object.assign({},Zu),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:Ju},initGroupAttributes:{groupID:zu,groupAttributes:Xu},setGroupAttributes:{groupID:zu,groupAttributes:Xu},deleteGroupAttributes:{groupID:zu,keyList:Object.assign(Object.assign({},Ju),{allowEmpty:!0})},getGroupAttributes:{groupID:zu,keyList:Object.assign(Object.assign({},Ju),{allowEmpty:!0})},getGroupCounters:{groupID:zu,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:zu,counters:Xu},increaseGroupCounter:{groupID:zu,key:zu,value:Zu},decreaseGroupCounter:{groupID:zu,key:zu,value:Zu}},el={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};var tl=new class{constructor(){this._installedSubPlugins=[],this.groupDataHandler=su,this.groupAction=fu,this.groupAttribute=xu,this.groupMember=Ru,this.name="Group"}install(e,t=[]){this._core=e,Ua.init(e),su.init(e),fu.init(e,this),Ru.init(e,this),Eu.init(e),Pu.init(e),xu.init(e),Yu.init(e),e.helper.registerValidateConfig({auth:el,params:Qu}),this._installSubPlugins(t);const{notificationCenter:s,InnerEvent:n}=e;s.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.subscribeInnerEvent(n.DESTROY,this._dispose,this)}getInstalledSubPlugins(){return this._installedSubPlugins}_installSubPlugins(e){const{utils:{isArray:t}}=this._core;e&&t(e)&&e.forEach(e=>{var t;this._installedSubPlugins.includes(e.name)||(null===(t=e.install)||void 0===t||t.call(e,this._core,this),this._installedSubPlugins.push(e.name))})}_reset(){su.reset(),xu.reset(),Pu.reset()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const sl=new class{init(e){this.core=e}},nl="AV_MBR_LIST",ol="AV_BAN_MBR",il={NORMAL_MESSAGE:3,GROUP_TIPS_HAS_ROAMING:4,GROUP_SYSTEM_MESSAGE:5,GROUP_TIPS_HAS_NO_ROAMING:6,BROADCAST_MESSAGE:17,MESSAGE_REVOKED:20,MESSAGE_REACTION:21,LIVE_CUSTOM_DATA:100},rl={GROUP_DISMISSED:5,QUIT_GROUP:8,AVCHATROOM_MEMBER_BANNED:21},al=60,cl=2603,ul=2686,ll=2688,dl=3122;class hl{constructor(e){const{core:t,manager:s,groupID:n,getRequestParams:o,onSuccess:i,onFail:r}=e;this._name="Polling",this._core=t,this._manager=s,this._timeoutID=-1,this._isRunning=!1,this._groupID=n,this._getRequestParams=o,this._onSuccess=i,this._onFail=r}start(){this._isRunning=!0,this._request(),console.log(`${this._name}.start pollingInterval:${this._manager.getCurrentPollingInterval(this._groupID)}`)}isRunning(){return this._isRunning}_request(){return pe(this,void 0,void 0,function*(){try{const e=this._getRequestParams(this._groupID),t=yield function(e,t){return pe(this,void 0,void 0,function*(){const{longPollingKey:s,startSequence:n,startBroadcastSeq:o,simplifiedMessage:i}=e,r={Key:s,StartSeq:n,StartBroadcastSeq:o,DownsizeFlag:i,USP:1,HoldTime:90};return t.common.buildAndSendPacket({servcmd:"group_open_long_polling_http_svc.get_msg",data:r})})}(e,this._core);this._onSuccess(this._groupID,t);const s=this._manager.getCurrentPollingInterval(this._groupID);this._runNextPolling(s)}catch(_){this._onFail(this._groupID,_),this._runNextPolling(2e3)}})}_runNextPolling(e){this.isRunning()&&(this._timeoutID>-1&&clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),e))}stop(){console.log(`${this._name}.stop timerID:${this._timeoutID}`),this._timeoutID>-1&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}class pl{constructor(e){this._maxLength=e,this._map=new Map}set(e){var t;if(this._map.size>=this._maxLength){const e=(null===(t=this._map.entries().next().value)||void 0===t?void 0:t[0])||"";this._map.delete(e)}this._map.set(e,1)}has(e){return this._map.has(e)}delete(e){this.has(e)&&this._map.delete(e)}clear(){this._map.clear()}}const gl=e=>e===il.GROUP_TIPS_HAS_NO_ROAMING||e===il.GROUP_TIPS_HAS_ROAMING,_l=e=>e===il.GROUP_SYSTEM_MESSAGE;function ml(e){const t=function(e){const{E:t,MCT:s,MR:n,MP:o,MTS:i,GId:r,MS:a,CCD:c,F_Account:u,IsSys:l,GInf:d,MsgBody:h}=e,p=he(e,["E","MCT","MR","MP","MTS","GId","MS","CCD","F_Account","IsSys","GInf","MsgBody"]);return Object.assign({Event:t,MsgClientTime:s,MsgRandom:n,MsgPriority:o,MsgTimeStamp:i,ToGroupId:r,MsgSeq:a,CloudCustomData:c,From_Account:u,IsSystemMsg:l,GroupInfo:fl(d),MsgBody:vl(h)},p)}(e);return function(e){const{Event:t}=e;(gl(t)||_l(t))&&(e.From_Account=e.From_Account||"@TIM#SYSTEM"),(t===il.BROADCAST_MESSAGE||t===il.NORMAL_MESSAGE)&&function(e){const{core:{OuterConstant:t}}=sl;e.CloudCustomData=e.CloudCustomData||"",e.MsgBody=e.MsgBody.map(e=>{if(e.MsgType===t.MSG_CUSTOM){const{content:t={}}=e;e.content=Object.assign({Data:"",Desc:"",Ext:""},t)}return e})}(e),gl(t)&&function(e){const{GroupJoinType:t,MsgOperatorMemberExtraInfo:s={},MsgMemberExtraInfo:n,Operator_Account:o,List_Account:i,OpType:r}=e.MsgBody||{};"number"==typeof t||1!==r&&2!==r||(e.MsgBody.GroupJoinType=2===r?0:1),n||(e.MsgBody.MsgMemberExtraInfo=null==i?void 0:i.map(e=>({UserId:e}))),1!==r||n||(e.MsgBody.MsgMemberExtraInfo=[{UserId:s.UserId}]),e.MsgBody.MsgOperatorMemberExtraInfo=Object.assign({Operator_Account:o,ImageUrl:"",NickName:""},s)}(e),_l(t)&&function(e){const{MsgOperatorMemberExtraInfo:t={},Operator_Account:s}=e.MsgBody||{};e.MsgBody.MsgMemberExtraInfo=Object.assign({UserId:s,ImageUrl:"",NickName:""},t),e.MsgBody=Object.assign({Authentication:"",RemarkInfo:"",MsgKey:1e3*e.MsgTimeStamp},e.MsgBody),e.MsgBody=Object.keys(e.MsgBody).filter(e=>"MsgOperatorMemberExtraInfo"!==e).reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:e.MsgBody[s]}),{})}(e)}(t),t}function fl(e){const t=e||{},{GN:s,GT:n,F_Hd:o,F_NN:i,F_Ll:r}=t,a=he(t,["GN","GT","F_Hd","F_NN","F_Ll"]),c=Object.assign({GroupName:s,GroupType:n},a);return o&&(c.From_AccountHeadurl=o),i&&(c.From_AccountNick=i),r&&(c.From_AccountLevel=r),c}function vl(e){let t=e;Array.isArray(e)||(t=[e]);const s=t.map(e=>{const{O_Account:t,Opt:s,L_Account:n,RT:o,UDF:i,OpInf:r,OnlineInf:a,MsgMemberExtraInfo:c}=e,u=he(e,["O_Account","Opt","L_Account","RT","UDF","OpInf","OnlineInf","MsgMemberExtraInfo"]),l=Object.assign({Operator_Account:t,OpType:s,List_Account:n,ReportType:o,UserDefinedField:i},u);return r&&(l.MsgOperatorMemberExtraInfo=function(e){const{Img:t,NN:s}=e,n=he(e,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:s},n)}(r)),c&&(l.MsgMemberExtraInfo=null==(d=c)?void 0:d.map(e=>{const{Img:t,NN:s}=e,n=he(e,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:s},n)})),a&&(l.OnlineMemberInfo=function(e){const{ET:t,Num:s}=e;return{ExpireTime:t,OnlineMemberNum:s}}(a)),l;var d});return Array.isArray(e)?s:s[0]}var Il=new class{constructor(){this._name="MessageParser",this._sequenceList=new pl(200),this._messageIDList=new pl(100),this._broadcastMessageIDMap=new Map,this._reportMessageStackedCount=0}init(e,t){this._core=e,this._avChatRoomHandler=t}onMessageReceived(e,t,s=!1){this._sortServerMessageList({groupID:e,serverMessageList:t,isHistoryMessage:s});const n=this._handleMessageList(e,t);if(0===n.length)return;if(!s){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core,o=(e=>{const{core:{common:{getMessagePreviewText:t}}}=sl;return{lastTime:(null==e?void 0:e.time)||(null==e?void 0:e.lastTime)||0,lastSequence:(null==e?void 0:e.sequence)||(null==e?void 0:e.lastSequence)||0,fromAccount:(null==e?void 0:e.from)||(null==e?void 0:e.fromAccount)||"",messageForShow:t(null==e?void 0:e.type,null==e?void 0:e.payload),payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",onlineOnlyFlag:(null==e?void 0:e._onlineOnlyFlag)||!1,nick:(null==e?void 0:e.nick)||"",nameCard:(null==e?void 0:e.nameCard)||"",version:(null==e?void 0:e.version)||0,isPeerRead:(null==e?void 0:e.isPeerRead)||!1,revoker:(null==e?void 0:e.revoker)||null}})(n[n.length-1]);t.updateConversation(`${s}${e}`,{lastMessage:o})}this._checkMessageStacked(n);const o=n.filter(e=>!0===e.isModified),i=n.filter(e=>!1===e.isModified),{OuterEvent:{MESSAGE_RECEIVED:r,MESSAGE_MODIFIED:a}}=this._core;o.length>0&&this._emitEvent({name:a,data:o}),i.length>0&&this._emitEvent({name:r,data:i})}_sortServerMessageList(e){const{groupID:t,serverMessageList:s,isHistoryMessage:n}=e;let o=[];this._avChatRoomHandler.isPollingSimplifiedMessage()&&!n?(s.sort((e,t)=>e.MS-t.MS),o=s.map(e=>e.MS)):(s.sort((e,t)=>e.MsgSeq-t.MsgSeq),o=s.map(e=>e.MsgSeq)),console.log(`${this._name}._sortServerMessageList groupID:${t} count:${o.length} sequenceList:${o}`),o.length=0}_handleMessageList(e,t){const{message:{messageDataHandler:s,messageHelper:n}}=this._core,o=this._avChatRoomHandler.isPollingSimplifiedMessage(),i=[],r=t.length;for(let a=0;a<r;a++){let r=t[a];if(o&&(r=ml(r)),_l(r.Event)&&Object.values(rl).includes(r.MsgBody.ReportType)){this._onGroupDismissed(e);break}if(null===this._filterMessageItem(r))continue;this._patchMessageType(r);const c=n.parseServerGroupMessage(r),u=this._createMessage(c);u.level=r.GroupInfo.From_AccountLevel,gl(r.Event)&&this._avChatRoomHandler.isGroupAttributesUpdated(c)?this._avChatRoomHandler.handleGroupAttributesUpdated(c):null!==this._filterDuplicateMessage(u)&&(s.isMessageSentByCurrentInstance(u)||(1===c.isModified&&(u.isModified=!0),gl(r.Event)&&this._updateLocalOnlineMemberCountFromTips(r),i.push(u)))}return i}_patchMessageType(e){const{OuterConstant:t}=this._core;gl(e.Event)&&(e.MsgBody.MsgType=t.MSG_GRP_TIP),_l(e.Event)&&(e.MsgBody.MsgType=t.MSG_GRP_SYS_NOTICE)}_filterMessageItem(e){const{Event:t}=e;return Object.values(il).includes(t)?t===il.MESSAGE_REVOKED?(this._handleMessageRevoked(e),null):(e=>e===il.LIVE_CUSTOM_DATA)(t)?(this._onLiveCustomData(e),null):(e=>e===il.MESSAGE_REACTION)(t)?null:e:(console.warn(`${this._name}.onMessageReceived unknown event:${t}`),null)}_createMessage(e){const{message:{messageFactory:t},OuterConstant:s}=this._core;let n=s.CONV_GROUP;e.event===il.GROUP_SYSTEM_MESSAGE&&(n=s.CONV_SYSTEM);const o=!!e.isSystemMessage,i=t.createMessage(Object.assign(Object.assign({},e),{conversationType:n,isSystemMessage:o,flow:"in"}));return i.setElement(e.elements),i}_filterDuplicateMessage(e){const{common:t}=this._core;if(!t.isUnlimitedAVChatRoom()){if(this._sequenceList.has(e.sequence))return null;this._sequenceList.set(e.sequence)}const s=this._messageIDList.has(e.ID);return s?(console.warn(`${this._name}_filterDuplicateMessageItem ID:${e.ID} has:${s}`),null):(this._messageIDList.set(e.ID),e)}_handleMessageRevoked(e){const{OuterConstant:t,OuterEvent:{MESSAGE_REVOKED:s}}=this._core,{ToGroupId:n,MsgBody:{RevokeMsgList:o},RevokerInfo:{Revoker_Account:i,Reason:r=""}}=e,a=[];o.forEach(e=>{const{TinyId:s,MsgClientTime:o,Random:c,MsgSeq:u}=e,l={conversationID:`${t.CONV_GROUP}${n}`,ID:`${s}-${o}-${c}`,revoker:i,revokeReason:r,revokerInfo:{userID:i,nick:"",avatar:""},sequence:u};a.push(l)}),0!==a.length&&this._emitEvent({name:s,data:a})}_onLiveCustomData(e){const{OuterEvent:{ROOM_CUSTOM_DATA_RECEIVED:t}}=this._core,{ToGroupId:s,MsgSeq:n,MsgTimeStamp:o,MsgBody:i}=e,r=(null==i?void 0:i.Content)||(null==i?void 0:i.MsgContent)||"";this._emitEvent({name:t,data:r}),console.log(`${this._name}._onLiveCustomData groupID:${s} sequence:${n} time:${o} data:${r}`)}_onGroupDismissed(e){this._avChatRoomHandler.reset(e)}_checkMessageStacked(e){const{length:t}=e;if(t>=100&&this._reportMessageStackedCount<5){const e=this._avChatRoomHandler.getJoinedGroups();this._core.ssoLog.info("MessageStacked",`count:${t} groupID:${e.join(",")}`),this._reportMessageStackedCount+=1}}_emitEvent(e){this._core.notificationCenter.emitOuterEvent(e.name,e)}onBroadcastMessageReceived(e){const{message:{messageHelper:t},OuterEvent:{MESSAGE_RECEIVED:s}}=this._core,n=this._avChatRoomHandler.isPollingSimplifiedMessage(),o=[],i=e.length;for(let r=0;r<i;r++){let s=e[r];n&&(s=ml(s));const i=t.parseServerGroupMessage(s);if(!Object.values(il).includes(s.Event)){console.warn(`${this._name}.onBroadcastMessageReceived unknown event:${s.Event}`);continue}const a=this._createMessage(i);a.isBroadcastMessage=!0,this._broadcastMessageIDMap.has(a.ID)||(o.push(a),this._broadcastMessageIDMap.set(a.ID,1))}o.length>0&&this._emitEvent({name:s,data:o})}_updateLocalOnlineMemberCountFromTips(e){const{utils:{isEmpty:t}}=this._core,{ToGroupId:s,MsgBody:{OnlineMemberInfo:n}}=e;if(t(n))return;const{OnlineMemberNum:o=0,ExpireTime:i=al}=n,r=Date.now();let a=this._avChatRoomHandler.getLocalOnlineMemberCount(s);t(a)?a={lastReqTime:0,lastSyncTime:0,latestUpdateTime:r,memberCount:o,expireTime:i}:(a.latestUpdateTime=r,a.memberCount=o),this._avChatRoomHandler.updateLocalOnlineMemberCount(s,a)}reset(){this._reportMessageStackedCount=0,this._sequenceList.clear(),this._messageIDList.clear(),this._broadcastMessageIDMap.clear()}};const El=e=>{const{core:{store:t}}=sl;return(t.get("cloudConfig")||{})[e]},Sl=e=>{const{core:{utils:{isUndefined:t}}}=sl;return!t(e)},yl=()=>{const e=El("polling_interval");return Sl(e)?parseInt(e,10):300},Cl=()=>{const e=El("polling_simplified_msg");return Sl(e)?parseInt(e,10):0};var Ml=new class{constructor(){this._name="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._onlineMemberCountMap=new Map,this._pollingIntervalMap=new Map,this._pollingNoMessageCountMap=new Map,this._membersReqInfoMap=new Map,this._startBroadcastSequence=1}init(e,t){this._core=e,this._parentPlugin=t,Il.init(e,this),e.ssoLog.debug("AVChatRoomHandler.init")}onAVChatRoomSystemNotification(e){const{OuterConstant:{GRP_AVCHATROOM:t}}=this._core,{GroupTips:s=[]}=e;for(let n=0;n<s.length;n++){const{MsgBody:e,GroupInfo:{GroupId:o,GroupType:i}}=s[n],r=Object.values(rl).includes(e.ReportType);i===t&&r&&this.reset(o)}}getCurrentPollingInterval(e){return this._pollingIntervalMap.get(e)||yl()}isPollingSimplifiedMessage(){return 0!==Cl()}isGroupAttributesUpdated(e){return!!this._parentPlugin.groupAttribute.isGroupAttributesUpdated(e)&&(this._parentPlugin.groupAttribute.handleGroupAttributesUpdated(e),!0)}updateLocalOnlineMemberCount(e,t){this._onlineMemberCountMap.set(e,t)}getLocalOnlineMemberCount(e){return this._onlineMemberCountMap.get(e)||{}}hasPollingInstance(e){return this._pollingInstanceMap.has(e)}getJoinedLiveList(){const{OuterConstant:{GRP_LIVE:e}}=this._core;let t=[];return this._joinedGroupMap.size>0&&(t=[...this._joinedGroupMap.values()].filter(t=>t.type===e)),t}handleJoinGroupResult(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t},OuterConstant:{CONV_GROUP:s},apiMap:{getConversationProfile:n},OuterConstant:o}=this._core,{longPollingKey:i,group:r,historyMessageList:a=[]}=e,{groupID:c}=r;return yield this._preCheck(r),this._joinedGroupMap.set(c,r),this._parentPlugin.groupDataHandler.updateLocalGroup([r]),this._parentPlugin.groupDataHandler.emitGroupListUpdate(),n(`${s}${c}`),a.length>0&&Il.onMessageReceived(c,a,!0),t(i)?{code:0,data:{status:o.JOIN_STATUS_SUCCESS,group:r}}:{code:0,data:this.startMessageLongPolling(e)}})}_preCheck(e){return pe(this,void 0,void 0,function*(){const{common:t,OuterConstant:s,helper:n,apiMap:{quitGroup:o},ssoLog:i}=this._core;if(t.isUnlimitedAVChatRoom()){if(this._pollingInstanceMap.size>(()=>{const e=El("polling_count_limit");return Sl(e)&&e>0?parseInt(e,10):20})())throw new n.ChatError({code:ll,message:"the count of longPolling exceeds the max limit"});return}if(0===this._joinedAVChatRoomCount())return;if(e.type===s.GRP_LIVE)return;const[r,a]=this._joinedGroupMap.entries().next().value;if(a.selfInfo.role===s.GRP_MBR_ROLE_OWNER)this._parentPlugin.groupDataHandler.deleteLocalGroup(r);else try{yield o(r)}catch(c){i.debug("quitGroup",`${this._name}._preCheck quitGroup failed, groupID:${r} info:`,c)}this.reset(r)})}startMessageLongPolling(e){const{OuterConstant:t}=this._core,{longPollingKey:s,startSequence:n=1,group:o}=e,{groupID:i}=o;return this._pollingRequestInfoMap.set(i,{longPollingKey:s,startSequence:n}),this._pollingIntervalMap.set(i,yl()),this._startPolling(i),this._reportLongPollingCount(),{status:t.JOIN_STATUS_SUCCESS,group:o}}_startPolling(e){if(this._core.ssoLog.debug("_startPolling",`${this._name}._startPolling groupID:${e}`),this._pollingInstanceMap.has(e)){const t=this._pollingInstanceMap.get(e);return void((null==t?void 0:t.isRunning())||null==t||t.start())}const t=new hl({core:this._core,manager:this,groupID:e,getRequestParams:this._handleRequestParams.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});t.start(),this._pollingInstanceMap.set(e,t)}_handleRequestParams(e){const{longPollingKey:t,startSequence:s}=this._pollingRequestInfoMap.get(e)||{};return e===[...this._pollingInstanceMap.keys()][0]?{longPollingKey:t,startSequence:s,startBroadcastSeq:this._startBroadcastSequence,simplifiedMessage:Cl()}:{longPollingKey:t,startSequence:s,simplifiedMessage:Cl()}}_handleSuccess(e,t){const{ErrorCode:s}=t;if(0!==s){const{longPollingKey:t,startSequence:n}=this._pollingRequestInfoMap.get(e)||{};return void console.warn(`${this._name}._handleSuccess groupID:${e} key:${t} startSeq:${n} errorCode:${s}`)}this._hasJoinedAVChatRoom(e)&&this._handleResponseData(e,t)}_handleResponseData(e,t){const{Key:s,NextSeq:n,NextBroadcastSeq:o,RspMsgList:i=[],RspBroadcastMsgList:r=[]}=t;if(s&&n&&this._pollingRequestInfoMap.set(e,{longPollingKey:s,startSequence:n}),o&&o>this._startBroadcastSequence&&(this._startBroadcastSequence=o),i.length>0)0!==this._getPollingNoMessageCount(e)&&(this._updatePollingNoMessageCount(e,0),this._pollingIntervalMap.set(e,yl())),Il.onMessageReceived(e,i);else{let t=this._getPollingNoMessageCount(e);if(t+=1,this._updatePollingNoMessageCount(e,t),t===(()=>{const e=El("polling_no_msg_count");return Sl(e)?parseInt(e,10):20})()){const t=yl()+(()=>{const e=El("polling_interval_plus");return Sl(e)?parseInt(e,10):2e3})();this._pollingIntervalMap.set(e,t)}}r.length>0&&Il.onBroadcastMessageReceived(r)}_handleFailure(e,t){const{ssoLog:s,utils:{safeStringify:n}}=this._core;s.warn("polling",`${this._name}._handleFailure groupID:${e} error: ${n(t)}`)}_joinedAVChatRoomCount(){const{OuterConstant:e}=this._core;let t=[];return this._joinedGroupMap.size>0&&(t=this.getJoinedGroups().filter(t=>t.type===e.GRP_AVCHATROOM)),t.length}_hasJoinedAVChatRoom(e){return this._joinedGroupMap.has(e)}getJoinedGroups(){return[...this._joinedGroupMap.values()]}updateLocalLiveGroup(e,t){this._joinedGroupMap.set(e,t),this._parentPlugin.groupDataHandler.updateLocalGroup([t])}handleLiveHistoryMessages(e,t){Il.onMessageReceived(e,t,!0)}isOverFrequencyLimit(e){if(!this._membersReqInfoMap.has(e))return this._membersReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;let{startTime:t,requestCount:s}=this._membersReqInfoMap.get(e);const{interval:n,count:o}=(()=>{const e=El("av_members_freq_limit");if(Sl(e)){const{interval:t,count:s}=JSON.parse(e);if(s>0&&t>0)return{interval:t,count:s}}return{interval:30,count:4}})();return Date.now()-t>1e3*n?(this._membersReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1):(s+=1,this._membersReqInfoMap.set(e,{startTime:t,requestCount:s}),s>o)}_stopPolling(e){if(this._core.ssoLog.debug("_stopPolling",`${this._name}._stopPolling groupID:${e}`),e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core;t.deleteConversation(`${s}${e}`);const n=this._pollingInstanceMap.get(e);return null==n||n.stop(),this._parentPlugin.groupDataHandler.deleteLocalGroup(e),this._pollingInstanceMap.delete(e),this._pollingRequestInfoMap.delete(e),this._joinedGroupMap.delete(e),this._onlineMemberCountMap.delete(e),this._pollingIntervalMap.delete(e),this._pollingNoMessageCountMap.delete(e),void this._membersReqInfoMap.delete(e)}for(const t of this._pollingInstanceMap.values())null==t||t.stop();this._pollingInstanceMap.clear(),this._pollingRequestInfoMap.clear(),this._joinedGroupMap.clear(),this._onlineMemberCountMap.clear(),this._pollingIntervalMap.clear(),this._pollingNoMessageCountMap.clear(),this._membersReqInfoMap.clear()}_updatePollingNoMessageCount(e,t){this._pollingNoMessageCountMap.set(e,t)}_getPollingNoMessageCount(e){return this._pollingNoMessageCountMap.get(e)||0}_reportLongPollingCount(){const e=this._joinedGroupMap.size;if(e>1){const{common:t,OuterConstant:s,ssoLog:n}=this._core,o=t.isUnlimitedAVChatRoom()?1:0,i=[],r=[];this._joinedGroupMap.values().forEach(({groupID:e,type:t})=>{t===s.GRP_LIVE?r.push(e):i.push(e)}),n.info("longPollingCount",String(e),{moreMessage:`av:${i.join(",")} live:${r.join(",")} code: ${o}`,eventType:29})}}reset(e){this._stopPolling(e),this._startBroadcastSequence=1,Il.reset()}},Al=new class{init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"joinGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}joinGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.joinGroup(e),{data:{status:n,group:{type:o}}}=s;return o===t.GRP_AVCHATROOM?n===t.JOIN_STATUS_ALREADY_IN_GROUP?s:Ml.handleJoinGroupResult(s.data):s})}},bl=new class{init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"quitGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}quitGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.quitGroup(e),{data:{type:n}}=s;return n===t.GRP_AVCHATROOM&&Ml.reset(e),s})}},Tl=new class{init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"dismissGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}dismissGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.dismissGroup(e),{data:{type:n}}=s;return n===t.GRP_AVCHATROOM&&Ml.reset(e),s})}},Ol=new class{constructor(){this._name="GetAVChatRoomMemberList"}init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const{appStore:{groupStore:t},helper:s,OuterConstant:n}=this._core,{groupID:o}=e,i=t.getGroup(o);if((null==i?void 0:i.type)===n.GRP_AVCHATROOM&&s.checkBusinessCapabilityBits(nl)){if(Ml.isOverFrequencyLimit(o))throw{code:2996,message:`Over frequency limit: get_members-${o}`};return this._getGroupMemberList(e)}return this._parentPlugin.groupMember.getGroupMemberList(e)})}_getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="_getGroupMemberList",{helper:s}=this._core;try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,offset:n=0}=e,o={GroupId:s,Timestamp:n};return t.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.get_members",data:o})})}(e,this._core),{MemberList:n=[],NextTimestamp:o=0}=s||{},i=this._handleMemberList(n);return console.log(`${this._name}.${t} ok, groupID:${e.groupID} count:${i.length} nextOffset:${o}`),{code:0,data:{memberList:i,offset:o}}}catch(n){const e=new s.ChatError({functionName:t,code:null==n?void 0:n.errorCode,message:null==n?void 0:n.errorInfo});throw console.error(`${this._name}.${t} fail:`,e),e}})}_handleMemberList(e){return e.map(e=>{const{Member_Account:t,NickName:s="",Avatar:n="",Remark:o="",JoinTime:i=0,Marks:r=[]}=e;return{userID:t,nick:s,avatar:n,remark:o,joinTime:i,marks:r,isOnline:!0}})}},wl=new class{constructor(){this._name="GetAVChatRoomOnlineMemberCount"}init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}getGroupOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const{appStore:{groupStore:t},OuterConstant:s}=this._core,n=t.getGroup(e);return n?n.type===s.GRP_AVCHATROOM?this._getOnlineMemberCount(e):this._parentPlugin.groupAction.getGroupOnlineMemberCount(e):{code:0,data:{memberCount:0}}})}_getOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const t="_getOnlineMemberCount",{utils:{isEmpty:s}}=this._core,n=Ml.getLocalOnlineMemberCount(e);if(s(n)||this._isExpired(e)){const{memberCount:s=0}=yield this._getOnlineMemberCountFromServer(e);return console.log(`${this._name}.${t} ok, groupID:${e} memberCount:${s} from server.`),{code:0,data:{memberCount:s}}}return console.log(`${this._name}.${t} ok, groupID:${e} memberCount:${n.memberCount} from local.`),{code:0,data:{memberCount:n.memberCount}}})}_isExpired(e){const t=Ml.getLocalOnlineMemberCount(e),s=Date.now(),n=s-t.lastSyncTime>1e3*t.expireTime,o=s-t.latestUpdateTime>1e4,i=s-t.lastReqTime>3e3;return n&&o&&i}_getOnlineMemberCountFromServer(e){return pe(this,void 0,void 0,function*(){const t="_getOnlineMemberCountFromServer";try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:s})})}(e,this._core),{OnlineMemberNum:s=0,ExpireTime:n=al}=t||{},o=Date.now(),i={lastSyncTime:o,latestUpdateTime:o,lastReqTime:o,memberCount:s,expireTime:n};return Ml.updateLocalOnlineMemberCount(e,i),{memberCount:s}}catch(s){const e=new this._core.helper.ChatError({functionName:t,code:null==s?void 0:s.errorCode,message:null==s?void 0:s.errorInfo});throw console.error(`${this._name}.${t} fail:`,e),e}})}},Dl=new class{constructor(){this._name="DeleteAVChatRoomMember"}init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupMember",{appStore:{groupStore:s},utils:{isUndefined:n},helper:o,OuterConstant:i}=this._core,{groupID:r}=e,a=s.getGroup(r);if(n(a))throw new o.ChatError({functionName:t,code:cl});if(a.type===i.GRP_AVCHATROOM){if(o.checkBusinessCapabilityBits(ol))return this._deleteGroupMember(e);throw new o.ChatError({functionName:t,code:dl})}return this._parentPlugin.groupMember.deleteGroupMember(e)})}_deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="_deleteGroupMember",{appStore:{groupStore:s},helper:n,ssoLog:o}=this._core,{groupID:i,duration:r=0,userIDList:a}=e;if(0===r)throw new n.ChatError({functionName:t,code:ul});try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,duration:o,reason:i}=e,r={GroupId:s,Members_Account:n,Duration:o,Description:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.ban_group_member",data:r})})}(e,this._core),o.debug(t,`${this._name}.${t} ok, groupID:${i}`),{code:0,data:{group:s.getGroup(i),userIDList:a}}}catch(c){throw new n.ChatError({functionName:t,code:null==c?void 0:c.errorCode,message:null==c?void 0:c.errorInfo})}})}},Rl=new class{constructor(){this._name="MarkAVChatRoomMember"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"markGroupMemberList",context:this})}markGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="markGroupMemberList",{groupID:s,markType:n,enableMark:o,userIDList:i=[]}=e,r=this._generateRequestData(e);try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,operationType:n,memberList:o}=e,i={GroupId:s,CommandType:n,MemberList:o};return t.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.modify_user_info",data:i})})}(r,this._core),{MemberList:a=[]}=e||{},{successUserIDList:c,failureUserIDList:u}=this._handleResult(a,i);return{code:0,data:{successUserIDList:c,failureUserIDList:u},successLog:{message:`${this._name}.${t} ok, groupID:${s} markType:${n} enableMark:${o} success:${c.length} fail:${u.length}`}}}catch(a){throw new this._core.helper.ChatError({functionName:t,code:null==a?void 0:a.errorCode,message:null==a?void 0:a.errorInfo})}})}_generateRequestData(e){const{groupID:t,markType:s,enableMark:n,userIDList:o=[]}=e,i=!0===n?1:2,r=[...o];return r.length>500&&console.warn(`${this._name}._generateRequestData, the length of userIDList cannot exceed 500`),{groupID:t,operationType:i,memberList:r.map(e=>({Member_Account:e,Marks:[s]}))}}_handleResult(e,t){const s=[],n=[];return e.length===t.length?(s.push(...t),{successUserIDList:s,failureUserIDList:n}):(t.forEach(t=>{e.find(e=>e.Member_Account===t)?s.push(t):n.push(t)}),{successUserIDList:s,failureUserIDList:n})}},Ll=new class{init(e,t){e.ssoLog.debug("AVChatRoomAction.init"),Al.init(e,t),bl.init(e,t),Tl.init(e,t),Ol.init(e,t),wl.init(e,t),Dl.init(e,t),Rl.init(e)}},Nl=new class{constructor(){this._name="LiveHandler"}init(e){this._core=e;const{helper:t,ssoLog:s}=e;t.registerExperimentalAPI("startMessageLongPolling",this),t.registerExperimentalAPI("stopMessageLongPolling",this),s.debug("LiveHandler.init")}startMessageLongPolling(e){const{common:t,utils:{isEmpty:s},OuterConstant:n,ssoLog:o}=this._core,{groupID:i,longPollingKey:r,longPollingSequence:a=1}=e;if(s(r))return o.warn("startMessageLongPolling",`${this._name}.startMessageLongPolling longPollingKey is empty.`),Promise.resolve({});Ml.hasPollingInstance(i)&&this.stopMessageLongPolling({groupID:i});const c=Ml.getJoinedLiveList(),u=t.isUnlimitedAVChatRoom();!u&&c.length>0&&this.stopMessageLongPolling({groupID:c[0].groupID}),o.debug("startMessageLongPolling",`${this._name}.startMessageLongPolling isUnlimited:${u} groupID:${i} longPollingKey:${r} longPollingSequence:${a}`);const l={groupID:i,type:n.GRP_LIVE};return Ml.updateLocalLiveGroup(i,l),this._getLiveHistoryMessages({groupID:i,longPollingKey:r,startSequence:a}),Ml.startMessageLongPolling({group:l,longPollingKey:r,startSequence:a})}stopMessageLongPolling(e){const{groupID:t}=e;return Ml.reset(t),this._core.ssoLog.debug("stopMessageLongPolling",`${this._name}.stopMessageLongPolling ok, groupID:${t}`),Promise.resolve({groupID:t})}_getLiveHistoryMessages(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{groupID:s}=e;try{const n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,longPollingKey:n,startSequence:o}=e,i={GroupId:s,LongPollingKey:n,PullPreSeq:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_huge_group_msg",data:i})})}(e,this._core),{RspMsgList:o=[]}=n||{};t.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages ok, groupID:${s} count:${o.length}`),o.length>0&&Ml.handleLiveHistoryMessages(s,o)}catch(n){t.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages failed, groupID:${s} info:${n.message}`)}})}},Pl=new class{constructor(){this.name="AVChatRoom"}install(e,t){this._core=e,sl.init(e),Ml.init(e,t),Ll.init(e,t),Nl.init(e);const{notificationCenter:s,InnerEvent:n}=e,{InnerEventSubType:o}=s;s.subscribeInnerEvent(n.MESSAGE_PUSH,o.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),s.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.subscribeInnerEvent(n.DESTROY,this._dispose,this)}_onAVChatRoomSystemNotification(e){Ml.onAVChatRoomSystemNotification(e)}_reset(){Ml.reset()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:s}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const kl="friend",Gl=100,Ul=2700,Fl=2710,xl=2711,$l=2716,ql=2742,Bl=30539,Vl="Tag_SNS_IM_",Wl={GROUP:`${Vl}Group`,REMARK:`${Vl}Remark`,ADDSOURCE:`${Vl}AddSource`,ADDWORDING:`${Vl}Wording`,ADDTIME:`${Vl}AddTime`},jl="Update_Type_Add",Hl="Update_Type_Delete",Kl="add",Yl="remove",zl="rename",Zl=e=>void 0===e;function Jl(e,t){return pe(this,void 0,void 0,function*(){return Ql(yield t.common.buildAndSendPacket({servcmd:"sns.friend_update",data:e}),"ResultItem",e=>({to:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function Xl(e,t){return pe(this,void 0,void 0,function*(){return Ql(yield t.common.buildAndSendPacket({servcmd:"sns.friend_check",data:e}),"InfoItem",e=>({userID:e.To_Account,relation:e.Relation,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function Ql(e,t="ResultItem",s=e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})){const{[t]:n=[],ActionStatus:o,ErrorCode:i,ErrorInfo:r,ErrorDisplay:a}=e;return{resultList:n.map(s),actionStatus:o,errorCode:i,errorInfo:r,errorDisplay:a}}const ed={[Wl.REMARK]:(e,t)=>{e.remark=t},[Wl.GROUP]:(e,t)=>{e.groupList=t?JSON.parse(JSON.stringify(t)):[]},[Wl.ADDSOURCE]:(e,t)=>{e.source=t},[Wl.ADDWORDING]:(e,t)=>{e.wording=t},[Wl.ADDTIME]:(e,t)=>{e.addTime=t}};let td=class{constructor(e){var t;this.userID="",this.source="",this.wording="",this.remark="",this.addTime=0,this.groupList=[],this.friendCustomField=[];const{userID:s,tagValueList:n=[],core:o}=e,i=null===(t=o.user.userProfile)||void 0===t?void 0:t.createProfile(s,n);this.userID=s,this.profile=i,n.forEach(e=>{const{tag:t,value:s}=e;t.indexOf("Tag_Profile_Custom")>-1&&this.friendCustomField.push({key:t,value:s});const n=ed[t];null==n||n(this,s)})}update(e){const t=[];this.friendCustomField.forEach(e=>{t.push(e.key)}),e.forEach(e=>{const{tag:s,value:n}=e;s.indexOf("Tag_Profile_Custom")>-1&&(t.indexOf(s)>-1?this.friendCustomField.forEach(e=>{e.key===s&&(e.value=n)}):this.friendCustomField.push({key:s,value:n}));const o=ed[s];null==o||o(this,n)})}};var sd=new class{constructor(){this._startIndex=0,this._standardSequence=0,this._customSequence=0}init(e){this._core=e;const{helper:t,constants:s}=e;t.registerApi({apiName:"getFriendList",context:this,methodName:"getFriendListFromCache"}),t.registerApi({apiName:"getFriendProfile",context:this}),t.registerApi({apiName:"addFriend",context:this}),t.registerApi({apiName:"deleteFriend",context:this}),t.registerApi({apiName:"updateFriend",context:this}),t.registerApi({apiName:"checkFriend",context:this}),t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.FRIEND_RECOVER,this.syncFriendListFromServer,this)}getFriendListFromCache(){return pe(this,void 0,void 0,function*(){const{appStore:{userStore:e},ssoLog:t,utils:{safeStringify:s}}=this._core,n=[...e.getFriendMap().values()];return t.debug("getFriendListFromCache",`${kl} getFriendListFromCache, data:${s(n)}`),{code:0,data:n}})}syncFriendListFromServer(){return pe(this,void 0,void 0,function*(){var e;const{ssoLog:t,helper:s}=this._core;try{t.debug("syncFriendListFromServer",`${kl} syncFriendListFromServer`);const s={From_Account:null===(e=this._core.store.get("login"))||void 0===e?void 0:e.userId,StartIndex:this._startIndex,StandardSequence:this._standardSequence,CustomSequence:this._customSequence},n=yield function(e,t){return pe(this,void 0,void 0,function*(){return function(e){const{UserDataItem:t=[],StandardSequence:s,CustomSequence:n,FriendNum:o,CompleteFlag:i,NextStartIndex:r,ActionStatus:a,ErrorCode:c,ErrorInfo:u,ErrorDisplay:l}=e;return{friendList:t.map(e=>{var t;return{userID:e.To_Account,tagValueList:null===(t=e.ValueItem)||void 0===t?void 0:t.map(e=>({tag:e.Tag,value:e.Value}))}}),standardSequence:s,customSequence:n,friendNumber:o,completeFlag:i,nextStartIndex:r,actionStatus:a,errorCode:c,errorInfo:u,errorDisplay:l}}(yield t.common.buildAndSendPacket({servcmd:"sns.friend_get",data:e}))})}(s,this._core),{friendList:o,nextStartIndex:i,standardSequence:r,customSequence:a,completeFlag:c}=n;this._startIndex=i,this._standardSequence=r,this._customSequence=a,this._processFriendList(o),0===c?yield this.syncFriendListFromServer():(this._emitFriendListUpdated(),this._fetchFriendProfile()),t.debug("syncFriendListFromServer",`${kl} syncFriendListFromServer ok`)}catch(n){const{errorCode:e}=n||{};throw new s.ChatError({code:e})}})}getFriendProfile(e){return pe(this,void 0,void 0,function*(){var t;try{let{userIDList:s}=e;s.length>Gl&&(s=s.slice(0,Gl));const{friendUserIdList:n,unFriendUserIdList:o}=this.partitionByIsFriend(s),i=this._createNonFriendErrorList(o);if(0===n.length)return{code:0,data:{friendList:[],failureUserIDList:i}};const r={From_Account:null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,To_Account:n},a=(yield function(e,t){return pe(this,void 0,void 0,function*(){return function(e){const{InfoItem:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{friendProfileList:t.map(e=>{var t;return{userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,relation:e.Relation,standardSequence:e.StandardSequence,customSequence:e.CustomSequence,profileItem:(null===(t=e.SnsProfileItem)||void 0===t?void 0:t.map(e=>({tag:e.Tag,value:e.Value})))||[]}}),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}(yield t.common.buildAndSendPacket({servcmd:"sns.friend_get_specified",data:e}))})}(r,this._core))||{},{successProfiles:c,failedProfiles:u}=this._processFriendProfileResponse(a);return{code:0,data:{friendList:c,failureUserIDList:[...u,...i]}}}catch(s){const{errorCode:e}=s||{};throw new this._core.helper.ChatError({code:e})}})}addFriend(e){return pe(this,void 0,void 0,function*(){var t;const{helper:s,store:n,ssoLog:o}=this._core;try{const{to:i,source:r,type:a,wording:c,remark:u,groupName:l}=e,d={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,AddFriendItem:[{To_Account:i,AddSource:r,AddWording:c,GroupName:l,Remark:u}],AddType:a},h=yield function(e,t){return pe(this,void 0,void 0,function*(){return Ql(yield t.common.buildAndSendPacket({servcmd:"sns.friend_add",data:e}))})}(d,this._core),{resultList:p=[]}=h,{userID:g,resultCode:_}=p[0];if(0===_)return o.debug("addFriend",`${kl} addFriend ok`),{code:0,data:{userID:g}};if(_===Bl)return o.debug("addFriend",`${kl} addFriend wait for the other party to agree`),{code:0,data:{userID:g,code:_,message:"wait for the other party to agree"}};throw new s.ChatError({functionName:"addFriend",code:_})}catch(i){const{errorCode:e}=i||{};throw new s.ChatError({code:e})}})}deleteFriend(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,ssoLog:n,helper:o}=this._core;try{let{userIDList:o,type:i}=e;const r=null===(t=s.get("login"))||void 0===t?void 0:t.userId;o.length>1e3&&(n.info("deleteFriend",`${kl} deleteFriend the length of userIDList cannot exceed:1000`),o=o.slice(0,Gl));const{friendUserIdList:a,unFriendUserIdList:c}=this.partitionByIsFriend(o);if(0===a.length)return{code:0,data:{friendList:[],failureUserIDList:this._createNonFriendErrorList(c)}};const u={From_Account:r,To_Account:a,DeleteType:i},l=yield function(e,t){return pe(this,void 0,void 0,function*(){return Ql(yield t.common.buildAndSendPacket({servcmd:"sns.friend_delete",data:e}))})}(u,this._core),{successUserIDList:d,failureUserIDList:h}=this._processOperationResult({resultList:l.resultList,includeRelation:!1});return{code:0,data:{successUserIDList:d,failureUserIDList:h}}}catch(i){const{errorCode:e}=i||{};throw new o.ChatError({code:e})}})}updateFriend(e){return pe(this,void 0,void 0,function*(){var t;const{helper:s,store:n,appStore:{userStore:o}}=this._core;try{const{userID:i,remark:r,friendCustomField:a}=e,c=null===(t=n.get("login"))||void 0===t?void 0:t.userId;if(!o.getFriendMap().has(i))throw new s.ChatError({functionName:"updateFriend",code:Ul});const u={From_Account:c,UpdateItem:[{To_Account:i,SnsItem:this._buildSnsItemList(r,a)}]},l=yield Jl(u,this._core),{resultList:d}=l,{to:h,resultCode:p,resultInfo:g}=d[0];if(Zl(p)||0===p)return{code:0,data:this._updateLocalFriend({userID:h,remark:r,friendCustomField:a})};throw new s.ChatError({functionName:"updateFriend",code:p,message:g})}catch(i){const{errorCode:e}=i||{};throw new s.ChatError({code:e})}})}checkFriend(e){return pe(this,void 0,void 0,function*(){var t;const{OuterConstant:s,store:n,helper:o}=this._core;try{const{userIDList:o,type:i}=e,r={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,To_Account:o,CheckType:i===s.SNS_CHECK_TYPE_SINGLE?i:s.SNS_CHECK_TYPE_BOTH},a=yield Xl(r,this._core),{successUserIDList:c=[],failureUserIDList:u=[]}=this._processOperationResult({resultList:a.resultList,includeRelation:!0});return{code:0,data:{successUserIDList:c,failureUserIDList:u}}}catch(i){const{errorCode:e}=i||{};throw new o.ChatError({code:e})}})}dispose(){this.reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this)}reset(){const{userStore:e}=this._core.appStore;e.getFriendMap().clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}updateFriendList(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("updateFriendList",`${kl} updateFriendList data:${s(e)}`);const{userStore:n}=this._core.appStore,{addedFriendList:o=[],removedFriendList:i=[]}=e;o.length>0&&(o.forEach(e=>{const t=new td({userID:e,core:this._core});n.getFriendMap().set(e,t)}),yield this.getFriendProfile({userIDList:o}),this._emitFriendListUpdated()),i.length>0&&(i.forEach(e=>{n.getFriendMap().delete(e)}),this._emitFriendListUpdated())})}updateFriendInfo(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("updateFriendList",`${kl} updateFriendInfo data:${s(e)}`);const{appStore:{userStore:n,conversationStore:o},utils:{isEmpty:i}}=this._core,{userID:r,tagValueList:a}=e[0]||{},c=n.getFriend(r);if(i(a)||!c)return;const u=a.map(e=>({tag:e.BytesTag,value:e.BytesValue}));u.forEach(e=>{var t;const{tag:s,value:n}=e,i=null===(t=o.getConversation(`C2C${r}`))||void 0===t?void 0:t.remark;s===Wl.REMARK&&n!==i&&o.updateConversation(`C2C${r}`,{remark:n}),c.update(u)}),this._emitFriendListUpdated()}_processFriendList(e){const{utils:{isEmpty:t},appStore:{userStore:s}}=this._core;t(e)||e.forEach(e=>{const{userID:t,tagValueList:n}=e;if(this._isInvalidFriend(t))return;const o=new td({userID:t,tagValueList:n,core:this._core});s.getFriendMap().set(t,o)})}_isInvalidFriend(e){return"@TLS#NOT_FOUND"===e||""===e}_fetchFriendProfile(){return pe(this,void 0,void 0,function*(){const{appStore:{userStore:e},user:{userProfile:t},ssoLog:s}=this._core;s.debug("_fetchFriendProfile",`${kl} _fetchFriendProfile`);const n=[...e.getFriendMap().keys()],o=Math.ceil(n.length/100);for(let i=0;i<o;i++){const s=100*i,o=Math.min(s+100,n.length),r=n.slice(s,o),a=yield null==t?void 0:t.getUserProfile({userIDList:r});a&&a.data&&a.data.forEach(t=>{const s=e.getFriend(t.userID);s&&(s.profile=t)}),this._emitFriendListUpdated()}})}_emitFriendListUpdated(){const{notificationCenter:e,OuterEvent:t,appStore:{userStore:s}}=this._core,n=Array.from(s.getFriendMap().values());e.emitOuterEvent(t.FRIEND_LIST_UPDATED,{name:t.FRIEND_LIST_UPDATED,data:n})}_updateCustomField(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let s=!1;return t.forEach(({key:t,value:n})=>{const o=e.find(e=>e.key===t);o?o.value!==n&&(o.value=n,s=!0):(e.push({key:t,value:n}),s=!0)}),s}_updateLocalFriend(e){const{userStore:t}=this._core.appStore,{userID:s,remark:n,friendCustomField:o}=e,i=t.getFriend(s);if(i)return Zl(n)||(i.remark=n),Array.isArray(o)&&o.length>0&&this._updateCustomField(i.friendCustomField,o),this._emitFriendListUpdated(),i}_processOperationResult(e){const{resultList:t,includeRelation:s=!1}=e,{isEmpty:n}=this._core.utils,o=[],i=[];return Array.isArray(t)&&!n(t)&&t.forEach(e=>{const{userID:t,relation:n,resultCode:r,resultInfo:a}=e;if(Zl(r)||0===r){const e={userID:t};s&&(e.code=0,e.relation=n),o.push(e)}else i.push({userID:t,code:r,message:a})}),{successUserIDList:o,failureUserIDList:i}}_createNonFriendErrorList(e){return e.map(e=>({userID:e,code:Ul,message:"The specified userID is not my friend"}))}_buildSnsItemList(e,t){const s=[];return Zl(e)||s.push({Tag:Wl.REMARK,Value:e}),Array.isArray(t)&&t.length>0&&t.forEach(e=>{s.push({tag:e.key,value:e.value})}),s}_processFriendProfileResponse(e){const{friendProfileList:t=[]}=e,{userStore:s}=this._core.appStore,n=[],o=[];return t.forEach(e=>{const{userID:t,resultCode:i,resultInfo:r,profileItem:a}=e;if(0===i){const e=new td({userID:t,tagValueList:a,core:this._core});n.push(e),s.getFriendMap().set(t,e)}else o.push({userID:t,code:i,message:r})}),{successProfiles:n,failedProfiles:o}}partitionByIsFriend(e){const t=[],s=[];return e.forEach(e=>{const{userStore:n}=this._core.appStore;n.getFriendMap().has(e)?t.push(e):s.push(e)}),{friendUserIdList:t,unFriendUserIdList:s}}isMyFriend(e){const{userStore:t}=this._core.appStore;return t.getFriendMap().has(e)}},nd=new class{init(e){this.core=e}};function od(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,common:n}=nd.core,o={From_Account:null===(t=s.get("login"))||void 0===t?void 0:t.userId,ResponseFriendItem:[{To_Account:e.userID,ResponseAction:e.type,Remark:e.remark}]};return ad(yield n.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function id(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,common:n}=nd.core,o={From_Account:null===(t=s.get("login"))||void 0===t?void 0:t.userId,ResponseFriendItem:[{To_Account:e.userID,ResponseAction:"Response_Action_Reject"}]};return ad(yield n.buildAndSendPacket({servcmd:"sns.friend_response",data:o}))})}function rd(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,common:n}=nd.core,o={From_Account:null===(t=s.get("login"))||void 0===t?void 0:t.userId,To_Account:[e.userID],PendencyType:e.type};return ad(yield n.buildAndSendPacket({servcmd:"sns.pendency_delete",data:o}))})}function ad(e){const{ResultItem:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{resultList:t.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}var cd=new class{constructor(){this._friendApplicationMap=new Map,this._unreadCount=0,this._startTime=0,this._currentSequence=0}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendApplicationList",context:this,methodName:"getFriendApplicationListFromCache"}),t.registerApi({apiName:"acceptFriendApplication",context:this}),t.registerApi({apiName:"refuseFriendApplication",context:this}),t.registerApi({apiName:"deleteFriendApplication",context:this}),t.registerApi({apiName:"setFriendApplicationRead",context:this})}getFriendApplicationListFromCache(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core,s=[...this._friendApplicationMap.values()];return e.debug("getFriendApplicationListFromCache",`${kl} getFriendApplicationListFromCache friendApplicationList:${t(s)}`),{code:0,data:{friendApplicationList:s,unreadCount:this._unreadCount}}})}syncFriendApplicationListFromServer(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core,s="syncFriendApplicationListFromServer";try{const e=yield function(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,OuterConstant:n,common:o}=nd.core,i={From_Account:null===(t=s.get("login"))||void 0===t?void 0:t.userId,PendencyType:n.SNS_APPLICATION_TYPE_BOTH,MaxLimited:Gl,StartTime:e.startTime,LastSequence:e.currentSequence};return function(e){const{PendencyItem:t=[],StartTime:s,UnreadPendencyCount:n,CurrentSequence:o,ActionStatus:i,ErrorCode:r,ErrorInfo:a,ErrorDisplay:c}=e;return{resultList:t.map(e=>({userID:e.To_Account,time:e.AddTime,source:e.AddSource,wording:e.AddWording,nick:e.Nick,type:e.PendencyType,avatar:e.Image})),startTime:s,unreadCount:n,currentSequence:o,actionStatus:i,errorCode:r,errorInfo:a,errorDisplay:c}}(yield o.buildAndSendPacket({servcmd:"sns.pendency_get",data:i}))})}({startTime:this._startTime,currentSequence:this._currentSequence}),{resultList:t,unreadCount:s,startTime:n,currentSequence:o}=e;this._startTime=n,this._currentSequence=o,this._unreadCount=s,this._friendApplicationMap.clear(),Array.isArray(t)&&t.forEach(e=>{const{userID:t,type:s}=e,n=this._createFriendApplication(e);this._friendApplicationMap.set(`${t}_${s}`,n)}),this._emitApplicationListUpdated()}catch(n){const t=new this._core.helper.ChatError({functionName:s,code:null==n?void 0:n.errorCode,message:null==n?void 0:n.errorInfo});throw e.error("syncFriendApplicationListFromServer",`${kl} ${s} error:`,{error:t}),t}})}acceptFriendApplication(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:{SNS_APPLICATION_AGREE:t,SNS_APPLICATION_AGREE_AND_ADD:s}}=this._core;return[t,s].includes(e.type)||(e.type=s),this._operationApplication({functionName:"acceptFriendApplication",options:e,protocolFunction:od})})}refuseFriendApplication(e){return pe(this,void 0,void 0,function*(){return this._operationApplication({functionName:"refuseFriendApplication",options:e,protocolFunction:id})})}deleteFriendApplication(e){return pe(this,void 0,void 0,function*(){const{userID:t,type:s}=e;return this._checkApplicationExists(t,s,"deleteFriendApplication"),this._operationApplication({functionName:"deleteFriendApplication",options:e,protocolFunction:rd})})}_checkApplicationExists(e,t,s){if(!this._friendApplicationMap.has(`${e}_${t}`))throw new this._core.helper.ChatError({functionName:s,code:$l})}_operationApplication(e){return pe(this,void 0,void 0,function*(){const{functionName:t,options:s,protocolFunction:n}=e;console.log(`${kl} ${t} options:`,s);try{const e=yield n(s),{resultList:o=[]}=e,{resultCode:i,resultInfo:r}=o[0];if(0===i)return console.log(`${kl} ${t} ok`),{code:0,data:{}};throw{errorCode:i,errorInfo:r}}catch(o){const e=new this._core.helper.ChatError({functionName:t,code:null==o?void 0:o.errorCode,message:null==o?void 0:o.errorInfo});throw console.error(`${kl} ${t} error:`,e),e}})}setFriendApplicationRead(){return pe(this,void 0,void 0,function*(){try{return yield function(){return pe(this,void 0,void 0,function*(){var e;const{store:t,common:s}=nd.core,n={From_Account:null===(e=t.get("login"))||void 0===e?void 0:e.userId,LatestPendencyTimeStamp:(o=Math.floor(Date.now()/1e3),i=0,Math.round(Number(o)*Math.pow(10,i))/Math.pow(10,i))};var o,i;return function(e){const{ActionStatus:t,ErrorCode:s,ErrorInfo:n,ErrorDisplay:o}=e;return{actionStatus:t,errorCode:s,errorInfo:n,errorDisplay:o}}(yield s.buildAndSendPacket({servcmd:"sns.pendency_report",data:n}))})}(),this._unreadCount=0,this._emitApplicationListUpdated(),{code:0,data:{}}}catch(_){throw new this._core.helper.ChatError({functionName:"setFriendApplicationRead",code:null==_?void 0:_.errorCode,message:null==_?void 0:_.errorInfo})}})}updateFriendApplicationList(e){const{from:t,addedApplicationList:s=[],removedApplicationList:n=[]}=e,{isEmpty:o}=this._core.utils;o(s)||this.onApplicationAdded(s,t),o(n)||this.onApplicationDeleted()}onApplicationAdded(e,t){var s;const{store:n,OuterConstant:o}=this._core,i=t===(null===(s=n.get("login"))||void 0===s?void 0:s.userId)?o.SNS_APPLICATION_SENT_BY_ME:o.SNS_APPLICATION_SENT_TO_ME;e.forEach(e=>{const t=`${e.userID}_${i}`;i!==o.SNS_APPLICATION_SENT_TO_ME||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,this._createFriendApplication(Object.assign(Object.assign({},e),{type:i})))}),this._emitApplicationListUpdated()}onApplicationDeleted(){this._startTime=0,this._currentSequence=0,this.syncFriendApplicationListFromServer()}onApplicationRead(){this._unreadCount=0,this._emitApplicationListUpdated()}reset(){this._startTime=0,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}dispose(){this.reset()}_createFriendApplication(e){return{userID:e.userID||"",nick:e.nick||"",avatar:e.avatar||"",time:e.time||0,source:e.source||"",wording:e.wording||"",type:e.type||""}}_emitApplicationListUpdated(){const{notificationCenter:e,OuterEvent:t}=this._core;e.emitOuterEvent(t.FRIEND_APPLICATION_LIST_UPDATED,{name:t.FRIEND_APPLICATION_LIST_UPDATED,data:{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}})}};function ud(){return pe(this,void 0,void 0,function*(){const{common:e}=nd.core,t={From_Account:e.getCurrentUserID(),LastSequence:0,NeedFriend:"Need_Friend_Type_Yes"};return md(yield e.buildAndSendPacket({servcmd:"sns.group_get",data:t}),e=>({name:e.GroupName,userIDList:e.To_Account||[],count:e.FriendNumber}))})}function ld(e){return pe(this,void 0,void 0,function*(){const{name:t,userIDList:s}=e,{common:n}=nd.core,o={From_Account:n.getCurrentUserID(),GroupName:[t],To_Account:s};return md(yield n.buildAndSendPacket({servcmd:"sns.group_add",data:o}),e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function dd(e){return pe(this,void 0,void 0,function*(){const{common:t}=nd.core,s={From_Account:t.getCurrentUserID(),GroupName:[e.name]};return md(yield t.buildAndSendPacket({servcmd:"sns.group_delete",data:s}))})}function hd(e){return pe(this,void 0,void 0,function*(){const{common:t}=nd.core,{name:s,userIDList:n}=e,o=_d(n,jl),i={From_Account:t.getCurrentUserID(),GroupOldName:s,UpdateGroupItem:o};return md(yield t.buildAndSendPacket({servcmd:"sns.group_update",data:i}),e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function pd(e){return pe(this,void 0,void 0,function*(){const{common:t}=nd.core,{name:s,userIDList:n}=e,o=_d(n,Hl),i={From_Account:t.getCurrentUserID(),GroupOldName:s,UpdateGroupItem:o};return md(yield t.buildAndSendPacket({servcmd:"sns.group_update",data:i}),e=>({userID:e.To_Account,updateType:e.UpdateType,resultCode:e.ResultCode,resultInfo:e.ResultInfo}))})}function gd(e){return pe(this,void 0,void 0,function*(){const{common:t}=nd.core,{oldName:s,newName:n}=e,o={From_Account:t.getCurrentUserID(),GroupOldName:s,GroupNewName:n};return md(yield t.buildAndSendPacket({servcmd:"sns.group_update",data:o}))})}function _d(e,t){return e.filter(e=>sd.isMyFriend(e)).map(e=>({To_Account:e,UpdateType:t}))}function md(e,t){const{CurrentSequence:s,ActionStatus:n,ErrorCode:o,ErrorInfo:i,ErrorDisplay:r,ResultItem:a=[]}=e,c={currentSequence:s,actionStatus:n,errorCode:o,errorInfo:i,errorDisplay:r};return t&&a.length>0?Object.assign(Object.assign({},c),{resultList:a.map(t)}):c}class fd{constructor(e){const{name:t="",userIDList:s=[]}=e;this.name=t,this.userIDList=s,this.count=s.length}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){const t=this.userIDList.indexOf(e);t>-1&&(this.userIDList.splice(t,1),this.count=this.userIDList.length)}}var vd=new class{constructor(){this._friendGroupMap=new Map}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getFriendGroupList",context:this,methodName:"getFriendGroupListFromCache"}),t.registerApi({apiName:"createFriendGroup",context:this}),t.registerApi({apiName:"deleteFriendGroup",context:this}),t.registerApi({apiName:"addToFriendGroup",context:this}),t.registerApi({apiName:"removeFromFriendGroup",context:this}),t.registerApi({apiName:"renameFriendGroup",context:this})}getFriendGroupListFromCache(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core,s=[...this._friendGroupMap.values()];return e.debug(`${kl} getFriendGroupListFromCache, data:${t(s)}`),{code:0,data:s}})}syncFriendGroupListFromServer(){return pe(this,void 0,void 0,function*(){const{ssoLog:e}=this._core,t="syncFriendGroupListFromServer";try{const s=yield ud(),{resultList:n=[]}=s;this._core.helper.isEmpty(n)&&e.debug("syncFriendGroupListFromServer",`${kl} ${t} ok. count: 0`),n.forEach(e=>{const t=new fd(e);this._friendGroupMap.set(e.name,t)}),this._emitGroupListUpdated()}catch(s){this._handleError(t,s)}})}createFriendGroup(e){return pe(this,void 0,void 0,function*(){const t="createFriendGroup";try{const{name:s}=e;this._checkGroupExist(t,s);const n=yield ld(e),{successUserIDList:o,failureUserIDList:i}=this._parseCreateGroupResponse(n),r=new fd({name:s,userIDList:o});return this._friendGroupMap.set(s,r),this._emitGroupListUpdated(),{code:0,data:{friendGroup:r,failureUserIDList:i}}}catch(s){this._handleError(t,s)}})}deleteFriendGroup(e){return pe(this,void 0,void 0,function*(){const t="deleteFriendGroup";try{const{name:s}=e;this._checkGroupNotExist(t,s),yield dd(e);const n=this._friendGroupMap.get(s);return n&&(this._updateFriendGroup({name:s,userIDList:n.userIDList,action:Yl}),this._friendGroupMap.delete(s)),this._emitGroupListUpdated(),{code:0,data:n}}catch(s){this._handleError(t,s)}})}addToFriendGroup(e){return pe(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"addToFriendGroup",params:e,protocolFunction:hd})})}removeFromFriendGroup(e){return pe(this,void 0,void 0,function*(){return this._updateFriendGroupMember({functionName:"removeFromFriendGroup",params:e,protocolFunction:pd})})}renameFriendGroup(e){return pe(this,void 0,void 0,function*(){const t="renameFriendGroup";try{const{oldName:s,newName:n}=e;this._checkGroupNotExist(t,s),this._checkGroupExist(t,n),yield gd(e);const o=this._updateGroupNameInCache(s,n);return o&&this._updateFriendGroup({name:s,userIDList:o.userIDList,action:zl,newName:n}),this._emitGroupListUpdated(),{code:0,data:o}}catch(s){this._handleError(t,s)}})}_updateFriendGroupMember(e){return pe(this,void 0,void 0,function*(){const{functionName:t,params:s,protocolFunction:n}=e;try{const{name:e}=s;this._checkGroupNotExist(t,e);const o=yield n(s),{friendGroup:i,failureUserIDList:r}=this._parseUpdateFriendGroupResponse(e,o);return this._emitGroupListUpdated(),{code:0,data:{friendGroup:i,failureUserIDList:r}}}catch(o){this._handleError(t,o)}})}_updateGroupNameInCache(e,t){const s=this._friendGroupMap.get(e);return s&&(s.name=t,this._friendGroupMap.delete(e),this._friendGroupMap.set(t,s)),s}_parseCreateGroupResponse(e){const{resultList:t=[]}=e,s=[],n=[];return t.forEach(({userID:e,resultCode:t,resultInfo:o})=>{Zl(t)||0===t?s.push(e):n.push({userID:e,code:t,message:o})}),{successUserIDList:s,failureUserIDList:n}}_parseUpdateFriendGroupResponse(e,t){const{resultList:s=[]}=t,n=this._friendGroupMap.get(e),o=[],i=[],r=[];return s.forEach(t=>{0===t.resultCode?n&&(t.updateType===jl?this._addFriendToGroup(e,t.userID,n,i):t.updateType===Hl&&this._removeFriendFromGroup(e,t.userID,n,r)):o.push({userID:t.userID,code:t.resultCode,message:t.resultInfo})}),{friendGroup:n,failureUserIDList:o}}_addFriendToGroup(e,t,s,n){s.addToUserIDList(t),n.push(t),this._updateFriendGroup({name:e,userIDList:n,action:Kl})}_removeFriendFromGroup(e,t,s,n){s.removeFromUserIDList(t),n.push(t),this._updateFriendGroup({name:e,userIDList:n,action:Yl})}_emitGroupListUpdated(){const{notificationCenter:e,OuterEvent:t}=this._core,s=[...this._friendGroupMap.values()];e.emitOuterEvent(t.FRIEND_GROUP_LIST_UPDATED,{name:t.FRIEND_GROUP_LIST_UPDATED,data:s})}_checkGroupNotExist(e,t){if(!this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:xl})}_checkGroupExist(e,t){if(this._friendGroupMap.has(t))throw new this._core.helper.ChatError({functionName:e,code:Fl})}_updateFriendGroup(e){const{name:t,userIDList:s,action:n,newName:o}=e,{userStore:i}=this._core.appStore;t&&!this._core.utils.isEmpty(s)&&s.forEach(e=>{const s=i.getFriend(e);if(!s)return;const{groupList:r}=s;switch(n){case Kl:-1===r.indexOf(t)&&(r.push(t),s.count=r.length);break;case Yl:{const e=r.indexOf(t);e>-1&&(r.splice(e,1),s.count=r.length);break}case zl:{if(!o)return;const e=r.indexOf(t);-1!==e&&(r[e]=o);break}}})}_handleError(e,t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}reset(){this._friendGroupMap.clear()}dispose(){this.reset()}};function Id(e){return e&&0!==e.length?e.map(e=>({userID:e.To_Account,addBlackTimeStamp:e.AddBlackTimeStamp})):[]}var Ed=new class{constructor(){this._blacklistMap=new Map,this._retryCount=0,this._startIndex=0}init(e){this._core=e;const{helper:t,constants:s}=e;t.registerApi({apiName:"getBlacklist",context:this,methodName:"getBlacklistFromCache"}),t.registerApi({apiName:"addToBlacklist",context:this}),t.registerApi({apiName:"removeFromBlacklist",context:this}),t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.BLACKLIST_RECOVER,this.syncBlacklistFromServer,this)}getBlacklistFromCache(){return pe(this,void 0,void 0,function*(){return{code:0,data:Array.from(this._blacklistMap.keys())}})}syncBlacklistFromServer(){return pe(this,void 0,void 0,function*(){try{this._core.ssoLog.debug(`${kl} syncBlacklistFromServer`);const e={From_Account:this._core.common.getCurrentUserID(),MaxLimited:Gl,StartIndex:this._startIndex},t=yield function(e,t){return pe(this,void 0,void 0,function*(){const{helper:s,channel:n}=t,o="sns.black_list_get",i=s.generateProtocolData({servcmd:o,data:e}),r=`${i.head.seq}${o}`,a=yield n.sendPacket(i,{requestId:r}),{BlackListItem:c=[],StartIndex:u=0}=a;return{blackList:Id(c),startIndex:u}})}(e,this._core),{blackList:s=[],startIndex:n=0}=t;return this._startIndex=n,this._addBlacklistMap(s),this._emitBlackListUpdated(),0!==this._startIndex&&this._retryCount<10?(this._retryCount++,yield this.syncBlacklistFromServer()):this._retryCount=0,{code:0,data:Array.from(this._blacklistMap.keys())}}catch(_){throw this._retryCount=0,_}})}addToBlacklist(e){return pe(this,void 0,void 0,function*(){const{helper:t}=this._core;try{const t=this._preprocessBlacklist(e),s={From_Account:this._core.common.getCurrentUserID(),To_Account:t},n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{helper:s,channel:n}=t,o="sns.black_list_add",i=s.generateProtocolData({servcmd:o,data:e}),r=`${i.head.seq}${o}`,a=yield n.sendPacket(i,{requestId:r}),{ResultItem:c=[]}=a;return{blackList:Id(c)}})}(s,this._core),{blackList:o=[]}=n;return this._addBlacklistMap(o),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(s){const{errorCode:e}=s||{};throw new t.ChatError({code:e})}})}removeFromBlacklist(e){return pe(this,void 0,void 0,function*(){const{helper:t}=this._core;try{const t={From_Account:this._core.common.getCurrentUserID(),To_Account:e.userIDList},s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{helper:s,channel:n}=t,o="sns.black_list_delete",i=s.generateProtocolData({servcmd:o,data:e}),r=`${i.head.seq}${o}`,a=yield n.sendPacket(i,{requestId:r}),{ResultItem:c=[]}=a;return{blackList:Id(c)}})}(t,this._core),{blackList:n=[]}=s;return this._deleteBlacklistMap(n),this._emitBlackListUpdated(),{code:0,data:Array.from(this._blacklistMap.keys())}}catch(s){const{errorCode:e}=s||{};throw new t.ChatError({code:e})}})}dispose(){this.reset()}reset(){this._retryCount=0,this._startIndex=0,this._blacklistMap.clear()}updateBlacklist(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("updateBlacklist",`${kl} updateBlacklist data: ${s(e)}`);const{addedBlacklist:n=[],removedBlacklist:o=[]}=e;let i=!1;n.length>0&&n.some(e=>!this._blacklistMap.has(e))&&(i=!0,this._addBlacklistMap(n.map(e=>({userID:e})))),o.length>0&&o.some(e=>this._blacklistMap.has(e))&&(i=!0,this._deleteBlacklistMap(o.map(e=>({userID:e})))),i&&this._emitBlackListUpdated()}_addBlacklistMap(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("_addBlacklistMap",`${kl} _addBlacklistMap blackList: ${s(e)}`),e.forEach(e=>{const{userID:t,addBlackTimeStamp:s=Date.now()}=e;t&&!this._blacklistMap.has(t)&&this._blacklistMap.set(t,{userID:t,addBlackTimeStamp:s})})}_deleteBlacklistMap(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("_deleteBlacklistMap",`${kl} _deleteBlacklistMap blackList: ${s(e)}`),e.forEach(e=>{const{userID:t}=e;t&&this._blacklistMap.has(t)&&this._blacklistMap.delete(t)})}_preprocessBlacklist(e){let{userIDList:t}=e;const s=this._core.common.getCurrentUserID();if(1===t.length&&t[0]===s)throw new this._core.helper.ChatError({functionName:"addToBlacklist",code:ql});return t.includes(s)&&(t=e.userIDList.filter(e=>e!==s)),t}_emitBlackListUpdated(){const{notificationCenter:e,OuterEvent:t,ssoLog:s,utils:{safeStringify:n}}=this._core,o=Array.from(this._blacklistMap.keys());s.debug(`${kl} _emitBlackListUpdated blackList:${n(o)}`),e.emitOuterEvent(t.BLACKLIST_UPDATED,{name:t.BLACKLIST_UPDATED,data:o})}};const Sd={addToBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromBlacklist:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},getFriendProfile:{userIDList:{required:!0,rules:["array"],allowEmpty:!1}},addFriend:{to:{required:!0,rules:["string"],allowEmpty:!1},source:{required:!0,rules:["string"],allowEmpty:!1},wording:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=nd.core;return e===t.SNS_ADD_TYPE_SINGLE||e===t.SNS_ADD_TYPE_BOTH||"type should be SNS_ADD_TYPE_SINGLE or SNS_ADD_TYPE_BOTH"}},remark:{required:!1,rules:["string"],allowEmpty:!0},groupName:{required:!1,rules:["string"],allowEmpty:!0}},deleteFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=nd.core;return e===t.SNS_DELETE_TYPE_SINGLE||e===t.SNS_DELETE_TYPE_BOTH||"type should be SNS_DELETE_TYPE_SINGLE or SNS_DELETE_TYPE_BOTH"}}},checkFriend:{userIDList:{required:!0,rules:["array"],allowEmpty:!1},type:{required:!1,rules:["string"],allowEmpty:!0}},updateFriend:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},friendCustomField:{required:!1,rules:["array"],allowEmpty:!0}},acceptFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},remark:{required:!1,rules:["string"],allowEmpty:!0},type:{required:!1,rules:["string"],allowEmpty:!0}},refuseFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1}},deleteFriendApplication:{userID:{required:!0,rules:["string"],allowEmpty:!1},type:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>{const{OuterConstant:t}=nd.core;return e===t.SNS_APPLICATION_SENT_TO_ME||e===t.SNS_APPLICATION_SENT_BY_ME||"type should be SNS_APPLICATION_SENT_TO_ME or SNS_APPLICATION_SENT_BY_ME"}}},createFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},deleteFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1}},addToFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},removeFromFriendGroup:{name:{required:!0,rules:["string"],allowEmpty:!1},userIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameFriendGroup:{oldName:{required:!0,rules:["string"],allowEmpty:!1},newName:{required:!0,rules:["string"],allowEmpty:!1}}},yd={getBlacklist:!0,addToBlacklist:!0,removeFromBlacklist:!0,getFriendList:!0,addFriend:!0,deleteFriend:!0,updateFriend:!0,checkFriend:!0,getFriendProfile:!0,getFriendApplicationList:!0,acceptFriendApplication:!0,refuseFriendApplication:!0,deleteFriendApplication:!0,setFriendApplicationRead:!0,getFriendGroupList:!0,createFriendGroup:!0,deleteFriendGroup:!0,addToFriendGroup:!0,removeFromFriendGroup:!0,renameFriendGroup:!0};var Cd=new class{constructor(){this.name="Friend"}install(e){e.ssoLog.debug(`${kl} install`),this._core=e;const{helper:t,notificationCenter:s,InnerEvent:n,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i}}=e;nd.init(e),sd.init(e),cd.init(e),vd.init(e),Ed.init(e),t.registerValidateConfig({auth:yd,params:Sd}),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.FRIEND_AND_BLACKLIST_SYNC,this.handleLoginSuccess,this),s.subscribeInnerEvent(n.LOGOUT,this.reset,this),s.subscribeInnerEvent(n.MESSAGE_PUSH,s.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this)}handleLoginSuccess(){Ed.syncBlacklistFromServer(),sd.syncFriendListFromServer(),cd.syncFriendApplicationListFromServer(),vd.syncFriendGroupListFromServer()}onFriendModified(e){const{from:t,addedBlacklist:s,removedBlacklist:n,addedFriendList:o,removedFriendList:i,addedApplicationList:r,removedApplicationList:a,friendUpdateInfo:c,reportTime:u}=this._parseFriendListModification(null==e?void 0:e.FriendListMod[0]),{isEmpty:l}=this._core.utils;l(s)&&l(n)||Ed.updateBlacklist({addedBlacklist:s,removedBlacklist:n}),l(o)&&l(i)||(sd.updateFriendList({addedFriendList:o,removedFriendList:i}),cd.updateFriendApplicationList({from:t,removedApplicationList:o})),l(c)||sd.updateFriendInfo(c),l(r)&&l(a)||cd.updateFriendApplicationList({from:t,addedApplicationList:r,removedApplicationList:a}),u&&cd.onApplicationRead()}_parseFriendListModification(e){const{PushType:t,From_Account:s,To_Account:n,ReportTime:o,BlackListAdd_Account:i=[],BlackListDel_Account:r=[],FriendAdd_Account:a=[],FriendDel_Account:c=[],PendencyAdd:u=[],FrienPencydDel_Account:l=[],FriendUpInfo:d=[]}=e,h=d.map(e=>({userID:e.Friend_Account,tagValueList:[...e.SNS]}));return{pushType:t,from:s,to:n,reportTime:o,addedBlacklist:i,removedBlacklist:r,addedFriendList:a,removedFriendList:c,addedApplicationList:u.map(e=>({userID:e.PendencyAdd_Account,source:e.AddSource,time:e.AddTime,wording:e.AddWording,nick:e.ProfileImNick})),friendUpdateInfo:h,removedApplicationList:l}}reset(){Ed.reset(),sd.reset(),cd.reset(),vd.reset()}dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,e.InnerEventSubType.FRIEND_LIST_MODIFIED,this.onFriendModified,this),Ed.dispose(),sd.dispose(),cd.dispose(),vd.dispose()}};const Md=new class{init(e){this.core=e}},Ad="Follow",bd="FOLLOW",Td=3122,Od={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};function wd(e,t){return pe(this,void 0,void 0,function*(){var s;const{common:n,store:o}=Md.core,i={FollowType:e,From_Account:null===(s=o.get("login"))||void 0===s?void 0:s.userId,StartCursor:t,WantNum:kd()};return function(e){const{FollowItem:t=[],NextCursor:s,ActionStatus:n,ErrorCode:o,ErrorInfo:i,ErrorDisplay:r}=e;return{resultList:t.map(e=>({userID:e.To_Account,followTime:e.FollowTime,profileItem:e.ProfileItem,profileSequence:e.ProfileSequence})),nextPageToken:s,actionStatus:n,errorCode:o,errorInfo:i,errorDisplay:r}}(yield n.buildAndSendPacket({servcmd:"follow.follow_get",data:i}))})}function Dd(e){return pe(this,void 0,void 0,function*(){return wd(Od.FOLLOWERS,e)})}function Rd(e){return pe(this,void 0,void 0,function*(){return wd(Od.MUTUAL,e)})}function Ld(e){return pe(this,void 0,void 0,function*(){return wd(Od.FOLLOWING,e)})}function Nd(e){return pe(this,void 0,void 0,function*(){var t;const{common:s,store:n}=Md.core,o={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,FollowItem:e.map(e=>({To_Account:e}))};return function(e){const{ResultItem:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{resultList:t.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}(yield s.buildAndSendPacket({servcmd:"follow.follow_add",data:o}))})}function Pd(e){return pe(this,void 0,void 0,function*(){var t;const{common:s,store:n}=Md.core,o={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,To_Account:e};return function(e){const{ResultItem:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{resultList:t.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}(yield s.buildAndSendPacket({servcmd:"follow.follow_delete",data:o}))})}function kd(){const e=Md.core.store.get("cloudConfig")||{},t=null==e?void 0:e.follow_req_count;if(void 0!==t){const e=Number(t);return e>1e3?1e3:e}return 500}const Gd={getMyFollowersList:[{required:!1,rules:["string"],allowEmpty:!0}],getMyFollowingsList:[{required:!1,rules:["string"],allowEmpty:!0}],getMutualFollowersList:[{required:!1,rules:["string"],allowEmpty:!0}],followUser:[{required:!0,rules:["array"],allowEmpty:!1}],unfollowUser:[{required:!0,rules:["array"],allowEmpty:!1}],checkFollow:[{required:!0,rules:["array"],allowEmpty:!1}],getUserFollowInfo:[{required:!0,rules:["array"],allowEmpty:!1}]},Ud={getMyFollowersList:!0,getMyFollowingsList:!0,getMutualFollowersList:!0,followUser:!0,unfollowUser:!0,checkFollow:!0,getUserFollowInfo:!0};var Fd=new class{constructor(){this.name="Follow"}install(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:n}=e;Md.init(e),t.registerApi({apiName:"getMyFollowingList",context:this}),t.registerApi({apiName:"getMyFollowersList",context:this}),t.registerApi({apiName:"getMutualFollowersList",context:this}),t.registerApi({apiName:"followUser",context:this}),t.registerApi({apiName:"unfollowUser",context:this}),t.registerApi({apiName:"getUserFollowInfo",context:this}),t.registerApi({apiName:"checkFollowType",context:this}),t.registerValidateConfig({auth:Ud,params:Gd}),s.subscribeInnerEvent(n.MESSAGE_PUSH,s.InnerEventSubType.FOLLOW_LIST_UPDATED,this.onFollowListUpdated,this)}getMyFollowingList(){return pe(this,arguments,void 0,function*(e=""){return this._getFollowList({functionName:"getMyFollowingList",protocolFunction:Ld,nextCursor:e})})}getMyFollowersList(){return pe(this,arguments,void 0,function*(e=""){return this._getFollowList({functionName:"getMyFollowersList",protocolFunction:Dd,nextCursor:e})})}getMutualFollowersList(){return pe(this,arguments,void 0,function*(e=""){return this._getFollowList({functionName:"getMutualFollowersList",protocolFunction:Rd,nextCursor:e})})}_getFollowList(e){return pe(this,void 0,void 0,function*(){const{functionName:t,protocolFunction:s,nextCursor:n=""}=e;try{this._checkBusinessCapabilityBits(t);const e=yield s(n),{resultList:o=[],nextPageToken:i=""}=e;return{code:0,data:{resultList:this._parseFollowItems(o),nextCursor:i},successLog:{message:`${t} nextCursor: ${n} from remote`}}}catch(o){this._handleError(t,o)}})}followUser(e){return pe(this,void 0,void 0,function*(){return this._handleUserFollowRelation({functionName:"followUser",userIDList:e,protocolFunction:Nd})})}unfollowUser(e){return pe(this,void 0,void 0,function*(){return this._handleUserFollowRelation({functionName:"unfollowUser",userIDList:e,protocolFunction:Pd})})}_handleUserFollowRelation(e){return pe(this,void 0,void 0,function*(){const{functionName:t,userIDList:s,protocolFunction:n}=e;try{const e=this._sliceUserIDList(s,20);this._checkBusinessCapabilityBits(t);const{resultList:o=[]}=yield n(e);return{code:0,data:o}}catch(o){this._handleError(t,o)}})}getUserFollowInfo(e){return pe(this,void 0,void 0,function*(){const t="getUserFollowInfo";try{this._checkBusinessCapabilityBits(t);const s=e||[this._core.common.getCurrentUserID()];console.log(`${Ad} ${t} userIDList: ${s}`);const n=yield function(e){return pe(this,void 0,void 0,function*(){var t;const{common:s,store:n}=Md.core,o={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,To_Account:e};return function(e){const{FollowInfo:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{followInfoList:t.map(e=>({userID:e.To_Account,resultCode:e.ResultCode,resultInfo:e.ResultInfo,followerCount:e.FollowerCount,followingCount:e.FollowingCount,mutualFollowingCount:e.MutualFollowingCount})),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}(yield s.buildAndSendPacket({servcmd:"follow.follow_get_info",data:o}))})}(e),{followInfoList:o=[]}=n,i=[];return o.forEach(e=>{const{followerCount:t,followingCount:s,mutualFollowingCount:n}=e;i.push({followerCount:t,followingCount:s,mutualFollowingCount:n})}),{code:0,data:i}}catch(s){this._handleError(t,s)}})}checkFollowType(e){return pe(this,void 0,void 0,function*(){const t="checkFollowType";try{this._checkBusinessCapabilityBits(t),e.length>100&&(e=e.slice(0,100),this._core.ssoLog.warn(t,`${Ad} ${t} the length of userIDList cannot exceed 100`));const s=yield function(e){return pe(this,void 0,void 0,function*(){var t;const{common:s,store:n}=Md.core,o={From_Account:null===(t=n.get("login"))||void 0===t?void 0:t.userId,To_Account:e};return function(e){const{ResultItem:t=[],ActionStatus:s,ErrorCode:n,ErrorInfo:o,ErrorDisplay:i}=e;return{resultList:t.map(e=>({userID:e.To_Account,followType:e.FollowType,resultCode:e.ResultCode,resultInfo:e.ResultInfo})),actionStatus:s,errorCode:n,errorInfo:o,errorDisplay:i}}(yield s.buildAndSendPacket({servcmd:"follow.follow_check",data:o}))})}(e),{resultList:n=[]}=s;return{code:0,data:n.map(({userID:e,followType:t})=>({userID:e,followType:t}))}}catch(s){this._handleError(t,s)}})}onFollowListUpdated(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("onFollowListUpdated",`${Ad} onFollowListUpdated ${s(e)}`);const{FollowChangeList:n=[]}=e;n.forEach(e=>this._processFollowChangeItem(e))}_processFollowChangeItem(e){const{From_Account:t,FollowDiffList:s=[]}=e,n=he(e,["From_Account","FollowDiffList"]),o={userID:t,avatar:n.FaceUrl,nick:n.NickName};s.forEach(e=>{const t=this._updateFollowRelation(e,o);this._notifyFollowChanges(t)})}_updateFollowRelation(e,t){const{IsAdd:s,FollowType:n=0}=e,o=this._initFollowInfo(),i=o[n];return i.isAdd=1===s,i.userInfoList.push(i.isAdd?t:t.userID),o}_notifyFollowChanges(e){const{OuterEvent:t}=this._core,s={[Od.FOLLOWERS]:t.MY_FOLLOWERS_LIST_UPDATED,[Od.FOLLOWING]:t.MY_FOLLOWING_LIST_UPDATED,[Od.MUTUAL]:t.MUTUAL_FOLLOWERS_LIST_UPDATED};Object.entries(e).forEach(([e,t])=>{const n=Number(e);t.userInfoList.length>0&&s[n]&&this._emitFollowUpdated(s[n],t)})}_initFollowInfo(){const e={};return Object.values(Od).forEach(t=>{t!==Od.NONE&&(e[t]={userInfoList:[],isAdd:!1})}),e}_emitFollowUpdated(e,t){const{notificationCenter:s}=this._core;s.emitOuterEvent(e,{name:e,data:t})}_sliceUserIDList(e,t){return e.slice(0,t)}_checkBusinessCapabilityBits(e){const{helper:t,store:s}=this._core;if(!(s.get("commercialConfig")||new Map).get(bd))throw new t.ChatError({functionName:e,code:Td,replacement1:e})}_handleError(e,t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}_parseFollowItems(e){return e.map(e=>{var t;const{userID:s,followTime:n,profileItem:o=[]}=e,i=[];o.forEach(e=>{i.push({tag:e.Tag,value:e.Value})});const r=null===(t=this._core.user.userProfile)||void 0===t?void 0:t.createProfile(s,i);return{userID:s,followTime:n,nick:null==r?void 0:r.nick,avatar:null==r?void 0:r.avatar,allowType:null==r?void 0:r.allowType,adminForbidType:null==r?void 0:r.adminForbidType}})}};const xd=new class{init(e){this.core=e}},$d="message",qd="user",Bd={OR:"or",AND:"and"},Vd=20,Wd=20,Hd=20,Kd={required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>!e||!!(Array.isArray(e)&&e.length<=5)||"keywordList should be an array and length <= 5"},Yd={required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>!e||!![Bd.OR,Bd.AND].includes(e)||"keywordListMatchType should be OR or AND"},zd={required:!1,rules:["number"],allowEmpty:!0,customValidator:e=>"number"==typeof e&&e>=1&&e<=100||"count must be a number between 1 and 100"},Zd={required:!1,rules:["string"],allowEmpty:!0},Jd={required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=xd.core;if(!Array.isArray(e))return"groupTypeList should be an array";const s=[t.GRP_PUBLIC,t.GRP_COMMUNITY,t.GRP_WORK,t.GRP_MEETING];let n=!1;for(let o=0;o<e.length;o++)if(-1===s.indexOf(e[o])){n=!0;break}return!n||"groupTypeList should be supported group type"}},Xd=e=>({required:!1,rules:["number"],allowEmpty:!0,customValidator:t=>"number"==typeof t&&t>=0||`${e} should be a number >= 0';`}),Qd={required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=xd.core;return!![t.GENDER_FEMALE,t.GENDER_MALE].includes(e)||"gender is invalid"}},eh={searchCloudMessages:{keywordList:Kd,keywordListMatchType:Yd,cursor:Zd,senderUserIDList:{required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>!!(Array.isArray(e)&&e.length<=5)||"senderUserIDList should be an array and length <= 5"},messageTypeList:{required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=xd.core,s=[t.MSG_TEXT,t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_FILE,t.MSG_VIDEO,t.MSG_LOCATION,t.MSG_CUSTOM,t.MSG_MERGER];let n=!1;for(let o=0;o<e.length;o++)if(-1===s.indexOf(e[o])){n=!0;break}return!n||"messageTypeList should be supported message type"}},conversationID:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=xd.core;return!(!(null==e?void 0:e.startsWith(t.CONV_C2C))&&!(null==e?void 0:e.startsWith(t.CONV_GROUP))&&e!==t.CONV_SYSTEM)||"conversationID is invalid"}},timePosition:Xd("timePosition"),timePeriod:Xd("timePeriod")},searchCloudUsers:{keywordList:Kd,keywordListMatchType:Yd,cursor:Zd,count:zd,miniBirthday:Xd("miniBirthday"),maxBirthday:Xd("maxBirthday"),gender:Qd},searchCloudGroupMembers:{keywordList:Kd,keywordListMatchType:Yd,cursor:Zd,count:zd,groupTypeList:Jd,groupIDList:{required:!1,rules:["array"],allowEmpty:!0}},searchCloudGroups:{keywordList:Kd,keywordListMatchType:Yd,cursor:Zd,count:zd,groupTypeList:Jd}},th={searchCloudMessages:!0,searchCloudUsers:!0,searchCloudGroupMembers:!0,searchCloudGroups:!0};var sh=new class{constructor(){this.name="CloudSearch"}install(e){this._core=e,xd.init(e),e.helper.registerApi({apiName:"searchCloudMessages",context:this}),e.helper.registerApi({apiName:"searchCloudUsers",context:this}),e.helper.registerApi({apiName:"searchCloudGroupMembers",context:this}),e.helper.registerApi({apiName:"searchCloudGroups",context:this}),e.helper.registerValidateConfig({auth:th,params:eh})}searchCloudMessages(e){return pe(this,void 0,void 0,function*(){try{const{OuterConstant:t,helper:s}=this._core,{conversationID:n,timePeriod:o,timePosition:i}=e,r=he(e,["conversationID","timePeriod","timePosition"]),a=Object.assign({count:100},r);n&&(n.startsWith(t.CONV_C2C)?a.account=n.replace(t.CONV_C2C,""):n.startsWith(t.CONV_GROUP)&&(a.groupID=n.replace(t.CONV_GROUP,""))),this._setTimeRangeParams(a,{timePeriod:o,timePosition:i});const c=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,senderUserIDList:o,messageTypeList:i,endTime:r,startTime:a,cursor:c,account:u,groupID:l}=e,d={Count:t,KeywordList:s,MatchType:n,SendUserIDList:o,MsgTypeList:i,EndTime:r,StartTime:a,Cursor:c,PeerAccount:u,GroupID:l};return xd.core.common.buildAndSendPacket({servcmd:"message_search.query",data:d})})}(a);if(!c)return{code:0,data:{}};const{ErrorCode:u,ErrorInfo:l,TotalCount:d,Cursor:h="",ConversationMsgs:p=[]}=c;if(0!==u)throw{errorCode:u,errorInfo:l};const g=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} res: totalCount:${d}`;return{code:0,data:{searchResultList:p.map(n=>{const{MsgList:o,Count:i,GroupID:r,UserID:a}=n,c=r?`${t.CONV_GROUP}${r}`:`${t.CONV_C2C}${a}`;return this._isSearchingAllConversations(e)&&i>1?{conversationID:c,messageCount:i,messageList:[]}:{conversationID:c,messageCount:i,messageList:o.map(e=>s.isEmpty(r)?function(e,t){const s=t.OuterConstant.CONV_C2C,n=t.message.messageHelper.parseServerPushMessage(e),o=t.message.messageFactory.createMessage(Object.assign(Object.assign({},n),{conversationType:s,flow:"in"}));return o.setElement(n.elements),o}(e,this._core):function(e,t){const s=t.OuterConstant.CONV_GROUP,n=t.message.messageHelper.parseServerGroupMessage(e),o=t.message.messageFactory.createMessage(Object.assign(Object.assign({},n),{conversationType:s,flow:"in"}));return o.setElement(n.elements),o}(e,this._core))}}),cursor:h,totalCount:d},successLog:{message:g}}}catch(t){const{errorCode:e,errorInfo:s}=t||{};this._handleError({errorCode:e,errorInfo:s,searchType:$d,functionName:"searchCloudMessages"})}})}searchCloudUsers(e){return pe(this,void 0,void 0,function*(){var t;try{const{keywordListMatchType:s,count:n=Wd}=e,o=he(e,["keywordListMatchType","count"]),i=Object.assign({count:n,keywordListMatchType:s===Bd.AND?1:0},o);this._setBirthdayRangeParams(i,e);const r=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,miniBirthday:o,maxBirthday:i,cursor:r,gender:a}=e,c={Count:t,Keywords:s,KeywordMatchType:n,Cursor:r,UserBirthStart:o,UserBirthEnd:i,Gender:a};return xd.core.common.buildAndSendPacket({servcmd:"user_search.query",data:c})})}(i);if(!r)return{error:0,data:{}};const{ErrorCode:a,ErrorInfo:c,TotalCount:u,Cursor:l="",Users:d=[]}=r;if(0!==a)throw{errorCode:a,errorInfo:c};const h=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${u}`,p=[];for(let e=0,g=d.length;e<g;e++){const{UserID:s,ProfileItems:n}=d[e];if(s===this._core.OuterConstant.USER_NOT_FOUND||""===s)continue;const o=n.map(e=>({tag:e.Tag,value:e.StrValue})),i=null===(t=this._core.user.userProfile)||void 0===t?void 0:t.createProfile(s,o);p.push(i)}return{code:0,data:{searchResultList:p,cursor:l,totalCount:u},successLog:{message:h}}}catch(s){const{errorCode:e,errorInfo:t}=s||{};this._handleError({errorCode:e,errorInfo:t,searchType:qd,functionName:"searchCloudUsers"})}})}searchCloudGroupMembers(e){return pe(this,void 0,void 0,function*(){try{const{count:t=Hd,keywordListMatchType:s}=e,n=he(e,["count","keywordListMatchType"]),o=Object.assign({count:t,keywordListMatchType:s===Bd.AND?1:0},n),i=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,groupTypeList:o,cursor:i,groupIDList:r}=e,a={Count:t,Keywords:s,KeywordMatchType:n,Cursor:i,GroupType:o,GroupIdList:r};return xd.core.common.buildAndSendPacket({servcmd:"group_member_search.query",data:a})})}(o);if(!i)return{code:0,data:{}};const{ErrorCode:r,ErrorInfo:a,GroupMembers:c=[],Cursor:u,TotalCount:l}=i;if(0!==r)throw{errorCode:r,errorInfo:a};const d=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${l}`,h=new Map;return c.forEach(e=>{const{GroupID:t,GroupName:s,GroupType:n,GroupFaceUrl:o,GroupMemberUserName:i,GroupMemberUserID:r,GroupMemberNameCard:a,GroupMemberAvatar:c=""}=e,u={groupID:t,name:s,type:n,avatar:o},l={userID:r,nick:i,nameCard:a,avatar:c};if(h.has(t)){const e=h.get(t);e.memberList.push(l),h.set(t,e)}else h.set(t,{groupInfo:u,memberList:[l]})}),{code:0,data:{searchResultList:[...h.values()],cursor:u,totalCount:l},successLog:{message:d}}}catch(t){const{errorCode:e,errorInfo:s}=t||{};this._handleError({errorCode:e,errorInfo:s,searchType:qd,functionName:"searchCloudGroupMembers"})}})}searchCloudGroups(e){return pe(this,void 0,void 0,function*(){try{const{count:t=Vd,keywordListMatchType:s}=e,n=he(e,["count","keywordListMatchType"]),o=Object.assign({count:t,keywordListMatchType:s===Bd.AND?1:0},n),i=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,groupTypeList:o,cursor:i}=e,r={Count:t,Keywords:s,KeywordMatchType:n,Cursor:i,GroupType:o};return xd.core.common.buildAndSendPacket({servcmd:"group_search.query",data:r})})}(o);if(!i)return{code:0,data:{}};const{ErrorCode:r,ErrorInfo:a,Groups:c,Cursor:u,TotalCount:l}=i;if(0!==r)throw{errorCode:r,errorInfo:a};const d=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${l}`;return{code:0,data:{searchResultList:(null==c?void 0:c.map(e=>function(e){const{GroupFaceUrl:t,GroupID:s,GroupIntroduction:n,GroupMemberNum:o,GroupName:i,GroupOwnerTinyID:r,GroupOwnerUserID:a,GroupOwnerUserName:c,GroupType:u,GroupAddOption:l,GroupInviteOption:d}=e;return{avatar:t,groupID:s,introduction:n,memberCount:o,name:i,ownerTinyID:r,ownerID:a,ownerNick:c,type:u,joinOption:l,inviteOption:d}}(e)))||[],cursor:u,totalCount:l},successLog:{message:d}}}catch(t){const{errorCode:e,errorInfo:s}=t||{};this._handleError({errorCode:e,errorInfo:s,searchType:qd,functionName:"searchCloudGroups"})}})}_setTimeRangeParams(e,{timePeriod:t,timePosition:s}){t&&t>0&&(e.startTime=s&&s>0?s-t:this._core.helper.timeManager.getServerTimeSeconds()-t),e.startTime&&e.startTime<0&&(e.startTime=void 0),s&&s>0&&(e.endTime=s)}_handleError({errorCode:e,errorMessage:t,searchType:s}){const{helper:n}=this._core;let o=e;throw 60020===e?o="SearchUnable":s!==$d&&27003===e?o="SearchParamsError":s!==$d&&60018===e&&(o="SearchOverLimit"),new n.ChatError({code:o,message:t})}_isSearchingAllConversations(e){return this._core.helper.isEmpty(e.conversationID)}_setBirthdayRangeParams(e,t){const{miniBirthday:s,maxBirthday:n}=t;void 0!==s&&(e.miniBirthday=s,void 0===n&&(e.maxBirthday=4294967295)),void 0!==n&&(e.maxBirthday=n)}},nh=new class{constructor(){this._conversationGroupMap=new Map}init(e){this._core=e}getConversationGroupMap(){return this._conversationGroupMap}getConversationGroup(e){return this._conversationGroupMap.get(e)}setConversationGroup(e,t){this._conversationGroupMap.set(e,t)}};const oh=new class{init(e){this.core=e}},ih="CONV_GROUP",rh=2500,ah=2503,ch=1,uh=2,lh="NOT_STARTED",dh="FETCHING",hh="FINISHED",ph="FAILED",gh=0,_h=1,mh=1,fh=2,vh=3,Ih=1,Eh=2;function Sh(e){const{helper:t,constants:s}=oh.core;if(!t.checkBusinessCapabilityBits(ih))throw new t.ChatError({functionName:e,code:s.ERROR_CODE.NO_USE,replacement1:e})}function yh(){const{notificationCenter:e,OuterEvent:t}=oh.core;e.emitOuterEvent(t.CONVERSATION_GROUP_LIST_UPDATED,{name:t.CONVERSATION_GROUP_LIST_UPDATED,data:[...nh.getConversationGroupMap().values()]})}function Ch(e){const{utils:{isUndefined:t},constants:{OuterConstant:s}}=oh.core,{Type:n,To_Account:o,Peer_Account:i}=e;let r="";const a=e.ToGroupId||e.GroupId;return n===ch?t(i)?t(o)||(r=`${s.CONV_C2C}${o}`):r=`${s.CONV_C2C}${i}`:n===uh&&(r=`${s.CONV_GROUP}${a}`),r}function Mh(e){const t=[],{OuterConstant:s,common:{isC2CConv:n,isGroupConv:o}}=oh.core,{conversationIDList:i,failureConversationIDList:r,additionalData:a={}}=e;return i.forEach(e=>{Ah(e,r),n(e)?t.push(Object.assign({ContactItem:{Type:ch,To_Account:e.replace(s.CONV_C2C,"")}},a)):o(e)&&t.push(Object.assign({ContactItem:{Type:uh,ToGroupId:e.replace(s.CONV_GROUP,"")}},a))}),t}function Ah(e,t){const{appStore:{conversationStore:s},common:{isC2CConv:n,isGroupConv:o}}=oh.core;s.getConversation(e)?n(e)||o(e)||t.push({conversationID:e,code:ah}):t.push({conversationID:e,code:rh})}function bh(e){const{utils:{isString:t}}=oh.core,s=[];if(!t(e))return s;const n=e.length;if(0===n)return s;for(let o=n-1;o>=0;o--)"1"===e[o]&&s.push(Math.pow(2,n-o-1));return s}function Th(e){null==e||e.forEach((t,s)=>{const{appStore:n}=oh.core,{conversationID:o,data:i}=t,r=s===e.length-1;n.conversationStore.updateConversation(o,i,{emit:r})})}function Oh(e){const{conversationInfoList:t,fromAccount:s}=e,n={From_Account:s,MarkItem:t};return oh.core.common.buildAndSendPacket({servcmd:"recentcontact.mark_contact",data:n})}function wh(e){const{fromAccount:t,groupName:s,conversationInfoList:n}=e,o={From_Account:t,UpdateType:1,UpdateGroup:{UpdateGroupType:Eh,OldGroupName:s,ContactUpdateItem:n}};return oh.core.common.buildAndSendPacket({servcmd:"recentcontact.update_contact_group",data:o})}var Dh=new class{init(e){const{helper:{registerApi:t}}=e;this._core=e,t({apiName:"createConversationGroup",context:this})}createConversationGroup(e){return pe(this,void 0,void 0,function*(){const{utils:{isPlainObject:t,isArray:s},appStore:n}=this._core;Sh("createConversationGroup");const{groupName:o,conversationIDList:i}=e,r=[],a=this._generateConversationInfo(i,r);if(r.length===i.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:r}};try{const e=yield function(e){const{common:{buildAndSendPacket:t,getCurrentUserID:s}}=oh.core,{item:n,groupName:o}=e;return t({servcmd:"recentcontact.create_contact_group",data:{From_Account:s(),GroupContactItem:[{GroupName:o,ContactItem:n}]}})}({groupName:o,item:a});if(e){const{GroupResultItem:i=[]}=e,{GroupItem:a,ResultItem:c}=(null==i?void 0:i[0])||{},u=[];if(t(a)){const{GroupName:e,GroupId:t}=a;nh.setConversationGroup(t,e),yh()}if(s(c)){const e=[];c.forEach(t=>{const{ContactItem:s,ResultCode:i,ResultInfo:a}=t,c=Ch(s);if(0===i){const t=n.conversationStore.getConversation(c);if(t&&!t.conversationGroupList.includes(o)){const s=t.conversationGroupList.slice();s.push(o),e.push({conversationID:c,data:{conversationGroupList:s}})}}else r.push({conversationID:c,code:i,message:a})}),e.length>0&&(Th(e),yh())}return{code:0,data:{successConversationIDList:u,failureConversationIDList:r}}}}catch(c){const{errorCode:e,errorInfo:t}=c;throw new this._core.helper.ChatError({functionName:"createConversationGroup",code:e,message:t})}})}_generateConversationInfo(e,t,s={}){const n=[],{OuterConstant:o,common:{isC2CConv:i,isGroupConv:r}}=this._core;return e.forEach(e=>{Ah(e,t),i(e)?n.push(Object.assign({Type:ch,To_Account:e.replace(o.CONV_C2C,"")},s)):r(e)&&n.push(Object.assign({Type:uh,ToGroupId:e.replace(o.CONV_GROUP,"")},s))}),n}},Rh=new class{constructor(){this._fetchConversationGroupStatus=lh}init(e){const{helper:{registerApi:t,registerWorkflowStep:s},constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:o}}=e;this._core=e,t({apiName:"getConversationGroupList",context:this}),s(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.CONVERSATION_GROUP_LIST_SYNC,this._syncConversationGroupList,this),s(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.CONVERSATION_GROUP_UPDATE,this._updateConversation,this)}getConversationGroupList(){return pe(this,void 0,void 0,function*(){return Sh("getConversationGroupList"),this._fetchConversationGroupStatus===ph&&(yield this._fetchConversationGroupList(0)),{code:0,data:[...nh.getConversationGroupMap().values()]}})}_syncConversationGroupList(){return pe(this,void 0,void 0,function*(){return yield this._fetchConversationGroupList(0)})}_fetchConversationGroupList(e){return pe(this,arguments,void 0,function*(e,t=[]){const{common:{getCurrentUserID:s},utils:{isArray:n}}=this._core;this._fetchConversationGroupStatus=dh;try{const o=s(),i=yield function(e){const{fromAccount:t,startIndex:s}=e,n={From_Account:t,StartIndex:s};return oh.core.common.buildAndSendPacket({servcmd:"recentcontact.get_contact_group",data:n})}({fromAccount:o,startIndex:e});if(i){const{CompleteFlag:e,ContactItem:s=[],NextStartIndex:o=0,GroupItem:r=[]}=i;if(n(r)&&r.forEach(e=>{const{GroupName:t,GroupId:s}=e;nh.setConversationGroup(s,t)}),t.push(...s),e===gh)return this._fetchConversationGroupList(o);if(e===_h)return this._fetchConversationGroupStatus=hh,t}}catch(o){this._fetchConversationGroupStatus=ph,console.error(o)}})}_updateConversation(e){var t;const{constants:{WORKFLOW_STEP:s}}=this._core,n=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t[s.CONVERSATION_GROUP_LIST_SYNC])||[];Th(this._generateConversationUpdateFields(n)),yh()}_generateConversationUpdateFields(e){const{utils:{isArray:t},appStore:s}=this._core,n=[];if(t(e)){let o;e.forEach(e=>{const i=[],{StandardMark:r,CustomMark:a="",ContactGroupId:c}=e;t(c)&&c.forEach(e=>{nh.getConversationGroupMap().has(e)&&i.push(nh.getConversationGroup(e))});const u=Ch(e);o=s.conversationStore.getConversation(u),o&&n.push({conversationID:u,data:{markList:bh(r),customData:a,conversationGroupList:[...i]}})})}return n}reset(){this._fetchConversationGroupStatus=lh}dispose(){this.reset()}},Lh=new class{init(e){const{notificationCenter:t,helper:{registerApi:s},InnerEvent:{MESSAGE_PUSH:n},InnerEventSubType:{CONVERSATION_MARK_UPDATED:o,CONVERSATION_GROUP_ADD:i,CONVERSATION_GROUP_DELETED:r,CONVERSATION_GROUP_UPDATED:a}}=e;this._core=e,s({apiName:"renameConversationGroup",context:this}),s({apiName:"deleteConversationGroup",context:this}),s({apiName:"markConversation",context:this}),s({apiName:"setConversationCustomData",context:this}),s({apiName:"deleteConversationsFromGroup",context:this}),s({apiName:"addConversationsToGroup",context:this}),t.subscribeInnerEvent(n,i,this._handleConversationGroupAdd,this),t.subscribeInnerEvent(n,r,this._handleConversationGroupDeleted,this),t.subscribeInnerEvent(n,a,this._handleConversationGroupUpdated,this),t.subscribeInnerEvent(n,o,this._handleConversationMarkUpdated,this)}renameConversationGroup(e){return pe(this,void 0,void 0,function*(){Sh("renameConversationGroup");const{common:{getCurrentUserID:t}}=this._core,{oldName:s,newName:n}=e,o=`oldName:${s} newName:${n}`;try{const e=yield function(e){const{fromAccount:t,oldName:s,newName:n}=e,o={From_Account:t,UpdateType:1,UpdateGroup:{UpdateGroupType:Ih,OldGroupName:s,NewGroupName:n}};return oh.core.common.buildAndSendPacket({servcmd:"recentcontact.update_contact_group",data:o})}({fromAccount:t(),oldName:s,newName:n});if(e){const{UpdateGroupResult:t}=e,{GroupId:o}=t;nh.setConversationGroup(o,n),yh(),this._updateLocalConversationGroupName({oldName:s,newName:n})}return{successLog:{message:o}}}catch(i){const{errorCode:e,errorInfo:t}=i;throw new this._core.helper.ChatError({functionName:"renameConversationGroup",code:e,message:t,moreMessage:o})}})}deleteConversationGroup(e){return pe(this,void 0,void 0,function*(){Sh("deleteConversationGroup");const{common:{getCurrentUserID:t}}=this._core;try{const s=yield function(e){const{fromAccount:t,groupName:s}=e,n={From_Account:t,GroupName:[s]};return oh.core.common.buildAndSendPacket({servcmd:"recentcontact.del_contact_group",data:n})}({fromAccount:t(),groupName:e});if(s){const{GroupItem:t}=s;let n=!1;return null==t||t.forEach(e=>{const{GroupId:t}=e,s=nh.getConversationGroupMap();s.has(t)&&(s.delete(t),n=!0)}),n&&yh(),this._deleteLocalConversationGroupName([e]),{successLog:{message:`groupName:${e}`}}}}catch(s){const{errorCode:t,errorInfo:n}=s;throw new this._core.helper.ChatError({functionName:"deleteConversationGroup",code:t,message:n,moreMessage:`groupName:${e}`})}})}markConversation(e){return pe(this,void 0,void 0,function*(){Sh("markConversation");const{utils:{isNumber:t},common:{getCurrentUserID:s},appStore:n}=this._core,{conversationIDList:o,markType:i,enableMark:r}=e,a=this._getFlagBit(i),c=[],u=[];let l,d;!0===r&&t(a)?l=[a]:d=[a];const h=Mh({conversationIDList:o,failureConversationIDList:c,additionalData:{SetMark:l,ClearMark:d,OptType:mh}});if(c.length===o.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:c}};try{const e=yield Oh({conversationInfoList:h,fromAccount:s()});if(e){const{ResultItem:t}=e,s=[];t.forEach(e=>{const{ContactItem:t,ResultCode:o,ResultInfo:a}=e,l=Ch(t);if(0===o){u.push(l);const e=n.conversationStore.getConversation(l);if(e){const t=e.markList.indexOf(i),n=!1===r&&-1!==t;if(!0===r&&-1===t)s.push({conversationID:l,data:{markList:[...e.markList,i]}});else if(n){const n=e.markList.slice();n.splice(t,1),s.push({conversationID:l,data:{markList:n}})}}}else c.push({conversationID:l,code:o,message:a})}),Th(s)}return{code:0,data:{successConversationIDList:u,failureConversationIDList:c}}}catch(p){const{errorCode:e,errorInfo:t}=p;throw new this._core.helper.ChatError({functionName:"markConversation",code:e,message:t})}})}setConversationCustomData(e){return pe(this,void 0,void 0,function*(){Sh("setConversationCustomData");const{common:{getCurrentUserID:t},appStore:s}=this._core,{conversationIDList:n,customData:o}=e,i=[],r=[],a=Mh({conversationIDList:n,failureConversationIDList:i,additionalData:{CustomMark:o,OptType:fh}});if(i.length===n.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:i}};try{const e=yield Oh({fromAccount:t(),conversationInfoList:a});if(e){const{ResultItem:t}=e,n=[];null==t||t.forEach(e=>{const{ContactItem:t,ResultCode:a,ResultInfo:c}=e;if(0===a){const e=Ch(t);r.push(e);const i=s.conversationStore.getConversation(e);i&&i.customData!==o&&n.push({conversationID:e,data:{customData:o}})}else i.push({conversationID:conversationID,code:a,message:c})}),Th(n)}return{code:0,data:{successConversationIDList:r,failureConversationIDList:i}}}catch(c){const{errorCode:e,errorInfo:t}=c;throw new this._core.helper.ChatError({functionName:"setConversationCustomData",code:e,message:t})}})}deleteConversationsFromGroup(e){return pe(this,void 0,void 0,function*(){Sh("deleteConversationsFromGroup");const{common:{getCurrentUserID:t},appStore:s}=this._core,{conversationIDList:n,groupName:o}=e,i=[],r=[],a=Mh({conversationIDList:n,failureConversationIDList:i,additionalData:{ContactOptType:2}});if(i.length===n.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:i}};try{const e=yield wh({fromAccount:t(),groupName:o,conversationInfoList:a});if(e){const t=[],{UpdateGroupResult:{ContactResultItem:n}}=e;null==n||n.forEach(e=>{const n=Ch(e.ContactItem);if(0===e.ResultCode){const e=s.conversationStore.getConversation(n);if(e){const s=e.conversationGroupList.indexOf(o);if(-1!==s){const o=e.conversationGroupList.slice();o.splice(s,1),r.push(n),t.push({conversationID:n,data:{conversationGroupList:o}})}}}else i.push({conversationID:n,code:e.ResultCode,message:e.ResultInfo})}),t.length>0&&(yh(),Th(t))}return{code:0,data:{successConversationIDList:r,failureConversationIDList:i}}}catch(c){const{errorCode:e,errorInfo:t}=c;throw new this._core.helper.ChatError({functionName:"deleteConversationsFromGroup",code:e,message:t})}})}addConversationsToGroup(e){return pe(this,void 0,void 0,function*(){Sh("deleteConversationsFromGroup");const{common:{getCurrentUserID:t},appStore:s}=this._core,{conversationIDList:n,groupName:o}=e,i=[],r=[],a=Mh({conversationIDList:n,failureConversationIDList:i,additionalData:{ContactOptType:1}});if(i.length===n.length)return{code:0,data:{successConversationIDList:[],failureConversationIDList:i}};try{const e=yield wh({fromAccount:t(),groupName:o,conversationInfoList:a});if(e){const t=[],{UpdateGroupResult:{ContactResultItem:n}}=e;null==n||n.forEach(e=>{const n=Ch(e.ContactItem);if(0===e.ResultCode){const e=s.conversationStore.getConversation(n);if(e&&-1===e.conversationGroupList.indexOf(o)){const s=e.conversationGroupList.slice();s.push(o),r.push(n),t.push({conversationID:n,data:{conversationGroupList:s}})}}else i.push({conversationID:n,code:e.ResultCode,message:e.ResultInfo})}),t.length>0&&(yh(),Th(t))}return{code:0,data:{successConversationIDList:r,failureConversationIDList:i}}}catch(c){const{errorCode:e,errorInfo:t}=c;throw new this._core.helper.ChatError({functionName:"deleteConversationsFromGroup",code:e,message:t})}})}_updateLocalConversationGroupName(e){const{appStore:t}=this._core,{oldName:s,newName:n}=e;let o=[];const i=[];let r=-1;Array.from(t.conversationStore.getConversationMap().values()).forEach(e=>{if(o=e.conversationGroupList,r=o.indexOf(s),-1!==r){const t=o.slice();t.splice(r,1,n),i.push({conversationID:e.conversationID,data:{conversationGroupList:t}})}}),Th(i)}_deleteLocalConversationGroupName(e){const{utils:{isEmpty:t},appStore:s}=this._core;if(t(e))return;const n=[];Array.from(s.conversationStore.getConversationMap().values()).forEach(t=>{const{conversationID:s,conversationGroupList:o}=t,i=o.filter(t=>!e.includes(t));i.length<o.length&&n.push({conversationID:s,data:{conversationGroupList:i}})}),Th(n)}_getFlagBit(e){const t=e.toString(2),s=t.length;for(let n=s-1;n>=0;n--)if("1"===t[n])return s-n-1}_handleConversationGroupAdd(e){var t;const{utils:{isArray:s},appStore:n}=this._core;null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{const{RecentContactCreateContactGroup:{MsgContactGroupContactItem:t}}=e;let o=!1;null==t||t.forEach(e=>{const{MsgGroupItem:t,MsgRecentContactItem:i}=e,{GroupId:r,GroupName:a}=t,c=[];nh.getConversationGroup(r)!==a&&(nh.setConversationGroup(r,a),o=!0),s(i)&&i.forEach(e=>{var t;const s=Ch(e),o=n.conversationStore.getConversation(s);if(o&&!(null===(t=o.conversationGroupList)||void 0===t?void 0:t.includes(a))){const e=o.conversationGroupList.slice();e.push(a),c.push({conversationID:s,data:{conversationGroupList:e}})}}),o&&yh(),Th(c)})})}_handleConversationGroupDeleted(e){var t;const{utils:{isArray:s}}=this._core;null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{const{MsgGroupItem:t}=(null==e?void 0:e.RecentContactDelContactGroup)||{};if(s(t)){let e=!1;const s=[];t.forEach(t=>{const{GroupId:n,GroupName:o}=t,i=nh.getConversationGroupMap();i.has(n)&&(i.delete(n),e=!0,s.push(o))}),e&&yh(),s.length>0&&this._deleteLocalConversationGroupName(s)}})}_handleConversationGroupUpdated(e){var t;null===(t=e.RecentContactMod)||void 0===t||t.forEach(e=>{const{RecentContactUpdateContactGroup:{MsgUpdateGroup:{GroupId:t,GroupName:s,OldGroupName:n,RecentContactUpdateGroupItem:o,UpdateGroupType:i}}}=e;1===i?this._handleGroupNameUpdated({groupID:t,newName:s,oldName:n}):2===i&&this._handleGroupAddOrDeleteFromConversation({groupInfoList:o,groupName:n})})}_handleConversationMarkUpdated(e){var t;const{appStore:s}=this._core;null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{const{RecentContactMarkContact:{RecentContactMarkContactItem:t}}=e,n=[];null==t||t.forEach(e=>{const{RecentContactItem:t,CustomMark:o,StandardMark:i,OptType:r}=e,a=Ch(t),c=s.conversationStore.getConversation(a);c&&(r===mh?this._updateStandMark({conversation:c,standardMark:i,updateConversationList:n}):r===fh?this._updateCustomMark({conversation:c,customMark:o,updateConversationList:n}):r===vh&&(this._updateStandMark({conversation:c,standardMark:i,updateConversationList:n}),this._updateCustomMark({conversation:c,customMark:o,updateConversationList:n})))}),Th(n)})}_updateStandMark(e){const{conversation:t,standardMark:s,updateConversationList:n}=e,o=bh(s);(function(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;e.sort(),t.sort();for(let s=0,n=e.length;s<n;s++)if(e[s]!==t[s])return!1;return!0})(t.markList,o)||n.push({conversationID:t.conversationID,data:{markList:o}})}_updateCustomMark(e){const{conversation:t,customMark:s,updateConversationList:n}=e;t.customData!==s&&void 0!==s&&(t.customData=s,n.push({conversationID:t.conversationID,data:{customData:s}}))}_handleGroupNameUpdated(e){const{groupID:t,oldName:s,newName:n}=e;nh.getConversationGroup(t)!==n&&(nh.setConversationGroup(t,n),yh(),this._updateLocalConversationGroupName({oldName:s,newName:n}))}_handleGroupAddOrDeleteFromConversation({groupInfoList:e,groupName:t}){const{appStore:s}=this._core,n=[];e.forEach(e=>{const{RecentContactItem:o,ContactOptType:i}=e,r=Ch(o),a=s.conversationStore.getConversation(r),c=a.conversationGroupList.indexOf(t);if(a){const e=a.conversationGroupList.slice();1===i&&-1===c?(e.push(t),n.push({conversationID:r,data:{conversationGroupList:e}})):2===i&&-1!==c&&(e.splice(c,1),n.push({conversationID:r,data:{conversationGroupList:e}}))}}),Th(n)}dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{CONVERSATION_MARK_UPDATED:s,CONVERSATION_GROUP_ADD:n,CONVERSATION_GROUP_DELETED:o,CONVERSATION_GROUP_UPDATED:i}}=this._core;e.unSubscribeInnerEvent(t,n,this._handleConversationGroupAdd,this),e.unSubscribeInnerEvent(t,o,this._handleConversationGroupDeleted,this),e.unSubscribeInnerEvent(t,i,this._handleConversationGroupUpdated,this),e.unSubscribeInnerEvent(t,s,this._handleConversationMarkUpdated,this)}};const Nh={required:!0,rules:["string"],allowEmpty:!1},Ph={required:!0,rules:["array"],allowEmpty:!1},kh={createConversationGroup:{groupName:Nh,conversationIDList:{required:!0,rules:["array"],allowEmpty:!1}},renameConversationGroup:{oldName:Nh,newName:Object.assign(Object.assign({},Nh),{customValidator:e=>!(e.length>32)||"newName length cannot longer than 32"})},deleteConversationGroup:[{required:!0,rules:["string"],allowEmpty:!1}],addConversationsToGroup:{conversationIDList:Ph,groupName:Nh},deleteConversationsFromGroup:{conversationIDList:Ph,groupName:Nh},markConversation:{conversationIDList:Ph,markType:{required:!0,rules:["number"],allowEmpty:!1,customValidator:e=>e<=0?"markType must be greater than 0":!(e>=Math.pow(2,64))||"markType must be less than 2^64"},enableMark:{required:!0,rules:["boolean"],allowEmpty:!1}},setConversationCustomData:{conversationIDList:Ph,customData:{required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>"string"!=typeof e?"customData must be string":!(e.length>256)||"customData length cannot longer than 256"}}},Gh={createConversationGroup:!0,deleteConversationGroup:!0,renameConversationGroup:!0,getConversationGroupList:!0,addConversationsToGroup:!0,deleteConversationsFromGroup:!0,markConversation:!0,setConversationCustomData:!0};var Uh=new class{constructor(){this.name="ConversationGroup"}install(e){this._core=e,oh.init(e),nh.init(e),Dh.init(e),Rh.init(e),Lh.init(e),e.helper.registerValidateConfig({auth:Gh,params:kh}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this.reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this.dispose,this)}dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this.reset,this),e.unSubscribeInnerEvent(t.DESTROY,this.dispose,this),Lh.dispose(),Rh.dispose()}reset(){Rh.reset()}};const Fh=new class{init(e){this.core=e}},xh="@TOPIC#_",$h=7,qh=8,Bh=17,Vh=18,Wh=20,jh=300,Hh=0,Kh=3600,Yh=3021,zh=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","nextMessageSeq","selfInfo","lastMessage"],Zh=e=>{const{core:{common:{getMessagePreviewText:t}}}=Fh;return{lastTime:(null==e?void 0:e.time)||0,lastSequence:(null==e?void 0:e.sequence)||0,fromAccount:(null==e?void 0:e.from)||"",payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",messageForShow:t(null==e?void 0:e.type,null==e?void 0:e.payload),nick:(null==e?void 0:e.nick)||"",avatar:(null==e?void 0:e.avatar)||"",version:(null==e?void 0:e.version)||0,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,revoker:(null==e?void 0:e.revoker)||null}};class Jh{constructor(e){this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=Zh(),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._init(e)}_init(e){for(const t in e)zh.includes(t)&&("lastMessage"===t?this[t]=Zh(e[t]):"selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateReadSequence(e=0,t=!1){t&&(this.selfInfo.readedSequence=e)}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=Zh(e)}updateGroupAtInfoList(e){const{core:{common:{updateGroupAtInfo:t}}}=Fh;t(e,this.groupAtInfoList)}updateTopic(e){const{core:{utils:{isUndefined:t},common:{deepMerge:s}}}=Fh;t(e.selfInfo)||this.updateSelfInfo(e.selfInfo),t(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),s(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg","groupAtInfoList"])}updateSelfInfo(e){const{core:{common:{deepMerge:t}}}=Fh;return t(this.selfInfo,e,[],[""])>0}reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}isLastMessageRevoked(e){var t;return e===(null===(t=this.lastMessage)||void 0===t?void 0:t.lastSequence)}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}clearGroupAtInfoList(){this.groupAtInfoList.length=0}}var Xh=new class{constructor(){this._name="TopicDataHandler",this._topicMap=new Map,this._topicRequestInfo=new Map}init(e){this._core=e;const{helper:t,constants:s,notificationCenter:n,InnerEvent:{LOGOUT:o,DESTROY:i}}=e;t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.TOPIC_REQUEST_INFO_RESET,this._resetTopicRequestInfo,this),n.subscribeInnerEvent(o,this._reset,this),n.subscribeInnerEvent(i,this._dispose,this),e.ssoLog.debug(`${this._name}.init`)}_hasTopic(e,t){var s;return!!(null===(s=this._topicMap.get(e))||void 0===s?void 0:s.get(t))}_setTopic(e,t,s){var n;null===(n=this._topicMap.get(e))||void 0===n||n.set(t,s)}_deleteTopic(e,t){var s;null===(s=this._topicMap.get(e))||void 0===s||s.delete(t)}getTopic(e,t){var s;return null===(s=this._topicMap.get(e))||void 0===s?void 0:s.get(t)}updateTopic(e){e.forEach(e=>{const{groupID:t,topicID:s}=e;let n=null;this._topicMap.has(t)||this._topicMap.set(t,new Map),this._hasTopic(t,s)?(n=this.getTopic(t,s),null==n||n.updateTopic(e)):(this._getLastMessage(e),n=new Jh(e),this._setTopic(t,s,n));const o=this.computeUnreadCount(n);null==n||n.updateUnreadCount(o)})}_getLastMessage(e){const{utils:{isEmpty:t,isUndefined:s,isArray:n}}=this._core;if(!s(e.lastMsg)){let s=null,o="";n(e.lastMsg.elements)?(s=e.lastMsg.elements[0].content,o=e.lastMsg.elements[0].type):(s=e.lastMsg.elements.content,o=e.lastMsg.elements.type);const i={payload:s,type:o,time:e.lastMsg.time,sequence:e.lastMsg.sequence,from:e.lastMsg.from,nick:e.lastMsg.nick,avatar:e.lastMsg.avatar,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:t(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker};e.lastMessage=i}}computeUnreadCount(e){const{excludedUnreadSequenceList:t=[],readedSequence:s}=e.selfInfo;let n=e.nextMessageSeq-e.selfInfo.readedSequence-1;if(t.length>0){let o=0;t.forEach(t=>{t>s&&t<=e.nextMessageSeq-1&&(o+=1)}),o>=1&&(n-=o)}return n>0?n:0}updateTopicAtInfo(e){0!==e.length&&e.forEach(e=>{const{utils:{isEmpty:t}}=this._core,{groupAtInfoList:s}=e;t(s)||this.updateGroupAtInfoList(s)})}updateGroupAtInfoList(e,t=!1){if(0===e.length)return;const{common:{getCurrentUserID:s},utils:{isUndefined:n,isEmpty:o}}=this._core,i=s();let r=null;e.forEach(e=>{var s;const{groupID:o,topicID:a,from:c}=e;c!==i&&(r=this.getTopic(o,a),r&&r.updateGroupAtInfoList(e),n(r)&&t&&(this.updateTopic([{groupID:o,topicID:a}]),null===(s=this.getTopic(o,a))||void 0===s||s.updateGroupAtInfoList(e)))}),o(r)||this.emitTopicUpdate(r)}getTopicList(e,t=[]){const s=this._topicMap.get(e),n=[];return s&&n.push(...s.values()),t.length>0?n.filter(e=>t.includes(e.topicID)):n}deleteTopicList(e,t=[]){this._topicMap.has(e)&&(t.forEach(t=>{this._hasTopic(e,t)&&this._deleteTopic(e,t)}),console.log(`${this._name}.deleteTopicList groupID:${e} topicID:${t.join(",")}`))}clearGroupAtInfoList(e,t){const{utils:{isEmpty:s}}=this._core,n=this.getTopic(e,t);s(null==n?void 0:n.groupAtInfoList)||(null==n||n.clearGroupAtInfoList(),console.log(`${this._name}.clearGroupAtInfoList topicID:${t}`))}markMessageAsRead(e,t){const{message:{messageDataHandler:s},OuterConstant:{CONV_GROUP:n}}=this._core,o=(null==s?void 0:s.getLocalMessageList(`${n}${e}`))||[];if(0===o.length)return;const{length:i}=o;for(let r=i-1;r>=0;r--){const e=o[r];if(!(t&&e.sequence>t)){if("in"===e.flow&&e.isRead)break;e.setIsRead(!0)}}}updateUnreadCount(e,t){const{message:{messageDataHandler:s},OuterConstant:{CONV_GROUP:n}}=this._core;let o=!1;const i=this.getTopic(e,t);if(!i)return;const r=(null==s?void 0:s.getLocalMessageList(`${n}${t}`))||[],a=i.unreadCount,c=null==r?void 0:r.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;console.log(`${this._name}._updateUnreadCount topicID:${t} currentUnreadCount:${a} newUnreadCount:${c}`),a!==c&&(i.updateUnreadCount(c),o=!0),o&&this.emitTopicUpdate(i)}updateSelfInfo(e){const{groupID:t,topicID:s,selfInfo:n}=e,o=this.getTopic(t,s);if(o){const e=o.updateSelfInfo(n);console.log(`${this._name}.updateSelfInfo topicID:${s} info:${JSON.stringify(n)} isUpdated:${e}`),e&&this.emitTopicUpdate(o)}}getTopicRequestInfo(e){return this._topicRequestInfo.get(e)||{}}setTopicRequestInfo(e,t){return this._topicRequestInfo.set(e,t)}emitTopicUpdate(e){const{OuterEvent:t,notificationCenter:s}=this._core;s.emitOuterEvent(t.TOPIC_UPDATED,{name:t.TOPIC_UPDATED,data:e})}_resetTopicRequestInfo(){this._topicRequestInfo.clear()}_reset(){this._topicMap.clear(),this._topicRequestInfo.clear()}_dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}};const Qh=(e="")=>{const{core:{OuterConstant:t}}=Fh;return e.replace(t.CONV_GROUP,"")},ep=(e="")=>e.split(xh)[0];var tp=new class{constructor(){this._name="TopicMessageHandler"}init(e){this._core=e;const{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:o},InnerEvent:{MESSAGE_PUSH:i,TOPIC_NEW_MESSAGE:r,TOPIC_MESSAGE_DELETED:a,TOPIC_MESSAGE_REVOKED:c,TOPIC_MESSAGE_MODIFIED:u,DESTROY:l}}=e,{InnerEventSubType:{TOPIC_AT_TIPS:d,TOPIC_LATEST_MESSAGE:h}}=s;t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(n.RECEIVE_GROUP_NEW_MESSAGE,o.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),s.subscribeInnerEvent(r,this._handleNewMessage,this),s.subscribeInnerEvent(a,this._handleMessageDeleted,this),s.subscribeInnerEvent(c,this._handleMessageRevoked,this),s.subscribeInnerEvent(u,this._handleMessageModified,this),s.subscribeInnerEvent(i,d,this._handleTopicAtTips,this),s.subscribeInnerEvent(i,h,this._handleLatestMessage,this),s.subscribeInnerEvent(l,this._dispose,this),e.ssoLog.debug(`${this._name}.init`)}_handleUnreadSyncFinished(e){var t;const{constants:{WORKFLOW_STEP:s}}=this._core,{groupTipList:n=[]}=e.result[s.UNREAD_MESSAGE_SYNC]||{};for(let o=0;o<n.length;o++){const e=n[o];12===e.Event&&(null===(t=e.GroupTips[0].MsgBody)||void 0===t?void 0:t.TopicId)&&this._handleTopicAtTips(e)}}_handleNewMessage(e){const{conversationUpdateFieldList:t=[]}=e.result||{};if(0===t.length)return;const{common:{isTopic:s}}=this._core;if(!s(t[0].conversationID))return;const{common:{getCurrentUserID:n}}=this._core;t.forEach(e=>{const{conversationID:t="",lastMessage:s}=e,o=Qh(t),i=ep(o),r=Xh.getTopic(i,o);if(r){const{from:e,sequence:t}=s,o=t+1,i=e===n();if(o>r.nextMessageSeq){r.updateNextMessageSeq(o),r.updateLastMessage(s),r.updateReadSequence(t,i);const e=i?0:Xh.computeUnreadCount(r);r.updateUnreadCount(e),this._emitTopicUpdate(r)}}})}_handleMessageDeleted(e){const t=Qh(e),s=ep(t),n=Xh.getTopic(s,t);if(console.log(`${this._name}._handleMessageDeleted, topicID:${t} hasTopic:${!!n}`),!n)return;const{message:{messageDataHandler:o},utils:{isEmpty:i}}=this._core,r=(null==o?void 0:o.getLocalMessageList(e))||[];let a={};for(let u=(r.length||0)-1;u>=0;u--)if(!r[u].isDeleted){a=r[u];break}let c=!1;n.lastMessage.lastSequence!==a.sequence&&(i(a)&&(a={}),n.updateLastMessage(a),c=!0),c&&(this._emitTopicUpdate(n),console.log(`${this._name}._handleMessageDeleted, topicID:${t} with lastMessage:${n.lastMessage}`))}_handleMessageRevoked(e){const{messageList:t=[]}=e;if(console.log(`${this._name}._handleMessageRevoked messageList:${t.length}`),0===t.length)return;let s=null,n=!1;t.forEach(e=>{const{to:t,sequence:o,revoker:i}=e,r=ep(t);if(s=Xh.getTopic(r,t),s){s.reduceUnreadCount()&&(n=!0),s.isLastMessageRevoked(o)&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(i),n=!0);const{excludedUnreadSequenceList:e=[]}=s.selfInfo;e.push(o),s.updateSelfInfo({excludedUnreadSequenceList:e})}}),n&&this._emitTopicUpdate(s)}_handleMessageModified(e){const{conversationID:t,messageList:s}=e,n=Qh(t),o=ep(n),i=Xh.getTopic(o,n);if(console.log(`${this._name}._handleMessageModified topicID:${n} hasTopic:${!!i}`),!i)return;const{lastMessage:r}=i;if(r){const e=(null==s?void 0:s[0])||{};if(this._shouldUpdateLastMessage(r,e)){const{common:{getMessagePreviewText:t}}=this._core,{time:s,sequence:n,elements:o,cloudCustomData:a,messageVersion:c}=e;r.type=o[0].type,r.payload=o[0].content,r.messageForShow=t(r.type,r.payload),r.cloudCustomData=a,r.version=c,r.lastSequence=n,r.lastTime=s,this._emitTopicUpdate(i)}}}_shouldUpdateLastMessage(e,t){if(null===e.payload)return!0;const{sequence:s,messageVersion:n}=t;return e.lastSequence===s&&e.version!==n}_emitTopicUpdate(e){const{notificationCenter:t,OuterEvent:s}=this._core;t.emitOuterEvent(s.TOPIC_UPDATED,{name:s.TOPIC_UPDATED,data:e})}_handleTopicAtTips(e){const{GroupTips:t=[]}=e,s=[];let n=!1;t.forEach(e=>{const{GroupAtTips:t,MsgBody:o,MsgRandom:i,ClientSeq:r}=e;let a={};t?a=this._convertAtInfo(t):o&&(a=this._convertAtInfo(o),n=!0),a.__random=i,a.__sequence=r,s.push(a)}),Xh.updateGroupAtInfoList(s,n)}_convertAtInfo(e){const{From_Account:t,GroupId:s,TopicId:n,MsgSeq:o,GroupAtType:i}=e;return{groupID:s,topicID:n,from:t,sequence:o,groupAtType:i}}_handleLatestMessage(e){const{utils:{isEmpty:t},message:{messageHelper:s,messageFactory:n}}=this._core,{NewMsg:o,NoUnreadSeqList:i}=e||{};if(!t(o)){const{GroupInfo:{TopicId:e}}=o,t=s.parseServerGroupMessage(o),r=n.createMessage(t);r.setElement(t.elements),this._updateUnreadCountAndLastMessage({topicID:e,message:r,excludedUnreadSequenceList:i})}}_updateUnreadCountAndLastMessage(e){const{utils:{isUndefined:t}}=this._core,{topicID:s,message:n,excludedUnreadSequenceList:o}=e,i=ep(s),r=Xh.getTopic(i,s);if(r){let e=r.selfInfo.excludedUnreadSequenceList||[];if(t(o)||(e=o),n._isExcludedFromUnreadCount&&e.push(n.sequence),r.updateSelfInfo({excludedUnreadSequenceList:e}),console.log(`${this._name}._updateUnreadCountAndLastMessage latest message sequence:${n.sequence} lastMessage sequence:${r.lastMessage.lastSequence}`),n.sequence>r.lastMessage.lastSequence){const e=n.sequence+1;r.updateLastMessage(n),r.updateNextMessageSeq(e);const t=Xh.computeUnreadCount(r);r.updateUnreadCount(t),this._emitTopicUpdate(r)}}}_dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,TOPIC_NEW_MESSAGE:s,TOPIC_MESSAGE_DELETED:n,TOPIC_MESSAGE_REVOKED:o,TOPIC_MESSAGE_MODIFIED:i,DESTROY:r}}=this._core,{InnerEventSubType:{TOPIC_AT_TIPS:a,TOPIC_LATEST_MESSAGE:c}}=e;e.unSubscribeInnerEvent(s,this._handleNewMessage,this),e.unSubscribeInnerEvent(n,this._handleMessageDeleted,this),e.unSubscribeInnerEvent(o,this._handleMessageRevoked,this),e.unSubscribeInnerEvent(i,this._handleMessageModified,this),e.unSubscribeInnerEvent(t,a,this._handleTopicAtTips,this),e.unSubscribeInnerEvent(t,c,this._handleLatestMessage,this),e.unSubscribeInnerEvent(r,this._dispose,this)}},sp=new class{constructor(){this._name="TopicOperationHandler"}init(e){this._core=e;const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s,DESTROY:n}}=e,{InnerEventSubType:{TOPIC_TIPS_NOTIFICATION:o,TOPIC_SYSTEM_NOTIFICATION:i,TOPIC_MESSAGE_READ_SYNC:r}}=t;t.subscribeInnerEvent(s,o,this._handleTopicTips,this),t.subscribeInnerEvent(s,i,this._handleTopicNotices,this),t.subscribeInnerEvent(s,r,this._handleTopicMessageReadSynced,this),t.subscribeInnerEvent(n,this._dispose,this),e.ssoLog.debug(`${this._name}.init`)}_handleTopicTips(e){const{GroupTips:t=[]}=e;for(let s=0;s<t.length;s++){const e=t[s];e.MsgBody.OpType!==$h?e.MsgBody.OpType!==qh?this._emitTopicTips(e):this._handleTopicProfileUpdated(e):this._handleMuteTimeUpdated(e)}}_handleMuteTimeUpdated(e){const{common:{getCurrentUserID:t}}=this._core,{GroupInfo:{GroupId:s,TopicId:n},MsgBody:{MsgMemberInfo:o=[]}}=e;for(let i=0;i<o.length;i++){const{User_Account:e,ShutupTime:r}=o[i];if(e===t()&&r>=0){Xh.updateSelfInfo({groupID:s,topicID:n,selfInfo:{muteTime:r}});break}}}_handleTopicProfileUpdated(e){const{GroupInfo:{GroupId:t,TopicId:s},MsgBody:{MsgTopicNewInfo:{CustomString:n,ShutupAll:o,TopicFaceUrl:i,TopicIntroduction:r,TopicName:a,TopicNotification:c}}}=e,u=Xh.getTopic(t,s);u&&(u.updateTopic({groupID:t,topicID:s,customData:n,muteAllMembers:o,avatar:i,introduction:r,topicName:a,notification:c}),Xh.emitTopicUpdate(u))}_handleTopicNotices(e){const{GroupTips:t=[]}=e;for(let s=0;s<t.length;s++){const e=t[s],{MsgBody:{ReportType:n,TopicIdArray:o,MsgFlag:i},GroupInfo:{GroupId:r,TopicId:a}}=e;n===Bh?this._handleTopicCreated({groupID:r,topicID:a}):n===Vh?this._handleTopicDeleted({groupID:r,topicIDList:o}):n===Wh?this._handleMessageRemindTypeUpdated({groupID:r,topicID:a,messageRemindType:i}):this._emitTopicNotices(e)}}_handleTopicCreated(e){const{OuterEvent:t,notificationCenter:s}=this._core;Xh.setTopicRequestInfo(e.groupID,{}),s.emitOuterEvent(t.TOPIC_CREATED,{name:t.TOPIC_CREATED,data:e})}_handleTopicDeleted(e){const{OuterEvent:t,notificationCenter:s}=this._core,{groupID:n,topicIDList:o=[]}=e;Xh.deleteTopicList(n,o),s.emitOuterEvent(t.TOPIC_DELETED,{name:t.TOPIC_DELETED,data:e})}_handleMessageRemindTypeUpdated(e){const{groupID:t,topicID:s,messageRemindType:n}=e;Xh.updateSelfInfo({groupID:t,topicID:s,selfInfo:{messageRemindType:n}})}_handleTopicMessageReadSynced(e){const{GroupTips:t}=e,{utils:{isUndefined:s}}=this._core;t.forEach(e=>{const{GroupReadInfoArray:t}=e.MsgBody;s(t)||t.forEach(e=>{const{GroupId:t,TopicId:s,LastReadMsgSeq:n}=e;console.log(`${this._name}._handleTopicMessageReadSynced topicID:${s} lastReadSequence:${n}`),Xh.updateSelfInfo({groupID:t,topicID:s,selfInfo:{readedSequence:n}}),Xh.clearGroupAtInfoList(t,s),Xh.markMessageAsRead(s,n),Xh.updateUnreadCount(t,s)})})}_emitTopicTips(e){const{message:{messageHelper:t,messageFactory:s},OuterConstant:n,OuterEvent:o,notificationCenter:i}=this._core;e.MsgBody.MsgType=n.MSG_GRP_TIP;const r=t.parseServerGroupMessage(e);r.flow="in",r.conversationType=n.CONV_GROUP;const a=s.createMessage(r);a.setElement(r.elements),a.isSystemMessage=!0,i.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[a]})}_emitTopicNotices(e){const{message:{messageHelper:t,messageFactory:s},OuterConstant:n,OuterEvent:o,notificationCenter:i}=this._core;e.MsgBody.MsgType=n.MSG_GRP_SYS_NOTICE;const r=t.parseServerGroupMessage(e);r.flow="in",r.conversationType=n.CONV_SYSTEM,r.conversationID=n.CONV_SYSTEM;const a=s.createMessage(r);a.setElement(r.elements),a.isSystemMessage=!0,i.emitOuterEvent(o.MESSAGE_RECEIVED,{name:o.MESSAGE_RECEIVED,data:[a]})}_dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core,{InnerEventSubType:{TOPIC_TIPS_NOTIFICATION:n,TOPIC_SYSTEM_NOTIFICATION:o,TOPIC_MESSAGE_READ_SYNC:i}}=e;e.unSubscribeInnerEvent(t,n,this._handleTopicTips,this),e.unSubscribeInnerEvent(t,o,this._handleTopicNotices,this),e.unSubscribeInnerEvent(t,i,this._handleTopicMessageReadSynced,this),e.unSubscribeInnerEvent(s,this._dispose,this)}},np=new class{constructor(){this._name="GetJoinedCommunityHandler"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getJoinedCommunityList",context:this})}getJoinedCommunityList(){return pe(this,void 0,void 0,function*(){const{apiMap:{getGroupList:e}}=this._core,t=(yield e(!0)).filter(e=>!0===e.isSupportTopic);return console.log(`${this._name}.getJoinedCommunityList ok, count:${t.length}`),{code:0,data:{groupList:t}}})}},op=new class{constructor(){this._name="CreateTopicHandler"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createTopicInCommunity",context:this})}createTopicInCommunity(e){return pe(this,void 0,void 0,function*(){const t="createTopicInCommunity",{utils:{isUndefined:s},common:{isTopic:n},helper:{ChatError:o}}=this._core,{topicID:i}=e;if(!s(i)&&!n(i)){const e=new o({functionName:t,code:Yh});throw console.error(`${this._name}.${t} fail:`,e),e}try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,topicID:n,topicName:o,avatar:i,notification:r,introduction:a,customData:c}=e,u={GroupId:s,TopicId:n,TopicName:o,FaceUrl:i,Notification:r,Introduction:a,CustomString:c};return t.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.create_topic",data:u})})}(e,this._core),{TopicId:n=""}=s||{};return console.log(`${this._name}.${t} ok, topicID:${n}`),Xh.updateTopic([Object.assign(Object.assign({},e),{topicID:n})]),{code:0,data:{topicID:n}}}catch(r){throw console.error(`${this._name}.${t} failed, error:`,r),r}})}},ip=new class{constructor(){this._name="DeleteTopicHandler"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteTopicFromCommunity",context:this})}deleteTopicFromCommunity(e){return pe(this,void 0,void 0,function*(){const t="deleteTopicFromCommunity",{groupID:s,topicIDList:n=[]}=e;try{const o=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,topicIDList:n}=e,o={GroupId:s,TopicIdList:n};return t.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.destroy_topic",data:o})})}({groupID:s,topicIDList:n},this._core),{DestroyResultItem:i=[]}=o||{},r=[],a=[],c=[];return i.forEach(e=>{const{TopicId:t,ErrorCode:s,ErrorInfo:n}=e;0===s?(r.push({topicID:t}),c.push(t)):a.push({topicID:t,code:s,message:n})}),c.length>0&&Xh.deleteTopicList(e.groupID,c),console.log(`${this._name}.${t} ok, groupID:${s} success:${r.length} fail:${a.length}`),{code:0,data:{successTopicList:r,failureTopicList:a}}}catch(o){throw console.error(`${this._name}.${t} failed, error:`,o),o}})}},rp=new class{constructor(){this._name="GetTopicHandler",this._getCloudConfig=e=>{const{store:t}=this._core;return(t.get("cloudConfig")||{})[e]}}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getTopicList",context:this})}getTopicList(e){return pe(this,void 0,void 0,function*(){const{groupID:t,topicIDList:s=[]}=e,n=0===s.length;if(this._isFetchingFromCache(t,n)){const e=Xh.getTopicList(t,s);if(n||e.length===s.length)return console.log(`${this._name}.getTopicList groupID:${t} from cache, count:${e.length}`),{code:0,data:{successTopicList:e,failureTopicList:[]}}}return this._getTopicListFromServer({groupID:t,topicIDList:s},n)})}_isFetchingFromCache(e,t){const{hasFetchedAllTopics:s=!1,time:n=0}=Xh.getTopicRequestInfo(e);return!(!s&&(t||s))&&Date.now()-n<this._getCacheDuration()}_getCacheDuration(){const{utils:{isUndefined:e}}=this._core;let t=this._getCloudConfig("topic_cache_time");return!e(t)&&(t=parseInt(t,10),t>=Hh&&t<=Kh)?1e3*t:1e3*jh}_getTopicListFromServer(e,t){return pe(this,void 0,void 0,function*(){const s="_getTopicListFromServer",{utils:{isEmpty:n}}=this._core,{groupID:o}=e;try{const i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,topicIDList:n}=e,o={GroupId:s,TopicIdList:n,MemberInfoFilter:["NoUnreadSeqList"]};return t.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.get_topic",data:o})})}(e,this._core),{TopicAndSelfInfo:r=[]}=i||{},a=[],c=[],u=[];this._convertTopicInfoList(r).forEach(e=>{const{topic:t,selfInfo:s,code:n,message:o}=e,{topicID:i}=t;0===n?(a.push(Object.assign(Object.assign({},t),{selfInfo:s})),c.push(i)):u.push({topicID:i,code:n,message:o})}),Xh.updateTopic(a),Xh.updateTopicAtInfo(a),console.log(`${this._name}.${s} groupID:${o} from remote, success count:${c.length}, fail count:${u.length}`);let l=[];return n(c)||(Xh.setTopicRequestInfo(o,{hasFetchedAllTopics:t,time:Date.now()}),l=Xh.getTopicList(o,c)),{code:0,data:{successTopicList:l,failureTopicList:u}}}catch(i){throw console.error(`${this._name}.${s} failed, error:`,i),i}})}_convertTopicInfoList(e){const t=[];return e.forEach(e=>{const{TopicInfo:s={},SelfInfo:n={},ErrorCode:o,ErrorInfo:i}=e;t.push({code:o,message:i,topic:this._convertTopicInfo(s),selfInfo:this._convertSelfInfo(n)})}),t}_convertTopicInfo(e){const{utils:{isEmpty:t}}=this._core;if(t(e))return{};const{CreateTime:s,CustomString:n,FaceUrl:o,GroupId:i,LastMsgTime:r,NextMsgSeq:a,Introduction:c,Notification:u,ShutUpAllFlag:l,TopicId:d,TopicName:h,LastMsg:p,AtInfoList:g}=e;return{createTime:s,customData:n,avatar:o,groupID:i,lastMessageTime:r,nextMessageSeq:a,introduction:c,notification:u,muteAllMembers:l,topicID:d,topicName:h,lastMsg:this._convertLastMsg(p),groupAtInfoList:this._convertAtInfoList({groupID:i,topicID:d,atInfoList:g})}}_convertLastMsg(e){const{utils:{isUndefined:t},OuterConstant:s}=this._core;if(t(e))return;4===e.Event&&(e.MsgBody.MsgType=s.MSG_GRP_TIP);const{message:{messageHelper:n}}=this._core,o=n.parseServerGroupMessage(e),{From_AccountHeadurl:i,From_AccountNick:r,LastMsgSeq:a}=e;return Object.assign(Object.assign({},o),{avatar:i,nick:r,sequence:a})}_convertAtInfoList(e){const{groupID:t,topicID:s,atInfoList:n=[]}=e;if(0===n.length)return[];const o=[];return n.forEach(e=>{const{AtFlagList:n,AtMsgSeq:i,From_Account:r}=e;o.push({groupID:t,topicID:s,groupAtType:n,sequence:i,from:r})}),o}_convertSelfInfo(e){const{utils:{isEmpty:t}}=this._core;if(t(e))return{};const{InheritGroupReceiveOption:s,MsgFlag:n,MsgSeq:o,NoUnreadSeqList:i,ShutUpTime:r}=e;return{inheritGroupReceiveOption:s,messageRemindType:n,readedSequence:o,excludedUnreadSequenceList:i,muteTime:r}}},ap=new class{constructor(){this._name="UpdateTopicHandler"}init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateTopicProfile",context:this})}updateTopicProfile(e){return pe(this,void 0,void 0,function*(){const t="updateTopicProfile",{utils:{isUndefined:s}}=this._core,{groupID:n,topicID:o,muteAllMembers:i}=e;s(e.muteAllMembers)||(e.muteAllMembers=!0===i?"On":"Off");try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,topicID:n,topicName:o,avatar:i,notification:r,introduction:a,customData:c,muteAllMembers:u}=e,l={GroupId:s,TopicId:n,TopicName:o,FaceUrl:i,Notification:r,Introduction:a,CustomString:c,ShutUpAllMember:u};return t.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.modify_topic",data:l})})}(e,this._core),console.log(`${this._name}.${t} ok, topicID:${o}`),Xh.updateTopic([e]),{code:0,data:{topic:Xh.getTopic(n,o)}}}catch(r){throw console.error(`${this._name}.${t} failed, topicID:${o} error:`,r),r}})}},cp=new class{constructor(){this._name="MessageReadHandler"}init(e){this._core=e;const{helper:t,common:{isTopic:s}}=e;t.registerApi({apiName:"setMessageRead",context:this,matcher:e=>s(e[0].conversationID)})}setMessageRead(e){return pe(this,void 0,void 0,function*(){const{utils:{isEmpty:t},ssoLog:s,helper:{ChatError:n}}=this._core,{conversationID:o}=e,i={code:0,data:{}},r=Qh(o),a=ep(r),c=Xh.getTopic(a,r),u=`${this._name}.setMessageRead topicID:${r} conversationID:${o} unreadCount:${(null==c?void 0:c.unreadCount)||0}`;if(i.successLog={message:u},!c)return i;if(t(c.groupAtInfoList)||this._deleteTopicAtTips(a,r),0===c.unreadCount)return i;const l=this._getLocalMessageMaxSequence(c);try{yield this._setTopicMessageRead(a,r,l)}catch(d){const{errorCode:e,errorInfo:t}=d;throw new n({functionName:"setMessageRead",code:e,message:t,moreMessage:u})}return Object.assign(Object.assign({},i),{successLog:{message:`${u} lastMessageSequence:${l}`}})})}_deleteTopicAtTips(e,t){return pe(this,void 0,void 0,function*(){this._core.ssoLog.debug("_deleteTopicAtTips",`${this._name}._deleteTopicAtTips groupID:${e} topicID:${t}`);const s=Xh.getTopic(e,t);if(!s)return;const n=(null==s?void 0:s.groupAtInfoList)||[];if(0!==n.length)try{const{common:{getCurrentUserID:s},OuterConstant:{CONV_AT_ALL:o}}=this._core;let i=[...n];if(i=n.filter(e=>!e.atTypeArray.includes(o)),0===i.length)return void Xh.clearGroupAtInfoList(e,t);const r=i.map(e=>({From_Account:e.from,To_Account:s(),MsgSeq:e.__sequence,MsgRandom:e.__random,GroupId:e.groupID}));yield function(e,t){return pe(this,void 0,void 0,function*(){const{messageListToDelete:s}=e,n={DelMsgList:s};return t.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:n})})}({messageListToDelete:r},this._core),this._core.ssoLog.debug(`${this._name}._deleteTopicAtTips ok. count:${n.length}`),Xh.clearGroupAtInfoList(e,t)}catch(o){console.error(`${this._name}._deleteTopicAtTips fail:`,o)}})}_getLocalMessageMaxSequence(e){var t;const{message:{messageDataHandler:s},OuterConstant:{CONV_GROUP:n}}=this._core,{topicID:o}=e,i=s.getLocalMessageList(`${n}${o}`),r=Math.max(...i.map(e=>e.sequence));let a=(null===(t=null==e?void 0:e.lastMessage)||void 0===t?void 0:t.lastSequence)||0;return r>a&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${a} to ${r}`),a=r),a}_setTopicMessageRead(e,t,s){return pe(this,void 0,void 0,function*(){try{yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,topicID:n,lastMessageSequence:o}=e,i={GroupId:s,TopicId:n,MsgReadedSeq:o};return t.common.buildAndSendPacket({servcmd:"million_group_open_http_svc.msg_read_report",data:i})})}({groupID:e,topicID:t,lastMessageSequence:s},this._core),console.log(`${this._name}._setTopicMessageRead ok, lastReadSequence:${s}`),Xh.updateSelfInfo({groupID:e,topicID:t,selfInfo:{readedSequence:s}}),Xh.markMessageAsRead(t,s),Xh.updateUnreadCount(e,t)}catch(n){throw console.error(`${this._name}._setTopicMessageRead fail:`,n),n}})}},up=new class{init(e){e.ssoLog.debug("TopicAction.init"),np.init(e),op.init(e),ip.init(e),rp.init(e),ap.init(e),cp.init(e)}};const lp={required:!0,rules:["string"],allowEmpty:!1},dp={createTopicInCommunity:{groupID:lp,topicName:lp},deleteTopicFromCommunity:{groupID:lp,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},getTopicList:{groupID:lp,topicIDList:{required:!1,rules:["array"],allowEmpty:!0}},updateTopicProfile:{groupID:lp,topicID:lp}},hp={getJoinedCommunityList:!0,createTopicInCommunity:!0,deleteTopicFromCommunity:!0,getTopicList:!0,updateTopicProfile:!0};var pp=new class{constructor(){this.name="Topic"}install(e){Fh.init(e),Xh.init(e),tp.init(e),sp.init(e),up.init(e),e.helper.registerValidateConfig({auth:hp,params:dp})}};function gp(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}const _p="qualityStat",mp="im-ssolog-quality-stat";var fp;!function(e){e[e.ONLINE=8]="ONLINE"}(fp||(fp={}));const vp="networkRTT",Ip="messageE2EDelay",Ep="sendMessageC2C",Sp="sendMessageGroup",yp="sendMessageGroupAV",Cp="sendMessageRichMedia",Mp="cosUpload",Ap="messageReceivedGroup",bp="messageReceivedGroupAVPush",Tp="messageReceivedGroupAVPull",Op={[vp]:2,[Ip]:3,[Ep]:4,[Sp]:5,[yp]:6,[Cp]:7,[Ap]:8,[bp]:9,[Tp]:10,[Mp]:11},wp=[Ep,Sp,yp,Cp,Mp],Dp=[Ap,bp,Tp],Rp=[vp,Ip,Ep,Sp,yp,Cp,Mp,Ap,bp,Tp],Lp={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},Np="quality_stat";var Pp=new class{constructor(){this._messageStatsMap=new Map,this._userSideErrorCodes=new Set(Object.values(Lp))}init(e){this._core=e,Object.values(wp).forEach(e=>{this._messageStatsMap.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costSum:0,costCount:0,fileSizeSum:0})})}dispatchSendStats(e){const{name:t,message:s,error:n,startTs:o}=e,{SEND_MESSAGE_STAT:i}=this._core.constants;switch(t){case i.TOTAL_COUNT:this._handleTotalCount(s);break;case i.SUCCESS_COUNT:this._handleSuccessCount(s);break;case i.FAILED_COUNT:this._handleFailedCount(s,n);break;case i.SEND_COST:this._handleSendCost(s,o)}}getStatResult(e){const t=this._messageStatsMap.get(e);if(!t||0===t.totalCount)return null;const{totalCount:s,successCount:n,failedCountOfUserSide:o}=t,i=gp(n/s*100,2),r=n+o,a=gp(r/s*100,2),c=this._calcAverageValue(t,e);return this._resetStat(e),{total_count:s,success_count_business:n,percent_business:i,success_count_platform:r,percent_platform:a,average_value:c}}_handleTotalCount(e){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.totalCount++}_handleSuccessCount(e){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.successCount++}_handleFailedCount(e,t){var s;const n=null!==(s=null==t?void 0:t.code)&&void 0!==s?s:null==t?void 0:t.errorCode;if(this._isUserSideError(n)){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.failedCountOfUserSide++}}_handleSendCost(e,t){const s=this._getSendMessageSpecifiedKey(e),n=s&&this._messageStatsMap.get(s);n&&(n.costSum+=Date.now()-t,n.costCount++)}_isUserSideError(e){return this._userSideErrorCodes.has(e)||e>=120001&&e<=13e4||e>=10100&&e<=10200}_getSendMessageSpecifiedKey(e){const{MSG_IMAGE:t,MSG_AUDIO:s,MSG_VIDEO:n,MSG_FILE:o,CONV_C2C:i,CONV_GROUP:r,GRP_AVCHATROOM:a}=this._core.OuterConstant;if([t,s,n,o].includes(e.type))return Cp;if(e.conversationType===i)return Ep;if(e.conversationType===r){const{groupStore:t}=this._core.appStore,s=t.getGroup(e.to);if(!s)return;const{type:n}=s;return n===a?yp:Sp}}_calcAverageValue(e,t){return 0===e.costCount?0:t===Mp?Math.round(1e3*e.fileSizeSum/e.costSum):Math.round(e.costSum/e.costCount)}_resetStat(e){const t=this._messageStatsMap.get(e);t&&(t.totalCount=0,t.successCount=0,t.failedCountOfUserSide=0,t.costSum=0,t.costCount=0,t.fileSizeSum=0)}},kp=new class{constructor(){this._lastCycleStats=new Map,this._currentCycleStats=new Map}init(e){this._core=e;const{OuterEvent:t,notificationCenter:s}=e;this._initStatsMap(),s.subscribeOuterEvent(t.MESSAGE_RECEIVED,this._onMessageReceived,this)}addMessageSequence(e){const t=this._getReceivedMessageSpecifiedKey(e),{utils:{isUndefined:s},OuterConstant:{CONV_GROUP:n},ssoLog:o}=this._core;if(s(t)||!this._currentCycleStats.has(t))return void o.warn("addMessageSequence",`${_p}.addMessageSequence invalid key:${t}`);const{conversationID:i,sequence:r}=e,a=i.replace(n,""),c=this._lastCycleStats.get(t);if(0===c.size||!c.has(a))return void this._addToCurrentCycle(t,a,r);const u=c.get(a);r>u.minSeq&&r<u.maxSeq?this._insertToLastCycle(r,u):this._addToCurrentCycle(t,a,r)}getStatResult(e){const t=this._lastCycleStats.get(e);if(!t||0===t.size)return this._transferCycleDataOptimized(e),null;let s=0,n=0;return t.forEach(e=>{const{sortedSequences:t,minSeq:o,maxSeq:i}=e;t.length>0&&(n+=t.length,s+=i-o+1)}),0===s?null:(this._transferCycleDataOptimized(e),{total_count:s,success_count_business:n,percent_business:gp(n/s*100,2)})}reset(){this._lastCycleStats.clear(),this._currentCycleStats.clear()}dispose(){const{notificationCenter:e,OuterEvent:{MESSAGE_RECEIVED:t}}=this._core;e.unSubscribeOuterEvent(t,this._onMessageReceived,this),this.reset()}_initStatsMap(){Object.values(Dp).forEach(e=>{this._lastCycleStats.set(e,new Map),this._currentCycleStats.set(e,new Map)})}_onMessageReceived(e){const{data:t=[]}=e;t.forEach(e=>{this.addMessageSequence(e)})}_transferCycleDataOptimized(e){const t=this._currentCycleStats.get(e);if(!t)return;const s=new Map;t.forEach((e,t)=>{const n=e.dirty?[...e.sortedSequences].sort((e,t)=>e-t):e.sortedSequences;s.set(t,{sortedSequences:n,minSeq:e.minSeq,maxSeq:e.maxSeq,dirty:!1})}),this._lastCycleStats.set(e,s),this._currentCycleStats.set(e,new Map)}_getReceivedMessageSpecifiedKey(e){const{OuterConstant:{CONV_GROUP:t,GRP_AVCHATROOM:s}}=this._core;if(e.conversationType===t&&!0!==(null==e?void 0:e._onlineOnlyFlag)){const{groupStore:t}=this._core.appStore,n=t.getGroup(e.to);if(!n)return null;const{type:o}=n;return o===s?Tp:Ap}}_insertToLastCycle(e,t){t.dirty&&(t.sortedSequences.sort((e,t)=>e-t),t.dirty=!1);const s=this._findInsertPos(t.sortedSequences,e);t.sortedSequences.splice(s,0,e),t.minSeq=Math.min(t.minSeq,e),t.maxSeq=Math.max(t.maxSeq,e)}_findInsertPos(e,t){let s=0,n=e.length-1;for(;s<=n;){const o=Math.floor((s+n)/2);if(e[o]===t)return o;e[o]<t?s=o+1:n=o-1}return s}_addToCurrentCycle(e,t,s){let n=this._currentCycleStats.get(e).get(t);n?(n.sortedSequences.push(s),n.minSeq=Math.min(n.minSeq,s),n.maxSeq=Math.max(n.maxSeq,s),n.dirty=!0):(n={sortedSequences:[s],minSeq:s,maxSeq:s,dirty:!1},this._currentCycleStats.get(e).set(t,n))}},Gp=new class{constructor(){this._totalDelay=0,this._totalCount=0,this._countLessThan1s=0,this._countLessThan3s=0}init(e){this._core=e;const{OuterEvent:{MESSAGE_RECEIVED:t},notificationCenter:s}=e;s.subscribeOuterEvent(t,this._onMessageReceived,this)}addMessageDelay(e){const{timeManager:t}=this._core.common,s=t.getServerTimeSeconds()-e;s>0&&(this._totalDelay+=s,this._totalCount++,s<=1?this._countLessThan1s++:s<=3&&this._countLessThan3s++)}getStatResult(){if(0===this._totalCount)return null;const e={total_count:this._totalCount,success_count_business:this._countLessThan1s,success_count_platform:this._countLessThan3s,percent_business:this._calculatePercentage(this._countLessThan1s,this._totalCount),percent_platform:this._calculatePercentage(this._countLessThan3s,this._totalCount),average_value:this._calculateAverageDelay(this._totalCount)};return this.reset(),e}reset(){this._totalDelay=0,this._totalCount=0,this._countLessThan1s=0,this._countLessThan3s=0}dispose(){const{notificationCenter:e,OuterEvent:{MESSAGE_RECEIVED:t}}=this._core;e.unSubscribeOuterEvent(t,this._onMessageReceived,this),this.reset()}_onMessageReceived(e){const{data:t=[]}=e,{OuterConstant:{MSG_GRP_TIP:s,MSG_GRP_SYS_NOTICE:n}}=this._core,o=[s,n];t.forEach(e=>{!o.includes(e.type)&&e.clientTime>0&&this.addMessageDelay(e.clientTime)})}_calculateAverageDelay(e){return 0===e?0:gp(this._totalDelay/e,1)}_calculatePercentage(e,t){return gp(e/t*100,2)}},Up=new class{init(e){this.core=e}},Fp=new class{constructor(){this.name="MessageQualityStat",this._reportIndex=0,this._wholePeriod=!1,this._pendingReports=[],this._failedLogsCache=new Map}install(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{QUALITY_STAT:n,LOGOUT:o,DESTROY:i},constants:{WORKFLOW_NAME:r,WORKFLOW_STEP:a}}=e;Up.init(e),Pp.init(e),kp.init(e),Gp.init(e),t.registerWorkflowStep(r.SYNC_SERVER_INFO_AFTER_LOGIN,a.QUALITY_REPORT,this.handleLoginSuccess,this),s.subscribeInnerEvent(n,this._handleQualityStat,this),s.subscribeInnerEvent(o,this._reset,this),s.subscribeInnerEvent(i,this._dispose,this)}handleLoginSuccess(){const{store:e,helper:t,utils:{isUndefined:s}}=this._core,n=e.get("cloudConfig")||{},{q_rpt_interval:o}=n,i=s(o)?12e4:Number(o);t.taskScheduler.addTask({id:Np,intervalMs:i,callback:this.report,context:this})}report(){this._wholePeriod=!0;const e=[...Rp.map(e=>{const t=this._buildQualityReportItem(e);return t?Object.assign(Object.assign({},t),{report_index:this._reportIndex,whole_period:this._wholePeriod}):null}).filter(Boolean),...this._pendingReports];this._pendingReports=[],this._needSkipReport()||this._uploadQualityReports(e)}_handleQualityStat(e){const{constants:{QUALITY_METRICS:t}}=this._core,{label:s,data:n}=e;s===t.MESSAGE_SEND_SUCCESS_RATE&&Pp.dispatchSendStats(n)}_needSkipReport(){return this._isSDKAppIDInBlacklist()&&!this._isTinyIDInWhitelist()}_isSDKAppIDInBlacklist(){const{store:e,utils:t}=this._core,s=e.get("cloudConfig")||{},n=e.get("instance")||{},{sdkAppId:o}=n,{q_rpt_sdkappid_bl:i=[]}=s;if(!t.isEmpty(i))return i.split(",").map(e=>Number(e)).includes(o)}_isTinyIDInWhitelist(){const{store:e,utils:t}=this._core,s=e.get("cloudConfig")||{},n=e.get("login")||{},o=Number(n.tinyID),{q_rpt_tinyid_wl:i=[]}=s;if(!t.isEmpty(i))return i.split(",").includes(o)}_buildQualityReportItem(e){const t=this._getStatResultByKey(e);if(null===t)return null;const s={quality_type:Op[e],timestamp:Date.now(),network_type:fp.ONLINE,extension:""};return Object.assign(Object.assign({},s),t)}_getStatResultByKey(e){switch(e){case Ip:return Gp.getStatResult();case Ep:case Sp:case yp:case Cp:case Mp:return Pp.getStatResult(e);case Ap:case bp:case Tp:return kp.getStatResult(e);default:return null}}_uploadQualityReports(e){return pe(this,void 0,void 0,function*(){try{const t={header:this._core.common.getCommonHead(),quality:e};yield function(e){const{common:t,channel:s}=Up.core,n="imopenstat.tim_web_report_v2",o=t.generateSSOLogProtocolData({servcmd:n,data:e}),i=`${o.head.seq}${n}`;s.sendPacket(o,{requestId:i})}(t),this._reportIndex++,this._wholePeriod=!1}catch(t){console.warn("doReport failed. error:",t),this._pendingReports=this._pendingReports.concat(e),this._cacheFailedLogs()}})}_cacheFailedLogs(){const e=this._pendingReports,t=`${_p}._cacheFailedLogs`;let s=[...this._failedLogsCache.get(mp)||[],...e];s.length>10&&(s=s.slice(s.length-10),console.log(`${t} logs overflow, keeping last 10 items`)),this._failedLogsCache.set(mp,s),console.log(`${t} count: ${s.length}`),this._pendingReports=[]}_reset(){const{helper:e}=this._core;e.taskScheduler.removeTask(Np)}_dispose(){const{notificationCenter:e,InnerEvent:{QUALITY_STAT:t,LOGOUT:s,DESTROY:n}}=this._core;e.unSubscribeInnerEvent(t,this._handleQualityStat,this),e.unSubscribeInnerEvent(s,this._reset,this),e.unSubscribeInnerEvent(n,this._dispose,this),this._reset(),Gp.dispose(),kp.dispose()}};const xp=1,$p=300;var qp=new class{constructor(){this.name="OfflineMessageSynchronizer",this._lastMessageSequenceMapOnDisconnect=new Map}install(e){this._core=e;const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:o}}=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncOfflineMessage,this),e.notificationCenter.subscribeInnerEvent(o.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}_syncOfflineMessage(e){const{conversationList:t}=(null==e?void 0:e.result)||{},{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){const e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}_recoverGroupHistoryMessage(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=[],n=[];return yield Promise.all(null==e?void 0:e.map(e=>pe(this,void 0,void 0,function*(){const{groupProfile:{groupID:o}={},lastMessage:{lastSequence:i}={}}=e,r=`${t.CONV_GROUP}${o}`;let a=this._getLocalLastMessageSequence(r);this._shouldRecoverHistory({localLastMessageSequence:a,serverLastMessageSequence:i})&&(yield this._recoverHistoryForConversation({conversationID:r,localLastMessageSequence:a,serverLastMessageSequence:i,groupTipList:n})),s.push(r.replace(t.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:s,groupTipList:n}})}_recoverHistoryForConversation(e){return pe(this,arguments,void 0,function*({conversationID:e,localLastMessageSequence:t,serverLastMessageSequence:s,groupTipList:n}){try{const{utils:{isArray:o,isObject:i,isEmpty:r},OuterEvent:a,OuterConstant:c,notificationCenter:u,message:l,appStore:d,common:{getMessagePreviewText:h}}=this._core,p=s-t,g=Math.min(20,p),_={},m=yield l.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:e,sequence:t+g,direction:c.Direction.FORWARD,count:g}),{nextReqMessageIDFromServer:f,hasNoMoreHistoryMessage:v,messageList:I,serverGroupTipList:E}=m;o(E)&&n.push(...E);const S=v&&f<0,y=[];if(o(I)&&(I.forEach(e=>{l.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===c.CONV_SYSTEM&&(e.isSystemMessage=!1),l.messageDataHandler.storeConversationMessage(e)&&!r(e.payload)&&(y.push(e),e._isExcludedFromLastMessage||(_.lastMessage=Object.assign({},e)))}),y.length>0&&u.emitOuterEvent(a.MESSAGE_RECEIVED,{name:a.MESSAGE_RECEIVED,data:y})),!S&&I.length>0){const t=I[I.length-1].sequence;yield this._recoverHistoryForConversation({conversationID:e,localLastMessageSequence:t,serverLastMessageSequence:s,groupTipList:n})}i(_.lastMessage)&&(_.lastMessage.messageForShow=h(_.lastMessage.type,_.lastMessage.payload),d.conversationStore.updateConversation(e,_))}catch(o){this._core.ssoLog.error("_recoverHistoryForConversation",`Recovery failed for conversation:${e}`,{error:o})}})}_updateLastMessageSequenceMapOnDisconnect(){const{message:e}=this._core,t=e.messageDataHandler.getContinuousMessagesByConversation();for(const[s,n]of t){if(s.startsWith("C2C"))continue;const e=Array.from(n.values());if((null==e?void 0:e.length)>0){const t=e[e.length-1].sequence;this._lastMessageSequenceMapOnDisconnect.set(s,t)}}}_getLocalLastMessageSequence(e){const{message:t}=this._core;if(this._lastMessageSequenceMapOnDisconnect.has(e))return this._lastMessageSequenceMapOnDisconnect.get(e);const s=t.messageDataHandler.getLocalMessageList(e),n=s[s.length-1];return null==n?void 0:n.sequence}_shouldRecoverHistory(e){const{localLastMessageSequence:t,serverLastMessageSequence:s}=e;if("number"!=typeof t||"number"!=typeof s)return!1;const n=s-t;return 0!==s&&t>0&&n>=xp&&n<$p}},Bp=new class{init(e){this.core=e}},Vp=new class{constructor(){this._reportedAtomicStoreIDs=new Set}init(e){const{helper:{registerExperimentalAPI:t}}=e;this._core=e,t("reportModalView",this),t("reportTUIFeatureUsage",this)}reportModalView(e){const{ssoLog:t,utils:{safeStringify:s,isString:n}}=this._core;try{if(!n(e))throw new Error("reportModalView data is not a string");t.createSSOLogData({method:"reportModalView",message:e,eventType:30}).end(!0)}catch(o){t.debug(`reportModalView Report failed: ${s(o)}`)}}reportTUIFeatureUsage(e){const{ssoLog:t,utils:{safeStringify:s,isEmpty:n}}=this._core,{atomicStoreID:o}=e;try{n(o)||this._reportedAtomicStoreIDs.has(o)||(this._core.ssoLog.info("reportTUIFeatureUsage",`atomicStoreID: ${e.atomicStoreID}`,{method:"reportTUIFeatureUsage",eventType:31,code:o}),this._reportedAtomicStoreIDs.add(o))}catch(i){t.debug(`reportTUIFeatureUsage Report failed: ${s(i)}`)}}reset(){this._reportedAtomicStoreIDs.clear()}dispose(){this.reset()}},Wp=new class{constructor(){this.name="DataReport"}install(e){this._core=e;const{notificationCenter:t,InnerEvent:{LOGOUT:s,DESTROY:n}}=e;Bp.init(e),Vp.init(e),t.subscribeInnerEvent(s,this._reset,this),t.subscribeInnerEvent(n,this._dispose,this)}_reset(){Vp.reset()}_dispose(){const{notificationCenter:e,InnerEvent:{LOGOUT:t,DESTROY:s}}=this._core;e.unSubscribeInnerEvent(t,this._reset,this),e.unSubscribeInnerEvent(s,this._dispose,this),Vp.dispose()}};const jp=new class{init(e){this.core=e}};function Hp(e){const{common:{filterProtocolDataInvalidFields:t,calcBodyCRC:s}}=jp.core,{servcmd:n,data:o}=e,i=function(e){const{store:t,common:{generateSequence:s},utils:{platform:n,base16EncodeBinaryString:o},constants:{WEB_PUSH_ACCOUNT_TYPE:i}}=jp.core,r=t.get("webPush")||{},a=t.get("instance")||{};return{servcmd:e,ver:"v4",platform:n,websdkappid:537048168,websdkversion:"1.7.3",a2:r.a2Key||void 0,tinyid:r.tinyID||void 0,status_instid:r.statusInstanceId||0,sdkappid:a.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:r.a2Key?void 0:r.userId,usersig:r.a2Key?void 0:r.userSig,sdkability:75689843,sdkability_ext:o(""),cappid:a.applicationID||0,tjgID:"",seq:s(),cs:0,idtype:i}}(n),r=t(o);return i.cs=s(n,r),{head:i,body:r}}const Kp=0,Yp=1,zp=2;function Zp(){return function(){if("undefined"==typeof window)return!1;if(window.matchMedia){const e=window.matchMedia("(display-mode: standalone)").matches,t=window.matchMedia("(display-mode: fullscreen)").matches;if(e)return!0;if(t){const e=!!document.querySelector('link[rel="manifest"]'),t="serviceWorker"in navigator&&null!==navigator.serviceWorker.controller;return e||t}}return"undefined"!=typeof navigator&&!0===navigator.standalone||!("undefined"==typeof document||!document.referrer||!document.referrer.includes("android-app://"))}()?zp:function(){const{utils:{IS_IOS:e,IS_ANDROID:t,USER_AGENT:s}}=jp.core;if(e||t)return!0;if("undefined"!=typeof navigator){const e=navigator;if(e.userAgentData&&e.userAgentData.mobile)return!0}const n=s.toLowerCase();return/android|webos|iphone|ipad|ipod|blackberry|windows phone|mobile|opera mini|iemobile/i.test(n)}()?Yp:Kp}function Jp(){return pe(this,void 0,void 0,function*(){var e;const{channel:t}=jp.core,s="im_open_status.wslogin",n=Hp({servcmd:s,data:{State:"Online",is_web_uniapp:0,InstType:0,WebClientType:Zp(),IsWebPushLogin:1,DomainList:[(null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin)||""]}}),o=`${n.head.seq}${s}`;return t.sendPacket(n,{timeout:9e4,requestId:o})})}var Xp=new class{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0}init(e){this._core=e;const{helper:{registerExperimentalAPI:t},notificationCenter:s,InnerEvent:{ERROR:n,FORCE_OFFLINE:o,DESTROY:i,RECONNECTED:r},constants:{ERROR_CODE:a}}=e;s.subscribeInnerEvent(o,this._handleForceOfflineFromServerPush,this),s.subscribeInnerEvent(n,a.ACCOUNT_A2KEY_EXPIRED,this._handleForceOfflineFromResponse,this,this._isWebPushEvent),s.subscribeInnerEvent(r,this._reLoginWebPush,this),s.subscribeInnerEvent(i,this._dispose,this),t("loginWebPush",this),t("logoutWebPush",this),t("setWebPushToken",this)}loginWebPush(e){return pe(this,void 0,void 0,function*(){const{store:t,common:{ChatError:s},constants:{ERROR_CODE:n},utils:{safeStringify:o},ssoLog:i}=this._core;i.debug("loginWebPush.start",o(e));try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new s({functionName:"loginWebPush",code:n.REPEAT_LOGIN});const{userID:r,userSig:a}=e;t.set("webPush",{userId:r,userSig:a});const c=yield Jp();if(c){i.info("loginWebPush",o(c));const{HelloInterval:e,TimeStamp:t,WebPushPubKey:s,InstId:n,A2Key:r,TinyId:a}=c;return this._latestLoginAt=0,this._handleLoginWebPushSuccess({helloInterval:e,serverTimeSeconds:t,instanceID:n,a2Key:r,tinyID:a,vapid:s}),{code:0,data:{vapid:s}}}}catch(r){const{errorCode:e,errorInfo:t}=r;throw e!==n.REPEAT_LOGIN&&(this._latestLoginAt=0),i.error("loginWebPush",o(r)),new s({functionName:"loginWebPush",code:e,message:t})}})}setWebPushToken(e){return pe(this,void 0,void 0,function*(){const{utils:{safeStringify:t},ssoLog:s,common:{ChatError:n}}=this._core;s.debug("setWebPushToken.start",t(e));try{const n=yield function(e){return pe(this,void 0,void 0,function*(){var t;const{store:s,channel:n}=jp.core,{browserType:o,pushToken:i,webPushAuthKey:r,webPushP256:a,pushSDKVersion:c,browserVersion:u,browserPlatform:l,browserLanguage:d}=e,h="offline_push_status.webpush_set_token",p=Hp({servcmd:h,data:{InstType:o,Auth:r,Endpoint:i,P256:a,SdkVer:(null===(t=s.get("instance"))||void 0===t?void 0:t.version)||"",PushVer:c,DevMod:u,DevOS:l,Lang:d}}),g=`${p.head.seq}${h}`;return n.sendPacket(p,{requestId:g})})}(e);return s.info("setWebPushToken",t(n)),n}catch(o){const{errorCode:e,errorInfo:i}=o;throw s.error("setWebPushToken",t(o)),new n({functionName:"loginWebPush",code:e,message:i})}})}logoutWebPush(e){return pe(this,void 0,void 0,function*(){const{utils:{safeStringify:t},ssoLog:s,common:{ChatError:n}}=this._core;s.debug("logoutWebPush.start",t(e));const{needLogoutFromServer:o=!0}=e||{};try{return o&&(yield function(){return pe(this,void 0,void 0,function*(){const e="im_open_status.wslogout",t=Hp({servcmd:e,data:{wslogout_type:0,isWebUniapp:0}}),s=`${t.head.seq}${e}`;return jp.core.channel.sendPacket(t,{requestId:s})})}()),s.info("logoutWebPush"),{code:0,data:{}}}catch(i){const{errorCode:e,errorInfo:o}=i;throw s.error("logoutWebPush",t(i)),new n({functionName:"logoutWebPush",code:e,message:o})}finally{this._reset()}})}_isLoginIn(){var e;return!0===(null===(e=this._core.store.get("webPush"))||void 0===e?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_handleLoginWebPushSuccess(e){var t;const{store:s}=this._core,{timeManager:n}=this._core.common,{serverTimeSeconds:o,a2Key:i,tinyID:r,instanceID:a,vapid:c}=e;if(!0!==(null===(t=s.get("login"))||void 0===t?void 0:t.isLoggedIn)){const e=1e3*o;n.calculateTimeOffsetWithServer(this._latestLoginAt,e)}s.set("webPush",{a2Key:i,tinyID:r,statusInstanceId:a,isLoggedIn:!0,vapid:c})}_handleForceOfflineFromResponse(e){this._isLoginIn()&&this.logoutWebPush({needLogoutFromServer:!1})}_isWebPushEvent(e){const{head:t}=e||{},{constants:{WEB_PUSH_ACCOUNT_TYPE:s}}=this._core;return(null==t?void 0:t.idtype)===s}_createRepeatLoginResponse(){var e;const{store:t,common:{getErrorMessage:s}}=this._core;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:s({code:"RepeatLogin",replacement1:null===(e=t.get("webPush"))||void 0===e?void 0:e.userId}),repeatLogin:!0}}}_handleForceOfflineFromServerPush(e){this.logoutWebPush({needLogoutFromServer:!1})}_reLoginWebPush(){return pe(this,void 0,void 0,function*(){const{store:e,ssoLog:t,utils:{safeStringify:s}}=this._core;try{if(!this._isLoginIn())return;const t=yield Jp();if(t){const{InstId:s}=t;e.set("webPush",{statusInstanceId:s})}}catch(n){t.warn("_reLoginWebPush",s(n))}})}_reset(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._core.store.clear("webPush")}_dispose(){const{notificationCenter:e,InnerEvent:{ERROR:t},constants:{ERROR_CODE:s}}=this._core;this._reset(),e.unSubscribeInnerEvent(t,s.ACCOUNT_A2KEY_EXPIRED,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(t,s.MSG_A2KEY_EXPIRED,this._handleForceOfflineFromResponse,this)}},Qp=new class{constructor(){this.name="PushTokenRegisterPlugin"}install(e){jp.init(e),Xp.init(e)}};let eg=Rs.STANDARD,tg=[];eg=Rs.PROFESSIONAL,tg=[Wn,Vn,Hn,to,oo,Fp,qp,Wp,Vi,ta,Ga,tl,Pl,sh,No,Cd,Fd,Uh,pp,Qp];var sg=Object.freeze({__proto__:null,ChatError:tn,WorkflowManager:pn,buildAndSendPacket:In,get builtInPlugins(){return tg},checkBusinessCapabilityBits:hn,deepMerge:An,getCurrentUserID:Cn,getErrorMessage:en,getMessagePreviewText:bn,isC2CConv:e=>s(e)&&e.slice(0,3)===Ss.CONV_C2C,isCommunity:_n,isGroupConv:e=>s(e)&&e.slice(0,5)===Ss.CONV_GROUP,isTopic:mn,isUnlimitedAVChatRoom:function(){var e;return!!(null===(e=ns.store.get("instance"))||void 0===e?void 0:e.unlimitedAVChatRoom)},liteChatInstanceMap:gn,registerInterceptor:ln,registerValidateConfig:dn,requireAuth:sn,get sdkEdition(){return eg},updateGroupAtInfo:(e,t)=>{const{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:o}=ws;if(function(e,t){const{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:o}=ws,{groupID:i,sequence:r}=e;let a=!1;return _n({groupID:i})?(t.forEach(t=>{t.messageSequence===r&&(t.atTypeArray.includes(s)&&e.groupAtType.includes(n)&&(t.atTypeArray=[o]),t.atTypeArray.includes(n)&&e.groupAtType.includes(s)&&(t.atTypeArray=[o],t.__random=e.__random,t.__sequence=e.__sequence),a=!0)}),a):a}(e,t))return;let i=[...e.groupAtType];i.includes(s)&&i.includes(n)&&(i=[o]);const r={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:i,__random:e.__random,__sequence:e.__sequence};t.push(r)},validateAndExecute:un,validateParameters:nn});class ng{constructor(){this._builtInPlugins=new Set,this._externalPlugins=new Set}static getInstance(){return ng._instance||(ng._instance=new ng),ng._instance}static setInstance(e){ng._instance=e}installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}_installPlugin(e,t){let s=[];s=o(e)?e:[e];const n=s.findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=n>-1?s.splice(n,1):[];s.forEach(e=>{this._isPluginInstalled(e.name)||(e&&os(e.install)?(t.add(e.name),os(e.getInstalledSubPlugins)?e.install(ug.getInstance().exposeApiForPlugin(),i):e.install(ug.getInstance().exposeApiForPlugin()),os(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):os(e)?(t.add(e.name),e(ug.getInstance().exposeApiForPlugin()),os(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}_isPluginInstalled(e){return this._builtInPlugins.has(e)||this._externalPlugins.has(e)}_isLoggedIn(){var e;return!0===(null===(e=ns.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}}var og=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}){const{emit:n,needSort:o}=s,i=this._conversationMap.get(e);i&&!Ie(t)&&(Object.keys(t).forEach(e=>{i[e]=t[e]}),n&&ns.notificationCenter.emitInnerEvent(ls.CONVERSATION_UPDATED,{needSort:o}))}deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),ns.notificationCenter.emitInnerEvent(ls.CONVERSATION_UPDATED))}},ig=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&&!Ie(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}},rg=new class{constructor(){this._messagesByConversation=new Map}updateMessage(e,t,s){var n;const{operation:o,updateUnreadCount:i=!0}=s,r=he(s,["operation","updateUnreadCount"]),a=[];for(const c of t){const t=null===(n=this._messagesByConversation.get(e))||void 0===n?void 0:n.get(c);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){const{conversationID:s}=t;mn(s)?ns.notificationCenter.emitInnerEvent(vs[e],t):ns.notificationCenter.emitInnerEvent(e,t)}},ag=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)}},cg=Object.freeze({__proto__:null,conversationStore:og,groupStore:ig,messageStore:rg,userStore:ag});class ug{static getInstance(){return ug._instance||(ug._instance=new ug),ug._instance}static setInstance(e){ug._instance=e}constructor(){this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this),setApplicationID:this.setApplicationID.bind(this)},this._apiHandlersMap={},this._apiMap={on:ns.notificationCenter.subscribeOuterEvent.bind(ns.notificationCenter),off:ns.notificationCenter.unSubscribeOuterEvent.bind(ns.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:ng.getInstance().installExternalPlugin.bind(ng.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}registerPlugin(e){ns.ssoLog.debug("registerPlugin",e)}statKeyFeatureUsage(e){ns.ssoLog.debug("statTUIKeyFeatures",e)}setLogLevel(e){ns.ssoLog.debug("setLogLevel",e),ns.ssoLog.setLogLevel(e)}setApplicationID(e){ns.store.set("instance",{applicationID:e})}getApiMap(){return this._apiMap}setApiMap(e){this._apiMap=e}registerApi(e){const{common:{timeManager:t},utils:{safeStringify:s}}=ns,{apiName:n,context:o,methodName:i=n,matcher:r}=e;this._apiHandlersMap[n]||(this._apiHandlersMap[n]=[]),this._apiHandlersMap[n].push({context:o,methodName:i,matcher:r}),this._apiMap[n]&&1!==this._apiHandlersMap[n].length||(this._apiMap[n]=(...e)=>{let o=t.getServerTimeMs(),r=0;"login"===n&&(r=4),Us.includes(n)&&ns.ssoLog.debug(n,`${n} start params: ${s(e)}`),un(i,e);const a=this._apiHandlersMap[n];for(const s of a)if(!s.matcher||s.matcher(e))try{const t=s.context[s.methodName].bind(s.context)(...e);return this._isPromiseLike(t)?this._handleAsyncResult(t,n,r,o):(this._reportApiSuccessLog({result:t,apiName:n,eventType:r,startTime:o}),t)}catch(c){throw ns.ssoLog.error(n,`${n} fail ${(null==c?void 0:c.errorMessage)||(null==c?void 0:c.message)})`,{error:c,costTime:t.getServerTimeMs()-o,eventType:r,method:n}),c}})}registerExperimentalAPI(e,t,s){const n=s||e;this._experimentalApiMap[e]=t[n].bind(t)}destroy(){return pe(this,void 0,void 0,function*(){var e,t;try{(null===(e=ns.store.get("login"))||void 0===e?void 0:e.isLogin)&&(yield this._apiMap.logout()),ns.notificationCenter.emitInnerEvent(ls.DESTROY)}catch(s){console.debug("destroy error: ",s)}finally{ns.notificationCenter.emitOuterEvent(cs.SDK_DESTROY,{SDKAppID:null===(t=ns.store.get("instance"))||void 0===t?void 0:t.sdkAppId}),gn.clear(),ng.getInstance().clear(),pn.getInstance().destroy(),ns.destroy()}})}exposeApiForClient(){return this._apiMap}exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:ls,InnerEventSubType:ns.notificationCenter.InnerEventSubType,OuterEvent:cs,OuterConstant:ws,SignalingEvent:ds,helper:Object.assign(Object.assign(Object.assign({},ns.utils),ns.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:ln,registerValidateConfig:dn,checkBusinessCapabilityBits:hn,registerWorkflowStep:pn.getInstance().registerWorkflowStep.bind(pn.getInstance()),ChatError:tn}),apiMap:this._apiMap},ns),{constants:Object.assign(Object.assign({},qs),ns.constants),common:Object.assign(Object.assign(Object.assign({},sg),ns.common),{workflowManager:pn.getInstance()}),utils:ns.utils,appStore:cg})}callExperimentalAPI(e,t){return ns.ssoLog.debug(`callExperimentalAPI.${e} start params: ${ns.utils.safeStringify(t)}`),this._experimentalApiMap[e]?this._experimentalApiMap[e](t):Promise.reject(new tn({code:Ds.INVALID_OPERATION}))}_isPromiseLike(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}_handleAsyncResult(e,t,s,n){return e.then(e=>(this._reportApiSuccessLog({result:e,apiName:t,eventType:s,startTime:n}),e)).catch(e=>{throw ns.ssoLog.error(t,`${t} fail ${(null==e?void 0:e.errorMessage)||(null==e?void 0:e.message)})`,{error:e,costTime:ns.common.timeManager.getServerTimeMs()-n,eventType:s,method:t}),e})}_reportApiSuccessLog(e){let{result:t,apiName:s,startTime:n,eventType:o}=e;const{timeManager:i}=ns.common,{successLog:{message:r,moreMessage:a}={message:"",moreMessage:""}}=t||{},c=i.getServerTimeMs();"login"===s&&(n+=i.getTimeOffsetWithServer()),Us.includes(s)&&ns.ssoLog.info(s,`${s} success ${r} ${a}`,{costTime:c-n,eventType:o,message:r,moreMessage:a}),(null==t?void 0:t.successLog)&&delete t.successLog}}class lg{constructor(){this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120,this._customLoginInfo=""}init(){const{notificationCenter:e,store:t}=ns;t.set("login",{isReady:!1}),ug.getInstance().registerApi({apiName:"login",context:this}),ug.getInstance().registerApi({apiName:"logout",context:this}),ug.getInstance().registerApi({apiName:"getLoginUser",context:this}),ug.getInstance().registerApi({apiName:"isReady",context:this}),ug.getInstance().registerExperimentalAPI("setCustomLoginInfo",this),e.subscribeInnerEvent(ls.RECONNECTED,this._reLogin,this),ns.notificationCenter.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}login(e){return pe(this,void 0,void 0,function*(){var t;const{sdkEdition:s}=ns.store.get("instance")||{};try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new tn({functionName:"login",code:Ds.REPEAT_LOGIN});const n=yield this._performLogin(e);this._validateAfterLogin(n),this._handleLoginSuccess(n),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),this._latestLoginAt=0;const o=null===(t=ns.channel.getSocketAdapter())||void 0===t?void 0:t.getId(),{appId:i,href:r}=ns.store.get("instance")||{},{instanceID:a,customStatus:c}=n||{};return{code:0,data:n,successLog:{message:s,moreMessage:`socketID:${o} instanceID:${a} customStatus:${c} href: ${r} appId: ${i}`}}}catch(n){const{errorCode:e}=n;e!==Ds.REPEAT_LOGIN&&(this._latestLoginAt=0);const t=new tn({functionName:"login",code:e});throw console.error(t),t}})}_reLogin(){return pe(this,void 0,void 0,function*(){var e;try{if(!this._isLoginIn())return;const t=yield Qs(this._customLoginInfo);if(t){const{instanceID:s,customStatus:n}=t;ns.store.set("login",{statusInstanceId:s}),pn.getInstance().executeWorkflow(Ls.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:n,statusType:Is.USER_STATUS_ONLINE});const o=null===(e=ns.channel.getSocketAdapter())||void 0===e?void 0:e.getId();ns.ssoLog.info("reLogin",`socketId:${o} instanceId:${s}`)}}catch(t){console.warn(t)}})}logout(){return pe(this,arguments,void 0,function*(e=Fs.USER_INITIATED){const{ssoLog:t}=ns;t.debug("logout",`logout start logoutReason: ${e}`);try{yield this._performLogout(e),t.info("logout","logout success"),ns.ssoLog.uploadSSOLogData()}catch(s){const{errorCode:e}=s;throw new tn({functionName:"logout",code:e})}finally{this._handleLogoutCompleted()}return{code:0,data:{}}})}getLoginUser(){return this._isLoginIn()?Cn():""}isReady(){var e;return null===(e=ns.store.get("login"))||void 0===e?void 0:e.isReady}setCustomLoginInfo(e=""){this._customLoginInfo=e}_updateAndEmitSDKReady(){ns.store.set("login",{isReady:!0}),setTimeout(()=>{ns.notificationCenter.emitOuterEvent(cs.SDK_READY,{name:cs.SDK_READY})},1)}_updateAndEmitSDKNotReady(){ns.store.set("login",{isReady:!1}),ns.notificationCenter.emitOuterEvent(cs.SDK_NOT_READY,{name:cs.SDK_NOT_READY})}_validateAfterLogin(e){const t="login";if(!e)throw new tn({functionName:t,message:"login response is empty"});const{tinyID:s,a2Key:n}=e||{};if(!s)throw new tn({functionName:t,code:Ds.NO_TINYID});if(!n)throw new tn({functionName:t,code:Ds.NO_A2KEY})}_createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:en({code:"RepeatLogin",replacement1:null===(e=ns.store.get("login"))||void 0===e?void 0:e.userId}),repeatLogin:!0}}}_performLogin(e){return pe(this,void 0,void 0,function*(){const{userID:t,userSig:s}=e;return ns.store.set("login",{userId:t,userSig:s}),this._latestLoginAt=Date.now(),Qs(this._customLoginInfo)})}_ensureAsyncComplete(){return pe(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}_handleLoginSuccess(e){const{timeManager:t}=ns.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),ns.user.userStatus.setCustomStatus(o),pn.getInstance().executeWorkflow(Ls.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:i}),ns.common.taskScheduler.addTask({id:Vs,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this})}_performLogout(e){return function(e){return pe(this,void 0,void 0,function*(){const{logoutReason:t}=e,s="im_open_status.wslogout",n=ns.common.generateProtocolData({servcmd:s,data:{wslogout_type:t,isWebUniapp:0}}),o=`${n.head.seq}${s}`;return yield ns.channel.sendPacket(n,{requestId:o})})}({logoutReason:e})}_handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),pn.getInstance().reset(),ns.notificationCenter.emitInnerEvent("logout")}_updateLoginStore(e){const{a2Key:t,tinyID:s,instanceID:n,authKey:o}=e;ns.store.set("login",{a2Key:t,tinyID:s,statusInstanceId:n,authKey:o,isLoggedIn:!0})}_sendOnlinePresenceRequest(){return pe(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{yield function(){const e="im_open_status.wshello",t=ns.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),s=`${t.head.seq}${e}`;return ns.channel.sendPacket(t,{requestId:s})}()}catch(_){ns.ssoLog.warn("_sendOnlinePresenceRequest",` error:${_.message}`)}})}_isLoginIn(){var e;return!0===(null===(e=ns.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}_isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}_reset(){ns.common.taskScheduler.removeTask(Vs),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,this._customLoginInfo="",ns.store.clear("login"),ns.store.set("login",{isReady:!1}),ns.store.set("instance",{applicationID:0})}_dispose(){this._reset();const{notificationCenter:e}=ns;e.unSubscribeInnerEvent(ls.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this)}}const dg={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},hg={logout:!0};class pg{constructor(){this.loginAction=new lg,this.kickedOutHandler=new Xs,this.loginAction.init(),this.kickedOutHandler.init(),dn({auth:hg,params:dg})}}var gg,_g,mg;!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(gg||(gg={})),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(_g||(_g={})),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"}(mg||(mg={}));const fg={1:_g.MSG_PRIORITY_HIGH,2:_g.MSG_PRIORITY_NORMAL,3:_g.MSG_PRIORITY_LOW,4:_g.MSG_PRIORITY_LOWEST},vg=0,Ig=1;var Eg;!function(e){e.IN="in",e.OUT="out"}(Eg||(Eg={}));const Sg=2,yg={};function Cg(e){if(!e)return 0;if(void 0===yg[e]){const t=new Date,s=`3${t.getHours()}`.slice(-2),n=`0${t.getMinutes()}`.slice(-2),o=`0${t.getSeconds()}`.slice(-2);yg[e]=parseInt([s,n,o,"0001"].join(""),10),console.log(`autoIncrementIndex start index:${yg[e]}`)}else yg[e]+=1;return yg[e]}class Mg{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=_g.MSG_PRIORITY_NORMAL,this._relayFlag=!1;const{clientTime:t=ns.common.timeManager.getServerTimeSeconds()||0,senderTinyID:s,currentUser:n,needReadReceipt:o,isSupportExtension:i,customModerationConfigurationId:r,to:a,from:c,nick:u="",avatar:l="",time:d,messageControlInfo:h,tinyID:p,cloudCustomData:g="",messageLifeTime:_,messageVersion:m=0,conversationType:f,sequence:v,checkResult:I=0,isPlaceMessage:E=0,messageFlagBits:S,receiverList:y,isSystemMessage:C=!1,status:M=gs.SUCCESS,revokeReason:A="",conversationSubType:b,clientSequence:T,protocol:O="JSON",revokerInfo:w={userID:"",nick:"",avatar:""},readReceiptInfo:D={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:R,groupProfile:L,atUserList:N,flow:P,isRead:k=!1}=e;var G;this.clientTime=t,this.senderTinyID=s||p,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===i||1===i,this._cmConfigID=r,this.to=a,this.nick=u,this.avatar=l,this.protocol=O,this.random=void 0===R?(G=G||99999999,Math.round(Math.random()*G)):R,this.time=d||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!!(null==h?void 0:h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!!(null==h?void 0:h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=g,this.messageLifeTime=_,this.from=c||null,this.sequence=v||0,this.conversationType=f||gg.CONV_C2C,this.hasRiskContent=I>1,this.version=m,this.isPlaceMessage=E,this.isRevoked=2===E||8===S,this.isSystemMessage=C,this.readReceiptInfo=D,this.revokeReason=A,this.revokerInfo=w,this._receiverList=y,this.conversationSubType=b,this.revoker=(null==w?void 0:w.revoker)||"",this.clientSequence=T||v||0,this.status=M,this.atUserList=N||[],this.flow=P,this.isRead=k,this.reInitialize(n),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,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===gg.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!==gg.CONV_SYSTEM?(t=s===gg.CONV_C2C?e===this.from?this.to:this.from:this.to,this.conversationID=t?`${s}${t}`:null):this.conversationID=gg.CONV_SYSTEM}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=Cg(e)),0===this.sequence&&this.conversationType===gg.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===gg.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-${this.random}`}setIsRead(e){this.isRead=e}}class Ag{static parseServerPushElement(e){const{MsgContent:t={}}=e,{Data:s,Ext:n,Desc:o}=t;return new Ag({data:s,description:o,extension:n})}constructor(e){this.type=mg.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}=ns.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 bg{static parseServerPushElement(e){const{MsgContent:t={Text:""}}=e,{Text:s}=t;return new bg({text:s})}constructor(e){this.type=ps.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}}}}var Tg=new class{constructor(){this._elementClassMap={[mg.MSG_CUSTOM]:Ag,[mg.MSG_TEXT]:bg}}init(){ug.getInstance().registerApi({apiName:"createCustomMessage",context:this}),ug.getInstance().registerApi({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=Eg.OUT}=e,{userId:n}=ns.store.get("login")||{};this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=Eg.OUT);const o=Object.assign(Object.assign({},e),{currentUser:n});return new Mg(o)}createCustomMessage(e){const t=Cn(),s=this.createMessage(Object.assign(Object.assign({},e),{from:t})),n=this._elementClassMap[mg.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 bg({text:s}),o=Cn(),i=ns.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}=ns.store.get("login")||{},i=ag.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=gs.UNSENT,e.flow=Eg.OUT,e}_isMultiEndpointSyncMessage(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===Eg.IN}_isSendByCurrentInstance(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===Eg.OUT}};const Og={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}},wg={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Dg={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Rg(e,t){return Object.keys(t).forEach(s=>{const{range:n,defaultValue:o}=t[s];e[s]=n.includes(e[s])?e[s]:o}),e}function Lg(e){const t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Ng(e){const{androidInfo:t={},androidOPPOChannelID:s=""}=e,n=t.OPPOChannelID||s,o=Rg(t,wg),{sound:i="",FCMChannelID:r=""}=o,a=he(o,["sound","FCMChannelID"]);return Object.assign(Object.assign({},a),{Sound:Lg(i),OPPOChannelID:n,GoogleChannelID:r})}function Pg(t){const{apnsInfo:s={},ignoreIOSBadge:n=!1,disableVoipPush:o}=t,i=Rg(s,Dg),{ignoreIOSBadge:r,disableVoipPush:a,enableIOSBackgroundNotification:c}=i,u=he(i,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),l=!0===r||!0===n?1:0;let d;return e(o)||(d=!1===o?1:0),e(a)||(d=!1===a?1:0),Object.assign(Object.assign({},u),{BadgeMode:l,IsVoipPush:d,ContentAvailable:c?1:0})}function kg(e){return ns.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Pg(e),AndroidInfo:Ng(e)}:Og}function Gg(e){const{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:o,IsSyncMsg:i,MsgBody:r,MsgClientTime:a,MsgLifeTime:c,MsgRandom:u,MsgSeq:l,MsgTimeStamp:d,SendMsgControl:h,SupportMessageExtension:p,TinyId:g,MsgCheckResult:_,CloudCustomData:m,MsgVersion:f,MsgFlagBits:v,RevokerInfo:I}=e;let E,{From_Account:S,To_Account:y}=e;if(1===i){const e=y;y=S,S=e}if(I){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=I;E={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:S,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:i,clientTime:a,messageLifeTime:c,random:u,sequence:l,time:d,messageControlInfo:{excludedFromLastMessage:1===(null==h?void 0:h.NoLastMsg),excludedFromUnreadCount:1===(null==h?void 0:h.NoUnread)},isSupportExtension:p,to:y,tinyID:g,checkResult:_,cloudCustomData:m,revokerInfo:E,messageVersion:f,messageFlagBits:v,readReceiptSentByPeer:o,elements:$g(r)}}function Ug(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,To_Account:a,MsgVersion:c,CloudCustomData:u}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,to:a,elements:$g(s),messageVersion:c,cloudCustomData:u}}function Fg(e){const{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:o,MsgClientTime:i,MsgRandom:r,MsgSeq:a,MsgTimeStamp:c,SendMsgControl:u,SupportMessageExtension:l,TinyId:d,CloudCustomData:h,MsgVersion:p,MsgCheckResult:g,NeedReadReceipt:_,IsPlaceMsg:m,RevokerInfo:f,GroupAtInfo:v}=e;let I,E=_g.MSG_PRIORITY_NORMAL;if(Object.keys(fg).includes(String(e.MsgPriority))&&(E=fg[e.MsgPriority]),f){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=f;I={reason:e,revoker:t,revokerFromUin:s,userID:t}}const S=function(e){const t=[];return Array.isArray(e)&&e.forEach(e=>{e.GroupAtAllFlag===vg?t.push(e.GroupAt_Account):e.GroupAtAllFlag===Ig&&t.push(ws.MSG_AT_ALL)}),t}(v);return{clientSequence:t,from:s,groupProfile:n,clientTime:i,priority:E,random:r,sequence:a,time:c,messageControlInfo:{excludedFromLastMessage:1===(null==u?void 0:u.NoLastMsg),excludedFromUnreadCount:1===(null==u?void 0:u.NoUnread)},isSupportExtension:l,tinyID:d,cloudCustomData:h,messageVersion:p,messageCheckResult:g,needReadReceipt:_,isPlaceMessage:m,revokerInfo:I,atUserList:S,elements:$g(o),to:xg(e)}}function xg(e){const{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=ns,{ToGroupId:n,GroupInfo:{MillionGroupFlag:o=0,TopicId:i}={}}=e;return o!==s||t(i)?n:i}function $g(e){if(!e)return null;if(Array.isArray(e))return e.map(e=>{const t=ns.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)});const t=ns.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}function qg(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,GroupId:a,TopicId:c,MsgVersion:u,CloudCustomData:l}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,groupID:a,topicID:c,elements:$g(s),messageVersion:u,cloudCustomData:l}}function Bg({conversationUpdateFields:e,message:t}){const{conversationID:s,conversationType:n,conversationSubType:o,flow:i,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,c=a?"":t,u=!r&&i===Eg.IN;e.has(s)?(e.get(s).lastMessage=c,u&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:o,unreadCount:u?1:0,lastMessage:c})}function Vg(e){return e.filter(e=>{const t=!Ie(null==e?void 0:e.getElements()),s=1===(null==e?void 0:e.isPlaceMessage);return t||ns.ssoLog.error("emptyMessageBody",`from:${e.from} to:${e.to} sequence:${e.sequence}`),t&&!s})}function Wg(e){const{messageDataHandler:t}=ns.message;return!t.isInMessageList(e)&&!t.isMessageSentByCurrentInstance(e)}var jg=Object.freeze({__proto__:null,autoIncrementIndex:Cg,filterValidMessages:Vg,parseServerGroupMessage:Fg,parseServerPushC2CModifyMessage:Ug,parseServerPushGroupModifyMessage:qg,parseServerPushMessage:Gg,parseServerPushMessageElement:$g,shouldStoreMessage:Wg,updateConversationFields:Bg});const{isPlainObject:Hg}=ns.utils;function Kg(e,t={}){const{onlineUserOnly:s,messageControlInfo:n}=t;let{offlinePushInfo:o}=t;e.conversationType===gg.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&&Hg(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 Yg(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 zg(e,t){return pe(this,void 0,void 0,function*(){const s=e.conversationType===gg.CONV_GROUP?function(e,t){var s;const n=Kg(e,t),{onlineUserOnly:i,cloudCustomData:r,messageControlInfo:a,offlinePushInfo:c}=n,u=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return o(e._receiverList)&&e._receiverList.length>0&&(l=e._receiverList,e._receiverList.length>50&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit"))),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null===(s=ns.store.get("login"))||void 0===s?void 0:s.userId,GroupId:e.to,MsgBody:u,CloudCustomData:r,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:i?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:kg(c),SendMsgControl:i?void 0:a,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:Yg(t)}}}(e,t):function(e,t){var s;const n=Kg(e,t),{onlineUserOnly:o,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:a}=n,c=!0===o?0:void 0,u=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null===(s=ns.store.get("login"))||void 0===s?void 0:s.userId,To_Account:e.to,MsgBody:u,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:kg(a),ForbidCallbackControl:Yg(t)}}}(e,t),n=yield In(s);return n?{time:n.MsgTime,messageDropReason:n.MsgDropReason,sequence:n.MsgSeq}:null})}const{isPlainObject:Zg}=ns.utils,{MSG_AUDIO:Jg,MSG_FILE:Xg,MSG_IMAGE:Qg,MSG_VIDEO:e_,MSG_MERGER:t_}=ws;class s_{init(){ug.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:e=>![Jg,Xg,Qg,e_,t_].includes(e[0].type)})}sendMessage(e,t){return pe(this,void 0,void 0,function*(){const{TOTAL_COUNT:s,SEND_COST:n,SUCCESS_COUNT:o,FAILED_COUNT:i}=Gs;if(!(e instanceof Mg))throw new tn({code:Ds.MSG_INSTANCE_REQUIRED});const r=e.validateBeforeSend();if(!r.isValid){const{code:e,message:t=""}=r.error||{};throw new tn({code:e,message:t})}this._reportMessageSendQuality({name:s,message:e});let a=!1;const{messageDataHandler:c}=ns.message||{};try{const{messageControlInfo:s}=t||{};let i=null;c.addRandomOfSentMessage(e.random);const r=Date.now();if(e.conversationType===gg.CONV_C2C?(a=!0===(null==t?void 0:t.onlineUserOnly),i=yield zg(e,t)):e.conversationType===gg.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(e),i=yield zg(e,t)),i){const{messageDropReason:t,sequence:u,time:l}=i;if(this._updateNickAndAvatarOfSentMessageByMe(e),t&&this._logRateLimitInfo(e,u,t),this._reportMessageSendQuality({name:o,message:e}),this._reportMessageSendQuality({name:n,message:e,startTs:r}),!0===e.isResend){const t=c.findMessage(e.ID);t&&(ns.ssoLog.debug("sendMessage",`sendMessage resend ok. ID:${t.ID}`),c.deleteConversationMessage(t))}return e.status=gs.SUCCESS,e.time=l,e.conversationType===gg.CONV_GROUP&&(e.sequence=u),a?e._onlineOnlyFlag=!0:(c.storeConversationMessage(e),this._applySentMessageControlInfo(e,s),this._emitOnlineMessageSent(e)),{code:0,data:{message:e}}}}catch(u){e.status=gs.FAIL,c.removeRandomOfSentMessage(e.random);let{errorCode:t}=u||{},s=(null==u?void 0:u.errorInfo)||(null==u?void 0:u.message)||"";throw this._hasRiskContent(t)&&(e.hasRiskContent=!0),a||this._isRejectedByRestApi(t)||c.storeConversationMessage(e),this._reportMessageSendQuality({name:i,message:e,error:u}),new tn({code:t,message:s,data:{message:e},moreMessage:`type:${e.type} from:${e.from} to:${e.to}`})}})}_hasRiskContent(e){return 80001===e||80004===e}_isRejectedByRestApi(e){return e>=10100&&e<=10200||e>=120001&&e<=13e4}_emitOnlineMessageSent(e){const t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,o=mn(s)?ls.TOPIC_NEW_MESSAGE:ls.NEW_MESSAGE;ns.notificationCenter.emitInnerEvent(o,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}_applySentMessageControlInfo(e,t){t&&Zg(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0))}_logRateLimitInfo(e,t,s){const n=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:${s}`;ns.ssoLog.warn("messageDropReason",n)}_updateNickAndAvatarOfSentMessageByMe(e){const{messageDataHandler:t}=ns.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})}}_validateBeforeSendGroupMessage(e){return pe(this,void 0,void 0,function*(){var t,s,n;const{to:o,from:i}=e;let r=o,a=ig.getGroup(r);if(_n({groupID:r})&&(null==a?void 0:a.isSupportTopic))throw new tn({code:Ds.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(mn(o)&&([r]=o.split(As.TOPIC),a=ig.getGroup(r)),!a&&"function"==typeof(null===(t=ug.getInstance().getApiMap())||void 0===t?void 0:t.getGroupProfile)){const e=yield ug.getInstance().getApiMap().getGroupProfile({groupID:r});if((null===(n=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.group)||void 0===n?void 0:n.type)===ws.GRP_AVCHATROOM){const e=en({code:Ds.MSG_SEND_FAIL_NOT_IN_AV,replacement1:i,replacement2:r});throw new tn({code:Ds.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}_reportMessageSendQuality(e){ns.notificationCenter.emitInnerEvent(ls.QUALITY_STAT,{label:ks.MESSAGE_SEND_SUCCESS_RATE,data:e})}}var n_=new class{constructor(){this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Set}init(){ns.notificationCenter.subscribeInnerEvent(ls.LOGOUT,this._reset,this),ns.notificationCenter.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}get _messagesByConversation(){return rg.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=Ee(i);return(null===(s=this._messagesByConversation.get(e))||void 0===s?void 0:s.has(t))?rg.updateMessage(e,[t],{isModified:!0,version:n,_elements:a,payload:a[0].content,type:a[0].type,cloudCustomData:r,hasRiskContent:c,operation:_s.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 rg.updateMessage(e,[t],{isRevoked:!0,revoker:n,operation:_s.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:t,sequence:s,random:n}){for(let o=0;o<t.length;o+=1){const i=t[o];if(i.sequence===s&&(e(n)||i.random===n))return i}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 r of t){const e=this._getUniqueIdOfMessage(r);i.has(e)||(n.push(r),o.push([e,r]))}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 o=0;o<s;o++){const t=e[o];n.has(t.ID)||n.set(t.ID,t)}}_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 n=s.length-1;n>=0;n--)if("out"===s[n].flow){this._setLatestMsgSentByMe(e,s[n]);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 n=s.length-1;n>=0;n--)if("in"===s[n].flow){this._setLatestMsgSentByPeer(e,s[n]);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.add(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(),ns.notificationCenter.unSubscribeInnerEvent(ls.LOGOUT,this._reset,this),ns.notificationCenter.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this)}};function o_(e,t){const s=og.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:u,elements:l,cloudCustomData:d}=t;o===a&&i===c&&r!==u&&(n.type=l[0].type,n.payload=l[0].content,n.messageForShow=bn(n.type,n.payload),n.cloudCustomData=d,n.version=u,og.updateConversation(e,{lastMessage:n}))}}class i_{init(){ug.getInstance().registerApi({apiName:"modifyMessage",context:this})}modifyMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,payload:s,sequence:n,conversationType:o,random:i,time:r,from:a,type:c}=e;if(this._canModifyMessageElement(c)){const t=e.getElements();t.length>1&&(t[0].type=c,t[0].content=s)}try{let s=null,c=null;if(o===gg.CONV_C2C?s=yield function(e){return pe(this,void 0,void 0,function*(){const{from:t,to:s,version:n=0,sequence:o,random:i,time:r,type:a,cloudCustomData:c}=e,u={From_Account:t,To_Account:s,MsgVersion:n,MsgSeq:o,MsgRandom:i,MsgTime:r,MsgType:a,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:c},l=yield In({servcmd:"openim.modify_c2c_msg",data:u});if(l){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=l;return{elements:$g(e),messageVersion:t,cloudCustomData:s}}})}(e):o===gg.CONV_GROUP&&(s=yield function(e){return pe(this,void 0,void 0,function*(){const{to:t,version:s=0,sequence:n,cloudCustomData:o}=e,i={GroupId:t,MsgVersion:s,MsgSeq:n,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:o},r=yield In({servcmd:"openim.modify_group_msg",data:i});if(r){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=r;return{elements:$g(e),messageVersion:t,cloudCustomData:s}}})}(e)),s){let u=`${o}${t}`;return t===Cn()&&o===gg.CONV_C2C&&(u=`${o}${a}`),c={conversationType:o,from:a,to:t,time:r,random:i,sequence:n,elements:null==s?void 0:s.elements,cloudCustomData:null==s?void 0:s.cloudCustomData,messageVersion:null==s?void 0:s.messageVersion,conversationID:u},this._handleModifyMessageSuccess(c),{code:0,data:{message:e},successLog:{message:`to:${t}`}}}}catch(u){const{errorCode:e}=u||{};throw new tn({functionName:"modifyMessage",code:e})}})}_handleModifyMessageSuccess(e){const{conversationID:t}=e,{isUpdated:s,message:n}=ns.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&ns.notificationCenter.emitOuterEvent(cs.MESSAGE_MODIFIED,{name:cs.MESSAGE_MODIFIED,data:[n]}),ns.notificationCenter.emitInnerEvent(ls.MESSAGE_MODIFIED,{conversationID:t,message:n}),o_(t,e)}_canModifyMessageElement(e){return[mg.MSG_TEXT,mg.MSG_CUSTOM,mg.MSG_LOCATION,mg.MSG_FACE].includes(e)}}class r_{init(){const{notificationCenter:e}=ns,{InnerEventSubType:t}=e;pn.getInstance().registerWorkflowStep(Ls.RECEIVE_C2C_NEW_MESSAGE,Ns.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),pn.getInstance().registerWorkflowStep(Ls.RECEIVE_C2C_NEW_MESSAGE,Ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),pn.getInstance().registerWorkflowStep(Ls.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){pn.getInstance().executeWorkflow(Ls.RECEIVE_C2C_NEW_MESSAGE,e)}_handleC2CMessagePush(e){const t=e.data||{},{messageDataHandler:s}=ns.message||{},n=[],o=new Map;return t.C2cMsgArray.forEach(e=>{const t=this._generateC2CMessage(e);this._updateMessageProfile(t);let i=1===t.isModified;s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t.isOnlineMessage()?(t._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(t)||n.push(t)):Wg(t)&&(s.storeConversationMessage(t)&&Bg({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&&ns.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&&ns.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:s})}_generateC2CMessage(e){const t=gg.CONV_C2C,s=Gg(e),n=ns.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:Eg.IN})),{elements:o}=s;return n.setElement(o),n}_updateMessageProfile(t){var n;const{messageDataHandler:o}=ns.message||{},i=null===(n=ns.store.get("login"))||void 0===n?void 0:n.userId,{from:r,nick:a,avatar:c,conversationID:u=""}=t;if(r!==i){const n=o.getLatestMsgSentByPeer(u);if(n){const{nick:i,avatar:r}=n;e(a)||e(c)?(t.nick=s(i)?i:t.nick,t.avatar=s(r)?r:t.avatar):a===i&&c===r||(o.updateNickAndAvatarOfSentMessage({conversationID:u,latestNick:a,latestAvatar:c,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:u,nick:a,avatar:c}))}}else{const e=o.getLatestMsgSentByMe(u);!e||a===e.nick&&c===e.avatar||o.updateNickAndAvatarOfSentMessage({conversationID:u,latestNick:a,latestAvatar:c,isSentByMe:!0})}}_updateConversationUserProfile(e){const{conversationID:t,nick:s,avatar:n}=e,o=og.getConversation(t),{userProfile:i={}}=o||{};i.avatar===n&&i.nick===s||og.updateConversation(t,{userProfile:Object.assign(Object.assign({},i),{nick:s,avatar:n})})}_updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=ns.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&ns.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),ns.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),o_(t,e)}_handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t;const s=gg.CONV_C2C;let n=Ug(e);const{to:o,from:i}=n;let r=`${s}${o}`;o===(null===(t=ns.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}=ns,{InnerEventSubType:t}=e;ns.notificationCenter.unSubscribeInnerEvent(ls.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),ns.notificationCenter.unSubscribeInnerEvent(ls.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),ns.notificationCenter.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this)}}class a_{init(){const{notificationCenter:e}=ns,{InnerEventSubType:t}=e;pn.getInstance().registerWorkflowStep(Ls.RECEIVE_GROUP_NEW_MESSAGE,Ns.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),pn.getInstance().registerWorkflowStep(Ls.RECEIVE_GROUP_NEW_MESSAGE,Ns.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}_executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&pn.getInstance().executeWorkflow(Ls.RECEIVE_GROUP_NEW_MESSAGE,e)}_handleGroupMessagePush(e){const t=e.data||{},{messageDataHandler:s}=ns.message,n=[],o=new Map,i=null==t?void 0:t.GroupMsgArray;return null==i||i.forEach(e=>{if(1===e.GroupInfo.NotVisible)return;const t=this._generateGroupMessage(e);this.updateMessageProfile(t);let i=1===t.isModified;s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t.isOnlineMessage()?(t._onlineOnlyFlag=!0,s.isMessageSentByCurrentInstance(t)||n.push(t)):Wg(t)&&s.storeConversationMessage(t)&&(n.push(t),Bg({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&&ns.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&&ns.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:o})}_generateGroupMessage(e){const t=gg.CONV_GROUP,s=Fg(e),n=ns.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:Eg.IN})),{elements:o}=s;return n.setElement(o),n}updateMessageProfile(e){var t;const{messageDataHandler:s}=ns.message||{},n=null===(t=ns.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:a="",_elements:c}=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})}else if(o===ws.CONV_SYSTEM){const{operationType:t,memberInfoList:s,operatorInfo:n}=c;let o={};if(Ie(s)?Ie(n)||(o=n):[bs.JOINED,bs.KICKED,bs.ADMIN_SET,bs.ADMIN_CANCELED].includes(t)&&(o=Object.assign({},s[0])),!Ie(o)){const{nick:t="",avatar:s=""}=o;e.nick=t,e.avatar=s}}}_updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=ns.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&ns.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),o_(t,e)}_handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{const t=gg.CONV_GROUP;let s=qg(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}=ns,{InnerEventSubType:{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}}=e;e.unSubscribeInnerEvent(ls.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(ls.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this)}_canExecuteReceiverNewMessageWorkFlow(e){var t,s;const{GroupId:n,GroupType:o}=(null===(s=null===(t=null==e?void 0:e.GroupMsgArray)||void 0===t?void 0:t[0])||void 0===s?void 0:s.GroupInfo)||{},i=o===Ms.GRP_AVCHATROOM;return!(!ig.getGroup(n)&&i)}}var c_=new class{constructor(){this.c2cMessageReceiver=new r_,this.groupMessageReceiver=new a_}init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}};const u_={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==(t=e)?void 0:t.text)&&("string"!=typeof t.text||0!==(null===(s=null==t?void 0:t.text)||void 0===s?void 0:s.length))||"payload.text must be a string";var t,s}}}},l_={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var d_=new class{getGroupRoamingMessagesByAnchor(e){return pe(this,void 0,void 0,function*(){try{const{conversationID:t,count:s,direction:n,sequence:i,messageSequenceList:r,getType:a}=e,c=t.replace(Ss.CONV_GROUP,""),u=[];let l=i;if(n===ms.BACKWARD){if("number"!=typeof i)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};l=i+s-1}const d=yield function(e){return pe(this,void 0,void 0,function*(){const{groupID:t,count:s,messageSequence:n,messageSequenceList:i,getType:r}=e,a={GroupId:t,ReqMsgNumber:s,WithRecalledMsg:1,Version:1,GetType:r};return n&&(a.ReqMsgSeq=n),o(i)&&i.length>0&&(a.ReqMsgSeqList=i),yield In({servcmd:"group_open_http_svc.group_msg_get",data:a})})}({groupID:c,count:s,messageSequence:l,messageSequenceList:r,getType:a});if(d){const{RspMsgList:e=[],NextReqMsgSeq:t=0,IsFinished:s,InvisibleMsgSeq:o}=d,r=`groupID:${c} sequence:${i} reqSeq:${l} direction:${n} complete:${s} nextSequence:${t} remoteMsgCount:${e.length} invisibleSequenceList:${o}`,a=[];for(let n=0;n<e.length;n++){const t=e[n];t.From_Account===ws.CONV_SYSTEM&&u.push(t);const s=this._parseMessage(t);a.push(s)}a.reverse();let h=s===Sg;n===ms.BACKWARD&&(h=a[a.length-1].sequence>=i);const p=Vg(a);return ns.ssoLog.info("getGroupRoamingMessagesByAnchor",r),{messageList:p,invisibleSequenceList:o,nextReqMessageIDFromServer:t,hasNoMoreHistoryMessage:h,serverGroupTipList:u}}}catch(t){const{errorCode:e,errorInfo:s}=t||{};throw new tn({code:e,message:s})}})}_parseMessage(e){const t=Ss.CONV_GROUP;4===e.Event&&(e.MsgBody.MsgType=ws.MSG_GRP_TIP);const s=Fg(e),n=Tg.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:"in"}));return n.setElement(s.elements),n}};class h_{constructor(){this.messageHelper=jg,this.messageFactory=Tg,this.messageSender=new s_,this.messageAction=new i_,this.messageReceiver=c_,this.messageDataHandler=n_,this.messageHistory=d_,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),this.messageDataHandler.init(),dn({auth:l_,params:u_})}}const p_="Tag_Profile_IM_",g_={NICK:`${p_}Nick`,GENDER:`${p_}Gender`,BIRTHDAY:`${p_}BirthDay`,LOCATION:`${p_}Location`,SELFSIGNATURE:`${p_}SelfSignature`,ALLOWTYPE:`${p_}AllowType`,LANGUAGE:`${p_}Language`,AVATAR:`${p_}Image`,MESSAGESETTINGS:`${p_}MsgSettings`,ADMINFORBIDTYPE:`${p_}AdminForbidType`,LEVEL:`${p_}Level`,ROLE:`${p_}Role`},__="Tag_Profile_Custom",m_="profileCustomField",f_="USER_STATUS",v_=1,I_=1e3,E_={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:[]},S_=new Map([[g_.NICK,"nick"],[g_.GENDER,"gender"],[g_.BIRTHDAY,"birthday"],[g_.LOCATION,"location"],[g_.SELFSIGNATURE,"selfSignature"],[g_.ALLOWTYPE,"allowType"],[g_.LANGUAGE,"language"],[g_.AVATAR,"avatar"],[g_.MESSAGESETTINGS,"messageSettings"],[g_.ADMINFORBIDTYPE,"adminForbidType"],[g_.LEVEL,"level"],[g_.ROLE,"role"]]);var y_=new class{createProfile(e,t){const s={userID:e,profileCustomField:[]};return t.forEach(e=>{const{tag:t,value:n}=e;t&&t.indexOf(__)>-1?s.profileCustomField.push({key:t,value:n}):S_.has(t)&&(s[S_.get(t)]=n)}),Object.assign(Object.assign({},E_),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=>{s!==m_&&t.push({tag:g_[s.toUpperCase()],value:e[s]})}),e.profileCustomField&&o(e.profileCustomField)&&e.profileCustomField.forEach(e=>{t.push({tag:e.key,value:e.value})}),t}normalizeProfileFields(e){const t={},s=[];return e.forEach(e=>{const{tag:n,value:o}=e;if(n&&n.indexOf(__)>-1&&s.push({key:n,value:o}),S_.has(n)&&void 0!==o){const e=S_.get(n);t[e]=o}}),s.length>0&&(t.profileCustomField=s),t}};const{generateProtocolData:C_}=ns.common;function M_(e){return pe(this,void 0,void 0,function*(){const t="profile.portrait_get_all",s={From_Account:Cn(),UserItem:[]};e.forEach(e=>{s.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});const n=C_({servcmd:t,data:s}),o=`${n.head.seq}${t}`,i=yield ns.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=y_.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 A_(e){return ag.getFriendMap().has(e)}const{isEmpty:b_}=ns.utils;class T_{constructor(){this._strangerProfileMap=new Map}init(){ug.getInstance().registerApi({apiName:"getMyProfile",context:this}),ug.getInstance().registerApi({apiName:"getUserProfile",context:this}),ug.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=y_.createProfile.bind(y_);const{notificationCenter:e}=ns;pn.getInstance().registerWorkflowStep(Ls.SYNC_SERVER_INFO_AFTER_LOGIN,Ns.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(ls.LOGOUT,this._reset,this),e.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}getMyProfile(){return pe(this,void 0,void 0,function*(){try{const e=Cn(),t=yield M_([e]);if(t){const s=this._handleProfileFormResponse(t)[0];return ag.getUserProfileMap().set(e,s),{code:0,data:s}}}catch(_){const{errorCode:t,errorInfo:s}=_;throw new tn({functionName:"getMyProfile",code:t,message:s})}})}getUserProfile(e){return pe(this,void 0,void 0,function*(){try{let{userIDList:t}=e;const{userIdListToRequest:s,profileFromCache:n}=this._filterRequestAndCacheUsers(t);if(0===s.length)return{code:0,data:n,successLog:{message:`userIDList.length:${t.length}`}};s.length>I_&&(ns.ssoLog.warn("getUserProfile","userIdListToRequest.length > 1000"),s.length=I_);const{data:i,error:r}=yield this._batchFetchUserProfiles(s),a=s.length,c=i.length,u=a-c;if(0===n.length&&a===u&&!b_(r))throw r;if(o(i))return i.forEach(e=>{A_(e.userID)?ag.getUserProfileMap().set(e.userID,e):this._strangerProfileMap.set(e.userID,e)}),{code:0,data:i.concat(n),successLog:{message:`getUserProfile query:${a} success:${c} fail:${u} from cache:${n.length}`}}}catch(t){const{errorCode:e}=t;throw new tn({functionName:"getUserProfile",code:e})}})}getMyProfileCacheThenServer(){return pe(this,void 0,void 0,function*(){const e=Cn(),t=ag.getUserProfileMap().has(e);return t?{code:0,data:t}:this.getMyProfile()})}updateMyProfile(e){return pe(this,void 0,void 0,function*(){const t=Cn(),s={};for(const i in e)void 0!==e[i]&&(s[i]=e[i]);const n=y_.convertParamsToProfile(s);try{const e={From_Account:t,ProfileItem:n};yield function(e){return pe(this,void 0,void 0,function*(){const t="profile.portrait_set",s=C_({servcmd:t,data:e}),n=`${s.head.seq}${t}`,o=yield ns.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 o=ag.getUserProfile(t);let i;i=o?Object.assign(Object.assign({},o),s):y_.createProfile(t,n);const r=!is(o,i,["lastUpdatedTime"]);return i.lastUpdatedTime=Date.now(),ag.getUserProfileMap().set(t,i),r&&this._emitProfileUpdated(i),{code:0,data:i,successLog:{message:`profileArray: ${ns.utils.safeStringify(n)}`}}}catch(o){const{errorCode:e,errorInfo:t}=o;throw new tn({functionName:"updateMyProfile",code:e,message:t})}})}updateMyNickAndAvatar(e){return pe(this,void 0,void 0,function*(){const t=Cn(),s=Date.now(),n=ag.getUserProfile(t);let o={};o=n?Object.assign(n,e):y_.createProfile(t,e),o.lastUpdatedTime=s,ag.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:y_.parseProfileList(n)}}(e.ProfileDataMod[0]);if(b_(t))return;const{isProfileUpdated:s,profile:n}=this._handleProfileModified(t);s&&this._emitProfileUpdated(n)}_emitProfileUpdated(e){ns.notificationCenter.emitInnerEvent(ls.PROFILE_UPDATE,{name:ls.PROFILE_UPDATE,data:[e]}),ns.notificationCenter.emitOuterEvent(cs.PROFILE_UPDATED,{name:cs.PROFILE_UPDATED,data:[e]}),og.updateConversation(`C2C${null==e?void 0:e.userID}`,{userProfile:e})}_dispose(){const{notificationCenter:e}=ns;e.unSubscribeInnerEvent(ls.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(ls.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this),this._reset()}_handleProfileModified(e){const{userId:t,profileList:s}=e,n=ag.getUserProfile(t);if(!(Cn()===t||A_(t)&&n))return{isProfileUpdated:!1,profile:null};const o=y_.normalizeProfileFields(s),i=Object.keys(o).some(e=>e===m_?!is(n.profileCustomField,o.profileCustomField):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 ag.getUserProfileMap().set(t,a),{isProfileUpdated:i,profile:a}}_filterRequestAndCacheUsers(e){const t=[],s=[];return e.forEach(e=>{const n=ag.getUserProfileMap().has(e);A_(e)&&n?s.push(ag.getUserProfile(e)):this._isStrangerAndProfileValid(e)?s.push(this._strangerProfileMap.get(e)):t.push(e)}),{userIdListToRequest:t,profileFromCache:s}}_handleProfileFormResponse(e){const{userProfile:t}=e;if(!Array.isArray(t))return[];const s=t.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!b_(e.profileItem)),n=Date.now();return s.map(e=>{const t=y_.createProfile(e.userId,e.profileItem);return t.lastUpdatedTime=n,t})}_isStrangerAndProfileValid(e){var t;if(!A_(e)){const{lastUpdatedTime:s=0}=this._strangerProfileMap.get(e)||{},n=(null===(t=ns.store.get("cloudConfig"))||void 0===t?void 0:t.stranger_profile_expiration_time)||6e5;return Date.now()-s<=n}return!1}_chunkUserIDList(e,t){return Array.from({length:Math.ceil(e.length/t)},(s,n)=>e.slice(n*t,(n+1)*t))}_batchFetchUserProfiles(e){return pe(this,void 0,void 0,function*(){const t=[],s=[];let n={};return this._chunkUserIDList(e,100).forEach(e=>{t.push(M_(e))}),(yield Promise.allSettled(t)).forEach(e=>{if("fulfilled"===e.status){const t=e.value,n=this._handleProfileFormResponse(t);o(n)&&s.push(...n)}else if("rejected"===e.status){const{code:t,message:s}=e.reason||{};n={errorCode:t,message:s}}}),{data:s,error:n}})}_reset(){ag.getUserProfileMap().clear(),this._strangerProfileMap.clear()}}const O_=new Map,w_=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let t=0,tt=w_.length;t<tt;t++)O_.set(t,w_[t]);function D_(e){if(!e)return"";const t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let o,i,r=0,a=0;i=t.charAt(a++);~i&&(o=r%4?64*o+i:i,r++%4)?s+=String.fromCharCode(255&o>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);try{return decodeURIComponent(escape(s))}catch(n){return console.warn(n),""}}const{isEmpty:R_}=ns.utils,{generateProtocolData:L_}=ns.common;function N_(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.ws_get_user_status",s=L_({servcmd:t,data:{To_Account:e}}),n=`${s.head.seq}${t}`,o=yield ns.channel.sendPacket(s,{requestId:n});if(o)return function(e){const{ErrorCode:t,ErrorInfo:s,ErrorList:n=[],UserStatusList:o=[]}=e;return{errorCode:t,errorInfo:s,successUserList:o.map(e=>{const{To_Account:t,Status:s,CustomStatus:n}=e;return{userID:t,statusType:s,customStatus:D_(n)}}),failureUserList:n.map(e=>{const{To_Account:t,Invalid_Account:s,ErrorCode:n,ErrorInfo:o}=e;return{userID:R_(s)?t:s,code:n,message:o}})}}(o)})}class P_{constructor(){this._customStatus=""}init(){const{notificationCenter:e}=ns;ug.getInstance().registerApi({apiName:"getUserStatus",context:this}),ug.getInstance().registerApi({apiName:"setSelfStatus",context:this}),ug.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),ug.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),pn.getInstance().registerWorkflowStep(Ls.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(ls.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(ls.LOGOUT,this._reset,this),e.subscribeInnerEvent(ls.DESTROY,this._dispose,this)}setSelfStatus(e){return pe(this,void 0,void 0,function*(){const t=Cn(),{customStatus:s}=e;try{return yield function(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.ws_set_custom_status",s=L_({servcmd:t,data:{CustomStatus:e}}),n=`${s.head.seq}${t}`,o=yield ns.channel.sendPacket(s,{requestId:n});if(o){const{ErrorCode:e,ErrorInfo:t}=o;return{errorCode:e,errorInfo:t}}})}(s),this._customStatus=s,{code:0,data:{userID:t,statusType:v_,customStatus:s},successLog:{message:`customStatus: ${s}`}}}catch(n){const{errorCode:e,errorInfo:t}=n;throw new tn({functionName:"setSelfStatus",code:e,message:t})}})}getUserStatus(e){return pe(this,void 0,void 0,function*(){const{userIDList:t=[]}=e;let s={};return this._isOnlyMeInArray(t)&&(s=this._getMyStatus()),s=yield this._getUserStatus(t),Object.assign(Object.assign({},s),{successLog:{message:`userIDList length: ${t.length}`}})})}setCustomStatus(e){const t=D_(e);this._customStatus=t}subscribeUserStatus(e){return pe(this,void 0,void 0,function*(){try{const{userIDList:t=[]}=e;this._checkBusinessCapabilityBits("subscribeUserStatus");const s=this._getMaxUserCount("subscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return pe(this,void 0,void 0,function*(){const{channel:t}=ns,s="im_open_status.ws_status_subscribe",n=L_({servcmd:s,data:{To_Account:e}}),o=`${n.head.seq}${s}`;return yield t.sendPacket(n,{requestId:o})})}(n),i=this._parseResponse(o);return{code:0,data:{failureUserList:i},successLog:{message:`userID length:${t.length} failCount: ${i.length}`}}}catch(t){const{errorCode:e}=t;throw new tn({functionName:"subscribeUserStatus",code:e})}})}unsubscribeUserStatus(e){return pe(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("unsubscribeUserStatus");const{userIDList:t=[]}=e,s=this._getMaxUserCount("unsubscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return pe(this,void 0,void 0,function*(){const{channel:t}=ns,s="im_open_status.ws_status_unsubscribe";let n={};n=0===e.length?{UnsubscribeAll:1}:{To_Account:e};const o=L_({servcmd:s,data:n}),i=`${o.head.seq}${s}`;return yield t.sendPacket(o,{requestId:i})})}(n),i=this._parseResponse(o);return{code:0,data:{failureUserList:i},successLog:{message:`userID length:${t.length} failCount: ${i.length}`}}}catch(t){const{errorCode:e}=t;throw new tn({functionName:"unsubscribeUserStatus",code: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:D_(n)}});this._emitUserStatusUpdatedEvent(s)}_onReOnline(e){const t=D_(e.data.customStatus);if(this._customStatus===t)return;this._customStatus=t;const s={userID:Cn(),statusType:v_,customStatus:t};this._emitUserStatusUpdatedEvent(s)}_emitUserStatusUpdatedEvent(e){ns.notificationCenter.emitOuterEvent(cs.USER_STATUS_UPDATED,{name:cs.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:ns.utils.isEmpty(s)?t:s,code:n,message:o}})}_checkBusinessCapabilityBits(e){if(!ns.store.get("commercialConfig").get(f_))throw new tn({functionName:e,code:Ds.NO_USE,replacement1:e})}_getMaxUserCount(e){const t=ns.store.get("cloudConfig")||{},s={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:100},unsubscribe:{key:"status_unsub_count",default:100}},{key:n,default:o}=s[e],i=t[n]||o;return parseInt(i,10)}_getMyStatus(){return{code:0,data:{successUserList:[{userID:Cn(),statusType:v_,customStatus:this._customStatus}],failureUserList:[]}}}_getUserStatus(e){return pe(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("getUserStatus");const t=this._getMaxUserCount("query"),s=this._sliceUserIDList(e,t),n=yield N_(s),{successUserList:o,failureUserList:i}=n||{};return{code:0,data:{successUserList:o,failureUserList:i}}}catch(t){const{errorCode:e}=t;throw new tn({functionName:"getUserStatus",code:e})}})}_isOnlyMeInArray(e){const t=Cn();return 1===e.length&&e.indexOf(t)>-1}_dispose(){const{notificationCenter:e}=ns;e.unSubscribeInnerEvent(ls.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(ls.LOGOUT,this._reset,this),this._reset()}_reset(){this._customStatus=""}}const k_={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,customValidator:function(e){for(const t of e){if("object"!=typeof t)return"Each item in profileCustomField must be an object";if("string"!=typeof(null==t?void 0:t.key))return"Each item.key in profileCustomField must be a string";if(!(null==t?void 0:t.key.startsWith(__)))return'Each item.key in profileCustomField must start with "Tag_Profile_Custom"'}return!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}}},G_={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};class U_{constructor(){this.userProfile=new T_,this.userStatus=new P_,this.userProfile.init(),this.userStatus.init(),dn({auth:G_,params:k_})}}function F_(e){const t=[];if(!s(e))return t;const n=e.length;if(0===n)return t;for(let s=n-1;s>=0;s--)"1"===e[s]&&t.push(2**(n-s-1));return t}var x_,$_,q_;!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(x_||(x_={})),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}($_||($_={})),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(q_||(q_={}));class B_{constructor(){this._name="SyncConversationHandler",this._pagingStatus=x_.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}init(){const{notificationCenter:e}=ns;pn.getInstance().registerWorkflowStep(Ls.SYNC_SERVER_INFO_AFTER_RE_ONLINE,Ns.CONVERSATION_RECOVER,this._syncConversationList,this),pn.getInstance().registerWorkflowStep(Ls.SYNC_SERVER_INFO_AFTER_LOGIN,Ns.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),e.subscribeInnerEvent(ls.LOGOUT,this._reset,this),e.subscribeInnerEvent(ls.DESTROY,this._dispose,this),ns.ssoLog.debug(`${this._name}.init`)}isSyncCompleted(){return this._pagingStatus===x_.RESOLVED}_syncConversationListAfterLogin(){return pe(this,void 0,void 0,function*(){return this._pagingStatus=x_.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}_syncConversationList(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=ns;e.debug("_syncConversationList","start");try{const t=yield this._pagingGetConversationList(!0);this._pagingStatus=x_.RESOLVED;const{conversationList:s=[]}=t||{};return e.info("_syncConversationList",`success count:${s.length}`),t}catch(s){const{errorCode:n,errorInfo:o}=s,i=new tn({code:n,message:o});e.error("_syncConversationList",`fail ${t(s)}`,{error:i})}})}_pagingGetConversationList(e){return pe(this,void 0,void 0,function*(){try{const t=[];this._pagingStatus=x_.PENDING;const s=yield function(e){return pe(this,void 0,void 0,function*(){const{fromAccount:t,pagingTimeStamp:s,pagingStartIndex:n,pagingPinnedTimeStamp:o,pagingPinnedStartIndex:i}=e;return In({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:t,StartIndex:n,TimeStamp:s,TopStartIndex:i,TopTimeStamp:o}})})}({fromAccount:Cn(),pagingTimeStamp:e?this._pagingTimeStamp:0,pagingStartIndex:e?this._pagingStartIndex:0,pagingPinnedTimeStamp:e?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:e?this._pagingPinnedStartIndex:0}),{CompleteFlag:n,SessionItem:o=[],TimeStamp:i,StartIndex:r,TopTimeStamp:a,TopStartIndex:c}=s||{};if(o.length>0){const e=this._getConversationOptions(o);t.push(...e);const{notificationCenter:s}=ns;s.emitInnerEvent(ls.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:e})}if(this._pagingTimeStamp=i,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=c,1!==n){const{conversationList:s}=yield this._pagingGetConversationList(e);t.push(...s)}return{conversationList:t}}catch(t){throw t}})}_getConversationOptions(e){const{utils:{isUndefined:t}}=ns,s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===$_.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}_filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===$_.C2C&&!function(e){let t;return e.startsWith(ws.CONV_C2C)&&(t=e.replace(ws.CONV_C2C,"")),"@TLS#ERROR"===t||"@TLS#NOT_FOUND"===t}(t)||2===e)}_assembleC2COption(e){var t,s,n,o,i,r;const a=this._createUserprofile(e);return{conversationID:`${ws.CONV_C2C}${e.userID}`,type:ws.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:(null===(t=e.lastMsg)||void 0===t?void 0:t.elements[0])?null===(s=e.lastMsg)||void 0===s?void 0:s.elements[0].type:null,payload:(null===(n=e.lastMsg)||void 0===n?void 0:n.elements[0])?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null===(o=e.lastMsg)||void 0===o?void 0:o.cloudCustomData)||"",isRevoked:e.lastMessageFlag===q_.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null===(r=null===(i=e.lastMsg)||void 0===i?void 0:i.revokerInfo)||void 0===r?void 0:r.revoker)||null},unreadCount:0,userProfile:a,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:F_(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}_createUserprofile(e){var t;const{userID:s,nick:n,peerAvatar:o}=e,i=[{tag:"Tag_Profile_IM_Nick",value:n},{tag:"Tag_Profile_IM_Image",value:o}];return null===(t=ns.user.userProfile)||void 0===t?void 0:t.createProfile(s,i)}_computeIsPeerRead(e){const t=Cn(),{lastC2CMsgFromAccount:s,time:n,c2cPeerReadTime:o}=e;return s===t&&n<=o}_assembleGroupOption(e){var t,s,n;return{conversationID:`${ws.CONV_GROUP}${e.groupID}`,type:ws.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?void 0:t.cloudCustomData)||"",isRevoked:e.lastMessageFlag===q_.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null===(n=null===(s=e.lastMsg)||void 0===s?void 0:s.revokerInfo)||void 0===n?void 0:n.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:F_(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.C2cPeerReadTime,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,s,n;const{utils:{isEmpty:o}}=ns;if(o(e))return null;let i="",r=null;if(!o(e.GroupTips)){const{From_Account:s,GroupName:n}=(null===(t=e.GroupTips)||void 0===t?void 0:t.GroupInfo)||{};i=ws.MSG_GRP_TIP,r=Object.assign(Object.assign({},this._parseContent(i,e.GroupTips.MsgBody)),{groupProfile:{from:s,groupName:n}})}return e.MsgBody&&(i=null===(s=e.MsgBody[0])||void 0===s?void 0:s.MsgType,r=this._parseContent(i,e.MsgBody[0])),{event:e.Event,elements:[{type:i,content:r,cloudCustomData:e.CloudCustomData}],revokerInfo:{revoker:null===(n=e.RevokerInfo)||void 0===n?void 0:n.Revoker_Account}}}_parseContent(e,t){var s;if(!t)return t;const n=ns.message.messageFactory.getElementClass(e);return n?null===(s=n.parseServerPushElement(t))||void 0===s?void 0:s.content:t}_amendLayersOverLimitProp(e){const{LayersOverLimit:t}=e;return he(e,["LayersOverLimit"]).layersOverLimit=1===t,e}_transMsgRemindType(e){let t="";return 0===e?t=ws.MSG_REMIND_ACPT_AND_NOTE:1===e?t=ws.MSG_REMIND_DISCARD:2===e?t=ws.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=ws.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_patchTypeAndPayload(e){var t;const{utils:{isUndefined:s}}=ns,{event:n,elements:o=[]}=e.lastMsg||{};return s(n)?{type:o[0]?o[0].type:null,payload:o[0]?this._amendLayersOverLimitProp(o[0].content):null}:{type:ws.MSG_GRP_TIP,payload:(null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.content)||{}}}_computeGroupUnreadCount(e){const{unreadCount:t=0,noUnreadCount:s=0}=e,n=t-s;return n>0?n:0}_reset(){this._pagingStatus=x_.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}_dispose(){this._reset();const{notificationCenter:e}=ns;e.unSubscribeInnerEvent(ls.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(ls.DESTROY,this._dispose,this)}}class V_{constructor(){this.syncConversationHandler=new B_,this.syncConversationHandler.init()}}return ns.ssoLog.debug(`TencentCloudLiteChat.VERSION:${at}`),{create:function(e){var t,s;const{SDKAppID:n,testEnv:o=!1,devMode:i=!1,unlimitedAVChatRoom:r=!1,scene:a="",oversea:c=!1,instance:u,disableIndependentDomain:l=!1}=e;let d=n;if(!function(e){if("number"==typeof e)return!0;const t=Number(e);return!Number.isNaN(t)}(d))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(d=Number(d),gn.has(d))return gn.get(d);let h=null;if(u)h=u,h._workflowManager&&pn.setInstance(h._workflowManager),h._pluginManager&&h._pluginManager.installBuiltInPlugin(tg),u.isReady()&&(null===(s=(t=pn.getInstance()).executeWorkflow)||void 0===s||s.call(t,Ls.SYNC_SERVER_INFO_AFTER_LOGIN));else{const e=function(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}();ns.init({sdkAppId:d,instanceId:e,testEnv:o,devMode:i,unlimitedAVChatRoom:r,disableIndependentDomain:l,scene:a,oversea:c,sdkEdition:eg,version:at}),pn.getInstance().init(),ns.message=new h_,ns.user=new U_,ns.login=new pg,ns.conversation=new V_,ng.getInstance().installBuiltInPlugin(tg),h=ug.getInstance().exposeApiForClient(),h._workflowManager=pn.getInstance(),h._pluginManager=ng.getInstance()}return gn.set(d,h),h},TSignaling:ds,EVENT:cs,VERSION:at,TYPES:ws}}();const o=s(n.exports),i="1.0.1";var r=(e=>(e.MESSAGE_RECEIVED="message_received",e.MESSAGE_REVOKED="message_revoked",e.NOTIFICATION_CLICKED="notification_clicked",e))(r||{});const a="[WebPush]";class c{constructor(){}static getInstance(){return c.instance||(c.instance=new c),c.instance}log(e,...t){console.log(`${a} ${e}`,...t)}warn(e,...t){console.warn(`${a} ${e}`,...t)}error(e,...t){console.error(`${a} ${e}`,...t)}info(e,...t){console.info(`${a} ${e}`,...t)}}const u=c.getInstance();class l{constructor(){this.events=new Map}on(e,t){this.events.has(e)||this.events.set(e,new Map);const s=Math.random().toString(36).substr(2,9);return this.events.get(e).set(s,t),s}off(e,t){const s=this.events.get(e);if(!s)return!1;for(const[n,o]of s.entries())if(o===t)return s.delete(n),!0;return!1}emit(e,...t){const s=this.events.get(e);s&&s.forEach(s=>{try{s(...t)}catch(n){u.error(`Event listener error for ${e}:`,n)}})}removeAllListeners(e){e?this.events.delete(e):this.events.clear()}listenerCount(e){const t=this.events.get(e);return t?t.size:0}}class d extends Error{constructor(e,t,s){super(`Parameter validation failed: ${e} - ${t}`),this.name="ValidationError",this.field=e,this.value=s}}class h{static validateValue(e,t,s){if(s.required&&(null==t||""===t))throw new d(e,s.message||`${e} is required`,t);if(s.required||null!=t&&""!==t){if(s.type&&!this.checkType(t,s.type))throw new d(e,s.message||`${e} must be of type ${s.type}`,t);if("string"===s.type&&"string"==typeof t){if(void 0!==s.min&&t.length<s.min)throw new d(e,s.message||`${e} length cannot be less than ${s.min} characters`,t);if(void 0!==s.max&&t.length>s.max)throw new d(e,s.message||`${e} length cannot exceed ${s.max} characters`,t)}if("number"===s.type&&"number"==typeof t){if(void 0!==s.min&&t<s.min)throw new d(e,s.message||`${e} cannot be less than ${s.min}`,t);if(void 0!==s.max&&t>s.max)throw new d(e,s.message||`${e} cannot be greater than ${s.max}`,t)}if(s.pattern&&"string"==typeof t&&!s.pattern.test(t))throw new d(e,s.message||`${e} format is incorrect`,t);if(s.custom){const n=s.custom(t);if(!0!==n){const o="string"==typeof n?n:s.message||`${e} validation failed`;throw new d(e,o,t)}}}}static validateObject(e,t){if(!e||"object"!=typeof e)throw new d("root","Parameter must be an object type");for(const[s,n]of Object.entries(t)){const t=e[s];this.validateValue(s,t,n)}}static checkType(e,t){switch(t){case"string":return"string"==typeof e;case"number":return"number"==typeof e&&!isNaN(e);case"boolean":return"boolean"==typeof e;case"object":return null!==e&&"object"==typeof e&&!Array.isArray(e);case"array":return Array.isArray(e);case"function":return"function"==typeof e;default:return!1}}static validateSDKAppID(e){this.validateValue("SDKAppID",e,{required:!0,type:"number",custom:e=>!!Number.isInteger(e)||"SDKAppID must be an integer",message:"SDKAppID must be an integer between 1-999999999"})}static validateAppKey(e){this.validateValue("appKey",e,{required:!0,type:"string",pattern:/^[a-zA-Z0-9_-]+$/,message:"appKey must be a 1-256 character string composed of letters, numbers, underscores or hyphens"})}static validateUserID(e){this.validateValue("userID",e,{required:!0,type:"string",pattern:/^[a-zA-Z0-9_.-]+$/,message:"userID must be a 1-128 character string composed of letters, numbers, underscores, dots or hyphens"})}static validateEventType(e){const t=["message_received","message_revoked","notification_clicked"];this.validateValue("eventType",e,{required:!0,type:"string",custom:e=>!!t.includes(e)||`eventType must be one of: ${t.join(", ")}`})}static validateListener(e){this.validateValue("listener",e,{required:!0,type:"function",message:"listener must be a function"})}static validateRegisterPushOptions(e){if(!e)throw new d("options","Registration options cannot be empty");const t={SDKAppID:{required:!0,type:"number",custom:e=>!!Number.isInteger(e)||"SDKAppID must be an integer"},appKey:{required:!0,type:"string",pattern:/^[a-zA-Z0-9_-]+$/},userID:{required:!0,type:"string",pattern:/^[a-zA-Z0-9_.-]+$/}};this.validateObject(e,t)}static validatePushMessage(e){if(!e)throw new d("message","Push message cannot be empty");this.validateObject(e,{messageID:{required:!0,type:"string"},title:{required:!0,type:"string"},body:{required:!0,type:"string"},icon:{required:!1,type:"string",pattern:/^https?:\/\/.+/},tag:{required:!1,type:"string"},timestamp:{required:!0,type:"number"}})}static validateURL(e,t="url"){this.validateValue(t,e,{required:!0,type:"string",pattern:/^https?:\/\/.+/,message:`${t} must be a valid HTTP/HTTPS URL`})}static validateServiceWorkerPath(e){this.validateValue("serviceWorkerPath",e,{required:!1,type:"string",pattern:/^[a-zA-Z0-9_./-]+\.js$/,message:"serviceWorkerPath must be a valid JavaScript file path"})}}class p{constructor(){this.browserInfo=null}static getInstance(){return p.instance||(p.instance=new p),p.instance}getBrowserInfo(){if(this.browserInfo)return this.browserInfo;const e="undefined"!=typeof navigator&&navigator.userAgent||"Test/1.0.0",t={name:"Unknown",version:"0.0.0",majorVersion:0,platform:this.detectPlatform(),userAgent:e,language:this.detectLanguage()};if(/Chrome\/(\d+)/.test(e)&&!/Edge|Edg/.test(e)){const s=e.match(/Chrome\/(\d+)\.(\d+)\.(\d+)/);s&&(t.name="Chrome",t.version=`${s[1]}.${s[2]}.${s[3]}`,t.majorVersion=parseInt(s[1]))}else if(/Firefox\/(\d+)/.test(e)){const s=e.match(/Firefox\/(\d+)\.(\d+)/);s&&(t.name="Firefox",t.version=`${s[1]}.${s[2]}`,t.majorVersion=parseInt(s[1]))}else if(/Safari\//.test(e)&&!/Chrome|Chromium/.test(e)){const s=e.match(/Version\/(\d+)\.(\d+)/);s&&(t.name="Safari",t.version=`${s[1]}.${s[2]}`,t.majorVersion=parseInt(s[1]))}else if(/Edg\/(\d+)/.test(e)){const s=e.match(/Edg\/(\d+)\.(\d+)\.(\d+)/);s&&(t.name="Edge",t.version=`${s[1]}.${s[2]}.${s[3]}`,t.majorVersion=parseInt(s[1]))}else if(/Edge\/(\d+)/.test(e)){const s=e.match(/Edge\/(\d+)\.(\d+)/);s&&(t.name="Edge Legacy",t.version=`${s[1]}.${s[2]}`,t.majorVersion=parseInt(s[1]))}else if(/OPR\/(\d+)/.test(e)){const s=e.match(/OPR\/(\d+)\.(\d+)\.(\d+)/);s&&(t.name="Opera",t.version=`${s[1]}.${s[2]}.${s[3]}`,t.majorVersion=parseInt(s[1]))}return this.browserInfo=t,t}detectPlatform(){if("undefined"==typeof navigator)return"Test";const e=navigator.userAgent||"";return/Windows/.test(e)?"Windows":/Mac OS X/.test(e)?"macOS":/Linux/.test(e)?"Linux":/Android/.test(e)?"Android":/iPhone|iPad|iPod/.test(e)?"iOS":"Unknown"}detectLanguage(){return"undefined"==typeof navigator?"en-US":navigator.language||navigator.languages?.[0]||"en-US"}getFeatureSupport(){return{serviceWorker:"serviceWorker"in navigator,pushManager:"PushManager"in window,notification:"Notification"in window,webPush:this.isWebPushSupported()}}detectWebPushCapability(){if("test"===process.env.NODE_ENV||"undefined"!=typeof jest)return{supported:!0,browserName:"Test",browserVersion:"1.0.0"};const e=this.getBrowserInfo();if("undefined"==typeof window)return{supported:!1,reason:"Not running in browser environment",browserName:e.name,browserVersion:e.version};if(!("serviceWorker"in navigator))return{supported:!1,reason:"Service Worker not supported",browserName:e.name,browserVersion:e.version};if(!("PushManager"in window))return{supported:!1,reason:"Push Manager not supported",browserName:e.name,browserVersion:e.version};if(!("Notification"in window))return{supported:!1,reason:"Notification API not supported",browserName:e.name,browserVersion:e.version};const t=this.checkBrowserVersionSupport(e);return t.supported?{supported:!0,browserName:e.name,browserVersion:e.version}:{supported:!1,reason:t.reason,browserName:e.name,browserVersion:e.version}}checkBrowserVersionSupport(e){switch(e.name){case"Safari":if(e.majorVersion<16)return{supported:!1,reason:"Safari version too old (requires 16+)"};break;case"Chrome":if(e.majorVersion<42)return{supported:!1,reason:"Chrome version too old (requires 42+)"};break;case"Firefox":if(e.majorVersion<44)return{supported:!1,reason:"Firefox version too old (requires 44+)"};break;case"Edge":if(e.majorVersion<17)return{supported:!1,reason:"Edge version too old (requires 17+)"};break;case"Edge Legacy":return{supported:!1,reason:"Edge Legacy not supported, please upgrade to new Edge"};case"Opera":if(e.majorVersion<39)return{supported:!1,reason:"Opera version too old (requires 39+)"};break;case"Unknown":return{supported:!1,reason:"Unknown browser, WebPush support uncertain"}}return{supported:!0}}isWebPushSupported(){return this.detectWebPushCapability().supported}getUnsupportedReason(){const e=this.detectWebPushCapability();return e.supported?void 0:e.reason}async checkNotificationPermission(){return"undefined"!=typeof window&&"Notification"in window?Notification.permission:(u.warn("Notification API not available"),"denied")}async requestNotificationPermission(){try{if("undefined"!=typeof window&&"Notification"in window&&"function"==typeof Notification.requestPermission)return await Notification.requestPermission();throw new Error("Notification permission request not supported")}catch(e){return u.error("Failed to request notification permission",e),this.handleBrowserSpecificError(e)}}requiresUserGesture(){return"Safari"===this.getBrowserInfo().name}handleBrowserSpecificError(e){const t=this.getBrowserInfo();let s="Permission denied";switch(t.name){case"Safari":s=`Safari: ${e.message}`;break;case"Chrome":s=`Chrome: ${e.message}`;break;case"Firefox":s=`Firefox: ${e.message}`;break;default:s=`${t.name}: ${e.message}`}return u.error("Browser specific error:",s),"denied"}checkBrowserSupport(){const e=this.detectWebPushCapability();return e.supported?(u.log("Browser supports Web Push:",{browser:`${e.browserName} ${e.browserVersion}`,features:this.getFeatureSupport()}),!0):(u.error("Browser not supported for Web Push:",e.reason),!1)}}const g=p.getInstance();const _=class e{static set(t,s){try{const n=JSON.stringify(s);localStorage.setItem(e.PREFIX+t,n)}catch(n){u.error("Storage set error:",n)}}static get(t,s){try{const n=localStorage.getItem(e.PREFIX+t);return null===n?s||null:JSON.parse(n)}catch(n){return u.error("Storage get error:",n),s||null}}static remove(t){try{localStorage.removeItem(e.PREFIX+t)}catch(s){u.error("Storage remove error:",s)}}static clear(){try{Object.keys(localStorage).forEach(t=>{t.startsWith(e.PREFIX)&&localStorage.removeItem(t)})}catch(t){u.error("Storage clear error:",t)}}};_.PREFIX="webpush_";let m=_;class f{constructor(e){this.registration=null,this.swUrl="/sw.js",this.eventEmitter=e,this.setupMessageListener()}static getInstance(e){return f.instance||(f.instance=new f(e)),f.instance}async checkServiceWorkerExists(e){try{return(await fetch(e,{method:"HEAD"})).ok}catch{return!1}}async autoDetectServiceWorkerUrl(){if("undefined"!=typeof window){const e=window.location.pathname;"/"!==(e.endsWith("/")?e:e+"/")?(this.swUrl="./sw.js",u.log("Detected subdirectory deployment, using relative path:",this.swUrl)):(this.swUrl="/sw.js",u.log("Detected root directory deployment, using absolute path:",this.swUrl));await this.checkServiceWorkerExists(this.swUrl)||u.warn("Default Service Worker path not available, will try other paths during registration")}}setServiceWorkerUrl(e){try{h.validateServiceWorkerPath(e),this.swUrl=e,u.log("Manually set Service Worker path:",e)}catch(t){if(t instanceof d)throw u.error("Set Service Worker path parameter validation failed",t.message),t;throw new Error("Failed to set Service Worker path")}}async register(){if(!("serviceWorker"in navigator))throw new Error("Service Worker is not supported");await this.autoDetectServiceWorkerUrl();const e=[this.swUrl,"./sw.js","/sw.js","/dist/sw.js","/assets/sw.js"],t=[...new Set(e)];let s=null;for(const o of t)try{return u.log("Attempting to register Service Worker:",o),this.registration=await navigator.serviceWorker.register(o),this.swUrl=o,u.log("Service Worker registration successful",{url:o,registration:this.registration}),await this.waitForServiceWorkerReady(),this.registration}catch(n){s=n,u.warn(`Service Worker registration failed (${o}):`,n);continue}throw u.error("All Service Worker paths failed to register",s),new Error(`Service Worker registration failed: ${s?.message||"Unknown error"}. Please ensure sw.js file exists in one of the following paths: ${t.join(", ")}`)}async waitForServiceWorkerReady(){if(!this.registration)throw new Error("Service Worker not registered");return new Promise(e=>{if(this.registration.active)return void e();const t=this.registration.installing||this.registration.waiting;t&&t.addEventListener("statechange",()=>{"activated"===t.state&&e()})})}async getPushSubscription(e){try{if(h.validateValue("vapidPublicKey",e,{required:!0,type:"string",min:1,max:512,message:"VAPID public key must be a valid string"}),!this.registration)throw new Error("Service Worker not registered");const t=this.getStoredVapidPublicKey();let s=await this.registration.pushManager.getSubscription();s&&t!==e&&(u.log("VAPID public key changed, unsubscribing existing subscription"),await s.unsubscribe(),s=null),s||(s=await this.registration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:this.urlBase64ToUint8Array(e)}),this.setStoreVapidPublicKey(e)),u.log("Get push subscription successful",s);const n=this.getSubscriptionInfo(s);return u.log("Extracted subscription information:",{token:n.token,auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint}),{subscription:s,token:n.token||"",auth:n.auth||"",p256dh:n.p256dh||"",endpoint:n.endpoint||""}}catch(t){if(t instanceof d)throw u.error("Get push subscription parameter validation failed",t.message),t;throw u.error("Get push subscription failed",t),t}}getSubscriptionInfo(e){if(!e||!e.endpoint)return{token:null,auth:null,p256dh:null,endpoint:null};const t=e.endpoint,s=g.getBrowserInfo(),n=e.getKey?{auth:e.getKey("auth")?this.arrayBufferToBase64(e.getKey("auth")):null,p256dh:e.getKey("p256dh")?this.arrayBufferToBase64(e.getKey("p256dh")):null}:{auth:null,p256dh:null};u.log("Extract push subscription information",{browser:`${s.name} ${s.version}`,hasAuth:!!n.auth,hasP256dh:!!n.p256dh});try{if("Chrome"===s.name||"Edge"===s.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return u.log("Extract Token using Chrome/Edge FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t};const s=t.match(/https:\/\/android\.googleapis\.com\/gcm\/send\/(.+)/);if(s)return u.log("Extract Token using Chrome/Edge GCM format"),{token:s[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Firefox"===s.name){const e=t.match(/https:\/\/updates\.push\.services\.mozilla\.com\/wpush\/v(\d+)\/(.+)/);if(e)return u.log(`Extract Token using Firefox WebPush v${e[1]} format`),{token:e[2],auth:n.auth,p256dh:n.p256dh,endpoint:t};const s=t.match(/https:\/\/updates\.push\.services\.mozilla\.com\/push\/(.+)/);if(s)return u.log("Extract Token using Firefox legacy format"),{token:s[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Safari"===s.name){if(s.majorVersion>=16){const e=t.match(/https:\/\/web\.push\.apple\.com\/(.+)/);if(e)return u.log("Extract Token using Safari Web Push format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}if(t.includes("safari")||t.includes("apple"))return u.log("Safari push notification uses complete endpoint as identifier"),{token:this.generateSafariToken(t),auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Opera"===s.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return u.log("Extract Token using Opera FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Samsung Internet"===s.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return u.log("Extract Token using Samsung Internet FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}const e=[{pattern:/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/,name:"FCM Standard"},{pattern:/https:\/\/android\.googleapis\.com\/gcm\/send\/(.+)/,name:"GCM Legacy"},{pattern:/https:\/\/gcm-http\.googleapis\.com\/gcm\/(.+)/,name:"GCM HTTP"},{pattern:/https:\/\/updates\.push\.services\.mozilla\.com\/wpush\/v\d+\/(.+)/,name:"Mozilla WebPush"},{pattern:/https:\/\/updates\.push\.services\.mozilla\.com\/push\/(.+)/,name:"Mozilla Legacy"},{pattern:/https:\/\/.*\.notify\.windows\.com\/.*\/(.+)/,name:"Windows Notification"},{pattern:/https:\/\/web\.push\.apple\.com\/(.+)/,name:"Apple Web Push"},{pattern:/https:\/\/.*\/push\/(.+)/,name:"Generic Push"},{pattern:/https:\/\/.*\/wpush\/(.+)/,name:"Generic WebPush"}];for(const{pattern:o,name:i}of e){const e=t.match(o);if(e&&e[1])return u.log(`Extract Token using generic pattern: ${i}`,{browser:s.name,pattern:o.source}),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}u.warn("Unable to extract standard Token from push endpoint, generating unique identifier",{browser:`${s.name} ${s.version}`,endpointLength:t.length,endpointStart:t.substring(0,50)+"..."});return{token:this.generateFallbackToken(t,s),auth:n.auth,p256dh:n.p256dh,endpoint:t}}catch(o){u.error("Error occurred during push subscription information extraction",{error:o instanceof Error?o.message:o,browser:s.name,endpointDomain:t.split("/")[2]});return{token:this.generateFallbackToken(t,s),auth:n.auth,p256dh:n.p256dh,endpoint:t}}}generateSafariToken(e){const t=e.match(/https:\/\/.*safari.*\/(.+)/);return t?`safari_${t[1]}`:`safari_${this.generateEndpointHash(e)}`}generateFallbackToken(e,t){const s=this.generateEndpointHash(e);return`${t.name.toLowerCase().replace(/\s+/g,"")}_${s}_${Date.now().toString(36)}`}generateEndpointHash(e){let t=0;for(let s=0;s<e.length;s++){t=(t<<5)-t+e.charCodeAt(s),t&=t}return Math.abs(t).toString(36)}async unsubscribe(){if(!this.registration)return!1;const e=await this.registration.pushManager.getSubscription();if(e){const t=await e.unsubscribe();return u.log("Unsubscribe from push notifications",t),this.clearStoredVapidPublicKey(),t}return!0}async unregister(){if(!this.registration)return!1;const e=await this.registration.unregister();return this.registration=null,this.clearStoredVapidPublicKey(),u.log("Unregister Service Worker",e),e}setupMessageListener(){"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",e=>{const t=e.data;this.handleServiceWorkerMessage(t)})}handleServiceWorkerMessage(e){switch(u.log("Received Service Worker message",e),e.type){case"MESSAGE_RECEIVED":this.eventEmitter.emit(r.MESSAGE_RECEIVED,e.data);break;case"NOTIFICATION_CLICKED":this.eventEmitter.emit(r.NOTIFICATION_CLICKED,e.data);break;case"MESSAGE_REVOKED":this.eventEmitter.emit(r.MESSAGE_REVOKED,e.data)}}async postMessage(e){try{if(h.validateValue("message",e,{required:!0,message:"Message content cannot be empty"}),!this.registration||!this.registration.active)throw new Error("Service Worker not activated");this.registration.active.postMessage(e),u.log("Send message to Service Worker successful",e)}catch(t){if(t instanceof d)throw u.error("Send message parameter validation failed",t.message),t;throw u.error("Send message to Service Worker failed",t),t}}arrayBufferToBase64(e){const t=new Uint8Array(e);let s="";for(let n=0;n<t.byteLength;n++)s+=String.fromCharCode(t[n]);return window.btoa(s)}urlBase64ToUint8Array(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),s=window.atob(t),n=new Uint8Array(s.length);for(let o=0;o<s.length;++o)n[o]=s.charCodeAt(o);return n}getRegistration(){return this.registration}getStoredVapidPublicKey(){try{return m.get("sdk_vapid_key")}catch(e){return u.error("Failed to get stored VAPID public key",e),null}}setStoreVapidPublicKey(e){try{m.set("sdk_vapid_key",e),u.log("VAPID public key stored successfully")}catch(t){u.error("Failed to store VAPID public key",t)}}clearStoredVapidPublicKey(){try{m.remove("sdk_vapid_key"),u.log("VAPID public key cleared successfully")}catch(e){u.error("Failed to clear VAPID public key",e)}}}var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},I=[],E=[],S="undefined"!=typeof Uint8Array?Uint8Array:Array,y=!1;function C(){y=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)I[t]=e[t],E[e.charCodeAt(t)]=t;E["-".charCodeAt(0)]=62,E["_".charCodeAt(0)]=63}function M(e,t,s){for(var n,o,i=[],r=t;r<s;r+=3)n=(e[r]<<16)+(e[r+1]<<8)+e[r+2],i.push(I[(o=n)>>18&63]+I[o>>12&63]+I[o>>6&63]+I[63&o]);return i.join("")}function A(e){var t;y||C();for(var s=e.length,n=s%3,o="",i=[],r=0,a=s-n;r<a;r+=16383)i.push(M(e,r,r+16383>a?a:r+16383));return 1===n?(t=e[s-1],o+=I[t>>2],o+=I[t<<4&63],o+="=="):2===n&&(t=(e[s-2]<<8)+e[s-1],o+=I[t>>10],o+=I[t>>4&63],o+=I[t<<2&63],o+="="),i.push(o),i.join("")}function b(e,t,s,n,o){var i,r,a=8*o-n-1,c=(1<<a)-1,u=c>>1,l=-7,d=s?o-1:0,h=s?-1:1,p=e[t+d];for(d+=h,i=p&(1<<-l)-1,p>>=-l,l+=a;l>0;i=256*i+e[t+d],d+=h,l-=8);for(r=i&(1<<-l)-1,i>>=-l,l+=n;l>0;r=256*r+e[t+d],d+=h,l-=8);if(0===i)i=1-u;else{if(i===c)return r?NaN:1/0*(p?-1:1);r+=Math.pow(2,n),i-=u}return(p?-1:1)*r*Math.pow(2,i-n)}function T(e,t,s,n,o,i){var r,a,c,u=8*i-o-1,l=(1<<u)-1,d=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,g=n?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-r))<1&&(r--,c*=2),(t+=r+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(r++,c/=2),r+d>=l?(a=0,r=l):r+d>=1?(a=(t*c-1)*Math.pow(2,o),r+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),r=0));o>=8;e[s+p]=255&a,p+=g,a/=256,o-=8);for(r=r<<o|a,u+=o;u>0;e[s+p]=255&r,p+=g,r/=256,u-=8);e[s+p-g]|=128*_}var O={}.toString,w=Array.isArray||function(e){return"[object Array]"==O.call(e)};function D(){return L.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function R(e,t){if(D()<t)throw new RangeError("Invalid typed array length");return L.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=L.prototype:(null===e&&(e=new L(t)),e.length=t),e}function L(e,t,s){if(!(L.TYPED_ARRAY_SUPPORT||this instanceof L))return new L(e,t,s);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return k(this,e)}return N(this,e,t,s)}function N(e,t,s,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,s,n){if(t.byteLength,s<0||t.byteLength<s)throw new RangeError("'offset' is out of bounds");if(t.byteLength<s+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===s&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,s):new Uint8Array(t,s,n),L.TYPED_ARRAY_SUPPORT?(e=t).__proto__=L.prototype:e=G(e,t),e}(e,t,s,n):"string"==typeof t?function(e,t,s){if("string"==typeof s&&""!==s||(s="utf8"),!L.isEncoding(s))throw new TypeError('"encoding" must be a valid string encoding');var n=0|x(t,s),o=(e=R(e,n)).write(t,s);return o!==n&&(e=e.slice(0,o)),e}(e,t,s):function(e,t){if(F(t)){var s=0|U(t.length);return 0===(e=R(e,s)).length||t.copy(e,0,0,s),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?R(e,0):G(e,t);if("Buffer"===t.type&&w(t.data))return G(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function P(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function k(e,t){if(P(t),e=R(e,t<0?0:0|U(t)),!L.TYPED_ARRAY_SUPPORT)for(var s=0;s<t;++s)e[s]=0;return e}function G(e,t){var s=t.length<0?0:0|U(t.length);e=R(e,s);for(var n=0;n<s;n+=1)e[n]=255&t[n];return e}function U(e){if(e>=D())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D().toString(16)+" bytes");return 0|e}function F(e){return!(null==e||!e._isBuffer)}function x(e,t){if(F(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var s=e.length;if(0===s)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":case void 0:return he(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*s;case"hex":return s>>>1;case"base64":return pe(e).length;default:if(n)return he(e).length;t=(""+t).toLowerCase(),n=!0}}function $(e,t,s){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===s||s>this.length)&&(s=this.length),s<=0)return"";if((s>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return te(this,t,s);case"utf8":case"utf-8":return J(this,t,s);case"ascii":return Q(this,t,s);case"latin1":case"binary":return ee(this,t,s);case"base64":return Z(this,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return se(this,t,s);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function q(e,t,s){var n=e[t];e[t]=e[s],e[s]=n}function B(e,t,s,n,o){if(0===e.length)return-1;if("string"==typeof s?(n=s,s=0):s>2147483647?s=2147483647:s<-2147483648&&(s=-2147483648),s=+s,isNaN(s)&&(s=o?0:e.length-1),s<0&&(s=e.length+s),s>=e.length){if(o)return-1;s=e.length-1}else if(s<0){if(!o)return-1;s=0}if("string"==typeof t&&(t=L.from(t,n)),F(t))return 0===t.length?-1:V(e,t,s,n,o);if("number"==typeof t)return t&=255,L.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,s):Uint8Array.prototype.lastIndexOf.call(e,t,s):V(e,[t],s,n,o);throw new TypeError("val must be string, number or Buffer")}function V(e,t,s,n,o){var i,r=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;r=2,a/=2,c/=2,s/=2}function u(e,t){return 1===r?e[t]:e.readUInt16BE(t*r)}if(o){var l=-1;for(i=s;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*r}else-1!==l&&(i-=i-l),l=-1}else for(s+c>a&&(s=a-c),i=s;i>=0;i--){for(var d=!0,h=0;h<c;h++)if(u(e,i+h)!==u(t,h)){d=!1;break}if(d)return i}return-1}function W(e,t,s,n){s=Number(s)||0;var o=e.length-s;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var r=0;r<n;++r){var a=parseInt(t.substr(2*r,2),16);if(isNaN(a))return r;e[s+r]=a}return r}function j(e,t,s,n){return ge(he(t,e.length-s),e,s,n)}function H(e,t,s,n){return ge(function(e){for(var t=[],s=0;s<e.length;++s)t.push(255&e.charCodeAt(s));return t}(t),e,s,n)}function K(e,t,s,n){return H(e,t,s,n)}function Y(e,t,s,n){return ge(pe(t),e,s,n)}function z(e,t,s,n){return ge(function(e,t){for(var s,n,o,i=[],r=0;r<e.length&&!((t-=2)<0);++r)n=(s=e.charCodeAt(r))>>8,o=s%256,i.push(o),i.push(n);return i}(t,e.length-s),e,s,n)}function Z(e,t,s){return 0===t&&s===e.length?A(e):A(e.slice(t,s))}function J(e,t,s){s=Math.min(e.length,s);for(var n=[],o=t;o<s;){var i,r,a,c,u=e[o],l=null,d=u>239?4:u>223?3:u>191?2:1;if(o+d<=s)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],r=e[o+2],128==(192&i)&&128==(192&r)&&(c=(15&u)<<12|(63&i)<<6|63&r)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],r=e[o+2],a=e[o+3],128==(192&i)&&128==(192&r)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&r)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=d}return function(e){var t=e.length;if(t<=X)return String.fromCharCode.apply(String,e);for(var s="",n=0;n<t;)s+=String.fromCharCode.apply(String,e.slice(n,n+=X));return s}(n)}L.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT,L.poolSize=8192,L._augment=function(e){return e.__proto__=L.prototype,e},L.from=function(e,t,s){return N(null,e,t,s)},L.TYPED_ARRAY_SUPPORT&&(L.prototype.__proto__=Uint8Array.prototype,L.__proto__=Uint8Array),L.alloc=function(e,t,s){return n=null,i=t,r=s,P(o=e),o<=0?R(n,o):void 0!==i?"string"==typeof r?R(n,o).fill(i,r):R(n,o).fill(i):R(n,o);var n,o,i,r},L.allocUnsafe=function(e){return k(null,e)},L.allocUnsafeSlow=function(e){return k(null,e)},L.isBuffer=_e,L.compare=function(e,t){if(!F(e)||!F(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var s=e.length,n=t.length,o=0,i=Math.min(s,n);o<i;++o)if(e[o]!==t[o]){s=e[o],n=t[o];break}return s<n?-1:n<s?1:0},L.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},L.concat=function(e,t){if(!w(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return L.alloc(0);var s;if(void 0===t)for(t=0,s=0;s<e.length;++s)t+=e[s].length;var n=L.allocUnsafe(t),o=0;for(s=0;s<e.length;++s){var i=e[s];if(!F(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},L.byteLength=x,L.prototype._isBuffer=!0,L.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)q(this,t,t+1);return this},L.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)q(this,t,t+3),q(this,t+1,t+2);return this},L.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)q(this,t,t+7),q(this,t+1,t+6),q(this,t+2,t+5),q(this,t+3,t+4);return this},L.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?J(this,0,e):$.apply(this,arguments)},L.prototype.equals=function(e){if(!F(e))throw new TypeError("Argument must be a Buffer");return this===e||0===L.compare(this,e)},L.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},L.prototype.compare=function(e,t,s,n,o){if(!F(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===s&&(s=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||s>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=s)return 0;if(n>=o)return-1;if(t>=s)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),r=(s>>>=0)-(t>>>=0),a=Math.min(i,r),c=this.slice(n,o),u=e.slice(t,s),l=0;l<a;++l)if(c[l]!==u[l]){i=c[l],r=u[l];break}return i<r?-1:r<i?1:0},L.prototype.includes=function(e,t,s){return-1!==this.indexOf(e,t,s)},L.prototype.indexOf=function(e,t,s){return B(this,e,t,s,!0)},L.prototype.lastIndexOf=function(e,t,s){return B(this,e,t,s,!1)},L.prototype.write=function(e,t,s,n){if(void 0===t)n="utf8",s=this.length,t=0;else if(void 0===s&&"string"==typeof t)n=t,s=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(s)?(s|=0,void 0===n&&(n="utf8")):(n=s,s=void 0)}var o=this.length-t;if((void 0===s||s>o)&&(s=o),e.length>0&&(s<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return W(this,e,t,s);case"utf8":case"utf-8":return j(this,e,t,s);case"ascii":return H(this,e,t,s);case"latin1":case"binary":return K(this,e,t,s);case"base64":return Y(this,e,t,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,e,t,s);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},L.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var X=4096;function Q(e,t,s){var n="";s=Math.min(e.length,s);for(var o=t;o<s;++o)n+=String.fromCharCode(127&e[o]);return n}function ee(e,t,s){var n="";s=Math.min(e.length,s);for(var o=t;o<s;++o)n+=String.fromCharCode(e[o]);return n}function te(e,t,s){var n=e.length;(!t||t<0)&&(t=0),(!s||s<0||s>n)&&(s=n);for(var o="",i=t;i<s;++i)o+=de(e[i]);return o}function se(e,t,s){for(var n=e.slice(t,s),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function ne(e,t,s){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>s)throw new RangeError("Trying to access beyond buffer length")}function oe(e,t,s,n,o,i){if(!F(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(s+n>e.length)throw new RangeError("Index out of range")}function ie(e,t,s,n){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-s,2);o<i;++o)e[s+o]=(t&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function re(e,t,s,n){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-s,4);o<i;++o)e[s+o]=t>>>8*(n?o:3-o)&255}function ae(e,t,s,n,o,i){if(s+n>e.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("Index out of range")}function ce(e,t,s,n,o){return o||ae(e,0,s,4),T(e,t,s,n,23,4),s+4}function ue(e,t,s,n,o){return o||ae(e,0,s,8),T(e,t,s,n,52,8),s+8}L.prototype.slice=function(e,t){var s,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),L.TYPED_ARRAY_SUPPORT)(s=this.subarray(e,t)).__proto__=L.prototype;else{var o=t-e;s=new L(o,void 0);for(var i=0;i<o;++i)s[i]=this[i+e]}return s},L.prototype.readUIntLE=function(e,t,s){e|=0,t|=0,s||ne(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},L.prototype.readUIntBE=function(e,t,s){e|=0,t|=0,s||ne(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},L.prototype.readUInt8=function(e,t){return t||ne(e,1,this.length),this[e]},L.prototype.readUInt16LE=function(e,t){return t||ne(e,2,this.length),this[e]|this[e+1]<<8},L.prototype.readUInt16BE=function(e,t){return t||ne(e,2,this.length),this[e]<<8|this[e+1]},L.prototype.readUInt32LE=function(e,t){return t||ne(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},L.prototype.readUInt32BE=function(e,t){return t||ne(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},L.prototype.readIntLE=function(e,t,s){e|=0,t|=0,s||ne(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},L.prototype.readIntBE=function(e,t,s){e|=0,t|=0,s||ne(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},L.prototype.readInt8=function(e,t){return t||ne(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},L.prototype.readInt16LE=function(e,t){t||ne(e,2,this.length);var s=this[e]|this[e+1]<<8;return 32768&s?4294901760|s:s},L.prototype.readInt16BE=function(e,t){t||ne(e,2,this.length);var s=this[e+1]|this[e]<<8;return 32768&s?4294901760|s:s},L.prototype.readInt32LE=function(e,t){return t||ne(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},L.prototype.readInt32BE=function(e,t){return t||ne(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},L.prototype.readFloatLE=function(e,t){return t||ne(e,4,this.length),b(this,e,!0,23,4)},L.prototype.readFloatBE=function(e,t){return t||ne(e,4,this.length),b(this,e,!1,23,4)},L.prototype.readDoubleLE=function(e,t){return t||ne(e,8,this.length),b(this,e,!0,52,8)},L.prototype.readDoubleBE=function(e,t){return t||ne(e,8,this.length),b(this,e,!1,52,8)},L.prototype.writeUIntLE=function(e,t,s,n){e=+e,t|=0,s|=0,n||oe(this,e,t,s,Math.pow(2,8*s)-1,0);var o=1,i=0;for(this[t]=255&e;++i<s&&(o*=256);)this[t+i]=e/o&255;return t+s},L.prototype.writeUIntBE=function(e,t,s,n){e=+e,t|=0,s|=0,n||oe(this,e,t,s,Math.pow(2,8*s)-1,0);var o=s-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+s},L.prototype.writeUInt8=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,1,255,0),L.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},L.prototype.writeUInt16LE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,2,65535,0),L.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ie(this,e,t,!0),t+2},L.prototype.writeUInt16BE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,2,65535,0),L.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ie(this,e,t,!1),t+2},L.prototype.writeUInt32LE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,4,4294967295,0),L.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):re(this,e,t,!0),t+4},L.prototype.writeUInt32BE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,4,4294967295,0),L.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):re(this,e,t,!1),t+4},L.prototype.writeIntLE=function(e,t,s,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*s-1);oe(this,e,t,s,o-1,-o)}var i=0,r=1,a=0;for(this[t]=255&e;++i<s&&(r*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/r|0)-a&255;return t+s},L.prototype.writeIntBE=function(e,t,s,n){if(e=+e,t|=0,!n){var o=Math.pow(2,8*s-1);oe(this,e,t,s,o-1,-o)}var i=s-1,r=1,a=0;for(this[t+i]=255&e;--i>=0&&(r*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/r|0)-a&255;return t+s},L.prototype.writeInt8=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,1,127,-128),L.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},L.prototype.writeInt16LE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,2,32767,-32768),L.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ie(this,e,t,!0),t+2},L.prototype.writeInt16BE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,2,32767,-32768),L.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ie(this,e,t,!1),t+2},L.prototype.writeInt32LE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,4,2147483647,-2147483648),L.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):re(this,e,t,!0),t+4},L.prototype.writeInt32BE=function(e,t,s){return e=+e,t|=0,s||oe(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),L.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):re(this,e,t,!1),t+4},L.prototype.writeFloatLE=function(e,t,s){return ce(this,e,t,!0,s)},L.prototype.writeFloatBE=function(e,t,s){return ce(this,e,t,!1,s)},L.prototype.writeDoubleLE=function(e,t,s){return ue(this,e,t,!0,s)},L.prototype.writeDoubleBE=function(e,t,s){return ue(this,e,t,!1,s)},L.prototype.copy=function(e,t,s,n){if(s||(s=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<s&&(n=s),n===s)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(s<0||s>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-s&&(n=e.length-t+s);var o,i=n-s;if(this===e&&s<t&&t<n)for(o=i-1;o>=0;--o)e[o+t]=this[o+s];else if(i<1e3||!L.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+s];else Uint8Array.prototype.set.call(e,this.subarray(s,s+i),t);return i},L.prototype.fill=function(e,t,s,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,s=this.length):"string"==typeof s&&(n=s,s=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!L.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<s)throw new RangeError("Out of range index");if(s<=t)return this;var i;if(t>>>=0,s=void 0===s?this.length:s>>>0,e||(e=0),"number"==typeof e)for(i=t;i<s;++i)this[i]=e;else{var r=F(e)?e:he(new L(e,n).toString()),a=r.length;for(i=0;i<s-t;++i)this[i+t]=r[i%a]}return this};var le=/[^+\/0-9A-Za-z-_]/g;function de(e){return e<16?"0"+e.toString(16):e.toString(16)}function he(e,t){var s;t=t||1/0;for(var n=e.length,o=null,i=[],r=0;r<n;++r){if((s=e.charCodeAt(r))>55295&&s<57344){if(!o){if(s>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(r+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=s;continue}if(s<56320){(t-=3)>-1&&i.push(239,191,189),o=s;continue}s=65536+(o-55296<<10|s-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,s<128){if((t-=1)<0)break;i.push(s)}else if(s<2048){if((t-=2)<0)break;i.push(s>>6|192,63&s|128)}else if(s<65536){if((t-=3)<0)break;i.push(s>>12|224,s>>6&63|128,63&s|128)}else{if(!(s<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(s>>18|240,s>>12&63|128,s>>6&63|128,63&s|128)}}return i}function pe(e){return function(e){var t,s,n,o,i,r;y||C();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[a-2]?2:"="===e[a-1]?1:0,r=new S(3*a/4-i),n=i>0?a-4:a;var c=0;for(t=0,s=0;t<n;t+=4,s+=3)o=E[e.charCodeAt(t)]<<18|E[e.charCodeAt(t+1)]<<12|E[e.charCodeAt(t+2)]<<6|E[e.charCodeAt(t+3)],r[c++]=o>>16&255,r[c++]=o>>8&255,r[c++]=255&o;return 2===i?(o=E[e.charCodeAt(t)]<<2|E[e.charCodeAt(t+1)]>>4,r[c++]=255&o):1===i&&(o=E[e.charCodeAt(t)]<<10|E[e.charCodeAt(t+1)]<<4|E[e.charCodeAt(t+2)]>>2,r[c++]=o>>8&255,r[c++]=255&o),r}(function(e){if((e=(t=e,t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(le,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function ge(e,t,s,n){for(var o=0;o<n&&!(o+s>=t.length||o>=e.length);++o)t[o+s]=e[o];return o}function _e(e){return null!=e&&(!!e._isBuffer||me(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&me(t.slice(0,0)));var t}function me(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function fe(e,t){return e(t={exports:{}},t.exports),t.exports}var ve=fe(function(e,t){var s,n,o,i,r,a,c,u,l,d,h,p,g;e.exports=(s=s||(n=Math,o=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),r=(i={}).lib={},a=r.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=r.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,s=e.words,n=this.sigBytes,o=e.sigBytes;if(this.clamp(),n%4)for(var i=0;i<o;i++){var r=s[i>>>2]>>>24-i%4*8&255;t[n+i>>>2]|=r<<24-(n+i)%4*8}else for(i=0;i<o;i+=4)t[n+i>>>2]=s[i>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=n.ceil(t/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t,s=[],o=function(e){var t=987654321,s=4294967295;return function(){var o=((t=36969*(65535&t)+(t>>16)&s)<<16)+(e=18e3*(65535&e)+(e>>16)&s)&s;return o/=4294967296,(o+=.5)*(n.random()>.5?1:-1)}},i=0;i<e;i+=4){var r=o(4294967296*(t||n.random()));t=987654071*r(),s.push(4294967296*r()|0)}return new c.init(s,e)}}),u=i.enc={},l=u.Hex={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],o=0;o<s;o++){var i=t[o>>>2]>>>24-o%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n+=2)s[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(s,t/2)}},d=u.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],o=0;o<s;o++){var i=t[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n++)s[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(s,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(d.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return d.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,s=t.words,o=t.sigBytes,i=this.blockSize,r=o/(4*i),a=(r=e?n.ceil(r):n.max((0|r)-this._minBufferSize,0))*i,u=n.min(4*a,o);if(a){for(var l=0;l<a;l+=i)this._doProcessBlock(s,l);var d=s.splice(0,a);t.sigBytes-=u}return new c.init(d,u)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),r.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,s){return new e.init(s).finalize(t)}},_createHmacHelper:function(e){return function(t,s){return new g.HMAC.init(e,s).finalize(t)}}}),g=i.algo={},i),s)}),Ie=(fe(function(e,t){var s,n,o,i,r,a;e.exports=(o=(n=s=ve).lib,i=o.Base,r=o.WordArray,(a=n.x64={}).Word=i.extend({init:function(e,t){this.high=e,this.low=t}}),a.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,s=[],n=0;n<t;n++){var o=e[n];s.push(o.high),s.push(o.low)}return r.create(s,this.sigBytes)},clone:function(){for(var e=i.clone.call(this),t=e.words=this.words.slice(0),s=t.length,n=0;n<s;n++)t[n]=t[n].clone();return e}}),s)}),fe(function(e,t){var s;e.exports=(s=ve,function(){if("function"==typeof ArrayBuffer){var e=s.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var s=e.byteLength,n=[],o=0;o<s;o++)n[o>>>2]|=e[o]<<24-o%4*8;t.call(this,n,s)}else t.apply(this,arguments)}).prototype=e}}(),s.lib.WordArray)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.WordArray,n=e.enc;function o(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],o=0;o<s;o+=2){var i=t[o>>>2]>>>16-o%4*8&65535;n.push(String.fromCharCode(i))}return n.join("")},parse:function(e){for(var s=e.length,n=[],o=0;o<s;o++)n[o>>>1]|=e.charCodeAt(o)<<16-o%2*16;return t.create(n,2*s)}},n.Utf16LE={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],i=0;i<s;i+=2){var r=o(t[i>>>2]>>>16-i%4*8&65535);n.push(String.fromCharCode(r))}return n.join("")},parse:function(e){for(var s=e.length,n=[],i=0;i<s;i++)n[i>>>1]|=o(e.charCodeAt(i)<<16-i%2*16);return t.create(n,2*s)}}}(),s.enc.Utf16)}),fe(function(e,t){var s,n,o;e.exports=(o=(n=s=ve).lib.WordArray,n.enc.Base64={stringify:function(e){var t=e.words,s=e.sigBytes,n=this._map;e.clamp();for(var o=[],i=0;i<s;i+=3)for(var r=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<s;a++)o.push(n.charAt(r>>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,s=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<s.length;i++)n[s.charCodeAt(i)]=i}var r=s.charAt(64);if(r){var a=e.indexOf(r);-1!==a&&(t=a)}return function(e,t,s){for(var n=[],i=0,r=0;r<t;r++)if(r%4){var a=s[e.charCodeAt(r-1)]<<r%4*2,c=s[e.charCodeAt(r)]>>>6-r%4*2;n[i>>>2]|=(a|c)<<24-i%4*8,i++}return o.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},s.enc.Base64)}),fe(function(e,t){var s;e.exports=(s=ve,function(e){var t=s,n=t.lib,o=n.WordArray,i=n.Hasher,r=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=r.MD5=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var n=t+s,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,r=e[t+0],c=e[t+1],p=e[t+2],g=e[t+3],_=e[t+4],m=e[t+5],f=e[t+6],v=e[t+7],I=e[t+8],E=e[t+9],S=e[t+10],y=e[t+11],C=e[t+12],M=e[t+13],A=e[t+14],b=e[t+15],T=i[0],O=i[1],w=i[2],D=i[3];T=u(T,O,w,D,r,7,a[0]),D=u(D,T,O,w,c,12,a[1]),w=u(w,D,T,O,p,17,a[2]),O=u(O,w,D,T,g,22,a[3]),T=u(T,O,w,D,_,7,a[4]),D=u(D,T,O,w,m,12,a[5]),w=u(w,D,T,O,f,17,a[6]),O=u(O,w,D,T,v,22,a[7]),T=u(T,O,w,D,I,7,a[8]),D=u(D,T,O,w,E,12,a[9]),w=u(w,D,T,O,S,17,a[10]),O=u(O,w,D,T,y,22,a[11]),T=u(T,O,w,D,C,7,a[12]),D=u(D,T,O,w,M,12,a[13]),w=u(w,D,T,O,A,17,a[14]),T=l(T,O=u(O,w,D,T,b,22,a[15]),w,D,c,5,a[16]),D=l(D,T,O,w,f,9,a[17]),w=l(w,D,T,O,y,14,a[18]),O=l(O,w,D,T,r,20,a[19]),T=l(T,O,w,D,m,5,a[20]),D=l(D,T,O,w,S,9,a[21]),w=l(w,D,T,O,b,14,a[22]),O=l(O,w,D,T,_,20,a[23]),T=l(T,O,w,D,E,5,a[24]),D=l(D,T,O,w,A,9,a[25]),w=l(w,D,T,O,g,14,a[26]),O=l(O,w,D,T,I,20,a[27]),T=l(T,O,w,D,M,5,a[28]),D=l(D,T,O,w,p,9,a[29]),w=l(w,D,T,O,v,14,a[30]),T=d(T,O=l(O,w,D,T,C,20,a[31]),w,D,m,4,a[32]),D=d(D,T,O,w,I,11,a[33]),w=d(w,D,T,O,y,16,a[34]),O=d(O,w,D,T,A,23,a[35]),T=d(T,O,w,D,c,4,a[36]),D=d(D,T,O,w,_,11,a[37]),w=d(w,D,T,O,v,16,a[38]),O=d(O,w,D,T,S,23,a[39]),T=d(T,O,w,D,M,4,a[40]),D=d(D,T,O,w,r,11,a[41]),w=d(w,D,T,O,g,16,a[42]),O=d(O,w,D,T,f,23,a[43]),T=d(T,O,w,D,E,4,a[44]),D=d(D,T,O,w,C,11,a[45]),w=d(w,D,T,O,b,16,a[46]),T=h(T,O=d(O,w,D,T,p,23,a[47]),w,D,r,6,a[48]),D=h(D,T,O,w,v,10,a[49]),w=h(w,D,T,O,A,15,a[50]),O=h(O,w,D,T,m,21,a[51]),T=h(T,O,w,D,C,6,a[52]),D=h(D,T,O,w,g,10,a[53]),w=h(w,D,T,O,S,15,a[54]),O=h(O,w,D,T,c,21,a[55]),T=h(T,O,w,D,I,6,a[56]),D=h(D,T,O,w,b,10,a[57]),w=h(w,D,T,O,f,15,a[58]),O=h(O,w,D,T,M,21,a[59]),T=h(T,O,w,D,_,6,a[60]),D=h(D,T,O,w,y,10,a[61]),w=h(w,D,T,O,p,15,a[62]),O=h(O,w,D,T,E,21,a[63]),i[0]=i[0]+T|0,i[1]=i[1]+O|0,i[2]=i[2]+w|0,i[3]=i[3]+D|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;s[o>>>5]|=128<<24-o%32;var i=e.floor(n/4294967296),r=n;s[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),s[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,s,n,o,i,r){var a=e+(t&s|~t&n)+o+r;return(a<<i|a>>>32-i)+t}function l(e,t,s,n,o,i,r){var a=e+(t&n|s&~n)+o+r;return(a<<i|a>>>32-i)+t}function d(e,t,s,n,o,i,r){var a=e+(t^s^n)+o+r;return(a<<i|a>>>32-i)+t}function h(e,t,s,n,o,i,r){var a=e+(s^(t|~n))+o+r;return(a<<i|a>>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),s.MD5)}),fe(function(e,t){var s,n,o,i,r,a,c,u;e.exports=(o=(n=s=ve).lib,i=o.WordArray,r=o.Hasher,a=n.algo,c=[],u=a.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var s=this._hash.words,n=s[0],o=s[1],i=s[2],r=s[3],a=s[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var d=(n<<5|n>>>27)+a+c[u];d+=u<20?1518500249+(o&i|~o&r):u<40?1859775393+(o^i^r):u<60?(o&i|o&r|i&r)-1894007588:(o^i^r)-899497514,a=r,r=i,i=o<<30|o>>>2,o=n,n=d}s[0]=s[0]+n|0,s[1]=s[1]+o|0,s[2]=s[2]+i|0,s[3]=s[3]+r|0,s[4]=s[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,s=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(s/4294967296),t[15+(n+64>>>9<<4)]=s,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=r._createHelper(u),n.HmacSHA1=r._createHmacHelper(u),s.SHA1)}),fe(function(e,t){var s;e.exports=(s=ve,function(e){var t=s,n=t.lib,o=n.WordArray,i=n.Hasher,r=t.algo,a=[],c=[];!function(){function t(t){for(var s=e.sqrt(t),n=2;n<=s;n++)if(!(t%n))return!1;return!0}function s(e){return 4294967296*(e-(0|e))|0}for(var n=2,o=0;o<64;)t(n)&&(o<8&&(a[o]=s(e.pow(n,.5))),c[o]=s(e.pow(n,1/3)),o++),n++}();var u=[],l=r.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(e,t){for(var s=this._hash.words,n=s[0],o=s[1],i=s[2],r=s[3],a=s[4],l=s[5],d=s[6],h=s[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var g=u[p-15],_=(g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3,m=u[p-2],f=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=_+u[p-7]+f+u[p-16]}var v=n&o^n&i^o&i,I=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),E=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&d)+c[p]+u[p];h=d,d=l,l=a,a=r+E|0,r=i,i=o,o=n,n=E+(I+v)|0}s[0]=s[0]+n|0,s[1]=s[1]+o|0,s[2]=s[2]+i|0,s[3]=s[3]+r|0,s[4]=s[4]+a|0,s[5]=s[5]+l|0,s[6]=s[6]+d|0,s[7]=s[7]+h|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;return s[o>>>5]|=128<<24-o%32,s[14+(o+64>>>9<<4)]=e.floor(n/4294967296),s[15+(o+64>>>9<<4)]=n,t.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=i._createHelper(l),t.HmacSHA256=i._createHmacHelper(l)}(Math),s.SHA256)}),fe(function(e,t){var s,n,o,i,r,a;e.exports=(o=(n=s=ve).lib.WordArray,i=n.algo,r=i.SHA256,a=i.SHA224=r.extend({_doReset:function(){this._hash=new o.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=r._doFinalize.call(this);return e.sigBytes-=4,e}}),n.SHA224=r._createHelper(a),n.HmacSHA224=r._createHmacHelper(a),s.SHA224)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.Hasher,n=e.x64,o=n.Word,i=n.WordArray,r=e.algo;function a(){return o.create.apply(o,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var e=0;e<80;e++)u[e]=a()}();var l=r.SHA512=t.extend({_doReset:function(){this._hash=new i.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var s=this._hash.words,n=s[0],o=s[1],i=s[2],r=s[3],a=s[4],l=s[5],d=s[6],h=s[7],p=n.high,g=n.low,_=o.high,m=o.low,f=i.high,v=i.low,I=r.high,E=r.low,S=a.high,y=a.low,C=l.high,M=l.low,A=d.high,b=d.low,T=h.high,O=h.low,w=p,D=g,R=_,L=m,N=f,P=v,k=I,G=E,U=S,F=y,x=C,$=M,q=A,B=b,V=T,W=O,j=0;j<80;j++){var H=u[j];if(j<16)var K=H.high=0|e[t+2*j],Y=H.low=0|e[t+2*j+1];else{var z=u[j-15],Z=z.high,J=z.low,X=(Z>>>1|J<<31)^(Z>>>8|J<<24)^Z>>>7,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^(J>>>7|Z<<25),ee=u[j-2],te=ee.high,se=ee.low,ne=(te>>>19|se<<13)^(te<<3|se>>>29)^te>>>6,oe=(se>>>19|te<<13)^(se<<3|te>>>29)^(se>>>6|te<<26),ie=u[j-7],re=ie.high,ae=ie.low,ce=u[j-16],ue=ce.high,le=ce.low;K=(K=(K=X+re+((Y=Q+ae)>>>0<Q>>>0?1:0))+ne+((Y+=oe)>>>0<oe>>>0?1:0))+ue+((Y+=le)>>>0<le>>>0?1:0),H.high=K,H.low=Y}var de,he=U&x^~U&q,pe=F&$^~F&B,ge=w&R^w&N^R&N,_e=D&L^D&P^L&P,me=(w>>>28|D<<4)^(w<<30|D>>>2)^(w<<25|D>>>7),fe=(D>>>28|w<<4)^(D<<30|w>>>2)^(D<<25|w>>>7),ve=(U>>>14|F<<18)^(U>>>18|F<<14)^(U<<23|F>>>9),Ie=(F>>>14|U<<18)^(F>>>18|U<<14)^(F<<23|U>>>9),Ee=c[j],Se=Ee.high,ye=Ee.low,Ce=V+ve+((de=W+Ie)>>>0<W>>>0?1:0),Me=fe+_e;V=q,W=B,q=x,B=$,x=U,$=F,U=k+(Ce=(Ce=(Ce=Ce+he+((de+=pe)>>>0<pe>>>0?1:0))+Se+((de+=ye)>>>0<ye>>>0?1:0))+K+((de+=Y)>>>0<Y>>>0?1:0))+((F=G+de|0)>>>0<G>>>0?1:0)|0,k=N,G=P,N=R,P=L,R=w,L=D,w=Ce+(me+ge+(Me>>>0<fe>>>0?1:0))+((D=de+Me|0)>>>0<de>>>0?1:0)|0}g=n.low=g+D,n.high=p+w+(g>>>0<D>>>0?1:0),m=o.low=m+L,o.high=_+R+(m>>>0<L>>>0?1:0),v=i.low=v+P,i.high=f+N+(v>>>0<P>>>0?1:0),E=r.low=E+G,r.high=I+k+(E>>>0<G>>>0?1:0),y=a.low=y+F,a.high=S+U+(y>>>0<F>>>0?1:0),M=l.low=M+$,l.high=C+x+(M>>>0<$>>>0?1:0),b=d.low=b+B,d.high=A+q+(b>>>0<B>>>0?1:0),O=h.low=O+W,h.high=T+V+(O>>>0<W>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,s=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(s/4294967296),t[31+(n+128>>>10<<5)]=s,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),s.SHA512)}),fe(function(e,t){var s,n,o,i,r,a,c,u;e.exports=(o=(n=s=ve).x64,i=o.Word,r=o.WordArray,a=n.algo,c=a.SHA512,u=a.SHA384=c.extend({_doReset:function(){this._hash=new r.init([new i.init(3418070365,3238371032),new i.init(1654270250,914150663),new i.init(2438529370,812702999),new i.init(355462360,4144912697),new i.init(1731405415,4290775857),new i.init(2394180231,1750603025),new i.init(3675008525,1694076839),new i.init(1203062813,3204075428)])},_doFinalize:function(){var e=c._doFinalize.call(this);return e.sigBytes-=16,e}}),n.SHA384=c._createHelper(u),n.HmacSHA384=c._createHmacHelper(u),s.SHA384)}),fe(function(e,t){var s;e.exports=(s=ve,function(e){var t=s,n=t.lib,o=n.WordArray,i=n.Hasher,r=t.x64.Word,a=t.algo,c=[],u=[],l=[];!function(){for(var e=1,t=0,s=0;s<24;s++){c[e+5*t]=(s+1)*(s+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)u[e+5*t]=t+(2*e+3*t)%5*5;for(var o=1,i=0;i<24;i++){for(var a=0,d=0,h=0;h<7;h++){if(1&o){var p=(1<<h)-1;p<32?d^=1<<p:a^=1<<p-32}128&o?o=o<<1^113:o<<=1}l[i]=r.create(a,d)}}();var d=[];!function(){for(var e=0;e<25;e++)d[e]=r.create()}();var h=a.SHA3=i.extend({cfg:i.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new r.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var s=this._state,n=this.blockSize/2,o=0;o<n;o++){var i=e[t+2*o],r=e[t+2*o+1];i=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),r=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),(O=s[o]).high^=r,O.low^=i}for(var a=0;a<24;a++){for(var h=0;h<5;h++){for(var p=0,g=0,_=0;_<5;_++)p^=(O=s[h+5*_]).high,g^=O.low;var m=d[h];m.high=p,m.low=g}for(h=0;h<5;h++){var f=d[(h+4)%5],v=d[(h+1)%5],I=v.high,E=v.low;for(p=f.high^(I<<1|E>>>31),g=f.low^(E<<1|I>>>31),_=0;_<5;_++)(O=s[h+5*_]).high^=p,O.low^=g}for(var S=1;S<25;S++){var y=(O=s[S]).high,C=O.low,M=c[S];M<32?(p=y<<M|C>>>32-M,g=C<<M|y>>>32-M):(p=C<<M-32|y>>>64-M,g=y<<M-32|C>>>64-M);var A=d[u[S]];A.high=p,A.low=g}var b=d[0],T=s[0];for(b.high=T.high,b.low=T.low,h=0;h<5;h++)for(_=0;_<5;_++){var O=s[S=h+5*_],w=d[S],D=d[(h+1)%5+5*_],R=d[(h+2)%5+5*_];O.high=w.high^~D.high&R.high,O.low=w.low^~D.low&R.low}O=s[0];var L=l[a];O.high^=L.high,O.low^=L.low}},_doFinalize:function(){var t=this._data,s=t.words,n=(this._nDataBytes,8*t.sigBytes),i=32*this.blockSize;s[n>>>5]|=1<<24-n%32,s[(e.ceil((n+1)/i)*i>>>5)-1]|=128,t.sigBytes=4*s.length,this._process();for(var r=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],l=0;l<c;l++){var d=r[l],h=d.high,p=d.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),p=16711935&(p<<8|p>>>24)|4278255360&(p<<24|p>>>8),u.push(p),u.push(h)}return new o.init(u,a)},clone:function(){for(var e=i.clone.call(this),t=e._state=this._state.slice(0),s=0;s<25;s++)t[s]=t[s].clone();return e}});t.SHA3=i._createHelper(h),t.HmacSHA3=i._createHmacHelper(h)}(Math),s.SHA3)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib,n=t.WordArray,o=t.Hasher,i=e.algo,r=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),a=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),d=n.create([1352829926,1548603684,1836072691,2053994217,0]),h=i.RIPEMD160=o.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var n=t+s,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i,h,I,E,S,y,C,M,A,b,T,O=this._hash.words,w=l.words,D=d.words,R=r.words,L=a.words,N=c.words,P=u.words;for(y=i=O[0],C=h=O[1],M=I=O[2],A=E=O[3],b=S=O[4],s=0;s<80;s+=1)T=i+e[t+R[s]]|0,T+=s<16?p(h,I,E)+w[0]:s<32?g(h,I,E)+w[1]:s<48?_(h,I,E)+w[2]:s<64?m(h,I,E)+w[3]:f(h,I,E)+w[4],T=(T=v(T|=0,N[s]))+S|0,i=S,S=E,E=v(I,10),I=h,h=T,T=y+e[t+L[s]]|0,T+=s<16?f(C,M,A)+D[0]:s<32?m(C,M,A)+D[1]:s<48?_(C,M,A)+D[2]:s<64?g(C,M,A)+D[3]:p(C,M,A)+D[4],T=(T=v(T|=0,P[s]))+b|0,y=b,b=A,A=v(M,10),M=C,C=T;T=O[1]+I+A|0,O[1]=O[2]+E+b|0,O[2]=O[3]+S+y|0,O[3]=O[4]+i+C|0,O[4]=O[0]+h+M|0,O[0]=T},_doFinalize:function(){var e=this._data,t=e.words,s=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var o=this._hash,i=o.words,r=0;r<5;r++){var a=i[r];i[r]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return o},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,s){return e^t^s}function g(e,t,s){return e&t|~e&s}function _(e,t,s){return(e|~t)^s}function m(e,t,s){return e&s|t&~s}function f(e,t,s){return e^(t|~s)}function v(e,t){return e<<t|e>>>32-t}e.RIPEMD160=o._createHelper(h),e.HmacRIPEMD160=o._createHmacHelper(h)}(),s.RIPEMD160)}),fe(function(e,t){var s,n,o,i;e.exports=(n=(s=ve).lib.Base,o=s.enc,i=o.Utf8,void(s.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var s=e.blockSize,n=4*s;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),r=this._iKey=t.clone(),a=o.words,c=r.words,u=0;u<s;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=r.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,s=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(s))}})))}),fe(function(e,t){var s,n,o,i,r,a,c,u,l;e.exports=(i=(o=(n=s=ve).lib).Base,r=o.WordArray,c=(a=n.algo).SHA1,u=a.HMAC,l=a.PBKDF2=i.extend({cfg:i.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,n=u.create(s.hasher,e),o=r.create(),i=r.create([1]),a=o.words,c=i.words,l=s.keySize,d=s.iterations;a.length<l;){var h=n.update(t).finalize(i);n.reset();for(var p=h.words,g=p.length,_=h,m=1;m<d;m++){_=n.finalize(_),n.reset();for(var f=_.words,v=0;v<g;v++)p[v]^=f[v]}o.concat(h),c[0]++}return o.sigBytes=4*l,o}}),n.PBKDF2=function(e,t,s){return l.create(s).compute(e,t)},s.PBKDF2)}),fe(function(e,t){var s,n,o,i,r,a,c,u;e.exports=(i=(o=(n=s=ve).lib).Base,r=o.WordArray,c=(a=n.algo).MD5,u=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:c,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var s=this.cfg,n=s.hasher.create(),o=r.create(),i=o.words,a=s.keySize,c=s.iterations;i.length<a;){u&&n.update(u);var u=n.update(e).finalize(t);n.reset();for(var l=1;l<c;l++)u=n.finalize(u),n.reset();o.concat(u)}return o.sigBytes=4*a,o}}),n.EvpKDF=function(e,t,s){return u.create(s).compute(e,t)},s.EvpKDF)}),fe(function(e,t){var s,n,o,i,r,a,c,u,l,d,h,p,g,_,m,f,v,I,E,S,y,C,M;e.exports=void((s=ve).lib.Cipher||(n=s,o=n.lib,i=o.Base,r=o.WordArray,a=o.BufferedBlockAlgorithm,c=n.enc,c.Utf8,u=c.Base64,l=n.algo,d=l.EvpKDF,h=o.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,s){this.cfg=this.cfg.extend(s),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?M:S}return function(t){return{encrypt:function(s,n,o){return e(n).encrypt(t,s,n,o)},decrypt:function(s,n,o){return e(n).decrypt(t,s,n,o)}}}}()}),o.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),p=n.mode={},g=o.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),_=p.CBC=function(){var e=g.extend();function t(e,t,s){var n=this._iv;if(n){var o=n;this._iv=undefined}else o=this._prevBlock;for(var i=0;i<s;i++)e[t+i]^=o[i]}return e.Encryptor=e.extend({processBlock:function(e,s){var n=this._cipher,o=n.blockSize;t.call(this,e,s,o),n.encryptBlock(e,s),this._prevBlock=e.slice(s,s+o)}}),e.Decryptor=e.extend({processBlock:function(e,s){var n=this._cipher,o=n.blockSize,i=e.slice(s,s+o);n.decryptBlock(e,s),t.call(this,e,s,o),this._prevBlock=i}}),e}(),m=n.pad={},f=m.Pkcs7={pad:function(e,t){for(var s=4*t,n=s-e.sigBytes%s,o=n<<24|n<<16|n<<8|n,i=[],a=0;a<n;a+=4)i.push(o);var c=r.create(i,n);e.concat(c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},o.BlockCipher=h.extend({cfg:h.cfg.extend({mode:_,padding:f}),reset:function(){h.reset.call(this);var e=this.cfg,t=e.iv,s=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=s.createEncryptor;else{n=s.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,t&&t.words):(this._mode=n.call(s,this,t&&t.words),this._mode.__creator=n)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),v=o.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),I=n.format={},E=I.OpenSSL={stringify:function(e){var t=e.ciphertext,s=e.salt;if(s)var n=r.create([1398893684,1701076831]).concat(s).concat(t);else n=t;return n.toString(u)},parse:function(e){var t=u.parse(e),s=t.words;if(1398893684==s[0]&&1701076831==s[1]){var n=r.create(s.slice(2,4));s.splice(0,4),t.sigBytes-=16}return v.create({ciphertext:t,salt:n})}},S=o.SerializableCipher=i.extend({cfg:i.extend({format:E}),encrypt:function(e,t,s,n){n=this.cfg.extend(n);var o=e.createEncryptor(s,n),i=o.finalize(t),r=o.cfg;return v.create({ciphertext:i,key:s,iv:r.iv,algorithm:e,mode:r.mode,padding:r.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,s,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(s,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=n.kdf={},C=y.OpenSSL={execute:function(e,t,s,n){n||(n=r.random(8));var o=d.create({keySize:t+s}).compute(e,n),i=r.create(o.words.slice(t),4*s);return o.sigBytes=4*t,v.create({key:o,iv:i,salt:n})}},M=o.PasswordBasedCipher=S.extend({cfg:S.cfg.extend({kdf:C}),encrypt:function(e,t,s,n){var o=(n=this.cfg.extend(n)).kdf.execute(s,e.keySize,e.ivSize);n.iv=o.iv;var i=S.encrypt.call(this,e,t,o.key,n);return i.mixIn(o),i},decrypt:function(e,t,s,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var o=n.kdf.execute(s,e.keySize,e.ivSize,t.salt);return n.iv=o.iv,S.decrypt.call(this,e,t,o.key,n)}})))}),fe(function(e,t){var s;e.exports=((s=ve).mode.CFB=function(){var e=s.lib.BlockCipherMode.extend();function t(e,t,s,n){var o=this._iv;if(o){var i=o.slice(0);this._iv=void 0}else i=this._prevBlock;n.encryptBlock(i,0);for(var r=0;r<s;r++)e[t+r]^=i[r]}return e.Encryptor=e.extend({processBlock:function(e,s){var n=this._cipher,o=n.blockSize;t.call(this,e,s,o,n),this._prevBlock=e.slice(s,s+o)}}),e.Decryptor=e.extend({processBlock:function(e,s){var n=this._cipher,o=n.blockSize,i=e.slice(s,s+o);t.call(this,e,s,o,n),this._prevBlock=i}}),e}(),s.mode.CFB)}),fe(function(e,t){var s,n,o;e.exports=((s=ve).mode.CTR=(o=(n=s.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var s=this._cipher,n=s.blockSize,o=this._iv,i=this._counter;o&&(i=this._counter=o.slice(0),this._iv=void 0);var r=i.slice(0);s.encryptBlock(r,0),i[n-1]=i[n-1]+1|0;for(var a=0;a<n;a++)e[t+a]^=r[a]}}),n.Decryptor=o,n),s.mode.CTR)}),fe(function(e,t){var s;e.exports=((s=ve).mode.CTRGladman=function(){var e=s.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,s=e>>8&255,n=255&e;255===t?(t=0,255===s?(s=0,255===n?n=0:++n):++s):++t,e=0,e+=t<<16,e+=s<<8,e+=n}return e}var n=e.Encryptor=e.extend({processBlock:function(e,s){var n,o=this._cipher,i=o.blockSize,r=this._iv,a=this._counter;r&&(a=this._counter=r.slice(0),this._iv=void 0),0===((n=a)[0]=t(n[0]))&&(n[1]=t(n[1]));var c=a.slice(0);o.encryptBlock(c,0);for(var u=0;u<i;u++)e[s+u]^=c[u]}});return e.Decryptor=n,e}(),s.mode.CTRGladman)}),fe(function(e,t){var s,n,o;e.exports=((s=ve).mode.OFB=(o=(n=s.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var s=this._cipher,n=s.blockSize,o=this._iv,i=this._keystream;o&&(i=this._keystream=o.slice(0),this._iv=void 0),s.encryptBlock(i,0);for(var r=0;r<n;r++)e[t+r]^=i[r]}}),n.Decryptor=o,n),s.mode.OFB)}),fe(function(e,t){var s,n;e.exports=((s=ve).mode.ECB=((n=s.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),n.Decryptor=n.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),n),s.mode.ECB)}),fe(function(e,t){var s;e.exports=((s=ve).pad.AnsiX923={pad:function(e,t){var s=e.sigBytes,n=4*t,o=n-s%n,i=s+o-1;e.clamp(),e.words[i>>>2]|=o<<24-i%4*8,e.sigBytes+=o},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},s.pad.Ansix923)}),fe(function(e,t){var s;e.exports=((s=ve).pad.Iso10126={pad:function(e,t){var n=4*t,o=n-e.sigBytes%n;e.concat(s.lib.WordArray.random(o-1)).concat(s.lib.WordArray.create([o<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},s.pad.Iso10126)}),fe(function(e,t){var s;e.exports=((s=ve).pad.Iso97971={pad:function(e,t){e.concat(s.lib.WordArray.create([2147483648],1)),s.pad.ZeroPadding.pad(e,t)},unpad:function(e){s.pad.ZeroPadding.unpad(e),e.sigBytes--}},s.pad.Iso97971)}),fe(function(e,t){var s;e.exports=((s=ve).pad.ZeroPadding={pad:function(e,t){var s=4*t;e.clamp(),e.sigBytes+=s-(e.sigBytes%s||s)},unpad:function(e){for(var t=e.words,s=e.sigBytes-1;!(t[s>>>2]>>>24-s%4*8&255);)s--;e.sigBytes=s+1}},s.pad.ZeroPadding)}),fe(function(e,t){var s;e.exports=((s=ve).pad.NoPadding={pad:function(){},unpad:function(){}},s.pad.NoPadding)}),fe(function(e,t){var s,n,o,i;e.exports=(o=(n=s=ve).lib.CipherParams,i=n.enc.Hex,n.format.Hex={stringify:function(e){return e.ciphertext.toString(i)},parse:function(e){var t=i.parse(e);return o.create({ciphertext:t})}},s.format.Hex)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.BlockCipher,n=e.algo,o=[],i=[],r=[],a=[],c=[],u=[],l=[],d=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var s=0,n=0;for(t=0;t<256;t++){var g=n^n<<1^n<<2^n<<3^n<<4;g=g>>>8^255&g^99,o[s]=g,i[g]=s;var _=e[s],m=e[_],f=e[m],v=257*e[g]^16843008*g;r[s]=v<<24|v>>>8,a[s]=v<<16|v>>>16,c[s]=v<<8|v>>>24,u[s]=v,v=16843009*f^65537*m^257*_^16843008*s,l[g]=v<<24|v>>>8,d[g]=v<<16|v>>>16,h[g]=v<<8|v>>>24,p[g]=v,s?(s=_^e[e[e[f^_]]],n^=e[e[n]]):s=n=1}}();var g=[0,1,2,4,8,16,32,64,128,27,54],_=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,s=e.sigBytes/4,n=4*((this._nRounds=s+6)+1),i=this._keySchedule=[],r=0;r<n;r++)if(r<s)i[r]=t[r];else{var a=i[r-1];r%s?s>6&&r%s==4&&(a=o[a>>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a]):(a=o[(a=a<<8|a>>>24)>>>24]<<24|o[a>>>16&255]<<16|o[a>>>8&255]<<8|o[255&a],a^=g[r/s|0]<<24),i[r]=i[r-s]^a}for(var c=this._invKeySchedule=[],u=0;u<n;u++)r=n-u,a=u%4?i[r]:i[r-4],c[u]=u<4||r<=4?a:l[o[a>>>24]]^d[o[a>>>16&255]]^h[o[a>>>8&255]]^p[o[255&a]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,r,a,c,u,o)},decryptBlock:function(e,t){var s=e[t+1];e[t+1]=e[t+3],e[t+3]=s,this._doCryptBlock(e,t,this._invKeySchedule,l,d,h,p,i),s=e[t+1],e[t+1]=e[t+3],e[t+3]=s},_doCryptBlock:function(e,t,s,n,o,i,r,a){for(var c=this._nRounds,u=e[t]^s[0],l=e[t+1]^s[1],d=e[t+2]^s[2],h=e[t+3]^s[3],p=4,g=1;g<c;g++){var _=n[u>>>24]^o[l>>>16&255]^i[d>>>8&255]^r[255&h]^s[p++],m=n[l>>>24]^o[d>>>16&255]^i[h>>>8&255]^r[255&u]^s[p++],f=n[d>>>24]^o[h>>>16&255]^i[u>>>8&255]^r[255&l]^s[p++],v=n[h>>>24]^o[u>>>16&255]^i[l>>>8&255]^r[255&d]^s[p++];u=_,l=m,d=f,h=v}_=(a[u>>>24]<<24|a[l>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^s[p++],m=(a[l>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^s[p++],f=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&l])^s[p++],v=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[l>>>8&255]<<8|a[255&d])^s[p++],e[t]=_,e[t+1]=m,e[t+2]=f,e[t+3]=v},keySize:8});e.AES=t._createHelper(_)}(),s.AES)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib,n=t.WordArray,o=t.BlockCipher,i=e.algo,r=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],d=i.DES=o.extend({_doReset:function(){for(var e=this._key.words,t=[],s=0;s<56;s++){var n=r[s]-1;t[s]=e[n>>>5]>>>31-n%32&1}for(var o=this._subKeys=[],i=0;i<16;i++){var u=o[i]=[],l=c[i];for(s=0;s<24;s++)u[s/6|0]|=t[(a[s]-1+l)%28]<<31-s%6,u[4+(s/6|0)]|=t[28+(a[s+24]-1+l)%28]<<31-s%6;for(u[0]=u[0]<<1|u[0]>>>31,s=1;s<7;s++)u[s]=u[s]>>>4*(s-1)+3;u[7]=u[7]<<5|u[7]>>>27}var d=this._invSubKeys=[];for(s=0;s<16;s++)d[s]=o[15-s]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,s){this._lBlock=e[t],this._rBlock=e[t+1],h.call(this,4,252645135),h.call(this,16,65535),p.call(this,2,858993459),p.call(this,8,16711935),h.call(this,1,1431655765);for(var n=0;n<16;n++){for(var o=s[n],i=this._lBlock,r=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((r^o[c])&l[c])>>>0];this._lBlock=r,this._rBlock=i^a}var d=this._lBlock;this._lBlock=this._rBlock,this._rBlock=d,h.call(this,1,1431655765),p.call(this,8,16711935),p.call(this,2,858993459),h.call(this,16,65535),h.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function h(e,t){var s=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=s,this._lBlock^=s<<e}function p(e,t){var s=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=s,this._rBlock^=s<<e}e.DES=o._createHelper(d);var g=i.TripleDES=o.extend({_doReset:function(){var e=this._key.words;this._des1=d.createEncryptor(n.create(e.slice(0,2))),this._des2=d.createEncryptor(n.create(e.slice(2,4))),this._des3=d.createEncryptor(n.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=o._createHelper(g)}(),s.TripleDES)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.StreamCipher,n=e.algo,o=n.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,s=e.sigBytes,n=this._S=[],o=0;o<256;o++)n[o]=o;o=0;for(var i=0;o<256;o++){var r=o%s,a=t[r>>>2]>>>24-r%4*8&255;i=(i+n[o]+a)%256;var c=n[o];n[o]=n[i],n[i]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=i.call(this)},keySize:8,ivSize:0});function i(){for(var e=this._S,t=this._i,s=this._j,n=0,o=0;o<4;o++){s=(s+e[t=(t+1)%256])%256;var i=e[t];e[t]=e[s],e[s]=i,n|=e[(e[t]+e[s])%256]<<24-8*o}return this._i=t,this._j=s,n}e.RC4=t._createHelper(o);var r=n.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)i.call(this)}});e.RC4Drop=t._createHelper(r)}(),s.RC4)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.StreamCipher,n=e.algo,o=[],i=[],r=[],a=n.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,s=0;s<4;s++)e[s]=16711935&(e[s]<<8|e[s]>>>24)|4278255360&(e[s]<<24|e[s]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],o=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,s=0;s<4;s++)c.call(this);for(s=0;s<8;s++)o[s]^=n[s+4&7];if(t){var i=t.words,r=i[0],a=i[1],u=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=u>>>16|4294901760&l,h=l<<16|65535&u;for(o[0]^=u,o[1]^=d,o[2]^=l,o[3]^=h,o[4]^=u,o[5]^=d,o[6]^=l,o[7]^=h,s=0;s<4;s++)c.call(this)}},_doProcessBlock:function(e,t){var s=this._X;c.call(this),o[0]=s[0]^s[5]>>>16^s[3]<<16,o[1]=s[2]^s[7]>>>16^s[5]<<16,o[2]=s[4]^s[1]>>>16^s[7]<<16,o[3]=s[6]^s[3]>>>16^s[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,s=0;s<8;s++)i[s]=t[s];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,s=0;s<8;s++){var n=e[s]+t[s],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);r[s]=c^u}e[0]=r[0]+(r[7]<<16|r[7]>>>16)+(r[6]<<16|r[6]>>>16)|0,e[1]=r[1]+(r[0]<<8|r[0]>>>24)+r[7]|0,e[2]=r[2]+(r[1]<<16|r[1]>>>16)+(r[0]<<16|r[0]>>>16)|0,e[3]=r[3]+(r[2]<<8|r[2]>>>24)+r[1]|0,e[4]=r[4]+(r[3]<<16|r[3]>>>16)+(r[2]<<16|r[2]>>>16)|0,e[5]=r[5]+(r[4]<<8|r[4]>>>24)+r[3]|0,e[6]=r[6]+(r[5]<<16|r[5]>>>16)+(r[4]<<16|r[4]>>>16)|0,e[7]=r[7]+(r[6]<<8|r[6]>>>24)+r[5]|0}e.Rabbit=t._createHelper(a)}(),s.Rabbit)}),fe(function(e,t){var s;e.exports=(s=ve,function(){var e=s,t=e.lib.StreamCipher,n=e.algo,o=[],i=[],r=[],a=n.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,s=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var o=0;o<4;o++)c.call(this);for(o=0;o<8;o++)n[o]^=s[o+4&7];if(t){var i=t.words,r=i[0],a=i[1],u=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=u>>>16|4294901760&l,h=l<<16|65535&u;for(n[0]^=u,n[1]^=d,n[2]^=l,n[3]^=h,n[4]^=u,n[5]^=d,n[6]^=l,n[7]^=h,o=0;o<4;o++)c.call(this)}},_doProcessBlock:function(e,t){var s=this._X;c.call(this),o[0]=s[0]^s[5]>>>16^s[3]<<16,o[1]=s[2]^s[7]>>>16^s[5]<<16,o[2]=s[4]^s[1]>>>16^s[7]<<16,o[3]=s[6]^s[3]>>>16^s[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,s=0;s<8;s++)i[s]=t[s];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,s=0;s<8;s++){var n=e[s]+t[s],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);r[s]=c^u}e[0]=r[0]+(r[7]<<16|r[7]>>>16)+(r[6]<<16|r[6]>>>16)|0,e[1]=r[1]+(r[0]<<8|r[0]>>>24)+r[7]|0,e[2]=r[2]+(r[1]<<16|r[1]>>>16)+(r[0]<<16|r[0]>>>16)|0,e[3]=r[3]+(r[2]<<8|r[2]>>>24)+r[1]|0,e[4]=r[4]+(r[3]<<16|r[3]>>>16)+(r[2]<<16|r[2]>>>16)|0,e[5]=r[5]+(r[4]<<8|r[4]>>>24)+r[3]|0,e[6]=r[6]+(r[5]<<16|r[5]>>>16)+(r[4]<<16|r[4]>>>16)|0,e[7]=r[7]+(r[6]<<8|r[6]>>>24)+r[5]|0}e.RabbitLegacy=t._createHelper(a)}(),s.RabbitLegacy)}),fe(function(e,t){e.exports=ve}));function Ee(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var ye=Ee,Ce=Se;function Me(e){if(ye===setTimeout)return setTimeout(e,0);if((ye===Ee||!ye)&&setTimeout)return ye=setTimeout,setTimeout(e,0);try{return ye(e,0)}catch(t){try{return ye.call(null,e,0)}catch(s){return ye.call(this,e,0)}}}"function"==typeof v.setTimeout&&(ye=setTimeout),"function"==typeof v.clearTimeout&&(Ce=clearTimeout);var Ae,be=[],Te=!1,Oe=-1;function we(){Te&&Ae&&(Te=!1,Ae.length?be=Ae.concat(be):Oe=-1,be.length&&De())}function De(){if(!Te){var e=Me(we);Te=!0;for(var t=be.length;t;){for(Ae=be,be=[];++Oe<t;)Ae&&Ae[Oe].run();Oe=-1,t=be.length}Ae=null,Te=!1,function(e){if(Ce===clearTimeout)return clearTimeout(e);if((Ce===Se||!Ce)&&clearTimeout)return Ce=clearTimeout,clearTimeout(e);try{Ce(e)}catch(t){try{return Ce.call(null,e)}catch(s){return Ce.call(this,e)}}}(e)}}function Re(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];be.push(new Le(e,t)),1!==be.length||Te||Me(De)}function Le(e,t){this.fun=e,this.array=t}Le.prototype.run=function(){this.fun.apply(null,this.array)};var Ne=v.performance||{};function Pe(){}function ke(){ke.init.call(this)}function Ge(e){return void 0===e._maxListeners?ke.defaultMaxListeners:e._maxListeners}function Ue(e,t,s,n){var o,i,r,a;if("function"!=typeof s)throw new TypeError('"listener" argument must be a function');if((i=e._events)?(i.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),i=e._events),r=i[t]):(i=e._events=new Pe,e._eventsCount=0),r){if("function"==typeof r?r=i[t]=n?[s,r]:[r,s]:n?r.unshift(s):r.push(s),!r.warned&&(o=Ge(e))&&o>0&&r.length>o){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=r.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else r=i[t]=s,++e._eventsCount;return e}function Fe(e,t,s){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,s.apply(e,arguments))}return o.listener=s,o}function xe(e){var t=this._events;if(t){var s=t[e];if("function"==typeof s)return 1;if(s)return s.length}return 0}function $e(e,t){for(var s=new Array(t);t--;)s[t]=e[t];return s}Ne.now||Ne.mozNow||Ne.msNow||Ne.oNow||Ne.webkitNow,Pe.prototype=Object.create(null),ke.EventEmitter=ke,ke.usingDomains=!1,ke.prototype.domain=void 0,ke.prototype._events=void 0,ke.prototype._maxListeners=void 0,ke.defaultMaxListeners=10,ke.init=function(){this.domain=null,ke.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Pe,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},ke.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},ke.prototype.getMaxListeners=function(){return Ge(this)},ke.prototype.emit=function(e){var t,s,n,o,i,r,a,c="error"===e;if(r=this._events)c=c&&null==r.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(s=r[e]))return!1;var l="function"==typeof s;switch(n=arguments.length){case 1:!function(e,t,s){if(t)e.call(s);else for(var n=e.length,o=$e(e,n),i=0;i<n;++i)o[i].call(s)}(s,l,this);break;case 2:!function(e,t,s,n){if(t)e.call(s,n);else for(var o=e.length,i=$e(e,o),r=0;r<o;++r)i[r].call(s,n)}(s,l,this,arguments[1]);break;case 3:!function(e,t,s,n,o){if(t)e.call(s,n,o);else for(var i=e.length,r=$e(e,i),a=0;a<i;++a)r[a].call(s,n,o)}(s,l,this,arguments[1],arguments[2]);break;case 4:!function(e,t,s,n,o,i){if(t)e.call(s,n,o,i);else for(var r=e.length,a=$e(e,r),c=0;c<r;++c)a[c].call(s,n,o,i)}(s,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,s,n){if(t)e.apply(s,n);else for(var o=e.length,i=$e(e,o),r=0;r<o;++r)i[r].apply(s,n)}(s,l,this,o)}return!0},ke.prototype.addListener=function(e,t){return Ue(this,e,t,!1)},ke.prototype.on=ke.prototype.addListener,ke.prototype.prependListener=function(e,t){return Ue(this,e,t,!0)},ke.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Fe(this,e,t)),this},ke.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Fe(this,e,t)),this},ke.prototype.removeListener=function(e,t){var s,n,o,i,r;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(s=n[e]))return this;if(s===t||s.listener&&s.listener===t)0==--this._eventsCount?this._events=new Pe:(delete n[e],n.removeListener&&this.emit("removeListener",e,s.listener||t));else if("function"!=typeof s){for(o=-1,i=s.length;i-- >0;)if(s[i]===t||s[i].listener&&s[i].listener===t){r=s[i].listener,o=i;break}if(o<0)return this;if(1===s.length){if(s[0]=void 0,0==--this._eventsCount)return this._events=new Pe,this;delete n[e]}else!function(e,t){for(var s=t,n=s+1,o=e.length;n<o;s+=1,n+=1)e[s]=e[n];e.pop()}(s,o);n.removeListener&&this.emit("removeListener",e,r||t)}return this},ke.prototype.removeAllListeners=function(e){var t,s;if(!(s=this._events))return this;if(!s.removeListener)return 0===arguments.length?(this._events=new Pe,this._eventsCount=0):s[e]&&(0==--this._eventsCount?this._events=new Pe:delete s[e]),this;if(0===arguments.length){for(var n,o=Object.keys(s),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Pe,this._eventsCount=0,this}if("function"==typeof(t=s[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},ke.prototype.listeners=function(e){var t,s=this._events;return s&&(t=s[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),s=0;s<t.length;++s)t[s]=e[s].listener||e[s];return t}(t):[]},ke.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):xe.call(e,t)},ke.prototype.listenerCount=xe,ke.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var qe="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e},Be=/%[sdj%]/g;function Ve(e){if(!st(e)){for(var t=[],s=0;s<arguments.length;s++)t.push(Ke(arguments[s]));return t.join(" ")}s=1;for(var n=arguments,o=n.length,i=String(e).replace(Be,function(e){if("%%"===e)return"%";if(s>=o)return e;switch(e){case"%s":return String(n[s++]);case"%d":return Number(n[s++]);case"%j":try{return JSON.stringify(n[s++])}catch(t){return"[Circular]"}default:return e}}),r=n[s];s<o;r=n[++s])et(r)||!it(r)?i+=" "+r:i+=" "+Ke(r);return i}function We(e,t){if(nt(v.process))return function(){return We(e,t).apply(this,arguments)};var s=!1;return function(){return s||(console.error(t),s=!0),e.apply(this,arguments)}}var je,He={};function Ke(e,t){var s={seen:[],stylize:ze};return arguments.length>=3&&(s.depth=arguments[2]),arguments.length>=4&&(s.colors=arguments[3]),Qe(t)?s.showHidden=t:t&&function(e,t){if(!t||!it(t))return e;for(var s=Object.keys(t),n=s.length;n--;)e[s[n]]=t[s[n]]}(s,t),nt(s.showHidden)&&(s.showHidden=!1),nt(s.depth)&&(s.depth=2),nt(s.colors)&&(s.colors=!1),nt(s.customInspect)&&(s.customInspect=!0),s.colors&&(s.stylize=Ye),Ze(s,e,s.depth)}function Ye(e,t){var s=Ke.styles[t];return s?"["+Ke.colors[s][0]+"m"+e+"["+Ke.colors[s][1]+"m":e}function ze(e,t){return e}function Ze(e,t,s){if(e.customInspect&&t&&ct(t.inspect)&&t.inspect!==Ke&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(s,e);return st(n)||(n=Ze(e,n,s)),n}var o=function(e,t){if(nt(t))return e.stylize("undefined","undefined");if(st(t)){var s="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(s,"string")}return"number"==typeof t?e.stylize(""+t,"number"):Qe(t)?e.stylize(""+t,"boolean"):et(t)?e.stylize("null","null"):void 0}(e,t);if(o)return o;var i,r=Object.keys(t),a=(i={},r.forEach(function(e,t){i[e]=!0}),i);if(e.showHidden&&(r=Object.getOwnPropertyNames(t)),at(t)&&(r.indexOf("message")>=0||r.indexOf("description")>=0))return Je(t);if(0===r.length){if(ct(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(ot(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(at(t))return Je(t)}var u,l,d="",h=!1,p=["{","}"];return u=t,Array.isArray(u)&&(h=!0,p=["[","]"]),ct(t)&&(d=" [Function"+(t.name?": "+t.name:"")+"]"),ot(t)&&(d=" "+RegExp.prototype.toString.call(t)),rt(t)&&(d=" "+Date.prototype.toUTCString.call(t)),at(t)&&(d=" "+Je(t)),0!==r.length||h&&0!=t.length?s<0?ot(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=h?function(e,t,s,n,o){for(var i=[],r=0,a=t.length;r<a;++r)lt(t,String(r))?i.push(Xe(e,t,s,n,String(r),!0)):i.push("");return o.forEach(function(o){o.match(/^\d+$/)||i.push(Xe(e,t,s,n,o,!0))}),i}(e,t,s,a,r):r.map(function(n){return Xe(e,t,s,a,n,h)}),e.seen.pop(),function(e,t,s){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?s[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+s[1]:s[0]+t+" "+e.join(", ")+" "+s[1]}(l,d,p)):p[0]+d+p[1]}function Je(e){return"["+Error.prototype.toString.call(e)+"]"}function Xe(e,t,s,n,o,i){var r,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),lt(n,o)||(r="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=et(s)?Ze(e,c.value,null):Ze(e,c.value,s-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),nt(r)){if(i&&o.match(/^\d+$/))return a;(r=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(r=r.substr(1,r.length-2),r=e.stylize(r,"name")):(r=r.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),r=e.stylize(r,"string"))}return r+": "+a}function Qe(e){return"boolean"==typeof e}function et(e){return null===e}function st(e){return"string"==typeof e}function nt(e){return void 0===e}function ot(e){return it(e)&&"[object RegExp]"===ut(e)}function it(e){return"object"==typeof e&&null!==e}function rt(e){return it(e)&&"[object Date]"===ut(e)}function at(e){return it(e)&&("[object Error]"===ut(e)||e instanceof Error)}function ct(e){return"function"==typeof e}function ut(e){return Object.prototype.toString.call(e)}function lt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function dt(){this.head=null,this.tail=null,this.length=0}Ke.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Ke.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},dt.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},dt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},dt.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},dt.prototype.clear=function(){this.head=this.tail=null,this.length=0},dt.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,s=""+t.data;t=t.next;)s+=e+t.data;return s},dt.prototype.concat=function(e){if(0===this.length)return L.alloc(0);if(1===this.length)return this.head.data;for(var t=L.allocUnsafe(e>>>0),s=this.head,n=0;s;)s.data.copy(t,n),n+=s.data.length,s=s.next;return t};var ht=L.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function pt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!ht(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=_t;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=mt;break;default:return void(this.write=gt)}this.charBuffer=new L(6),this.charReceived=0,this.charLength=0}function gt(e){return e.toString(this.encoding)}function _t(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function mt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}pt.prototype.write=function(e){for(var t="";this.charLength;){var s=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,s),this.charReceived+=s,this.charReceived<this.charLength)return"";if(e=e.slice(s,e.length),!((n=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n,o=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,o),o-=this.charReceived),o=(t+=e.toString(this.encoding,0,o)).length-1,(n=t.charCodeAt(o))>=55296&&n<=56319){var i=this.surrogateSize;return this.charLength+=i,this.charReceived+=i,this.charBuffer.copy(this.charBuffer,i,0,i),e.copy(this.charBuffer,0,0,i),t.substring(0,o)}return t},pt.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var s=e[e.length-t];if(1==t&&s>>5==6){this.charLength=2;break}if(t<=2&&s>>4==14){this.charLength=3;break}if(t<=3&&s>>3==30){this.charLength=4;break}}this.charReceived=t},pt.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var s=this.charReceived,n=this.charBuffer,o=this.encoding;t+=n.slice(0,s).toString(o)}return t},Et.ReadableState=It;var ft,vt=(ft="stream",nt(je)&&(je=""),ft=ft.toUpperCase(),He[ft]||(new RegExp("\\b"+ft+"\\b","i").test(je)?He[ft]=function(){var e=Ve.apply(null,arguments);console.error("%s %d: %s",ft,0,e)}:He[ft]=function(){}),He[ft]);function It(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Yt&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var s=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=s||0===s?s:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new dt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new pt(e.encoding),this.encoding=e.encoding)}function Et(e){if(!(this instanceof Et))return new Et(e);this._readableState=new It(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),ke.call(this)}function St(e,t,s,n,o){var i,r,a,c=(i=t,a=null,_e(r=s)||"string"==typeof r||null==r||i.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a);if(c)e.emit("error",c);else if(null===s)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var s=t.decoder.end();s&&s.length&&(t.buffer.push(s),t.length+=t.objectMode?1:s.length)}t.ended=!0,Mt(e)}}(e,t);else if(t.objectMode||s&&s.length>0)if(t.ended&&!o){var u=new Error("stream.push() after EOF");e.emit("error",u)}else if(t.endEmitted&&o){var l=new Error("stream.unshift() after end event");e.emit("error",l)}else{var d;!t.decoder||o||n||(s=t.decoder.write(s),d=!t.objectMode&&0===s.length),o||(t.reading=!1),d||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",s),e.read(0)):(t.length+=t.objectMode?1:s.length,o?t.buffer.unshift(s):t.buffer.push(s),t.needReadable&&Mt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Re(bt,e,t))}(e,t)}else o||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(t)}qe(Et,ke),Et.prototype.push=function(e,t){var s=this._readableState;return s.objectMode||"string"!=typeof e||(t=t||s.defaultEncoding)!==s.encoding&&(e=L.from(e,t),t=""),St(this,s,e,t,!1)},Et.prototype.unshift=function(e){return St(this,this._readableState,e,"",!0)},Et.prototype.isPaused=function(){return!1===this._readableState.flowing},Et.prototype.setEncoding=function(e){return this._readableState.decoder=new pt(e),this._readableState.encoding=e,this};var yt=8388608;function Ct(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=((s=e)>=yt?s=yt:(s--,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s++),s)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0));var s}function Mt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(vt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Re(At,e):At(e))}function At(e){vt("emit readable"),e.emit("readable"),wt(e)}function bt(e,t){for(var s=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(vt("maybeReadMore read 0"),e.read(0),s!==t.length);)s=t.length;t.readingMore=!1}function Tt(e){vt("readable nexttick read 0"),e.read(0)}function Ot(e,t){t.reading||(vt("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),wt(e),t.flowing&&!t.reading&&e.read(0)}function wt(e){var t=e._readableState;for(vt("flow",t.flowing);t.flowing&&null!==e.read(););}function Dt(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(s=e,n=t.buffer,o=t.decoder,s<n.head.data.length?(i=n.head.data.slice(0,s),n.head.data=n.head.data.slice(s)):i=s===n.head.data.length?n.shift():o?function(e,t){var s=t.head,n=1,o=s.data;for(e-=o.length;s=s.next;){var i=s.data,r=e>i.length?i.length:e;if(r===i.length?o+=i:o+=i.slice(0,e),0===(e-=r)){r===i.length?(++n,s.next?t.head=s.next:t.head=t.tail=null):(t.head=s,s.data=i.slice(r));break}++n}return t.length-=n,o}(s,n):function(e,t){var s=L.allocUnsafe(e),n=t.head,o=1;for(n.data.copy(s),e-=n.data.length;n=n.next;){var i=n.data,r=e>i.length?i.length:e;if(i.copy(s,s.length-e,0,r),0===(e-=r)){r===i.length?(++o,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(r));break}++o}return t.length-=o,s}(s,n),r=i),r);var s,n,o,i,r}function Rt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Re(Lt,t,e))}function Lt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Nt(e,t){for(var s=0,n=e.length;s<n;s++)if(e[s]===t)return s;return-1}function Pt(){}function kt(e,t,s){this.chunk=e,this.encoding=t,this.callback=s,this.next=null}function Gt(e,t){Object.defineProperty(this,"buffer",{get:We(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof Yt&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var s=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=s||0===s?s:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var o=!1===e.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var s,n=e._writableState,o=n.sync,i=n.writecb;if((s=n).writing=!1,s.writecb=null,s.length-=s.writelen,s.writelen=0,t)!function(e,t,s,n,o){--t.pendingcb,s?Re(o,n):o(n),e._writableState.errorEmitted=!0,e.emit("error",n)}(e,n,o,t,i);else{var r=qt(n);r||n.corked||n.bufferProcessing||!n.bufferedRequest||$t(e,n),o?Re(xt,e,n,r,i):xt(e,n,r,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Wt(this)}function Ut(e){if(!(this instanceof Ut||this instanceof Yt))return new Ut(e);this._writableState=new Gt(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),ke.call(this)}function Ft(e,t,s,n,o,i,r){t.writelen=n,t.writecb=r,t.writing=!0,t.sync=!0,s?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function xt(e,t,s,n){var o,i;s||(o=e,0===(i=t).length&&i.needDrain&&(i.needDrain=!1,o.emit("drain"))),t.pendingcb--,n(),Vt(e,t)}function $t(e,t){t.bufferProcessing=!0;var s=t.bufferedRequest;if(e._writev&&s&&s.next){var n=t.bufferedRequestCount,o=new Array(n),i=t.corkedRequestsFree;i.entry=s;for(var r=0;s;)o[r]=s,s=s.next,r+=1;Ft(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new Wt(t)}else{for(;s;){var a=s.chunk,c=s.encoding,u=s.callback;if(Ft(e,t,!1,t.objectMode?1:a.length,a,c,u),s=s.next,t.writing)break}null===s&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=s,t.bufferProcessing=!1}function qt(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Bt(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Vt(e,t){var s=qt(t);return s&&(0===t.pendingcb?(Bt(e,t),t.finished=!0,e.emit("finish")):Bt(e,t)),s}function Wt(e){var t=this;this.next=null,this.entry=null,this.finish=function(s){var n=t.entry;for(t.entry=null;n;){var o=n.callback;e.pendingcb--,o(s),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}Et.prototype.read=function(e){vt("read",e),e=parseInt(e,10);var t=this._readableState,s=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return vt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Rt(this):Mt(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Rt(this),null;var n,o=t.needReadable;return vt("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&vt("length less than watermark",o=!0),t.ended||t.reading?vt("reading or ended",o=!1):o&&(vt("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Ct(s,t))),null===(n=e>0?Dt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),s!==e&&t.ended&&Rt(this)),null!==n&&this.emit("data",n),n},Et.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Et.prototype.pipe=function(e,t){var s=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,vt("pipe count=%d opts=%j",n.pipesCount,t);var o=t&&!1===t.end?l:r;function i(e){vt("onunpipe"),e===s&&l()}function r(){vt("onend"),e.end()}n.endEmitted?Re(o):s.once("end",o),e.on("unpipe",i);var a,c=(a=s,function(){var e=a._readableState;vt("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a.listeners("data").length&&(e.flowing=!0,wt(a))});e.on("drain",c);var u=!1;function l(){vt("cleanup"),e.removeListener("close",g),e.removeListener("finish",_),e.removeListener("drain",c),e.removeListener("error",p),e.removeListener("unpipe",i),s.removeListener("end",r),s.removeListener("end",l),s.removeListener("data",h),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}var d=!1;function h(t){vt("ondata"),d=!1,!1!==e.write(t)||d||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Nt(n.pipes,e))&&!u&&(vt("false write response, pause",s._readableState.awaitDrain),s._readableState.awaitDrain++,d=!0),s.pause())}function p(t){vt("onerror",t),m(),e.removeListener("error",p),0===e.listeners("error").length&&e.emit("error",t)}function g(){e.removeListener("finish",_),m()}function _(){vt("onfinish"),e.removeListener("close",g),m()}function m(){vt("unpipe"),s.unpipe(e)}return s.on("data",h),function(e,t,s){if("function"==typeof e.prependListener)return e.prependListener(t,s);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(s):e._events[t]=[s,e._events[t]]:e.on(t,s)}(e,"error",p),e.once("close",g),e.once("finish",_),e.emit("pipe",s),n.flowing||(vt("pipe resume"),s.resume()),e},Et.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var s=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)s[o].emit("unpipe",this);return this}var i=Nt(t.pipes,e);return-1===i||(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},Et.prototype.on=function(e,t){var s=ke.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&Mt(this):Re(Tt,this))}return s},Et.prototype.addListener=Et.prototype.on,Et.prototype.resume=function(){var e,t,s=this._readableState;return s.flowing||(vt("resume"),s.flowing=!0,e=this,(t=s).resumeScheduled||(t.resumeScheduled=!0,Re(Ot,e,t))),this},Et.prototype.pause=function(){return vt("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(vt("pause"),this._readableState.flowing=!1,this.emit("pause")),this},Et.prototype.wrap=function(e){var t=this._readableState,s=!1,n=this;for(var o in e.on("end",function(){if(vt("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&n.push(e)}n.push(null)}),e.on("data",function(o){vt("wrapped data"),t.decoder&&(o=t.decoder.write(o)),t.objectMode&&null==o||(t.objectMode||o&&o.length)&&(n.push(o)||(s=!0,e.pause()))}),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));return function(e,t){for(var s=0,n=e.length;s<n;s++)t(e[s])}(["error","close","destroy","pause","resume"],function(t){e.on(t,n.emit.bind(n,t))}),n._read=function(t){vt("wrapped _read",t),s&&(s=!1,e.resume())},n},Et._fromList=Dt,Ut.WritableState=Gt,qe(Ut,ke),Gt.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},Ut.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ut.prototype.write=function(e,t,s){var n,o,i,r=this._writableState,a=!1;return"function"==typeof t&&(s=t,t=null),L.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof s&&(s=Pt),r.ended?(n=this,o=s,i=new Error("write after end"),n.emit("error",i),Re(o,i)):function(e,t,s,n){var o=!0,i=!1;return null===s?i=new TypeError("May not write null values to stream"):L.isBuffer(s)||"string"==typeof s||void 0===s||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),Re(n,i),o=!1),o}(this,r,e,s)&&(r.pendingcb++,a=function(e,t,s,n,o){var i,r,a;r=s,a=n,(i=t).objectMode||!1===i.decodeStrings||"string"!=typeof r||(r=L.from(r,a)),s=r,L.isBuffer(s)&&(n="buffer");var c=t.objectMode?1:s.length;t.length+=c;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest=new kt(s,n,o),l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Ft(e,t,!1,c,s,n,o);return u}(this,r,e,t,s)),a},Ut.prototype.cork=function(){this._writableState.corked++},Ut.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||$t(this,e))},Ut.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Ut.prototype._write=function(e,t,s){s(new Error("not implemented"))},Ut.prototype._writev=null,Ut.prototype.end=function(e,t,s){var n,o,i,r=this._writableState;"function"==typeof e?(s=e,e=null,t=null):"function"==typeof t&&(s=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||(n=this,i=s,(o=r).ending=!0,Vt(n,o),i&&(o.finished?Re(i):n.once("finish",i)),o.ended=!0,n.writable=!1)},qe(Yt,Et);for(var jt=Object.keys(Ut.prototype),Ht=0;Ht<jt.length;Ht++){var Kt=jt[Ht];Yt.prototype[Kt]||(Yt.prototype[Kt]=Ut.prototype[Kt])}function Yt(e){if(!(this instanceof Yt))return new Yt(e);Et.call(this,e),Ut.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",zt)}function zt(){this.allowHalfOpen||this._writableState.ended||Re(Zt,this)}function Zt(e){e.end()}function Jt(e){this.afterTransform=function(t,s){return function(e,t,s){var n=e._transformState;n.transforming=!1;var o=n.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!=s&&e.push(s),o(t);var i=e._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&e._read(i.highWaterMark)}(e,t,s)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Xt(e){if(!(this instanceof Xt))return new Xt(e);Yt.call(this,e),this._transformState=new Jt(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(e){Qt(t,e)}):Qt(t)})}function Qt(e,t){if(t)return e.emit("error",t);var s=e._writableState,n=e._transformState;if(s.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}function es(e){if(!(this instanceof es))return new es(e);Xt.call(this,e)}function ts(){ke.call(this)}qe(Xt,Yt),Xt.prototype.push=function(e,t){return this._transformState.needTransform=!1,Yt.prototype.push.call(this,e,t)},Xt.prototype._transform=function(e,t,s){throw new Error("Not implemented")},Xt.prototype._write=function(e,t,s){var n=this._transformState;if(n.writecb=s,n.writechunk=e,n.writeencoding=t,!n.transforming){var o=this._readableState;(n.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},Xt.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},qe(es,Xt),es.prototype._transform=function(e,t,s){s(null,e)},qe(ts,ke),ts.Readable=Et,ts.Writable=Ut,ts.Duplex=Yt,ts.Transform=Xt,ts.PassThrough=es,ts.Stream=ts,ts.prototype.pipe=function(e,t){var s=this;function n(t){e.writable&&!1===e.write(t)&&s.pause&&s.pause()}function o(){s.readable&&s.resume&&s.resume()}s.on("data",n),e.on("drain",o),e._isStdio||t&&!1===t.end||(s.on("end",r),s.on("close",a));var i=!1;function r(){i||(i=!0,e.end())}function a(){i||(i=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(u(),0===ke.listenerCount(this,"error"))throw e}function u(){s.removeListener("data",n),e.removeListener("drain",o),s.removeListener("end",r),s.removeListener("close",a),s.removeListener("error",c),e.removeListener("error",c),s.removeListener("end",u),s.removeListener("close",u),e.removeListener("close",u)}return s.on("error",c),e.on("error",c),s.on("end",u),s.on("close",u),e.on("close",u),e.emit("pipe",s),e};var ss={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"};function ns(){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}function os(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]}var is=Uint8Array,rs=Uint16Array,as=Int32Array;function cs(e){for(var t=e.length;--t>=0;)e[t]=0}var us=256,ls=286,ds=30,hs=15,ps=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],gs=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],_s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ms=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],fs=new Array(576);cs(fs);var vs=new Array(60);cs(vs);var Is=new Array(512);cs(Is);var Es=new Array(256);cs(Es);var Ss=new Array(29);cs(Ss);var ys,Cs,Ms,As=new Array(ds);function bs(e,t,s,n,o){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=n,this.max_length=o,this.has_stree=e&&e.length}function Ts(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Os(e){return e<256?Is[e]:Is[256+(e>>>7)]}function ws(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Ds(e,t,s){e.bi_valid>16-s?(e.bi_buf|=t<<e.bi_valid&65535,ws(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=s)}function Rs(e,t,s){Ds(e,s[2*t],s[2*t+1])}function Ls(e,t){var s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1}function Ns(e,t,s){var n,o,i=new Array(16),r=0;for(n=1;n<=hs;n++)i[n]=r=r+s[n-1]<<1;for(o=0;o<=t;o++){var a=e[2*o+1];0!==a&&(e[2*o]=Ls(i[a]++,a))}}function Ps(e){var t;for(t=0;t<ls;t++)e.dyn_ltree[2*t]=0;for(t=0;t<ds;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function ks(e){e.bi_valid>8?ws(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Gs(e,t,s,n){var o=2*t,i=2*s;return e[o]<e[i]||e[o]===e[i]&&n[t]<=n[s]}function Us(e,t,s){for(var n=e.heap[s],o=s<<1;o<=e.heap_len&&(o<e.heap_len&&Gs(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!Gs(t,n,e.heap[o],e.depth));)e.heap[s]=e.heap[o],s=o,o<<=1;e.heap[s]=n}function Fs(e,t,s){var n,o,i,r,a=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],o=e.pending_buf[e.l_buf+a],a++,0===n?Rs(e,o,t):(Rs(e,(i=Es[o])+us+1,t),0!==(r=ps[i])&&Ds(e,o-=Ss[i],r),Rs(e,i=Os(--n),s),0!==(r=gs[i])&&Ds(e,n-=As[i],r))}while(a<e.last_lit);Rs(e,256,t)}function xs(e,t){var s,n,o,i=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<c;s++)0!==i[2*s]?(e.heap[++e.heap_len]=u=s,e.depth[s]=0):i[2*s+1]=0;for(;e.heap_len<2;)i[2*(o=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[o]=0,e.opt_len--,a&&(e.static_len-=r[2*o+1]);for(t.max_code=u,s=e.heap_len>>1;s>=1;s--)Us(e,i,s);o=c;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Us(e,i,1),n=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=n,i[2*o]=i[2*s]+i[2*n],e.depth[o]=(e.depth[s]>=e.depth[n]?e.depth[s]:e.depth[n])+1,i[2*s+1]=i[2*n+1]=o,e.heap[1]=o++,Us(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var s,n,o,i,r,a,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,_=0;for(i=0;i<=hs;i++)e.bl_count[i]=0;for(c[2*e.heap[e.heap_max]+1]=0,s=e.heap_max+1;s<573;s++)(i=c[2*c[2*(n=e.heap[s])+1]+1]+1)>g&&(i=g,_++),c[2*n+1]=i,n>u||(e.bl_count[i]++,r=0,n>=p&&(r=h[n-p]),a=c[2*n],e.opt_len+=a*(i+r),d&&(e.static_len+=a*(l[2*n+1]+r)));if(0!==_){do{for(i=g-1;0===e.bl_count[i];)i--;e.bl_count[i]--,e.bl_count[i+1]+=2,e.bl_count[g]--,_-=2}while(_>0);for(i=g;0!==i;i--)for(n=e.bl_count[i];0!==n;)(o=e.heap[--s])>u||(c[2*o+1]!==i&&(e.opt_len+=(i-c[2*o+1])*c[2*o],c[2*o+1]=i),n--)}}(e,t),Ns(i,u,e.bl_count)}function $s(e,t,s){var n,o,i=-1,r=t[1],a=0,c=7,u=4;for(0===r&&(c=138,u=3),t[2*(s+1)+1]=65535,n=0;n<=s;n++)o=r,r=t[2*(n+1)+1],++a<c&&o===r||(a<u?e.bl_tree[2*o]+=a:0!==o?(o!==i&&e.bl_tree[2*o]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,i=o,0===r?(c=138,u=3):o===r?(c=6,u=3):(c=7,u=4))}function qs(e,t,s){var n,o,i=-1,r=t[1],a=0,c=7,u=4;for(0===r&&(c=138,u=3),n=0;n<=s;n++)if(o=r,r=t[2*(n+1)+1],!(++a<c&&o===r)){if(a<u)do{Rs(e,o,e.bl_tree)}while(0!=--a);else 0!==o?(o!==i&&(Rs(e,o,e.bl_tree),a--),Rs(e,16,e.bl_tree),Ds(e,a-3,2)):a<=10?(Rs(e,17,e.bl_tree),Ds(e,a-3,3)):(Rs(e,18,e.bl_tree),Ds(e,a-11,7));a=0,i=o,0===r?(c=138,u=3):o===r?(c=6,u=3):(c=7,u=4)}}cs(As);var Bs=!1;function Vs(e,t,s,n){var o,i,r;Ds(e,0+(n?1:0),3),i=t,r=s,ks(o=e),ws(o,r),ws(o,~r),os(o.pending_buf,o.window,i,r,o.pending),o.pending+=r}function Ws(e,t,s){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&s,e.last_lit++,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(Es[s]+us+1)]++,e.dyn_dtree[2*Os(t)]++),e.last_lit===e.lit_bufsize-1}function js(e,t,s,n){for(var o=65535&e,i=e>>>16&65535,r=0;0!==s;){s-=r=s>2e3?2e3:s;do{i=i+(o=o+t[n++]|0)|0}while(--r);o%=65521,i%=65521}return o|i<<16}var Hs=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}();function Ks(e,t,s,n){var o=Hs,i=n+s;e^=-1;for(var r=n;r<i;r++)e=e>>>8^o[255&(e^t[r])];return-1^e}var Ys,zs=-2,Zs=258,Js=262,Xs=103,Qs=113,en=666;function tn(e,t){return e.msg=ss[t],t}function sn(e){return(e<<1)-(e>4?9:0)}function nn(e){for(var t=e.length;--t>=0;)e[t]=0}function on(e){var t=e.state,s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(os(e.output,t.pending_buf,t.pending_out,s,e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))}function rn(e,t){(function(e,t,s,n){var o,i,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<us;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),xs(e,e.l_desc),xs(e,e.d_desc),r=function(e){var t;for($s(e,e.dyn_ltree,e.l_desc.max_code),$s(e,e.dyn_dtree,e.d_desc.max_code),xs(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*ms[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(i=e.static_len+3+7>>>3)<=o&&(o=i)):o=i=s+5,s+4<=o&&-1!==t?Vs(e,t,s,n):4===e.strategy||i===o?(Ds(e,2+(n?1:0),3),Fs(e,fs,vs)):(Ds(e,4+(n?1:0),3),function(e,t,s,n){var o;for(Ds(e,t-257,5),Ds(e,s-1,5),Ds(e,n-4,4),o=0;o<n;o++)Ds(e,e.bl_tree[2*ms[o]+1],3);qs(e,e.dyn_ltree,t-1),qs(e,e.dyn_dtree,s-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),Fs(e,e.dyn_ltree,e.dyn_dtree)),Ps(e),n&&ks(e)})(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,on(e.strm)}function an(e,t){e.pending_buf[e.pending++]=t}function cn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function un(e,t){var s,n,o=e.max_chain_length,i=e.strstart,r=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-Js?e.strstart-(e.w_size-Js):0,u=e.window,l=e.w_mask,d=e.prev,h=e.strstart+Zs,p=u[i+r-1],g=u[i+r];e.prev_length>=e.good_match&&(o>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(s=t)+r]===g&&u[s+r-1]===p&&u[s]===u[i]&&u[++s]===u[i+1]){i+=2,s++;do{}while(u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&u[++i]===u[++s]&&i<h);if(n=Zs-(h-i),i=h-Zs,n>r){if(e.match_start=t,r=n,n>=a)break;p=u[i+r-1],g=u[i+r]}}}while((t=d[t&l])>c&&0!=--o);return r<=e.lookahead?r:e.lookahead}function ln(e){var t,s,n,o,i,r,a,c,u,l,d=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=d+(d-Js)){os(e.window,e.window,d,d,0),e.match_start-=d,e.strstart-=d,e.block_start-=d,t=s=e.hash_size;do{n=e.head[--t],e.head[t]=n>=d?n-d:0}while(--s);t=s=d;do{n=e.prev[--t],e.prev[t]=n>=d?n-d:0}while(--s);o+=d}if(0===e.strm.avail_in)break;if(r=e.strm,a=e.window,c=e.strstart+e.lookahead,u=o,l=void 0,(l=r.avail_in)>u&&(l=u),s=0===l?0:(r.avail_in-=l,os(a,r.input,r.next_in,l,c),1===r.state.wrap?r.adler=js(r.adler,a,l,c):2===r.state.wrap&&(r.adler=Ks(r.adler,a,l,c)),r.next_in+=l,r.total_in+=l,l),e.lookahead+=s,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[i+3-1])&e.hash_mask,e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Js&&0!==e.strm.avail_in)}function dn(e,t){for(var s,n;;){if(e.lookahead<Js){if(ln(e),e.lookahead<Js&&0===t)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-Js&&(e.match_length=un(e,s)),e.match_length>=3)if(n=Ws(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=Ws(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(rn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(rn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(rn(e,!1),0===e.strm.avail_out)?1:2}function hn(e,t){for(var s,n,o;;){if(e.lookahead<Js){if(ln(e),e.lookahead<Js&&0===t)return 1;if(0===e.lookahead)break}if(s=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==s&&e.prev_length<e.max_lazy_match&&e.strstart-s<=e.w_size-Js&&(e.match_length=un(e,s),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-3,n=Ws(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(rn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Ws(e,0,e.window[e.strstart-1]))&&rn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ws(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(rn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(rn(e,!1),0===e.strm.avail_out)?1:2}function pn(e,t,s,n,o){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=n,this.func=o}function gn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new rs(1146),this.dyn_dtree=new rs(122),this.bl_tree=new rs(78),nn(this.dyn_ltree),nn(this.dyn_dtree),nn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new rs(16),this.heap=new rs(573),nn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new rs(573),nn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function _n(e){var t,s,n,o=(s=e)&&s.state?(s.total_in=s.total_out=0,s.data_type=2,(n=s.state).pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap?42:Qs,s.adler=2===n.wrap?0:1,n.last_flush=0,function(e){Bs||(function(){var e,t,s,n,o,i=new Array(16);for(s=0,n=0;n<28;n++)for(Ss[n]=s,e=0;e<1<<ps[n];e++)Es[s++]=n;for(Es[s-1]=n,o=0,n=0;n<16;n++)for(As[n]=o,e=0;e<1<<gs[n];e++)Is[o++]=n;for(o>>=7;n<ds;n++)for(As[n]=o<<7,e=0;e<1<<gs[n]-7;e++)Is[256+o++]=n;for(t=0;t<=hs;t++)i[t]=0;for(e=0;e<=143;)fs[2*e+1]=8,e++,i[8]++;for(;e<=255;)fs[2*e+1]=9,e++,i[9]++;for(;e<=279;)fs[2*e+1]=7,e++,i[7]++;for(;e<=287;)fs[2*e+1]=8,e++,i[8]++;for(Ns(fs,287,i),e=0;e<ds;e++)vs[2*e+1]=5,vs[2*e]=Ls(e,5);ys=new bs(fs,ps,257,ls,hs),Cs=new bs(vs,gs,0,ds,hs),Ms=new bs(new Array(0),_s,0,19,7)}(),Bs=!0),e.l_desc=new Ts(e.dyn_ltree,ys),e.d_desc=new Ts(e.dyn_dtree,Cs),e.bl_desc=new Ts(e.bl_tree,Ms),e.bi_buf=0,e.bi_valid=0,Ps(e)}(n),0):tn(s,zs);return 0===o&&((t=e.state).window_size=2*t.w_size,nn(t.head),t.max_lazy_match=Ys[t.level].max_lazy,t.good_match=Ys[t.level].good_length,t.nice_match=Ys[t.level].nice_length,t.max_chain_length=Ys[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),o}function mn(e,t){var s,n,o,i;if(!e||!e.state||t>5||t<0)return e?tn(e,zs):zs;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===en&&4!==t)return tn(e,0===e.avail_out?-5:zs);if(n.strm=e,s=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,an(n,31),an(n,139),an(n,8),n.gzhead?(an(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),an(n,255&n.gzhead.time),an(n,n.gzhead.time>>8&255),an(n,n.gzhead.time>>16&255),an(n,n.gzhead.time>>24&255),an(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),an(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(an(n,255&n.gzhead.extra.length),an(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ks(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(an(n,0),an(n,0),an(n,0),an(n,0),an(n,0),an(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),an(n,3),n.status=Qs);else{var r=8+(n.w_bits-8<<4)<<8;r|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(r|=32),r+=31-r%31,n.status=Qs,cn(n,r),0!==n.strstart&&(cn(n,e.adler>>>16),cn(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),on(e),o=n.pending,n.pending!==n.pending_buf_size));)an(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),on(e),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,an(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),on(e),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,an(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ks(e.adler,n.pending_buf,n.pending-o,o)),0===i&&(n.status=Xs)}else n.status=Xs;if(n.status===Xs&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&on(e),n.pending+2<=n.pending_buf_size&&(an(n,255&e.adler),an(n,e.adler>>8&255),e.adler=0,n.status=Qs)):n.status=Qs),0!==n.pending){if(on(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&sn(t)<=sn(s)&&4!==t)return tn(e,-5);if(n.status===en&&0!==e.avail_in)return tn(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==en){var a=2===n.strategy?function(e,t){for(var s;;){if(0===e.lookahead&&(ln(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,s=Ws(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(rn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(rn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(rn(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var s,n,o,i,r=e.window;;){if(e.lookahead<=Zs){if(ln(e),e.lookahead<=Zs&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=r[o=e.strstart-1])===r[++o]&&n===r[++o]&&n===r[++o]){i=e.strstart+Zs;do{}while(n===r[++o]&&n===r[++o]&&n===r[++o]&&n===r[++o]&&n===r[++o]&&n===r[++o]&&n===r[++o]&&n===r[++o]&&o<i);e.match_length=Zs-(i-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=Ws(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=Ws(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(rn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(rn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(rn(e,!1),0===e.strm.avail_out)?1:2}(n,t):Ys[n.level].func(n,t);if(3!==a&&4!==a||(n.status=en),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===a&&(1===t?function(e){var t;Ds(e,2,3),Rs(e,256,fs),16===(t=e).bi_valid?(ws(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(n):5!==t&&(Vs(n,0,0,!1),3===t&&(nn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),on(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(an(n,255&e.adler),an(n,e.adler>>8&255),an(n,e.adler>>16&255),an(n,e.adler>>24&255),an(n,255&e.total_in),an(n,e.total_in>>8&255),an(n,e.total_in>>16&255),an(n,e.total_in>>24&255)):(cn(n,e.adler>>>16),cn(n,65535&e.adler)),on(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)}Ys=[new pn(0,0,0,0,function(e,t){var s=65535;for(s>e.pending_buf_size-5&&(s=e.pending_buf_size-5);;){if(e.lookahead<=1){if(ln(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+s;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,rn(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-Js&&(rn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(rn(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(rn(e,!1),e.strm.avail_out),1)}),new pn(4,4,8,4,dn),new pn(4,5,16,8,dn),new pn(4,6,32,32,dn),new pn(4,4,16,16,hn),new pn(8,16,32,32,hn),new pn(8,16,128,128,hn),new pn(8,32,128,256,hn),new pn(32,128,258,1024,hn),new pn(32,258,258,4096,hn)];function fn(e,t){var s,n,o,i,r,a,c,u,l,d,h,p,g,_,m,f,v,I,E,S,y,C,M,A,b;s=e.state,n=e.next_in,A=e.input,o=n+(e.avail_in-5),i=e.next_out,b=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,u=s.wsize,l=s.whave,d=s.wnext,h=s.window,p=s.hold,g=s.bits,_=s.lencode,m=s.distcode,f=(1<<s.lenbits)-1,v=(1<<s.distbits)-1;e:do{g<15&&(p+=A[n++]<<g,g+=8,p+=A[n++]<<g,g+=8),I=_[p&f];t:for(;;){if(p>>>=E=I>>>24,g-=E,0==(E=I>>>16&255))b[i++]=65535&I;else{if(!(16&E)){if(!(64&E)){I=_[(65535&I)+(p&(1<<E)-1)];continue t}if(32&E){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}S=65535&I,(E&=15)&&(g<E&&(p+=A[n++]<<g,g+=8),S+=p&(1<<E)-1,p>>>=E,g-=E),g<15&&(p+=A[n++]<<g,g+=8,p+=A[n++]<<g,g+=8),I=m[p&v];s:for(;;){if(p>>>=E=I>>>24,g-=E,!(16&(E=I>>>16&255))){if(!(64&E)){I=m[(65535&I)+(p&(1<<E)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(y=65535&I,g<(E&=15)&&(p+=A[n++]<<g,(g+=8)<E&&(p+=A[n++]<<g,g+=8)),(y+=p&(1<<E)-1)>c){e.msg="invalid distance too far back",s.mode=30;break e}if(p>>>=E,g-=E,y>(E=i-r)){if((E=y-E)>l&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(C=0,M=h,0===d){if(C+=u-E,E<S){S-=E;do{b[i++]=h[C++]}while(--E);C=i-y,M=b}}else if(d<E){if(C+=u+d-E,(E-=d)<S){S-=E;do{b[i++]=h[C++]}while(--E);if(C=0,d<S){S-=E=d;do{b[i++]=h[C++]}while(--E);C=i-y,M=b}}}else if(C+=d-E,E<S){S-=E;do{b[i++]=h[C++]}while(--E);C=i-y,M=b}for(;S>2;)b[i++]=M[C++],b[i++]=M[C++],b[i++]=M[C++],S-=3;S&&(b[i++]=M[C++],S>1&&(b[i++]=M[C++]))}else{C=i-y;do{b[i++]=b[C++],b[i++]=b[C++],b[i++]=b[C++],S-=3}while(S>2);S&&(b[i++]=b[C++],S>1&&(b[i++]=b[C++]))}break}}break}}while(n<o&&i<a);n-=S=g>>3,p&=(1<<(g-=S<<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=p,s.bits=g}var vn=15,In=[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],En=[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],Sn=[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],yn=[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];function Cn(e,t,s,n,o,i,r,a){var c,u,l,d,h,p,g,_,m,f=a.bits,v=0,I=0,E=0,S=0,y=0,C=0,M=0,A=0,b=0,T=0,O=null,w=0,D=new rs(16),R=new rs(16),L=null,N=0;for(v=0;v<=vn;v++)D[v]=0;for(I=0;I<n;I++)D[t[s+I]]++;for(y=f,S=vn;S>=1&&0===D[S];S--);if(y>S&&(y=S),0===S)return o[i++]=20971520,o[i++]=20971520,a.bits=1,0;for(E=1;E<S&&0===D[E];E++);for(y<E&&(y=E),A=1,v=1;v<=vn;v++)if(A<<=1,(A-=D[v])<0)return-1;if(A>0&&(0===e||1!==S))return-1;for(R[1]=0,v=1;v<vn;v++)R[v+1]=R[v]+D[v];for(I=0;I<n;I++)0!==t[s+I]&&(r[R[t[s+I]]++]=I);if(0===e?(O=L=r,p=19):1===e?(O=In,w-=257,L=En,N-=257,p=256):(O=Sn,L=yn,p=-1),T=0,I=0,v=E,h=i,C=y,M=0,l=-1,d=(b=1<<y)-1,1===e&&b>852||2===e&&b>592)return 1;for(;;){g=v-M,r[I]<p?(_=0,m=r[I]):r[I]>p?(_=L[N+r[I]],m=O[w+r[I]]):(_=96,m=0),c=1<<v-M,E=u=1<<C;do{o[h+(T>>M)+(u-=c)]=g<<24|_<<16|m}while(0!==u);for(c=1<<v-1;T&c;)c>>=1;if(0!==c?(T&=c-1,T+=c):T=0,I++,0==--D[v]){if(v===S)break;v=t[s+r[I]]}if(v>y&&(T&d)!==l){for(0===M&&(M=y),h+=E,A=1<<(C=v-M);C+M<S&&!((A-=D[C+M])<=0);)C++,A<<=1;if(b+=1<<C,1===e&&b>852||2===e&&b>592)return 1;o[l=T&d]=y<<24|C<<16|h-i}}return 0!==T&&(o[h+T]=v-M<<24|64<<16),a.bits=y,0}var Mn=-2,An=12,bn=30;function Tn(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function On(){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 rs(320),this.work=new rs(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function wn(e){var t,s,n;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,(s=e)&&s.state?(n=s.state,s.total_in=s.total_out=n.total=0,s.msg="",n.wrap&&(s.adler=1&n.wrap),n.mode=1,n.last=0,n.havedict=0,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new as(852),n.distcode=n.distdyn=new as(592),n.sane=1,n.back=-1,0):Mn):Mn}var Dn,Rn,Ln=!0;function Nn(e){if(Ln){var t;for(Dn=new as(512),Rn=new as(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(Cn(1,e.lens,0,288,Dn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Cn(2,e.lens,0,32,Rn,0,e.work,{bits:5}),Ln=!1}e.lencode=Dn,e.lenbits=9,e.distcode=Rn,e.distbits=5}var Pn;function kn(e){if(e<1||e>7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function Gn(e,t){for(var s=0;s<e.length;s++)this[t+s]=e[s]}kn.prototype.init=function(e,t,s,n,o){var i;switch(this.windowBits=e,this.level=t,this.memLevel=s,this.strategy=n,3!==this.mode&&4!==this.mode||(this.windowBits+=16),7===this.mode&&(this.windowBits+=32),5!==this.mode&&6!==this.mode||(this.windowBits=-this.windowBits),this.strm=new ns,this.mode){case 1:case 3:case 5:i=function(e,t,s,n,o,i){if(!e)return zs;var r=1;if(-1===t&&(t=6),n<0?(r=0,n=-n):n>15&&(r=2,n-=16),o<1||o>9||n<8||n>15||t<0||t>9||i<0||i>4)return tn(e,zs);8===n&&(n=9);var a=new gn;return e.state=a,a.strm=e,a.wrap=r,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new is(2*a.w_size),a.head=new rs(a.hash_size),a.prev=new rs(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new is(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=i,a.method=8,_n(e)}(this.strm,this.level,0,this.windowBits,this.memLevel,this.strategy);break;case 2:case 4:case 6:case 7:i=function(e,t){var s,n,o,i,r,a;return e?(n=new On,e.state=n,n.window=null,0!==(i=t,s=(o=e)&&o.state?(a=o.state,i<0?(r=0,i=-i):(r=1+(i>>4),i<48&&(i&=15)),i&&(i<8||i>15)?Mn:(null!==a.window&&a.wbits!==i&&(a.window=null),a.wrap=r,a.wbits=i,wn(o))):Mn)&&(e.state=null),s):Mn}(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===i?(this.write_in_progress=!1,this.init_done=!0):this._error(i)},kn.prototype.params=function(){throw new Error("deflateParams Not supported")},kn.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},kn.prototype.write=function(e,t,s,n,o,i,r){this._writeCheck(),this.write_in_progress=!0;var a=this;return Re(function(){a.write_in_progress=!1;var c=a._write(e,t,s,n,o,i,r);a.callback(c[0],c[1]),a.pending_close&&a.close()}),this},kn.prototype.writeSync=function(e,t,s,n,o,i,r){return this._writeCheck(),this._write(e,t,s,n,o,i,r)},kn.prototype._write=function(e,t,s,n,o,i,r){if(this.write_in_progress=!0,0!==e&&1!==e&&2!==e&&3!==e&&4!==e&&5!==e)throw new Error("Invalid flush value");null==t&&(t=new L(0),n=0,s=0),o._set?o.set=o._set:o.set=Gn;var a,c=this.strm;switch(c.avail_in=n,c.input=t,c.next_in=s,c.avail_out=r,c.output=o,c.next_out=i,this.mode){case 1:case 3:case 5:a=mn(c,e);break;case 7:case 2:case 4:case 6:a=function(e,t){var s,n,o,i,r,a,c,u,l,d,h,p,g,_,m,f,v,I,E,S,y,C,M,A,b,T,O,w,D,R,L=0,N=new is(4),P=[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 Mn;(s=e.state).mode===An&&(s.mode=13),r=e.next_out,o=e.output,c=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,u=s.hold,l=s.bits,d=a,h=c,C=0;e:for(;;)switch(s.mode){case 1:if(0===s.wrap){s.mode=13;break}for(;l<16;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(2&s.wrap&&35615===u){s.check=0,N[0]=255&u,N[1]=u>>>8&255,s.check=Ks(s.check,N,2,0),u=0,l=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",s.mode=bn;break}if(8!=(15&u)){e.msg="unknown compression method",s.mode=bn;break}if(l-=4,y=8+(15&(u>>>=4)),0===s.wbits)s.wbits=y;else if(y>s.wbits){e.msg="invalid window size",s.mode=bn;break}s.dmax=1<<y,e.adler=s.check=1,s.mode=512&u?10:An,u=0,l=0;break;case 2:for(;l<16;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(s.flags=u,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=bn;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=bn;break}s.head&&(s.head.text=u>>8&1),512&s.flags&&(N[0]=255&u,N[1]=u>>>8&255,s.check=Ks(s.check,N,2,0)),u=0,l=0,s.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.head&&(s.head.time=u),512&s.flags&&(N[0]=255&u,N[1]=u>>>8&255,N[2]=u>>>16&255,N[3]=u>>>24&255,s.check=Ks(s.check,N,4,0)),u=0,l=0,s.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.head&&(s.head.xflags=255&u,s.head.os=u>>8),512&s.flags&&(N[0]=255&u,N[1]=u>>>8&255,s.check=Ks(s.check,N,2,0)),u=0,l=0,s.mode=5;case 5:if(1024&s.flags){for(;l<16;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.length=u,s.head&&(s.head.extra_len=u),512&s.flags&&(N[0]=255&u,N[1]=u>>>8&255,s.check=Ks(s.check,N,2,0)),u=0,l=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((p=s.length)>a&&(p=a),p&&(s.head&&(y=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),os(s.head.extra,n,i,p,y)),512&s.flags&&(s.check=Ks(s.check,n,p,i)),a-=p,i+=p,s.length-=p),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;p=0;do{y=n[i+p++],s.head&&y&&s.length<65536&&(s.head.name+=String.fromCharCode(y))}while(y&&p<a);if(512&s.flags&&(s.check=Ks(s.check,n,p,i)),a-=p,i+=p,y)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;p=0;do{y=n[i+p++],s.head&&y&&s.length<65536&&(s.head.comment+=String.fromCharCode(y))}while(y&&p<a);if(512&s.flags&&(s.check=Ks(s.check,n,p,i)),a-=p,i+=p,y)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;l<16;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(u!==(65535&s.check)){e.msg="header crc mismatch",s.mode=bn;break}u=0,l=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=An;break;case 10:for(;l<32;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}e.adler=s.check=Tn(u),u=0,l=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=c,e.next_in=i,e.avail_in=a,s.hold=u,s.bits=l,2;e.adler=s.check=1,s.mode=An;case An:if(5===t||6===t)break e;case 13:if(s.last){u>>>=7&l,l-=7&l,s.mode=27;break}for(;l<3;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}switch(s.last=1&u,l-=1,3&(u>>>=1)){case 0:s.mode=14;break;case 1:if(Nn(s),s.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=bn}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",s.mode=bn;break}if(s.length=65535&u,u=0,l=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(p=s.length){if(p>a&&(p=a),p>c&&(p=c),0===p)break e;os(o,n,i,p,r),a-=p,i+=p,c-=p,r+=p,s.length-=p;break}s.mode=An;break;case 17:for(;l<14;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(s.nlen=257+(31&u),u>>>=5,l-=5,s.ndist=1+(31&u),u>>>=5,l-=5,s.ncode=4+(15&u),u>>>=4,l-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=bn;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;l<3;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.lens[P[s.have++]]=7&u,u>>>=3,l-=3}for(;s.have<19;)s.lens[P[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,M={bits:s.lenbits},C=Cn(0,s.lens,0,19,s.lencode,0,s.work,M),s.lenbits=M.bits,C){e.msg="invalid code lengths set",s.mode=bn;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;f=(L=s.lencode[u&(1<<s.lenbits)-1])>>>16&255,v=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(v<16)u>>>=m,l-=m,s.lens[s.have++]=v;else{if(16===v){for(A=m+2;l<A;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(u>>>=m,l-=m,0===s.have){e.msg="invalid bit length repeat",s.mode=bn;break}y=s.lens[s.have-1],p=3+(3&u),u>>>=2,l-=2}else if(17===v){for(A=m+3;l<A;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}l-=m,y=0,p=3+(7&(u>>>=m)),u>>>=3,l-=3}else{for(A=m+7;l<A;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}l-=m,y=0,p=11+(127&(u>>>=m)),u>>>=7,l-=7}if(s.have+p>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=bn;break}for(;p--;)s.lens[s.have++]=y}}if(s.mode===bn)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=bn;break}if(s.lenbits=9,M={bits:s.lenbits},C=Cn(1,s.lens,0,s.nlen,s.lencode,0,s.work,M),s.lenbits=M.bits,C){e.msg="invalid literal/lengths set",s.mode=bn;break}if(s.distbits=6,s.distcode=s.distdyn,M={bits:s.distbits},C=Cn(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,M),s.distbits=M.bits,C){e.msg="invalid distances set",s.mode=bn;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(a>=6&&c>=258){e.next_out=r,e.avail_out=c,e.next_in=i,e.avail_in=a,s.hold=u,s.bits=l,fn(e,h),r=e.next_out,o=e.output,c=e.avail_out,i=e.next_in,n=e.input,a=e.avail_in,u=s.hold,l=s.bits,s.mode===An&&(s.back=-1);break}for(s.back=0;f=(L=s.lencode[u&(1<<s.lenbits)-1])>>>16&255,v=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(f&&!(240&f)){for(I=m,E=f,S=v;f=(L=s.lencode[S+((u&(1<<I+E)-1)>>I)])>>>16&255,v=65535&L,!(I+(m=L>>>24)<=l);){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}u>>>=I,l-=I,s.back+=I}if(u>>>=m,l-=m,s.back+=m,s.length=v,0===f){s.mode=26;break}if(32&f){s.back=-1,s.mode=An;break}if(64&f){e.msg="invalid literal/length code",s.mode=bn;break}s.extra=15&f,s.mode=22;case 22:if(s.extra){for(A=s.extra;l<A;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.length+=u&(1<<s.extra)-1,u>>>=s.extra,l-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;f=(L=s.distcode[u&(1<<s.distbits)-1])>>>16&255,v=65535&L,!((m=L>>>24)<=l);){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(!(240&f)){for(I=m,E=f,S=v;f=(L=s.distcode[S+((u&(1<<I+E)-1)>>I)])>>>16&255,v=65535&L,!(I+(m=L>>>24)<=l);){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}u>>>=I,l-=I,s.back+=I}if(u>>>=m,l-=m,s.back+=m,64&f){e.msg="invalid distance code",s.mode=bn;break}s.offset=v,s.extra=15&f,s.mode=24;case 24:if(s.extra){for(A=s.extra;l<A;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}s.offset+=u&(1<<s.extra)-1,u>>>=s.extra,l-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=bn;break}s.mode=25;case 25:if(0===c)break e;if(p=h-c,s.offset>p){if((p=s.offset-p)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=bn;break}p>s.wnext?(p-=s.wnext,g=s.wsize-p):g=s.wnext-p,p>s.length&&(p=s.length),_=s.window}else _=o,g=r-s.offset,p=s.length;p>c&&(p=c),c-=p,s.length-=p;do{o[r++]=_[g++]}while(--p);0===s.length&&(s.mode=21);break;case 26:if(0===c)break e;o[r++]=s.length,c--,s.mode=21;break;case 27:if(s.wrap){for(;l<32;){if(0===a)break e;a--,u|=n[i++]<<l,l+=8}if(h-=c,e.total_out+=h,s.total+=h,h&&(e.adler=s.check=s.flags?Ks(s.check,o,h,r-h):js(s.check,o,h,r-h)),h=c,(s.flags?u:Tn(u))!==s.check){e.msg="incorrect data check",s.mode=bn;break}u=0,l=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;l<32;){if(0===a)break e;a--,u+=n[i++]<<l,l+=8}if(u!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=bn;break}u=0,l=0}s.mode=29;case 29:C=1;break e;case bn:C=-3;break e;case 31:return-4;default:return Mn}return e.next_out=r,e.avail_out=c,e.next_in=i,e.avail_in=a,s.hold=u,s.bits=l,(s.wsize||h!==e.avail_out&&s.mode<bn&&(s.mode<27||4!==t))&&(b=e,T=e.output,O=e.next_out,w=h-e.avail_out,null===(R=b.state).window&&(R.wsize=1<<R.wbits,R.wnext=0,R.whave=0,R.window=new is(R.wsize)),w>=R.wsize?(os(R.window,T,O-R.wsize,R.wsize,0),R.wnext=0,R.whave=R.wsize):((D=R.wsize-R.wnext)>w&&(D=w),os(R.window,T,O-w,D,R.wnext),(w-=D)?(os(R.window,T,O-w,w,0),R.wnext=w,R.whave=R.wsize):(R.wnext+=D,R.wnext===R.wsize&&(R.wnext=0),R.whave<R.wsize&&(R.whave+=D)))),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,s.total+=h,s.wrap&&h&&(e.adler=s.check=s.flags?Ks(s.check,o,h,e.next_out-h):js(s.check,o,h,e.next_out-h)),e.data_type=s.bits+(s.last?64:0)+(s.mode===An?128:0)+(20===s.mode||15===s.mode?256:0),(0===d&&0===h||4===t)&&0===C&&(C=-5),C}(c,e);break;default:throw new Error("Unknown mode "+this.mode)}return 1!==a&&0!==a&&this._error(a),this.write_in_progress=!1,[c.avail_in,c.avail_out]},kn.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,1===this.mode||3===this.mode||5===this.mode?function(e){var t;e&&e.state&&(42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==Xs&&t!==Qs&&t!==en?tn(e,zs):(e.state=null,t===Qs&&tn(e,-3)))}(this.strm):function(e){if(!e||!e.state)return Mn;var t=e.state;t.window&&(t.window=null),e.state=null}(this.strm),this.mode=0)},kn.prototype.reset=function(){switch(this.mode){case 1:case 5:Pn=_n(this.strm);break;case 2:case 6:Pn=wn(this.strm)}0!==Pn&&this._error(Pn)},kn.prototype._error=function(e){this.onerror(ss[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var Un=Object.freeze({NONE:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,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,Zlib:kn}),Fn={};Object.keys(Un).forEach(function(e){Fn[e]=Un[e]}),Fn.Z_MIN_WINDOWBITS=8,Fn.Z_MAX_WINDOWBITS=15,Fn.Z_DEFAULT_WINDOWBITS=15,Fn.Z_MIN_CHUNK=64,Fn.Z_MAX_CHUNK=1/0,Fn.Z_DEFAULT_CHUNK=16384,Fn.Z_MIN_MEMLEVEL=1,Fn.Z_MAX_MEMLEVEL=9,Fn.Z_DEFAULT_MEMLEVEL=8,Fn.Z_MIN_LEVEL=-1,Fn.Z_MAX_LEVEL=9,Fn.Z_DEFAULT_LEVEL=Fn.Z_DEFAULT_COMPRESSION;var xn={Z_OK:Fn.Z_OK,Z_STREAM_END:Fn.Z_STREAM_END,Z_NEED_DICT:Fn.Z_NEED_DICT,Z_ERRNO:Fn.Z_ERRNO,Z_STREAM_ERROR:Fn.Z_STREAM_ERROR,Z_DATA_ERROR:Fn.Z_DATA_ERROR,Z_MEM_ERROR:Fn.Z_MEM_ERROR,Z_BUF_ERROR:Fn.Z_BUF_ERROR,Z_VERSION_ERROR:Fn.Z_VERSION_ERROR};function $n(e,t){if("string"==typeof t&&(t=new L(t)),!_e(t))throw new TypeError("Not a string or buffer");var s=Fn.Z_FINISH;return e._processChunk(t,s)}function qn(e){if(!(this instanceof qn))return new qn(e);Yn.call(this,e,Fn.DEFLATE)}function Bn(e){if(!(this instanceof Bn))return new Bn(e);Yn.call(this,e,Fn.INFLATE)}function Vn(e){if(!(this instanceof Vn))return new Vn(e);Yn.call(this,e,Fn.GZIP)}function Wn(e){if(!(this instanceof Wn))return new Wn(e);Yn.call(this,e,Fn.GUNZIP)}function jn(e){if(!(this instanceof jn))return new jn(e);Yn.call(this,e,Fn.DEFLATERAW)}function Hn(e){if(!(this instanceof Hn))return new Hn(e);Yn.call(this,e,Fn.INFLATERAW)}function Kn(e){if(!(this instanceof Kn))return new Kn(e);Yn.call(this,e,Fn.UNZIP)}function Yn(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||Fn.Z_DEFAULT_CHUNK,Xt.call(this,e),e.flush&&e.flush!==Fn.Z_NO_FLUSH&&e.flush!==Fn.Z_PARTIAL_FLUSH&&e.flush!==Fn.Z_SYNC_FLUSH&&e.flush!==Fn.Z_FULL_FLUSH&&e.flush!==Fn.Z_FINISH&&e.flush!==Fn.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||Fn.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<Fn.Z_MIN_CHUNK||e.chunkSize>Fn.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<Fn.Z_MIN_WINDOWBITS||e.windowBits>Fn.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<Fn.Z_MIN_LEVEL||e.level>Fn.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<Fn.Z_MIN_MEMLEVEL||e.memLevel>Fn.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=Fn.Z_FILTERED&&e.strategy!=Fn.Z_HUFFMAN_ONLY&&e.strategy!=Fn.Z_RLE&&e.strategy!=Fn.Z_FIXED&&e.strategy!=Fn.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!_e(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new Fn.Zlib(t);var s=this;this._hadError=!1,this._binding.onerror=function(e,t){s._binding=null,s._hadError=!0;var n=new Error(e);n.errno=t,n.code=Fn.codes[t],s.emit("error",n)};var n=Fn.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(n=e.level);var o=Fn.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(o=e.strategy),this._binding.init(e.windowBits||Fn.Z_DEFAULT_WINDOWBITS,n,e.memLevel||Fn.Z_DEFAULT_MEMLEVEL,o,e.dictionary),this._buffer=new L(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=o,this.once("end",this.close)}Object.keys(xn).forEach(function(e){xn[xn[e]]=e}),qe(Yn,Xt),Yn.prototype.params=function(e,t,s){if(e<Fn.Z_MIN_LEVEL||e>Fn.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=Fn.Z_FILTERED&&t!=Fn.Z_HUFFMAN_ONLY&&t!=Fn.Z_RLE&&t!=Fn.Z_FIXED&&t!=Fn.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(Fn.Z_SYNC_FLUSH,function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,s&&s())})}else Re(s)},Yn.prototype.reset=function(){return this._binding.reset()},Yn.prototype._flush=function(e){this._transform(new L(0),"",e)},Yn.prototype.flush=function(e,t){var s=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=Fn.Z_FULL_FLUSH),s.ended)t&&Re(t);else if(s.ending)t&&this.once("end",t);else if(s.needDrain){var n=this;this.once("drain",function(){n.flush(t)})}else this._flushFlag=e,this.write(new L(0),"",t)},Yn.prototype.close=function(e){if(e&&Re(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Re(function(){t.emit("close")})}},Yn.prototype._transform=function(e,t,s){var n,o=this._writableState,i=(o.ending||o.ended)&&(!e||o.length===e.length);if(null===!e&&!_e(e))return s(new Error("invalid input"));i?n=Fn.Z_FINISH:(n=this._flushFlag,e.length>=o.length&&(this._flushFlag=this._opts.flush||Fn.Z_NO_FLUSH)),this._processChunk(e,n,s)},Yn.prototype._processChunk=function(e,t,s){var n=e&&e.length,o=this._chunkSize-this._offset,i=0,r=this,a="function"==typeof s;if(!a){var c,u=[],l=0;this.on("error",function(e){c=e});do{var d=this._binding.writeSync(t,e,i,n,this._buffer,this._offset,o)}while(!this._hadError&&g(d[0],d[1]));if(this._hadError)throw c;var h=L.concat(u,l);return this.close(),h}var p=this._binding.write(t,e,i,n,this._buffer,this._offset,o);function g(c,d){if(!r._hadError){var h=o-d;if(function(e){if(!e)throw new Error("have should not go down")}(h>=0),h>0){var p=r._buffer.slice(r._offset,r._offset+h);r._offset+=h,a?r.push(p):(u.push(p),l+=p.length)}if((0===d||r._offset>=r._chunkSize)&&(o=r._chunkSize,r._offset=0,r._buffer=new L(r._chunkSize)),0===d){if(i+=n-c,n=c,!a)return!0;var _=r._binding.write(t,e,i,n,r._buffer,r._offset,r._chunkSize);return _.callback=g,void(_.buffer=e)}if(!a)return!1;s()}}p.buffer=e,p.callback=g},qe(qn,Yn),qe(Bn,Yn),qe(Vn,Yn),qe(Wn,Yn),qe(jn,Yn),qe(Hn,Yn),qe(Kn,Yn);var zn=function(e,t){return $n(new qn(t),e)},Zn=function(e,t){return $n(new Bn(t),e)};class Jn{constructor(e,t,s){this.SDKAPPID=e,this.EXPIRETIME=s,this.PRIVATEKEY=t}genTestUserSig(e){return this._isNumber(this.SDKAPPID)?this._isString(this.PRIVATEKEY)?this._isString(e)?this._isNumber(this.EXPIRETIME)?(console.log("sdkAppID="+this.SDKAPPID+" key="+this.PRIVATEKEY+" userID="+e+" expire="+this.EXPIRETIME),this.genSigWithUserbuf(e,this.EXPIRETIME,null)):(console.error("expireTime must be a number"),""):(console.error("userID must be a string"),""):(console.error("privateKey must be a string"),""):(console.error("sdkAppID must be a number"),"")}newBuffer(e,t){return L.from?L.from(e,t):new L(e,t)}unescape(e){return e.replace(/_/g,"=").replace(/\-/g,"/").replace(/\*/g,"+")}escape(e){return e.replace(/\+/g,"*").replace(/\//g,"-").replace(/=/g,"_")}encode(e){return this.escape(this.newBuffer(e).toString("base64"))}decode(e){return this.newBuffer(this.unescape(e),"base64")}base64encode(e){return this.newBuffer(e).toString("base64")}base64decode(e){return this.newBuffer(e,"base64").toString()}_hmacsha256(e,t,s,n){let o="TLS.identifier:"+e+"\n";o+="TLS.sdkappid:"+this.SDKAPPID+"\n",o+="TLS.time:"+t+"\n",o+="TLS.expire:"+s+"\n",null!=n&&(o+="TLS.userbuf:"+n+"\n");let i=Ie.HmacSHA256(o,this.PRIVATEKEY);return Ie.enc.Base64.stringify(i)}_utc(){return Math.round(Date.now()/1e3)}_isNumber(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)}_isString(e){return"string"==typeof e}genSigWithUserbuf(e,t,s){let n=this._utc(),o={"TLS.ver":"2.0","TLS.identifier":e,"TLS.sdkappid":this.SDKAPPID,"TLS.time":n,"TLS.expire":t},i="";if(null!=s){let r=this.base64encode(s);o["TLS.userbuf"]=r,i=this._hmacsha256(e,n,t,r)}else i=this._hmacsha256(e,n,t,null);o["TLS.sig"]=i;let r=JSON.stringify(o),a=zn(this.newBuffer(r)).toString("base64"),c=this.escape(a);return console.log("ret="+c),c}validate(e){let t=this.decode(e),s=Zn(t);console.log("validate ret="+s)}}function Xn(e){const{SDKAppID:t,secretKey:s,userID:n}=e;return{SDKAppID:t,userSig:new Jn(t,s,604800).genTestUserSig(n)}}class Qn{constructor(){this.isRegistered=!1,this.registrationID="",this.chat=null,this.SDKAppID=0,this.appKey="",this.vapidPublicKey="",this.EVENT=r,this.VERSION=i,u.log("version:",i),this.eventEmitter=new l,this.serviceWorkerManager=f.getInstance(this.eventEmitter),this.initializeBrowserCompatibility().catch(e=>{u.error("Browser compatibility initialization failed",e)}),this.setupInternalListeners()}static getInstance(){return this.instance||(this.instance=new Qn),this.instance}async registerPush(e){try{h.validateRegisterPushOptions(e);const{SDKAppID:t,appKey:s,userID:n,chat:i}=e;this.isRegistered&&(u.warn("Push service already registered, will unregister first and then re-register"),await this.unRegisterPush()),this.checkBrowserSupport();if("granted"!==await this.requestNotificationPermission())throw new Error("User denied notification permission");this.SDKAppID=t,this.appKey=s,this.registrationID=n,this.chat=i||o.create({SDKAppID:this.SDKAppID,...e}),await this.serviceWorkerManager.register(),await this.chatLogin();const r=await this.serviceWorkerManager.getPushSubscription(this.vapidPublicKey);return await this.setToken(r),this.isRegistered=!0,u.log("Push service registration successful",this.registrationID),this.registrationID}catch(t){if(t instanceof d)throw u.error("Push service registration parameter validation failed",t.message),t;throw u.error("Push service registration failed",t),t}}async unRegisterPush(){try{return this.isRegistered?(this.chat,await this.serviceWorkerManager.unsubscribe(),await this.serviceWorkerManager.unregister(),await this.chat.callExperimentalAPI("logoutWebPush"),this.isRegistered=!1,this.registrationID="",this.SDKAppID=0,this.appKey="",this.vapidPublicKey="",this.clearState(),u.log("Push service unregistration successful"),!0):(u.warn("Push service is not registered, no need to unregister"),!0)}catch(e){return u.error("Push service unregistration failed",e),!1}}addPushListener(e,t){try{h.validateEventType(e),h.validateListener(t);const s=this.eventEmitter.on(e,t);return u.log("Add push listener",e,s),s}catch(s){if(s instanceof d)throw u.error("Add push listener parameter validation failed",s.message),s;throw u.error("Add push listener failed",s),new Error("Add push listener failed")}}removePushListener(e,t){try{h.validateEventType(e),h.validateListener(t);const s=this.eventEmitter.off(e,t);return u.log("Remove push listener",e,s),s}catch(s){if(s instanceof d)throw u.error("Remove push listener parameter validation failed",s.message),s;return u.error("Remove push listener failed",s),!1}}checkBrowserSupport(){if(!g.checkBrowserSupport()){const e=g.detectWebPushCapability();throw new Error(`Browser not supported: ${e.reason}`)}}async requestNotificationPermission(){try{const e=await g.checkNotificationPermission();if("granted"===e)return"granted";const t=g.detectWebPushCapability().browserName;if("denied"===e){const e=`Notification permission denied for ${t}. Please check your system settings.`;throw new Error(e)}g.requiresUserGesture()&&u.warn("Current browser requires user gesture to request notification permission");const s=await g.requestNotificationPermission();if("granted"!==s)throw new Error(`User denied notification permission for ${t}`);return this.showSystemPermissionAlert(t),s}catch(e){throw u.error("Request notification permission failed",e),e}}async chatLogin(){try{const e=await this.chat.callExperimentalAPI("loginWebPush",{userID:this.registrationID,userSig:Xn({SDKAppID:this.SDKAppID,secretKey:this.appKey,userID:this.registrationID}).userSig});e.data.vapid?this.vapidPublicKey=e.data.vapid:u.error("Failed to fetch VAPID public key")}catch(e){if(2905===e?.code){const t=new Error("The API you are calling is only available in the Professional edition. Please change your import from @tencentcloud/lite-chat to @tencentcloud/lite-chat/professional to access this feature.");throw t.code=e.code,t}throw e}}getSystemPermissionMessage(e){return navigator.userAgent.toLowerCase().includes("mac os")?`For macOS: System Preferences > Notifications > ${e}, then enable notifications.`:`For Windows: Settings > Privacy > Notifications > ${e}, then enable notifications.`}showSystemPermissionAlert(e){const t=this.getSystemPermissionMessage(e);alert(`System notification permission for ${e}.\n\n${t}\n\nPlease refresh the page after enabling notifications.`)}getBrowserInstType(){const e=navigator.userAgent.toLowerCase();return e.includes("edg/")?3003:e.includes("yabrowser/")?3004:e.includes("opr/")||e.includes("opera/")?3005:e.includes("chrome/")&&!e.includes("edg/")?3e3:e.includes("firefox/")?3001:e.includes("safari/")&&!e.includes("chrome/")?3002:1}async setToken(e){try{const t=g.detectWebPushCapability(),s=g.getBrowserInfo(),n={browserType:this.getBrowserInstType(),pushToken:e.endpoint,webPushAuthKey:e.auth,webPushP256:e.p256dh,pushSDKVersion:i,browserVersion:`${t.browserName} ${t.browserVersion}`,browserPlatform:s.platform,browserLanguage:s.language};return await this.chat.callExperimentalAPI("setWebPushToken",n)}catch(t){throw u.error("Device registration failed",t),t}}async initializeBrowserCompatibility(){try{const e=g.detectWebPushCapability();u.log("Browser Web Push capability initialization completed",{browser:`${e.browserName} ${e.browserVersion}`,supported:e.supported,reason:e.reason}),e.supported||u.warn("[WebPush] Browser compatibility warning:",e.reason)}catch(e){u.error("Browser compatibility initialization failed",e)}}setupInternalListeners(){this.eventEmitter.on(r.MESSAGE_RECEIVED,e=>{this.SDKAppID&&this.registrationID&&e.messageID&&this.pushStatistics(e.messageID,"reach")}),this.eventEmitter.on(r.NOTIFICATION_CLICKED,e=>{this.SDKAppID&&this.registrationID&&e.notification?.messageID&&this.pushStatistics(e.notification.messageID,"click")})}async pushStatistics(e,t){try{if(!this.chat)return void u.warn("Chat SDK not initialized, skipping statistics");const s={messageID:e,type:t,timestamp:Date.now(),SDKAppID:this.SDKAppID,registrationID:this.registrationID};u.log(`Message ${t} statistics recorded`,s)}catch(s){u.error(`Failed to record message ${t} statistics`,s)}}clearState(){this.isRegistered=!1,this.registrationID="",this.SDKAppID=0,this.appKey="",this.vapidPublicKey=""}}const eo=Qn.getInstance();e.EVENT=r,e.default=eo,e.webPush=eo,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tencentcloud/lite-chat/professional")):"function"==typeof define&&define.amd?define(["exports","@tencentcloud/lite-chat/professional"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WebPushSDK={},e.TencentCloudChat)}(this,function(e,t){"use strict";const r="1.0.2";var n=(e=>(e.MESSAGE_RECEIVED="message_received",e.MESSAGE_REVOKED="message_revoked",e.NOTIFICATION_CLICKED="notification_clicked",e))(n||{});const i="[WebPush]";class s{constructor(){}static getInstance(){return s.instance||(s.instance=new s),s.instance}log(e,...t){console.log(`${i} ${e}`,...t)}warn(e,...t){console.warn(`${i} ${e}`,...t)}error(e,...t){console.error(`${i} ${e}`,...t)}info(e,...t){console.info(`${i} ${e}`,...t)}}const o=s.getInstance();class a{constructor(){this.events=new Map}on(e,t){this.events.has(e)||this.events.set(e,new Map);const r=Math.random().toString(36).substr(2,9);return this.events.get(e).set(r,t),r}off(e,t){const r=this.events.get(e);if(!r)return!1;for(const[n,i]of r.entries())if(i===t)return r.delete(n),!0;return!1}emit(e,...t){const r=this.events.get(e);r&&r.forEach(r=>{try{r(...t)}catch(n){o.error(`Event listener error for ${e}:`,n)}})}removeAllListeners(e){e?this.events.delete(e):this.events.clear()}listenerCount(e){const t=this.events.get(e);return t?t.size:0}}class h extends Error{constructor(e,t,r){super(`Parameter validation failed: ${e} - ${t}`),this.name="ValidationError",this.field=e,this.value=r}}class c{static validateValue(e,t,r){if(r.required&&(null==t||""===t))throw new h(e,r.message||`${e} is required`,t);if(r.required||null!=t&&""!==t){if(r.type&&!this.checkType(t,r.type))throw new h(e,r.message||`${e} must be of type ${r.type}`,t);if("string"===r.type&&"string"==typeof t){if(void 0!==r.min&&t.length<r.min)throw new h(e,r.message||`${e} length cannot be less than ${r.min} characters`,t);if(void 0!==r.max&&t.length>r.max)throw new h(e,r.message||`${e} length cannot exceed ${r.max} characters`,t)}if("number"===r.type&&"number"==typeof t){if(void 0!==r.min&&t<r.min)throw new h(e,r.message||`${e} cannot be less than ${r.min}`,t);if(void 0!==r.max&&t>r.max)throw new h(e,r.message||`${e} cannot be greater than ${r.max}`,t)}if(r.pattern&&"string"==typeof t&&!r.pattern.test(t))throw new h(e,r.message||`${e} format is incorrect`,t);if(r.custom){const n=r.custom(t);if(!0!==n){const i="string"==typeof n?n:r.message||`${e} validation failed`;throw new h(e,i,t)}}}}static validateObject(e,t){if(!e||"object"!=typeof e)throw new h("root","Parameter must be an object type");for(const[r,n]of Object.entries(t)){const t=e[r];this.validateValue(r,t,n)}}static checkType(e,t){switch(t){case"string":return"string"==typeof e;case"number":return"number"==typeof e&&!isNaN(e);case"boolean":return"boolean"==typeof e;case"object":return null!==e&&"object"==typeof e&&!Array.isArray(e);case"array":return Array.isArray(e);case"function":return"function"==typeof e;default:return!1}}static validateSDKAppID(e){this.validateValue("SDKAppID",e,{required:!0,type:"number",custom:e=>!!Number.isInteger(e)||"SDKAppID must be an integer",message:"SDKAppID must be an integer between 1-999999999"})}static validateAppKey(e){this.validateValue("appKey",e,{required:!0,type:"string",pattern:/^[a-zA-Z0-9_-]+$/,message:"appKey must be a 1-256 character string composed of letters, numbers, underscores or hyphens"})}static validateUserID(e){this.validateValue("userID",e,{required:!0,type:"string",pattern:/^[a-zA-Z0-9_.-]+$/,message:"userID must be a 1-128 character string composed of letters, numbers, underscores, dots or hyphens"})}static validateEventType(e){const t=["message_received","message_revoked","notification_clicked"];this.validateValue("eventType",e,{required:!0,type:"string",custom:e=>!!t.includes(e)||`eventType must be one of: ${t.join(", ")}`})}static validateListener(e){this.validateValue("listener",e,{required:!0,type:"function",message:"listener must be a function"})}static validateRegisterPushOptions(e){if(!e)throw new h("options","Registration options cannot be empty");const t={SDKAppID:{required:!0,type:"number",custom:e=>!!Number.isInteger(e)||"SDKAppID must be an integer"},appKey:{required:!0,type:"string",pattern:/^[a-zA-Z0-9_-]+$/},userID:{required:!0,type:"string",pattern:/^[a-zA-Z0-9_.-]+$/}};this.validateObject(e,t)}static validatePushMessage(e){if(!e)throw new h("message","Push message cannot be empty");this.validateObject(e,{messageID:{required:!0,type:"string"},title:{required:!0,type:"string"},body:{required:!0,type:"string"},icon:{required:!1,type:"string",pattern:/^https?:\/\/.+/},tag:{required:!1,type:"string"},timestamp:{required:!0,type:"number"}})}static validateURL(e,t="url"){this.validateValue(t,e,{required:!0,type:"string",pattern:/^https?:\/\/.+/,message:`${t} must be a valid HTTP/HTTPS URL`})}static validateServiceWorkerPath(e){this.validateValue("serviceWorkerPath",e,{required:!1,type:"string",pattern:/^[a-zA-Z0-9_./-]+\.js$/,message:"serviceWorkerPath must be a valid JavaScript file path"})}}class l{constructor(){this.browserInfo=null}static getInstance(){return l.instance||(l.instance=new l),l.instance}getBrowserInfo(){if(this.browserInfo)return this.browserInfo;const e="undefined"!=typeof navigator&&navigator.userAgent||"Test/1.0.0",t={name:"Unknown",version:"0.0.0",majorVersion:0,platform:this.detectPlatform(),userAgent:e,language:this.detectLanguage()};if(/Chrome\/(\d+)/.test(e)&&!/Edge|Edg/.test(e)){const r=e.match(/Chrome\/(\d+)\.(\d+)\.(\d+)/);r&&(t.name="Chrome",t.version=`${r[1]}.${r[2]}.${r[3]}`,t.majorVersion=parseInt(r[1]))}else if(/Firefox\/(\d+)/.test(e)){const r=e.match(/Firefox\/(\d+)\.(\d+)/);r&&(t.name="Firefox",t.version=`${r[1]}.${r[2]}`,t.majorVersion=parseInt(r[1]))}else if(/Safari\//.test(e)&&!/Chrome|Chromium/.test(e)){const r=e.match(/Version\/(\d+)\.(\d+)/);r&&(t.name="Safari",t.version=`${r[1]}.${r[2]}`,t.majorVersion=parseInt(r[1]))}else if(/Edg\/(\d+)/.test(e)){const r=e.match(/Edg\/(\d+)\.(\d+)\.(\d+)/);r&&(t.name="Edge",t.version=`${r[1]}.${r[2]}.${r[3]}`,t.majorVersion=parseInt(r[1]))}else if(/Edge\/(\d+)/.test(e)){const r=e.match(/Edge\/(\d+)\.(\d+)/);r&&(t.name="Edge Legacy",t.version=`${r[1]}.${r[2]}`,t.majorVersion=parseInt(r[1]))}else if(/OPR\/(\d+)/.test(e)){const r=e.match(/OPR\/(\d+)\.(\d+)\.(\d+)/);r&&(t.name="Opera",t.version=`${r[1]}.${r[2]}.${r[3]}`,t.majorVersion=parseInt(r[1]))}return this.browserInfo=t,t}detectPlatform(){if("undefined"==typeof navigator)return"Test";const e=navigator.userAgent||"";return/Windows/.test(e)?"Windows":/Mac OS X/.test(e)?"macOS":/Linux/.test(e)?"Linux":/Android/.test(e)?"Android":/iPhone|iPad|iPod/.test(e)?"iOS":"Unknown"}detectLanguage(){return"undefined"==typeof navigator?"en-US":navigator.language||navigator.languages?.[0]||"en-US"}getFeatureSupport(){return{serviceWorker:"serviceWorker"in navigator,pushManager:"PushManager"in window,notification:"Notification"in window,webPush:this.isWebPushSupported()}}detectWebPushCapability(){if("undefined"!=typeof jest)return{supported:!0,browserName:"Test",browserVersion:"1.0.0"};const e=this.getBrowserInfo();if("undefined"==typeof window)return{supported:!1,reason:"Not running in browser environment",browserName:e.name,browserVersion:e.version};if(!("serviceWorker"in navigator))return{supported:!1,reason:"Service Worker not supported",browserName:e.name,browserVersion:e.version};if(!("PushManager"in window))return{supported:!1,reason:"Push Manager not supported",browserName:e.name,browserVersion:e.version};if(!("Notification"in window))return{supported:!1,reason:"Notification API not supported",browserName:e.name,browserVersion:e.version};const t=this.checkBrowserVersionSupport(e);return t.supported?{supported:!0,browserName:e.name,browserVersion:e.version}:{supported:!1,reason:t.reason,browserName:e.name,browserVersion:e.version}}checkBrowserVersionSupport(e){switch(e.name){case"Safari":if(e.majorVersion<16)return{supported:!1,reason:"Safari version too old (requires 16+)"};break;case"Chrome":if(e.majorVersion<42)return{supported:!1,reason:"Chrome version too old (requires 42+)"};break;case"Firefox":if(e.majorVersion<44)return{supported:!1,reason:"Firefox version too old (requires 44+)"};break;case"Edge":if(e.majorVersion<17)return{supported:!1,reason:"Edge version too old (requires 17+)"};break;case"Edge Legacy":return{supported:!1,reason:"Edge Legacy not supported, please upgrade to new Edge"};case"Opera":if(e.majorVersion<39)return{supported:!1,reason:"Opera version too old (requires 39+)"};break;case"Unknown":return{supported:!1,reason:"Unknown browser, WebPush support uncertain"}}return{supported:!0}}isWebPushSupported(){return this.detectWebPushCapability().supported}getUnsupportedReason(){const e=this.detectWebPushCapability();return e.supported?void 0:e.reason}async checkNotificationPermission(){return"undefined"!=typeof window&&"Notification"in window?Notification.permission:(o.warn("Notification API not available"),"denied")}async requestNotificationPermission(){try{if("undefined"!=typeof window&&"Notification"in window&&"function"==typeof Notification.requestPermission)return await Notification.requestPermission();throw new Error("Notification permission request not supported")}catch(e){return o.error("Failed to request notification permission",e),this.handleBrowserSpecificError(e)}}requiresUserGesture(){return"Safari"===this.getBrowserInfo().name}handleBrowserSpecificError(e){const t=this.getBrowserInfo();let r="Permission denied";switch(t.name){case"Safari":r=`Safari: ${e.message}`;break;case"Chrome":r=`Chrome: ${e.message}`;break;case"Firefox":r=`Firefox: ${e.message}`;break;default:r=`${t.name}: ${e.message}`}return o.error("Browser specific error:",r),"denied"}checkBrowserSupport(){const e=this.detectWebPushCapability();return e.supported?(o.log("Browser supports Web Push:",{browser:`${e.browserName} ${e.browserVersion}`,features:this.getFeatureSupport()}),!0):(o.error("Browser not supported for Web Push:",e.reason),!1)}}const u=l.getInstance();const f=class e{static set(t,r){try{const n=JSON.stringify(r);localStorage.setItem(e.PREFIX+t,n)}catch(n){o.error("Storage set error:",n)}}static get(t,r){try{const n=localStorage.getItem(e.PREFIX+t);return null===n?r||null:JSON.parse(n)}catch(n){return o.error("Storage get error:",n),r||null}}static remove(t){try{localStorage.removeItem(e.PREFIX+t)}catch(r){o.error("Storage remove error:",r)}}static clear(){try{Object.keys(localStorage).forEach(t=>{t.startsWith(e.PREFIX)&&localStorage.removeItem(t)})}catch(t){o.error("Storage clear error:",t)}}};f.PREFIX="webpush_";let d=f;class p{constructor(e){this.registration=null,this.swUrl="/sw.js",this.eventEmitter=e,this.setupMessageListener()}static getInstance(e){return p.instance||(p.instance=new p(e)),p.instance}async checkServiceWorkerExists(e){try{return(await fetch(e,{method:"HEAD"})).ok}catch{return!1}}async autoDetectServiceWorkerUrl(){if("undefined"!=typeof window){const e=window.location.pathname;"/"!==(e.endsWith("/")?e:e+"/")?(this.swUrl="./sw.js",o.log("Detected subdirectory deployment, using relative path:",this.swUrl)):(this.swUrl="/sw.js",o.log("Detected root directory deployment, using absolute path:",this.swUrl));await this.checkServiceWorkerExists(this.swUrl)||o.warn("Default Service Worker path not available, will try other paths during registration")}}setServiceWorkerUrl(e){try{c.validateServiceWorkerPath(e),this.swUrl=e,o.log("Manually set Service Worker path:",e)}catch(t){if(t instanceof h)throw o.error("Set Service Worker path parameter validation failed",t.message),t;throw new Error("Failed to set Service Worker path")}}async register(){if(!("serviceWorker"in navigator))throw new Error("Service Worker is not supported");await this.autoDetectServiceWorkerUrl();const e=[this.swUrl,"./sw.js","/sw.js","/dist/sw.js","/assets/sw.js"],t=[...new Set(e)];let r=null;for(const i of t)try{return o.log("Attempting to register Service Worker:",i),this.registration=await navigator.serviceWorker.register(i),this.swUrl=i,o.log("Service Worker registration successful",{url:i,registration:this.registration}),await this.waitForServiceWorkerReady(),this.registration}catch(n){r=n,o.warn(`Service Worker registration failed (${i}):`,n);continue}throw o.error("All Service Worker paths failed to register",r),new Error(`Service Worker registration failed: ${r?.message||"Unknown error"}. Please ensure sw.js file exists in one of the following paths: ${t.join(", ")}`)}async waitForServiceWorkerReady(){if(!this.registration)throw new Error("Service Worker not registered");return new Promise(e=>{if(this.registration.active)return void e();const t=this.registration.installing||this.registration.waiting;t&&t.addEventListener("statechange",()=>{"activated"===t.state&&e()})})}async getPushSubscription(e){try{if(c.validateValue("vapidPublicKey",e,{required:!0,type:"string",min:1,max:512,message:"VAPID public key must be a valid string"}),!this.registration)throw new Error("Service Worker not registered");const t=this.getStoredVapidPublicKey();let r=await this.registration.pushManager.getSubscription();r&&t!==e&&(o.log("VAPID public key changed, unsubscribing existing subscription"),await r.unsubscribe(),r=null),r||(r=await this.registration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:this.urlBase64ToUint8Array(e)}),this.setStoreVapidPublicKey(e)),o.log("Get push subscription successful",r);const n=this.getSubscriptionInfo(r);return o.log("Extracted subscription information:",{token:n.token,auth:n.auth,p256dh:n.p256dh,endpoint:n.endpoint}),{subscription:r,token:n.token||"",auth:n.auth||"",p256dh:n.p256dh||"",endpoint:n.endpoint||""}}catch(t){if(t instanceof h)throw o.error("Get push subscription parameter validation failed",t.message),t;throw o.error("Get push subscription failed",t),t}}getSubscriptionInfo(e){if(!e||!e.endpoint)return{token:null,auth:null,p256dh:null,endpoint:null};const t=e.endpoint,r=u.getBrowserInfo(),n=e.getKey?{auth:e.getKey("auth")?this.arrayBufferToBase64(e.getKey("auth")):null,p256dh:e.getKey("p256dh")?this.arrayBufferToBase64(e.getKey("p256dh")):null}:{auth:null,p256dh:null};o.log("Extract push subscription information",{browser:`${r.name} ${r.version}`,hasAuth:!!n.auth,hasP256dh:!!n.p256dh});try{if("Chrome"===r.name||"Edge"===r.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return o.log("Extract Token using Chrome/Edge FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t};const r=t.match(/https:\/\/android\.googleapis\.com\/gcm\/send\/(.+)/);if(r)return o.log("Extract Token using Chrome/Edge GCM format"),{token:r[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Firefox"===r.name){const e=t.match(/https:\/\/updates\.push\.services\.mozilla\.com\/wpush\/v(\d+)\/(.+)/);if(e)return o.log(`Extract Token using Firefox WebPush v${e[1]} format`),{token:e[2],auth:n.auth,p256dh:n.p256dh,endpoint:t};const r=t.match(/https:\/\/updates\.push\.services\.mozilla\.com\/push\/(.+)/);if(r)return o.log("Extract Token using Firefox legacy format"),{token:r[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Safari"===r.name){if(r.majorVersion>=16){const e=t.match(/https:\/\/web\.push\.apple\.com\/(.+)/);if(e)return o.log("Extract Token using Safari Web Push format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}if(t.includes("safari")||t.includes("apple"))return o.log("Safari push notification uses complete endpoint as identifier"),{token:this.generateSafariToken(t),auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Opera"===r.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return o.log("Extract Token using Opera FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}else if("Samsung Internet"===r.name){const e=t.match(/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/);if(e)return o.log("Extract Token using Samsung Internet FCM format"),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}const e=[{pattern:/https:\/\/fcm\.googleapis\.com\/fcm\/send\/(.+)/,name:"FCM Standard"},{pattern:/https:\/\/android\.googleapis\.com\/gcm\/send\/(.+)/,name:"GCM Legacy"},{pattern:/https:\/\/gcm-http\.googleapis\.com\/gcm\/(.+)/,name:"GCM HTTP"},{pattern:/https:\/\/updates\.push\.services\.mozilla\.com\/wpush\/v\d+\/(.+)/,name:"Mozilla WebPush"},{pattern:/https:\/\/updates\.push\.services\.mozilla\.com\/push\/(.+)/,name:"Mozilla Legacy"},{pattern:/https:\/\/.*\.notify\.windows\.com\/.*\/(.+)/,name:"Windows Notification"},{pattern:/https:\/\/web\.push\.apple\.com\/(.+)/,name:"Apple Web Push"},{pattern:/https:\/\/.*\/push\/(.+)/,name:"Generic Push"},{pattern:/https:\/\/.*\/wpush\/(.+)/,name:"Generic WebPush"}];for(const{pattern:i,name:s}of e){const e=t.match(i);if(e&&e[1])return o.log(`Extract Token using generic pattern: ${s}`,{browser:r.name,pattern:i.source}),{token:e[1],auth:n.auth,p256dh:n.p256dh,endpoint:t}}o.warn("Unable to extract standard Token from push endpoint, generating unique identifier",{browser:`${r.name} ${r.version}`,endpointLength:t.length,endpointStart:t.substring(0,50)+"..."});return{token:this.generateFallbackToken(t,r),auth:n.auth,p256dh:n.p256dh,endpoint:t}}catch(i){o.error("Error occurred during push subscription information extraction",{error:i instanceof Error?i.message:i,browser:r.name,endpointDomain:t.split("/")[2]});return{token:this.generateFallbackToken(t,r),auth:n.auth,p256dh:n.p256dh,endpoint:t}}}generateSafariToken(e){const t=e.match(/https:\/\/.*safari.*\/(.+)/);return t?`safari_${t[1]}`:`safari_${this.generateEndpointHash(e)}`}generateFallbackToken(e,t){const r=this.generateEndpointHash(e);return`${t.name.toLowerCase().replace(/\s+/g,"")}_${r}_${Date.now().toString(36)}`}generateEndpointHash(e){let t=0;for(let r=0;r<e.length;r++){t=(t<<5)-t+e.charCodeAt(r),t&=t}return Math.abs(t).toString(36)}async unsubscribe(){if(!this.registration)return!1;const e=await this.registration.pushManager.getSubscription();if(e){const t=await e.unsubscribe();return o.log("Unsubscribe from push notifications",t),this.clearStoredVapidPublicKey(),t}return!0}async unregister(){if(!this.registration)return!1;const e=await this.registration.unregister();return this.registration=null,this.clearStoredVapidPublicKey(),o.log("Unregister Service Worker",e),e}setupMessageListener(){"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",e=>{const t=e.data;this.handleServiceWorkerMessage(t)})}handleServiceWorkerMessage(e){switch(o.log("Received Service Worker message",e),e.type){case"MESSAGE_RECEIVED":this.eventEmitter.emit(n.MESSAGE_RECEIVED,e.data);break;case"NOTIFICATION_CLICKED":this.eventEmitter.emit(n.NOTIFICATION_CLICKED,e.data);break;case"MESSAGE_REVOKED":this.eventEmitter.emit(n.MESSAGE_REVOKED,e.data)}}async postMessage(e){try{if(c.validateValue("message",e,{required:!0,message:"Message content cannot be empty"}),!this.registration||!this.registration.active)throw new Error("Service Worker not activated");this.registration.active.postMessage(e),o.log("Send message to Service Worker successful",e)}catch(t){if(t instanceof h)throw o.error("Send message parameter validation failed",t.message),t;throw o.error("Send message to Service Worker failed",t),t}}arrayBufferToBase64(e){const t=new Uint8Array(e);let r="";for(let n=0;n<t.byteLength;n++)r+=String.fromCharCode(t[n]);return window.btoa(r)}urlBase64ToUint8Array(e){const t=(e+"=".repeat((4-e.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n}getRegistration(){return this.registration}getStoredVapidPublicKey(){try{return d.get("sdk_vapid_key")}catch(e){return o.error("Failed to get stored VAPID public key",e),null}}setStoreVapidPublicKey(e){try{d.set("sdk_vapid_key",e),o.log("VAPID public key stored successfully")}catch(t){o.error("Failed to store VAPID public key",t)}}clearStoredVapidPublicKey(){try{d.remove("sdk_vapid_key"),o.log("VAPID public key cleared successfully")}catch(e){o.error("Failed to clear VAPID public key",e)}}}var g="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},_=[],v=[],w="undefined"!=typeof Uint8Array?Uint8Array:Array,m=!1;function b(){m=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)_[t]=e[t],v[e.charCodeAt(t)]=t;v["-".charCodeAt(0)]=62,v["_".charCodeAt(0)]=63}function y(e,t,r){for(var n,i,s=[],o=t;o<r;o+=3)n=(e[o]<<16)+(e[o+1]<<8)+e[o+2],s.push(_[(i=n)>>18&63]+_[i>>12&63]+_[i>>6&63]+_[63&i]);return s.join("")}function k(e){var t;m||b();for(var r=e.length,n=r%3,i="",s=[],o=0,a=r-n;o<a;o+=16383)s.push(y(e,o,o+16383>a?a:o+16383));return 1===n?(t=e[r-1],i+=_[t>>2],i+=_[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=_[t>>10],i+=_[t>>4&63],i+=_[t<<2&63],i+="="),s.push(i),s.join("")}function E(e,t,r,n,i){var s,o,a=8*i-n-1,h=(1<<a)-1,c=h>>1,l=-7,u=r?i-1:0,f=r?-1:1,d=e[t+u];for(u+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+e[t+u],u+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+e[t+u],u+=f,l-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)}function S(e,t,r,n,i,s){var o,a,h,c=8*s-i-1,l=(1<<c)-1,u=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+u>=1?f/h:f*Math.pow(2,1-u))*h>=2&&(o++,h/=2),o+u>=l?(a=0,o=l):o+u>=1?(a=(t*h-1)*Math.pow(2,i),o+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*g}var x={}.toString,A=Array.isArray||function(e){return"[object Array]"==x.call(e)};function R(){return I.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function B(e,t){if(R()<t)throw new RangeError("Invalid typed array length");return I.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=I.prototype:(null===e&&(e=new I(t)),e.length=t),e}function I(e,t,r){if(!(I.TYPED_ARRAY_SUPPORT||this instanceof I))return new I(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return L(this,e)}return P(this,e,t,r)}function P(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),I.TYPED_ARRAY_SUPPORT?(e=t).__proto__=I.prototype:e=z(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!I.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|M(t,r),i=(e=B(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(C(t)){var r=0|T(t.length);return 0===(e=B(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?B(e,0):z(e,t);if("Buffer"===t.type&&A(t.data))return z(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function D(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function L(e,t){if(D(t),e=B(e,t<0?0:0|T(t)),!I.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function z(e,t){var r=t.length<0?0:0|T(t.length);e=B(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function T(e){if(e>=R())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+R().toString(16)+" bytes");return 0|e}function C(e){return!(null==e||!e._isBuffer)}function M(e,t){if(C(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ce(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return le(e).length;default:if(n)return ce(e).length;t=(""+t).toLowerCase(),n=!0}}function O(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return J(this,t,r);case"utf8":case"utf-8":return q(this,t,r);case"ascii":return X(this,t,r);case"latin1":case"binary":return G(this,t,r);case"base64":return $(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function U(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function N(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=I.from(t,n)),C(t))return 0===t.length?-1:F(e,t,r,n,i);if("number"==typeof t)return t&=255,I.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):F(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function F(e,t,r,n,i){var s,o=1,a=e.length,h=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,h/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(s=r;s<a;s++)if(c(e,s)===c(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===h)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(r+h>a&&(r=a-h),s=r;s>=0;s--){for(var u=!0,f=0;f<h;f++)if(c(e,s+f)!==c(t,f)){u=!1;break}if(u)return s}return-1}function W(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function H(e,t,r,n){return ue(ce(t,e.length-r),e,r,n)}function Z(e,t,r,n){return ue(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function j(e,t,r,n){return Z(e,t,r,n)}function K(e,t,r,n){return ue(le(t),e,r,n)}function V(e,t,r,n){return ue(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function $(e,t,r){return 0===t&&r===e.length?k(e):k(e.slice(t,r))}function q(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,h,c=e[i],l=null,u=c>239?4:c>223?3:c>191?2:1;if(i+u<=r)switch(u){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[i+1]))&&(h=(31&c)<<6|63&s)>127&&(l=h);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(h=(15&c)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(l=h);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(l=h)}null===l?(l=65533,u=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=u}return function(e){var t=e.length;if(t<=Y)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Y));return r}(n)}I.TYPED_ARRAY_SUPPORT=void 0===g.TYPED_ARRAY_SUPPORT||g.TYPED_ARRAY_SUPPORT,I.poolSize=8192,I._augment=function(e){return e.__proto__=I.prototype,e},I.from=function(e,t,r){return P(null,e,t,r)},I.TYPED_ARRAY_SUPPORT&&(I.prototype.__proto__=Uint8Array.prototype,I.__proto__=Uint8Array),I.alloc=function(e,t,r){return n=null,s=t,o=r,D(i=e),i<=0?B(n,i):void 0!==s?"string"==typeof o?B(n,i).fill(s,o):B(n,i).fill(s):B(n,i);var n,i,s,o},I.allocUnsafe=function(e){return L(null,e)},I.allocUnsafeSlow=function(e){return L(null,e)},I.isBuffer=fe,I.compare=function(e,t){if(!C(e)||!C(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},I.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},I.concat=function(e,t){if(!A(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return I.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=I.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!C(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},I.byteLength=M,I.prototype._isBuffer=!0,I.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)U(this,t,t+1);return this},I.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)U(this,t,t+3),U(this,t+1,t+2);return this},I.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)U(this,t,t+7),U(this,t+1,t+6),U(this,t+2,t+5),U(this,t+3,t+4);return this},I.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?q(this,0,e):O.apply(this,arguments)},I.prototype.equals=function(e){if(!C(e))throw new TypeError("Argument must be a Buffer");return this===e||0===I.compare(this,e)},I.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},I.prototype.compare=function(e,t,r,n,i){if(!C(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),h=this.slice(n,i),c=e.slice(t,r),l=0;l<a;++l)if(h[l]!==c[l]){s=h[l],o=c[l];break}return s<o?-1:o<s?1:0},I.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},I.prototype.indexOf=function(e,t,r){return N(this,e,t,r,!0)},I.prototype.lastIndexOf=function(e,t,r){return N(this,e,t,r,!1)},I.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return W(this,e,t,r);case"utf8":case"utf-8":return H(this,e,t,r);case"ascii":return Z(this,e,t,r);case"latin1":case"binary":return j(this,e,t,r);case"base64":return K(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},I.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Y=4096;function X(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function G(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function J(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=he(e[s]);return i}function Q(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function ee(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function te(e,t,r,n,i,s){if(!C(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function re(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function ne(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function ie(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function se(e,t,r,n,i){return i||ie(e,0,r,4),S(e,t,r,n,23,4),r+4}function oe(e,t,r,n,i){return i||ie(e,0,r,8),S(e,t,r,n,52,8),r+8}I.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),I.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=I.prototype;else{var i=t-e;r=new I(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},I.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||ee(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},I.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||ee(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},I.prototype.readUInt8=function(e,t){return t||ee(e,1,this.length),this[e]},I.prototype.readUInt16LE=function(e,t){return t||ee(e,2,this.length),this[e]|this[e+1]<<8},I.prototype.readUInt16BE=function(e,t){return t||ee(e,2,this.length),this[e]<<8|this[e+1]},I.prototype.readUInt32LE=function(e,t){return t||ee(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},I.prototype.readUInt32BE=function(e,t){return t||ee(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},I.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||ee(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},I.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||ee(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},I.prototype.readInt8=function(e,t){return t||ee(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},I.prototype.readInt16LE=function(e,t){t||ee(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},I.prototype.readInt16BE=function(e,t){t||ee(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},I.prototype.readInt32LE=function(e,t){return t||ee(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},I.prototype.readInt32BE=function(e,t){return t||ee(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},I.prototype.readFloatLE=function(e,t){return t||ee(e,4,this.length),E(this,e,!0,23,4)},I.prototype.readFloatBE=function(e,t){return t||ee(e,4,this.length),E(this,e,!1,23,4)},I.prototype.readDoubleLE=function(e,t){return t||ee(e,8,this.length),E(this,e,!0,52,8)},I.prototype.readDoubleBE=function(e,t){return t||ee(e,8,this.length),E(this,e,!1,52,8)},I.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||te(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},I.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||te(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},I.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,1,255,0),I.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},I.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):re(this,e,t,!0),t+2},I.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,2,65535,0),I.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):re(this,e,t,!1),t+2},I.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ne(this,e,t,!0),t+4},I.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,4,4294967295,0),I.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},I.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);te(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+r},I.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);te(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o|0)-a&255;return t+r},I.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,1,127,-128),I.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},I.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):re(this,e,t,!0),t+2},I.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,2,32767,-32768),I.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):re(this,e,t,!1),t+2},I.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,4,2147483647,-2147483648),I.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ne(this,e,t,!0),t+4},I.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||te(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),I.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},I.prototype.writeFloatLE=function(e,t,r){return se(this,e,t,!0,r)},I.prototype.writeFloatBE=function(e,t,r){return se(this,e,t,!1,r)},I.prototype.writeDoubleLE=function(e,t,r){return oe(this,e,t,!0,r)},I.prototype.writeDoubleBE=function(e,t,r){return oe(this,e,t,!1,r)},I.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!I.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},I.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!I.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=C(e)?e:ce(new I(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var ae=/[^+\/0-9A-Za-z-_]/g;function he(e){return e<16?"0"+e.toString(16):e.toString(16)}function ce(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function le(e){return function(e){var t,r,n,i,s,o;m||b();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===e[a-2]?2:"="===e[a-1]?1:0,o=new w(3*a/4-s),n=s>0?a-4:a;var h=0;for(t=0,r=0;t<n;t+=4,r+=3)i=v[e.charCodeAt(t)]<<18|v[e.charCodeAt(t+1)]<<12|v[e.charCodeAt(t+2)]<<6|v[e.charCodeAt(t+3)],o[h++]=i>>16&255,o[h++]=i>>8&255,o[h++]=255&i;return 2===s?(i=v[e.charCodeAt(t)]<<2|v[e.charCodeAt(t+1)]>>4,o[h++]=255&i):1===s&&(i=v[e.charCodeAt(t)]<<10|v[e.charCodeAt(t+1)]<<4|v[e.charCodeAt(t+2)]>>2,o[h++]=i>>8&255,o[h++]=255&i),o}(function(e){if((e=(t=e,t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(ae,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function ue(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function fe(e){return null!=e&&(!!e._isBuffer||de(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&de(t.slice(0,0)));var t}function de(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function pe(e,t){return e(t={exports:{}},t.exports),t.exports}var ge=pe(function(e,t){var r,n,i,s,o,a,h,c,l,u,f,d,p;e.exports=(r=r||(n=Math,i=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o=(s={}).lib={},a=o.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},h=o.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=n.ceil(t/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t,r=[],i=function(e){var t=987654321,r=4294967295;return function(){var i=((t=36969*(65535&t)+(t>>16)&r)<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r;return i/=4294967296,(i+=.5)*(n.random()>.5?1:-1)}},s=0;s<e;s+=4){var o=i(4294967296*(t||n.random()));t=987654071*o(),r.push(4294967296*o()|0)}return new h.init(r,e)}}),c=s.enc={},l=c.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new h.init(r,t/2)}},u=c.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new h.init(r,t)}},f=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=o.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,r=t.words,i=t.sigBytes,s=this.blockSize,o=i/(4*s),a=(o=e?n.ceil(o):n.max((0|o)-this._minBufferSize,0))*s,c=n.min(4*a,i);if(a){for(var l=0;l<a;l+=s)this._doProcessBlock(r,l);var u=r.splice(0,a);t.sigBytes-=c}return new h.init(u,c)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),o.Hasher=d.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new p.HMAC.init(e,r).finalize(t)}}}),p=s.algo={},s),r)}),_e=(pe(function(e,t){var r,n,i,s,o,a;e.exports=(i=(n=r=ge).lib,s=i.Base,o=i.WordArray,(a=n.x64={}).Word=s.extend({init:function(e,t){this.high=e,this.low=t}}),a.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,r=[],n=0;n<t;n++){var i=e[n];r.push(i.high),r.push(i.low)}return o.create(r,this.sigBytes)},clone:function(){for(var e=s.clone.call(this),t=e.words=this.words.slice(0),r=t.length,n=0;n<r;n++)t[n]=t[n].clone();return e}}),r)}),pe(function(e,t){var r;e.exports=(r=ge,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init;(e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)}).prototype=e}}(),r.lib.WordArray)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.WordArray,n=e.enc;function i(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=2){var s=t[i>>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var r=e.length,n=[],i=0;i<r;i++)n[i>>>1]|=e.charCodeAt(i)<<16-i%2*16;return t.create(n,2*r)}},n.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],s=0;s<r;s+=2){var o=i(t[s>>>2]>>>16-s%4*8&65535);n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var r=e.length,n=[],s=0;s<r;s++)n[s>>>1]|=i(e.charCodeAt(s)<<16-s%2*16);return t.create(n,2*r)}}}(),r.enc.Utf16)}),pe(function(e,t){var r,n,i;e.exports=(i=(n=r=ge).lib.WordArray,n.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<r;a++)i.push(n.charAt(o>>>6*(3-a)&63));var h=n.charAt(64);if(h)for(;i.length%4;)i.push(h);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var s=0;s<r.length;s++)n[r.charCodeAt(s)]=s}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],s=0,o=0;o<t;o++)if(o%4){var a=r[e.charCodeAt(o-1)]<<o%4*2,h=r[e.charCodeAt(o)]>>>6-o%4*2;n[s>>>2]|=(a|h)<<24-s%4*8,s++}return i.create(n,s)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)}),pe(function(e,t){var r;e.exports=(r=ge,function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var h=o.MD5=s.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var s=this._hash.words,o=e[t+0],h=e[t+1],d=e[t+2],p=e[t+3],g=e[t+4],_=e[t+5],v=e[t+6],w=e[t+7],m=e[t+8],b=e[t+9],y=e[t+10],k=e[t+11],E=e[t+12],S=e[t+13],x=e[t+14],A=e[t+15],R=s[0],B=s[1],I=s[2],P=s[3];R=c(R,B,I,P,o,7,a[0]),P=c(P,R,B,I,h,12,a[1]),I=c(I,P,R,B,d,17,a[2]),B=c(B,I,P,R,p,22,a[3]),R=c(R,B,I,P,g,7,a[4]),P=c(P,R,B,I,_,12,a[5]),I=c(I,P,R,B,v,17,a[6]),B=c(B,I,P,R,w,22,a[7]),R=c(R,B,I,P,m,7,a[8]),P=c(P,R,B,I,b,12,a[9]),I=c(I,P,R,B,y,17,a[10]),B=c(B,I,P,R,k,22,a[11]),R=c(R,B,I,P,E,7,a[12]),P=c(P,R,B,I,S,12,a[13]),I=c(I,P,R,B,x,17,a[14]),R=l(R,B=c(B,I,P,R,A,22,a[15]),I,P,h,5,a[16]),P=l(P,R,B,I,v,9,a[17]),I=l(I,P,R,B,k,14,a[18]),B=l(B,I,P,R,o,20,a[19]),R=l(R,B,I,P,_,5,a[20]),P=l(P,R,B,I,y,9,a[21]),I=l(I,P,R,B,A,14,a[22]),B=l(B,I,P,R,g,20,a[23]),R=l(R,B,I,P,b,5,a[24]),P=l(P,R,B,I,x,9,a[25]),I=l(I,P,R,B,p,14,a[26]),B=l(B,I,P,R,m,20,a[27]),R=l(R,B,I,P,S,5,a[28]),P=l(P,R,B,I,d,9,a[29]),I=l(I,P,R,B,w,14,a[30]),R=u(R,B=l(B,I,P,R,E,20,a[31]),I,P,_,4,a[32]),P=u(P,R,B,I,m,11,a[33]),I=u(I,P,R,B,k,16,a[34]),B=u(B,I,P,R,x,23,a[35]),R=u(R,B,I,P,h,4,a[36]),P=u(P,R,B,I,g,11,a[37]),I=u(I,P,R,B,w,16,a[38]),B=u(B,I,P,R,y,23,a[39]),R=u(R,B,I,P,S,4,a[40]),P=u(P,R,B,I,o,11,a[41]),I=u(I,P,R,B,p,16,a[42]),B=u(B,I,P,R,v,23,a[43]),R=u(R,B,I,P,b,4,a[44]),P=u(P,R,B,I,E,11,a[45]),I=u(I,P,R,B,A,16,a[46]),R=f(R,B=u(B,I,P,R,d,23,a[47]),I,P,o,6,a[48]),P=f(P,R,B,I,w,10,a[49]),I=f(I,P,R,B,x,15,a[50]),B=f(B,I,P,R,_,21,a[51]),R=f(R,B,I,P,E,6,a[52]),P=f(P,R,B,I,p,10,a[53]),I=f(I,P,R,B,y,15,a[54]),B=f(B,I,P,R,h,21,a[55]),R=f(R,B,I,P,m,6,a[56]),P=f(P,R,B,I,A,10,a[57]),I=f(I,P,R,B,v,15,a[58]),B=f(B,I,P,R,S,21,a[59]),R=f(R,B,I,P,g,6,a[60]),P=f(P,R,B,I,k,10,a[61]),I=f(I,P,R,B,d,15,a[62]),B=f(B,I,P,R,b,21,a[63]),s[0]=s[0]+R|0,s[1]=s[1]+B|0,s[2]=s[2]+I|0,s[3]=s[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var s=e.floor(n/4294967296),o=n;r[15+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,h=a.words,c=0;c<4;c++){var l=h[c];h[c]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,r,n,i,s,o){var a=e+(t&r|~t&n)+i+o;return(a<<s|a>>>32-s)+t}function l(e,t,r,n,i,s,o){var a=e+(t&n|r&~n)+i+o;return(a<<s|a>>>32-s)+t}function u(e,t,r,n,i,s,o){var a=e+(t^r^n)+i+o;return(a<<s|a>>>32-s)+t}function f(e,t,r,n,i,s,o){var a=e+(r^(t|~n))+i+o;return(a<<s|a>>>32-s)+t}t.MD5=s._createHelper(h),t.HmacMD5=s._createHmacHelper(h)}(Math),r.MD5)}),pe(function(e,t){var r,n,i,s,o,a,h,c;e.exports=(i=(n=r=ge).lib,s=i.WordArray,o=i.Hasher,a=n.algo,h=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],c=0;c<80;c++){if(c<16)h[c]=0|e[t+c];else{var l=h[c-3]^h[c-8]^h[c-14]^h[c-16];h[c]=l<<1|l>>>31}var u=(n<<5|n>>>27)+a+h[c];u+=c<20?1518500249+(i&s|~i&o):c<40?1859775393+(i^s^o):c<60?(i&s|i&o|s&o)-1894007588:(i^s^o)-899497514,a=o,o=s,s=i<<30|i>>>2,i=n,n=u}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),n.SHA1=o._createHelper(c),n.HmacSHA1=o._createHmacHelper(c),r.SHA1)}),pe(function(e,t){var r;e.exports=(r=ge,function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.algo,a=[],h=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),h[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],l=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],l=r[5],u=r[6],f=r[7],d=0;d<64;d++){if(d<16)c[d]=0|e[t+d];else{var p=c[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,_=c[d-2],v=(_<<15|_>>>17)^(_<<13|_>>>19)^_>>>10;c[d]=g+c[d-7]+v+c[d-16]}var w=n&i^n&s^i&s,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),b=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&u)+h[d]+c[d];f=u,u=l,l=a,a=o+b|0,o=s,s=i,i=n,n=b+(m+w)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+u|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(l),t.HmacSHA256=s._createHmacHelper(l)}(Math),r.SHA256)}),pe(function(e,t){var r,n,i,s,o,a;e.exports=(i=(n=r=ge).lib.WordArray,s=n.algo,o=s.SHA256,a=s.SHA224=o.extend({_doReset:function(){this._hash=new i.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=o._doFinalize.call(this);return e.sigBytes-=4,e}}),n.SHA224=o._createHelper(a),n.HmacSHA224=o._createHmacHelper(a),r.SHA224)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.Hasher,n=e.x64,i=n.Word,s=n.WordArray,o=e.algo;function a(){return i.create.apply(i,arguments)}var h=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var e=0;e<80;e++)c[e]=a()}();var l=o.SHA512=t.extend({_doReset:function(){this._hash=new s.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],l=r[5],u=r[6],f=r[7],d=n.high,p=n.low,g=i.high,_=i.low,v=s.high,w=s.low,m=o.high,b=o.low,y=a.high,k=a.low,E=l.high,S=l.low,x=u.high,A=u.low,R=f.high,B=f.low,I=d,P=p,D=g,L=_,z=v,T=w,C=m,M=b,O=y,U=k,N=E,F=S,W=x,H=A,Z=R,j=B,K=0;K<80;K++){var V=c[K];if(K<16)var $=V.high=0|e[t+2*K],q=V.low=0|e[t+2*K+1];else{var Y=c[K-15],X=Y.high,G=Y.low,J=(X>>>1|G<<31)^(X>>>8|G<<24)^X>>>7,Q=(G>>>1|X<<31)^(G>>>8|X<<24)^(G>>>7|X<<25),ee=c[K-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ie=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),se=c[K-7],oe=se.high,ae=se.low,he=c[K-16],ce=he.high,le=he.low;$=($=($=J+oe+((q=Q+ae)>>>0<Q>>>0?1:0))+ne+((q+=ie)>>>0<ie>>>0?1:0))+ce+((q+=le)>>>0<le>>>0?1:0),V.high=$,V.low=q}var ue,fe=O&N^~O&W,de=U&F^~U&H,pe=I&D^I&z^D&z,ge=P&L^P&T^L&T,_e=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),ve=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),we=(O>>>14|U<<18)^(O>>>18|U<<14)^(O<<23|U>>>9),me=(U>>>14|O<<18)^(U>>>18|O<<14)^(U<<23|O>>>9),be=h[K],ye=be.high,ke=be.low,Ee=Z+we+((ue=j+me)>>>0<j>>>0?1:0),Se=ve+ge;Z=W,j=H,W=N,H=F,N=O,F=U,O=C+(Ee=(Ee=(Ee=Ee+fe+((ue+=de)>>>0<de>>>0?1:0))+ye+((ue+=ke)>>>0<ke>>>0?1:0))+$+((ue+=q)>>>0<q>>>0?1:0))+((U=M+ue|0)>>>0<M>>>0?1:0)|0,C=z,M=T,z=D,T=L,D=I,L=P,I=Ee+(_e+pe+(Se>>>0<ve>>>0?1:0))+((P=ue+Se|0)>>>0<ue>>>0?1:0)|0}p=n.low=p+P,n.high=d+I+(p>>>0<P>>>0?1:0),_=i.low=_+L,i.high=g+D+(_>>>0<L>>>0?1:0),w=s.low=w+T,s.high=v+z+(w>>>0<T>>>0?1:0),b=o.low=b+M,o.high=m+C+(b>>>0<M>>>0?1:0),k=a.low=k+U,a.high=y+O+(k>>>0<U>>>0?1:0),S=l.low=S+F,l.high=E+N+(S>>>0<F>>>0?1:0),A=u.low=A+H,u.high=x+W+(A>>>0<H>>>0?1:0),B=f.low=B+j,f.high=R+Z+(B>>>0<j>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=t.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});e.SHA512=t._createHelper(l),e.HmacSHA512=t._createHmacHelper(l)}(),r.SHA512)}),pe(function(e,t){var r,n,i,s,o,a,h,c;e.exports=(i=(n=r=ge).x64,s=i.Word,o=i.WordArray,a=n.algo,h=a.SHA512,c=a.SHA384=h.extend({_doReset:function(){this._hash=new o.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var e=h._doFinalize.call(this);return e.sigBytes-=16,e}}),n.SHA384=h._createHelper(c),n.HmacSHA384=h._createHmacHelper(c),r.SHA384)}),pe(function(e,t){var r;e.exports=(r=ge,function(e){var t=r,n=t.lib,i=n.WordArray,s=n.Hasher,o=t.x64.Word,a=t.algo,h=[],c=[],l=[];!function(){for(var e=1,t=0,r=0;r<24;r++){h[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)c[e+5*t]=t+(2*e+3*t)%5*5;for(var i=1,s=0;s<24;s++){for(var a=0,u=0,f=0;f<7;f++){if(1&i){var d=(1<<f)-1;d<32?u^=1<<d:a^=1<<d-32}128&i?i=i<<1^113:i<<=1}l[s]=o.create(a,u)}}();var u=[];!function(){for(var e=0;e<25;e++)u[e]=o.create()}();var f=a.SHA3=s.extend({cfg:s.cfg.extend({outputLength:512}),_doReset:function(){for(var e=this._state=[],t=0;t<25;t++)e[t]=new o.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(e,t){for(var r=this._state,n=this.blockSize/2,i=0;i<n;i++){var s=e[t+2*i],o=e[t+2*i+1];s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(B=r[i]).high^=o,B.low^=s}for(var a=0;a<24;a++){for(var f=0;f<5;f++){for(var d=0,p=0,g=0;g<5;g++)d^=(B=r[f+5*g]).high,p^=B.low;var _=u[f];_.high=d,_.low=p}for(f=0;f<5;f++){var v=u[(f+4)%5],w=u[(f+1)%5],m=w.high,b=w.low;for(d=v.high^(m<<1|b>>>31),p=v.low^(b<<1|m>>>31),g=0;g<5;g++)(B=r[f+5*g]).high^=d,B.low^=p}for(var y=1;y<25;y++){var k=(B=r[y]).high,E=B.low,S=h[y];S<32?(d=k<<S|E>>>32-S,p=E<<S|k>>>32-S):(d=E<<S-32|k>>>64-S,p=k<<S-32|E>>>64-S);var x=u[c[y]];x.high=d,x.low=p}var A=u[0],R=r[0];for(A.high=R.high,A.low=R.low,f=0;f<5;f++)for(g=0;g<5;g++){var B=r[y=f+5*g],I=u[y],P=u[(f+1)%5+5*g],D=u[(f+2)%5+5*g];B.high=I.high^~P.high&D.high,B.low=I.low^~P.low&D.low}B=r[0];var L=l[a];B.high^=L.high,B.low^=L.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),s=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/s)*s>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var o=this._state,a=this.cfg.outputLength/8,h=a/8,c=[],l=0;l<h;l++){var u=o[l],f=u.high,d=u.low;f=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(f)}return new i.init(c,a)},clone:function(){for(var e=s.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});t.SHA3=s._createHelper(f),t.HmacSHA3=s._createHmacHelper(f)}(Math),r.SHA3)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib,n=t.WordArray,i=t.Hasher,s=e.algo,o=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),a=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),h=n.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),c=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),l=n.create([0,1518500249,1859775393,2400959708,2840853838]),u=n.create([1352829926,1548603684,1836072691,2053994217,0]),f=s.RIPEMD160=i.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var s,f,m,b,y,k,E,S,x,A,R,B=this._hash.words,I=l.words,P=u.words,D=o.words,L=a.words,z=h.words,T=c.words;for(k=s=B[0],E=f=B[1],S=m=B[2],x=b=B[3],A=y=B[4],r=0;r<80;r+=1)R=s+e[t+D[r]]|0,R+=r<16?d(f,m,b)+I[0]:r<32?p(f,m,b)+I[1]:r<48?g(f,m,b)+I[2]:r<64?_(f,m,b)+I[3]:v(f,m,b)+I[4],R=(R=w(R|=0,z[r]))+y|0,s=y,y=b,b=w(m,10),m=f,f=R,R=k+e[t+L[r]]|0,R+=r<16?v(E,S,x)+P[0]:r<32?_(E,S,x)+P[1]:r<48?g(E,S,x)+P[2]:r<64?p(E,S,x)+P[3]:d(E,S,x)+P[4],R=(R=w(R|=0,T[r]))+A|0,k=A,A=x,x=w(S,10),S=E,E=R;R=B[1]+m+x|0,B[1]=B[2]+b+A|0,B[2]=B[3]+y+k|0,B[3]=B[4]+s+E|0,B[4]=B[0]+f+S|0,B[0]=R},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,s=i.words,o=0;o<5;o++){var a=s[o];s[o]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function d(e,t,r){return e^t^r}function p(e,t,r){return e&t|~e&r}function g(e,t,r){return(e|~t)^r}function _(e,t,r){return e&r|t&~r}function v(e,t,r){return e^(t|~r)}function w(e,t){return e<<t|e>>>32-t}e.RIPEMD160=i._createHelper(f),e.HmacRIPEMD160=i._createHmacHelper(f)}(),r.RIPEMD160)}),pe(function(e,t){var r,n,i,s;e.exports=(n=(r=ge).lib.Base,i=r.enc,s=i.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,h=o.words,c=0;c<r;c++)a[c]^=1549556828,h[c]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))}),pe(function(e,t){var r,n,i,s,o,a,h,c,l;e.exports=(s=(i=(n=r=ge).lib).Base,o=i.WordArray,h=(a=n.algo).SHA1,c=a.HMAC,l=a.PBKDF2=s.extend({cfg:s.extend({keySize:4,hasher:h,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=c.create(r.hasher,e),i=o.create(),s=o.create([1]),a=i.words,h=s.words,l=r.keySize,u=r.iterations;a.length<l;){var f=n.update(t).finalize(s);n.reset();for(var d=f.words,p=d.length,g=f,_=1;_<u;_++){g=n.finalize(g),n.reset();for(var v=g.words,w=0;w<p;w++)d[w]^=v[w]}i.concat(f),h[0]++}return i.sigBytes=4*l,i}}),n.PBKDF2=function(e,t,r){return l.create(r).compute(e,t)},r.PBKDF2)}),pe(function(e,t){var r,n,i,s,o,a,h,c;e.exports=(s=(i=(n=r=ge).lib).Base,o=i.WordArray,h=(a=n.algo).MD5,c=a.EvpKDF=s.extend({cfg:s.extend({keySize:4,hasher:h,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=r.hasher.create(),i=o.create(),s=i.words,a=r.keySize,h=r.iterations;s.length<a;){c&&n.update(c);var c=n.update(e).finalize(t);n.reset();for(var l=1;l<h;l++)c=n.finalize(c),n.reset();i.concat(c)}return i.sigBytes=4*a,i}}),n.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},r.EvpKDF)}),pe(function(e,t){var r,n,i,s,o,a,h,c,l,u,f,d,p,g,_,v,w,m,b,y,k,E,S;e.exports=void((r=ge).lib.Cipher||(n=r,i=n.lib,s=i.Base,o=i.WordArray,a=i.BufferedBlockAlgorithm,h=n.enc,h.Utf8,c=h.Base64,l=n.algo,u=l.EvpKDF,f=i.Cipher=a.extend({cfg:s.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?S:y}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),i.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),d=n.mode={},p=i.BlockCipherMode=s.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),g=d.CBC=function(){var e=p.extend();function t(e,t,r){var n=this._iv;if(n){var i=n;this._iv=undefined}else i=this._prevBlock;for(var s=0;s<r;s++)e[t+s]^=i[s]}return e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize;t.call(this,e,r,i),n.encryptBlock(e,r),this._prevBlock=e.slice(r,r+i)}}),e.Decryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,s=e.slice(r,r+i);n.decryptBlock(e,r),t.call(this,e,r,i),this._prevBlock=s}}),e}(),_=n.pad={},v=_.Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);var h=o.create(s,n);e.concat(h)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},i.BlockCipher=f.extend({cfg:f.cfg.extend({mode:g,padding:v}),reset:function(){f.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,t&&t.words):(this._mode=n.call(r,this,t&&t.words),this._mode.__creator=n)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),w=i.CipherParams=s.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=n.format={},b=m.OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(t);else n=t;return n.toString(c)},parse:function(e){var t=c.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return w.create({ciphertext:t,salt:n})}},y=i.SerializableCipher=s.extend({cfg:s.extend({format:b}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),s=i.finalize(t),o=i.cfg;return w.create({ciphertext:s,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),k=n.kdf={},E=k.OpenSSL={execute:function(e,t,r,n){n||(n=o.random(8));var i=u.create({keySize:t+r}).compute(e,n),s=o.create(i.words.slice(t),4*r);return i.sigBytes=4*t,w.create({key:i,iv:s,salt:n})}},S=i.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:E}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize);n.iv=i.iv;var s=y.encrypt.call(this,e,t,i.key,n);return s.mixIn(i),s},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,y.decrypt.call(this,e,t,i.key,n)}})))}),pe(function(e,t){var r;e.exports=((r=ge).mode.CFB=function(){var e=r.lib.BlockCipherMode.extend();function t(e,t,r,n){var i=this._iv;if(i){var s=i.slice(0);this._iv=void 0}else s=this._prevBlock;n.encryptBlock(s,0);for(var o=0;o<r;o++)e[t+o]^=s[o]}return e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize;t.call(this,e,r,i,n),this._prevBlock=e.slice(r,r+i)}}),e.Decryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,s=e.slice(r,r+i);t.call(this,e,r,i,n),this._prevBlock=s}}),e}(),r.mode.CFB)}),pe(function(e,t){var r,n,i;e.exports=((r=ge).mode.CTR=(i=(n=r.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,s=this._counter;i&&(s=this._counter=i.slice(0),this._iv=void 0);var o=s.slice(0);r.encryptBlock(o,0),s[n-1]=s[n-1]+1|0;for(var a=0;a<n;a++)e[t+a]^=o[a]}}),n.Decryptor=i,n),r.mode.CTR)}),pe(function(e,t){var r;e.exports=((r=ge).mode.CTRGladman=function(){var e=r.lib.BlockCipherMode.extend();function t(e){if(255&~(e>>24))e+=1<<24;else{var t=e>>16&255,r=e>>8&255,n=255&e;255===t?(t=0,255===r?(r=0,255===n?n=0:++n):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=n}return e}var n=e.Encryptor=e.extend({processBlock:function(e,r){var n,i=this._cipher,s=i.blockSize,o=this._iv,a=this._counter;o&&(a=this._counter=o.slice(0),this._iv=void 0),0===((n=a)[0]=t(n[0]))&&(n[1]=t(n[1]));var h=a.slice(0);i.encryptBlock(h,0);for(var c=0;c<s;c++)e[r+c]^=h[c]}});return e.Decryptor=n,e}(),r.mode.CTRGladman)}),pe(function(e,t){var r,n,i;e.exports=((r=ge).mode.OFB=(i=(n=r.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,s=this._keystream;i&&(s=this._keystream=i.slice(0),this._iv=void 0),r.encryptBlock(s,0);for(var o=0;o<n;o++)e[t+o]^=s[o]}}),n.Decryptor=i,n),r.mode.OFB)}),pe(function(e,t){var r,n;e.exports=((r=ge).mode.ECB=((n=r.lib.BlockCipherMode.extend()).Encryptor=n.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),n.Decryptor=n.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),n),r.mode.ECB)}),pe(function(e,t){var r;e.exports=((r=ge).pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,n=4*t,i=n-r%n,s=r+i-1;e.clamp(),e.words[s>>>2]|=i<<24-s%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Ansix923)}),pe(function(e,t){var r;e.exports=((r=ge).pad.Iso10126={pad:function(e,t){var n=4*t,i=n-e.sigBytes%n;e.concat(r.lib.WordArray.random(i-1)).concat(r.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},r.pad.Iso10126)}),pe(function(e,t){var r;e.exports=((r=ge).pad.Iso97971={pad:function(e,t){e.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(e,t)},unpad:function(e){r.pad.ZeroPadding.unpad(e),e.sigBytes--}},r.pad.Iso97971)}),pe(function(e,t){var r;e.exports=((r=ge).pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){for(var t=e.words,r=e.sigBytes-1;!(t[r>>>2]>>>24-r%4*8&255);)r--;e.sigBytes=r+1}},r.pad.ZeroPadding)}),pe(function(e,t){var r;e.exports=((r=ge).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}),pe(function(e,t){var r,n,i,s;e.exports=(i=(n=r=ge).lib.CipherParams,s=n.enc.Hex,n.format.Hex={stringify:function(e){return e.ciphertext.toString(s)},parse:function(e){var t=s.parse(e);return i.create({ciphertext:t})}},r.format.Hex)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],s=[],o=[],a=[],h=[],c=[],l=[],u=[],f=[],d=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var p=n^n<<1^n<<2^n<<3^n<<4;p=p>>>8^255&p^99,i[r]=p,s[p]=r;var g=e[r],_=e[g],v=e[_],w=257*e[p]^16843008*p;o[r]=w<<24|w>>>8,a[r]=w<<16|w>>>16,h[r]=w<<8|w>>>24,c[r]=w,w=16843009*v^65537*_^257*g^16843008*r,l[p]=w<<24|w>>>8,u[p]=w<<16|w>>>16,f[p]=w<<8|w>>>24,d[p]=w,r?(r=g^e[e[e[v^g]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),s=this._keySchedule=[],o=0;o<n;o++)if(o<r)s[o]=t[o];else{var a=s[o-1];o%r?r>6&&o%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[o/r|0]<<24),s[o]=s[o-r]^a}for(var h=this._invKeySchedule=[],c=0;c<n;c++)o=n-c,a=c%4?s[o]:s[o-4],h[c]=c<4||o<=4?a:l[i[a>>>24]]^u[i[a>>>16&255]]^f[i[a>>>8&255]]^d[i[255&a]]}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,a,h,c,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,l,u,f,d,s),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,s,o,a){for(var h=this._nRounds,c=e[t]^r[0],l=e[t+1]^r[1],u=e[t+2]^r[2],f=e[t+3]^r[3],d=4,p=1;p<h;p++){var g=n[c>>>24]^i[l>>>16&255]^s[u>>>8&255]^o[255&f]^r[d++],_=n[l>>>24]^i[u>>>16&255]^s[f>>>8&255]^o[255&c]^r[d++],v=n[u>>>24]^i[f>>>16&255]^s[c>>>8&255]^o[255&l]^r[d++],w=n[f>>>24]^i[c>>>16&255]^s[l>>>8&255]^o[255&u]^r[d++];c=g,l=_,u=v,f=w}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&f])^r[d++],_=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[f>>>8&255]<<8|a[255&c])^r[d++],v=(a[u>>>24]<<24|a[f>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^r[d++],w=(a[f>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[d++],e[t]=g,e[t+1]=_,e[t+2]=v,e[t+3]=w},keySize:8});e.AES=t._createHelper(g)}(),r.AES)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib,n=t.WordArray,i=t.BlockCipher,s=e.algo,o=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],u=s.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=o[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],s=0;s<16;s++){var c=i[s]=[],l=h[s];for(r=0;r<24;r++)c[r/6|0]|=t[(a[r]-1+l)%28]<<31-r%6,c[4+(r/6|0)]|=t[28+(a[r+24]-1+l)%28]<<31-r%6;for(c[0]=c[0]<<1|c[0]>>>31,r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var u=this._invSubKeys=[];for(r=0;r<16;r++)u[r]=i[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],f.call(this,4,252645135),f.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),f.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],s=this._lBlock,o=this._rBlock,a=0,h=0;h<8;h++)a|=c[h][((o^i[h])&l[h])>>>0];this._lBlock=o,this._rBlock=s^a}var u=this._lBlock;this._lBlock=this._rBlock,this._rBlock=u,f.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function f(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<<e}function d(e,t){var r=(this._rBlock>>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<<e}e.DES=i._createHelper(u);var p=s.TripleDES=i.extend({_doReset:function(){var e=this._key.words;this._des1=u.createEncryptor(n.create(e.slice(0,2))),this._des2=u.createEncryptor(n.create(e.slice(2,4))),this._des3=u.createEncryptor(n.create(e.slice(4,6)))},encryptBlock:function(e,t){this._des1.encryptBlock(e,t),this._des2.decryptBlock(e,t),this._des3.encryptBlock(e,t)},decryptBlock:function(e,t){this._des3.decryptBlock(e,t),this._des2.encryptBlock(e,t),this._des1.decryptBlock(e,t)},keySize:6,ivSize:2,blockSize:2});e.TripleDES=i._createHelper(p)}(),r.TripleDES)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.StreamCipher,n=e.algo,i=n.RC4=t.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var s=0;i<256;i++){var o=i%r,a=t[o>>>2]>>>24-o%4*8&255;s=(s+n[i]+a)%256;var h=n[i];n[i]=n[s],n[s]=h}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=s.call(this)},keySize:8,ivSize:0});function s(){for(var e=this._S,t=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+e[t=(t+1)%256])%256;var s=e[t];e[t]=e[r],e[r]=s,n|=e[(e[t]+e[r])%256]<<24-8*i}return this._i=t,this._j=r,n}e.RC4=t._createHelper(i);var o=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)s.call(this)}});e.RC4Drop=t._createHelper(o)}(),r.RC4)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.StreamCipher,n=e.algo,i=[],s=[],o=[],a=n.Rabbit=t.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)h.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(t){var s=t.words,o=s[0],a=s[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=c>>>16|4294901760&l,f=l<<16|65535&c;for(i[0]^=c,i[1]^=u,i[2]^=l,i[3]^=f,i[4]^=c,i[5]^=u,i[6]^=l,i[7]^=f,r=0;r<4;r++)h.call(this)}},_doProcessBlock:function(e,t){var r=this._X;h.call(this),i[0]=r[0]^r[5]>>>16^r[3]<<16,i[1]=r[2]^r[7]>>>16^r[5]<<16,i[2]=r[4]^r[1]>>>16^r[7]<<16,i[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),e[t+n]^=i[n]},blockSize:4,ivSize:2});function h(){for(var e=this._X,t=this._C,r=0;r<8;r++)s[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<s[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<s[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<s[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<s[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<s[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<s[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<s[6]>>>0?1:0)|0,this._b=t[7]>>>0<s[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],i=65535&n,a=n>>>16,h=((i*i>>>17)+i*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=h^c}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=t._createHelper(a)}(),r.Rabbit)}),pe(function(e,t){var r;e.exports=(r=ge,function(){var e=r,t=e.lib.StreamCipher,n=e.algo,i=[],s=[],o=[],a=n.RabbitLegacy=t.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)h.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var s=t.words,o=s[0],a=s[1],c=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),l=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),u=c>>>16|4294901760&l,f=l<<16|65535&c;for(n[0]^=c,n[1]^=u,n[2]^=l,n[3]^=f,n[4]^=c,n[5]^=u,n[6]^=l,n[7]^=f,i=0;i<4;i++)h.call(this)}},_doProcessBlock:function(e,t){var r=this._X;h.call(this),i[0]=r[0]^r[5]>>>16^r[3]<<16,i[1]=r[2]^r[7]>>>16^r[5]<<16,i[2]=r[4]^r[1]>>>16^r[7]<<16,i[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)i[n]=16711935&(i[n]<<8|i[n]>>>24)|4278255360&(i[n]<<24|i[n]>>>8),e[t+n]^=i[n]},blockSize:4,ivSize:2});function h(){for(var e=this._X,t=this._C,r=0;r<8;r++)s[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<s[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<s[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<s[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<s[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<s[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<s[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<s[6]>>>0?1:0)|0,this._b=t[7]>>>0<s[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],i=65535&n,a=n>>>16,h=((i*i>>>17)+i*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=h^c}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=t._createHelper(a)}(),r.RabbitLegacy)}),pe(function(e,t){e.exports=ge}));function ve(){throw new Error("setTimeout has not been defined")}function we(){throw new Error("clearTimeout has not been defined")}var me=ve,be=we;function ye(e){if(me===setTimeout)return setTimeout(e,0);if((me===ve||!me)&&setTimeout)return me=setTimeout,setTimeout(e,0);try{return me(e,0)}catch(t){try{return me.call(null,e,0)}catch(r){return me.call(this,e,0)}}}"function"==typeof g.setTimeout&&(me=setTimeout),"function"==typeof g.clearTimeout&&(be=clearTimeout);var ke,Ee=[],Se=!1,xe=-1;function Ae(){Se&&ke&&(Se=!1,ke.length?Ee=ke.concat(Ee):xe=-1,Ee.length&&Re())}function Re(){if(!Se){var e=ye(Ae);Se=!0;for(var t=Ee.length;t;){for(ke=Ee,Ee=[];++xe<t;)ke&&ke[xe].run();xe=-1,t=Ee.length}ke=null,Se=!1,function(e){if(be===clearTimeout)return clearTimeout(e);if((be===we||!be)&&clearTimeout)return be=clearTimeout,clearTimeout(e);try{be(e)}catch(t){try{return be.call(null,e)}catch(r){return be.call(this,e)}}}(e)}}function Be(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];Ee.push(new Ie(e,t)),1!==Ee.length||Se||ye(Re)}function Ie(e,t){this.fun=e,this.array=t}Ie.prototype.run=function(){this.fun.apply(null,this.array)};var Pe=g.performance||{};function De(){}function Le(){Le.init.call(this)}function ze(e){return void 0===e._maxListeners?Le.defaultMaxListeners:e._maxListeners}function Te(e,t,r,n){var i,s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=new De,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=ze(e))&&i>0&&o.length>i){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,a=h,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=r,++e._eventsCount;return e}function Ce(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Me(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Oe(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Pe.now||Pe.mozNow||Pe.msNow||Pe.oNow||Pe.webkitNow,De.prototype=Object.create(null),Le.EventEmitter=Le,Le.usingDomains=!1,Le.prototype.domain=void 0,Le.prototype._events=void 0,Le.prototype._maxListeners=void 0,Le.defaultMaxListeners=10,Le.init=function(){this.domain=null,Le.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new De,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Le.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Le.prototype.getMaxListeners=function(){return ze(this)},Le.prototype.emit=function(e){var t,r,n,i,s,o,a,h="error"===e;if(o=this._events)h=h&&null==o.error;else if(!h)return!1;if(a=this.domain,h){if(t=arguments[1],!a){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Oe(e,n),s=0;s<n;++s)i[s].call(r)}(r,l,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Oe(e,i),o=0;o<i;++o)s[o].call(r,n)}(r,l,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Oe(e,s),a=0;a<s;++a)o[a].call(r,n,i)}(r,l,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Oe(e,o),h=0;h<o;++h)a[h].call(r,n,i,s)}(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Oe(e,i),o=0;o<i;++o)s[o].apply(r,n)}(r,l,this,i)}return!0},Le.prototype.addListener=function(e,t){return Te(this,e,t,!1)},Le.prototype.on=Le.prototype.addListener,Le.prototype.prependListener=function(e,t){return Te(this,e,t,!0)},Le.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ce(this,e,t)),this},Le.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ce(this,e,t)),this},Le.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new De:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new De,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},Le.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new De,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new De:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),s=0;s<i.length;++s)"removeListener"!==(n=i[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new De,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Le.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Le.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Me.call(e,t)},Le.prototype.listenerCount=Me,Le.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Ue="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},Ne=/%[sdj%]/g;function Fe(e){if(!Je(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(je(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,s=String(e).replace(Ne,function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}}),o=n[r];r<i;o=n[++r])Ge(o)||!tt(o)?s+=" "+o:s+=" "+je(o);return s}function We(e,t){if(Qe(g.process))return function(){return We(e,t).apply(this,arguments)};var r=!1;return function(){return r||(console.error(t),r=!0),e.apply(this,arguments)}}var He,Ze={};function je(e,t){var r={seen:[],stylize:Ve};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Xe(t)?r.showHidden=t:t&&function(e,t){if(!t||!tt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]]}(r,t),Qe(r.showHidden)&&(r.showHidden=!1),Qe(r.depth)&&(r.depth=2),Qe(r.colors)&&(r.colors=!1),Qe(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Ke),$e(r,e,r.depth)}function Ke(e,t){var r=je.styles[t];return r?"["+je.colors[r][0]+"m"+e+"["+je.colors[r][1]+"m":e}function Ve(e,t){return e}function $e(e,t,r){if(e.customInspect&&t&&it(t.inspect)&&t.inspect!==je&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return Je(n)||(n=$e(e,n,r)),n}var i=function(e,t){if(Qe(t))return e.stylize("undefined","undefined");if(Je(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return"number"==typeof t?e.stylize(""+t,"number"):Xe(t)?e.stylize(""+t,"boolean"):Ge(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var s,o=Object.keys(t),a=(s={},o.forEach(function(e,t){s[e]=!0}),s);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),nt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return qe(t);if(0===o.length){if(it(t)){var h=t.name?": "+t.name:"";return e.stylize("[Function"+h+"]","special")}if(et(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(nt(t))return qe(t)}var c,l,u="",f=!1,d=["{","}"];return c=t,Array.isArray(c)&&(f=!0,d=["[","]"]),it(t)&&(u=" [Function"+(t.name?": "+t.name:"")+"]"),et(t)&&(u=" "+RegExp.prototype.toString.call(t)),rt(t)&&(u=" "+Date.prototype.toUTCString.call(t)),nt(t)&&(u=" "+qe(t)),0!==o.length||f&&0!=t.length?r<0?et(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),l=f?function(e,t,r,n,i){for(var s=[],o=0,a=t.length;o<a;++o)ot(t,String(o))?s.push(Ye(e,t,r,n,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(Ye(e,t,r,n,i,!0))}),s}(e,t,r,a,o):o.map(function(n){return Ye(e,t,r,a,n,f)}),e.seen.pop(),function(e,t,r){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(l,u,d)):d[0]+u+d[1]}function qe(e){return"["+Error.prototype.toString.call(e)+"]"}function Ye(e,t,r,n,i,s){var o,a,h;if((h=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=h.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):h.set&&(a=e.stylize("[Setter]","special")),ot(n,i)||(o="["+i+"]"),a||(e.seen.indexOf(h.value)<0?(a=Ge(r)?$e(e,h.value,null):$e(e,h.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),Qe(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function Xe(e){return"boolean"==typeof e}function Ge(e){return null===e}function Je(e){return"string"==typeof e}function Qe(e){return void 0===e}function et(e){return tt(e)&&"[object RegExp]"===st(e)}function tt(e){return"object"==typeof e&&null!==e}function rt(e){return tt(e)&&"[object Date]"===st(e)}function nt(e){return tt(e)&&("[object Error]"===st(e)||e instanceof Error)}function it(e){return"function"==typeof e}function st(e){return Object.prototype.toString.call(e)}function ot(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function at(){this.head=null,this.tail=null,this.length=0}je.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},je.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},at.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},at.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},at.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},at.prototype.clear=function(){this.head=this.tail=null,this.length=0},at.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},at.prototype.concat=function(e){if(0===this.length)return I.alloc(0);if(1===this.length)return this.head.data;for(var t=I.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var ht=I.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function ct(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!ht(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=ut;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=ft;break;default:return void(this.write=lt)}this.charBuffer=new I(6),this.charReceived=0,this.charLength=0}function lt(e){return e.toString(this.encoding)}function ut(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function ft(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}ct.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(e=e.slice(r,e.length),!((n=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),i=(t+=e.toString(this.encoding,0,i)).length-1,(n=t.charCodeAt(i))>=55296&&n<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),e.copy(this.charBuffer,0,0,s),t.substring(0,i)}return t},ct.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},ct.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},_t.ReadableState=gt;var dt,pt=(dt="stream",Qe(He)&&(He=""),dt=dt.toUpperCase(),Ze[dt]||(new RegExp("\\b"+dt+"\\b","i").test(He)?Ze[dt]=function(){var e=Fe.apply(null,arguments);console.error("%s %d: %s",dt,0,e)}:Ze[dt]=function(){}),Ze[dt]);function gt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof jt&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new at,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new ct(e.encoding),this.encoding=e.encoding)}function _t(e){if(!(this instanceof _t))return new _t(e);this._readableState=new gt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),Le.call(this)}function vt(e,t,r,n,i){var s,o,a,h=(s=t,a=null,fe(o=r)||"string"==typeof o||null==o||s.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a);if(h)e.emit("error",h);else if(null===r)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,bt(e)}}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var c=new Error("stream.push() after EOF");e.emit("error",c)}else if(t.endEmitted&&i){var l=new Error("stream.unshift() after end event");e.emit("error",l)}else{var u;!t.decoder||i||n||(r=t.decoder.write(r),u=!t.objectMode&&0===r.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&bt(e))),function(e,t){t.readingMore||(t.readingMore=!0,Be(kt,e,t))}(e,t)}else i||(t.reading=!1);return function(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}(t)}Ue(_t,Le),_t.prototype.push=function(e,t){var r=this._readableState;return r.objectMode||"string"!=typeof e||(t=t||r.defaultEncoding)!==r.encoding&&(e=I.from(e,t),t=""),vt(this,r,e,t,!1)},_t.prototype.unshift=function(e){return vt(this,this._readableState,e,"",!0)},_t.prototype.isPaused=function(){return!1===this._readableState.flowing},_t.prototype.setEncoding=function(e){return this._readableState.decoder=new ct(e),this._readableState.encoding=e,this};var wt=8388608;function mt(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=((r=e)>=wt?r=wt:(r--,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r++),r)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0));var r}function bt(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(pt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Be(yt,e):yt(e))}function yt(e){pt("emit readable"),e.emit("readable"),xt(e)}function kt(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(pt("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function Et(e){pt("readable nexttick read 0"),e.read(0)}function St(e,t){t.reading||(pt("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),xt(e),t.flowing&&!t.reading&&e.read(0)}function xt(e){var t=e._readableState;for(pt("flow",t.flowing);t.flowing&&null!==e.read(););}function At(e,t){return 0===t.length?null:(t.objectMode?o=t.buffer.shift():!e||e>=t.length?(o=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(r=e,n=t.buffer,i=t.decoder,r<n.head.data.length?(s=n.head.data.slice(0,r),n.head.data=n.head.data.slice(r)):s=r===n.head.data.length?n.shift():i?function(e,t){var r=t.head,n=1,i=r.data;for(e-=i.length;r=r.next;){var s=r.data,o=e>s.length?s.length:e;if(o===s.length?i+=s:i+=s.slice(0,e),0===(e-=o)){o===s.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(o));break}++n}return t.length-=n,i}(r,n):function(e,t){var r=I.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,o),0===(e-=o)){o===s.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(o));break}++i}return t.length-=i,r}(r,n),o=s),o);var r,n,i,s,o}function Rt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Be(Bt,t,e))}function Bt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function It(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Pt(){}function Dt(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function Lt(e,t){Object.defineProperty(this,"buffer",{get:We(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),e=e||{},this.objectMode=!!e.objectMode,t instanceof jt&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=!1===e.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r,n=e._writableState,i=n.sync,s=n.writecb;if((r=n).writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,t)!function(e,t,r,n,i){--t.pendingcb,r?Be(i,n):i(n),e._writableState.errorEmitted=!0,e.emit("error",n)}(e,n,i,t,s);else{var o=Ot(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||Mt(e,n),i?Be(Ct,e,n,o,s):Ct(e,n,o,s)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new Ft(this)}function zt(e){if(!(this instanceof zt||this instanceof jt))return new zt(e);this._writableState=new Lt(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev)),Le.call(this)}function Tt(e,t,r,n,i,s,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,s,t.onwrite),t.sync=!1}function Ct(e,t,r,n){var i,s;r||(i=e,0===(s=t).length&&s.needDrain&&(s.needDrain=!1,i.emit("drain"))),t.pendingcb--,n(),Nt(e,t)}function Mt(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var o=0;r;)i[o]=r,r=r.next,o+=1;Tt(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new Ft(t)}else{for(;r;){var a=r.chunk,h=r.encoding,c=r.callback;if(Tt(e,t,!1,t.objectMode?1:a.length,a,h,c),r=r.next,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}function Ot(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ut(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function Nt(e,t){var r=Ot(t);return r&&(0===t.pendingcb?(Ut(e,t),t.finished=!0,e.emit("finish")):Ut(e,t)),r}function Ft(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}_t.prototype.read=function(e){pt("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return pt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Rt(this):bt(this),null;if(0===(e=mt(e,t))&&t.ended)return 0===t.length&&Rt(this),null;var n,i=t.needReadable;return pt("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&pt("length less than watermark",i=!0),t.ended||t.reading?pt("reading or ended",i=!1):i&&(pt("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=mt(r,t))),null===(n=e>0?At(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Rt(this)),null!==n&&this.emit("data",n),n},_t.prototype._read=function(e){this.emit("error",new Error("not implemented"))},_t.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,pt("pipe count=%d opts=%j",n.pipesCount,t);var i=t&&!1===t.end?l:o;function s(e){pt("onunpipe"),e===r&&l()}function o(){pt("onend"),e.end()}n.endEmitted?Be(i):r.once("end",i),e.on("unpipe",s);var a,h=(a=r,function(){var e=a._readableState;pt("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a.listeners("data").length&&(e.flowing=!0,xt(a))});e.on("drain",h);var c=!1;function l(){pt("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",h),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",o),r.removeListener("end",l),r.removeListener("data",f),c=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||h()}var u=!1;function f(t){pt("ondata"),u=!1,!1!==e.write(t)||u||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==It(n.pipes,e))&&!c&&(pt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,u=!0),r.pause())}function d(t){pt("onerror",t),_(),e.removeListener("error",d),0===e.listeners("error").length&&e.emit("error",t)}function p(){e.removeListener("finish",g),_()}function g(){pt("onfinish"),e.removeListener("close",p),_()}function _(){pt("unpipe"),r.unpipe(e)}return r.on("data",f),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",g),e.emit("pipe",r),n.flowing||(pt("pipe resume"),r.resume()),e},_t.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var s=It(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},_t.prototype.on=function(e,t){var r=Le.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&bt(this):Be(Et,this))}return r},_t.prototype.addListener=_t.prototype.on,_t.prototype.resume=function(){var e,t,r=this._readableState;return r.flowing||(pt("resume"),r.flowing=!0,e=this,(t=r).resumeScheduled||(t.resumeScheduled=!0,Be(St,e,t))),this},_t.prototype.pause=function(){return pt("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(pt("pause"),this._readableState.flowing=!1,this.emit("pause")),this},_t.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;for(var i in e.on("end",function(){if(pt("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&n.push(e)}n.push(null)}),e.on("data",function(i){pt("wrapped data"),t.decoder&&(i=t.decoder.write(i)),t.objectMode&&null==i||(t.objectMode||i&&i.length)&&(n.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));return function(e,t){for(var r=0,n=e.length;r<n;r++)t(e[r])}(["error","close","destroy","pause","resume"],function(t){e.on(t,n.emit.bind(n,t))}),n._read=function(t){pt("wrapped _read",t),r&&(r=!1,e.resume())},n},_t._fromList=At,zt.WritableState=Lt,Ue(zt,Le),Lt.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},zt.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},zt.prototype.write=function(e,t,r){var n,i,s,o=this._writableState,a=!1;return"function"==typeof t&&(r=t,t=null),I.isBuffer(e)?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof r&&(r=Pt),o.ended?(n=this,i=r,s=new Error("write after end"),n.emit("error",s),Be(i,s)):function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):I.isBuffer(r)||"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),Be(n,s),i=!1),i}(this,o,e,r)&&(o.pendingcb++,a=function(e,t,r,n,i){var s,o,a;o=r,a=n,(s=t).objectMode||!1===s.decodeStrings||"string"!=typeof o||(o=I.from(o,a)),r=o,I.isBuffer(r)&&(n="buffer");var h=t.objectMode?1:r.length;t.length+=h;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest=new Dt(r,n,i),l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else Tt(e,t,!1,h,r,n,i);return c}(this,o,e,t,r)),a},zt.prototype.cork=function(){this._writableState.corked++},zt.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||Mt(this,e))},zt.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},zt.prototype._write=function(e,t,r){r(new Error("not implemented"))},zt.prototype._writev=null,zt.prototype.end=function(e,t,r){var n,i,s,o=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||o.finished||(n=this,s=r,(i=o).ending=!0,Nt(n,i),s&&(i.finished?Be(s):n.once("finish",s)),i.ended=!0,n.writable=!1)},Ue(jt,_t);for(var Wt=Object.keys(zt.prototype),Ht=0;Ht<Wt.length;Ht++){var Zt=Wt[Ht];jt.prototype[Zt]||(jt.prototype[Zt]=zt.prototype[Zt])}function jt(e){if(!(this instanceof jt))return new jt(e);_t.call(this,e),zt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",Kt)}function Kt(){this.allowHalfOpen||this._writableState.ended||Be(Vt,this)}function Vt(e){e.end()}function $t(e){this.afterTransform=function(t,r){return function(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!=r&&e.push(r),i(t);var s=e._readableState;s.reading=!1,(s.needReadable||s.length<s.highWaterMark)&&e._read(s.highWaterMark)}(e,t,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function qt(e){if(!(this instanceof qt))return new qt(e);jt.call(this,e),this._transformState=new $t(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(e){Yt(t,e)}):Yt(t)})}function Yt(e,t){if(t)return e.emit("error",t);var r=e._writableState,n=e._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}function Xt(e){if(!(this instanceof Xt))return new Xt(e);qt.call(this,e)}function Gt(){Le.call(this)}Ue(qt,jt),qt.prototype.push=function(e,t){return this._transformState.needTransform=!1,jt.prototype.push.call(this,e,t)},qt.prototype._transform=function(e,t,r){throw new Error("Not implemented")},qt.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},qt.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},Ue(Xt,qt),Xt.prototype._transform=function(e,t,r){r(null,e)},Ue(Gt,Le),Gt.Readable=_t,Gt.Writable=zt,Gt.Duplex=jt,Gt.Transform=qt,Gt.PassThrough=Xt,Gt.Stream=Gt,Gt.prototype.pipe=function(e,t){var r=this;function n(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function i(){r.readable&&r.resume&&r.resume()}r.on("data",n),e.on("drain",i),e._isStdio||t&&!1===t.end||(r.on("end",o),r.on("close",a));var s=!1;function o(){s||(s=!0,e.end())}function a(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function h(e){if(c(),0===Le.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",o),r.removeListener("close",a),r.removeListener("error",h),e.removeListener("error",h),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",h),e.on("error",h),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e};var Jt={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"};function Qt(){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}function er(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var s=0;s<n;s++)e[i+s]=t[r+s]}var tr=Uint8Array,rr=Uint16Array,nr=Int32Array;function ir(e){for(var t=e.length;--t>=0;)e[t]=0}var sr=256,or=286,ar=30,hr=15,cr=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],lr=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ur=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],fr=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],dr=new Array(576);ir(dr);var pr=new Array(60);ir(pr);var gr=new Array(512);ir(gr);var _r=new Array(256);ir(_r);var vr=new Array(29);ir(vr);var wr,mr,br,yr=new Array(ar);function kr(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function Er(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Sr(e){return e<256?gr[e]:gr[256+(e>>>7)]}function xr(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Ar(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,xr(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function Rr(e,t,r){Ar(e,r[2*t],r[2*t+1])}function Br(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function Ir(e,t,r){var n,i,s=new Array(16),o=0;for(n=1;n<=hr;n++)s[n]=o=o+r[n-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=Br(s[a]++,a))}}function Pr(e){var t;for(t=0;t<or;t++)e.dyn_ltree[2*t]=0;for(t=0;t<ar;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Dr(e){e.bi_valid>8?xr(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Lr(e,t,r,n){var i=2*t,s=2*r;return e[i]<e[s]||e[i]===e[s]&&n[t]<=n[r]}function zr(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&Lr(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Lr(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Tr(e,t,r){var n,i,s,o,a=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],i=e.pending_buf[e.l_buf+a],a++,0===n?Rr(e,i,t):(Rr(e,(s=_r[i])+sr+1,t),0!==(o=cr[s])&&Ar(e,i-=vr[s],o),Rr(e,s=Sr(--n),r),0!==(o=lr[s])&&Ar(e,n-=yr[s],o))}while(a<e.last_lit);Rr(e,256,t)}function Cr(e,t){var r,n,i,s=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,h=t.stat_desc.elems,c=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<h;r++)0!==s[2*r]?(e.heap[++e.heap_len]=c=r,e.depth[r]=0):s[2*r+1]=0;for(;e.heap_len<2;)s[2*(i=e.heap[++e.heap_len]=c<2?++c:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=o[2*i+1]);for(t.max_code=c,r=e.heap_len>>1;r>=1;r--)zr(e,s,r);i=h;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],zr(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,zr(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,o,a,h=t.dyn_tree,c=t.max_code,l=t.stat_desc.static_tree,u=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(s=0;s<=hr;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)>p&&(s=p,g++),h[2*n+1]=s,n>c||(e.bl_count[s]++,o=0,n>=d&&(o=f[n-d]),a=h[2*n],e.opt_len+=a*(s+o),u&&(e.static_len+=a*(l[2*n+1]+o)));if(0!==g){do{for(s=p-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(s=p;0!==s;s--)for(n=e.bl_count[s];0!==n;)(i=e.heap[--r])>c||(h[2*i+1]!==s&&(e.opt_len+=(s-h[2*i+1])*h[2*i],h[2*i+1]=s),n--)}}(e,t),Ir(s,c,e.bl_count)}function Mr(e,t,r){var n,i,s=-1,o=t[1],a=0,h=7,c=4;for(0===o&&(h=138,c=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++a<h&&i===o||(a<c?e.bl_tree[2*i]+=a:0!==i?(i!==s&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=i,0===o?(h=138,c=3):i===o?(h=6,c=3):(h=7,c=4))}function Or(e,t,r){var n,i,s=-1,o=t[1],a=0,h=7,c=4;for(0===o&&(h=138,c=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++a<h&&i===o)){if(a<c)do{Rr(e,i,e.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(Rr(e,i,e.bl_tree),a--),Rr(e,16,e.bl_tree),Ar(e,a-3,2)):a<=10?(Rr(e,17,e.bl_tree),Ar(e,a-3,3)):(Rr(e,18,e.bl_tree),Ar(e,a-11,7));a=0,s=i,0===o?(h=138,c=3):i===o?(h=6,c=3):(h=7,c=4)}}ir(yr);var Ur=!1;function Nr(e,t,r,n){var i,s,o;Ar(e,0+(n?1:0),3),s=t,o=r,Dr(i=e),xr(i,o),xr(i,~o),er(i.pending_buf,i.window,s,o,i.pending),i.pending+=o}function Fr(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(_r[r]+sr+1)]++,e.dyn_dtree[2*Sr(t)]++),e.last_lit===e.lit_bufsize-1}function Wr(e,t,r,n){for(var i=65535&e,s=e>>>16&65535,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(i=i+t[n++]|0)|0}while(--o);i%=65521,s%=65521}return i|s<<16}var Hr=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function Zr(e,t,r,n){var i=Hr,s=n+r;e^=-1;for(var o=n;o<s;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}var jr,Kr=-2,Vr=258,$r=262,qr=103,Yr=113,Xr=666;function Gr(e,t){return e.msg=Jt[t],t}function Jr(e){return(e<<1)-(e>4?9:0)}function Qr(e){for(var t=e.length;--t>=0;)e[t]=0}function en(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(er(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function tn(e,t){(function(e,t,r,n){var i,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<sr;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),Cr(e,e.l_desc),Cr(e,e.d_desc),o=function(e){var t;for(Mr(e,e.dyn_ltree,e.l_desc.max_code),Mr(e,e.dyn_dtree,e.d_desc.max_code),Cr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*fr[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?Nr(e,t,r,n):4===e.strategy||s===i?(Ar(e,2+(n?1:0),3),Tr(e,dr,pr)):(Ar(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Ar(e,t-257,5),Ar(e,r-1,5),Ar(e,n-4,4),i=0;i<n;i++)Ar(e,e.bl_tree[2*fr[i]+1],3);Or(e,e.dyn_ltree,t-1),Or(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Tr(e,e.dyn_ltree,e.dyn_dtree)),Pr(e),n&&Dr(e)})(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,en(e.strm)}function rn(e,t){e.pending_buf[e.pending++]=t}function nn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function sn(e,t){var r,n,i=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,h=e.strstart>e.w_size-$r?e.strstart-(e.w_size-$r):0,c=e.window,l=e.w_mask,u=e.prev,f=e.strstart+Vr,d=c[s+o-1],p=c[s+o];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(c[(r=t)+o]===p&&c[r+o-1]===d&&c[r]===c[s]&&c[++r]===c[s+1]){s+=2,r++;do{}while(c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&s<f);if(n=Vr-(f-s),s=f-Vr,n>o){if(e.match_start=t,o=n,n>=a)break;d=c[s+o-1],p=c[s+o]}}}while((t=u[t&l])>h&&0!=--i);return o<=e.lookahead?o:e.lookahead}function on(e){var t,r,n,i,s,o,a,h,c,l,u=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=u+(u-$r)){er(e.window,e.window,u,u,0),e.match_start-=u,e.strstart-=u,e.block_start-=u,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=u?n-u:0}while(--r);t=r=u;do{n=e.prev[--t],e.prev[t]=n>=u?n-u:0}while(--r);i+=u}if(0===e.strm.avail_in)break;if(o=e.strm,a=e.window,h=e.strstart+e.lookahead,c=i,l=void 0,(l=o.avail_in)>c&&(l=c),r=0===l?0:(o.avail_in-=l,er(a,o.input,o.next_in,l,h),1===o.state.wrap?o.adler=Wr(o.adler,a,l,h):2===o.state.wrap&&(o.adler=Zr(o.adler,a,l,h)),o.next_in+=l,o.total_in+=l,l),e.lookahead+=r,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+3-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<$r&&0!==e.strm.avail_in)}function an(e,t){for(var r,n;;){if(e.lookahead<$r){if(on(e),e.lookahead<$r&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-$r&&(e.match_length=sn(e,r)),e.match_length>=3)if(n=Fr(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(tn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(tn(e,!1),0===e.strm.avail_out)?1:2}function hn(e,t){for(var r,n,i;;){if(e.lookahead<$r){if(on(e),e.lookahead<$r&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-$r&&(e.match_length=sn(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Fr(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(tn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Fr(e,0,e.window[e.strstart-1]))&&tn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Fr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(tn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(tn(e,!1),0===e.strm.avail_out)?1:2}function cn(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function ln(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new rr(1146),this.dyn_dtree=new rr(122),this.bl_tree=new rr(78),Qr(this.dyn_ltree),Qr(this.dyn_dtree),Qr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new rr(16),this.heap=new rr(573),Qr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new rr(573),Qr(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function un(e){var t,r,n,i=(r=e)&&r.state?(r.total_in=r.total_out=0,r.data_type=2,(n=r.state).pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap?42:Yr,r.adler=2===n.wrap?0:1,n.last_flush=0,function(e){Ur||(function(){var e,t,r,n,i,s=new Array(16);for(r=0,n=0;n<28;n++)for(vr[n]=r,e=0;e<1<<cr[n];e++)_r[r++]=n;for(_r[r-1]=n,i=0,n=0;n<16;n++)for(yr[n]=i,e=0;e<1<<lr[n];e++)gr[i++]=n;for(i>>=7;n<ar;n++)for(yr[n]=i<<7,e=0;e<1<<lr[n]-7;e++)gr[256+i++]=n;for(t=0;t<=hr;t++)s[t]=0;for(e=0;e<=143;)dr[2*e+1]=8,e++,s[8]++;for(;e<=255;)dr[2*e+1]=9,e++,s[9]++;for(;e<=279;)dr[2*e+1]=7,e++,s[7]++;for(;e<=287;)dr[2*e+1]=8,e++,s[8]++;for(Ir(dr,287,s),e=0;e<ar;e++)pr[2*e+1]=5,pr[2*e]=Br(e,5);wr=new kr(dr,cr,257,or,hr),mr=new kr(pr,lr,0,ar,hr),br=new kr(new Array(0),ur,0,19,7)}(),Ur=!0),e.l_desc=new Er(e.dyn_ltree,wr),e.d_desc=new Er(e.dyn_dtree,mr),e.bl_desc=new Er(e.bl_tree,br),e.bi_buf=0,e.bi_valid=0,Pr(e)}(n),0):Gr(r,Kr);return 0===i&&((t=e.state).window_size=2*t.w_size,Qr(t.head),t.max_lazy_match=jr[t.level].max_lazy,t.good_match=jr[t.level].good_length,t.nice_match=jr[t.level].nice_length,t.max_chain_length=jr[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),i}function fn(e,t){var r,n,i,s;if(!e||!e.state||t>5||t<0)return e?Gr(e,Kr):Kr;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===Xr&&4!==t)return Gr(e,0===e.avail_out?-5:Kr);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,rn(n,31),rn(n,139),rn(n,8),n.gzhead?(rn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),rn(n,255&n.gzhead.time),rn(n,n.gzhead.time>>8&255),rn(n,n.gzhead.time>>16&255),rn(n,n.gzhead.time>>24&255),rn(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(rn(n,255&n.gzhead.extra.length),rn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Zr(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(rn(n,0),rn(n,0),rn(n,0),rn(n,0),rn(n,0),rn(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),rn(n,3),n.status=Yr);else{var o=8+(n.w_bits-8<<4)<<8;o|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(o|=32),o+=31-o%31,n.status=Yr,nn(n,o),0!==n.strstart&&(nn(n,e.adler>>>16),nn(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),en(e),i=n.pending,n.pending!==n.pending_buf_size));)rn(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),en(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,rn(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),en(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,rn(n,s)}while(0!==s);n.gzhead.hcrc&&n.pending>i&&(e.adler=Zr(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=qr)}else n.status=qr;if(n.status===qr&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&en(e),n.pending+2<=n.pending_buf_size&&(rn(n,255&e.adler),rn(n,e.adler>>8&255),e.adler=0,n.status=Yr)):n.status=Yr),0!==n.pending){if(en(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&Jr(t)<=Jr(r)&&4!==t)return Gr(e,-5);if(n.status===Xr&&0!==e.avail_in)return Gr(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==Xr){var a=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(on(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(tn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(tn(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,o=e.window;;){if(e.lookahead<=Vr){if(on(e),e.lookahead<=Vr&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){s=e.strstart+Vr;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);e.match_length=Vr-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Fr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(tn(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(tn(e,!1),0===e.strm.avail_out)?1:2}(n,t):jr[n.level].func(n,t);if(3!==a&&4!==a||(n.status=Xr),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===a&&(1===t?function(e){var t;Ar(e,2,3),Rr(e,256,dr),16===(t=e).bi_valid?(xr(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(n):5!==t&&(Nr(n,0,0,!1),3===t&&(Qr(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),en(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(rn(n,255&e.adler),rn(n,e.adler>>8&255),rn(n,e.adler>>16&255),rn(n,e.adler>>24&255),rn(n,255&e.total_in),rn(n,e.total_in>>8&255),rn(n,e.total_in>>16&255),rn(n,e.total_in>>24&255)):(nn(n,e.adler>>>16),nn(n,65535&e.adler)),en(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)}jr=[new cn(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(on(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,tn(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-$r&&(tn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(tn(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(tn(e,!1),e.strm.avail_out),1)}),new cn(4,4,8,4,an),new cn(4,5,16,8,an),new cn(4,6,32,32,an),new cn(4,4,16,16,hn),new cn(8,16,32,32,hn),new cn(8,16,128,128,hn),new cn(8,32,128,256,hn),new cn(32,128,258,1024,hn),new cn(32,258,258,4096,hn)];function dn(e,t){var r,n,i,s,o,a,h,c,l,u,f,d,p,g,_,v,w,m,b,y,k,E,S,x,A;r=e.state,n=e.next_in,x=e.input,i=n+(e.avail_in-5),s=e.next_out,A=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),h=r.dmax,c=r.wsize,l=r.whave,u=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,_=r.distcode,v=(1<<r.lenbits)-1,w=(1<<r.distbits)-1;e:do{p<15&&(d+=x[n++]<<p,p+=8,d+=x[n++]<<p,p+=8),m=g[d&v];t:for(;;){if(d>>>=b=m>>>24,p-=b,0==(b=m>>>16&255))A[s++]=65535&m;else{if(!(16&b)){if(!(64&b)){m=g[(65535&m)+(d&(1<<b)-1)];continue t}if(32&b){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}y=65535&m,(b&=15)&&(p<b&&(d+=x[n++]<<p,p+=8),y+=d&(1<<b)-1,d>>>=b,p-=b),p<15&&(d+=x[n++]<<p,p+=8,d+=x[n++]<<p,p+=8),m=_[d&w];r:for(;;){if(d>>>=b=m>>>24,p-=b,!(16&(b=m>>>16&255))){if(!(64&b)){m=_[(65535&m)+(d&(1<<b)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(k=65535&m,p<(b&=15)&&(d+=x[n++]<<p,(p+=8)<b&&(d+=x[n++]<<p,p+=8)),(k+=d&(1<<b)-1)>h){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=b,p-=b,k>(b=s-o)){if((b=k-b)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(E=0,S=f,0===u){if(E+=c-b,b<y){y-=b;do{A[s++]=f[E++]}while(--b);E=s-k,S=A}}else if(u<b){if(E+=c+u-b,(b-=u)<y){y-=b;do{A[s++]=f[E++]}while(--b);if(E=0,u<y){y-=b=u;do{A[s++]=f[E++]}while(--b);E=s-k,S=A}}}else if(E+=u-b,b<y){y-=b;do{A[s++]=f[E++]}while(--b);E=s-k,S=A}for(;y>2;)A[s++]=S[E++],A[s++]=S[E++],A[s++]=S[E++],y-=3;y&&(A[s++]=S[E++],y>1&&(A[s++]=S[E++]))}else{E=s-k;do{A[s++]=A[E++],A[s++]=A[E++],A[s++]=A[E++],y-=3}while(y>2);y&&(A[s++]=A[E++],y>1&&(A[s++]=A[E++]))}break}}break}}while(n<i&&s<a);n-=y=p>>3,d&=(1<<(p-=y<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=s<a?a-s+257:257-(s-a),r.hold=d,r.bits=p}var pn=15,gn=[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],_n=[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],vn=[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],wn=[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];function mn(e,t,r,n,i,s,o,a){var h,c,l,u,f,d,p,g,_,v=a.bits,w=0,m=0,b=0,y=0,k=0,E=0,S=0,x=0,A=0,R=0,B=null,I=0,P=new rr(16),D=new rr(16),L=null,z=0;for(w=0;w<=pn;w++)P[w]=0;for(m=0;m<n;m++)P[t[r+m]]++;for(k=v,y=pn;y>=1&&0===P[y];y--);if(k>y&&(k=y),0===y)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(b=1;b<y&&0===P[b];b++);for(k<b&&(k=b),x=1,w=1;w<=pn;w++)if(x<<=1,(x-=P[w])<0)return-1;if(x>0&&(0===e||1!==y))return-1;for(D[1]=0,w=1;w<pn;w++)D[w+1]=D[w]+P[w];for(m=0;m<n;m++)0!==t[r+m]&&(o[D[t[r+m]]++]=m);if(0===e?(B=L=o,d=19):1===e?(B=gn,I-=257,L=_n,z-=257,d=256):(B=vn,L=wn,d=-1),R=0,m=0,w=b,f=s,E=k,S=0,l=-1,u=(A=1<<k)-1,1===e&&A>852||2===e&&A>592)return 1;for(;;){p=w-S,o[m]<d?(g=0,_=o[m]):o[m]>d?(g=L[z+o[m]],_=B[I+o[m]]):(g=96,_=0),h=1<<w-S,b=c=1<<E;do{i[f+(R>>S)+(c-=h)]=p<<24|g<<16|_}while(0!==c);for(h=1<<w-1;R&h;)h>>=1;if(0!==h?(R&=h-1,R+=h):R=0,m++,0==--P[w]){if(w===y)break;w=t[r+o[m]]}if(w>k&&(R&u)!==l){for(0===S&&(S=k),f+=b,x=1<<(E=w-S);E+S<y&&!((x-=P[E+S])<=0);)E++,x<<=1;if(A+=1<<E,1===e&&A>852||2===e&&A>592)return 1;i[l=R&u]=k<<24|E<<16|f-s}}return 0!==R&&(i[f+R]=w-S<<24|64<<16),a.bits=k,0}var bn=-2,yn=12,kn=30;function En(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Sn(){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 rr(320),this.work=new rr(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function xn(e){var t,r,n;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,(r=e)&&r.state?(n=r.state,r.total_in=r.total_out=n.total=0,r.msg="",n.wrap&&(r.adler=1&n.wrap),n.mode=1,n.last=0,n.havedict=0,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new nr(852),n.distcode=n.distdyn=new nr(592),n.sane=1,n.back=-1,0):bn):bn}var An,Rn,Bn=!0;function In(e){if(Bn){var t;for(An=new nr(512),Rn=new nr(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(mn(1,e.lens,0,288,An,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;mn(2,e.lens,0,32,Rn,0,e.work,{bits:5}),Bn=!1}e.lencode=An,e.lenbits=9,e.distcode=Rn,e.distbits=5}var Pn;function Dn(e){if(e<1||e>7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function Ln(e,t){for(var r=0;r<e.length;r++)this[t+r]=e[r]}Dn.prototype.init=function(e,t,r,n,i){var s;switch(this.windowBits=e,this.level=t,this.memLevel=r,this.strategy=n,3!==this.mode&&4!==this.mode||(this.windowBits+=16),7===this.mode&&(this.windowBits+=32),5!==this.mode&&6!==this.mode||(this.windowBits=-this.windowBits),this.strm=new Qt,this.mode){case 1:case 3:case 5:s=function(e,t,r,n,i,s){if(!e)return Kr;var o=1;if(-1===t&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||n<8||n>15||t<0||t>9||s<0||s>4)return Gr(e,Kr);8===n&&(n=9);var a=new ln;return e.state=a,a.strm=e,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new tr(2*a.w_size),a.head=new rr(a.hash_size),a.prev=new rr(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new tr(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=s,a.method=8,un(e)}(this.strm,this.level,0,this.windowBits,this.memLevel,this.strategy);break;case 2:case 4:case 6:case 7:s=function(e,t){var r,n,i,s,o,a;return e?(n=new Sn,e.state=n,n.window=null,0!==(s=t,r=(i=e)&&i.state?(a=i.state,s<0?(o=0,s=-s):(o=1+(s>>4),s<48&&(s&=15)),s&&(s<8||s>15)?bn:(null!==a.window&&a.wbits!==s&&(a.window=null),a.wrap=o,a.wbits=s,xn(i))):bn)&&(e.state=null),r):bn}(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}0===s?(this.write_in_progress=!1,this.init_done=!0):this._error(s)},Dn.prototype.params=function(){throw new Error("deflateParams Not supported")},Dn.prototype._writeCheck=function(){if(!this.init_done)throw new Error("write before init");if(0===this.mode)throw new Error("already finalized");if(this.write_in_progress)throw new Error("write already in progress");if(this.pending_close)throw new Error("close is pending")},Dn.prototype.write=function(e,t,r,n,i,s,o){this._writeCheck(),this.write_in_progress=!0;var a=this;return Be(function(){a.write_in_progress=!1;var h=a._write(e,t,r,n,i,s,o);a.callback(h[0],h[1]),a.pending_close&&a.close()}),this},Dn.prototype.writeSync=function(e,t,r,n,i,s,o){return this._writeCheck(),this._write(e,t,r,n,i,s,o)},Dn.prototype._write=function(e,t,r,n,i,s,o){if(this.write_in_progress=!0,0!==e&&1!==e&&2!==e&&3!==e&&4!==e&&5!==e)throw new Error("Invalid flush value");null==t&&(t=new I(0),n=0,r=0),i._set?i.set=i._set:i.set=Ln;var a,h=this.strm;switch(h.avail_in=n,h.input=t,h.next_in=r,h.avail_out=o,h.output=i,h.next_out=s,this.mode){case 1:case 3:case 5:a=fn(h,e);break;case 7:case 2:case 4:case 6:a=function(e,t){var r,n,i,s,o,a,h,c,l,u,f,d,p,g,_,v,w,m,b,y,k,E,S,x,A,R,B,I,P,D,L=0,z=new tr(4),T=[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 bn;(r=e.state).mode===yn&&(r.mode=13),o=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,c=r.hold,l=r.bits,u=a,f=h,E=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===c){r.check=0,z[0]=255&c,z[1]=c>>>8&255,r.check=Zr(r.check,z,2,0),c=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=kn;break}if(8!=(15&c)){e.msg="unknown compression method",r.mode=kn;break}if(l-=4,k=8+(15&(c>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=kn;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&c?10:yn,c=0,l=0;break;case 2:for(;l<16;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(r.flags=c,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=kn;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=kn;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&(z[0]=255&c,z[1]=c>>>8&255,r.check=Zr(r.check,z,2,0)),c=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.time=c),512&r.flags&&(z[0]=255&c,z[1]=c>>>8&255,z[2]=c>>>16&255,z[3]=c>>>24&255,r.check=Zr(r.check,z,4,0)),c=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(z[0]=255&c,z[1]=c>>>8&255,r.check=Zr(r.check,z,2,0)),c=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(z[0]=255&c,z[1]=c>>>8&255,r.check=Zr(r.check,z,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>a&&(d=a),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),er(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=Zr(r.check,n,d,s)),a-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break e;d=0;do{k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&(r.check=Zr(r.check,n,d,s)),a-=d,s+=d,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break e;d=0;do{k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&(r.check=Zr(r.check,n,d,s)),a-=d,s+=d,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=kn;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=yn;break;case 10:for(;l<32;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}e.adler=r.check=En(c),c=0,l=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=o,e.avail_out=h,e.next_in=s,e.avail_in=a,r.hold=c,r.bits=l,2;e.adler=r.check=1,r.mode=yn;case yn:if(5===t||6===t)break e;case 13:if(r.last){c>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}switch(r.last=1&c,l-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(In(r),r.mode=20,6===t){c>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=kn}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=kn;break}if(r.length=65535&c,c=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>a&&(d=a),d>h&&(d=h),0===d)break e;er(i,n,s,d,o),a-=d,s+=d,h-=d,o+=d,r.length-=d;break}r.mode=yn;break;case 17:for(;l<14;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(r.nlen=257+(31&c),c>>>=5,l-=5,r.ndist=1+(31&c),c>>>=5,l-=5,r.ncode=4+(15&c),c>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=kn;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.lens[T[r.have++]]=7&c,c>>>=3,l-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},E=mn(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,E){e.msg="invalid code lengths set",r.mode=kn;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;v=(L=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,w=65535&L,!((_=L>>>24)<=l);){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(w<16)c>>>=_,l-=_,r.lens[r.have++]=w;else{if(16===w){for(x=_+2;l<x;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(c>>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=kn;break}k=r.lens[r.have-1],d=3+(3&c),c>>>=2,l-=2}else if(17===w){for(x=_+3;l<x;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}l-=_,k=0,d=3+(7&(c>>>=_)),c>>>=3,l-=3}else{for(x=_+7;l<x;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}l-=_,k=0,d=11+(127&(c>>>=_)),c>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=kn;break}for(;d--;)r.lens[r.have++]=k}}if(r.mode===kn)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=kn;break}if(r.lenbits=9,S={bits:r.lenbits},E=mn(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,E){e.msg="invalid literal/lengths set",r.mode=kn;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},E=mn(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,E){e.msg="invalid distances set",r.mode=kn;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(a>=6&&h>=258){e.next_out=o,e.avail_out=h,e.next_in=s,e.avail_in=a,r.hold=c,r.bits=l,dn(e,f),o=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,c=r.hold,l=r.bits,r.mode===yn&&(r.back=-1);break}for(r.back=0;v=(L=r.lencode[c&(1<<r.lenbits)-1])>>>16&255,w=65535&L,!((_=L>>>24)<=l);){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(v&&!(240&v)){for(m=_,b=v,y=w;v=(L=r.lencode[y+((c&(1<<m+b)-1)>>m)])>>>16&255,w=65535&L,!(m+(_=L>>>24)<=l);){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}c>>>=m,l-=m,r.back+=m}if(c>>>=_,l-=_,r.back+=_,r.length=w,0===v){r.mode=26;break}if(32&v){r.back=-1,r.mode=yn;break}if(64&v){e.msg="invalid literal/length code",r.mode=kn;break}r.extra=15&v,r.mode=22;case 22:if(r.extra){for(x=r.extra;l<x;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;v=(L=r.distcode[c&(1<<r.distbits)-1])>>>16&255,w=65535&L,!((_=L>>>24)<=l);){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(!(240&v)){for(m=_,b=v,y=w;v=(L=r.distcode[y+((c&(1<<m+b)-1)>>m)])>>>16&255,w=65535&L,!(m+(_=L>>>24)<=l);){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}c>>>=m,l-=m,r.back+=m}if(c>>>=_,l-=_,r.back+=_,64&v){e.msg="invalid distance code",r.mode=kn;break}r.offset=w,r.extra=15&v,r.mode=24;case 24:if(r.extra){for(x=r.extra;l<x;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=kn;break}r.mode=25;case 25:if(0===h)break e;if(d=f-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=kn;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=i,p=o-r.offset,d=r.length;d>h&&(d=h),h-=d,r.length-=d;do{i[o++]=g[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===h)break e;i[o++]=r.length,h--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===a)break e;a--,c|=n[s++]<<l,l+=8}if(f-=h,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?Zr(r.check,i,f,o-f):Wr(r.check,i,f,o-f)),f=h,(r.flags?c:En(c))!==r.check){e.msg="incorrect data check",r.mode=kn;break}c=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===a)break e;a--,c+=n[s++]<<l,l+=8}if(c!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=kn;break}c=0,l=0}r.mode=29;case 29:E=1;break e;case kn:E=-3;break e;case 31:return-4;default:return bn}return e.next_out=o,e.avail_out=h,e.next_in=s,e.avail_in=a,r.hold=c,r.bits=l,(r.wsize||f!==e.avail_out&&r.mode<kn&&(r.mode<27||4!==t))&&(A=e,R=e.output,B=e.next_out,I=f-e.avail_out,null===(D=A.state).window&&(D.wsize=1<<D.wbits,D.wnext=0,D.whave=0,D.window=new tr(D.wsize)),I>=D.wsize?(er(D.window,R,B-D.wsize,D.wsize,0),D.wnext=0,D.whave=D.wsize):((P=D.wsize-D.wnext)>I&&(P=I),er(D.window,R,B-I,P,D.wnext),(I-=P)?(er(D.window,R,B-I,I,0),D.wnext=I,D.whave=D.wsize):(D.wnext+=P,D.wnext===D.wsize&&(D.wnext=0),D.whave<D.wsize&&(D.whave+=P)))),u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?Zr(r.check,i,f,e.next_out-f):Wr(r.check,i,f,e.next_out-f)),e.data_type=r.bits+(r.last?64:0)+(r.mode===yn?128:0)+(20===r.mode||15===r.mode?256:0),(0===u&&0===f||4===t)&&0===E&&(E=-5),E}(h,e);break;default:throw new Error("Unknown mode "+this.mode)}return 1!==a&&0!==a&&this._error(a),this.write_in_progress=!1,[h.avail_in,h.avail_out]},Dn.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,1===this.mode||3===this.mode||5===this.mode?function(e){var t;e&&e.state&&(42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==qr&&t!==Yr&&t!==Xr?Gr(e,Kr):(e.state=null,t===Yr&&Gr(e,-3)))}(this.strm):function(e){if(!e||!e.state)return bn;var t=e.state;t.window&&(t.window=null),e.state=null}(this.strm),this.mode=0)},Dn.prototype.reset=function(){switch(this.mode){case 1:case 5:Pn=un(this.strm);break;case 2:case 6:Pn=xn(this.strm)}0!==Pn&&this._error(Pn)},Dn.prototype._error=function(e){this.onerror(Jt[e]+": "+this.strm.msg,e),this.write_in_progress=!1,this.pending_close&&this.close()};var zn=Object.freeze({NONE:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,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,Zlib:Dn}),Tn={};Object.keys(zn).forEach(function(e){Tn[e]=zn[e]}),Tn.Z_MIN_WINDOWBITS=8,Tn.Z_MAX_WINDOWBITS=15,Tn.Z_DEFAULT_WINDOWBITS=15,Tn.Z_MIN_CHUNK=64,Tn.Z_MAX_CHUNK=1/0,Tn.Z_DEFAULT_CHUNK=16384,Tn.Z_MIN_MEMLEVEL=1,Tn.Z_MAX_MEMLEVEL=9,Tn.Z_DEFAULT_MEMLEVEL=8,Tn.Z_MIN_LEVEL=-1,Tn.Z_MAX_LEVEL=9,Tn.Z_DEFAULT_LEVEL=Tn.Z_DEFAULT_COMPRESSION;var Cn={Z_OK:Tn.Z_OK,Z_STREAM_END:Tn.Z_STREAM_END,Z_NEED_DICT:Tn.Z_NEED_DICT,Z_ERRNO:Tn.Z_ERRNO,Z_STREAM_ERROR:Tn.Z_STREAM_ERROR,Z_DATA_ERROR:Tn.Z_DATA_ERROR,Z_MEM_ERROR:Tn.Z_MEM_ERROR,Z_BUF_ERROR:Tn.Z_BUF_ERROR,Z_VERSION_ERROR:Tn.Z_VERSION_ERROR};function Mn(e,t){if("string"==typeof t&&(t=new I(t)),!fe(t))throw new TypeError("Not a string or buffer");var r=Tn.Z_FINISH;return e._processChunk(t,r)}function On(e){if(!(this instanceof On))return new On(e);jn.call(this,e,Tn.DEFLATE)}function Un(e){if(!(this instanceof Un))return new Un(e);jn.call(this,e,Tn.INFLATE)}function Nn(e){if(!(this instanceof Nn))return new Nn(e);jn.call(this,e,Tn.GZIP)}function Fn(e){if(!(this instanceof Fn))return new Fn(e);jn.call(this,e,Tn.GUNZIP)}function Wn(e){if(!(this instanceof Wn))return new Wn(e);jn.call(this,e,Tn.DEFLATERAW)}function Hn(e){if(!(this instanceof Hn))return new Hn(e);jn.call(this,e,Tn.INFLATERAW)}function Zn(e){if(!(this instanceof Zn))return new Zn(e);jn.call(this,e,Tn.UNZIP)}function jn(e,t){if(this._opts=e=e||{},this._chunkSize=e.chunkSize||Tn.Z_DEFAULT_CHUNK,qt.call(this,e),e.flush&&e.flush!==Tn.Z_NO_FLUSH&&e.flush!==Tn.Z_PARTIAL_FLUSH&&e.flush!==Tn.Z_SYNC_FLUSH&&e.flush!==Tn.Z_FULL_FLUSH&&e.flush!==Tn.Z_FINISH&&e.flush!==Tn.Z_BLOCK)throw new Error("Invalid flush flag: "+e.flush);if(this._flushFlag=e.flush||Tn.Z_NO_FLUSH,e.chunkSize&&(e.chunkSize<Tn.Z_MIN_CHUNK||e.chunkSize>Tn.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBits<Tn.Z_MIN_WINDOWBITS||e.windowBits>Tn.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.level<Tn.Z_MIN_LEVEL||e.level>Tn.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevel<Tn.Z_MIN_MEMLEVEL||e.memLevel>Tn.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=Tn.Z_FILTERED&&e.strategy!=Tn.Z_HUFFMAN_ONLY&&e.strategy!=Tn.Z_RLE&&e.strategy!=Tn.Z_FIXED&&e.strategy!=Tn.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!fe(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new Tn.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(e,t){r._binding=null,r._hadError=!0;var n=new Error(e);n.errno=t,n.code=Tn.codes[t],r.emit("error",n)};var n=Tn.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(n=e.level);var i=Tn.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(i=e.strategy),this._binding.init(e.windowBits||Tn.Z_DEFAULT_WINDOWBITS,n,e.memLevel||Tn.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new I(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}Object.keys(Cn).forEach(function(e){Cn[Cn[e]]=e}),Ue(jn,qt),jn.prototype.params=function(e,t,r){if(e<Tn.Z_MIN_LEVEL||e>Tn.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=Tn.Z_FILTERED&&t!=Tn.Z_HUFFMAN_ONLY&&t!=Tn.Z_RLE&&t!=Tn.Z_FIXED&&t!=Tn.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(Tn.Z_SYNC_FLUSH,function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())})}else Be(r)},jn.prototype.reset=function(){return this._binding.reset()},jn.prototype._flush=function(e){this._transform(new I(0),"",e)},jn.prototype.flush=function(e,t){var r=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=Tn.Z_FULL_FLUSH),r.ended)t&&Be(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",function(){n.flush(t)})}else this._flushFlag=e,this.write(new I(0),"",t)},jn.prototype.close=function(e){if(e&&Be(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Be(function(){t.emit("close")})}},jn.prototype._transform=function(e,t,r){var n,i=this._writableState,s=(i.ending||i.ended)&&(!e||i.length===e.length);if(null===!e&&!fe(e))return r(new Error("invalid input"));s?n=Tn.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||Tn.Z_NO_FLUSH)),this._processChunk(e,n,r)},jn.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,s=0,o=this,a="function"==typeof r;if(!a){var h,c=[],l=0;this.on("error",function(e){h=e});do{var u=this._binding.writeSync(t,e,s,n,this._buffer,this._offset,i)}while(!this._hadError&&p(u[0],u[1]));if(this._hadError)throw h;var f=I.concat(c,l);return this.close(),f}var d=this._binding.write(t,e,s,n,this._buffer,this._offset,i);function p(h,u){if(!o._hadError){var f=i-u;if(function(e){if(!e)throw new Error("have should not go down")}(f>=0),f>0){var d=o._buffer.slice(o._offset,o._offset+f);o._offset+=f,a?o.push(d):(c.push(d),l+=d.length)}if((0===u||o._offset>=o._chunkSize)&&(i=o._chunkSize,o._offset=0,o._buffer=new I(o._chunkSize)),0===u){if(s+=n-h,n=h,!a)return!0;var g=o._binding.write(t,e,s,n,o._buffer,o._offset,o._chunkSize);return g.callback=p,void(g.buffer=e)}if(!a)return!1;r()}}d.buffer=e,d.callback=p},Ue(On,jn),Ue(Un,jn),Ue(Nn,jn),Ue(Fn,jn),Ue(Wn,jn),Ue(Hn,jn),Ue(Zn,jn);var Kn=function(e,t){return Mn(new On(t),e)},Vn=function(e,t){return Mn(new Un(t),e)};class $n{constructor(e,t,r){this.SDKAPPID=e,this.EXPIRETIME=r,this.PRIVATEKEY=t}genTestUserSig(e){return this._isNumber(this.SDKAPPID)?this._isString(this.PRIVATEKEY)?this._isString(e)?this._isNumber(this.EXPIRETIME)?(console.log("sdkAppID="+this.SDKAPPID+" key="+this.PRIVATEKEY+" userID="+e+" expire="+this.EXPIRETIME),this.genSigWithUserbuf(e,this.EXPIRETIME,null)):(console.error("expireTime must be a number"),""):(console.error("userID must be a string"),""):(console.error("privateKey must be a string"),""):(console.error("sdkAppID must be a number"),"")}newBuffer(e,t){return I.from?I.from(e,t):new I(e,t)}unescape(e){return e.replace(/_/g,"=").replace(/\-/g,"/").replace(/\*/g,"+")}escape(e){return e.replace(/\+/g,"*").replace(/\//g,"-").replace(/=/g,"_")}encode(e){return this.escape(this.newBuffer(e).toString("base64"))}decode(e){return this.newBuffer(this.unescape(e),"base64")}base64encode(e){return this.newBuffer(e).toString("base64")}base64decode(e){return this.newBuffer(e,"base64").toString()}_hmacsha256(e,t,r,n){let i="TLS.identifier:"+e+"\n";i+="TLS.sdkappid:"+this.SDKAPPID+"\n",i+="TLS.time:"+t+"\n",i+="TLS.expire:"+r+"\n",null!=n&&(i+="TLS.userbuf:"+n+"\n");let s=_e.HmacSHA256(i,this.PRIVATEKEY);return _e.enc.Base64.stringify(s)}_utc(){return Math.round(Date.now()/1e3)}_isNumber(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"==typeof e&&e.constructor===Number)}_isString(e){return"string"==typeof e}genSigWithUserbuf(e,t,r){let n=this._utc(),i={"TLS.ver":"2.0","TLS.identifier":e,"TLS.sdkappid":this.SDKAPPID,"TLS.time":n,"TLS.expire":t},s="";if(null!=r){let o=this.base64encode(r);i["TLS.userbuf"]=o,s=this._hmacsha256(e,n,t,o)}else s=this._hmacsha256(e,n,t,null);i["TLS.sig"]=s;let o=JSON.stringify(i),a=Kn(this.newBuffer(o)).toString("base64"),h=this.escape(a);return console.log("ret="+h),h}validate(e){let t=this.decode(e),r=Vn(t);console.log("validate ret="+r)}}function qn(e){const{SDKAppID:t,secretKey:r,userID:n}=e;return{SDKAppID:t,userSig:new $n(t,r,604800).genTestUserSig(n)}}class Yn{constructor(){this.isRegistered=!1,this.registrationID="",this.chat=null,this.SDKAppID=0,this.appKey="",this.vapidPublicKey="",this.EVENT=n,this.VERSION=r,o.log("version:",r),this.eventEmitter=new a,this.serviceWorkerManager=p.getInstance(this.eventEmitter),this.initializeBrowserCompatibility().catch(e=>{o.error("Browser compatibility initialization failed",e)}),this.setupInternalListeners()}static getInstance(){return this.instance||(this.instance=new Yn),this.instance}async registerPush(e){try{c.validateRegisterPushOptions(e);const{SDKAppID:r,appKey:n,userID:i,chat:s}=e;this.isRegistered&&(o.warn("Push service already registered, will unregister first and then re-register"),await this.unRegisterPush()),this.checkBrowserSupport();if("granted"!==await this.requestNotificationPermission())throw new Error("User denied notification permission");if(this.SDKAppID=r,this.appKey=n,this.registrationID=i,s)this.chat=s;else{if(void 0===t)throw new Error("TencentCloudChat SDK is not available. Please ensure you have imported @tencentcloud/lite-chat/professional or provided a chat instance in the options.");this.chat=t.create({SDKAppID:this.SDKAppID,...e})}await this.serviceWorkerManager.register(),await this.chatLogin();const a=await this.serviceWorkerManager.getPushSubscription(this.vapidPublicKey);return await this.setToken(a),this.isRegistered=!0,o.log("Push service registration successful",this.registrationID),this.registrationID}catch(r){if(r instanceof h)throw o.error("Push service registration parameter validation failed",r.message),r;throw o.error("Push service registration failed",r),r}}async unRegisterPush(){try{return this.isRegistered?(this.chat,await this.serviceWorkerManager.unsubscribe(),await this.serviceWorkerManager.unregister(),await this.chat.callExperimentalAPI("logoutWebPush"),this.isRegistered=!1,this.registrationID="",this.SDKAppID=0,this.appKey="",this.vapidPublicKey="",this.clearState(),o.log("Push service unregistration successful"),!0):(o.warn("Push service is not registered, no need to unregister"),!0)}catch(e){return o.error("Push service unregistration failed",e),!1}}addPushListener(e,t){try{c.validateEventType(e),c.validateListener(t);const r=this.eventEmitter.on(e,t);return o.log("Add push listener",e,r),r}catch(r){if(r instanceof h)throw o.error("Add push listener parameter validation failed",r.message),r;throw o.error("Add push listener failed",r),new Error("Add push listener failed")}}removePushListener(e,t){try{c.validateEventType(e),c.validateListener(t);const r=this.eventEmitter.off(e,t);return o.log("Remove push listener",e,r),r}catch(r){if(r instanceof h)throw o.error("Remove push listener parameter validation failed",r.message),r;return o.error("Remove push listener failed",r),!1}}checkBrowserSupport(){if(!u.checkBrowserSupport()){const e=u.detectWebPushCapability();throw new Error(`Browser not supported: ${e.reason}`)}}async requestNotificationPermission(){try{const e=await u.checkNotificationPermission();if("granted"===e)return"granted";const t=u.detectWebPushCapability().browserName;if("denied"===e){const e=`Notification permission denied for ${t}. Please check your system settings.`;throw new Error(e)}u.requiresUserGesture()&&o.warn("Current browser requires user gesture to request notification permission");const r=await u.requestNotificationPermission();if("granted"!==r)throw new Error(`User denied notification permission for ${t}`);return this.showSystemPermissionAlert(t),r}catch(e){throw o.error("Request notification permission failed",e),e}}async chatLogin(){try{const e=await this.chat.callExperimentalAPI("loginWebPush",{userID:this.registrationID,userSig:qn({SDKAppID:this.SDKAppID,secretKey:this.appKey,userID:this.registrationID}).userSig});e.data.vapid?this.vapidPublicKey=e.data.vapid:o.error("Failed to fetch VAPID public key")}catch(e){if(2905===e?.code){const t=new Error("The API you are calling is only available in the Professional edition. Please change your import from @tencentcloud/lite-chat to @tencentcloud/lite-chat/professional to access this feature.");throw t.code=e.code,t}throw e}}getSystemPermissionMessage(e){return navigator.userAgent.toLowerCase().includes("mac os")?`For macOS: System Preferences > Notifications > ${e}, then enable notifications.`:`For Windows: Settings > Privacy > Notifications > ${e}, then enable notifications.`}showSystemPermissionAlert(e){const t=this.getSystemPermissionMessage(e);alert(`System notification permission for ${e}.\n\n${t}\n\nPlease refresh the page after enabling notifications.`)}getBrowserInstType(){const e=navigator.userAgent.toLowerCase();return e.includes("edg/")?3003:e.includes("yabrowser/")?3004:e.includes("opr/")||e.includes("opera/")?3005:e.includes("chrome/")&&!e.includes("edg/")?3e3:e.includes("firefox/")?3001:e.includes("safari/")&&!e.includes("chrome/")?3002:1}async setToken(e){try{const t=u.detectWebPushCapability(),n=u.getBrowserInfo(),i={browserType:this.getBrowserInstType(),pushToken:e.endpoint,webPushAuthKey:e.auth,webPushP256:e.p256dh,pushSDKVersion:r,browserVersion:`${t.browserName} ${t.browserVersion}`,browserPlatform:n.platform,browserLanguage:n.language};return await this.chat.callExperimentalAPI("setWebPushToken",i)}catch(t){throw o.error("Device registration failed",t),t}}async initializeBrowserCompatibility(){try{const e=u.detectWebPushCapability();o.log("Browser Web Push capability initialization completed",{browser:`${e.browserName} ${e.browserVersion}`,supported:e.supported,reason:e.reason}),e.supported||o.warn("[WebPush] Browser compatibility warning:",e.reason)}catch(e){o.error("Browser compatibility initialization failed",e)}}setupInternalListeners(){this.eventEmitter.on(n.MESSAGE_RECEIVED,e=>{this.SDKAppID&&this.registrationID&&e.messageID&&this.pushStatistics(e.messageID,"reach")}),this.eventEmitter.on(n.NOTIFICATION_CLICKED,e=>{this.SDKAppID&&this.registrationID&&e.notification?.messageID&&this.pushStatistics(e.notification.messageID,"click")})}async pushStatistics(e,t){try{if(!this.chat)return void o.warn("Chat SDK not initialized, skipping statistics");const r={messageID:e,type:t,timestamp:Date.now(),SDKAppID:this.SDKAppID,registrationID:this.registrationID};o.log(`Message ${t} statistics recorded`,r)}catch(r){o.error(`Failed to record message ${t} statistics`,r)}}clearState(){this.isRegistered=!1,this.registrationID="",this.SDKAppID=0,this.appKey="",this.vapidPublicKey=""}}const Xn=Yn.getInstance();e.EVENT=n,e.default=Xn,e.webPush=Xn,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|