1 |
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).TIM=t()}(this,(function(){var e={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_SYSTEM_NOTICE_RECEIVED:"receiveGroupSystemNotice",PROFILE_UPDATED:"onProfileUpdated",BLACKLIST_UPDATED:"blacklistUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",SDK_RELOAD:"sdkReload"},t={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_SYSTEM:"@TIM#SYSTEM",GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",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,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",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",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_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected"};function n(e){return(n="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 o(e,t,n,o,r,i,s){try{var a=e[i](s),u=a.value}catch(c){return void n(c)}a.done?t(u):Promise.resolve(u).then(o,r)}function r(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var s=e.apply(t,n);function a(e){o(s,r,i,a,u,"next",e)}function u(e){o(s,r,i,a,u,"throw",e)}a(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function m(e,t,n){return(m=d()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&h(r,n.prototype),r}).apply(null,arguments)}function f(e){var t="function"==typeof Map?new Map:void 0;return(f=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return m(e,arguments,g(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),h(o,e)})(e)}function _(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?v(e):t}function I(e){var t=d();return function(){var n,o=g(e);if(t){var r=g(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return y(this,n)}}function M(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],o=!0,r=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(o=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);o=!0);}catch(u){r=!0,i=u}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}return n}(e,t)||E(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||E(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function E(e,t){if(e){if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function D(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=E(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,i=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}var S=function(){function e(){i(this,e),this.cache=[],this.options=null}return a(e,[{key:"use",value:function(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}},{key:"next",value:function(e){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}},{key:"run",value:function(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}]),e}(),k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function O(e,t){return e(t={exports:{}},t.exports),t.exports}var R,A,N,L=O((function(e,t){var n,o,r,i,s,a,u,c,l,p,g,h,d,m,f,_,v,y;e.exports=(n="function"==typeof Promise,o="object"==typeof self?self:k,r="undefined"!=typeof Symbol,i="undefined"!=typeof Map,s="undefined"!=typeof Set,a="undefined"!=typeof WeakMap,u="undefined"!=typeof WeakSet,c="undefined"!=typeof DataView,l=r&&void 0!==Symbol.iterator,p=r&&void 0!==Symbol.toStringTag,g=s&&"function"==typeof Set.prototype.entries,h=i&&"function"==typeof Map.prototype.entries,d=g&&Object.getPrototypeOf((new Set).entries()),m=h&&Object.getPrototypeOf((new Map).entries()),f=l&&"function"==typeof Array.prototype[Symbol.iterator],_=f&&Object.getPrototypeOf([][Symbol.iterator]()),v=l&&"function"==typeof String.prototype[Symbol.iterator],y=v&&Object.getPrototypeOf(""[Symbol.iterator]()),function(e){var t=typeof e;if("object"!==t)return t;if(null===e)return"null";if(e===o)return"global";if(Array.isArray(e)&&(!1===p||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var r=p&&e[Symbol.toStringTag];if("string"==typeof r)return r;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":n&&l===Promise.prototype?"Promise":s&&l===Set.prototype?"Set":i&&l===Map.prototype?"Map":u&&l===WeakSet.prototype?"WeakSet":a&&l===WeakMap.prototype?"WeakMap":c&&l===DataView.prototype?"DataView":i&&l===m?"Map Iterator":s&&l===d?"Set Iterator":f&&l===_?"Array Iterator":v&&l===y?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),w="undefined"!=typeof window,P="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync,G=w&&window.navigator&&window.navigator.userAgent||"",b=/AppleWebKit\/([\d.]+)/i.exec(G),U=(b&&parseFloat(b.pop()),/iPad/i.test(G)),q=/iPhone/i.test(G)&&!U,F=/iPod/i.test(G),x=q||U||F,V=((R=G.match(/OS (\d+)_/i))&&R[1]&&R[1],/Android/i.test(G)),K=function(){var e=G.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),H=(V&&/webkit/i.test(G),/Firefox/i.test(G),/Edge/i.test(G)),B=!H&&/Chrome/i.test(G),j=(function(){var e=G.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(G)),$=(/MSIE\s8\.0/.test(G),function(){var e=/MSIE\s(\d+)\.\d/.exec(G),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(G)&&/rv:11.0/.test(G)&&(t=11),t}()),Y=(/Safari/i.test(G),/TBS\/\d+/i.test(G)),W=(function(){var e=G.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]}(),!Y&&/MQQBrowser\/\d+/i.test(G),!Y&&/ QQBrowser\/\d+/i.test(G),/(micromessenger|webbrowser)/i.test(G)),z=/Windows/i.test(G),J=/MAC OS X/i.test(G),X=(/MicroMessenger/i.test(G),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});A="undefined"!=typeof console?console:void 0!==X&&X.console?X.console:"undefined"!=typeof window&&window.console?window.console:{};for(var Q=function(){},Z=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],ee=Z.length;ee--;)N=Z[ee],console[N]||(A[N]=Q);A.methods=Z;var te=A,ne=0,oe=new Map;function re(){var e=new Date;return"TIM "+e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){var t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())+":"}var ie={_data:[],_length:0,_visible:!1,arguments2String:function(e){var t;if(1===e.length)t=re()+e[0];else{t=re();for(var n=0,o=e.length;n<o;n++)he(e[n])?me(e[n])?t+=Me(e[n]):t+=JSON.stringify(e[n]):t+=e[n],t+=" "}return t},debug:function(){if(ne<=-1){var e=this.arguments2String(arguments);ie.record(e,"debug"),te.debug(e)}},log:function(){if(ne<=0){var e=this.arguments2String(arguments);ie.record(e,"log"),te.log(e)}},info:function(){if(ne<=1){var e=this.arguments2String(arguments);ie.record(e,"info"),te.info(e)}},warn:function(){if(ne<=2){var e=this.arguments2String(arguments);ie.record(e,"warn"),te.warn(e)}},error:function(){if(ne<=3){var e=this.arguments2String(arguments);ie.record(e,"error"),te.error(e)}},time:function(e){oe.set(e,ye.now())},timeEnd:function(e){if(oe.has(e)){var t=ye.now()-oe.get(e);return oe.delete(e),t}return te.warn("未找到对应label: ".concat(e,", 请在调用 logger.timeEnd 前,调用 logger.time")),0},setLevel:function(e){e<4&&te.log(re()+"set level from "+ne+" to "+e),ne=e},record:function(e,t){1100===ie._length&&(ie._data.splice(0,100),ie._length=1e3),ie._length++,ie._data.push("".concat(e," [").concat(t,"] \n"))},getLog:function(){return ie._data}},se=function(e){return"file"===fe(e)},ae=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"===n(e)&&e.constructor===Number)},ue=function(e){return"string"==typeof e},ce=function(e){return null!==e&&"object"===n(e)},le=function(e){if("object"!==n(e)||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var o=t;null!==Object.getPrototypeOf(o);)o=Object.getPrototypeOf(o);return t===o},pe=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===fe(e)},ge=function(e){return void 0===e},he=function(e){return pe(e)||ce(e)},de=function(e){return"function"==typeof e},me=function(e){return e instanceof Error},fe=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},_e=function(e){if("string"!=typeof e)return!1;var t=e[0];return!/[^a-zA-Z0-9]/.test(t)},ve=0;Date.now||(Date.now=function(){return(new Date).getTime()});var ye={now:function(){0===ve&&(ve=Date.now()-1);var e=Date.now()-ve;return e>4294967295?(ve+=4294967295,Date.now()-ve):e},utc:function(){return Math.round(Date.now()/1e3)}},Ie=function e(t,n,o,r){if(!he(t)||!he(n))return 0;for(var i,s=0,a=Object.keys(n),u=0,c=a.length;u<c;u++)if(i=a[u],!(ge(n[i])||o&&o.includes(i)))if(he(t[i])&&he(n[i]))s+=e(t[i],n[i],o,r);else{if(r&&r.includes(n[i]))continue;t[i]!==n[i]&&(t[i]=n[i],s+=1)}return s},Me=function(e){return JSON.stringify(e,["message","code"])},Ce=function(){var e=new Date,t=e.toISOString(),n=e.getTimezoneOffset()/60,o="";return o=n<0?n>-10?"+0"+Math.abs(100*n):"+"+Math.abs(100*n):n>=10?"-"+100*n:"-0"+100*n,t.replace("Z",o)},Ee=function(e){if(0===e.length)return 0;for(var t=0,n=0,o="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)n+=e[t++].charCodeAt[t]<=255?1:!1===o?3:2;return n},Te=function(e){var t=e||99999999;return Math.round(Math.random()*t)},De="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Se=De.length,ke=function(e,t){for(var n in e)if(e[n]===t)return!0;return!1},Oe={},Re=function(){if(P)return"https:";var e=window.location.protocol;return["http:","https:"].indexOf(e)<0&&(e="http:"),e},Ae=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function Ne(e,t){pe(e)&&pe(t)?t.forEach((function(t){var n=t.key,o=t.value,r=e.find((function(e){return e.key===n}));r?r.value=o:e.push({key:n,value:o})})):ie.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var Le=function(e){return e===t.GRP_WORK},we=function(e){return e===t.GRP_PUBLIC},Pe=function(e){return e===t.GRP_MEETING},Ge=function(e){return e===t.GRP_AVCHATROOM},be=function(e){return ue(e)&&e===t.CONV_SYSTEM};function Ue(e,t){var n={};return Object.keys(e).forEach((function(o){n[o]=t(e[o],o)})),n}function qe(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return"".concat(e()+e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}function Fe(e){var t=e.originUrl,n=void 0===t?void 0:t,o=e.originWidth,r=e.originHeight,i=e.min,s=void 0===i?198:i,a=parseInt(o),u=parseInt(r),c={url:void 0,width:0,height:0};return(a<=u?a:u)<=s?(c.url=n,c.width=a,c.height=u):(u<=a?(c.width=Math.ceil(a*s/u),c.height=s):(c.width=s,c.height=Math.ceil(u*s/a)),c.url="".concat(n,198===s?"?imageView2/3/w/198/h/198":"?imageView2/3/w/720/h/720")),ge(n)?_(c,["url"]):c}function xe(e){var t=e[2];e[2]=e[1],e[1]=t;for(var n=0;n<e.length;n++)e[n].setSizeType(n+1),e[n].setType(n)}var Ve=Object.prototype.hasOwnProperty;function Ke(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(le(e)){for(var t in e)if(Ve.call(e,t))return!1;return!0}return!("map"!==fe(e)&&!function(e){return"set"===fe(e)}(e)&&!se(e))&&0===e.size}function He(e,t,n){if(void 0===t)return!0;var o=!0;if("object"===L(t).toLowerCase())Object.keys(t).forEach((function(r){var i=1===e.length?e[0][r]:void 0;o=!!Be(i,t[r],n,r)&&o}));else if("array"===L(t).toLowerCase())for(var r=0;r<t.length;r++)o=!!Be(e[r],t[r],n,t[r].name)&&o;if(o)return o;throw new Error("Params validate failed.")}function Be(e,t,n,o){if(void 0===t)return!0;var r=!0;return t.required&&Ke(e)&&(te.error("TIM [".concat(n,'] Missing required params: "').concat(o,'".')),r=!1),Ke(e)||L(e).toLowerCase()===t.type.toLowerCase()||(te.error("TIM [".concat(n,'] Invalid params: type check failed for "').concat(o,'".Expected ').concat(t.type,".")),r=!1),t.validator&&!t.validator(e)&&(te.error("TIM [".concat(n,"] Invalid params: custom validator check failed for params.")),r=!1),r}var je={SUCCESS:"JoinedSuccess",WAIT_APPROVAL:"WaitAdminApproval"},$e={SUCCESS:0},Ye={IS_LOGIN:1,IS_NOT_LOGIN:0},We={UNSEND:"unSend",SUCCESS:"success",FAIL:"fail"},ze={NOT_START:"notStart",PENDING:"pengding",RESOLVED:"resolved",REJECTED:"rejected"},Je=function(){function e(n){i(this,e),this.type=t.MSG_TEXT,this.content={text:n.text||""}}return a(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),Xe={JSON:{TYPE:{C2C:{NOTICE:1,COMMON:9,EVENT:10},GROUP:{COMMON:3,TIP:4,SYSTEM:5,TIP2:6},FRIEND:{NOTICE:7},PROFILE:{NOTICE:8}},SUBTYPE:{C2C:{COMMON:0,READED:92,KICKEDOUT:96},GROUP:{COMMON:0,LOVEMESSAGE:1,TIP:2,REDPACKET:3}},OPTIONS:{GROUP:{JOIN:1,QUIT:2,KICK:3,SET_ADMIN:4,CANCEL_ADMIN:5,MODIFY_GROUP_INFO:6,MODIFY_MEMBER_INFO:7}}},PROTOBUF:{},IMAGE_TYPES:{ORIGIN:1,LARGE:2,SMALL:3},IMAGE_FORMAT:{JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255}},Qe=1,Ze=2,et=3,tt=4,nt=5,ot=7,rt=8,it=9,st=10,at=15,ut=255,ct=2,lt=0,pt=1,gt={NICK:"Tag_Profile_IM_Nick",GENDER:"Tag_Profile_IM_Gender",BIRTHDAY:"Tag_Profile_IM_BirthDay",LOCATION:"Tag_Profile_IM_Location",SELFSIGNATURE:"Tag_Profile_IM_SelfSignature",ALLOWTYPE:"Tag_Profile_IM_AllowType",LANGUAGE:"Tag_Profile_IM_Language",AVATAR:"Tag_Profile_IM_Image",MESSAGESETTINGS:"Tag_Profile_IM_MsgSettings",ADMINFORBIDTYPE:"Tag_Profile_IM_AdminForbidType",LEVEL:"Tag_Profile_IM_Level",ROLE:"Tag_Profile_IM_Role"},ht={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},dt={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},mt={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},ft=function(){function e(n){i(this,e),this._imageMemoryURL="",this._file=n.file,P?this.createImageDataASURLInWXMiniApp(n.file):this.createImageDataASURLInWeb(n.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:n.imageFormat||Xe.IMAGE_FORMAT.UNKNOWN,uuid:n.uuid,imageInfoArray:[]},this.initImageInfoArray(n.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return a(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=Te(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.url||"",this.url=t.url||e._imageMemoryURL||e._defaultImage},this._ImageInfoModel.prototype={setSizeType:function(e){this.sizeType=e},setType:function(e){this.type=e},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=0,n=null,o=null;t<=2;)o=ge(e)||ge(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(n=new this._ImageInfoModel(o)).setSizeType(t+1),n.setType(t),this.addImageInfo(n),t++;this.updateAccessSideImageInfoArray()}},{key:"updateImageInfoArray",value:function(e){for(var t,n=this.content.imageInfoArray.length,o=0;o<n;o++)t=this.content.imageInfoArray[o],e[o].size&&(t.size=e[o].size),e[o].url&&t.setImageUrl(e[o].url),e[o].width&&(t.width=e[o].width),e[o].height&&(t.height=e[o].height)}},{key:"_autoFixUrl",value:function(){for(var e=this.content.imageInfoArray.length,t="",n="",o=["http","https"],r=null,i=0;i<e;i++)this.content.imageInfoArray[i].url&&""!==(r=this.content.imageInfoArray[i]).imageUrl&&(n=r.imageUrl.slice(0,r.imageUrl.indexOf("://")+1),t=r.imageUrl.slice(r.imageUrl.indexOf("://")+1),o.indexOf(n)<0&&(n="https:"),this.content.imageInfoArray[i].setImageUrl([n,t].join("")))}},{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateImageFormat",value:function(e){this.content.imageFormat=Xe.IMAGE_FORMAT[e.toUpperCase()]||Xe.IMAGE_FORMAT.UNKNOWN}},{key:"createImageDataASURLInWeb",value:function(e){void 0!==e&&e.files.length>0&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}},{key:"createImageDataASURLInWXMiniApp",value:function(e){e&&e.url&&(this._imageMemoryURL=e.url)}},{key:"replaceImageInfo",value:function(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}},{key:"addImageInfo",value:function(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateAccessSideImageInfoArray",value:function(){var e=this.content.imageInfoArray,t=e[0],n=t.width,o=void 0===n?0:n,r=t.height,i=void 0===r?0:r;0!==o&&0!==i&&(xe(e),Object.assign(e[2],Fe({originWidth:o,originHeight:i,min:720})))}},{key:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&(""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size)}}]),e}(),_t=function(){function e(n){i(this,e),this.type=t.MSG_FACE,this.content=n||null}return a(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),vt=function(){function e(n){i(this,e),this.type=t.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:n.second,size:n.size,url:n.url,remoteAudioUrl:"",uuid:n.uuid}}return a(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateAudioUrl",value:function(e){this.content.remoteAudioUrl=e}},{key:"sendable",value:function(){return""!==this.content.remoteAudioUrl}}]),e}(),yt={from:!0,groupID:!0,groupName:!0,to:!0},It=function(){function e(n){i(this,e),this.type=t.MSG_GRP_TIP,this.content={},this._initContent(n)}return a(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"remarkInfo":break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;case"operatorInfo":case"memberInfoList":break;case"msgMemberInfo":t.content.memberList=e[n],Object.defineProperty(t.content,"msgMemberInfo",{get:function(){return ie.warn("!!! 禁言的群提示消息中的 payload.msgMemberInfo 属性即将废弃,请使用 payload.memberList 属性替代。 \n","msgMemberInfo 中的 shutupTime 属性对应更改为 memberList 中的 muteTime 属性,表示禁言时长。 \n","参考:群提示消息 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/Message.html#.GroupTipPayload"),t.content.memberList.map((function(e){return{userID:e.userID,shutupTime:e.muteTime}}))}});break;case"onlineMemberInfo":break;case"memberNum":t.content[n]=e[n],t.content.memberCount=e[n];break;default:t.content[n]=e[n]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var o=t[n];yt[o]&&(this.content.groupProfile[o]=e[o])}}}]),e}(),Mt={from:!0,groupID:!0,name:!0,to:!0},Ct=function(){function e(n){i(this,e),this.type=t.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(n)}return a(e,[{key:"_initContent",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"memberInfoList":break;case"remarkInfo":t.content.handleMessage=e[n];break;case"groupProfile":t.content.groupProfile={},t._initGroupProfile(e[n]);break;default:t.content[n]=e[n]}}))}},{key:"_initGroupProfile",value:function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var o=t[n];Mt[o]&&(this.content.groupProfile[o]=e[o])}}}]),e}(),Et="https://cloud.tencent.com/document/product/",Tt="您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。",Dt="UserSig 非法,请使用官网提供的 API 重新生成 UserSig(".concat(Et,"269/32688)。"),St={70001:"UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",70002:"UserSig 长度为0,请检查传入的 UserSig 是否正确。",70003:Dt,70005:Dt,70009:"UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig(".concat(Et,"269/32688)。"),70013:"请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配。".concat(Tt),70014:"请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配。".concat(Tt),70016:"密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥(".concat(Et,"269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。"),70020:"SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。",70050:"UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。".concat(Tt),70051:"帐号被拉入黑名单。",70052:"UserSig 已经失效,请重新生成,再次尝试。",70107:"因安全原因被限制登录,请不要频繁登录。",70169:"请求的用户帐号不存在。",70114:"".concat("服务端内部超时,请稍后重试。"),70202:"".concat("服务端内部超时,请稍后重试。"),70206:"请求中批量数量不合法。",70402:"参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。",70403:"请求失败,需要 App 管理员权限。",70398:"帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引(".concat(Et,"269/32458)。"),70500:"".concat("服务端内部错误,请重试。"),71e3:"删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。",20001:"请求包非法。",20002:"UserSig 或 A2 失效。",20003:"消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。",20004:"网络异常,请重试。",20005:"".concat("服务端内部错误,请重试。"),20006:"触发发送".concat("单聊消息","之前回调,App 后台返回禁止下发该消息。"),20007:"发送".concat("单聊消息",",被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(").concat(Et,"269/38656)。"),20009:"消息发送双方互相不是好友,禁止发送(配置".concat("单聊消息","校验好友关系才会出现)。"),20010:"发送".concat("单聊消息",",自己不是对方的好友(单向关系),禁止发送。"),20011:"发送".concat("单聊消息",",对方不是自己的好友(单向关系),禁止发送。"),20012:"发送方被禁言,该条消息被禁止发送。",20016:"消息撤回超过了时间限制(默认2分钟)。",20018:"删除漫游内部错误。",90001:"JSON 格式解析失败,请检查请求包是否符合 JSON 规范。",90002:"".concat("JSON 格式请求包体","中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(").concat(Et,"269/2720#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement)。"),90003:"".concat("JSON 格式请求包体","中缺少 To_Account 字段或者 To_Account 帐号不存在。"),90005:"".concat("JSON 格式请求包体","中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。"),90006:"".concat("JSON 格式请求包体","中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。"),90007:"".concat("JSON 格式请求包体","中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。"),90008:"".concat("JSON 格式请求包体","中缺少 From_Account 字段或者 From_Account 帐号不存在。"),90009:"请求需要 App 管理员权限。",90010:"".concat("JSON 格式请求包体","不符合消息格式描述,请参考 TIMMsgElement 对象的定义(").concat(Et,"269/2720#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement)。"),90011:"批量发消息目标帐号超过500,请减少 To_Account 中目标帐号数量。",90012:"To_Account 没有注册或不存在,请确认 To_Account 是否导入即时通信 IM 或者是否拼写错误。",90026:"消息离线存储时间错误(最多不能超过7天)。",90031:"".concat("JSON 格式请求包体","中 SyncOtherMachine 字段不是 Integer 类型。"),90044:"".concat("JSON 格式请求包体","中 MsgLifeTime 字段不是 Integer 类型。"),90048:"请求的用户帐号不存在。",90054:"撤回请求中的 MsgKey 不合法。",90994:"".concat("服务端内部错误,请重试。"),90995:"".concat("服务端内部错误,请重试。"),91e3:"".concat("服务端内部错误,请重试。"),90992:"".concat("服务端内部错误,请重试。","如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。"),93e3:"JSON 数据包超长,消息包体请不要超过8k。",91101:"Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。",10002:"".concat("服务端内部错误,请重试。"),10003:"请求中的接口名称错误,请核对接口名称并重试。",10004:"参数非法,请根据错误描述检查请求是否正确。",10005:"请求包体中携带的帐号数量过多。",10006:"操作频率限制,请尝试降低调用的频率。",10007:"操作权限不足,例如 Work ".concat("群组","中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。"),10008:"请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。",10009:"该群不允许群主主动退出。",10010:"".concat("群组","不存在,或者曾经存在过,但是目前已经被解散。"),10011:"解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。",10012:"发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。",10013:"被邀请加入的用户已经是群成员。",10014:"群已满员,无法将请求中的用户加入".concat("群组",",如果是批量加人,可以尝试减少加入用户的数量。"),10015:"找不到指定 ID 的".concat("群组","。"),10016:"App 后台通过第三方回调拒绝本次操作。",10017:"因被禁言而不能发送消息,请检查发送者是否被设置禁言。",10018:"应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。",10019:"请求的用户帐号不存在。",10021:"".concat("群组"," ID 已被使用,请选择其他的").concat("群组"," ID。"),10023:"发消息的频率超限,请延长两次发消息时间的间隔。",10024:"此邀请或者申请请求已经被处理。",10025:"".concat("群组"," ID 已被使用,并且操作者为群主,可以直接使用。"),10026:"该 SDKAppID 请求的命令字已被禁用。",10030:"请求撤回的消息不存在。",10031:"消息撤回超过了时间限制(默认2分钟)。",10032:"请求撤回的消息不支持撤回操作。",10033:"".concat("群组","类型不支持消息撤回操作。"),10034:"该消息类型不支持删除操作。",10035:"直播群和在线成员广播大群不支持删除消息。",10036:"直播群创建数量超过了限制,请参考价格说明(".concat(Et,"269/11673)购买预付费套餐“IM直播群”。"),10037:"单个用户可创建和加入的".concat("群组","数量超过了限制,请参考价格说明(").concat(Et,"269/11673)购买或升级预付费套餐“单人可创建与加入").concat("群组","数”。"),10038:"群成员数量超过限制,请参考价格说明(".concat(Et,"269/11673)购买或升级预付费套餐“扩展群人数上限”。"),10041:"该应用(SDKAppID)已配置不支持群消息撤回。"},kt=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this)).code=e.code,o.message=St[e.code]||e.message,o.data=e.data||{},o}return n}(f(Error)),Ot={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,COS_UNDETECTED:2040,MESSAGE_SEND_FAIL:2100,MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS:2103,MESSAGE_SEND_NEED_MESSAGE_INSTANCE:2105,MESSAGE_SEND_INVALID_CONVERSATION_TYPE:2106,MESSAGE_FILE_IS_EMPTY:2108,MESSAGE_ONPROGRESS_FUNCTION_ERROR:2109,MESSAGE_REVOKE_FAIL:2110,MESSAGE_IMAGE_SELECT_FILE_FIRST:2251,MESSAGE_IMAGE_TYPES_LIMIT:2252,MESSAGE_IMAGE_SIZE_LIMIT:2253,MESSAGE_AUDIO_UPLOAD_FAIL:2300,MESSAGE_AUDIO_SIZE_LIMIT:2301,MESSAGE_VIDEO_UPLOAD_FAIL:2350,MESSAGE_VIDEO_SIZE_LIMIT:2351,MESSAGE_VIDEO_TYPES_LIMIT:2352,MESSAGE_FILE_UPLOAD_FAIL:2400,MESSAGE_FILE_SELECT_FILE_FIRST:2401,MESSAGE_FILE_SIZE_LIMIT:2402,MESSAGE_FILE_URL_IS_EMPTY:2403,CONVERSATION_NOT_FOUND:2500,USER_OR_GROUP_NOT_FOUND:2501,CONVERSATION_UN_RECORDED_TYPE:2502,ILLEGAL_GROUP_TYPE:2600,CANNOT_JOIN_WORK:2601,CANNOT_CHANGE_OWNER_IN_AVCHATROOM:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,CANNOT_DISMISS_Work:2622,JOIN_GROUP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AVCHATROOM:2661,CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN:2662,CANNOT_KICK_MEMBER_IN_AVCHATROOM:2680,NOT_OWNER:2681,CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM:2682,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,DEL_FRIEND_INVALID_PARAM:2700,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,ADD_BLACKLIST_INVALID_PARAM:2740,DEL_BLACKLIST_INVALID_PARAM:2741,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NETWORK_BASE_OPTIONS_NO_URL:2802,NETWORK_UNDEFINED_SERVER_NAME:2803,NETWORK_PACKAGE_UNDEFINED:2804,NO_NETWORK:2805,CONVERTOR_IRREGULAR_PARAMS:2900,NOTICE_RUNLOOP_UNEXPECTED_CONDITION:2901,NOTICE_RUNLOOP_OFFSET_LOST:2902,UNCAUGHT_ERROR:2903,GET_LONGPOLL_ID_FAILED:2904,INVALID_OPERATION:2905,SDK_IS_NOT_READY:2999,LONG_POLL_KICK_OUT:91101,MESSAGE_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,LONG_POLL_API_PARAM_ERROR:90001},Rt="无 SDKAppID",At="无 accountType",Nt="无 userID",Lt="无 userSig",wt="无 tinyID",Pt="无 a2key",Gt="未检测到 COS 上传插件",bt="消息发送失败",Ut="MessageController.constructor() 需要参数 options",qt="需要 Message 的实例",Ft='Message.conversationType 只能为 "C2C" 或 "GROUP"',xt="无法发送空文件",Vt="回调函数运行时遇到错误,请检查接入侧代码",Kt="消息撤回失败",Ht="请先选择一个图片",Bt="只允许上传 jpg png jpeg gif 格式的图片",jt="图片大小超过20M,无法发送",$t="语音上传失败",Yt="语音大小大于20M,无法发送",Wt="视频上传失败",zt="视频大小超过100M,无法发送",Jt="只允许上传 mp4 格式的视频",Xt="文件上传失败",Qt="请先选择一个文件",Zt="文件大小超过100M,无法发送 ",en="缺少必要的参数文件 URL",tn="没有找到相应的会话,请检查传入参数",nn="没有找到相应的用户或群组,请检查传入参数",on="未记录的会话类型",rn="非法的群类型,请检查传入参数",sn="不能加入 Work 类型的群组",an="AVChatRoom 类型的群组不能转让群主",un="不能把群主转让给自己",cn="不能解散 Work 类型的群组",ln="加群失败,请检查传入参数或重试",pn="AVChatRoom 类型的群不支持邀请群成员",gn="非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群",hn="不能在 AVChatRoom 类型的群组踢人",dn="你不是群主,只有群主才有权限操作",mn="不能在 Work / AVChatRoom 类型的群中设置群成员身份",fn="不合法的群成员身份,请检查传入参数",_n="不能设置自己的群成员身份,请检查传入参数",vn="不能将自己禁言,请检查传入参数",yn="传入 deleteFriend 接口的参数无效",In="传入 updateMyProfile 接口的参数无效",Mn="updateMyProfile 无标配资料字段或自定义资料字段",Cn="传入 addToBlacklist 接口的参数无效",En="传入 removeFromBlacklist 接口的参数无效",Tn="不能拉黑自己",Dn="网络层初始化错误,缺少 URL 参数",Sn="打包错误,未定义的 serverName",kn="未定义的 packageConfig",On="未连接到网络",Rn="不规范的参数名称",An="意料外的通知条件",Nn="_syncOffset 丢失",Ln="获取 longpolling id 失败",wn="无效操作,如调用了未定义或者未实现的方法等",Pn="接口需要 SDK 处于 ready 状态后才能调用",Gn=["jpg","jpeg","gif","png"],bn=["mp4"],Un=function(){function e(n){i(this,e);var o=this._check(n);if(o instanceof kt)throw o;this.type=t.MSG_FILE,this._percent=0;var r=this._getFileInfo(n);this.content={downloadFlag:2,fileUrl:n.url||"",uuid:n.uuid,fileName:r.name||"",fileSize:r.size||0}}return a(e,[{key:"_getFileInfo",value:function(e){if(e.fileName&&e.fileSize)return{size:e.fileSize,name:e.fileName};if(P)return{};var t=e.file.files[0];return{size:t.size,name:t.name,type:t.type.slice(t.type.lastIndexOf("/")+1).toLowerCase()}}},{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateFileUrl",value:function(e){this.content.fileUrl=e}},{key:"_check",value:function(e){if(e.size>104857600)return new kt({code:Ot.MESSAGE_FILE_SIZE_LIMIT,message:"".concat(Zt,": ").concat(104857600," bytes")})}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&(""!==this.content.fileName&&0!==this.content.fileSize)}}]),e}(),qn=function(){function e(n){i(this,e),this.type=t.MSG_CUSTOM,this.content={data:n.data||"",description:n.description||"",extension:n.extension||""}}return a(e,[{key:"setData",value:function(e){return this.content.data=e,this}},{key:"setDescription",value:function(e){return this.content.description=e,this}},{key:"setExtension",value:function(e){return this.content.extension=e,this}},{key:"sendable",value:function(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}]),e}(),Fn=function(){function e(n){i(this,e),this.type=t.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:n.remoteVideoUrl,videoFormat:n.videoFormat,videoSecond:parseInt(n.videoSecond,10),videoSize:n.videoSize,videoUrl:n.videoUrl,videoDownloadFlag:2,videoUUID:n.videoUUID,thumbUUID:n.thumbUUID,thumbFormat:n.thumbFormat,thumbWidth:n.thumbWidth,thumbHeight:n.thumbHeight,thumbSize:n.thumbSize,thumbDownloadFlag:2,thumbUrl:n.thumbUrl}}return a(e,[{key:"updatePercent",value:function(e){this._percent=e,this._percent>1&&(this._percent=1)}},{key:"updateVideoUrl",value:function(e){e&&(this.content.remoteVideoUrl=e)}},{key:"sendable",value:function(){return""!==this.content.remoteVideoUrl}}]),e}(),xn=function e(n){i(this,e),this.type=t.MSG_GEO,this.content=n},Vn={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST},Kn=function(){function e(n){i(this,e),this.ID="",this.conversationID=n.conversationID||null,this.conversationType=n.conversationType||t.CONV_C2C,this.conversationSubType=n.conversationSubType,this.time=n.time||Math.ceil(Date.now()/1e3),this.sequence=n.sequence||0,this.clientSequence=n.clientSequence||n.sequence||0,this.random=n.random||Te(),this.priority=this._computePriority(n.priority),this.nick="",this.avatar="",this.isPeerRead=!1,this._elements=[],this.isPlaceMessage=n.isPlaceMessage||0,this.isRevoked=2===n.isPlaceMessage||8===n.msgFlagBits,this.geo={},this.from=n.from||null,this.to=n.to||null,this.flow="",this.isSystemMessage=n.isSystemMessage||!1,this.protocol=n.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=n.status||We.SUCCESS,this.reInitialize(n.currentUser),this.extractGroupInfo(n.groupProfile||null)}return a(e,[{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){null!==e&&(ue(e.fromAccountNick)&&(this.nick=e.fromAccountNick),ue(e.fromAccountHeadurl)&&(this.avatar=e.fromAccountHeadurl))}},{key:"_initProxy",value:function(){this.payload=this._elements[0].content,this.type=this._elements[0].type}},{key:"reInitialize",value:function(e){e&&(this.status=this.from?We.SUCCESS:We.UNSEND,!this.from&&(this.from=e)),this._initFlow(e),this._initielizeSequence(e),this._concactConversationID(e),this.generateMessageID(e)}},{key:"isSendable",value:function(){return 0!==this._elements.length&&("function"!=typeof this._elements[0].sendable?(ie.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===t.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initielizeSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return ie.error("autoincrementIndex(string: key) need key parameter"),!1;if(void 0===Oe[e]){var t=new Date,n="3".concat(t.getHours()).slice(-2),o="0".concat(t.getMinutes()).slice(-2),r="0".concat(t.getSeconds()).slice(-2);Oe[e]=parseInt([n,o,r,"0001"].join("")),n=null,o=null,r=null,ie.warn("utils.autoincrementIndex() create new sequence : ".concat(e," = ").concat(Oe[e]))}return Oe[e]++}(e)),0===this.sequence&&this.conversationType===t.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function(e){var t=e===this.from?1:0,n=this.sequence>0?this.sequence:this.clientSequence;this.ID="".concat(this.conversationID,"-").concat(n,"-").concat(this.random,"-").concat(t)}},{key:"_initFlow",value:function(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}},{key:"_concactConversationID",value:function(e){var n=this.to,o="",r=this.conversationType;r!==t.CONV_SYSTEM?(o=r===t.CONV_C2C?e===this.from?n:this.from:this.to,this.conversationID="".concat(r).concat(o)):this.conversationID=t.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Je||e instanceof ft||e instanceof _t||e instanceof vt||e instanceof Un||e instanceof Fn||e instanceof It||e instanceof Ct||e instanceof qn||e instanceof xn}},{key:"setElement",value:function(e){var n=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var o=function(e){switch(e.type){case t.MSG_TEXT:n.setTextElement(e.content);break;case t.MSG_IMAGE:n.setImageElement(e.content);break;case t.MSG_AUDIO:n.setAudioElement(e.content);break;case t.MSG_FILE:n.setFileElement(e.content);break;case t.MSG_VIDEO:n.setVideoElement(e.content);break;case t.MSG_CUSTOM:n.setCustomElement(e.content);break;case t.MSG_GEO:n.setGEOElement(e.content);break;case t.MSG_GRP_TIP:n.setGroupTipElement(e.content);break;case t.MSG_GRP_SYS_NOTICE:n.setGroupSystemNoticeElement(e.content);break;case t.MSG_FACE:n.setFaceElement(e.content);break;default:ie.warn(e.type,e.content,"no operation......")}};if(Array.isArray(e))for(var r=0;r<e.length;r++)o(e[r]);else o(e);this._initProxy()}},{key:"setTextElement",value:function(e){var t="string"==typeof e?e:e.text,n=new Je({text:t});this._elements.push(n)}},{key:"setImageElement",value:function(e){var t=new ft(e);this._elements.push(t)}},{key:"setAudioElement",value:function(e){var t=new vt(e);this._elements.push(t)}},{key:"setFileElement",value:function(e){var t=new Un(e);this._elements.push(t)}},{key:"setVideoElement",value:function(e){var t=new Fn(e);this._elements.push(t)}},{key:"setGEOElement",value:function(e){var t=new xn(e);this._elements.push(t)}},{key:"setCustomElement",value:function(e){var t=new qn(e);this._elements.push(t)}},{key:"setGroupTipElement",value:function(e){var n={},o=e.operationType;Ke(e.memberInfoList)||o!==t.GRP_TIP_MBR_JOIN&&o!==t.GRP_TIP_MBR_KICKED_OUT?e.operatorInfo&&(n=e.operatorInfo):n=e.memberInfoList[0];var r=n,i=r.nick,s=r.avatar;ue(i)&&(this.nick=i),ue(s)&&(this.avatar=s);var a=new It(e);this._elements.push(a)}},{key:"setGroupSystemNoticeElement",value:function(e){var t=new Ct(e);this._elements.push(t)}},{key:"setFaceElement",value:function(e){var t=new _t(e);this._elements.push(t)}},{key:"setIsRead",value:function(e){this.isRead=e}},{key:"_computePriority",value:function(e){if(ge(e))return t.MSG_PRIORITY_NORMAL;if(ue(e)&&-1!==Object.values(Vn).indexOf(e))return e;if(ae(e)){var n=""+e;if(-1!==Object.keys(Vn).indexOf(n))return Vn[n]}return t.MSG_PRIORITY_NORMAL}},{key:"elements",get:function(){return ie.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}}]),e}(),Hn=function(e){return!!e&&(!!(function(e){return ue(e)&&e.slice(0,3)===t.CONV_C2C}(e)||function(e){return ue(e)&&e.slice(0,5)===t.CONV_GROUP}(e)||be(e))||(console.warn("非法的会话 ID:".concat(e,"。会话 ID 组成方式:C2C + userID(单聊)GROUP + groupID(群聊)@TIM#SYSTEM(系统通知会话)")),!1))},Bn="请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#",jn=function(e){return e.param?"".concat(e.api," ").concat(e.param," ").concat(e.desc,"。").concat(Bn).concat(e.api):"".concat(e.api," ").concat(e.desc,"。").concat(Bn).concat(e.api)},$n={type:"String",required:!0},Yn={type:"Array",required:!0},Wn={type:"Object",required:!0},zn={login:{userID:$n,userSig:$n},addToBlacklist:{userIDList:Yn},on:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(jn({api:"on",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(jn({api:"on",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("on 接口的 handler 参数推荐使用具名函数。具名函数可以使用 off 接口取消订阅,匿名函数无法取消订阅。"),!0)}}],once:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(jn({api:"once",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(jn({api:"once",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("once 接口的 handler 参数推荐使用具名函数。"),!0)}}],off:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn(jn({api:"off",param:"eventName",desc:"类型必须为 String,且不能为空"})),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn(jn({api:"off",param:"handler",desc:"参数必须为 Function"})),!1):(""===e.name&&console.warn("off 接口无法为匿名函数取消监听事件。"),!0)}}],sendMessage:[l({name:"message"},Wn)],getMessageList:{conversationID:l(l({},$n),{},{validator:function(e){return Hn(e)}}),nextReqMessageID:{type:"String"},count:{type:"Number",validator:function(e){return!(!ge(e)&&!/^[1-9][0-9]*$/.test(e))||(console.warn(jn({api:"getMessageList",param:"count",desc:"必须为正整数"})),!1)}}},setMessageRead:{conversationID:l(l({},$n),{},{validator:function(e){return Hn(e)}})},getConversationProfile:[l(l({name:"conversationID"},$n),{},{validator:function(e){return Hn(e)}})],deleteConversation:[l(l({name:"conversationID"},$n),{},{validator:function(e){return Hn(e)}})],getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:$n,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:Yn},createGroup:{name:$n},joinGroup:{groupID:$n,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[l({name:"groupID"},$n)],handleApplication:{message:Wn,handleAction:$n,handleMessage:{type:"String"}},changeGroupOwner:{groupID:$n,newOwnerID:$n},updateGroupProfile:{groupID:$n,muteAllMembers:{type:"Boolean"}},dismissGroup:[l({name:"groupID"},$n)],searchGroupByID:[l({name:"groupID"},$n)],getGroupMemberList:{groupID:$n,offset:{type:"Number"},count:{type:"Number"}},getGroupMemberProfile:{groupID:$n,userIDList:Yn,memberCustomFieldFilter:{type:"Array"}},addGroupMemeber:{groupID:$n,userIDList:Yn},setGroupMemberRole:{groupID:$n,userID:$n,role:$n},setGroupMemberMuteTime:{groupID:$n,userID:$n,muteTime:{type:"Number",validator:function(e){return e>=0}}},setGroupMemberNameCard:{groupID:$n,userID:{type:"String"},nameCard:l(l({},$n),{},{validator:function(e){return!0!==/^\s+$/.test(e)}})},setMessageRemindType:{groupID:$n,messageRemindType:$n},setGroupMemberCustomField:{groupID:$n,userID:{type:"String"},memberCustomField:Yn},deleteGroupMember:{groupID:$n},createTextMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){return le(e)?ue(e.text)?0!==e.text.length||(console.warn(jn({api:"createTextMessage",desc:"消息内容不能为空"})),!1):(console.warn(jn({api:"createTextMessage",param:"payload.text",desc:"类型必须为 String"})),!1):(console.warn(jn({api:"createTextMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createCustomMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){return le(e)?e.data&&!ue(e.data)?(console.warn(jn({api:"createCustomMessage",param:"payload.data",desc:"类型必须为 String"})),!1):e.description&&!ue(e.description)?(console.warn(jn({api:"createCustomMessage",param:"payload.description",desc:"类型必须为 String"})),!1):!(e.extension&&!ue(e.extension))||(console.warn(jn({api:"createCustomMessage",param:"payload.extension",desc:"类型必须为 String"})),!1):(console.warn(jn({api:"createCustomMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createImageMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){if(!le(e))return console.warn(jn({api:"createImageMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(ge(e.file))return console.warn(jn({api:"createImageMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(w){if(!(e.file instanceof HTMLInputElement||se(e.file)))return console.warn(jn({api:"createImageMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(jn({api:"createImageMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return ge(e)&&console.warn(jn({api:"createImageMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}})},createAudioMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){return!!le(e)||(console.warn(jn({api:"createAudioMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}}),onProgress:{type:"Function",required:!1,validator:function(e){return ge(e)&&console.warn(jn({api:"createAudioMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createVideoMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){if(!le(e))return console.warn(jn({api:"createVideoMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(ge(e.file))return console.warn(jn({api:"createVideoMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(w){if(!(e.file instanceof HTMLInputElement||se(e.file)))return console.warn(jn({api:"createVideoMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(jn({api:"createVideoMessage",param:"payload.file",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return ge(e)&&console.warn(jn({api:"createVideoMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},createFaceMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){return le(e)?ae(e.index)?!!ue(e.data)||(console.warn(jn({api:"createFaceMessage",param:"payload.data",desc:"类型必须为 String"})),!1):(console.warn(jn({api:"createFaceMessage",param:"payload.index",desc:"类型必须为 Number"})),!1):(console.warn(jn({api:"createFaceMessage",param:"payload",desc:"类型必须为 plain object"})),!1)}})},createFileMessage:{to:$n,conversationType:$n,payload:l(l({},Wn),{},{validator:function(e){if(!le(e))return console.warn(jn({api:"createFileMessage",param:"payload",desc:"类型必须为 plain object"})),!1;if(ge(e.file))return console.warn(jn({api:"createFileMessage",param:"payload.file",desc:"不能为 undefined"})),!1;if(w){if(!(e.file instanceof HTMLInputElement||se(e.file)))return console.warn(jn({api:"createFileMessage",param:"payload.file",desc:"类型必须是 HTMLInputElement 或 File"})),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn(jn({api:"createFileMessage",desc:"您没有选择文件,无法发送"})),!1}return!0}}),onProgress:{type:"Function",required:!1,validator:function(e){return ge(e)&&console.warn(jn({api:"createFileMessage",desc:"没有 onProgress 回调,您将无法获取上传进度"})),!0}}},revokeMessage:[l(l({name:"message"},Wn),{},{validator:function(e){return e instanceof Kn?e.conversationType===t.CONV_SYSTEM?(console.warn("revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息"),!1):!0!==e.isRevoked||(console.warn("revokeMessage 消息已经被撤回,请勿重复操作"),!1):(console.warn("revokeMessage 参数 message 必须为 Message(".concat(Bn,"Message.html) 实例。")),!1)}})],getUserProfile:{userIDList:{type:"Array",validator:function(e){return pe(e)?(0===e.length&&console.warn(jn({api:"getUserProfile",param:"userIDList",desc:"不能为空数组"})),!0):(console.warn(jn({api:"getUserProfile",param:"userIDList",desc:"必须为数组"})),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!ge(e)||(!!pe(e)||(console.warn(jn({api:"updateMyProfile",param:"profileCustomField",desc:"必须为数组"})),!1))}}}},Jn={login:"login",logout:"logout",on:"on",once:"once",off:"off",setLogLevel:"setLogLevel",downloadLog:"downloadLog",registerPlugin:"registerPlugin",destroy:"destroy",createTextMessage:"createTextMessage",createImageMessage:"createImageMessage",createAudioMessage:"createAudioMessage",createVideoMessage:"createVideoMessage",createCustomMessage:"createCustomMessage",createFaceMessage:"createFaceMessage",createFileMessage:"createFileMessage",sendMessage:"sendMessage",resendMessage:"resendMessage",getMessageList:"getMessageList",setMessageRead:"setMessageRead",revokeMessage:"revokeMessage",getConversationList:"getConversationList",getConversationProfile:"getConversationProfile",deleteConversation:"deleteConversation",getGroupList:"getGroupList",getGroupProfile:"getGroupProfile",createGroup:"createGroup",joinGroup:"joinGroup",updateGroupProfile:"updateGroupProfile",quitGroup:"quitGroup",dismissGroup:"dismissGroup",changeGroupOwner:"changeGroupOwner",searchGroupByID:"searchGroupByID",setMessageRemindType:"setMessageRemindType",handleGroupApplication:"handleGroupApplication",getGroupMemberProfile:"getGroupMemberProfile",getGroupMemberList:"getGroupMemberList",addGroupMember:"addGroupMember",deleteGroupMember:"deleteGroupMember",setGroupMemberNameCard:"setGroupMemberNameCard",setGroupMemberMuteTime:"setGroupMemberMuteTime",setGroupMemberRole:"setGroupMemberRole",setGroupMemberCustomField:"setGroupMemberCustomField",getGroupOnlineMemberCount:"getGroupOnlineMemberCount",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList",callExperimentalAPI:"callExperimentalAPI"},Xn="1.7.3",Qn="537048168",Zn="10",eo="protobuf",to="json",no=1,oo=2,ro=3,io=4,so={HOST:{CURRENT:{COMMON:"https://webim.tim.qq.com",PIC:"https://pic.tim.qq.com",COS:"https://yun.tim.qq.com"},PRODUCTION:{COMMON:"https://webim.tim.qq.com",PIC:"https://pic.tim.qq.com",COS:"https://yun.tim.qq.com"},OVERSEA_PRODUCTION:{COMMON:"https://api.im.qcloud.com",PIC:"https://api.im.qcloud.com",COS:"https://api.im.qcloud.com"},SANDBOX:{COMMON:"https://events.tim.qq.com",PIC:"https://pic.tim.qq.com",COS:"https://yun.tim.qq.com"},TEST:{COMMON:"https://test.tim.qq.com",PIC:"https://pic.tim.qq.com",COS:"https://test.tim.qq.com"},setCurrent:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;e===no?this.CURRENT=this.SANDBOX:e===oo?this.CURRENT=this.TEST:e===ro?this.CURRENT=this.PRODUCTION:e===io&&(this.CURRENT=this.OVERSEA_PRODUCTION)}},NAME:{OPEN_IM:"openim",GROUP:"group_open_http_svc",FRIEND:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GROUP_NO_AUTH:"group_open_http_noauth_svc",BIG_GROUP_LONG_POLLING:"group_open_long_polling_http_svc",BIG_GROUP_LONG_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr"},CMD:{ACCESS_LAYER:"accesslayer",LOGIN:"login",LOGOUT_LONG_POLL:"longpollinglogout",LOGOUT_ALL:"logout",PORTRAIT_GET:"portrait_get_all",PORTRAIT_SET:"portrait_set",GET_LONG_POLL_ID:"getlongpollingid",LONG_POLL:"longpolling",AVCHATROOM_LONG_POLL:"get_msg",FRIEND_ADD:"friend_add",FRIEND_GET_ALL:"friend_get_all",FRIEND_DELETE:"friend_delete",RESPONSE_PENDENCY:"friend_response",GET_PENDENCY:"pendency_get",DELETE_PENDENCY:"pendency_delete",GET_GROUP_PENDENCY:"get_pendency",GET_BLACKLIST:"black_list_get",ADD_BLACKLIST:"black_list_add",DELETE_BLACKLIST:"black_list_delete",CREATE_GROUP:"create_group",GET_JOINED_GROUPS:"get_joined_group_list",SEND_MESSAGE:"sendmsg",REVOKE_C2C_MESSAGE:"msgwithdraw",SEND_GROUP_MESSAGE:"send_group_msg",REVOKE_GROUP_MESSAGE:"group_msg_recall",GET_GROUP_INFO:"get_group_info",GET_GROUP_MEMBER_INFO:"get_specified_group_member_info",GET_GROUP_MEMBER_LIST:"get_group_member_info",QUIT_GROUP:"quit_group",CHANGE_GROUP_OWNER:"change_group_owner",DESTROY_GROUP:"destroy_group",ADD_GROUP_MEMBER:"add_group_member",DELETE_GROUP_MEMBER:"delete_group_member",SEARCH_GROUP_BY_ID:"get_group_public_info",APPLY_JOIN_GROUP:"apply_join_group",HANDLE_APPLY_JOIN_GROUP:"handle_apply_join_group",MODIFY_GROUP_INFO:"modify_group_base_info",MODIFY_GROUP_MEMBER_INFO:"modify_group_member_info",DELETE_GROUP_SYSTEM_MESSAGE:"deletemsg",GET_CONVERSATION_LIST:"get",PAGING_GET_CONVERSATION_LIST:"page_get",DELETE_CONVERSATION:"delete",GET_MESSAGES:"getmsg",GET_C2C_ROAM_MESSAGES:"getroammsg",GET_GROUP_ROAM_MESSAGES:"group_msg_get",SET_C2C_MESSAGE_READ:"msgreaded",GET_PEER_READ_TIME:"get_peer_read_time",SET_GROUP_MESSAGE_READ:"msg_read_report",FILE_READ_AND_WRITE_AUTHKEY:"authkey",FILE_UPLOAD:"pic_up",COS_SIGN:"cos",TIM_WEB_REPORT:"tim_web_report",BIG_DATA_HALLWAY_AUTH_KEY:"authkey",GET_ONLINE_MEMBER_NUM:"get_online_member_num"},CHANNEL:{SOCKET:1,XHR:2,AUTO:0},NAME_VERSION:{openim:"v4",group_open_http_svc:"v4",sns:"v4",profile:"v4",recentcontact:"v4",openpic:"v4",group_open_http_noauth_svc:"v4",group_open_long_polling_http_svc:"v4",group_open_long_polling_http_noauth_svc:"v4",imopenstat:"v4",im_cos_sign_svr:"v4",webim:"v4"}};so.HOST.setCurrent(ro);var ao={request:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",avatar:"FaceUrl"},response:{GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",GroupWithdrawInfoArray:"revokedInfos",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupName:"name",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension"},ignoreKeyWord:["C2C","ID","USP"]},uo="_contextWasUpdated",co="_contextWasReset",lo="_a2KeyAndTinyIDUpdated",po="_specifiedConfigUpdated",go="_noticeIsSynchronizing",ho="_noticeIsSynchronized",mo="_messageSent",fo="_syncMessageProcessing",_o="_syncMessageFinished",vo="_receiveInstantMessage",yo="_receiveGroupInstantMessage",Io="_receveGroupSystemNotice",Mo="_messageRevoked",Co="_longPollGetIDFailed",Eo="_longPollRequestFailed",To="_longPollResponseOK",Do="_longPollKickedOut",So="_longPollMitipuleDeviceKickedOut",ko="_longPollGetNewC2CNotice",Oo="_longPollGetNewGroupMessages",Ro="_longPollGetNewGroupTips",Ao="_longPollGetNewGroupNotice",No="_longPollGetNewFriendMessages",Lo="_longPollProfileModified",wo=" _longpollGroupMessageRevoked",Po="_longpollC2CMessageRevoked",Go="_longpollC2CMessageReadReceipt",bo="_avlongPollRequestFailed",Uo="_avlongPollResponseOK",qo="_onGroupListUpdated",Fo="_loginSuccess",xo="_signLogoutExcuting",Vo="_logoutSuccess",Ko="_a2keyExpired",Ho="_errorHasBeenDetected",Bo="_onConversationListUpdated",jo="_onConversationListProfileUpdated",$o="_conversationDeleted",Yo="onProfileUpdated",Wo="joinAVChatRoomSuccess",zo="joinAVChatRoomSuccessNoAuth",Jo="_sdkStateReady",Xo="_sdkReload";function Qo(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);var n;return 0===(e=Array.isArray(e)?e.map((function(e){return e.trim()})).filter((function(e){return e.length})).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=Zo(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),n=e,t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n)}var Zo=function(e){for(var t=!1,n=!1,o=!1,r=0;r<e.length;r++){var i=e[r];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,r)+"-"+e.slice(r),t=!1,o=n,n=!0,r++):n&&o&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,r-1)+"-"+e.slice(r-1),o=n,n=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,o=n,n=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e};function er(e,t,n){var o=[],r=0,i=function e(t,n){if(++r>10)return r--,t;if(pe(t)){var i=t.map((function(t){return ce(t)?e(t,n):t}));return r--,i}if(ce(t)){var s=(a=t,u=function(e,t){if(!_e(t))return!1;if((s=t)!==Qo(s)){for(var r=!0,i=0;i<ao.ignoreKeyWord.length;i++)if(t.includes(ao.ignoreKeyWord[i])){r=!1;break}r&&o.push(t)}var s;return ge(n[t])?function(e){return"OPPOChannelID"===e?e:e[0].toUpperCase()+Qo(e).slice(1)}(t):n[t]},c=Object.create(null),Object.keys(a).forEach((function(e){var t=u(a[e],e);t&&(c[t]=a[e])})),c);return s=Ue(s,(function(t,o){return pe(t)||ce(t)?e(t,n):t})),r--,s}var a,u,c}(e,t=l(l({},ao.request),t));return o.length>0&&n.innerEmitter.emit(Ho,{code:Ot.CONVERTOR_IRREGULAR_PARAMS,message:Rn}),i}function tr(e,t){if(t=l(l({},ao.response),t),pe(e))return e.map((function(e){return ce(e)?tr(e,t):e}));if(ce(e)){var n=(o=e,r=function(e,n){return ge(t[n])?Qo(n):t[n]},i={},Object.keys(o).forEach((function(e){i[r(o[e],e)]=o[e]})),i);return n=Ue(n,(function(e){return pe(e)||ce(e)?tr(e,t):e}))}var o,r,i}var nr=function(){function e(t){var n=this;i(this,e),this.url="",this.requestData=null,this.method=t.method||"POST",this.callback=function(e){return tr(e=t.decode(e),n._getResponseMap(t))},this._initializeServerMap(),this._initializeURL(t),this._initializeRequestData(t)}return a(e,[{key:"_initializeServerMap",value:function(){this._serverMap=Object.create(null);var e="";for(var t in so.NAME)if(Object.prototype.hasOwnProperty.call(so.NAME,t))switch(e=so.NAME[t]){case so.NAME.PIC:this._serverMap[e]=so.HOST.CURRENT.PIC;break;case so.NAME.IM_COS_SIGN:this._serverMap[e]=so.HOST.CURRENT.COS;break;default:this._serverMap[e]=so.HOST.CURRENT.COMMON}}},{key:"_getHost",value:function(e){if(void 0!==this._serverMap[e])return this._serverMap[e];throw new kt({code:Ot.NETWORK_UNDEFINED_SERVER_NAME,message:Sn})}},{key:"_initializeURL",value:function(e){var t=e.serverName,n=e.cmd,o=this._getHost(t),r="".concat(o,"/").concat(so.NAME_VERSION[t],"/").concat(t,"/").concat(n);r+="?".concat(this._getQueryString(e.queryString)),this.url=r}},{key:"getUrl",value:function(){return this.url.replace(/&reqtime=(\d+)/,"&reqtime=".concat(Math.ceil(+new Date/1e3)))}},{key:"_initializeRequestData",value:function(e){var t,n=e.requestData;t=this._requestDataCleaner(n),this.requestData=e.encode(t)}},{key:"_requestDataCleaner",value:function(e){var t=Array.isArray(e)?[]:Object.create(null);for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&_e(o)&&null!==e[o]&&("object"!==n(e[o])?t[o]=e[o]:t[o]=this._requestDataCleaner.bind(this)(e[o]));return t}},{key:"_getQueryString",value:function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&("function"!=typeof e[n]?t.push("".concat(n,"=").concat(e[n])):t.push("".concat(n,"=").concat(e[n]())));return t.join("&")}},{key:"_getResponseMap",value:function(e){if(e.keyMaps&&e.keyMaps.response&&Object.keys(e.keyMaps.response).length>0)return e.keyMaps.response}}]),e}();function or(e){this.mixin(e)}or.mixin=function(e){var t=e.prototype||e;t._isReady=!1,t.ready=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},t.triggerReady=function(){var e=this;this._isReady=!0,setTimeout((function(){var t=e._readyQueue;e._readyQueue=[],t&&t.length>0&&t.forEach((function(e){e.call(this)}),e)}),1)},t.resetReady=function(){this._isReady=!1,this._readyQueue=[]},t.isReady=function(){return this._isReady}};var rr=function(){function e(t){i(this,e),or.mixin(this),this.tim=t}return a(e,[{key:"isLoggedIn",value:function(){return this.tim.context.login===Ye.IS_LOGIN||!!this.tim.context.a2Key}},{key:"createTransportCapsule",value:function(e){var t=this.tim.packageConfig.get(e);return t?new nr(t):null}},{key:"request",value:function(e){var t=this.createTransportCapsule(e);return t||ie.error("unknown transport capsule, please check!",e),this.tim.connectionController.request(t)}},{key:"emitInnerEvent",value:function(e,t){this.tim.innerEmitter.emit(e,t)}},{key:"emitOuterEvent",value:function(e,t){this.tim.outerEmitter.emit(e,t)}},{key:"reset",value:function(){ie.warn(["method: IMController.reset() method must be implemented"].join())}},{key:"probeNetwork",value:function(){return this.tim.netMonitor.probe()}},{key:"getNetworkType",value:function(){return this.tim.netMonitor.getNetworkType()}},{key:"getPlatform",value:function(){var e="web";return W?e="wechat":P&&(e="wxmp"),e}}]),e}(),ir=function(){function e(t,n){i(this,e),this.data=t,this._innerEmitter=n,this.defaultData={},Object.assign(this.defaultData,t),this.initGetterAndSetter()}return a(e,[{key:"initGetterAndSetter",value:function(){var e=this,t=function(t){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){return e.data[t]},set:function(n){e.data[t]!==n&&(e.data[t]=n,e.onChange.bind(e)(t,n))}})};for(var n in e.data)Object.prototype.hasOwnProperty.call(e.data,n)&&t(n)}},{key:"onChange",value:function(e,t){this._innerEmitter.emit(uo,{key:e,value:t})}},{key:"reset",value:function(){for(var e in ie.log("Context.reset"),this.data)Object.prototype.hasOwnProperty.call(this.data,e)&&(this.data[e]=this.defaultData.hasOwnProperty(e)?this.defaultData[e]:null)}}]),e}(),sr=function(e){p(n,e);var t=I(n);function n(e){var o;i(this,n);var r=(o=t.call(this,e)).tim.loginInfo;return o._context=new ir({login:Ye.IS_NOT_LOGIN,SDKAppID:r.SDKAppID,appIDAt3rd:null,accountType:r.accountType,identifier:r.identifier,tinyID:null,identifierNick:r.identifierNick,userSig:r.userSig,a2Key:null,contentType:"json",apn:1,unlimitedAVChatRoom:r.unlimitedAVChatRoom,scene:r.scene,oversea:r.oversea,instanceID:r.instanceID},o.tim.innerEmitter),o._initListener(),o}return a(n,[{key:"reset",value:function(){this._context.reset(),this.emitInnerEvent(co)}},{key:"_initListener",value:function(){this.tim.innerEmitter.on(uo,this._onContextMemberChange,this),this.tim.innerEmitter.on(Fo,this._updateA2KeyAndTinyID,this)}},{key:"_updateA2KeyAndTinyID",value:function(e){var t=e.data,n=t.a2Key,o=t.tinyID;this._context.a2Key=n,this._context.tinyID=o,this.emitInnerEvent(lo),this.triggerReady()}},{key:"getContext",value:function(){return this._context}},{key:"_onContextMemberChange",value:function(e){var t=e.data,n=t.key,o=t.value;("tinyID"===n||"a2Key"===n)&&(o.length<=0?this._context.login=Ye.IS_NOT_LOGIN:this._context.login=null!==this._context.a2Key?Ye.IS_LOGIN:Ye.IS_NOT_LOGIN)}}]),n}(rr),ar=function e(t){i(this,e),this.code=0,this.data=t||{}},ur=null,cr=function(e){ur=e},lr=function(e){return e instanceof ar?(ie.warn("IMPromise.resolve 此函数会自动用options创建IMResponse实例,调用侧不需创建,建议修改!"),Promise.resolve(e)):Promise.resolve(new ar(e))},pr=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof kt)return n&&null!==ur&&ur.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){var o=new kt({code:Ot.UNCAUGHT_ERROR,message:t.message});return n&&null!==ur&&ur.emit(e.ERROR,o),Promise.reject(o)}if(ge(t)||ge(t.code)||ge(t.message))ie.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if(ae(t.code)&&ue(t.message)){var r=new kt(t);return n&&null!==ur&&ur.emit(e.ERROR,r),Promise.reject(r)}ie.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},gr="sdkReady",hr="login",dr="longpolling",mr="longpollingAV",fr="sendMessage",_r="sendMessageC2C",vr="sendMessageGroupWork",yr="sendMessageGroupPublic",Ir="sendMessageGroupMeeting",Mr="sendMessageGroupAV",Cr="messageReceived",Er="messageReceivedAV",Tr="initConversationList",Dr="initGroupList",Sr="upload",kr=function(){function e(t){i(this,e),this.SDKAppID="",this.version="",this.tinyID="",this.userID="",this.platform="",this.method=t,this.time="",this.startts=Date.now(),this.endts=0,this.timespan=0,this.codeint=0,this.message="",this.text="",this.msgType="",this.networkType="",this.platform="",this.scene="",this._sentFlag=!1,this.instanceID="",this.host=function(){var e="unknown";if(J&&(e="mac"),z&&(e="windows"),x&&(e="ios"),V&&(e="android"),P)try{var t=wx.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(n){}return e}(),this.mpLibVersion=function(){if(P)try{var e=wx.getSystemInfoSync().SDKVersion;return void 0===e?"-":e}catch(t){return"-"}return"-"}()}return a(e,[{key:"setCommonInfo",value:function(e){var t=e.SDKAppID,n=e.version,o=e.tinyID,r=e.userID,i=e.platform,s=e.scene,a=e.instanceID;this.SDKAppID="".concat(t),this.version="".concat(n),this.tinyID=o,this.userID=r,this.platform=i,this.scene=s,this.time=Ce(),this.instanceID=a,this.startts&&this.endts&&!this.timespan&&(this.timespan=Math.abs(this.endts-this.startts))}},{key:"setEnd",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._sentFlag||(this.endts=Date.now(),t?(this._sentFlag=!0,this._eventStatController.pushIn(this)):setTimeout((function(){e._sentFlag=!0,e._eventStatController.pushIn(e)}),0))}},{key:"setError",value:function(e,t,n){return e instanceof Error?(this._sentFlag||(this.setNetworkType(n),t?(e.code&&this.setCode(e.code),e.message&&this.setMessage(e.message)):(this.setCode(Ot.NO_NETWORK),this.setMessage(On))),this):(ie.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(e){return ge(e)||this._sentFlag||("ECONNABORTED"===e&&(this.codeint=103),ae(e)?this.codeint=e:ie.warn("SSOLogData.setCode value not a number, please check!",e,n(e))),this}},{key:"setMessage",value:function(e){return ge(e)||this._sentFlag?this:ue(e)?(this.message=e,this):this}},{key:"setText",value:function(e){return ae(e)?this.text=e.toString():ue(e)&&(this.text=e),this}},{key:"setMessageType",value:function(e){return this.msgType=e,this}},{key:"setNetworkType",value:function(e){return ge(e)?ie.warn("SSOLogData.setNetworkType value is undefined, please check!"):this.networkType=e,this}}],[{key:"bindController",value:function(t){e.prototype._eventStatController=t}}]),e}(),Or="sdkConstruct",Rr="sdkReady",Ar="accessLayer",Nr="login",Lr="logout",wr="kickedOut",Pr="registerPlugin",Gr="getCosAuthKey",br="upload",Ur="sendMessage",qr="sendComboMessage",Fr="getC2CRoamingMessages",xr="getGroupRoamingMessages",Vr="revokeMessage",Kr="setC2CMessageRead",Hr="setGroupMessageRead",Br="emptyMessageBody",jr="getPeerReadTime",$r="getConversationList",Yr="getConversationProfile",Wr="deleteConversation",zr="getConversationListInStorage",Jr="syncConversationList",Xr="createGroup",Qr="applyJoinGroup",Zr="joinAVChatRoomSilently",ei="quitGroup",ti="searchGroupByID",ni="changeGroupOwner",oi="handleGroupApplication",ri="setMessageRemindType",ii="dismissGroup",si="updateGroupProfile",ai="getGroupList",ui="getGroupProfile",ci="getGroupListInStorage",li="getGroupLastSequence",pi="getGroupMemberList",gi="getGroupMemberProfile",hi="addGroupMember",di="deleteGroupMember",mi="setGroupMemberMuteTime",fi="setGroupMemberNameCard",_i="setGroupMemberRole",vi="setGroupMemberCustomField",yi="getGroupOnlineMemberCount",Ii="getLongPollID",Mi="longPollingError",Ci="networkJitter",Ei="sdkReload",Ti="messageLoss",Di="messageStacked",Si="getUserProfile",ki="updateMyProfile",Oi="getBlacklist",Ri="addToBlacklist",Ai="removeFromBlacklist",Ni="mpHideToShow",Li="callbackFunctionError",wi="exceptionError",Pi=function(n){p(r,n);var o=I(r);function r(e){var t;return i(this,r),!0===(t=o.call(this,e)).tim.context.oversea&&so.HOST.setCurrent(io),t._initializeListener(),t}return a(r,[{key:"login",value:function(e){if(this.isLoggedIn()){var t="您已经登录账号".concat(e.identifier,"!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。");return ie.warn(t),lr({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}ie.log("SignController.login userID=".concat(e.identifier)),ie.time(hr);var n=this._checkLoginInfo(e);return Ke(n)?(this.tim.context.identifier=e.identifier,this.tim.context.userSig=e.userSig,this.tim.context.identifier&&this.tim.context.userSig?this._accessLayer():void 0):pr(n)}},{key:"_isLoginCurrentUser",value:function(e){return this.tim.context.identifier===e}},{key:"_initializeListener",value:function(){var e=this.tim.innerEmitter;e.on(Do,this._onMultipleAccountKickedOut,this),e.on(So,this._onMultipleDeviceKickedOut,this),e.on(Ko,this._onUserSigExpired,this)}},{key:"_accessLayer",value:function(){var e=this,t=new kr(Ar);return ie.log("SignController._accessLayer."),this.request({name:"accessLayer",action:"query"}).then((function(n){return t.setNetworkType(e.getNetworkType()).setText(n.data.webImAccessLayer).setEnd(),ie.log("SignController._accessLayer ok. webImAccessLayer=".concat(n.data.webImAccessLayer)),e.tim.context.oversea||n.data.webImAccessLayer!==no||so.HOST.setCurrent(n.data.webImAccessLayer),e._login()})).catch((function(n){return e.probeNetwork().then((function(o){var r=M(o,2),i=r[0],s=r[1];t.setError(n,i,s).setEnd(!0),e.tim.eventStatController.reportAtOnce()})),ie.error("SignController._accessLayer failed. error:",n),pr(n)}))}},{key:"_login",value:function(){var e=this,t=new kr(Nr);return this.request({name:"login",action:"query"}).then((function(n){var o=null;if(!n.data.tinyID)throw o=new kt({code:Ot.NO_TINYID,message:wt}),t.setError(o,!0,e.getNetworkType()).setEnd(),o;if(!n.data.a2Key)throw o=new kt({code:Ot.NO_A2KEY,message:Pt}),t.setError(o,!0,e.getNetworkType()).setEnd(),o;return t.setNetworkType(e.getNetworkType()).setText("".concat(e.tim.loginInfo.identifier)).setEnd(),ie.log("SignController.login ok. userID=".concat(e.tim.loginInfo.identifier," loginCost=").concat(ie.timeEnd(hr),"ms")),e.emitInnerEvent(Fo,{a2Key:n.data.a2Key,tinyID:n.data.tinyID}),lr(n.data)})).catch((function(n){return e.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd(!0)})),ie.error("SignController.login failed. error:",n),pr(n)}))}},{key:"logout",value:function(){return new kr(Lr).setNetworkType(this.getNetworkType()).setText("userID=".concat(this.tim.loginInfo.identifier," type=").concat("longPollLogout")).setEnd(!0),ie.info("SignController.logout"),this.emitInnerEvent(xo),this._logout(pt).then(this._emitLogoutSuccess.bind(this)).catch(this._emitLogoutSuccess.bind(this))}},{key:"_logout",value:function(e){var t=this.tim.notificationController,n=e===lt?"logout":"longPollLogout",o=e===lt?{name:n,action:"query"}:{name:n,action:"query",param:{longPollID:t.getLongPollID()}};return this.request(o).catch((function(e){return ie.error("SignController._logout error:",e),pr(e)}))}},{key:"_checkLoginInfo",value:function(e){var t=0,n="";return null===e.SDKAppID?(t=Ot.NO_SDKAPPID,n=Rt):null===e.accountType?(t=Ot.NO_ACCOUNT_TYPE,n=At):null===e.identifier?(t=Ot.NO_IDENTIFIER,n=Nt):null===e.userSig&&(t=Ot.NO_USERSIG,n=Lt),Ke(t)||Ke(n)?{}:{code:t,message:n}}},{key:"_emitLogoutSuccess",value:function(){return this.emitInnerEvent(Vo),lr({})}},{key:"_onMultipleAccountKickedOut",value:function(){var n=this;new kr(wr).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_MULT_ACCOUNT).setEnd(!0),ie.warn("SignController._onMultipleAccountKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)),this.tim.logout().then((function(){n.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_ACCOUNT})}))}},{key:"_onMultipleDeviceKickedOut",value:function(){var n=this;new kr(wr).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_MULT_DEVICE).setEnd(!0),ie.warn("SignController._onMultipleDeviceKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)),this.tim.logout().then((function(){n.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_DEVICE})}))}},{key:"_onUserSigExpired",value:function(){new kr(wr).setNetworkType(this.getNetworkType()).setText(t.KICKED_OUT_USERSIG_EXPIRED).setEnd(!0),ie.warn("SignController._onUserSigExpired: userSig 签名过期被踢下线"),this.emitOuterEvent(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this.tim.resetSDK()}},{key:"reset",value:function(){ie.info("SignController.reset")}}]),r}(rr),Gi=function e(){i(this,e)},bi=function(e){p(n,e);var t=I(n);function n(){var e;return i(this,n),(e=t.call(this)).retry=2,e._request=e.promisify(wx.request),e}return a(n,[{key:"request",value:function(e){return this._checkOptions(e),this._initOptions(e),e=l(l({},e),{},{responseType:"text"}),this._requestWithRetry(e)}},{key:"_requestWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._request(e).then(this._handleResolve).catch((function(o){if(ue(o.errMsg)){if(o.errMsg.includes("abort"))return lr({});if(o.errMsg.includes("timeout"))return t.retry>0&&n<t.retry?t._requestWithRetry(e,++n):pr(new kt({code:Ot.NETWORK_TIMEOUT,message:o.errMsg}));if(o.errMsg.includes("fail"))return t.retry>0&&n<t.retry?t._requestWithRetry(e,++n):pr(new kt({code:Ot.NETWORK_ERROR,message:o.errMsg}))}return pr(new kt(l({code:Ot.UNCAUGHT_ERROR,message:o.message},o)))}))}},{key:"_handleResolve",value:function(e){var t=e.data,n=t.error_code,o=t.ErrorCode;return ae(n)&&(o=n),o!==$e.SUCCESS&&(e.data.ErrorCode=Number("".concat(o))),e}},{key:"promisify",value:function(e){return function(t){return new Promise((function(n,o){var r=e(Object.assign({},t,{success:n,fail:o}));t.updateAbort&&t.updateAbort((function(){r&&de(r.abort)&&r.abort()}))}))}}}]),n}(function(){function e(){i(this,e)}return a(e,[{key:"request",value:function(e){console.warn("请注意: ConnectionBase.request() 方法必须被派生类重写:")}},{key:"_checkOptions",value:function(e){if(!1==!!e.url)throw new kt({code:Ot.NETWORK_BASE_OPTIONS_NO_URL,message:Dn})}},{key:"_initOptions",value:function(e){e.method=["POST","GET","PUT","DELETE","OPTION"].indexOf(e.method)>=0?e.method:"POST",e.dataType=e.dataType||"json",e.responseType=e.responseType||"json"}}]),e}()),Ui=function e(){i(this,e)},qi=function(){function e(){i(this,e),this.request=0,this.success=0,this.fail=0,this.reportRate=10,this.requestTimeCost=[]}return a(e,[{key:"report",value:function(){if(1!==this.request){if(this.request%this.reportRate!=0)return null;var e=this.avgRequestTime(),t="runLoop reports: success=".concat(this.success,",fail=").concat(this.fail,",total=").concat(this.request,",avg=").concat(e,",cur=").concat(this.requestTimeCost[this.requestTimeCost.length-1],",max=").concat(Math.max.apply(null,this.requestTimeCost),",min=").concat(Math.min.apply(null,this.requestTimeCost));ie.log(t)}}},{key:"setRequestTime",value:function(e,t){var n=Math.abs(t-e);100===this.requestTimeCost.length&&this.requestTimeCost.shift(),this.requestTimeCost.push(n)}},{key:"avgRequestTime",value:function(){for(var e,t=this.requestTimeCost.length,n=0,o=0;o<t;o++)n+=this.requestTimeCost[o];return e=n/t,Math.round(100*e)/100}}]),e}(),Fi=function(){function e(t){i(this,e),this._initializeOptions(t),this._initializeMembers(),this.status=new qi}return a(e,[{key:"destructor",value:function(){clearTimeout(this._seedID);var e=this._index();for(var t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=null);return e}},{key:"setIndex",value:function(e){this._index=e}},{key:"isRunning",value:function(){return!this._stoped}},{key:"getIndex",value:function(){return this._index}},{key:"_initializeOptions",value:function(e){this.options=e}},{key:"_initializeMembers",value:function(){this._index=-1,this._seedID=0,this._requestStatus=!1,this._stoped=!1,this._intervalTime=0,this._intervalIncreaseStep=1e3,this._intervalDecreaseStep=1e3,this._intervalTimeMax=5e3,this._protectTimeout=3e3,this._getNoticeSeq=this.options.getNoticeSeq,this._retryCount=0,this._responseTime=Date.now(),this._responseTimeThreshold=2e3,this.requestor=new bi,this.abort=null}},{key:"start",value:function(){0===this._seedID?(this._stoped=!1,this._send()):ie.log('WXRunLoop.start(): WXRunLoop is running now, if you want to restart runLoop , please run "stop()" first.')}},{key:"_reset",value:function(){ie.log("WXRunLoop.reset(), long poll _intervalMaxRate",this._intervalMaxRate),this.stop(),this.start()}},{key:"_intervalTimeIncrease",value:function(){this._intervalTime!==this._responseTimeThreshold&&(this._intervalTime<this._responseTimeThreshold&&(this._intervalTime+=this._intervalIncreaseStep),this._intervalTime>this._responseTimeThreshold&&(this._intervalTime=this._responseTimeThreshold))}},{key:"_intervalTimeDecrease",value:function(){0!==this._intervalTime&&(this._intervalTime>0&&(this._intervalTime-=this._intervalDecreaseStep),this._intervalTime<0&&(this._intervalTime=0))}},{key:"_intervalTimeAdjustment",value:function(){var e=Date.now();100*Math.floor((e-this._responseTime)/100)<=this._responseTimeThreshold?this._intervalTimeIncrease():this._intervalTimeDecrease(),this._responseTime=e}},{key:"_intervalTimeAdjustmentBaseOnResponseData",value:function(e){e.ErrorCode===$e.SUCCESS?this._intervalTimeDecrease():this._intervalTimeIncrease()}},{key:"_send",value:function(){var e=this;if(!0!==this._requestStatus){var t=this;this._requestStatus=!0,this.status.request++,"function"==typeof this.options.before&&this.options.before(t.options.pack.requestData);var n=Date.now(),o=0;this.requestor.request({url:t.options.pack.getUrl(),data:t.options.pack.requestData,method:t.options.pack.method,updateAbort:function(t){e.abort=t}}).then((function(r){if(t._intervalTimeAdjustmentBaseOnResponseData.bind(e)(r.data),t._retryCount>0&&(t._retryCount=0),e.status.success++,o=Date.now(),e.status.setRequestTime(n,o),r.data.timecost=o-n,"function"==typeof t.options.success)try{e.options.success({pack:e.options.pack,error:!1,data:e.options.pack.callback(r.data)})}catch(i){ie.warn("WXRunLoop._send(), error:",i)}t._requestStatus=!1,!1===t._stoped&&(t._seedID=setTimeout(t._send.bind(t),t._intervalTime)),e.status.report()})).catch((function(r){if(e.status.fail++,t._retryCount++,t._intervalTimeAdjustment.bind(e)(),!1===t._stoped&&(t._seedID=setTimeout(t._send.bind(t),t._intervalTime)),t._requestStatus=!1,"function"==typeof t.options.fail)try{e.options.fail({pack:e.options.pack,error:r,data:!1})}catch(i){ie.warn("WXRunLoop._send(), fail callback error:",i),ie.error(i)}o=Date.now(),e.status.setRequestTime(n,o),e.status.report()}))}}},{key:"stop",value:function(){this._clearAllTimeOut(),this._stoped=!0}},{key:"_clearAllTimeOut",value:function(){clearTimeout(this._seedID),this._seedID=0}}]),e}(),xi=function(){function e(t){i(this,e),this.tim=t,this.httpConnection=P?new bi:new Gi,this.keepAliveConnections=[]}return a(e,[{key:"initializeListener",value:function(){this.tim.innerEmitter.on(xo,this._stopAllRunLoop,this)}},{key:"request",value:function(e){var t={url:e.url,data:e.requestData,method:e.method,callback:e.callback};return this.httpConnection.request(t).then((function(t){return t.data=e.callback(t.data),t.data.errorCode!==$e.SUCCESS?pr(new kt({code:t.data.errorCode,message:t.data.errorInfo})):t}))}},{key:"createRunLoop",value:function(e){var t=this.createKeepAliveConnection(e);return t.setIndex(this.keepAliveConnections.push(t)-1),t}},{key:"stopRunLoop",value:function(e){e.stop()}},{key:"_stopAllRunLoop",value:function(){for(var e=this.keepAliveConnections.length,t=0;t<e;t++)this.keepAliveConnections[t].stop()}},{key:"destroyRunLoop",value:function(e){e.stop();var t=e.destructor();this.keepAliveConnections.slice(t,1)}},{key:"startRunLoopExclusive",value:function(e){for(var t=e.getIndex(),n=0;n<this.keepAliveConnections.length;n++)n!==t&&this.keepAliveConnections[n].stop();e.start()}},{key:"createKeepAliveConnection",value:function(e){return P?new Fi(e):(this.tim.options.runLoopNetType===ct||this.tim.options.runLoopNetType,new Ui(e))}},{key:"clearAll",value:function(){this.conn.cancelAll()}},{key:"reset",value:function(){this.keepAliveConnections=[]}}]),e}(),Vi=function(){function t(e){i(this,t),this.tim=e,this.tim.innerEmitter.on(Ho,this._onErrorDetected,this)}return a(t,[{key:"_onErrorDetected",value:function(t){var n=t.data;new kr(wi).setText("code=".concat(n.code," message=").concat(n.message)).setNetworkType(this.tim.netMonitor.getNetworkType()).setEnd(),n.code?ie.warn("Oops! code:".concat(n.code," message:").concat(n.message)):ie.warn("Oops! message:".concat(n.message," stack:").concat(n.stack)),this.tim.outerEmitter.emit(e.ERROR,n)}}]),t}(),Ki=function(){function e(n){var o=this;i(this,e),Ke(n)||(this.userID=n.userID||"",this.nick=n.nick||"",this.gender=n.gender||"",this.birthday=n.birthday||0,this.location=n.location||"",this.selfSignature=n.selfSignature||"",this.allowType=n.allowType||t.ALLOW_TYPE_ALLOW_ANY,this.language=n.language||0,this.avatar=n.avatar||"",this.messageSettings=n.messageSettings||0,this.adminForbidType=n.adminForbidType||t.FORBID_TYPE_NONE,this.level=n.level||0,this.role=n.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Ke(n.profileCustomField)||n.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return a(e,[{key:"validate",value:function(e){var t=!0,n="";if(Ke(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField)for(var o=e.profileCustomField.length,r=null,i=0;i<o;i++){if(r=e.profileCustomField[i],!ue(r.key)||-1===r.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"自定义资料字段的前缀必须是 Tag_Profile_Custom"};if(!ue(r.value))return{valid:!1,tips:"自定义资料字段的 value 必须是字符串"}}for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if("profileCustomField"===s)continue;if(Ke(e[s])&&!ue(e[s])&&!ae(e[s])){n="key:"+s+", invalid value:"+e[s],t=!1;continue}switch(s){case"nick":ue(e[s])||(n="nick should be a string",t=!1),Ee(e[s])>500&&(n="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(Ee(e[s])," bytes"),t=!1);break;case"gender":ke(ht,e.gender)||(n="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":ae(e.birthday)||(n="birthday should be a number",t=!1);break;case"location":ue(e.location)||(n="location should be a string",t=!1);break;case"selfSignature":ue(e.selfSignature)||(n="selfSignature should be a string",t=!1);break;case"allowType":ke(mt,e.allowType)||(n="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":ae(e.language)||(n="language should be a number",t=!1);break;case"avatar":ue(e.avatar)||(n="avatar should be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(n="messageSettings should be 0 or 1",t=!1);break;case"adminForbidType":ke(dt,e.adminForbidType)||(n="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":ae(e.level)||(n="level should be a number",t=!1);break;case"role":ae(e.role)||(n="role should be a number",t=!1);break;default:n="unknown key:"+s+" "+e[s],t=!1}}return{valid:t,tips:n}}}]),e}(),Hi=function(){function t(e){i(this,t),this.userController=e,this.TAG="profile",this.Actions={Q:"query",U:"update"},this.accountProfileMap=new Map,this.expirationTime=864e5}return a(t,[{key:"setExpirationTime",value:function(e){this.expirationTime=e}},{key:"getUserProfile",value:function(e){var t=this,n=e.userIDList;e.fromAccount=this.userController.getMyAccount(),n.length>100&&(ie.warn("ProfileHandler.getUserProfile 获取用户资料人数不能超过100人"),n.length=100);for(var o,r=[],i=[],s=0,a=n.length;s<a;s++)o=n[s],this.userController.isMyFriend(o)&&this._containsAccount(o)?i.push(this._getProfileFromMap(o)):r.push(o);if(0===r.length)return lr(i);e.toAccount=r;var u=e.bFromGetMyProfile||!1,c=[];e.toAccount.forEach((function(e){c.push({toAccount:e,standardSequence:0,customSequence:0})})),e.userItem=c;var l=new kr(Si);l.setText(n.length>5?"userIDList.length=".concat(n.length):"userIDList=".concat(n));var p=this.userController.generateConfig(this.TAG,this.Actions.Q,e);return this.userController.request(p).then((function(e){l.setNetworkType(t.userController.getNetworkType()).setEnd(),ie.info("ProfileHandler.getUserProfile ok");var n=t._handleResponse(e).concat(i);return u?(t.userController.onGotMyProfile(),new ar(n[0])):new ar(n)})).catch((function(e){return t.userController.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];l.setError(e,o,r).setEnd()})),ie.error("ProfileHandler.getUserProfile error:",e),pr(e)}))}},{key:"getMyProfile",value:function(){var e=this.userController.getMyAccount();if(ie.log("ProfileHandler.getMyProfile myAccount="+e),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return ie.debug("ProfileHandler.getMyProfile from cache, myProfile:"+JSON.stringify(t)),this.userController.onGotMyProfile(),lr(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,n,o=ye.now(),r=e.data.userProfileItem,i=[],s=0,a=r.length;s<a;s++)"@TLS#NOT_FOUND"!==r[s].to&&""!==r[s].to&&(t=r[s].to,n=this._updateMap(t,this._getLatestProfileFromResponse(t,r[s].profileItem)),i.push(n));return ie.log("ProfileHandler._handleResponse cost "+(ye.now()-o)+" ms"),i}},{key:"_getLatestProfileFromResponse",value:function(e,t){var n={};if(n.userID=e,n.profileCustomField=[],!Ke(t))for(var o=0,r=t.length;o<r;o++)if(t[o].tag.indexOf("Tag_Profile_Custom")>-1)n.profileCustomField.push({key:t[o].tag,value:t[o].value});else switch(t[o].tag){case gt.NICK:n.nick=t[o].value;break;case gt.GENDER:n.gender=t[o].value;break;case gt.BIRTHDAY:n.birthday=t[o].value;break;case gt.LOCATION:n.location=t[o].value;break;case gt.SELFSIGNATURE:n.selfSignature=t[o].value;break;case gt.ALLOWTYPE:n.allowType=t[o].value;break;case gt.LANGUAGE:n.language=t[o].value;break;case gt.AVATAR:n.avatar=t[o].value;break;case gt.MESSAGESETTINGS:n.messageSettings=t[o].value;break;case gt.ADMINFORBIDTYPE:n.adminForbidType=t[o].value;break;case gt.LEVEL:n.level=t[o].value;break;case gt.ROLE:n.role=t[o].value;break;default:ie.warn("ProfileHandler._handleResponse unkown tag->",t[o].tag,t[o].value)}return n}},{key:"updateMyProfile",value:function(t){var n=this,o=new kr(ki);o.setText(JSON.stringify(t));var r=(new Ki).validate(t);if(!r.valid)return o.setCode(Ot.UPDATE_PROFILE_INVALID_PARAM).setMessage("ProfileHandler.updateMyProfile info:".concat(r.tips)).setNetworkType(this.userController.getNetworkType()).setEnd(),ie.error("ProfileHandler.updateMyProfile info:".concat(r.tips,",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")),pr({code:Ot.UPDATE_PROFILE_INVALID_PARAM,message:In});var i=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&("profileCustomField"===s?t.profileCustomField.forEach((function(e){i.push({tag:e.key,value:e.value})})):i.push({tag:gt[s.toUpperCase()],value:t[s]}));if(0===i.length)return o.setCode(Ot.UPDATE_PROFILE_NO_KEY).setMessage(Mn).setNetworkType(this.userController.getNetworkType()).setEnd(),ie.error("ProfileHandler.updateMyProfile info:".concat(Mn,",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")),pr({code:Ot.UPDATE_PROFILE_NO_KEY,message:Mn});var a=this.userController.generateConfig(this.TAG,this.Actions.U,{fromAccount:this.userController.getMyAccount(),profileItem:i});return this.userController.request(a).then((function(r){o.setNetworkType(n.userController.getNetworkType()).setEnd(),ie.info("ProfileHandler.updateMyProfile ok");var i=n._updateMap(n.userController.getMyAccount(),t);return n.userController.emitOuterEvent(e.PROFILE_UPDATED,[i]),lr(i)})).catch((function(e){return n.userController.probeNetwork().then((function(t){var n=M(t,2),r=n[0],i=n[1];o.setError(e,r,i).setEnd()})),ie.error("ProfileHandler.updateMyProfile error:",e),pr(e)}))}},{key:"onProfileModified",value:function(t){var n=t.data;if(!Ke(n)){var o,r,i=n.length;ie.info("ProfileHandler.onProfileModified length="+i);for(var s=[],a=0;a<i;a++)o=n[a].userID,r=this._updateMap(o,this._getLatestProfileFromResponse(o,n[a].profileList)),s.push(r);this.userController.emitInnerEvent(Yo,s),this.userController.emitOuterEvent(e.PROFILE_UPDATED,s)}}},{key:"_fillMap",value:function(){if(0===this.accountProfileMap.size){for(var e=this._getCachedProfiles(),t=Date.now(),n=0,o=e.length;n<o;n++)t-e[n].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[n].userID,e[n]);ie.log("ProfileHandler._fillMap from cache, map.size="+this.accountProfileMap.size)}}},{key:"_updateMap",value:function(e,t){var n,o=Date.now();return this._containsAccount(e)?(n=this._getProfileFromMap(e),t.profileCustomField&&Ne(n.profileCustomField,t.profileCustomField),Ie(n,t,["profileCustomField"]),n.lastUpdatedTime=o):(n=new Ki(t),(this.userController.isMyFriend(e)||e===this.userController.getMyAccount())&&(n.lastUpdatedTime=o,this.accountProfileMap.set(e,n))),this._flushMap(e===this.userController.getMyAccount()),n}},{key:"_flushMap",value:function(e){var t=C(this.accountProfileMap.values()),n=this.userController.tim.storage;ie.debug("ProfileHandler._flushMap length=".concat(t.length," flushAtOnce=").concat(e)),n.setItem(this.TAG,t,e)}},{key:"_containsAccount",value:function(e){return this.accountProfileMap.has(e)}},{key:"_getProfileFromMap",value:function(e){return this.accountProfileMap.get(e)}},{key:"_getCachedProfiles",value:function(){var e=this.userController.tim.storage.getItem(this.TAG);return Ke(e)?[]:e}},{key:"onConversationsProfileUpdated",value:function(e){for(var t,n,o,r=[],i=0,s=e.length;i<s;i++)n=(t=e[i]).userID,this.userController.isMyFriend(n)&&(this._containsAccount(n)?(o=this._getProfileFromMap(n),Ie(o,t)>0&&r.push(n)):r.push(t.userID));0!==r.length&&(ie.info("ProfileHandler.onConversationsProfileUpdated toAccount:",r),this.getUserProfile({userIDList:r}))}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),t}(),Bi=function(){function e(t){i(this,e),this.options=t?t.options:{enablePointer:!0},this.pointsList={},this.reportText={},this.maxNameLen=0,this.gapChar="-",this.log=console.log,this.currentTask=""}return a(e,[{key:"newTask",value:function(e){!1!==this.options.enablePointer&&(e||(e=["task",this._timeFormat()].join("-")),this.pointsList[e]=[],this.currentTask=e,console.log("Pointer new Task : ".concat(this.currentTask)))}},{key:"deleteTask",value:function(e){!1!==this.options.enablePointer&&(e||(e=this.currentTask),this.pointsList[e].length=0,delete this.pointsList[e])}},{key:"dot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if(!1!==this.options.enablePointer){t=t||this.currentTask;var n=+new Date;this.maxNameLen=this.maxNameLen<e.length?e.length:this.maxNameLen,this.flen=this.maxNameLen+10,this.pointsList[t].push({pointerName:e,time:n})}}},{key:"_analisys",value:function(e){if(!1!==this.options.enablePointer){e=e||this.currentTask;for(var t=this.pointsList[e],n=t.length,o=[],r=[],i=0;i<n;i++)0!==i&&(r=this._analisysTowPoints(t[i-1],t[i]),o.push(r.join("")));return r=this._analisysTowPoints(t[0],t[n-1],!0),o.push(r.join("")),o.join("")}}},{key:"_analisysTowPoints",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!1!==this.options.enablePointer){var o=this.flen,r=t.time-e.time,i=r.toString(),s=e.pointerName+this.gapChar.repeat(o-e.pointerName.length),a=t.pointerName+this.gapChar.repeat(o-t.pointerName.length),u=this.gapChar.repeat(4-i.length)+i,c=n?["%c",s,a,u,"ms\n%c"]:[s,a,u,"ms\n"];return c}}},{key:"report",value:function(e){if(!1!==this.options.enablePointer){e=e||this.currentTask;var t=this._analisys(e);this.pointsList=[];var n=this._timeFormat(),o="Pointer[".concat(e,"(").concat(n,")]"),r=4*this.maxNameLen,i=(r-o.length)/2;console.log(["-".repeat(i),o,"-".repeat(i)].join("")),console.log("%c"+t,"color:#66a","color:red","color:#66a"),console.log("-".repeat(r))}}},{key:"_timeFormat",value:function(){var e=new Date,t=this.zeroFix(e.getMonth()+1,2),n=this.zeroFix(e.getDate(),2);return"".concat(t,"-").concat(n," ").concat(e.getHours(),":").concat(e.getSeconds(),":").concat(e.getMinutes(),"~").concat(e.getMilliseconds())}},{key:"zeroFix",value:function(e,t){return("000000000"+e).slice(-t)}},{key:"reportAll",value:function(){if(!1!==this.options.enablePointer)for(var e in this.pointsList)Object.prototype.hasOwnProperty.call(this.pointsList,e)&&this.eport(e)}}]),e}(),ji=function e(t,n){i(this,e),this.userID=t;var o={};if(o.userID=t,!Ke(n))for(var r=0,s=n.length;r<s;r++)switch(n[r].tag){case gt.NICK:o.nick=n[r].value;break;case gt.GENDER:o.gender=n[r].value;break;case gt.BIRTHDAY:o.birthday=n[r].value;break;case gt.LOCATION:o.location=n[r].value;break;case gt.SELFSIGNATURE:o.selfSignature=n[r].value;break;case gt.ALLOWTYPE:o.allowType=n[r].value;break;case gt.LANGUAGE:o.language=n[r].value;break;case gt.AVATAR:o.avatar=n[r].value;break;case gt.MESSAGESETTINGS:o.messageSettings=n[r].value;break;case gt.ADMINFORBIDTYPE:o.adminForbidType=n[r].value;break;case gt.LEVEL:o.level=n[r].value;break;case gt.ROLE:o.role=n[r].value;break;default:ie.debug("snsProfileItem unkown tag->",n[r].tag)}this.profile=new Ki(o)},$i=function(){function e(t){i(this,e),this.userController=t,this.TAG="friend",this.Actions={G:"get",D:"delete"},this.friends=new Map,this.pointer=new Bi}return a(e,[{key:"isMyFriend",value:function(e){var t=this.friends.has(e);return t||ie.debug("FriendHandler.isMyFriend "+e+" is not my friend"),t}},{key:"_transformFriendList",value:function(e){if(!Ke(e)&&!Ke(e.infoItem)){ie.info("FriendHandler._transformFriendList friendNum="+e.friendNum);for(var t,n,o=e.infoItem,r=0,i=o.length;r<i;r++)n=o[r].infoAccount,t=new ji(n,o[r].snsProfileItem),this.friends.set(n,t)}}},{key:"_friends2map",value:function(e){var t=new Map;for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.set(n,e[n]);return t}},{key:"getFriendList",value:function(){var e=this,t={};t.fromAccount=this.userController.getMyAccount(),ie.info("FriendHandler.getFriendList myAccount="+t.fromAccount);var n=this.userController.generateConfig(this.TAG,this.Actions.G,t);return this.userController.request(n).then((function(t){ie.info("FriendHandler.getFriendList ok"),e._transformFriendList(t.data);var n=C(e.friends.values());return lr(n)})).catch((function(e){return ie.error("FriendHandler.getFriendList error:",e),pr(e)}))}},{key:"deleteFriend",value:function(e){if(!Array.isArray(e.toAccount))return ie.error("FriendHandler.deleteFriend options.toAccount 必需是数组"),pr({code:Ot.DEL_FRIEND_INVALID_PARAM,message:yn});e.toAccount.length>1e3&&(ie.warn("FriendHandler.deleteFriend 删除好友人数不能超过1000人"),e.toAccount.length=1e3);var t=this.userController.generateConfig(this.TAG,this.Actions.D,e);return this.userController.request(t).then((function(e){return ie.info("FriendHandler.deleteFriend ok"),lr()})).catch((function(e){return ie.error("FriendHandler.deleteFriend error:",e),pr(e)}))}}]),e}(),Yi=function e(t){i(this,e),Ke||(this.userID=t.userID||"",this.timeStamp=t.timeStamp||0)},Wi=function(){function t(e){i(this,t),this.userController=e,this.TAG="blacklist",this.Actions={G:"get",C:"create",D:"delete"},this.blacklistMap=new Map,this.startIndex=0,this.maxLimited=100,this.curruentSequence=0}return a(t,[{key:"getBlacklist",value:function(){var e=this,t={};t.fromAccount=this.userController.getMyAccount(),t.maxLimited=this.maxLimited,t.startIndex=0,t.lastSequence=this.curruentSequence;var n=new kr(Oi),o=this.userController.generateConfig(this.TAG,this.Actions.G,t);return this.userController.request(o).then((function(t){var o=Ke(t.data.blackListItem)?0:t.data.blackListItem.length;return n.setNetworkType(e.userController.getNetworkType()).setText(o).setEnd(),ie.info("BlacklistHandler.getBlacklist ok"),e.curruentSequence=t.data.curruentSequence,e._handleResponse(t.data.blackListItem,!0),e._onBlacklistUpdated()})).catch((function(t){return e.userController.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];n.setError(t,r,i).setEnd()})),ie.error("BlacklistHandler.getBlacklist error:",t),pr(t)}))}},{key:"addBlacklist",value:function(e){var t=this,n=new kr(Ri);if(!pe(e.userIDList))return n.setCode(Ot.ADD_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.addBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(),ie.error("BlacklistHandler.addBlacklist options.userIDList 必需是数组"),pr({code:Ot.ADD_BLACKLIST_INVALID_PARAM,message:Cn});var o=this.userController.tim.loginInfo.identifier;if(1===e.userIDList.length&&e.userIDList[0]===o)return n.setCode(Ot.CANNOT_ADD_SELF_TO_BLACKLIST).setMessage(Tn).setNetworkType(this.userController.getNetworkType()).setEnd(),ie.error("BlacklistHandler.addBlacklist 不能把自己拉黑"),pr({code:Ot.CANNOT_ADD_SELF_TO_BLACKLIST,message:Tn});e.userIDList.includes(o)&&(e.userIDList=e.userIDList.filter((function(e){return e!==o})),ie.warn("BlacklistHandler.addBlacklist 不能把自己拉黑,已过滤")),e.fromAccount=this.userController.getMyAccount(),e.toAccount=e.userIDList;var r=this.userController.generateConfig(this.TAG,this.Actions.C,e);return this.userController.request(r).then((function(o){return n.setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setEnd(),ie.info("BlacklistHandler.addBlacklist ok"),t._handleResponse(o.data.resultItem,!0),t._onBlacklistUpdated()})).catch((function(e){return t.userController.probeNetwork().then((function(t){var o=M(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),ie.error("BlacklistHandler.addBlacklist error:",e),pr(e)}))}},{key:"_handleResponse",value:function(e,t){if(!Ke(e))for(var n,o,r,i=0,s=e.length;i<s;i++)o=e[i].to,r=e[i].resultCode,(ge(r)||0===r)&&(t?((n=this.blacklistMap.has(o)?this.blacklistMap.get(o):new Yi).userID=o,!Ke(e[i].addBlackTimeStamp)&&(n.timeStamp=e[i].addBlackTimeStamp),this.blacklistMap.set(o,n)):this.blacklistMap.has(o)&&(n=this.blacklistMap.get(o),this.blacklistMap.delete(o)));ie.log("BlacklistHandler._handleResponse total="+this.blacklistMap.size+" bAdd="+t)}},{key:"deleteBlacklist",value:function(e){var t=this,n=new kr(Ai);if(!pe(e.userIDList))return n.setCode(Ot.DEL_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(),ie.error("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组"),pr({code:Ot.DEL_BLACKLIST_INVALID_PARAM,message:En});e.fromAccount=this.userController.getMyAccount(),e.toAccount=e.userIDList;var o=this.userController.generateConfig(this.TAG,this.Actions.D,e);return this.userController.request(o).then((function(o){return n.setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setEnd(),ie.info("BlacklistHandler.deleteBlacklist ok"),t._handleResponse(o.data.resultItem,!1),t._onBlacklistUpdated()})).catch((function(e){return t.userController.probeNetwork().then((function(t){var o=M(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),ie.error("BlacklistHandler.deleteBlacklist error:",e),pr(e)}))}},{key:"_onBlacklistUpdated",value:function(){var t=C(this.blacklistMap.keys());return this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,t),lr(t)}},{key:"handleBlackListDelAccount",value:function(t){for(var n,o=[],r=0,i=t.length;r<i;r++)n=t[r],this.blacklistMap.has(n)&&(this.blacklistMap.delete(n),o.push(n));o.length>0&&(ie.log("BlacklistHandler.handleBlackListDelAccount delCount="+o.length+" : "+o.join(",")),this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,C(this.blacklistMap.keys())))}},{key:"handleBlackListAddAccount",value:function(t){for(var n,o=[],r=0,i=t.length;r<i;r++)n=t[r],this.blacklistMap.has(n)||(this.blacklistMap.set(n,new Yi({userID:n})),o.push(n));o.length>0&&(ie.log("BlacklistHandler.handleBlackListAddAccount addCount="+o.length+" : "+o.join(",")),this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,C(this.blacklistMap.keys())))}},{key:"reset",value:function(){this.blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.curruentSequence=0}}]),t}(),zi=function(){function e(t){i(this,e),this.userController=t,this.TAG="applyC2C",this.Actions={C:"create",G:"get",D:"delete",U:"update"}}return a(e,[{key:"applyAddFriend",value:function(e){var t=this,n=this.userController.generateConfig(this.TAG,this.Actions.C,e),o=this.userController.request(n);return o.then((function(e){t.userController.isActionSuccessful("applyAddFriend",t.Actions.C,e)})).catch((function(e){})),o}},{key:"getPendency",value:function(e){var t=this,n=this.userController.generateConfig(this.TAG,this.Actions.G,e),o=this.userController.request(n);return o.then((function(e){t.userController.isActionSuccessful("getPendency",t.Actions.G,e)})).catch((function(e){})),o}},{key:"deletePendency",value:function(e){var t=this,n=this.userController.generateConfig(this.TAG,this.Actions.D,e),o=this.userController.request(n);return o.then((function(e){t.userController.isActionSuccessful("deletePendency",t.Actions.D,e)})).catch((function(e){})),o}},{key:"replyPendency",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.userController.generateConfig(this.TAG,this.Actions.U,t),o=this.userController.request(n);return o.then((function(t){e.userController.isActionSuccessful("replyPendency",e.Actions.U,t)})).catch((function(e){})),o}}]),e}(),Ji=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e)).profileHandler=new Hi(v(o)),o.friendHandler=new $i(v(o)),o.blacklistHandler=new Wi(v(o)),o.applyC2CHandler=new zi(v(o)),o._initializeListener(),o}return a(n,[{key:"_initializeListener",value:function(e){var t=this.tim.innerEmitter;t.on(lo,this.onContextUpdated,this),t.on(Lo,this.onProfileModified,this),t.on(No,this.onNewFriendMessages,this),t.on(jo,this.onConversationsProfileUpdated,this)}},{key:"onContextUpdated",value:function(e){var t=this.tim.context;!1!=!!t.a2Key&&!1!=!!t.tinyID&&(this.profileHandler.getMyProfile(),this.friendHandler.getFriendList(),this.blacklistHandler.getBlacklist())}},{key:"onGotMyProfile",value:function(){this.triggerReady()}},{key:"onProfileModified",value:function(e){this.profileHandler.onProfileModified(e)}},{key:"onNewFriendMessages",value:function(e){ie.debug("onNewFriendMessages",JSON.stringify(e.data)),Ke(e.data.blackListDelAccount)||this.blacklistHandler.handleBlackListDelAccount(e.data.blackListDelAccount),Ke(e.data.blackListAddAccount)||this.blacklistHandler.handleBlackListAddAccount(e.data.blackListAddAccount)}},{key:"onConversationsProfileUpdated",value:function(e){this.profileHandler.onConversationsProfileUpdated(e.data)}},{key:"getMyAccount",value:function(){return this.tim.context.identifier}},{key:"isMyFriend",value:function(e){return this.friendHandler.isMyFriend(e)}},{key:"generateConfig",value:function(e,t,n){return{name:e,action:t,param:n}}},{key:"getMyProfile",value:function(){return this.profileHandler.getMyProfile()}},{key:"getUserProfile",value:function(e){return this.profileHandler.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this.profileHandler.updateMyProfile(e)}},{key:"getFriendList",value:function(){return this.friendHandler.getFriendList()}},{key:"deleteFriend",value:function(e){return this.friendHandler.deleteFriend(e)}},{key:"getBlacklist",value:function(){return this.blacklistHandler.getBlacklist()}},{key:"addBlacklist",value:function(e){return this.blacklistHandler.addBlacklist(e)}},{key:"deleteBlacklist",value:function(e){return this.blacklistHandler.deleteBlacklist(e)}},{key:"applyAddFriend",value:function(e){return this.applyC2CHandler.applyAddFriend(e)}},{key:"getPendency",value:function(e){return this.applyC2CHandler.getPendency(e)}},{key:"deletePendency",value:function(e){return this.applyC2CHandler.deletePendency(e)}},{key:"replyPendency",value:function(e){return this.applyC2CHandler.replyPendency(e)}},{key:"reset",value:function(){ie.info("UserController.reset"),this.resetReady(),this.profileHandler.reset(),this.blacklistHandler.reset(),this.checkTimes=0}}]),n}(rr),Xi=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers"],Qi=function(){function e(t){i(this,e),this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime="",this.infoSequence="",this.lastInfoTime="",this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:""},this.lastMessage={lastTime:"",lastSequence:"",fromAccount:"",messageForShow:""},this.nextMessageSeq="",this.memberNum="",this.memberCount="",this.maxMemberNum="",this.maxMemberCount="",this.joinOption="",this.groupCustomField=[],this.muteAllMembers=void 0,this._initGroup(t)}return a(e,[{key:"_initGroup",value:function(e){for(var t in e)Xi.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),this[t]=e[t]):this.updateSelfInfo(e[t]))}},{key:"updateGroup",value:function(e){e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),ge(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField&&Ne(this.groupCustomField,e.groupCustomField),ge(e.memberNum)||(this.memberCount=e.memberNum),ge(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),Ie(this,e,["members","errorCode","lastMsgTime","groupCustomField"])}},{key:"updateSelfInfo",value:function(e){var t=e.nameCard,n=e.joinTime,o=e.role,r=e.messageRemindType;Ie(this.selfInfo,{nameCard:t,joinTime:n,role:o,messageRemindType:r},[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}},{key:"memberNum",set:function(e){},get:function(){return ie.warn("!!!v2.8.0起弃用memberNum,请使用 memberCount"),this.memberCount}},{key:"maxMemberNum",set:function(e){},get:function(){return ie.warn("!!!v2.8.0起弃用maxMemberNum,请使用 maxMemberCount"),this.maxMemberCount}}]),e}(),Zi=function(e,n){if(ge(n))return"";switch(e){case t.MSG_TEXT:return n.text;case t.MSG_IMAGE:return"[图片]";case t.MSG_GEO:return"[位置]";case t.MSG_AUDIO:return"[语音]";case t.MSG_VIDEO:return"[视频]";case t.MSG_FILE:return"[文件]";case t.MSG_CUSTOM:return"[自定义消息]";case t.MSG_GRP_TIP:return"[群提示消息]";case t.MSG_GRP_SYS_NOTICE:return"[群系统通知]";case t.MSG_FACE:return"[动画表情]";default:return""}},es=function(e){return ge(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1}:e instanceof Kn?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Zi(e.type,e.payload),payload:e.payload||null,type:e.type||null,isRevoked:!1}:l(l({},e),{},{isRevoked:!1,messageForShow:Zi(e.type,e.payload)})},ts=function(){function e(t){i(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=es(t.lastMessage),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this._initProfile(t)}return a(e,[{key:"_initProfile",value:function(e){var n=this;Object.keys(e).forEach((function(t){switch(t){case"userProfile":n.userProfile=e.userProfile;break;case"groupProfile":n.groupProfile=e.groupProfile}})),ge(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new Ki({userID:e.conversationID.replace("C2C","")}):ge(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new Qi({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e,n){ge(e)||(Pe(this.subType)||Ge(this.subType)?this.unreadCount=0:n&&this.type===t.CONV_GROUP?this.unreadCount=e:this.unreadCount=this.unreadCount+e)}},{key:"updateLastMessage",value:function(e){this.lastMessage=es(e)}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var n=e.sequence,o=e.time;return this.type===t.CONV_C2C&&n===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&n===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function(e){this.lastMessage.isRevoked=e}},{key:"toAccount",get:function(){return this.conversationID.replace("C2C","").replace("GROUP","")}},{key:"subType",get:function(){return this.groupProfile?this.groupProfile.type:""}}]),e}(),ns=function(n){p(r,n);var o=I(r);function r(e){var t;return i(this,r),(t=o.call(this,e)).pagingStatus=ze.NOT_START,t.pagingTimeStamp=0,t.conversationMap=new Map,t.tempGroupList=[],t._initListeners(),t}return a(r,[{key:"hasLocalConversationMap",value:function(){return this.conversationMap.size>0}},{key:"_createLocalConversation",value:function(e){return this.conversationMap.has(e)?this.conversationMap.get(e):(ie.log("ConversationController._createLocalConversation conversationID:".concat(e)),new ts({conversationID:e,type:e.slice(0,3)===t.CONV_C2C?t.CONV_C2C:t.CONV_GROUP}))}},{key:"hasLocalConversation",value:function(e){return this.conversationMap.has(e)}},{key:"getConversationList",value:function(){var e=this;ie.log("ConversationController.getConversationList."),this.pagingStatus===ze.REJECTED&&(ie.log("ConversationController.getConversationList. continue to sync conversationList"),this._syncConversationList());var t=new kr($r);return this.request({name:"conversation",action:"query"}).then((function(n){var o=n.data.conversations,r=void 0===o?[]:o,i=e._getConversationOptions(r);return e._updateLocalConversationList(i,!0),e._setStorageConversationList(),e._handleC2CPeerReadTime(),t.setText(r.length).setNetworkType(e.getNetworkType()).setEnd(),ie.log("ConversationController.getConversationList ok."),lr({conversationList:e.getLocalConversationList()})})).catch((function(n){return e.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd()})),ie.error("ConversationController.getConversationList error:",n),pr(n)}))}},{key:"_syncConversationList",value:function(){var e=this,t=new kr(Jr);return this.pagingStatus===ze.NOT_START&&this.conversationMap.clear(),this._autoPagingSyncConversationList().then((function(n){return e.pagingStatus=ze.RESOLVED,e._setStorageConversationList(),e._handleC2CPeerReadTime(),t.setText("".concat(e.conversationMap.size)).setNetworkType(e.getNetworkType()).setEnd(),n})).catch((function(n){return e.pagingStatus=ze.REJECTED,t.setText(e.pagingTimeStamp),e.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd()})),pr(n)}))}},{key:"_autoPagingSyncConversationList",value:function(){var e=this;return this.pagingStatus=ze.PENDING,this.request({name:"conversation",action:"pagingQuery",param:{fromAccount:this.tim.context.identifier,timeStamp:this.pagingTimeStamp,orderType:1}}).then((function(t){var n=t.data,o=n.completeFlag,r=n.conversations,i=void 0===r?[]:r,s=n.timeStamp;if(ie.log("ConversationController._autoPagingSyncConversationList completeFlag=".concat(o," nums=").concat(i.length)),i.length>0){var a=e._getConversationOptions(i);e._updateLocalConversationList(a,!0)}return e._isReady?e._emitConversationUpdate():e.triggerReady(),e.pagingTimeStamp=s,1!==o?e._autoPagingSyncConversationList():lr()}))}},{key:"_handleC2CPeerReadTime",value:function(){var e,n=this.tim.messageController,o=D(this.conversationMap);try{for(o.s();!(e=o.n()).done;){var r=M(e.value,2),i=r[0],s=r[1];s.type===t.CONV_C2C&&(ie.debug("ConversationController._handleC2CPeerReadTime",i,s.peerReadTime),n.recordPeerReadTime(i,s.peerReadTime))}}catch(a){o.e(a)}finally{o.f()}}},{key:"getConversationProfile",value:function(e){var n=this,o=this.conversationMap.has(e)?this.conversationMap.get(e):this._createLocalConversation(e);if(o._isInfoCompleted||o.type===t.CONV_SYSTEM)return lr({conversation:o});var r=new kr(Yr);return ie.log("ConversationController.getConversationProfile. conversationID:".concat(e," lastMessage:"),o.lastMessage),this._updateUserOrGroupProfileCompletely(o).then((function(t){return r.setNetworkType(n.getNetworkType()).setText("conversationID=".concat(e," unreadCount=").concat(t.data.conversation.unreadCount)).setEnd(),ie.log("ConversationController.getConversationProfile ok. conversationID:",e),t})).catch((function(t){return n.probeNetwork().then((function(n){var o=M(n,2),i=o[0],s=o[1];r.setError(t,i,s).setText("conversationID=".concat(e)).setEnd()})),ie.error("ConversationController.getConversationProfile error:",t),pr(t)}))}},{key:"deleteConversation",value:function(e){var n=this,o={};if(!this.conversationMap.has(e)){var r=new kt({code:Ot.CONVERSATION_NOT_FOUND,message:tn});return pr(r)}switch(this.conversationMap.get(e).type){case t.CONV_C2C:o.type=1,o.toAccount=e.replace(t.CONV_C2C,"");break;case t.CONV_GROUP:o.type=2,o.toGroupID=e.replace(t.CONV_GROUP,"");break;case t.CONV_SYSTEM:return this.tim.groupController.deleteGroupSystemNotice({messageList:this.tim.messageController.getLocalMessageList(e)}),this.deleteLocalConversation(e),lr({conversationID:e});default:var i=new kt({code:Ot.CONVERSATION_UN_RECORDED_TYPE,message:on});return pr(i)}var s=new kr(Wr);return s.setText("conversationID=".concat(e)),ie.log("ConversationController.deleteConversation. conversationID=".concat(e)),this.tim.setMessageRead({conversationID:e}).then((function(){return n.request({name:"conversation",action:"delete",param:o})})).then((function(){return s.setNetworkType(n.getNetworkType()).setEnd(),ie.log("ConversationController.deleteConversation ok."),n.deleteLocalConversation(e),lr({conversationID:e})})).catch((function(e){return n.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];s.setError(e,o,r).setEnd()})),ie.error("ConversationController.deleteConversation error:",e),pr(e)}))}},{key:"getLocalConversationList",value:function(){return C(this.conversationMap.values())}},{key:"getLocalConversation",value:function(e){return this.conversationMap.get(e)}},{key:"_initLocalConversationList",value:function(){var e=new kr(zr);ie.time(Tr),ie.log("ConversationController._initLocalConversationList.");var t=this._getStorageConversationList();if(t){for(var n=t.length,o=0;o<n;o++)this.conversationMap.set(t[o].conversationID,new ts(t[o]));this._emitConversationUpdate(!0,!1),e.setNetworkType(this.getNetworkType()).setText(n).setEnd()}else e.setNetworkType(this.getNetworkType()).setText(0).setEnd();this._syncConversationList()}},{key:"_getStorageConversationList",value:function(){return this.tim.storage.getItem("conversationMap")}},{key:"_setStorageConversationList",value:function(){var e=this.getLocalConversationList().slice(0,20).map((function(e){return{conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile}}));this.tim.storage.setItem("conversationMap",e)}},{key:"_initListeners",value:function(){var e=this;this.tim.innerEmitter.once(lo,this._initLocalConversationList,this),this.tim.innerEmitter.on(mo,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(fo,this._handleSyncMessages,this),this.tim.innerEmitter.on(_o,this._handleSyncMessages,this),this.tim.innerEmitter.on(vo,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(yo,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(Io,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(qo,this._onGroupListUpdated,this),this.tim.innerEmitter.on(Yo,this._updateConversationUserProfile,this),this.tim.innerEmitter.on(Mo,this._onMessageRevoked,this),this.ready((function(){e.tempGroupList.length>0&&(e._updateConversationGroupProfile(e.tempGroupList),e.tempGroupList.length=0)}))}},{key:"_onGroupListUpdated",value:function(e){this._updateConversationGroupProfile(e.data)}},{key:"_updateConversationGroupProfile",value:function(e){var t=this;pe(e)&&0===e.length||(this.hasLocalConversationMap()?(e.forEach((function(e){var n="GROUP".concat(e.groupID);if(t.conversationMap.has(n)){var o=t.conversationMap.get(n);o.groupProfile=e,o.lastMessage.lastSequence<e.nextMessageSeq&&(o.lastMessage.lastSequence=e.nextMessageSeq-1),o.subType||(o.subType=e.type)}})),this._emitConversationUpdate(!0,!1)):this.tempGroupList=e)}},{key:"_updateConversationUserProfile",value:function(e){var t=this;e.data.forEach((function(e){var n="C2C".concat(e.userID);t.conversationMap.has(n)&&(t.conversationMap.get(n).userProfile=e)})),this._emitConversationUpdate(!0,!1)}},{key:"_onMessageRevoked",value:function(e){var t=this,n=e.data;if(0!==n.length){var o=null,r=!1;n.forEach((function(e){(o=t.conversationMap.get(e.conversationID))&&o.isLastMessageRevoked(e)&&(r=!0,o.setLastMessageRevoked(!0))})),r&&this._emitConversationUpdate(!0,!1)}}},{key:"_handleSyncMessages",value:function(e){this._onSendOrReceiveMessage(e,!0)}},{key:"_onSendOrReceiveMessage",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=e.data.eventDataList;this._isReady?0!==o.length&&(this._getPeerReadTime(o),this._updateLocalConversationList(o,!1,n),this._setStorageConversationList(),this._emitConversationUpdate()):this.ready((function(){t._onSendOrReceiveMessage(e,n)}))}},{key:"_getPeerReadTime",value:function(e){var n=this,o=[];e.forEach((function(e){n.conversationMap.has(e.conversationID)||e.type!==t.CONV_C2C||o.push(e.conversationID.replace(t.CONV_C2C,""))})),o.length>0&&(ie.debug("ConversationController._getPeerReadTime userIDList:".concat(o)),this.tim.messageController.getPeerReadTime(o))}},{key:"_updateLocalConversationList",value:function(e,t,n){var o;o=this._updateTempConversations(e,t,n),this.conversationMap=new Map(this._sortConversations([].concat(C(o.conversations),C(this.conversationMap)))),t||this._updateUserOrGroupProfile(o.newerConversations)}},{key:"_updateTempConversations",value:function(e,n,o){for(var r=[],i=[],s=0,a=e.length;s<a;s++){var u=new ts(e[s]),c=this.conversationMap.get(u.conversationID);if(this.conversationMap.has(u.conversationID)){var l=["unreadCount","allowType","adminForbidType","payload"];o&&l.push("lastMessage"),Ie(c,u,l,[null,void 0,"",0,NaN]),c.updateUnreadCount(u.unreadCount,n),o||(c.lastMessage.payload=e[s].lastMessage.payload),this.conversationMap.delete(c.conversationID),r.push([c.conversationID,c])}else{if(u.type===t.CONV_GROUP){var p=u.groupProfile.groupID,g=this.tim.groupController.getLocalGroupProfile(p);g&&(u.groupProfile=g,u.updateUnreadCount(0))}i.push(u),r.push([u.conversationID,u])}}return{conversations:r,newerConversations:i}}},{key:"_sortConversations",value:function(e){return e.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime}))}},{key:"_updateUserOrGroupProfile",value:function(e){var n=this;if(0!==e.length){var o=[],r=[];e.forEach((function(e){if(e.type===t.CONV_C2C)o.push(e.toAccount);else if(e.type===t.CONV_GROUP){var i=e.toAccount;n.tim.groupController.hasLocalGroup(i)?e.groupProfile=n.tim.groupController.getLocalGroupProfile(i):r.push(i)}})),o.length>0&&this.tim.getUserProfile({userIDList:o}).then((function(e){var t=e.data;pe(t)?t.forEach((function(e){n.conversationMap.get("C2C".concat(e.userID)).userProfile=e})):n.conversationMap.get("C2C".concat(t.userID)).userProfile=t})),r.length>0&&this.tim.groupController.getGroupProfileAdvance({groupIDList:r,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var t="GROUP".concat(e.groupID);if(n.conversationMap.has(t)){var o=n.conversationMap.get(t);Ie(o.groupProfile,e,[],[null,void 0,"",0,NaN]),!o.subType&&e.type&&(o.subType=e.type)}}))}))}}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var n=this;return e.type===t.CONV_C2C?this.tim.getUserProfile({userIDList:[e.toAccount]}).then((function(t){var o=t.data;return 0===o.length?pr(new kt({code:Ot.USER_OR_GROUP_NOT_FOUND,message:nn})):(e.userProfile=o[0],e._isInfoCompleted=!0,n._unshiftConversation(e),lr({conversation:e}))})):this.tim.getGroupProfile({groupID:e.toAccount}).then((function(t){return e.groupProfile=t.data.group,e._isInfoCompleted=!0,n._unshiftConversation(e),lr({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof ts&&!this.conversationMap.has(e.conversationID)&&(this.conversationMap=new Map([[e.conversationID,e]].concat(C(this.conversationMap))),this._setStorageConversationList(),this._emitConversationUpdate(!0,!1))}},{key:"deleteLocalConversation",value:function(e){this.conversationMap.delete(e),this._setStorageConversationList(),this.emitInnerEvent($o,e),this._emitConversationUpdate(!0,!1)}},{key:"_getConversationOptions",value:function(e){var t=[],n=e.filter((function(e){var t=e.lastMsg;return le(t)})).map((function(e){if(1===e.type){var n={userID:e.userID,nick:e.c2CNick,avatar:e.c2CImage};return t.push(n),{conversationID:"C2C".concat(e.userID),type:"C2C",lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null},userProfile:new Ki(n),peerReadTime:e.c2cPeerReadTime}}return{conversationID:"GROUP".concat(e.groupID),type:"GROUP",lastMessage:{lastTime:e.time,lastSequence:e.messageReadSeq+e.unreadCount,fromAccount:e.msgGroupFromAccount,messageForShow:e.messageShow,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null},groupProfile:new Qi({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0}}));return t.length>0&&this.emitInnerEvent(jo,t),n}},{key:"_emitConversationUpdate",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=C(this.conversationMap.values());n&&this.emitInnerEvent(Bo,o),t&&this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED,o)}},{key:"_conversationMapTreeShaking",value:function(e){var n=this,o=new Map(C(this.conversationMap));e.forEach((function(e){return o.delete(e.conversationID)})),o.has(t.CONV_SYSTEM)&&o.delete(t.CONV_SYSTEM);var r=this.tim.groupController.getJoinedAVChatRoom();r&&r.forEach((function(e){o.delete("".concat(t.CONV_GROUP).concat(e))})),C(o.keys()).forEach((function(e){return n.conversationMap.delete(e)}))}},{key:"reset",value:function(){this.pagingStatus=ze.NOT_START,this.pagingTimeStamp=0,this.conversationMap.clear(),this.resetReady(),this.tim.innerEmitter.once(lo,this._initLocalConversationList,this)}}]),r}(rr),os=function(){function e(t){if(i(this,e),void 0===t)throw new kt({code:Ot.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,message:Ut});if(void 0===t.tim)throw new kt({code:Ot.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,message:"".concat(Ut,".tim")});this.list=new Map,this.tim=t.tim,this._initializeOptions(t)}return a(e,[{key:"getLocalOldestMessageByConversationID",value:function(e){if(!e)return null;if(!this.list.has(e))return null;var t=this.list.get(e).values();return t?t.next().value:null}},{key:"_initializeOptions",value:function(e){this.options={};var t={memory:{maxDatasPerKey:100,maxBytesPerData:256,maxKeys:0},cache:{maxDatasPerKey:10,maxBytesPerData:256,maxKeys:0}};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(void 0===e[n]){this.options[n]=t[n];continue}var o=t[n];for(var r in o)if(Object.prototype.hasOwnProperty.call(o,r)){if(void 0===e[n][r]){this.options[n][r]=o[r];continue}this.options[n][r]=e[n][r]}}}},{key:"pushIn",value:function(e){var t=e.conversationID,n=e.ID,o=!0;return this.list.has(t)||this.list.set(t,new Map),this.list.has(t)&&this.list.get(t).has(n)?o=!1:this.list.get(t).set(n,e),o}},{key:"unshift",value:function(e){pe(e)?e.length>0&&this._unshiftMultipleMessages(e):this._unshiftSingleMessage(e)}},{key:"_unshiftSingleMessage",value:function(e){var t=e.conversationID,n=e.ID;if(!this.list.has(t))return this.list.set(t,new Map),void this.list.get(t).set(n,e);var o=Array.from(this.list.get(t));o.unshift([n,e]),this.list.set(t,new Map(o))}},{key:"_unshiftMultipleMessages",value:function(e){for(var t=e.length,n=[],o=e[0].conversationID,r=this.list.has(o)?Array.from(this.list.get(o)):[],i=0;i<t;i++)n.push([e[i].ID,e[i]]);this.list.set(o,new Map(n.concat(r)))}},{key:"remove",value:function(e){var t=e.conversationID,n=e.ID;this.list.has(t)&&this.list.get(t).delete(n)}},{key:"revoke",value:function(e,t,n){if(ie.debug("revoke message",e,t,n),this.list.has(e)){var o,r=D(this.list.get(e));try{for(r.s();!(o=r.n()).done;){var i=M(o.value,2)[1];if(i.sequence===t&&!i.isRevoked&&(ge(n)||i.random===n))return i.isRevoked=!0,i}}catch(s){r.e(s)}finally{r.f()}}return null}},{key:"removeByConversationID",value:function(e){this.list.has(e)&&this.list.delete(e)}},{key:"updateMessageIsPeerReadProperty",value:function(e,t){var n=[];if(this.list.has(e)){var o,r=D(this.list.get(e));try{for(r.s();!(o=r.n()).done;){var i=M(o.value,2)[1];i.time<=t&&!i.isPeerRead&&"out"===i.flow&&(i.isPeerRead=!0,n.push(i))}}catch(s){r.e(s)}finally{r.f()}ie.log("MessagesList.updateMessageIsPeerReadProperty conversationID=".concat(e," peerReadTime=").concat(t," count=").concat(n.length))}return n}},{key:"hasLocalMessageList",value:function(e){return this.list.has(e)}},{key:"getLocalMessageList",value:function(e){return this.hasLocalMessageList(e)?C(this.list.get(e).values()):[]}},{key:"hasLocalMessage",value:function(e,t){return!!this.hasLocalMessageList(e)&&this.list.get(e).has(t)}},{key:"getLocalMessage",value:function(e,t){return this.hasLocalMessage(e,t)?this.list.get(e).get(t):null}},{key:"reset",value:function(){this.list.clear()}}]),e}(),rs=function(){function e(t){i(this,e),this.tim=t}return a(e,[{key:"setMessageRead",value:function(e){var n=e.conversationID,o=e.messageID,r=this.tim.conversationController.getLocalConversation(n);if(ie.log("ReadReportHandler.setMessageRead conversationID=".concat(n," unreadCount=").concat(r?r.unreadCount:0)),!r||0===r.unreadCount)return lr();var i=o?this.tim.messageController.getLocalMessage(n,o):null;switch(r.type){case t.CONV_C2C:return this._setC2CMessageRead({conversationID:n,lastMessageTime:i?i.time:r.lastMessage.lastTime});case t.CONV_GROUP:return this._setGroupMessageRead({conversationID:n,lastMessageSeq:i?i.sequence:r.lastMessage.lastSequence});case t.CONV_SYSTEM:return r.unreadCount=0,lr();default:return lr()}}},{key:"_setC2CMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageTime;ie.log("ReadReportHandler._setC2CMessageRead conversationID=".concat(n," lastMessageTime=").concat(o)),ae(o)||ie.warn("ReadReportHandler._setC2CMessageRead 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确");var r=new kr(Kr);return r.setText("".concat(n,"-").concat(o)),this.tim.messageController.request({name:"conversation",action:"setC2CMessageRead",param:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:n.replace("C2C",""),lastMessageTime:o,receipt:1}]}}}).then((function(){return r.setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(),ie.log("ReadReportHandler._setC2CMessageRead ok."),t._updateIsReadAfterReadReport({conversationID:n,lastMessageTime:o}),t._updateUnreadCount(n),new ar})).catch((function(e){return t.tim.netMonitor.probe().then((function(t){var n=M(t,2),o=n[0],i=n[1];r.setError(e,o,i).setEnd()})),ie.log("ReadReportHandler._setC2CMessageRead failed. ".concat(Me(e))),pr(e)}))}},{key:"_setGroupMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageSeq;ie.log("ReadReportHandler._setGroupMessageRead conversationID=".concat(n," lastMessageSeq=").concat(o)),ae(o)||ie.warn("ReadReportHandler._setGroupMessageRead 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确");var r=new kr(Hr);return r.setText("".concat(n,"-").concat(o)),this.tim.messageController.request({name:"conversation",action:"setGroupMessageRead",param:{groupID:n.replace("GROUP",""),messageReadSeq:o}}).then((function(){return r.setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(),ie.log("ReadReportHandler._setGroupMessageRead ok."),t._updateIsReadAfterReadReport({conversationID:n,lastMessageSeq:o}),t._updateUnreadCount(n),new ar})).catch((function(e){return t.tim.netMonitor.probe().then((function(t){var n=M(t,2),o=n[0],i=n[1];r.setError(e,o,i).setEnd()})),ie.log("ReadReportHandler._setGroupMessageRead failed. ".concat(Me(e))),pr(e)}))}},{key:"_updateUnreadCount",value:function(e){var t=this.tim,n=t.conversationController,o=t.messageController,r=n.getLocalConversation(e),i=o.getLocalMessageList(e);r&&(r.unreadCount=i.filter((function(e){return!e.isRead})).length,ie.log("ReadReportHandler._updateUnreadCount conversationID=".concat(r.conversationID," unreadCount=").concat(r.unreadCount)))}},{key:"_updateIsReadAfterReadReport",value:function(e){var t=e.conversationID,n=e.lastMessageSeq,o=e.lastMessageTime,r=this.tim.messageController.getLocalMessageList(t);if(0!==r.length)for(var i,s=r.length-1;s>=0;s--)if(i=r[s],!(o&&i.time>o||n&&i.sequence>n)){if("in"===i.flow&&i.isRead)break;i.setIsRead(!0)}}},{key:"updateIsRead",value:function(e){var n=this.tim,o=n.conversationController,r=n.messageController,i=o.getLocalConversation(e),s=r.getLocalMessageList(e);if(i&&0!==s.length&&!be(i.type)){for(var a=[],u=0;u<s.length;u++)"in"!==s[u].flow?"out"!==s[u].flow||s[u].isRead||s[u].setIsRead(!0):a.push(s[u]);var c=0;if(i.type===t.CONV_C2C){var l=a.slice(-i.unreadCount).filter((function(e){return e.isRevoked})).length;c=a.length-i.unreadCount-l}else c=a.length-i.unreadCount;for(var p=0;p<c&&!a[p].isRead;p++)a[p].setIsRead(!0)}}}]),e}(),is=function(){function e(t){var n=t.tim,o=t.messageController;i(this,e),this.tim=n,this.messageController=o,this.completedMap=new Map,this._initListener()}return a(e,[{key:"getMessageList",value:function(e){var t=this,n=e.conversationID,o=e.nextReqMessageID,r=e.count;if(this.tim.groupController.checkJoinedAVChatRoomByID(n.replace("GROUP","")))return ie.log("GetMessageHandler.getMessageList not available in avchatroom. conversationID=".concat(n)),lr({messageList:[],nextReqMessageID:"",isCompleted:!0});(ge(r)||r>15)&&(r=15);var i=this._computeLeftCount({conversationID:n,nextReqMessageID:o});return ie.log("GetMessageHandler.getMessageList. conversationID=".concat(n," leftCount=").concat(i," count=").concat(r," nextReqMessageID=").concat(o)),this._needGetHistory({conversationID:n,leftCount:i,count:r})?this.messageController.getHistoryMessages({conversationID:n,count:20}).then((function(){return i=t._computeLeftCount({conversationID:n,nextReqMessageID:o}),new ar(t._computeResult({conversationID:n,nextReqMessageID:o,count:r,leftCount:i}))})):(ie.log("GetMessageHandler.getMessageList. get messagelist from memory"),lr(this._computeResult({conversationID:n,nextReqMessageID:o,count:r,leftCount:i})))}},{key:"setCompleted",value:function(e){ie.log("GetMessageHandler.setCompleted. conversationID=".concat(e)),this.completedMap.set(e,!0)}},{key:"deleteCompletedItem",value:function(e){ie.log("GetMessageHandler.deleteCompletedItem. conversationID=".concat(e)),this.completedMap.delete(e)}},{key:"_initListener",value:function(){var e=this;this.tim.innerEmitter.on(Jo,(function(){e.setCompleted(t.CONV_SYSTEM)})),this.tim.innerEmitter.on(Wo,(function(n){var o=n.data;e.setCompleted("".concat(t.CONV_GROUP).concat(o))}))}},{key:"_getMessageListSize",value:function(e){return this.messageController.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var n=e.conversationID,o=e.leftCount,r=e.count,i=this.tim.conversationController.getLocalConversation(n),s=!!i&&i.type===t.CONV_SYSTEM,a=!!i&&i.subType===t.GRP_AVCHATROOM;return!s&&!a&&(o<r&&!this.completedMap.has(n))}},{key:"_computeResult",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,o=e.count,r=e.leftCount,i=this._computeMessageList({conversationID:t,nextReqMessageID:n,count:o}),s=this._computeIsCompleted({conversationID:t,leftCount:r,count:o}),a=this._computeNextReqMessageID({messageList:i,isCompleted:s,conversationID:t});return ie.log("GetMessageHandler._computeResult. conversationID=".concat(t," leftCount=").concat(r," count=").concat(o," nextReqMessageID=").concat(a," nums=").concat(i.length," isCompleted=").concat(s)),{messageList:i,nextReqMessageID:a,isCompleted:s}}},{key:"_computeNextReqMessageID",value:function(e){var t=e.messageList,n=e.isCompleted,o=e.conversationID;if(!n)return 0===t.length?"":t[0].ID;var r=this.messageController.getLocalMessageList(o);return 0===r.length?"":r[0].ID}},{key:"_computeMessageList",value:function(e){var t=e.conversationID,n=e.nextReqMessageID,o=e.count,r=this.messageController.getLocalMessageList(t),i=this._computeIndexEnd({nextReqMessageID:n,messageList:r}),s=this._computeIndexStart({indexEnd:i,count:o});return r.slice(s,i)}},{key:"_computeIndexEnd",value:function(e){var t=e.messageList,n=void 0===t?[]:t,o=e.nextReqMessageID;return o?n.findIndex((function(e){return e.ID===o})):n.length}},{key:"_computeIndexStart",value:function(e){var t=e.indexEnd,n=e.count;return t>n?t-n:0}},{key:"_computeLeftCount",value:function(e){var t=e.conversationID,n=e.nextReqMessageID;return n?this.messageController.getLocalMessageList(t).findIndex((function(e){return e.ID===n})):this._getMessageListSize(t)}},{key:"_computeIsCompleted",value:function(e){var t=e.conversationID;return!!(e.leftCount<=e.count&&this.completedMap.has(t))}},{key:"reset",value:function(){ie.log("GetMessageHandler.reset"),this.completedMap.clear()}}]),e}(),ss=function e(t){i(this,e),this.value=t,this.next=null},as=function(){function e(t){i(this,e),this.MAX_LENGTH=t,this.pTail=null,this.pNodeToDel=null,this.map=new Map,ie.log("SinglyLinkedList init MAX_LENGTH=".concat(this.MAX_LENGTH))}return a(e,[{key:"pushIn",value:function(e){var t=new ss(e);if(this.map.size<this.MAX_LENGTH)null===this.pTail?(this.pTail=t,this.pNodeToDel=t):(this.pTail.next=t,this.pTail=t),this.map.set(e,1);else{var n=this.pNodeToDel;this.pNodeToDel=this.pNodeToDel.next,this.map.delete(n.value),n.next=null,n=null,this.pTail.next=t,this.pTail=t,this.map.set(e,1)}}},{key:"has",value:function(e){return this.map.has(e)}},{key:"tail",value:function(){return this.pTail}},{key:"size",value:function(){return this.map.size}},{key:"data",value:function(){return Array.from(this.map.keys())}},{key:"reset",value:function(){for(var e;null!==this.pNodeToDel;)e=this.pNodeToDel,this.pNodeToDel=this.pNodeToDel.next,e.next=null,e=null;this.pTail=null,this.map.clear()}}]),e}(),us=function(){function e(t){i(this,e),this.tim=t}return a(e,[{key:"upload",value:function(e){switch(e.type){case t.MSG_IMAGE:return this._uploadImage(e);case t.MSG_FILE:return this._uploadFile(e);case t.MSG_AUDIO:return this._uploadAudio(e);case t.MSG_VIDEO:return this._uploadVideo(e);default:return Promise.resolve()}}},{key:"_uploadImage",value:function(e){var t=this.tim,n=t.uploadController,o=t.messageController,r=e.getElements()[0],i=o.getMessageOptionByID(e.messageID);return n.uploadImage({file:i.payload.file,to:i.to,onProgress:function(e){if(r.updatePercent(e),de(i.onProgress))try{i.onProgress(e)}catch(t){return pr(new kt({code:Ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(Vt)}))}}}).then((function(t){var n=t.location,o=t.fileType,i=t.fileSize,s=t.width,a=t.height,u=Ae(n);r.updateImageFormat(o);var c=Fe({originUrl:u,originWidth:s,originHeight:a,min:198}),p=Fe({originUrl:u,originWidth:s,originHeight:a,min:720});return r.updateImageInfoArray([{size:i,url:u,width:s,height:a},l({},p),l({},c)]),e}))}},{key:"_uploadFile",value:function(e){var t=this.tim,n=t.uploadController,o=t.messageController,r=e.getElements()[0],i=o.getMessageOptionByID(e.messageID);return n.uploadFile({file:i.payload.file,to:i.to,onProgress:function(e){if(r.updatePercent(e),de(i.onProgress))try{i.onProgress(e)}catch(t){return pr(new kt({code:Ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(Vt)}))}}}).then((function(t){var n=t.location,o=Ae(n);return r.updateFileUrl(o),e}))}},{key:"_uploadAudio",value:function(e){var t=this.tim,n=t.uploadController,o=t.messageController,r=e.getElements()[0],i=o.getMessageOptionByID(e.messageID);return n.uploadAudio({file:i.payload.file,to:i.to,onProgress:function(e){if(r.updatePercent(e),de(i.onProgress))try{i.onProgress(e)}catch(t){return pr(new kt({code:Ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(Vt)}))}}}).then((function(t){var n=t.location,o=Ae(n);return r.updateAudioUrl(o),e}))}},{key:"_uploadVideo",value:function(e){var t=this.tim,n=t.uploadController,o=t.messageController,r=e.getElements()[0],i=o.getMessageOptionByID(e.messageID);return n.uploadVideo({file:i.payload.file,to:i.to,onProgress:function(e){if(r.updatePercent(e),de(i.onProgress))try{i.onProgress(e)}catch(t){return pr(new kt({code:Ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(Vt)}))}}}).then((function(t){var n=Ae(t.location);return r.updateVideoUrl(n),e}))}}]),e}(),cs=function(n){p(r,n);var o=I(r);function r(e){var t;return i(this,r),(t=o.call(this,e))._initializeMembers(),t._initializeListener(),t._initialzeHandlers(),t.messageOptionMap=new Map,t}return a(r,[{key:"_initializeMembers",value:function(){this.messagesList=new os({tim:this.tim}),this.currentMessageKey={},this.singlyLinkedList=new as(100),this._peerReadTimeMap=new Map}},{key:"_initialzeHandlers",value:function(){this.readReportHandler=new rs(this.tim,this),this.getMessageHandler=new is({messageController:this,tim:this.tim}),this.uploadFileHandler=new us(this.tim)}},{key:"reset",value:function(){this.messagesList.reset(),this.currentMessageKey={},this.getMessageHandler.reset(),this.singlyLinkedList.reset(),this._peerReadTimeMap.clear(),this.messageOptionMap.clear()}},{key:"_initializeListener",value:function(){var e=this.tim.innerEmitter;e.on(ko,this._onReceiveC2CMessage,this),e.on(go,this._onSyncMessagesProcessing,this),e.on(ho,this._onSyncMessagesFinished,this),e.on(Oo,this._onReceiveGroupMessage,this),e.on(Ro,this._onReceiveGroupTips,this),e.on(Ao,this._onReceiveSystemNotice,this),e.on(wo,this._onReceiveGroupMessageRevokedNotice,this),e.on(Po,this._onReceiveC2CMessageRevokedNotice,this),e.on(Go,this._onC2CMessageReadReceipt,this),e.on($o,this._clearConversationMessages,this)}},{key:"_guardForAVChatRoom",value:function(e){if(e.conversationType===t.CONV_GROUP){var n=this.tim.groupController,o=e.to;return n.hasLocalGroup(o)?Promise.resolve():n.getGroupProfile({groupID:o}).then((function(n){var r=n.data.group.type;if(ie.log("MessageController._guardForAVChatRoom. groupID=".concat(o," type=").concat(r)),r===t.GRP_AVCHATROOM){var i="userId=".concat(e.from," 未加入群 groupID=").concat(o,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#joinGroup");return ie.warn("MessageController._guardForAVChatRoom sendMessage not allowed. ".concat(i)),pr(new kt({code:Ot.MESSAGE_SEND_FAIL,message:i,data:{message:e}}))}return Promise.resolve()}))}return Promise.resolve()}},{key:"sendMessageInstance",value:function(e,n){var o,r=this,i=null;switch(e.conversationType){case t.CONV_C2C:i=this._handleOnSendC2CMessageSuccess.bind(this);break;case t.CONV_GROUP:i=this._handleOnSendGroupMessageSuccess.bind(this);break;default:return pr(new kt({code:Ot.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:Ft}))}return this.singlyLinkedList.pushIn(e.random),this.uploadFileHandler.upload(e).then((function(){return r._guardForAVChatRoom(e).then((function(){var i=null;return e.isSendable()?(r._addSendMessageTotalCount(e),o=Date.now(),e.conversationType===t.CONV_C2C?i=r._createC2CMessagePack(e,n):e.conversationType===t.CONV_GROUP&&(i=r._createGroupMessagePack(e,n)),r.request(i)):pr({code:Ot.MESSAGE_FILE_URL_IS_EMPTY,message:en})})).then((function(n){return r._addSendMessageSuccessCount(e,o),e.conversationType===t.CONV_GROUP&&(e.sequence=n.data.sequence,e.time=n.data.time,e.generateMessageID(r.tim.context.identifier)),r.messagesList.pushIn(e),i(e,n.data),r.messageOptionMap.delete(e.messageID),r.emitInnerEvent(mo,{eventDataList:[{conversationID:e.conversationID,unreadCount:0,type:e.conversationType,subType:e.conversationSubType,lastMessage:e}]}),"TIMImageElem"===e.type&&xe(e.payload.imageInfoArray),new ar({message:e})})).catch((function(t){e.status=We.FAIL;var n=new kr(Ur);return n.setMessageType(e.type).setText("".concat(r._generateTjgID(e),"-").concat(e.type,"-").concat(e.from,"-").concat(e.to)),r.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];n.setError(t,r,i).setEnd()})),ie.error("MessageController.sendMessageInstance error:",t),pr(new kt({code:t&&t.code?t.code:Ot.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:bt,data:{message:e}}))}))}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if(e.conversationType===t.CONV_C2C)return _r;if(e.conversationType===t.CONV_GROUP){var n=this.tim.groupController.getLocalGroupProfile(e.to);if(!n)return;var o=n.type;if(Le(o))return vr;if(we(o))return yr;if(Pe(o))return Ir;if(Ge(o))return Mr}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this.tim.sumStatController;t.addTotalCount(fr);var n=this._getSendMessageSpecifiedKey(e);n&&t.addTotalCount(n)}},{key:"_addSendMessageSuccessCount",value:function(e,t){var n=this.tim.sumStatController,o=Math.abs(Date.now()-t);n.addSuccessCount(fr),n.addCost(fr,o);var r=this._getSendMessageSpecifiedKey(e);r&&(n.addSuccessCount(r),n.addCost(r,o))}},{key:"resendMessage",value:function(e){return e.isResend=!0,e.status=We.UNSEND,this.sendMessageInstance(e)}},{key:"_isFileLikeMessage",value:function(e){return[t.MSG_IMAGE,t.MSG_FILE,t.MSG_AUDIO,t.MSG_VIDEO].indexOf(e.type)>=0}},{key:"_resendBinaryTypeMessage",value:function(){}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var n=this.tim.groupController.getJoinedAVChatRoom();return!n||!n.includes(e.to)||e.conversationType!==t.CONV_GROUP}},{key:"_createC2CMessagePack",value:function(e,t){var n=0,o=null;return t&&(t.offlinePushInfo&&(o=t.offlinePushInfo),!0===t.onlineUserOnly&&(n=1,o?o.disablePush=!0:o={disablePush:!0})),{name:"c2cMessage",action:"create",tjgID:this._generateTjgID(e),param:{toAccount:e.to,msgBody:e.getElements(),msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:this._canIUseOnlineOnlyFlag(e)&&n?0:void 0,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0}}}},{key:"_handleOnSendC2CMessageSuccess",value:function(e,t){e.status=We.SUCCESS,e.time=t.time}},{key:"_createGroupMessagePack",value:function(e,t){var n=0,o=null;return t&&(!0===t.onlineUserOnly&&(n=1),t.offlinePushInfo&&(o=t.offlinePushInfo)),{name:"groupMessage",action:"create",tjgID:this._generateTjgID(e),param:{groupID:e.to,msgBody:e.getElements(),random:e.random,priority:e.priority,clientSequence:e.clientSequence,onlineOnlyFlag:this._canIUseOnlineOnlyFlag(e)?n:0,offlinePushInfo:o?{pushFlag:!0===o.disablePush?1:0,title:o.title||"",desc:o.description||"",ext:o.extension||"",apnsInfo:{badgeMode:!0===o.ignoreIOSBadge?1:0},androidInfo:{OPPOChannelID:o.androidOPPOChannelID||""}}:void 0}}}},{key:"_handleOnSendGroupMessageSuccess",value:function(e,t){e.sequence=t.sequence,e.time=t.time,e.status=We.SUCCESS}},{key:"_onReceiveC2CMessage",value:function(n){ie.debug("MessageController._onReceiveC2CMessage nums=".concat(n.data.length));var o=Date.now(),r=this._newC2CMessageStoredAndSummary({notifiesList:n.data,type:t.CONV_C2C,C2CRemainingUnreadList:n.C2CRemainingUnreadList}),i=r.eventDataList,s=r.result;if(i.length>0&&this.emitInnerEvent(vo,{eventDataList:i,result:s}),s.length>0){var a=this.tim.sumStatController;a.addTotalCount(Cr),a.addSuccessCount(Cr),a.addCost(Cr,Date.now()-o),this.emitOuterEvent(e.MESSAGE_RECEIVED,s)}}},{key:"_onReceiveGroupMessage",value:function(t){ie.debug("MessageController._onReceiveGroupMessage nums=".concat(t.data.length));var n=Date.now(),o=this.newGroupMessageStoredAndSummary(t.data),r=o.eventDataList,i=o.result;if(r.length>0&&this.emitInnerEvent(yo,{eventDataList:r,result:i,isGroupTip:!1}),i.length>0){var s=this.tim.sumStatController;s.addTotalCount(Cr),s.addSuccessCount(Cr),s.addCost(Cr,Date.now()-n),this.emitOuterEvent(e.MESSAGE_RECEIVED,i)}}},{key:"_onReceiveGroupTips",value:function(t){var n=Date.now(),o=t.data;ie.debug("MessageController._onReceiveGroupTips nums=".concat(o.length));var r=this.newGroupTipsStoredAndSummary(o),i=r.eventDataList,s=r.result;if(i.length>0&&this.emitInnerEvent(yo,{eventDataList:i,result:s,isGroupTip:!0}),s.length>0){var a=this.tim.sumStatController;a.addTotalCount(Cr),a.addSuccessCount(Cr),a.addCost(Cr,Date.now()-n),this.emitOuterEvent(e.MESSAGE_RECEIVED,s)}}},{key:"_onReceiveSystemNotice",value:function(t){var n=Date.now(),o=t.data,r=o.groupSystemNotices,i=o.type;ie.debug("MessageController._onReceiveSystemNotice nums=".concat(r.length));var s=this.newSystemNoticeStoredAndSummary({notifiesList:r,type:i}),a=s.eventDataList,u=s.result;if(a.length>0&&this.emitInnerEvent(Io,{eventDataList:a,result:u,type:i}),u.length>0&&"poll"===i){var c=this.tim.sumStatController;c.addTotalCount(Cr),c.addSuccessCount(Cr),c.addCost(Cr,Date.now()-n),this.emitOuterEvent(e.MESSAGE_RECEIVED,u)}}},{key:"_onReceiveGroupMessageRevokedNotice",value:function(t){var n=this;ie.debug("MessageController._onReceiveGroupMessageRevokedNotice nums=".concat(t.data.length));var o=[],r=null;t.data.forEach((function(e){e.elements.revokedInfos.forEach((function(e){(r=n.messagesList.revoke("GROUP".concat(e.groupID),e.sequence))&&o.push(r)}))})),0!==o.length&&(this.emitInnerEvent(Mo,o),this.emitOuterEvent(e.MESSAGE_REVOKED,o))}},{key:"_onReceiveC2CMessageRevokedNotice",value:function(t){var n=this;ie.debug("MessageController._onReceiveC2CMessageRevokedNotice nums=".concat(t.data.length));var o=[],r=null;t.data.forEach((function(e){e.c2cMessageRevokedNotify.revokedInfos.forEach((function(e){var t=n.tim.context.identifier===e.from?"C2C".concat(e.to):"C2C".concat(e.from);(r=n.messagesList.revoke(t,e.sequence,e.random))&&o.push(r)}))})),0!==o.length&&(this.emitInnerEvent(Mo,o),this.emitOuterEvent(e.MESSAGE_REVOKED,o))}},{key:"_onC2CMessageReadReceipt",value:function(e){var t=this;e.data.forEach((function(e){var n=e.c2cMessageReadReceipt.to;e.c2cMessageReadReceipt.uinPairReadArray.forEach((function(e){var o=e.peerReadTime;ie.debug("MessageController._onC2CMessageReadReceipt to=".concat(n," peerReadTime=").concat(o));var r="C2C".concat(n);t.recordPeerReadTime(r,o),t._updateMessageIsPeerReadProperty(r,o)}))}))}},{key:"_updateMessageIsPeerReadProperty",value:function(n,o){if(n.startsWith(t.CONV_C2C)&&o>0){var r=this.messagesList.updateMessageIsPeerReadProperty(n,o);r.length>0&&this.emitOuterEvent(e.MESSAGE_READ_BY_PEER,r)}}},{key:"getPeerReadTime",value:function(e){var t=this;if(!Ke(e)){var n=new kr(jr);return ie.log("MessageController.getPeerReadTime userIDList:".concat(e)),this.request({name:"c2cPeerReadTime",action:"get",param:{userIDList:e}}).then((function(o){var r=o.data.peerReadTimeList;ie.log("MessageController.getPeerReadTime ok. peerReadTimeList:".concat(r));for(var i="",s=0;s<e.length;s++)i+="".concat(e[s],"-").concat(r[s]," "),r[s]>0&&t.recordPeerReadTime("C2C".concat(e[s]),r[s]);n.setNetworkType(t.getNetworkType()).setText(i).setEnd()})).catch((function(e){t.probeNetwork().then((function(t){var o=M(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),ie.warn("MessageController.getPeerReadTime failed. error:",e)}))}}},{key:"recordPeerReadTime",value:function(e,t){this._peerReadTimeMap.has(e)?this._peerReadTimeMap.get(e)<t&&this._peerReadTimeMap.set(e,t):this._peerReadTimeMap.set(e,t)}},{key:"_clearConversationMessages",value:function(e){var t=e.data;this.messagesList.removeByConversationID(t),this.getMessageHandler.deleteCompletedItem(t)}},{key:"_pushIntoNoticeResult",value:function(e,t){return!(!this.messagesList.pushIn(t)||this.singlyLinkedList.has(t.random))&&(e.push(t),!0)}},{key:"_newC2CMessageStoredAndSummary",value:function(e){for(var n=e.notifiesList,o=e.type,r=e.C2CRemainingUnreadList,i=e.isFromSync,s=null,a=[],u=[],c={},l=this.tim.bigDataHallwayController,p=0,g=n.length;p<g;p++){var h=n[p];if(h.currentUser=this.tim.context.identifier,h.conversationType=o,h.isSystemMessage=!!h.isSystemMessage,s=new Kn(h),h.elements=l.parseElements(h.elements,h.from),s.setElement(h.elements),!i)if(!this._pushIntoNoticeResult(u,s))continue;void 0===c[s.conversationID]?c[s.conversationID]=a.push({conversationID:s.conversationID,unreadCount:"out"===s.flow?0:1,type:s.conversationType,subType:s.conversationSubType,lastMessage:s})-1:(a[c[s.conversationID]].type=s.conversationType,a[c[s.conversationID]].subType=s.conversationSubType,a[c[s.conversationID]].lastMessage=s,"in"===s.flow&&a[c[s.conversationID]].unreadCount++)}if(pe(r))for(var d=function(e,n){var o=a.find((function(t){return t.conversationID==="C2C".concat(r[e].from)}));o?o.unreadCount+=r[e].count:a.push({conversationID:"C2C".concat(r[e].from),unreadCount:r[e].count,type:t.CONV_C2C,lastMsgTime:r[e].lastMsgTime})},m=0,f=r.length;m<f;m++)d(m);return{eventDataList:a,result:u}}},{key:"newGroupMessageStoredAndSummary",value:function(e){var n=null,o=[],r={},i=[],s=t.CONV_GROUP,a=this.tim.bigDataHallwayController,u=e.length;u>1&&e.sort((function(e,t){return e.sequence-t.sequence}));for(var c=0;c<u;c++){var l=e[c];if(l.currentUser=this.tim.context.identifier,l.conversationType=s,l.isSystemMessage=!!l.isSystemMessage,n=new Kn(l),l.elements=a.parseElements(l.elements,l.from),n.setElement(l.elements),!this._isMessageFromAVChatroom(n))this._pushIntoNoticeResult(i,n)&&(void 0===r[n.conversationID]?r[n.conversationID]=o.push({conversationID:n.conversationID,unreadCount:"out"===n.flow?0:1,type:n.conversationType,subType:n.conversationSubType,lastMessage:n})-1:(o[r[n.conversationID]].type=n.conversationType,o[r[n.conversationID]].subType=n.conversationSubType,o[r[n.conversationID]].lastMessage=n,"in"===n.flow&&o[r[n.conversationID]].unreadCount++))}return{eventDataList:o,result:i}}},{key:"_isMessageFromAVChatroom",value:function(e){var t=e.conversationID.slice(5);return this.tim.groupController.checkJoinedAVChatRoomByID(t)}},{key:"newGroupTipsStoredAndSummary",value:function(e){for(var n=null,o=[],r=[],i={},s=0,a=e.length;s<a;s++){var u=e[s];if(u.currentUser=this.tim.context.identifier,u.conversationType=t.CONV_GROUP,(n=new Kn(u)).setElement({type:t.MSG_GRP_TIP,content:l(l({},u.elements),{},{groupProfile:u.groupProfile})}),n.isSystemMessage=!1,!this._isMessageFromAVChatroom(n))this._pushIntoNoticeResult(r,n)&&(void 0===i[n.conversationID]?i[n.conversationID]=o.push({conversationID:n.conversationID,unreadCount:"out"===n.flow?0:1,type:n.conversationType,subType:n.conversationSubType,lastMessage:n})-1:(o[i[n.conversationID]].type=n.conversationType,o[i[n.conversationID]].subType=n.conversationSubType,o[i[n.conversationID]].lastMessage=n,"in"===n.flow&&o[i[n.conversationID]].unreadCount++))}return{eventDataList:o,result:r}}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var n=e.notifiesList,o=e.type,r=null,i=n.length,s=0,a=[],u={conversationID:t.CONV_SYSTEM,unreadCount:0,type:t.CONV_SYSTEM,subType:null,lastMessage:null};for(s=0;s<i;s++){var c=n[s];if(c.elements.operationType!==at)c.currentUser=this.tim.context.identifier,c.conversationType=t.CONV_SYSTEM,c.conversationID=t.CONV_SYSTEM,(r=new Kn(c)).setElement({type:t.MSG_GRP_SYS_NOTICE,content:l(l({},c.elements),{},{groupProfile:c.groupProfile})}),r.isSystemMessage=!0,(1===r.sequence&&1===r.random||2===r.sequence&&2===r.random)&&(r.sequence=Te(),r.random=Te(),r.generateMessageID(c.currentUser),ie.log("MessageController.newSystemNoticeStoredAndSummary sequence and random maybe duplicated, regenerate. ID=".concat(r.ID))),this._pushIntoNoticeResult(a,r)&&("poll"===o?u.unreadCount++:"sync"===o&&r.setIsRead(!0),u.subType=r.conversationSubType)}return u.lastMessage=a[a.length-1],{eventDataList:a.length>0?[u]:[],result:a}}},{key:"_onSyncMessagesProcessing",value:function(e){var n=this._newC2CMessageStoredAndSummary({notifiesList:e.data,type:t.CONV_C2C,isFromSync:!0,C2CRemainingUnreadList:e.C2CRemainingUnreadList}),o=n.eventDataList,r=n.result;this.emitInnerEvent(fo,{eventDataList:o,result:r})}},{key:"_onSyncMessagesFinished",value:function(e){this.triggerReady();var n=this._newC2CMessageStoredAndSummary({notifiesList:e.data.messageList,type:t.CONV_C2C,isFromSync:!0,C2CRemainingUnreadList:e.data.C2CRemainingUnreadList}),o=n.eventDataList,r=n.result;this.emitInnerEvent(_o,{eventDataList:o,result:r})}},{key:"getHistoryMessages",value:function(e){if(e.conversationID===t.CONV_SYSTEM)return lr();!e.count&&(e.count=15),e.count>20&&(e.count=20);var n=this.messagesList.getLocalOldestMessageByConversationID(e.conversationID);n||((n={}).time=0,n.sequence=0,0===e.conversationID.indexOf(t.CONV_C2C)?(n.to=e.conversationID.replace(t.CONV_C2C,""),n.conversationType=t.CONV_C2C):0===e.conversationID.indexOf(t.CONV_GROUP)&&(n.to=e.conversationID.replace(t.CONV_GROUP,""),n.conversationType=t.CONV_GROUP));var o="";switch(n.conversationType){case t.CONV_C2C:return o=e.conversationID.replace(t.CONV_C2C,""),this.getC2CRoamMessages({conversationID:e.conversationID,peerAccount:o,count:e.count,lastMessageTime:void 0===this.currentMessageKey[e.conversationID]?0:n.time});case t.CONV_GROUP:return this.getGroupRoamMessages({conversationID:e.conversationID,groupID:n.to,count:e.count,sequence:n.sequence-1});default:return lr()}}},{key:"getC2CRoamMessages",value:function(e){var n=this,o=e.conversationID,r=void 0!==this.currentMessageKey[o]?this.currentMessageKey[o]:"";ie.log("MessageController.getC2CRoamMessages toAccount=".concat(e.peerAccount," count=").concat(e.count||15," lastMessageTime=").concat(e.lastMessageTime||0," messageKey=").concat(r));var i=new kr(Fr);return this.request({name:"c2cMessage",action:"query",param:{peerAccount:e.peerAccount,count:e.count||15,lastMessageTime:e.lastMessageTime||0,messageKey:r}}).then((function(s){var a=s.data,u=a.complete,c=a.messageList;ge(c)?ie.log("MessageController.getC2CRoamMessages ok. complete=".concat(u," but messageList is undefined!")):ie.log("MessageController.getC2CRoamMessages ok. complete=".concat(u," nums=").concat(c.length)),i.setNetworkType(n.getNetworkType()).setText("".concat(e.peerAccount,"-").concat(e.count||15,"-").concat(e.lastMessageTime||0,"-").concat(r,"-").concat(u,"-").concat(c?c.length:"undefined")).setEnd(),1===u&&n.getMessageHandler.setCompleted(o);var l=n._roamMessageStore(c,t.CONV_C2C,o);n.readReportHandler.updateIsRead(o),n.currentMessageKey[o]=s.data.messageKey;var p=n._peerReadTimeMap.get(o);if(ie.log("MessageController.getC2CRoamMessages update isPeerRead property. conversationID=".concat(o," peerReadTime=").concat(p)),p)n._updateMessageIsPeerReadProperty(o,p);else{var g=o.replace(t.CONV_C2C,"");n.getPeerReadTime([g]).then((function(){n._updateMessageIsPeerReadProperty(o,n._peerReadTimeMap.get(o))}))}return l})).catch((function(t){return n.probeNetwork().then((function(n){var o=M(n,2),s=o[0],a=o[1];i.setError(t,s,a).setText("".concat(e.peerAccount,"-").concat(e.count||15,"-").concat(e.lastMessageTime||0,"-").concat(r)).setEnd()})),ie.warn("MessageController.getC2CRoamMessages failed. ".concat(t)),pr(t)}))}},{key:"_computeLastSequence",value:function(e){return e.sequence>=0?Promise.resolve(e.sequence):this.tim.groupController.getGroupLastSequence(e.groupID)}},{key:"getGroupRoamMessages",value:function(e){var n=this,o=new kr(xr),r=0;return this._computeLastSequence(e).then((function(t){return r=t,ie.log("MessageController.getGroupRoamMessages groupID=".concat(e.groupID," lastSequence=").concat(r)),n.request({name:"groupMessage",action:"query",param:{groupID:e.groupID,count:21,sequence:r}})})).then((function(i){var s=i.data,a=s.messageList,u=s.complete;ge(a)?ie.log("MessageController.getGroupRoamMessages ok. complete=".concat(u," but messageList is undefined!")):ie.log("MessageController.getGroupRoamMessages ok. complete=".concat(u," nums=").concat(a.length)),o.setNetworkType(n.getNetworkType()).setText("".concat(e.groupID,"-").concat(r,"-").concat(u,"-").concat(a?a.length:"undefined")).setEnd();var c="GROUP".concat(e.groupID);if(2===u||Ke(a))return n.getMessageHandler.setCompleted(c),[];var l=n._roamMessageStore(a,t.CONV_GROUP,c);return n.readReportHandler.updateIsRead(c),n._patchConversationLastMessage(c),l})).catch((function(t){return n.probeNetwork().then((function(n){var i=M(n,2),s=i[0],a=i[1];o.setError(t,s,a).setText("".concat(e.groupID,"-").concat(r)).setEnd()})),ie.warn("MessageController.getGroupRoamMessages failed. ".concat(t)),pr(t)}))}},{key:"_patchConversationLastMessage",value:function(e){var t=this.tim.conversationController.getLocalConversation(e);if(t){var n=t.lastMessage,o=n.messageForShow,r=n.payload;if(Ke(o)||Ke(r)){var i=this.messagesList.getLocalMessageList(e);if(0===i.length)return;var s=i[i.length-1];ie.log("MessageController._patchConversationLastMessage conversationID:".concat(e," payload:"),s.payload),t.updateLastMessage(s)}}}},{key:"_roamMessageStore",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,r=null,i=[],s=0,a=e.length,u=null,c=n===t.CONV_GROUP,p=this.tim.bigDataHallwayController,g=function(){s=c?e.length-1:0,a=c?0:e.length},h=function(){c?--s:++s},d=function(){return c?s>=a:s<a};for(g();d();h())if(c&&1===e[s].sequence&&this.getMessageHandler.setCompleted(o),1!==e[s].isPlaceMessage)if((r=new Kn(e[s])).to=e[s].to,r.isSystemMessage=!!e[s].isSystemMessage,r.conversationType=n,e[s].event===Xe.JSON.TYPE.GROUP.TIP?u={type:t.MSG_GRP_TIP,content:l(l({},e[s].elements),{},{groupProfile:e[s].groupProfile})}:(e[s].elements=p.parseElements(e[s].elements,e[s].from),u=e[s].elements),Ke(u)){var m=new kr(Br);m.setText("from:".concat(r.from," to:").concat(r.to," sequence:").concat(r.sequence," event:").concat(e[s].event)),m.setNetworkType(this.getNetworkType()).setEnd()}else r.setElement(u),r.reInitialize(this.tim.context.identifier),i.push(r);return this.messagesList.unshift(i),g=h=d=null,i}},{key:"getLocalMessageList",value:function(e){return this.messagesList.getLocalMessageList(e)}},{key:"getLocalMessage",value:function(e,t){return this.messagesList.getLocalMessage(e,t)}},{key:"hasLocalMessage",value:function(e,t){return this.messagesList.hasLocalMessage(e,t)}},{key:"deleteLocalMessage",value:function(e){e instanceof Kn&&this.messagesList.remove(e)}},{key:"revokeMessage",value:function(e){var n,o=this;e.conversationType===t.CONV_C2C?n={name:"c2cMessageWillBeRevoked",action:"create",param:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}}:e.conversationType===t.CONV_GROUP&&(n={name:"groupMessageWillBeRevoked",action:"create",param:{to:e.to,msgSeqList:[{msgSeq:e.sequence}]}});var r=new kr(Vr);return r.setMessageType(e.type).setText("".concat(this._generateTjgID(e),"-").concat(e.type,"-").concat(e.from,"-").concat(e.to)),this.request(n).then((function(t){var n=t.data.recallRetList;if(!Ke(n)&&0!==n[0].retCode){var i=new kt({code:n[0].retCode,message:St[n[0].retCode]||Kt,data:{message:e}});return r.setCode(i.code).setMessage(i.message).setEnd(),pr(i)}return ie.info("MessageController.revokeMessage ok. ID=".concat(e.ID)),e.isRevoked=!0,r.setEnd(),o.emitInnerEvent(Mo,[e]),new ar({message:e})})).catch((function(t){o.probeNetwork().then((function(e){var n=M(e,2),o=n[0],i=n[1];r.setError(t,o,i).setEnd()}));var n=new kt({code:t&&t.code?t.code:Ot.MESSAGE_REVOKE_FAIL,message:t&&t.message?t.message:Kt,data:{message:e}});return ie.warn("MessageController.revokeMessage failed. ID=".concat(e.ID," code=").concat(n.code," message=").concat(n.message)),pr(n)}))}},{key:"setMessageRead",value:function(e){var t=this;return new Promise((function(n,o){t.ready((function(){t.readReportHandler.setMessageRead(e).then(n).catch(o)}))}))}},{key:"getMessageList",value:function(e){return this.getMessageHandler.getMessageList(e)}},{key:"createTextMessage",value:function(e){e.currentUser=this.tim.context.identifier;var t=new Kn(e),n="string"==typeof e.payload?e.payload:e.payload.text,o=new Je({text:n});return t.setElement(o),t}},{key:"createCustomMessage",value:function(e){e.currentUser=this.tim.context.identifier;var t=new Kn(e),n=new qn({data:e.payload.data,description:e.payload.description,extension:e.payload.extension});return t.setElement(n),t}},{key:"createImageMessage",value:function(e){e.currentUser=this.tim.context.identifier;var t=new Kn(e);if(P){var n=e.payload.file;if(se(n))return void ie.warn("微信小程序环境下调用 createImageMessage 接口时,payload.file 不支持传入 File 对象");var o=n.tempFilePaths[0],r={url:o,name:o.slice(o.lastIndexOf("/")+1),size:n.tempFiles[0].size,type:o.slice(o.lastIndexOf(".")+1).toLowerCase()};e.payload.file=r}else if(w&&se(e.payload.file)){var i=e.payload.file;e.payload.file={files:[i]}}var s=new ft({imageFormat:Xe.IMAGE_FORMAT.UNKNOWN,uuid:this._generateUUID(),file:e.payload.file});return t.setElement(s),this.messageOptionMap.set(t.messageID,e),t}},{key:"createFileMessage",value:function(e){if(!P){if(w&&se(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}e.currentUser=this.tim.context.identifier;var n=new Kn(e),o=new Un({uuid:this._generateUUID(),file:e.payload.file});return n.setElement(o),this.messageOptionMap.set(n.messageID,e),n}ie.warn("微信小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createAudioMessage",value:function(e){if(P){var t=e.payload.file;if(P){var n={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=n}e.currentUser=this.tim.context.identifier;var o=new Kn(e),r=new vt({second:Math.floor(t.duration/1e3),size:t.fileSize,url:t.tempFilePath,uuid:this._generateUUID()});return o.setElement(r),this.messageOptionMap.set(o.messageID,e),o}ie.warn("createAudioMessage 目前只支持微信小程序发语音消息")}},{key:"createVideoMessage",value:function(e){e.currentUser=this.tim.context.identifier,e.payload.file.thumbUrl="https://webim-1252463788.cos.ap-shanghai.myqcloud.com/assets/images/transparent.png",e.payload.file.thumbSize=1668;var t={};if(P){if(se(e.payload.file))return void ie.warn("微信小程序环境下调用 createVideoMessage 接口时,payload.file 不支持传入 File 对象");var n=e.payload.file;t.url=n.tempFilePath,t.name=n.tempFilePath.slice(n.tempFilePath.lastIndexOf("/")+1),t.size=n.size,t.second=n.duration,t.type=n.tempFilePath.slice(n.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(w){if(se(e.payload.file)){var o=e.payload.file;e.payload.file.files=[o]}var r=e.payload.file;t.url=window.URL.createObjectURL(r.files[0]),t.name=r.files[0].name,t.size=r.files[0].size,t.second=r.files[0].duration||0,t.type=r.files[0].type.split("/")[1]}e.payload.file.videoFile=t;var i=new Kn(e),s=new Fn({videoFormat:t.type,videoSecond:Number(t.second.toFixed(0)),videoSize:t.size,remoteVideoUrl:"",videoUrl:t.url,videoUUID:this._generateUUID(),thumbUUID:this._generateUUID(),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()});return i.setElement(s),this.messageOptionMap.set(i.messageID,e),i}},{key:"createFaceMessage",value:function(e){e.currentUser=this.tim.context.identifier;var t=new Kn(e),n=new _t(e.payload);return t.setElement(n),t}},{key:"_generateUUID",value:function(){var e=this.tim.context;return"".concat(e.SDKAppID,"-").concat(e.identifier,"-").concat(function(){for(var e="",t=32;t>0;--t)e+=De[Math.floor(Math.random()*Se)];return e}())}},{key:"_generateTjgID",value:function(e){return this.tim.context.tinyID+"-"+e.random}},{key:"getMessageOptionByID",value:function(e){return this.messageOptionMap.get(e)}},{key:"isMessageSentByCurrentInstance",value:function(e){return!(!this.messagesList.hasLocalMessage(e.conversationID,e.ID)&&!this.singlyLinkedList.has(e.random))}},{key:"pushToMessageList",value:function(e){this.messagesList.pushIn(e)}}]),r}(rr),ls=function(){function e(t){i(this,e),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.lastSendMsgTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this._initMember(t)}return a(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&Ne(this.memberCustomField,e.memberCustomField),Ie(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){ge(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){ge(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&Ne(this.memberCustomField,e)}}]),e}(),ps=function(){function e(t){i(this,e),this.tim=t.tim,this.groupController=t.groupController,this._initListeners()}return a(e,[{key:"_initListeners",value:function(){this.tim.innerEmitter.on(yo,this._onReceivedGroupTips,this)}},{key:"_onReceivedGroupTips",value:function(e){var t=this,n=e.data,o=n.result;n.isGroupTip&&o.forEach((function(e){switch(e.payload.operationType){case 1:t._onNewMemberComeIn(e);break;case 2:t._onMemberQuit(e);break;case 3:t._onMemberKickedOut(e);break;case 4:t._onMemberSetAdmin(e);break;case 5:t._onMemberCancelledAdmin(e);break;case 6:t._onGroupProfileModified(e);break;case 7:t._onMemberInfoModified(e);break;default:ie.warn("GroupTipsHandler._onReceivedGroupTips Unhandled groupTips. operationType=",e.payload.operationType)}}))}},{key:"_onNewMemberComeIn",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,r=this.groupController.getLocalGroupProfile(o);r&&ae(n)&&(r.memberNum=n)}},{key:"_onMemberQuit",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,r=this.groupController.getLocalGroupProfile(o);r&&ae(n)&&(r.memberNum=n),this.groupController.deleteLocalGroupMembers(o,e.payload.userIDList)}},{key:"_onMemberKickedOut",value:function(e){var t=e.payload,n=t.memberNum,o=t.groupProfile.groupID,r=this.groupController.getLocalGroupProfile(o);r&&ae(n)&&(r.memberNum=n),this.groupController.deleteLocalGroupMembers(o,e.payload.userIDList)}},{key:"_onMemberSetAdmin",value:function(e){var n=this,o=e.payload.groupProfile.groupID;e.payload.userIDList.forEach((function(e){var r=n.groupController.getLocalGroupMemberInfo(o,e);r&&r.updateRole(t.GRP_MBR_ROLE_ADMIN)}))}},{key:"_onMemberCancelledAdmin",value:function(e){var n=this,o=e.payload.groupProfile.groupID;e.payload.userIDList.forEach((function(e){var r=n.groupController.getLocalGroupMemberInfo(o,e);r&&r.updateRole(t.GRP_MBR_ROLE_MEMBER)}))}},{key:"_onGroupProfileModified",value:function(e){var t=this,n=e.payload.newGroupProfile,o=e.payload.groupProfile.groupID,r=this.groupController.getLocalGroupProfile(o);Object.keys(n).forEach((function(e){switch(e){case"ownerID":t._ownerChaged(r,n);break;default:r[e]=n[e]}})),this.groupController.emitGroupListUpdate(!0,!0)}},{key:"_ownerChaged",value:function(e,n){var o=e.groupID,r=this.groupController.getLocalGroupProfile(o),i=this.tim.context.identifier;if(i===n.ownerID){r.updateGroup({selfInfo:{role:t.GRP_MBR_ROLE_OWNER}});var s=this.groupController.getLocalGroupMemberInfo(o,i),a=this.groupController.getLocalGroupProfile(o).ownerID,u=this.groupController.getLocalGroupMemberInfo(o,a);s&&s.updateRole(t.GRP_MBR_ROLE_OWNER),u&&u.updateRole(t.GRP_MBR_ROLE_MEMBER)}}},{key:"_onMemberInfoModified",value:function(e){var t=this,n=e.payload.groupProfile.groupID;e.payload.memberList.forEach((function(e){var o=t.groupController.getLocalGroupMemberInfo(n,e.userID);o&&e.muteTime&&o.updateMuteUntil(e.muteTime)}))}}]),e}(),gs=function(){function n(e){i(this,n),this.groupController=e.groupController,this.tim=e.tim,this.pendencyMap=new Map,this._initLiceners()}return a(n,[{key:"_initLiceners",value:function(){this.tim.innerEmitter.on(Io,this._onReceivedGroupSystemNotice,this),this.tim.innerEmitter.on(ho,this._clearGroupSystemNotice,this)}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(n){n.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var o=e.tim.messageController.getLocalMessageList(t.CONV_SYSTEM),r=[];o.forEach((function(t){var n=t.payload,o=n.operatorID,i=n.operationType,s=n.groupProfile;if(i===Qe){var a="".concat(o,"_").concat(s.groupID,"_").concat(s.to),u=e.pendencyMap.get(a);u&&ae(u.handled)&&0!==u.handled&&r.push(t)}})),e.groupController.deleteGroupSystemNotice({messageList:r})}))}},{key:"getPendencyList",value:function(e){var t=this;return this.groupController.request({name:"group",action:"getGroupPendency",param:{startTime:e&&e.startTime?e.startTime:0,limit:e&&e.limit?e.limit:10,handleAccount:this.tim.context.identifier}}).then((function(e){var n=e.data,o=n.pendencyList;return 0!==n.nextStartTime?t.getPendencyList({startTime:n.nextStartTime}).then((function(e){return[].concat(C(o),C(e))})):o}))}},{key:"_onReceivedGroupSystemNotice",value:function(t){var n=this,o=t.data,r=o.result;"sync"!==o.type&&r.forEach((function(t){switch(t.payload.operationType){case 1:n._onApplyGroupRequest(t);break;case 2:n._onApplyGroupRequestAgreed(t);break;case 3:n._onApplyGroupRequestRefused(t);break;case 4:n._onMemberKicked(t);break;case 5:n._onGroupDismissed(t);break;case 6:break;case 7:n._onInviteGroup(t);break;case 8:n._onQuitGroup(t);break;case 9:n._onSetManager(t);break;case 10:n._onDeleteManager(t);break;case 11:case 12:case 15:break;case 255:n.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:ut})}}))}},{key:"_onApplyGroupRequest",value:function(t){this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:Qe})}},{key:"_onApplyGroupRequestAgreed",value:function(t){var n=this,o=t.payload.groupProfile.groupID;this.groupController.hasLocalGroup(o)||this.groupController.getGroupProfile({groupID:o}).then((function(e){var t=e.data.group;t&&(n.groupController.updateGroupMap([t]),n.groupController.emitGroupListUpdate())})),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:Ze})}},{key:"_onApplyGroupRequestRefused",value:function(t){this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:et})}},{key:"_onMemberKicked",value:function(t){var n=t.payload.groupProfile.groupID;this.groupController.hasLocalGroup(n)&&this.groupController.deleteLocalGroupAndConversation(n),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:tt})}},{key:"_onGroupDismissed",value:function(t){var n=t.payload.groupProfile.groupID,o=this.groupController.hasLocalGroup(n),r=this.groupController.AVChatRoomHandler;o&&this.groupController.deleteLocalGroupAndConversation(n),r.checkJoinedAVChatRoomByID(n)&&r.reset(n),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:nt})}},{key:"_onInviteGroup",value:function(t){var n=this,o=t.payload.groupProfile.groupID;this.groupController.hasLocalGroup(o)||this.groupController.getGroupProfile({groupID:o}).then((function(e){var t=e.data.group;t&&(n.groupController.updateGroupMap([t]),n.groupController.emitGroupListUpdate())})),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:ot})}},{key:"_onQuitGroup",value:function(t){var n=t.payload.groupProfile.groupID;this.groupController.hasLocalGroup(n)&&this.groupController.deleteLocalGroupAndConversation(n),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:rt})}},{key:"_onSetManager",value:function(n){var o=n.payload.groupProfile,r=o.to,i=o.groupID,s=this.groupController.getLocalGroupMemberInfo(i,r);s&&s.updateRole(t.GRP_MBR_ROLE_ADMIN),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:n,type:it})}},{key:"_onDeleteManager",value:function(n){var o=n.payload.groupProfile,r=o.to,i=o.groupID,s=this.groupController.getLocalGroupMemberInfo(i,r);s&&s.updateRole(t.GRP_MBR_ROLE_MEMBER),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:n,type:st})}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),n}(),hs={3:!0,4:!0,5:!0,6:!0},ds=function(){function n(e){var t=e.tim,o=e.groupController;i(this,n),this.tim=t,this.groupController=o,this.sequencesLinkedList=new as(100),this.receivedMessageCount=0,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._joinedGroupMap=new Map,this._reportMessageStackedCount=0,this._onlineMemberCountMap=new Map,this.DEFAULT_EXPIRE_TIME=60}return a(n,[{key:"hasJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedAVChatRoom",value:function(){return this._joinedGroupMap.size>0?C(this._joinedGroupMap.keys()):null}},{key:"start",value:function(e){var t=this._pollingRequestInfoMap.get(e),n={key:t.key,startSeq:t.startSeq};if(this._pollingInstanceMap.has(e)){var o=this._pollingInstanceMap.get(e);o.isRunning()||o.start()}else{var r=this.groupController.createTransportCapsule({name:"AVChatRoom",action:"startLongPoll",param:n}),i=this.tim.connectionController.createRunLoop({pack:r,before:this._updateRequestData.bind(this,e),success:this._handleSuccess.bind(this,e),fail:this._handleFailure.bind(this),isAVChatRoomLoop:!0});i.start(),this._pollingInstanceMap.set(e,i),ie.log("AVChatRoomHandler.start message channel started. groupID=".concat(e))}}},{key:"stop",value:function(e){var t=this._pollingInstanceMap.get(e);t&&t.isRunning()&&(t.abort(),t.stop(),ie.log("AVChatRoomHandler.stop message channel stopped. groupID=".concat(e)))}},{key:"startRunLoop",value:function(e){var t=this;return this._precheck().then((function(){var n=e.longPollingKey,o=e.group,r=o.groupID;return t._pollingRequestInfoMap.set(r,{key:n,startSeq:0}),t._joinedGroupMap.set(r,o),t._addAVChatRoomID(r),t.groupController.updateGroupMap([o]),t.groupController.emitGroupListUpdate(!0,!1),t.start(r),t.groupController.isLoggedIn()?lr({status:je.SUCCESS,group:o}):lr({status:je.SUCCESS})}))}},{key:"joinWithoutAuth",value:function(e){var t=this;return this.groupController.request({name:"group",action:"applyJoinAVChatRoom",param:e}).then((function(n){var o=n.data.longPollingKey;if(ge(o))return pr(new kt({code:Ot.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN,message:gn}));ie.log("AVChatRoomHandler.joinWithoutAuth ok. groupID:".concat(e.groupID)),t.groupController.emitInnerEvent(zo),t.groupController.emitInnerEvent(Wo,e.groupID);var r=new Qi({groupID:e.groupID});return t.startRunLoop({group:r,longPollingKey:o}),new ar({status:je.SUCCESS})})).catch((function(t){return ie.error("AVChatRoomHandler.joinWithoutAuth error:".concat(Me(t),". groupID:").concat(e.groupID)),pr(t)}))}},{key:"_precheck",value:function(){if(this.tim.context.unlimitedAVChatRoom)return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();var e=M(this._joinedGroupMap.entries().next().value,2),n=e[0],o=e[1];if(this.groupController.isLoggedIn()){if(!(o.selfInfo.role===t.GRP_MBR_ROLE_OWNER||o.ownerID===this.tim.loginInfo.identifier))return this.groupController.quitGroup(n);this.groupController.deleteLocalGroupAndConversation(n)}else this.groupController.deleteLocalGroupAndConversation(n);return this.reset(n),Promise.resolve()}},{key:"_updateRequestData",value:function(e,t){var n=this._pollingRequestInfoMap.get(e),o=n.key,r=n.startSeq;t.StartSeq=r,t.Key=o,this.tim.sumStatController.addTotalCount(mr)}},{key:"_handleSuccess",value:function(e,t){this.tim.sumStatController.addSuccessCount(mr),this.tim.sumStatController.addCost(mr,t.data.timecost);var n=t.data,o=n.errorCode,r=n.errorInfo,i=n.key,s=n.nextSeq,a=n.rspMsgList;if(o!==$e.SUCCESS){var u=this._pollingRequestInfoMap.get(e),c=new kr(Mi),l=u?"".concat(u.key,"-").concat(u.startSeq):"requestInfo is undefined";c.setMessage("".concat(e,"-").concat(l,"-").concat(r||JSON.stringify(t.data))).setCode(o).setNetworkType(this.groupController.getNetworkType()).setEnd(!0)}else ue(i)&&ae(s)&&this._pollingRequestInfoMap.set(e,{key:i,startSeq:s}),pe(a)&&a.length>0&&(a.forEach((function(e){e.to=e.groupID})),this._dispatchNotice(a));this.groupController.emitInnerEvent(Uo)}},{key:"_handleFailure",value:function(e){if(e.error)if("ECONNABORTED"===e.error.code||e.error.code===Ot.NETWORK_TIMEOUT)if(e.error.config){var t=e.error.config.url,n=e.error.config.data;ie.log("AVChatRoomHandler._handleFailure request timed out. url=".concat(t," data=").concat(n))}else ie.log("AVChatRoomHandler._handleFailure request timed out");else ie.log("AVChatRoomHandler._handleFailure request failed due to network error");this.groupController.emitInnerEvent(bo)}},{key:"_dispatchNotice",value:function(n){if(pe(n)&&0!==n.length){var o=Date.now(),r=null,i=[],s=[],a=n.length;a>1&&n.sort((function(e,t){return e.sequence-t.sequence}));for(var u=0;u<a;u++)if(hs[n[u].event]){if(this.receivedMessageCount+=1,r=this.packMessage(n[u],n[u].event),this.tim.context.unlimitedAVChatRoom||!this.sequencesLinkedList.has(r.sequence)){var c=r.conversationID;if(this.receivedMessageCount%40==0&&this.tim.messageLossController.detectMessageLoss(c,this.sequencesLinkedList.data()),null!==this.sequencesLinkedList.tail()){var l=this.sequencesLinkedList.tail().value,p=r.sequence-l;p>1&&p<=20?this.tim.messageLossController.onMessageMaybeLost(c,l+1,p-1):p<-1&&p>=-20&&this.tim.messageLossController.onMessageMaybeLost(c,r.sequence+1,Math.abs(p)-1)}this.sequencesLinkedList.pushIn(r.sequence),this._isMessageSentByCurrentInstance(r)||(r.conversationType===t.CONV_SYSTEM&&s.push(r),i.push(r))}}else ie.warn("AVChatRoomHandler._dispatchMessage 未处理的 event 类型: ".concat(n[u].event));if(s.length>0&&this.groupController.emitInnerEvent(Io,{result:s,eventDataList:[],type:"poll"}),0!==i.length){var g=this.packConversationOption(i);g.length>0&&this.groupController.emitInnerEvent(yo,{eventDataList:g,type:"poll"}),ie.debug("AVChatRoomHandler._dispatchNotice nums=".concat(i.length));var h=this.tim.sumStatController;h.addTotalCount(Er),h.addSuccessCount(Er),h.addCost(Er,Date.now()-o),this._checkMessageStacked(i),this.groupController.emitOuterEvent(e.MESSAGE_RECEIVED,i)}}}},{key:"_checkMessageStacked",value:function(e){var t=e.length;t>=100&&(ie.warn("AVChatRoomHandler.checkMessageStacked 直播群消息堆积数:".concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5&&(new kr(Di).setNetworkType(this.groupController.getNetworkType()).setText("nums=".concat(t," groupID=").concat(C(this._joinedGroupMap.keys()))).setEnd(),this._reportMessageStackedCount+=1))}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this.tim.messageController.isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,n){e.currentUser=this.tim.context.identifier,e.conversationType=5===n?t.CONV_SYSTEM:t.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var o=new Kn(e),r=this.packElements(e,n);return o.setElement(r),o}},{key:"packElements",value:function(e,n){return 4===n||6===n?(this._updateMemberCountByGroupTips(e),{type:t.MSG_GRP_TIP,content:l(l({},e.elements),{},{groupProfile:e.groupProfile})}):5===n?{type:t.MSG_GRP_SYS_NOTICE,content:l(l({},e.elements),{},{groupProfile:e.groupProfile})}:this.tim.bigDataHallwayController.parseElements(e.elements,e.from)}},{key:"packConversationOption",value:function(e){for(var t=new Map,n=0;n<e.length;n++){var o=e[n],r=o.conversationID;if(t.has(r)){var i=t.get(r);i.lastMessage=o,"in"===o.flow&&i.unreadCount++}else t.set(r,{conversationID:o.conversationID,unreadCount:"out"===o.flow?0:1,type:o.conversationType,subType:o.conversationSubType,lastMessage:o})}return C(t.values())}},{key:"_addAVChatRoomID",value:function(e){var t=this.tim.loginInfo.avchatroomIDList||[];t.includes(e)||(this.tim.context.unlimitedAVChatRoom?t.push(e):t.splice(0,1,e),this.tim.loginInfo.avchatroomIDList=t)}},{key:"_deleteAVChatRoomID",value:function(e){var t=this.tim.loginInfo.avchatroomIDList||[],n=t.indexOf(e);-1!==n&&(t.splice(n,1),this.tim.loginInfo.avchatroomIDList=t)}},{key:"joinAVChatRoomSilently",value:function(){var e=this,t=this.tim.loginInfo.avchatroomIDList||[];if(0!==t.length){var n=new kr(Zr);t.forEach((function(t){e.groupController.joinGroup({groupID:t}).then((function(o){ie.warn("AVChatRoomHandler.joinAVChatRoomSilently silently join group ok:".concat(t)),n.setCode(o.code).setText("groupID=".concat(t)).setNetworkType(e.groupController.getNetworkType()).setEnd(!0)})).catch((function(o){ie.warn("AVChatRoomHandler.joinAVChatRoomSilently silently join group failed:".concat(Me(o))),n.setMessage("".concat(t,"-").concat(JSON.stringify(o))).setCode(o.code).setNetworkType(e.groupController.getNetworkType()).setEnd(!0)}))}))}}},{key:"getGroupOnlineMemberCount",value:function(e){var t=this._onlineMemberCountMap.get(e)||{},n=Date.now();return Ke(t)||n-t.lastSyncTime>1e3*t.expireTime&&n-t.latestUpdateTime>1e4&&n-t.lastReqTime>3e3?(t.lastReqTime=n,this._onlineMemberCountMap.set(e,t),this._getGroupOnlineMemberCount(e).then((function(e){return new ar({memberCount:e.memberCount})})).catch((function(e){return pr(e)}))):lr({memberCount:t.memberCount})}},{key:"_getGroupOnlineMemberCount",value:function(e){var t=this;return this.groupController.request({name:"group",action:"getOnlineMemberNum",param:{groupID:e}}).then((function(n){var o=t._onlineMemberCountMap.get(e)||{},r=n.data,i=r.onlineMemberNum,s=void 0===i?0:i,a=r.expireTime,u=void 0===a?t.DEFAULT_EXPIRE_TIME:a;ie.log("AVChatRoomHandler._getGroupOnlineMemberCount ok. groupID=".concat(e," memberCount=").concat(s," expireTime=").concat(u));var c=Date.now();return Ke(o)&&(o.lastReqTime=c),t._onlineMemberCountMap.set(e,Object.assign(o,{lastSyncTime:c,latestUpdateTime:c,memberCount:s,expireTime:u})),{memberCount:s}})).catch((function(n){return ie.warn("AVChatRoomHandler._getGroupOnlineMemberCount failed. error:".concat(Me(n))),new kr(yi).setCode(n.code).setMessage("".concat(e,"-").concat(JSON.stringify(n))).setNetworkType(t.groupController.getNetworkType()).setEnd(),Promise.reject(n)}))}},{key:"_updateMemberCountByGroupTips",value:function(e){var t=e.groupProfile.groupID,n=e.elements.onlineMemberInfo,o=void 0===n?void 0:n;if(void 0!==o){var r=o.onlineMemberNum,i=void 0===r?0:r,s=o.expireTime,a=void 0===s?this.DEFAULT_EXPIRE_TIME:s,u=this._onlineMemberCountMap.get(t)||{},c=Date.now();Ke(u)?Object.assign(u,{lastReqTime:0,lastSyncTime:0,latestUpdateTime:c,memberCount:i,expireTime:a}):(u.latestUpdateTime=c,u.memberCount=i),ie.debug("AVChatRoomHandler._updateMemberCountByGroupTips info:",u),this._onlineMemberCountMap.set(t,u)}}},{key:"reset",value:function(e){if(0!==this._pollingInstanceMap.size){if(e)ie.log("AVChatRoomHandler.reset groupID=".concat(e)),this.stop(e),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e),this._onlineMemberCountMap.delete(e);else{ie.log("AVChatRoomHandler.reset all");var t,n=D(this._pollingInstanceMap.keys());try{for(n.s();!(t=n.n()).done;){var o=t.value;this.stop(o)}}catch(r){n.e(r)}finally{n.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear(),this._onlineMemberCountMap.clear()}this.sequencesLinkedList.reset(),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._deleteAVChatRoomID(e)}}}]),n}(),ms="GroupController",fs=function(n){p(r,n);var o=I(r);function r(e){var t;return i(this,r),(t=o.call(this,e)).groupMap=new Map,t.groupMemberListMap=new Map,t.groupNoticeHandler=new gs({tim:e,groupController:v(t)}),t.groupTipsHandler=new ps({tim:e,groupController:v(t)}),t.AVChatRoomHandler=new ds({tim:e,groupController:v(t)}),t._initListeners(),t}return a(r,[{key:"createGroup",value:function(e){var n=this,o="".concat(ms,".createGroup");if(!["Public","Private","ChatRoom","AVChatRoom"].includes(e.type)){var r=new kt({code:Ot.ILLEGAL_GROUP_TYPE,message:rn});return pr(r)}Ge(e.type)&&!ge(e.memberList)&&e.memberList.length>0&&(ie.warn("".concat(o,"创建AVChatRoom时不能添加群成员,自动忽略该字段")),e.memberList=void 0),we(e.type)||ge(e.joinOption)||(ie.warn("".concat(o," 创建Work/Meeting/AVChatRoom群时不能设置字段:joinOption,自动忽略该字段")),e.joinOption=void 0);var i=new kr(Xr);return ie.log("".concat(o)),this.request({name:"group",action:"create",param:e}).then((function(r){if(i.setNetworkType(n.getNetworkType()).setText("groupType=".concat(e.type," groupID=").concat(r.data.groupID)).setEnd(),ie.log("".concat(o," ok. groupID:"),r.data.groupID),e.type===t.GRP_AVCHATROOM)return n.getGroupProfile({groupID:r.data.groupID});n.updateGroupMap([l(l({},e),{},{groupID:r.data.groupID})]);var s=n.tim.createCustomMessage({to:r.data.groupID,conversationType:t.CONV_GROUP,payload:{data:"group_create",extension:"".concat(n.tim.context.identifier,"创建群组")}});return n.tim.sendMessage(s),n.emitGroupListUpdate(),n.getGroupProfile({groupID:r.data.groupID})})).then((function(e){var n=e.data.group;return n.selfInfo.messageRemindType=t.MSG_REMIND_ACPT_AND_NOTE,n.selfInfo.role=t.GRP_MBR_ROLE_OWNER,e})).catch((function(t){return i.setText("groupType=".concat(e.type)),n.probeNetwork().then((function(e){var n=M(e,2),o=n[0],r=n[1];i.setError(t,o,r).setEnd()})),ie.error("".concat(o," error:"),t),pr(t)}))}},{key:"joinGroup",value:function(e){var n=this,o=e.groupID,r=e.type,i="".concat(ms,".joinGroup");if(r===t.GRP_WORK){var s=new kt({code:Ot.CANNOT_JOIN_WORK,message:sn});return pr(s)}if(this.hasLocalGroup(o)){if(!this.isLoggedIn())return lr({status:t.JOIN_STATUS_ALREADY_IN_GROUP});var a=new kr(Qr);return this.getGroupProfile({groupID:o}).then((function(e){return a.setNetworkType(n.getNetworkType()).setText("groupID=".concat(o," joinedStatus=").concat(t.JOIN_STATUS_ALREADY_IN_GROUP)).setEnd(),lr({status:t.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(t){return a.setNetworkType(n.getNetworkType()).setText("groupID=".concat(o," unjoined")).setEnd(),ie.warn("".concat(i," ").concat(o," was unjoined, now join!")),n.groupMap.delete(o),n.applyJoinGroup(e)}))}return ie.log("".concat(i," groupID:"),o),this.isLoggedIn()?this.applyJoinGroup(e):this.AVChatRoomHandler.joinWithoutAuth(e)}},{key:"quitGroup",value:function(e){var t=this,n="".concat(ms,".quitGroup");ie.log("".concat(n," groupID:"),e);var o=this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e);if(o&&!this.isLoggedIn())return ie.log("".concat(n," anonymously ok. groupID:"),e),this.deleteLocalGroupAndConversation(e),this.AVChatRoomHandler.reset(e),lr({groupID:e});var r=new kr(ei);return this.request({name:"group",action:"quitGroup",param:{groupID:e}}).then((function(){return r.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e)).setEnd(),ie.log("".concat(n," ok. groupID:"),e),o&&t.AVChatRoomHandler.reset(e),t.deleteLocalGroupAndConversation(e),new ar({groupID:e})})).catch((function(o){return r.setText("groupID=".concat(e)),t.probeNetwork().then((function(e){var t=M(e,2),n=t[0],i=t[1];r.setError(o,n,i).setEnd()})),ie.error("".concat(n," error. error:").concat(Me(o)," groupID:").concat(e)),pr(o)}))}},{key:"changeGroupOwner",value:function(e){var n=this,o="".concat(ms,".changeGroupOwner");if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===t.GRP_AVCHATROOM)return pr(new kt({code:Ot.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:an}));if(e.newOwnerID===this.tim.loginInfo.identifier)return pr(new kt({code:Ot.CANNOT_CHANGE_OWNER_TO_SELF,message:un}));var r=new kr(ni);return ie.log("".concat(o," groupID:"),e.groupID),this.request({name:"group",action:"changeGroupOwner",param:e}).then((function(){r.setNetworkType(n.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(),ie.log("".concat(o," ok. groupID:"),e.groupID);var t=e.groupID,i=e.newOwnerID;n.groupMap.get(t).ownerID=i;var s=n.groupMemberListMap.get(t);if(s instanceof Map){var a=s.get(n.tim.loginInfo.identifier);ge(a)||(a.updateRole("Member"),n.groupMap.get(t).selfInfo.role="Member");var u=s.get(i);ge(u)||u.updateRole("Owner")}return n.emitGroupListUpdate(!0,!1),new ar({group:n.groupMap.get(t)})})).catch((function(t){return r.setText("groupID=".concat(e.groupID)),n.probeNetwork().then((function(e){var n=M(e,2),o=n[0],i=n[1];r.setError(t,o,i).setEnd()})),ie.error("".concat(o," error:").concat(Me(t)," groupID:").concat(e.groupID)),pr(t)}))}},{key:"dismissGroup",value:function(e){var n=this,o="".concat(ms,".dismissGroup");if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===t.GRP_WORK)return pr(new kt({code:Ot.CANNOT_DISMISS_WORK,message:cn}));var r=new kr(ii);return ie.log("".concat(o," groupID:").concat(e)),this.request({name:"group",action:"destroyGroup",param:{groupID:e}}).then((function(){return r.setNetworkType(n.getNetworkType()).setText("groupID=".concat(e)).setEnd(),ie.log("".concat(o," ok. groupID:").concat(e)),n.deleteLocalGroupAndConversation(e),n.checkJoinedAVChatRoomByID(e)&&n.AVChatRoomHandler.reset(e),new ar({groupID:e})})).catch((function(t){return r.setText("groupID=".concat(e)),n.probeNetwork().then((function(e){var n=M(e,2),o=n[0],i=n[1];r.setError(t,o,i).setEnd()})),ie.error("".concat(o," error:").concat(Me(t)," groupID:").concat(e)),pr(t)}))}},{key:"updateGroupProfile",value:function(e){var t=this,n="".concat(ms,".updateGroupProfile");!this.hasLocalGroup(e.groupID)||we(this.getLocalGroupProfile(e.groupID).type)||ge(e.joinOption)||(ie.warn("".concat(n," Work/Meeting/AVChatRoom群不能设置字段:joinOption,自动忽略该字段")),e.joinOption=void 0),ge(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var o=new kr(si);return o.setText(JSON.stringify(e)),ie.log("".concat(n," groupID:"),e.groupID),this.request({name:"group",action:"updateGroupProfile",param:e}).then((function(){(o.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(n," ok. groupID:"),e.groupID),t.hasLocalGroup(e.groupID))&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList());return new ar({group:t.groupMap.get(e.groupID)})})).catch((function(r){return t.probeNetwork().then((function(e){var t=M(e,2),n=t[0],i=t[1];o.setError(r,n,i).setEnd()})),ie.log("".concat(n," failed. error:").concat(Me(r)," groupID:").concat(e.groupID)),pr(r)}))}},{key:"setGroupMemberRole",value:function(e){var n=this,o="".concat(ms,".setGroupMemberRole"),r=e.groupID,i=e.userID,s=e.role,a=this.groupMap.get(r);if(a.selfInfo.role!==t.GRP_MBR_ROLE_OWNER)return pr(new kt({code:Ot.NOT_OWNER,message:dn}));if([t.GRP_WORK,t.GRP_AVCHATROOM].includes(a.type))return pr(new kt({code:Ot.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:mn}));if([t.GRP_MBR_ROLE_ADMIN,t.GRP_MBR_ROLE_MEMBER].indexOf(s)<0)return pr(new kt({code:Ot.INVALID_MEMBER_ROLE,message:fn}));if(i===this.tim.loginInfo.identifier)return pr(new kt({code:Ot.CANNOT_SET_SELF_MEMBER_ROLE,message:_n}));var u=new kr(_i);return u.setText("groupID=".concat(r," userID=").concat(i," role=").concat(s)),ie.log("".concat(o," groupID:").concat(r,". userID: ").concat(i)),this._modifyGroupMemberInfo({groupID:r,userID:i,role:s}).then((function(e){return u.setNetworkType(n.getNetworkType()).setEnd(),ie.log("".concat(o," ok. groupID:").concat(r,". userID: ").concat(i)),new ar({group:a,member:e})})).catch((function(e){return n.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];u.setError(e,o,r).setEnd()})),ie.error("".concat(o," error:").concat(Me(e)," groupID:").concat(r," userID:").concat(i)),pr(e)}))}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,n=e.groupID,o=e.userID,r=e.muteTime,i="".concat(ms,".setGroupMemberMuteTime");if(o===this.tim.loginInfo.identifier)return pr(new kt({code:Ot.CANNOT_MUTE_SELF,message:vn}));ie.log("".concat(i," groupID:").concat(n,". userID: ").concat(o));var s=new kr(mi);return s.setText("groupID=".concat(n," userID=").concat(o," muteTime=").concat(r)),this._modifyGroupMemberInfo({groupID:n,userID:o,muteTime:r}).then((function(e){return s.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(i," ok. groupID:").concat(n,". userID: ").concat(o)),new ar({group:t.getLocalGroupProfile(n),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];s.setError(e,o,r).setEnd()})),ie.error("".concat(i," error:").concat(Me(e)," groupID:").concat(n," userID:").concat(o)),pr(e)}))}},{key:"setMessageRemindType",value:function(e){var t=this,n="".concat(ms,".setMessageRemindType"),o=new kr(ri);o.setText("groupID=".concat(e.groupID," userID=").concat(e.userID||this.tim.loginInfo.identifier)),ie.log("".concat(n," groupID:").concat(e.groupID,". userID: ").concat(e.userID||this.tim.loginInfo.identifier));var r=e.groupID,i=e.messageRemindType;return this._modifyGroupMemberInfo({groupID:r,messageRemindType:i,userID:this.tim.loginInfo.identifier}).then((function(){o.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(n," ok. groupID:").concat(e.groupID," userID:").concat(e.userID||t.tim.loginInfo.identifier));var r=t.getLocalGroupProfile(e.groupID);return r&&(r.selfInfo.messageRemindType=i),new ar({group:r})})).catch((function(r){return t.probeNetwork().then((function(e){var t=M(e,2),n=t[0],i=t[1];o.setError(r,n,i).setEnd()})),ie.error("".concat(n," error:").concat(Me(r)," groupID:").concat(e.groupID," userID:").concat(e.userID||t.tim.loginInfo.identifier)),pr(r)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,n="".concat(ms,".setGroupMemberNameCard"),o=e.groupID,r=e.userID,i=void 0===r?this.tim.loginInfo.identifier:r,s=e.nameCard;ie.log("".concat(n," groupID:").concat(o,". userID: ").concat(i));var a=new kr(fi);return a.setText("groupID=".concat(o," userID=").concat(i," nameCard=").concat(s)),this._modifyGroupMemberInfo({groupID:o,userID:i,nameCard:s}).then((function(e){ie.log("".concat(n," ok. groupID:").concat(o,". userID: ").concat(i)),a.setNetworkType(t.getNetworkType()).setEnd();var r=t.getLocalGroupProfile(o);return i===t.tim.loginInfo.identifier&&r&&r.setSelfNameCard(s),new ar({group:r,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];a.setError(e,o,r).setEnd()})),ie.error("".concat(n," error:").concat(Me(e)," groupID:").concat(o," userID:").concat(i)),pr(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,n="".concat(ms,".setGroupMemberCustomField"),o=e.groupID,r=e.userID,i=void 0===r?this.tim.loginInfo.identifier:r,s=e.memberCustomField;ie.log("".concat(n," groupID:").concat(o,". userID: ").concat(i));var a=new kr(vi);return a.setText("groupID=".concat(o," userID=").concat(i," memberCustomField=").concat(s)),this._modifyGroupMemberInfo({groupID:o,userID:i,memberCustomField:s}).then((function(e){return a.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(n," ok. groupID:").concat(o,". userID: ").concat(i)),new ar({group:t.groupMap.get(o),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];a.setError(e,o,r).setEnd()})),ie.error("".concat(n," error:").concat(Me(e)," groupID:").concat(o," userID:").concat(i)),pr(e)}))}},{key:"getGroupList",value:function(e){var t=this,n="".concat(ms,".getGroupList"),o=new kr(ai);ie.log("".concat(n));var r={introduction:"Introduction",notification:"Notification",createTime:"CreateTime",ownerID:"Owner_Account",lastInfoTime:"LastInfoTime",memberNum:"MemberNum",maxMemberNum:"MaxMemberNum",joinOption:"ApplyJoinOption",muteAllMembers:"ShutUpAllMember"},i=["Type","Name","FaceUrl","NextMsgSeq","LastMsgTime"];return e&&e.groupProfileFilter&&e.groupProfileFilter.forEach((function(e){r[e]&&i.push(r[e])})),this.request({name:"group",action:"list",param:{responseFilter:{groupBaseInfoFilter:i,selfInfoFilter:["Role","JoinTime","MsgFlag"]}}}).then((function(e){var r=e.data.groups;return ie.log("".concat(n," ok. nums=").concat(r.length)),t._groupListTreeShaking(r),t.updateGroupMap(r),o.setNetworkType(t.getNetworkType()).setText("".concat(r.length,"-afterTreeshaking-").concat(t.groupMap.size)).setEnd(),t.tempConversationList&&(ie.log("".concat(n," update last message with tempConversationList, nums=").concat(t.tempConversationList.length)),t._handleUpdateGroupLastMessage({data:t.tempConversationList}),t.tempConversationList=null),t.emitGroupListUpdate(),new ar({groupList:t.getLocalGroups()})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),r=n[0],i=n[1];o.setError(e,r,i).setEnd()})),ie.error("".concat(n," error:"),e),pr(e)}))}},{key:"getGroupMemberList",value:function(e){var t=this,n=e.groupID,o=e.offset,r=void 0===o?0:o,i=e.count,s=void 0===i?15:i,a="".concat(ms,".getGroupMemberList"),u=new kr(pi);ie.log("".concat(a," groupID: ").concat(n," offset: ").concat(r," count: ").concat(s));var c=[];return this.request({name:"group",action:"getGroupMemberList",param:{groupID:n,offset:r,limit:s>100?100:s,memberInfoFilter:["Role","NameCard","ShutUpUntil"]}}).then((function(e){var o=e.data,r=o.members,i=o.memberNum;return pe(r)&&0!==r.length?(t.hasLocalGroup(n)&&(t.getLocalGroupProfile(n).memberNum=i),c=t._updateLocalGroupMemberMap(n,r),t.tim.getUserProfile({userIDList:r.map((function(e){return e.userID})),tagList:[gt.NICK,gt.AVATAR]})):Promise.resolve([])})).then((function(e){var o=e.data;if(!pe(o)||0===o.length)return lr({memberList:[]});var i=o.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(n,i),u.setNetworkType(t.getNetworkType()).setText("groupID=".concat(n," offset=").concat(r," count=").concat(s)).setEnd(),ie.log("".concat(a," ok.")),new ar({memberList:c})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];u.setError(e,o,r).setEnd()})),ie.error("".concat(a," error:"),e),pr(e)}))}},{key:"getLocalGroups",value:function(){return C(this.groupMap.values())}},{key:"getLocalGroupProfile",value:function(e){return this.groupMap.get(e)}},{key:"hasLocalGroup",value:function(e){return this.groupMap.has(e)}},{key:"getLocalGroupMemberInfo",value:function(e,t){return this.groupMemberListMap.has(e)?this.groupMemberListMap.get(e).get(t):null}},{key:"setLocalGroupMember",value:function(e,t){if(this.groupMemberListMap.has(e))this.groupMemberListMap.get(e).set(t.userID,t);else{var n=(new Map).set(t.userID,t);this.groupMemberListMap.set(e,n)}}},{key:"hasLocalGroupMember",value:function(e,t){return this.groupMemberListMap.has(e)&&this.groupMemberListMap.get(e).has(t)}},{key:"hasLocalGroupMemberMap",value:function(e){return this.groupMemberListMap.has(e)}},{key:"getGroupProfile",value:function(e){var t=this,n="".concat(ms,".getGroupProfile"),o=new kr(ui);ie.log("".concat(n," groupID:"),e.groupID);var r=e.groupID,i=e.groupCustomFieldFilter,s={groupIDList:[r],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:i}};return this.getGroupProfileAdvance(s).then((function(i){var s,a=i.data,u=a.successGroupList,c=a.failureGroupList;return ie.log("".concat(n," ok. groupID:").concat(e.groupID)),c.length>0?pr(c[0]):(Ge(u[0].type)&&!t.hasLocalGroup(r)?s=new Qi(u[0]):(t.updateGroupMap(u),s=t.getLocalGroupProfile(r)),o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(s.groupID," type=").concat(s.type," muteAllMembers=").concat(s.muteAllMembers," ownerID=").concat(s.ownerID)).setEnd(),s&&s.selfInfo&&!s.selfInfo.nameCard?t.updateSelfInfo(s).then((function(e){return new ar({group:e})})):new ar({group:s}))})).catch((function(r){return t.probeNetwork().then((function(t){var n=M(t,2),i=n[0],s=n[1];o.setError(r,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),ie.error("".concat(n," error:").concat(Me(r)," groupID:").concat(e.groupID)),pr(r)}))}},{key:"getGroupMemberProfile",value:function(e){var t=this,n="".concat(ms,".getGroupMemberProfile"),o=new kr(gi);o.setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)),ie.log("".concat(n," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var r=e.groupID,i=e.userIDList;return this._getGroupMemberProfileAdvance(l(l({},e),{},{userIDList:i})).then((function(e){var n=e.data.members;return pe(n)&&0!==n.length?(t._updateLocalGroupMemberMap(r,n),t.tim.getUserProfile({userIDList:n.map((function(e){return e.userID})),tagList:[gt.NICK,gt.AVATAR]})):lr([])})).then((function(e){var n=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));t._updateLocalGroupMemberMap(r,n);var s=i.filter((function(e){return t.hasLocalGroupMember(r,e)})).map((function(e){return t.getLocalGroupMemberInfo(r,e)}));return o.setNetworkType(t.getNetworkType()).setEnd(),new ar({memberList:s})}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({name:"group",action:"getGroupMemberProfile",param:l(l({},e),{},{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"updateSelfInfo",value:function(e){var t="".concat(ms,".updateSelfInfo"),n=e.groupID;ie.log("".concat(t," groupID:"),n);var o={groupID:n,userIDList:[this.tim.loginInfo.identifier]};return this.getGroupMemberProfile(o).then((function(o){var r=o.data.memberList;return ie.log("".concat(t," ok. groupID:"),n),e&&0!==r.length&&e.updateSelfInfo(r[0]),e}))}},{key:"addGroupMember",value:function(e){var t=this,n="".concat(ms,".addGroupMember"),o=new kr(hi);o.setText("groupID=".concat(e.groupID));var r=this.getLocalGroupProfile(e.groupID);if(Ge(r.type)){var i=new kt({code:Ot.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:pn});return o.setCode(Ot.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setMessage(pn).setNetworkType(this.getNetworkType()).setText("groupID=".concat(e.groupID," groupType=").concat(r.type)).setEnd(),pr(i)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),ie.log("".concat(n," groupID:"),e.groupID),this.request({name:"group",action:"addGroupMember",param:e}).then((function(i){var s=i.data.members;o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(),ie.log("".concat(n," ok. groupID:"),e.groupID);var a=s.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),u=s.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),c=s.filter((function(e){return 2===e.result})).map((function(e){return e.userID}));return 0===a.length?new ar({successUserIDList:a,failureUserIDList:u,existedUserIDList:c}):(r.memberNum+=a.length,new ar({successUserIDList:a,failureUserIDList:u,existedUserIDList:c,group:r}))})).catch((function(r){return t.probeNetwork().then((function(t){var n=M(t,2),i=n[0],s=n[1];o.setError(r,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),ie.error("".concat(n," error:").concat(Me(r)," groupID:").concat(e.groupID)),pr(r)}))}},{key:"deleteGroupMember",value:function(e){var n=this,o="".concat(ms,".deleteGroupMember"),r=new kr(di);r.setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)),ie.log("".concat(o," groupID:").concat(e.groupID," userIDList:").concat(e.userIDList));var i=this.getLocalGroupProfile(e.groupID);return i.type===t.GRP_AVCHATROOM?pr(new kt({code:Ot.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:hn})):this.request({name:"group",action:"deleteGroupMember",param:e}).then((function(){return r.setNetworkType(n.getNetworkType()).setEnd(),ie.log("".concat(o," ok")),i.memberNum--,n.deleteLocalGroupMembers(e.groupID,e.userIDList),new ar({group:i,userIDList:e.userIDList})})).catch((function(t){return n.probeNetwork().then((function(n){var o=M(n,2),i=o[0],s=o[1];r.setError(t,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),ie.error("".concat(o," error:").concat(Me(t)," groupID:").concat(e.groupID)),pr(t)}))}},{key:"searchGroupByID",value:function(e){var t=this,n="".concat(ms,".searchGroupByID"),o={groupIDList:[e]},r=new kr(ti);return r.setText("groupID=".concat(e)),ie.log("".concat(n," groupID:").concat(e)),this.request({name:"group",action:"searchGroupByID",param:o}).then((function(o){var i=o.data.groupProfile;if(i[0].errorCode!==$e.SUCCESS)throw new kt({code:i[0].errorCode,message:i[0].errorInfo});return r.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(n," ok. groupID:").concat(e)),new ar({group:new Qi(i[0])})})).catch((function(o){return t.probeNetwork().then((function(e){var t=M(e,2),n=t[0],i=t[1];r.setError(o,n,i).setEnd()})),ie.warn("".concat(n," error:").concat(Me(o)," groupID:").concat(e)),pr(o)}))}},{key:"applyJoinGroup",value:function(e){var t=this,n="".concat(ms,".applyJoinGroup"),o=new kr(Qr);return this.request({name:"group",action:"applyJoinGroup",param:e}).then((function(r){var i=r.data,s=i.joinedStatus,a=i.longPollingKey;switch(o.setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID," joinedStatus=").concat(s)).setEnd(),ie.log("".concat(n," ok. groupID:").concat(e.groupID," joinedStatus:").concat(s," longPollingKey:").concat(a)),s){case je.WAIT_APPROVAL:return new ar({status:je.WAIT_APPROVAL});case je.SUCCESS:return t.getGroupProfile({groupID:e.groupID}).then((function(n){var o=n.data.group,r={status:je.SUCCESS,group:o};return ge(a)?(t.emitGroupListUpdate(!0,!1),new ar(r)):(t.emitInnerEvent(Wo,e.groupID),t.AVChatRoomHandler.startRunLoop({longPollingKey:a,group:o}))}));default:var u=new kt({code:Ot.JOIN_GROUP_FAIL,message:ln});return ie.error("".concat(n," error:").concat(Me(u)," groupID:").concat(e.groupID)),pr(u)}})).catch((function(r){return o.setText("groupID=".concat(e.groupID)),t.probeNetwork().then((function(e){var t=M(e,2),n=t[0],i=t[1];o.setError(r,n,i).setEnd()})),ie.error("".concat(n," error:").concat(Me(r)," groupID:").concat(e.groupID)),pr(r)}))}},{key:"applyJoinAVChatRoom",value:function(e){return this.AVChatRoomHandler.applyJoinAVChatRoom(e)}},{key:"handleGroupApplication",value:function(e){var t=this,n="".concat(ms,".handleGroupApplication"),o=e.message.payload,r=o.groupProfile.groupID,i=o.authentication,s=o.messageKey,a=o.operatorID,u=new kr(oi);return u.setText("groupID=".concat(r)),ie.log("".concat(n," groupID:"),r),this.request({name:"group",action:"handleApplyJoinGroup",param:l(l({},e),{},{applicant:a,groupID:r,authentication:i,messageKey:s})}).then((function(){return u.setNetworkType(t.getNetworkType()).setEnd(),ie.log("".concat(n," ok. groupID:"),r),t.deleteGroupSystemNotice({messageList:[e.message]}),new ar({group:t.getLocalGroupProfile(r)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];u.setError(e,o,r).setEnd()})),ie.error("".concat(n," error. error:").concat(Me(e)," groupID:").concat(r)),pr(e)}))}},{key:"deleteGroupSystemNotice",value:function(e){var n=this,o="".concat(ms,".deleteGroupSystemNotice");return pe(e.messageList)&&0!==e.messageList.length?(ie.log("".concat(o)+e.messageList.map((function(e){return e.ID}))),this.request({name:"group",action:"deleteGroupSystemNotice",param:{messageListToDelete:e.messageList.map((function(e){return{from:t.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){return ie.log("".concat(o," ok")),e.messageList.forEach((function(e){n.tim.messageController.deleteLocalMessage(e)})),new ar})).catch((function(e){return ie.error("".concat(o," error:"),e),pr(e)}))):lr()}},{key:"getGroupProfileAdvance",value:function(e){var t="".concat(ms,".getGroupProfileAdvance");return pe(e.groupIDList)&&e.groupIDList.length>50&&(ie.warn("".concat(t," 获取群资料的数量不能超过50个")),e.groupIDList.length=50),ie.log("".concat(t," groupIDList:"),e.groupIDList),this.request({name:"group",action:"query",param:e}).then((function(e){ie.log("".concat(t," ok."));var n=e.data.groups,o=n.filter((function(e){return ge(e.errorCode)||e.errorCode===$e.SUCCESS})),r=n.filter((function(e){return e.errorCode&&e.errorCode!==$e.SUCCESS})).map((function(e){return new kt({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}));return new ar({successGroupList:o,failureGroupList:r})})).catch((function(n){return ie.error("".concat(t," error:").concat(Me(n)," groupIDList:").concat(e.groupIDList)),pr(n)}))}},{key:"_deleteLocalGroup",value:function(e){return this.groupMap.delete(e),this.groupMemberListMap.delete(e),this._setStorageGroupList(),this.groupMap.has(e)&&this.groupMemberListMap.has(e)}},{key:"_initGroupList",value:function(){var e=this,t="".concat(ms,"._initGroupList"),n=new kr(ci);ie.time(Dr),ie.log("".concat(t));var o=this._getStorageGroupList();pe(o)&&o.length>0?(o.forEach((function(t){e.groupMap.set(t.groupID,new Qi(t))})),this.emitGroupListUpdate(!0,!1),n.setNetworkType(this.getNetworkType()).setText(this.groupMap.size).setEnd()):n.setNetworkType(this.getNetworkType()).setText(0).setEnd(),this.triggerReady(),ie.log("".concat(t," ok. initCost=").concat(ie.timeEnd(Dr),"ms")),this.getGroupList()}},{key:"_initListeners",value:function(){var e=this.tim.innerEmitter;e.once(lo,this._initGroupList,this),e.on(Bo,this._handleUpdateGroupLastMessage,this),e.on(yo,this._handleReceivedGroupMessage,this),e.on(Yo,this._handleProfileUpdated,this)}},{key:"emitGroupListUpdate",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.getLocalGroups();n&&this.emitInnerEvent(qo,o),t&&this.emitOuterEvent(e.GROUP_LIST_UPDATED,o)}},{key:"_handleReceivedGroupMessage",value:function(e){var n=this,o=e.data.eventDataList;Array.isArray(o)&&o.forEach((function(e){var o=e.conversationID.replace(t.CONV_GROUP,"");n.groupMap.has(o)&&(n.groupMap.get(o).nextMessageSeq=e.lastMessage.sequence+1)}))}},{key:"_onReceivedGroupSystemNotice",value:function(e){var t=e.data;this.groupNoticeHandler._onReceivedGroupNotice(t)}},{key:"_handleUpdateGroupLastMessage",value:function(e){var n="".concat(ms,"._handleUpdateGroupLastMessage"),o=e.data;if(ie.log("".concat(n," convNums=").concat(o.length," groupNums=").concat(this.groupMap.size)),0!==this.groupMap.size){for(var r,i,s,a=!1,u=0,c=o.length;u<c;u++)(r=o[u]).conversationID&&r.type!==t.CONV_GROUP&&(i=r.conversationID.split(/^GROUP/)[1],(s=this.getLocalGroupProfile(i))&&(s.lastMessage=r.lastMessage,a=!0));a&&(this.groupMap=this._sortLocalGroupList(this.groupMap),this.emitGroupListUpdate(!0,!1))}else this.tempConversationList=o}},{key:"_sortLocalGroupList",value:function(e){var t=C(e).filter((function(e){var t=M(e,2);t[0];return!Ke(t[1].lastMessage)}));return t.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),new Map([].concat(C(t),C(e)))}},{key:"_getStorageGroupList",value:function(){return this.tim.storage.getItem("groupMap")}},{key:"_setStorageGroupList",value:function(){var e=this.getLocalGroups().filter((function(e){var t=e.type;return!Ge(t)})).slice(0,20).map((function(e){return{groupID:e.groupID,name:e.name,avatar:e.avatar,type:e.type}}));this.tim.storage.setItem("groupMap",e)}},{key:"updateGroupMap",value:function(e){var t=this;e.forEach((function(e){t.groupMap.has(e.groupID)?t.groupMap.get(e.groupID).updateGroup(e):t.groupMap.set(e.groupID,new Qi(e))})),this._setStorageGroupList()}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var n=this;return pe(t)&&0!==t.length?t.map((function(t){return n.hasLocalGroupMember(e,t.userID)?n.getLocalGroupMemberInfo(e,t.userID).updateMember(t):n.setLocalGroupMember(e,new ls(t)),n.getLocalGroupMemberInfo(e,t.userID)})):[]}},{key:"deleteLocalGroupMembers",value:function(e,t){var n=this.groupMemberListMap.get(e);n&&t.forEach((function(e){n.delete(e)}))}},{key:"_modifyGroupMemberInfo",value:function(e){var t=this,n=e.groupID,o=e.userID;return this.request({name:"group",action:"modifyGroupMemberInfo",param:e}).then((function(){if(t.hasLocalGroupMember(n,o)){var r=t.getLocalGroupMemberInfo(n,o);return ge(e.muteTime)||r.updateMuteUntil(e.muteTime),ge(e.role)||r.updateRole(e.role),ge(e.nameCard)||r.updateNameCard(e.nameCard),ge(e.memberCustomField)||r.updateMemberCustomField(e.memberCustomField),r}return t.getGroupMemberProfile({groupID:n,userIDList:[o]}).then((function(e){return M(e.data.memberList,1)[0]}))}))}},{key:"_groupListTreeShaking",value:function(e){for(var t=new Map(C(this.groupMap)),n=0,o=e.length;n<o;n++)t.delete(e[n].groupID);this.AVChatRoomHandler.hasJoinedAVChatRoom()&&this.AVChatRoomHandler.getJoinedAVChatRoom().forEach((function(e){t.delete(e)}));for(var r=C(t.keys()),i=0,s=r.length;i<s;i++)this.groupMap.delete(r[i])}},{key:"_handleProfileUpdated",value:function(e){for(var t=this,n=e.data,o=function(e){var o=n[e];t.groupMemberListMap.forEach((function(e){e.has(o.userID)&&e.get(o.userID).updateMember({nick:o.nick,avatar:o.avatar})}))},r=0;r<n.length;r++)o(r)}},{key:"getJoinedAVChatRoom",value:function(){return this.AVChatRoomHandler.getJoinedAVChatRoom()}},{key:"deleteLocalGroupAndConversation",value:function(e){this._deleteLocalGroup(e),this.tim.conversationController.deleteLocalConversation("GROUP".concat(e)),this.emitGroupListUpdate(!0,!1)}},{key:"checkJoinedAVChatRoomByID",value:function(e){return this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e)}},{key:"getGroupLastSequence",value:function(e){var t=this,n="".concat(ms,".getGroupLastSequence"),o=new kr(li),r=0;if(this.hasLocalGroup(e)){var i=this.getLocalGroupProfile(e);if(i.lastMessage.lastSequence>0)return r=i.lastMessage.lastSequence,ie.log("".concat(n," got lastSequence=").concat(r," from local group profile[lastMessage.lastSequence]. groupID=").concat(e)),o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r," from local group profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(),Promise.resolve(r);if(i.nextMessageSeq>1)return r=i.nextMessageSeq-1,ie.log("".concat(n," got lastSequence=").concat(r," from local group profile[nextMessageSeq]. groupID=").concat(e)),o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r," from local group profile[nextMessageSeq]. groupID=").concat(e)).setEnd(),Promise.resolve(r)}var s="GROUP".concat(e),a=this.tim.conversationController.getLocalConversation(s);if(a&&a.lastMessage.lastSequence)return r=a.lastMessage.lastSequence,ie.log("".concat(n," got lastSequence=").concat(r," from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)),o.setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(r," from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(),Promise.resolve(r);var u={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(u).then((function(i){var s=i.data.successGroupList;return Ke(s)?ie.log("".concat(n," successGroupList is empty. groupID=").concat(e)):(r=s[0].nextMessageSeq-1,ie.log("".concat(n," got lastSequence=").concat(r," from getGroupProfileAdvance. groupID=").concat(e))),o.setNetworkType(t.getNetworkType()).setText("got lastSequence=".concat(r," from getGroupProfileAdvance. groupID=").concat(e)).setEnd(),r})).catch((function(r){return t.probeNetwork().then((function(t){var n=M(t,2),i=n[0],s=n[1];o.setError(r,i,s).setText("get lastSequence failed from getGroupProfileAdvance. groupID=".concat(e)).setEnd()})),ie.warn("".concat(n," failed. ").concat(r)),pr(r)}))}},{key:"getGroupOnlineMemberCount",value:function(e){return this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e)?this.AVChatRoomHandler.getGroupOnlineMemberCount(e):lr({memberCount:0})}},{key:"reset",value:function(){this.groupMap.clear(),this.groupMemberListMap.clear(),this.resetReady(),this.groupNoticeHandler.reset(),this.AVChatRoomHandler.reset(),this.tim.innerEmitter.once(lo,this._initGroupList,this)}}]),r}(rr),_s=function(n){p(r,n);var o=I(r);function r(e){var n;i(this,r),(n=o.call(this,e)).REALTIME_MESSAGE_TIMEOUT=3e5,n.LONGPOLLING_ID_TIMEOUT=3e5,n._currentState=t.NET_STATE_CONNECTED,n._status={OPENIM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0},AVCHATROOM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0}};var s=n.tim.innerEmitter;return s.on(Co,n._onGetLongPollIDFailed,v(n)),s.on(To,n._onOpenIMResponseOK,v(n)),s.on(Eo,n._onOpenIMRequestFailed,v(n)),s.on(Uo,n._onAVChatroomResponseOK,v(n)),s.on(bo,n._onAVChatroomRequestFailed,v(n)),n}return a(r,[{key:"_onGetLongPollIDFailed",value:function(){this._currentState!==t.NET_STATE_DISCONNECTED&&this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}},{key:"_onOpenIMResponseOK",value:function(){this._onResponseOK("OPENIM")}},{key:"_onOpenIMRequestFailed",value:function(){this._onRequestFailed("OPENIM")}},{key:"_onAVChatroomResponseOK",value:function(){this.isLoggedIn()||this._onResponseOK("AVCHATROOM")}},{key:"_onAVChatroomRequestFailed",value:function(){this.isLoggedIn()||this._onRequestFailed("AVCHATROOM")}},{key:"_onResponseOK",value:function(e){var n=this._status[e],o=Date.now();if(0!==n.lastResponseReceivedTime){var r=o-n.lastResponseReceivedTime;ie.debug("StatusController._onResponseOK key=".concat(e," currentState=").concat(this._currentState," interval=").concat(r," failedCount=").concat(n.failedCount," jitterCount=").concat(n.jitterCount)),n.failedCount>0&&(n.failedCount=0,n.jitterCount+=1,this._currentState!==t.NET_STATE_CONNECTED&&this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED));r<=this.LONGPOLLING_ID_TIMEOUT?n.jitterCount>=3&&(new kr(Ci).setText("".concat(e,"-").concat(r,"-").concat(n.jitterCount)).setNetworkType(this.getNetworkType()).setEnd(),n.jitterCount=0):(new kr(Ei).setText("".concat(e,"-").concat(r)).setNetworkType(this.getNetworkType()).setEnd(),ie.warn("StatusController._onResponseOK, sdk reload. key=".concat(e," interval=").concat(r,"ms. https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/module-EVENT.html#.SDK_RELOAD")),this.emitInnerEvent(Xo)),n.lastResponseReceivedTime=o}else n.lastResponseReceivedTime=o}},{key:"_onRequestFailed",value:function(e){var n=this,o=this._status[e];Date.now()-o.lastResponseReceivedTime>=this.LONGPOLLING_ID_TIMEOUT?this._currentState!==t.NET_STATE_DISCONNECTED&&(ie.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable more than 5min. key=".concat(e," networkType=").concat(this.getNetworkType())),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)):(o.failedCount+=1,o.failedCount>5?this.probeNetwork().then((function(r){var i=M(r,2),s=i[0],a=i[1];s?(n._currentState!==t.NET_STATE_CONNECTING&&n._emitNetStateChangeEvent(t.NET_STATE_CONNECTING),ie.warn("StatusController._onRequestFailed, connecting, network jitter. key=".concat(e," networkType=").concat(a))):(n._currentState!==t.NET_STATE_DISCONNECTED&&n._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED),ie.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable. key=".concat(e," networkType=").concat(a))),o.failedCount=0,o.jitterCount=0})):this._currentState===t.NET_STATE_CONNECTED&&this._emitNetStateChangeEvent(t.NET_STATE_CONNECTING))}},{key:"_emitNetStateChangeEvent",value:function(t){ie.log("StatusController._emitNetStateChangeEvent net state changed from ".concat(this._currentState," to ").concat(t)),this._currentState=t,this.emitOuterEvent(e.NET_STATE_CHANGE,{state:t})}},{key:"reset",value:function(){ie.log("StatusController.reset"),this._currentState=t.NET_STATE_CONNECTED,this._status={OPENIM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0},AVCHATROOM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0}}}}]),r}(rr);function vs(){return null}var ys=function(){function e(t){i(this,e),this.tim=t,this.isWX=P,this.storageQueue=new Map,this.checkTimes=0,this.checkTimer=setInterval(this._onCheckTimer.bind(this),1e3),this._errorTolerantHandle()}return a(e,[{key:"_errorTolerantHandle",value:function(){!this.isWX&&ge(window.localStorage)&&(this.getItem=vs,this.setItem=vs,this.removeItem=vs,this.clear=vs)}},{key:"_onCheckTimer",value:function(){if(this.checkTimes++,this.checkTimes%20==0){if(0===this.storageQueue.size)return;this._doFlush()}}},{key:"_doFlush",value:function(){try{var e,t=D(this.storageQueue);try{for(t.s();!(e=t.n()).done;){var n=M(e.value,2),o=n[0],r=n[1];this.isWX?wx.setStorageSync(this._getKey(o),r):localStorage.setItem(this._getKey(o),JSON.stringify(r))}}catch(i){t.e(i)}finally{t.f()}this.storageQueue.clear()}catch(s){ie.warn("Storage._doFlush error",s)}}},{key:"_getPrefix",value:function(){var e=this.tim.loginInfo,t=e.SDKAppID,n=e.identifier;return"TIM_".concat(t,"_").concat(n,"_")}},{key:"getItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;return this.isWX?wx.getStorageSync(n):JSON.parse(localStorage.getItem(n))}catch(o){ie.warn("Storage.getItem error:",o)}}},{key:"setItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(n){var r=o?this._getKey(e):e;this.isWX?wx.setStorageSync(r,t):localStorage.setItem(r,JSON.stringify(t))}else this.storageQueue.set(e,t)}},{key:"clear",value:function(){try{this.isWX?wx.clearStorageSync():localStorage.clear()}catch(e){ie.warn("Storage.clear error:",e)}}},{key:"removeItem",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];try{var n=t?this._getKey(e):e;this.isWX?wx.removeStorageSync(n):localStorage.removeItem(n)}catch(o){ie.warn("Storage.removeItem error:",o)}}},{key:"getSize",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"b";try{var o={size:0,limitSize:5242880,unit:n};if(Object.defineProperty(o,"leftSize",{enumerable:!0,get:function(){return o.limitSize-o.size}}),this.isWX&&(o.limitSize=1024*wx.getStorageInfoSync().limitSize),e)o.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(this.isWX){var r=wx.getStorageInfoSync(),i=r.keys;i.forEach((function(e){o.size+=JSON.stringify(wx.getStorageSync(e)).length+t._getKey(e).length}))}else for(var s in localStorage)localStorage.hasOwnProperty(s)&&(o.size+=localStorage.getItem(s).length+s.length);return this._convertUnit(o)}catch(a){ie.warn("Storage.getSize error:",a)}}},{key:"_convertUnit",value:function(e){var t={},n=e.unit;for(var o in t.unit=n,e)"number"==typeof e[o]&&("kb"===n.toLowerCase()?t[o]=Math.round(e[o]/1024):"mb"===n.toLowerCase()?t[o]=Math.round(e[o]/1024/1024):t[o]=e[o]);return t}},{key:"_getKey",value:function(e){return"".concat(this._getPrefix()).concat(e)}},{key:"reset",value:function(){this._doFlush(),this.checkTimes=0}}]),e}(),Is=O((function(e){var t=Object.prototype.hasOwnProperty,n="~";function o(){}function r(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,o,i,s){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new r(o,i||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,o,r=[];if(0===this._eventsCount)return r;for(o in e=this._events)t.call(e,o)&&r.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},a.prototype.listeners=function(e){var t=n?n+e:e,o=this._events[t];if(!o)return[];if(o.fn)return[o.fn];for(var r=0,i=o.length,s=new Array(i);r<i;r++)s[r]=o[r].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,o=this._events[t];return o?o.fn?1:o.length:0},a.prototype.emit=function(e,t,o,r,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,o),!0;case 4:return l.fn.call(l.context,t,o,r),!0;case 5:return l.fn.call(l.context,t,o,r,i),!0;case 6:return l.fn.call(l.context,t,o,r,i,s),!0}for(c=1,u=new Array(p-1);c<p;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var g,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),p){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,o);break;case 4:l[c].fn.call(l[c].context,t,o,r);break;default:if(!u)for(g=1,u=new Array(p-1);g<p;g++)u[g-1]=arguments[g];l[c].fn.apply(l[c].context,u)}}return!0},a.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,o,r){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||r&&!a.once||o&&a.context!==o||s(this,i);else{for(var u=0,c=[],l=a.length;u<l;u++)(a[u].fn!==t||r&&!a[u].once||o&&a[u].context!==o)&&c.push(a[u]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a}));function Ms(e){var t=e.context||null;return{platform:Zn,websdkappid:Qn,v:Xn,a2:t&&t.a2Key||void 0,tinyid:t&&t.tinyID||void 0,sdkappid:t&&t.SDKAppID||0,contentType:t&&t.contentType||0,apn:t&&t.apn||1,accounttype:t&&t.accountType||0}}var Cs=function(){function e(t){i(this,e),this.tim=t,this.tim.innerEmitter.on(uo,this._update,this),this.tim.innerEmitter.on(co,this._update,this),this.tim.innerEmitter.on(po,this._updateSpecifiedConfig,this),this._initConfig()}return a(e,[{key:"_update",value:function(e){this._initConfig()}},{key:"_updateSpecifiedConfig",value:function(e){var t=this;e.data.forEach((function(e){t._set(e)}))}},{key:"get",value:function(e){var t=e.name,o=e.action,r=e.param,i=e.tjgID;if(ge(this.config[t])||ge(this.config[t][o]))throw new kt({code:Ot.NETWORK_PACKAGE_UNDEFINED,message:"".concat(kn,": PackageConfig.").concat(t)});var s=function e(t){if(0===Object.getOwnPropertyNames(t).length)return Object.create(null);var o=Array.isArray(t)?[]:Object.create(null),r="";for(var i in t)null!==t[i]?void 0!==t[i]?(r=n(t[i]),["string","number","function","boolean"].indexOf(r)>=0?o[i]=t[i]:o[i]=e(t[i])):o[i]=void 0:o[i]=null;return o}(this.config[t][o]);return s.requestData=this._initRequestData(r,s),s.encode=this._initEncoder(s),s.decode=this._initDecoder(s),i&&(s.queryString.tjg_id=i),s}},{key:"_set",value:function(e){var t=e.key,o=e.value;if(!1!=!!t){var r=t.split(".");if(!(r.length<=0)){!function e(t,o,r,i){var s=o[r];"object"===n(t[s])?e(t[s],o,r+1,i):t[s]=i}(this.config,r,0,o)}}}},{key:"_initConfig",value:function(){var e;this.config={},this.config.accessLayer=(e=this.tim,{create:null,query:{serverName:so.NAME.WEB_IM,cmd:so.CMD.ACCESS_LAYER,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:l(l({},Ms(e)),{},{identifier:e.context.identifier,usersig:e.context.userSig}),requestData:{}},update:null,delete:null}),this.config.login=function(e){return{create:null,query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.LOGIN,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:l(l({},Ms(e)),{},{identifier:e.loginInfo.identifier,usersig:e.loginInfo.userSig,sdkappid:e.loginInfo.SDKAppID,accounttype:e.loginInfo.accountType,reqtime:+new Date/1e3}),requestData:{state:"Online"},keyMaps:{request:{tinyID:"tinyId"},response:{TinyId:"tinyID"}}},update:null,delete:null}}(this.tim),this.config.logout=function(e){return{create:null,query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.LOGOUT_ALL,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:l(l({},Ms(e)),{},{reqtime:+new Date/1e3}),requestData:{}},update:null,delete:null}}(this.tim),this.config.longPollLogout=function(e){return{create:null,query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.LOGOUT_LONG_POLL,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:l(l({},Ms(e)),{},{reqtime:+new Date}),requestData:{longPollID:""},keyMaps:{request:{longPollID:"LongPollingId"}}},update:null,delete:null}}(this.tim),this.config.profile=function(e){var t=Ms(e),n={serverName:so.NAME.PROFILE,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{query:l(l({},n),{},{cmd:so.CMD.PORTRAIT_GET,requestData:{fromAccount:"",userItem:[]},keyMaps:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),update:l(l({},n),{},{cmd:so.CMD.PORTRAIT_SET,requestData:{fromAccount:"",profileItem:[{tag:gt.NICK,value:""},{tag:gt.GENDER,value:""},{tag:gt.ALLOWTYPE,value:""},{tag:gt.AVATAR,value:""}]}})}}(this.tim),this.config.group=function(e){var n=e.context.login===Ye.IS_LOGIN||e.context.a2Key?so.NAME.GROUP:so.NAME.BIG_GROUP_NO_AUTH,o=Ms(e),r={request:{ownerID:"Owner_Account",userID:"Member_Account",newOwnerID:"NewOwner_Account",maxMemberNum:"MaxMemberCount",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember",messageRemindType:"MsgFlag",userIDList:"MemberList",groupIDList:"GroupIdList",applyMessage:"ApplyMsg",muteTime:"ShutUpTime",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption"},response:{GroupIdList:"groups",MsgFlag:"messageRemindType",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers",ApplyJoinOption:"joinOption"}},i={serverName:so.NAME.GROUP,channel:so.CHANNEL.XHR,protocol:to,queryString:o};return{create:l(l({},i),{},{cmd:so.CMD.CREATE_GROUP,requestData:{type:t.GRP_WORK,name:void 0,groupID:void 0,ownerID:e.loginInfo.identifier,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0},keyMaps:r}),list:l(l({},i),{},{cmd:so.CMD.GET_JOINED_GROUPS,requestData:{userID:e.loginInfo.identifier,limit:void 0,offset:void 0,groupType:void 0,responseFilter:void 0},keyMaps:r}),query:l(l({},i),{},{cmd:so.CMD.GET_GROUP_INFO,requestData:{groupIDList:void 0,responseFilter:void 0},keyMaps:r}),getGroupMemberProfile:l(l({},i),{},{cmd:so.CMD.GET_GROUP_MEMBER_INFO,requestData:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMaps:{request:l(l({},r.request),{},{userIDList:"Member_List_Account"}),response:r.response}}),getGroupMemberList:l(l({},i),{},{cmd:so.CMD.GET_GROUP_MEMBER_LIST,requestData:{groupID:void 0,limit:0,offset:0,memberRoleFilter:void 0,memberInfoFilter:void 0},keyMaps:r}),quitGroup:l(l({},i),{},{cmd:so.CMD.QUIT_GROUP,requestData:{groupID:void 0}}),changeGroupOwner:l(l({},i),{},{cmd:so.CMD.CHANGE_GROUP_OWNER,queryString:o,requestData:{groupID:void 0,newOwnerID:void 0},keyMaps:r}),destroyGroup:l(l({},i),{},{cmd:so.CMD.DESTROY_GROUP,requestData:{groupID:void 0}}),updateGroupProfile:l(l({},i),{},{cmd:so.CMD.MODIFY_GROUP_INFO,requestData:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,maxMemberNum:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0},keyMaps:{request:l(l({},r.request),{},{groupCustomField:"AppDefinedData"}),response:r.response}}),modifyGroupMemberInfo:l(l({},i),{},{cmd:so.CMD.MODIFY_GROUP_MEMBER_INFO,requestData:{groupID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMaps:r}),addGroupMember:l(l({},i),{},{cmd:so.CMD.ADD_GROUP_MEMBER,requestData:{groupID:void 0,silence:void 0,userIDList:void 0},keyMaps:r}),deleteGroupMember:l(l({},i),{},{cmd:so.CMD.DELETE_GROUP_MEMBER,requestData:{groupID:void 0,userIDList:void 0,reason:void 0},keyMaps:{request:{userIDList:"MemberToDel_Account"}}}),searchGroupByID:l(l({},i),{},{cmd:so.CMD.SEARCH_GROUP_BY_ID,requestData:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption"]}},keyMaps:{request:{groupIDList:"GroupIdList"}}}),applyJoinGroup:l(l({},i),{},{cmd:so.CMD.APPLY_JOIN_GROUP,requestData:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0},keyMaps:r}),applyJoinAVChatRoom:l(l({},i),{},{serverName:so.NAME.BIG_GROUP_NO_AUTH,cmd:so.CMD.APPLY_JOIN_GROUP,requestData:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0},keyMaps:r}),handleApplyJoinGroup:l(l({},i),{},{cmd:so.CMD.HANDLE_APPLY_JOIN_GROUP,requestData:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMaps:{request:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"},response:{MsgKey:"messageKey"}}}),deleteGroupSystemNotice:l(l({},i),{},{serverName:so.NAME.OPEN_IM,cmd:so.CMD.DELETE_GROUP_SYSTEM_MESSAGE,requestData:{messageListToDelete:void 0},keyMaps:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),getGroupPendency:l(l({},i),{},{cmd:so.CMD.GET_GROUP_PENDENCY,requestData:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMaps:{request:{handleAccount:"Handle_Account"}}}),getOnlineMemberNum:{serverName:n,cmd:so.CMD.GET_ONLINE_MEMBER_NUM,channel:so.CHANNEL.XHR,protocol:to,queryString:o,requestData:{groupID:void 0}}}}(this.tim),this.config.longPollID=function(e){return{create:{},query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.GET_LONG_POLL_ID,channel:so.CHANNEL.XHR,protocol:to,queryString:l(l({},Ms(e)),{},{reqtime:+new Date/1e3}),requestData:{},keyMaps:{response:{LongPollingId:"longPollingID"}}},update:{},delete:{}}}(this.tim),this.config.longPoll=function(e){var t=l(l({},Ms(e)),{},{reqtime:Math.ceil(+new Date/1e3)});return{create:{},query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.LONG_POLL,channel:so.CHANNEL.AUTO,protocol:to,queryString:t,requestData:{timeout:null,cookie:{notifySeq:0,noticeSeq:0,longPollingID:0}},keyMaps:{response:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension"}}},update:{},delete:{}}}(this.tim),this.config.applyC2C=function(e){var t=Ms(e),n={serverName:so.NAME.FRIEND,channel:so.CHANNEL.XHR,protocol:to,queryString:t};return{create:l(l({},n),{},{cmd:so.CMD.FRIEND_ADD,requestData:{fromAccount:"",addFriendItem:[]}}),get:l(l({},n),{},{cmd:so.CMD.GET_PENDENCY,requestData:{fromAccount:"",pendencyType:"Pendency_Type_ComeIn"}}),update:l(l({},n),{},{cmd:so.CMD.RESPONSE_PENDENCY,requestData:{fromAccount:"",responseFriendItem:[]}}),delete:l(l({},n),{},{cmd:so.CMD.DELETE_PENDENCY,requestData:{fromAccount:"",toAccount:[],pendencyType:"Pendency_Type_ComeIn"}})}}(this.tim),this.config.friend=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}}),n={serverName:so.NAME.FRIEND,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{get:l(l({},n),{},{cmd:so.CMD.FRIEND_GET_ALL,requestData:{fromAccount:"",timeStamp:0,tagList:[gt.NICK,"Tag_SNS_IM_Remark",gt.AVATAR]},keyMaps:{request:{},response:{}}}),delete:l(l({},n),{},{cmd:so.CMD.FRIEND_DELETE,requestData:{fromAccount:"",toAccount:[],deleteType:"Delete_Type_Single"}})}}(this.tim),this.config.blacklist=function(e){var t=Ms(e),n={serverName:so.NAME.FRIEND,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{create:l(l({},n),{},{cmd:so.CMD.ADD_BLACKLIST,requestData:{fromAccount:"",toAccount:[]}}),get:l(l({},n),{},{cmd:so.CMD.GET_BLACKLIST,requestData:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0}}),delete:l(l({},n),{},{cmd:so.CMD.DELETE_BLACKLIST,requestData:{fromAccount:"",toAccount:[]}}),update:{}}}(this.tim),this.config.c2cMessage=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}}),n={request:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag"},response:{MsgContent:"content",MsgTime:"time",Data:"data",Desc:"description",Ext:"extension",MsgKey:"messageKey",MsgType:"type",MsgBody:"elements",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}},o={serverName:so.NAME.OPEN_IM,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{create:l(l({},o),{},{cmd:so.CMD.SEND_MESSAGE,requestData:{fromAccount:e.loginInfo.identifier,toAccount:"",msgTimeStamp:Math.ceil(+new Date/1e3),msgSeq:0,msgRandom:0,msgBody:[],msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}}},keyMaps:n}),query:l(l({},o),{},{cmd:so.CMD.GET_C2C_ROAM_MESSAGES,requestData:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMsg:1},keyMaps:n})}}(this.tim),this.config.c2cMessageWillBeRevoked=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}});return{create:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.REVOKE_C2C_MESSAGE,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:Math.ceil(+new Date/1e3),msgSeq:0,msgRandom:0}},keyMaps:{request:{msgInfo:"MsgInfo",fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody"}}}}}(this.tim),this.config.c2cPeerReadTime=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}});return{get:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.GET_PEER_READ_TIME,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{userIDList:void 0},keyMaps:{request:{userIDList:"To_Account"},response:{ReadTime:"peerReadTimeList"}}}}}(this.tim),this.config.groupMessage=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}}),n={request:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq"},response:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsPlaceMsg:"isPlaceMessage",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}},o={serverName:so.NAME.GROUP,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{create:l(l({},o),{},{cmd:so.CMD.SEND_GROUP_MESSAGE,requestData:{groupID:"",fromAccount:e.loginInfo.identifier,random:0,clientSequence:0,priority:"",msgBody:[],onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{badgeMode:0},androidInfo:{OPPOChannelID:""}}},keyMaps:n}),query:l(l({},o),{},{cmd:so.CMD.GET_GROUP_ROAM_MESSAGES,requestData:{withRecalledMsg:1,groupID:"",count:15,sequence:""},keyMaps:n}),update:null,delete:null}}(this.tim),this.config.groupMessageWillBeRevoked=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}});return{create:{serverName:so.NAME.GROUP,cmd:so.CMD.REVOKE_GROUP_MESSAGE,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{to:"",msgSeqList:[]},keyMaps:{request:{to:"GroupId",msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}}(this.tim),this.config.conversation=function(e){var t=Ms(e),n={serverName:so.NAME.RECENT_CONTACT,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t};return{query:l(l({},n),{},{cmd:so.CMD.GET_CONVERSATION_LIST,requestData:{fromAccount:e.loginInfo.identifier,count:0},keyMaps:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq"}}}),pagingQuery:l(l({},n),{},{cmd:so.CMD.PAGING_GET_CONVERSATION_LIST,requestData:{fromAccount:void 0,timeStamp:void 0,orderType:void 0},keyMaps:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime"}}}),delete:l(l({},n),{},{cmd:so.CMD.DELETE_CONVERSATION,requestData:{fromAccount:e.loginInfo.identifier,toAccount:void 0,type:1,toGroupID:void 0},keyMaps:{request:{toGroupID:"ToGroupid"}}}),setC2CMessageRead:l(l({},n),{},{serverName:so.NAME.OPEN_IM,cmd:so.CMD.SET_C2C_MESSAGE_READ,requestData:{C2CMsgReaded:void 0},keyMaps:{request:{lastMessageTime:"LastedMsgTime"}}}),setGroupMessageRead:l(l({},n),{},{serverName:so.NAME.GROUP,cmd:so.CMD.SET_GROUP_MESSAGE_READ,requestData:{groupID:void 0,messageReadSeq:void 0},keyMaps:{request:{messageReadSeq:"MsgReadedSeq"}}})}}(this.tim),this.config.syncMessage=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return[Math.ceil(+new Date),Math.random()].join("")}});return{create:null,query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.GET_MESSAGES,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{cookie:"",syncFlag:0,needAbstract:1},keyMaps:{request:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},response:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"groupID",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList"}}},update:null,delete:null}}(this.tim),this.config.AVChatRoom=function(e){var t=so.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,n=l(l({},Ms(e)),{},{accounttype:"792",reqtime:function(){return+new Date}});return(e.context.login===Ye.IS_LOGIN||e.context.a2Key)&&(t=so.NAME.BIG_GROUP_LONG_POLLING),{startLongPoll:{serverName:t,cmd:so.CMD.AVCHATROOM_LONG_POLL,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:n,requestData:{USP:1,startSeq:1,holdTime:90,key:void 0},keyMaps:{request:{USP:"USP"},response:{ToGroupId:"groupID",MsgPriority:"priority"}}}}}(this.tim),this.config.cosUpload=function(e){var t=l(l({},Ms(e)),{},{reqtime:function(){return+new Date}});return{create:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.FILE_UPLOAD,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{appVersion:"2.1",fromAccount:"",toAccount:"",sequence:0,time:function(){return Math.ceil(Date.now()/1e3)},random:function(){return Te()},fileStrMd5:"",fileSize:"",serverVer:1,authKey:"",busiId:1,pkgFlag:1,sliceOffset:0,sliceSize:0,sliceData:"",contentType:"application/x-www-form-urlencoded"},keyMaps:{request:{},response:{}}},update:null,delete:null}}(this.tim),this.config.cosSig=function(e){var t={sdkappid:e.loginInfo.SDKAppID,identifier:e.loginInfo.identifier,userSig:e.context.userSig};return{create:null,query:{serverName:so.NAME.IM_COS_SIGN,cmd:so.CMD.COS_SIGN,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:t,requestData:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMaps:{request:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},response:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}},update:null,delete:null}}(this.tim),this.config.bigDataHallwayAuthKey=function(e){return{create:null,query:{serverName:so.NAME.OPEN_IM,cmd:so.CMD.BIG_DATA_HALLWAY_AUTH_KEY,channel:so.CHANNEL.XHR,protocol:to,method:"POST",queryString:l(l({},Ms(e)),{},{accounttype:"792",reqtime:function(){return+new Date}}),requestData:{}}}}(this.tim),this.config.ssoEventStat=function(e){var t={sdkappid:e.loginInfo.SDKAppID,reqtime:Math.ceil(+new Date/1e3)};return{create:{serverName:so.NAME.IM_OPEN_STAT,cmd:so.CMD.TIM_WEB_REPORT,channel:so.CHANNEL.AUTO,protocol:to,queryString:t,requestData:{table:"",report:[]},keyMaps:{request:{table:"table",report:"report",SDKAppID:"sdkappid",version:"version",tinyID:"tinyid",userID:"userid",platform:"platform",method:"method",time:"time",start:"start",end:"end",cost:"cost",status:"status",codeint:"codeint",message:"message",pointer:"pointer",text:"text",msgType:"msgtype",networkType:"networktype",startts:"startts",endts:"endts",timespan:"timespan"}}},query:{},update:{},delete:{}}}(this.tim),this.config.ssoSumStat=function(e){var t=null;null!==e.context&&(t={sdkappid:e.context.SDKAppID,reqtime:Math.ceil(+new Date/1e3)});return{create:{serverName:so.NAME.IM_OPEN_STAT,cmd:so.CMD.TIM_WEB_REPORT,channel:so.CHANNEL.AUTO,protocol:to,queryString:t,requestData:{table:"",report:[]},keyMaps:{request:{table:"table",report:"report",SDKAppID:"sdkappid",version:"version",tinyID:"tinyid",userID:"userid",item:"item",lpID:"lpid",platform:"platform",scene:"scene",networkType:"networktype",total:"total",successRate:"successrate",avg:"avg",timespan:"timespan",time:"time"}}},query:{},update:{},delete:{}}}(this.tim)}},{key:"_initRequestData",value:function(e,t){if(void 0===e)return er(t.requestData,this._getRequestMap(t),this.tim);var n=t.requestData,o=Object.create(null);for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){if(o[r]="function"==typeof n[r]?n[r]():n[r],void 0===e[r])continue;o[r]=e[r]}return o=er(o,this._getRequestMap(t),this.tim)}},{key:"_getRequestMap",value:function(e){if(e.keyMaps&&e.keyMaps.request&&Object.keys(e.keyMaps.request).length>0)return e.keyMaps.request}},{key:"_initEncoder",value:function(e){switch(e.protocol){case to:return function(e){if("string"===n(e))try{return JSON.parse(e)}catch(t){return e}return e};case eo:return function(e){return e};default:return function(e){return ie.warn("PackageConfig._initEncoder(), unknow response type, data: ",JSON.stringify(e)),e}}}},{key:"_initDecoder",value:function(e){switch(e.protocol){case to:return function(e){if("string"===n(e))try{return JSON.parse(e)}catch(t){return e}return e};case eo:return function(e){return e};default:return function(e){return ie.warn("PackageConfig._initDecoder(), unknow response type, data: ",e),e}}}}]),e}(),Es=function(){for(var e=[],t=Ts(arguments),n=0;n<arguments.length;n++)Number.isInteger(arguments[n])?e.push(arguments[n]):e.push(!0==!!arguments[n]?"1":"0");return e.join(t)},Ts=function(e){var t=e.length,n=e[t-1];if("string"!=typeof n)return"";if(n.length>1)return"";var o=e[t-1];return delete e[t-1],e.length-=t===e.length?1:0,o},Ds={C2CMessageArray:1,groupMessageArray:1,groupTips:1,C2CNotifyMessageArray:1,profileModify:1,friendListMod:1},Ss=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e))._initialization(),o}return a(n,[{key:"_initialization",value:function(){this._syncOffset="",this._syncNoticeList=[],this._syncEventArray=[],this._syncMessagesIsRunning=!1,this._syncMessagesFinished=!1,this._isLongPoll=!1,this._longPollID=0,this._noticeSequence=0,this._initializeListener(),this._runLoop=null,this._initShuntChannels()}},{key:"_initShuntChannels",value:function(){this._shuntChannels=Object.create(null),this._shuntChannels.C2CMessageArray=this._C2CMessageArrayChannel.bind(this),this._shuntChannels.groupMessageArray=this._groupMessageArrayChannel.bind(this),this._shuntChannels.groupTips=this._groupTipsChannel.bind(this),this._shuntChannels.C2CNotifyMessageArray=this._C2CNotifyMessageArrayChannel.bind(this),this._shuntChannels.profileModify=this._profileModifyChannel.bind(this),this._shuntChannels.friendListMod=this._friendListModChannel.bind(this)}},{key:"_C2CMessageArrayChannel",value:function(e,t,n){this.emitInnerEvent(ko,t)}},{key:"_groupMessageArrayChannel",value:function(e,t,n){this.emitInnerEvent(Oo,t)}},{key:"_groupTipsChannel",value:function(e,t,n){var o=this;switch(e){case 4:case 6:this.emitInnerEvent(Ro,t);break;case 5:t.forEach((function(e){pe(e.elements.revokedInfos)?o.emitInnerEvent(wo,t):o.emitInnerEvent(Ao,{groupSystemNotices:t,type:n})}));break;default:ie.log("NotificationController._groupTipsChannel unknown event=".concat(e," type=").concat(n),t)}}},{key:"_C2CNotifyMessageArrayChannel",value:function(e,t,n){if(t[0]){var o=t[0];o.hasOwnProperty("kickoutMsgNotify")?this.emitInnerEvent(So):o.hasOwnProperty("c2cMessageRevokedNotify")?this.emitInnerEvent(Po,t):o.hasOwnProperty("c2cMessageReadReceipt")&&this.emitInnerEvent(Go,t)}}},{key:"_profileModifyChannel",value:function(e,t,n){this.emitInnerEvent(Lo,t)}},{key:"_friendListModChannel",value:function(e,t,n){this.emitInnerEvent(No,t)}},{key:"_dispatchNotice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"poll";if(pe(e))for(var n=null,o=null,r="",i="",s="",a=0,u=0,c=e.length;u<c;u++)a=(n=e[u]).event,r=Object.keys(n).find((function(e){return void 0!==Ds[e]})),de(this._shuntChannels[r])?(o=n[r],"poll"===t&&this._updatenoticeSequence(o),this._shuntChannels[r](a,o,t)):("poll"===t&&this._updatenoticeSequence(),i="".concat(Ot.NOTICE_RUNLOOP_UNEXPECTED_CONDITION),s="".concat(An,": ").concat(a,", ").concat(r),this.emitInnerEvent(Ho,new kt({code:i,message:s,data:{payloadName:r,event:a}})),i="",s="")}},{key:"getLongPollID",value:function(){return this._longPollID}},{key:"_IAmReady",value:function(){this.triggerReady()}},{key:"reset",value:function(){this._noticeSequence=0,this._resetSync(),this.closeNoticeChannel()}},{key:"_resetSync",value:function(){this._syncOffset="",this._syncNoticeList=[],this._syncEventArray=[],this._syncMessagesIsRunning=!1,this._syncMessagesFinished=!1}},{key:"_setNoticeSeqInRequestData",value:function(e){e.Cookie.NoticeSeq=this._noticeSequence,this.tim.sumStatController.addTotalCount(dr)}},{key:"_updatenoticeSequence",value:function(e){if(e){var t=e[e.length-1].noticeSequence;t&&"number"==typeof t?t<=this._noticeSequence||(this._noticeSequence=t):this._noticeSequence++}else this._noticeSequence++}},{key:"_initializeListener",value:function(){var e=this.tim.innerEmitter;e.on(lo,this._startSyncMessages,this),e.on(Vo,this.closeNoticeChannel,this)}},{key:"openNoticeChannel",value:function(){ie.log("NotificationController.openNoticeChannel"),this._getLongPollID()}},{key:"closeNoticeChannel",value:function(){ie.log("NotificationController.closeNoticeChannel"),(this._runLoop instanceof Ui||this._runLoop instanceof Fi)&&(this._runLoop.abort(),this._runLoop.stop()),this._longPollID=0,this._isLongPoll=!1}},{key:"_getLongPollID",value:function(){var e=this;if(0===this._longPollID){var t=new kr(Ii);this.request({name:"longPollID",action:"query"}).then((function(n){var o=n.data.longPollingID;e._onGetLongPollIDSuccess(o),t.setText("longPollingID=".concat(o)).setNetworkType(e.getNetworkType()).setEnd()})).catch((function(n){var o=new kt({code:n.code||Ot.GET_LONGPOLL_ID_FAILED,message:n.message||Ln});e.emitInnerEvent(Co),e.emitInnerEvent(Ho,o),e.probeNetwork().then((function(e){var n=M(e,2),r=n[0],i=n[1];t.setError(o,r,i).setEnd()}))}))}else this._onGetLongPollIDSuccess(this._longPollID)}},{key:"_onGetLongPollIDSuccess",value:function(e){this.emitInnerEvent(po,[{key:"long_poll_logout.query.requestData.longPollingID",value:e},{key:"longPoll.query.requestData.cookie.longPollingID",value:e}]),this._longPollID=e,this._startLongPoll(),this._IAmReady(),this.tim.sumStatController.recordLongPollingID(this._longPollID)}},{key:"_startLongPoll",value:function(){if(!0!==this._isLongPoll){ie.log("NotificationController._startLongPoll...");var e=this.tim.connectionController,t=this.createTransportCapsule({name:"longPoll",action:"query"});this._isLongPoll=!0,this._runLoop=e.createRunLoop({pack:t,before:this._setNoticeSeqInRequestData.bind(this),success:this._onNoticeReceived.bind(this),fail:this._onNoticeFail.bind(this)}),this._runLoop.start()}else ie.log("NotificationController._startLongPoll is running...")}},{key:"_onNoticeReceived",value:function(e){var t=e.data;t.errorCode!==$e.SUCCESS?(new kr(Mi).setMessage(t.errorInfo||JSON.stringify(t)).setCode(t.errorCode).setNetworkType(this.getNetworkType()).setEnd(!0),this._onResponseError(t)):this.emitInnerEvent(To);this.tim.sumStatController.addSuccessCount(dr),this.tim.sumStatController.addCost(dr,t.timecost),e.data.eventArray&&this._dispatchNotice(e.data.eventArray)}},{key:"_onResponseError",value:function(e){switch(e.errorCode){case Ot.LONG_POLL_KICK_OUT:ie.warn("NotificationController._onResponseError, longPollingID=".concat(this._longPollID," was kicked out")),this.emitInnerEvent(Do),this.closeNoticeChannel();break;case Ot.MESSAGE_A2KEY_EXPIRED:case Ot.ACCOUNT_A2KEY_EXPIRED:this.emitInnerEvent(Ko);break;default:ge(e.errorCode)||ge(e.errorInfo)?ie.log("NotificationController._onResponseError, errorCode or errorInfo undefined!",e):this.emitInnerEvent(Ho,new kt({code:e.errorCode,message:e.errorInfo}))}}},{key:"_onNoticeFail",value:function(e){if(e.error)if("ECONNABORTED"===e.error.code||e.error.code===Ot.NETWORK_TIMEOUT)if(e.error.config){var t=e.error.config.url,n=e.error.config.data;ie.log("NotificationController._onNoticeFail request timed out. url=".concat(t," data=").concat(n))}else ie.log("NotificationController._onNoticeFail request timed out.");else ie.log("NotificationController._onNoticeFail request failed due to network error");this.emitInnerEvent(Eo)}},{key:"_startSyncMessages",value:function(e){!0!==this._syncMessagesFinished&&this.syncMessage()}},{key:"syncMessage",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this._syncMessagesIsRunning=!0,this.request({name:"syncMessage",action:"query",param:{cookie:t,syncFlag:n}}).then((function(t){var n=t.data;switch(Es(n.cookie,n.syncFlag)){case"00":case"01":e.emitInnerEvent(Ho,{code:Ot.NOTICE_RUNLOOP_OFFSET_LOST,message:Nn});break;case"10":case"11":n.eventArray&&e._dispatchNotice(n.eventArray,"sync"),e._syncNoticeList=e._syncNoticeList.concat(n.messageList),e.emitInnerEvent(go,{data:n.messageList,C2CRemainingUnreadList:n.C2CRemainingUnreadList}),e._syncOffset=n.cookie,e.syncMessage(n.cookie,n.syncFlag);break;case"12":n.eventArray&&e._dispatchNotice(n.eventArray,"sync"),e.openNoticeChannel(),e._syncNoticeList=e._syncNoticeList.concat(n.messageList),e.emitInnerEvent(ho,{messageList:n.messageList,C2CRemainingUnreadList:n.C2CRemainingUnreadList}),e._syncOffset=n.cookie,e._syncNoticeList=[],e._syncMessagesIsRunning=!1,e._syncMessagesFinished=!0}})).catch((function(t){e._syncMessagesIsRunning=!1,ie.error("NotificationController.syncMessage failed. error:",t)}))}}]),n}(rr),ks=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e)).COSSDK=null,o._cosUploadMethod=null,o.expiredTimeLimit=600,o.appid=0,o.bucketName="",o.ciUrl="",o.directory="",o.downloadUrl="",o.uploadUrl="",o.expiredTimeOut=o.expiredTimeLimit,o.region="ap-shanghai",o.cos=null,o.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},o._timer=0,o.tim.innerEmitter.on(lo,o._init,v(o)),o.triggerReady(),o}return a(n,[{key:"_expiredTimer",value:function(){var e=this;this._timer=setInterval((function(){Math.ceil(Date.now()/1e3)>=e.cosOptions.expiredTime-120&&(e._getAuthorizationKey(),clearInterval(e._timer))}),6e4)}},{key:"_init",value:function(){var e=P?"cos-wx-sdk":"cos-js-sdk";this.COSSDK=this.tim.getPlugin(e),this.COSSDK?this._getAuthorizationKey():ie.warn("UploadController._init 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#registerPlugin")}},{key:"_getAuthorizationKey",value:function(){var e=this,t=Math.ceil(Date.now()/1e3),n=new kr(Gr);this.request({name:"cosSig",action:"query",param:{duration:this.expiredTimeLimit}}).then((function(o){ie.log("UploadController._getAuthorizationKey ok. data:",o.data);var r=o.data,i=r.expiredTime-t;n.setText("requestId=".concat(r.requestId," requestTime=").concat(t," expiredTime=").concat(r.expiredTime," timeout=").concat(i,"s")).setNetworkType(e.getNetworkType()).setEnd(),e.appid=r.appid,e.bucketName=r.bucketName,e.ciUrl=r.ciUrl,e.directory=r.directory,e.downloadUrl=r.downloadUrl,e.uploadUrl=r.uploadUrl,e.expiredTimeOut=i,e.cosOptions={secretId:r.secretId,secretKey:r.secretKey,sessionToken:r.sessionToken,expiredTime:r.expiredTime},e._initUploaderMethod(),e._expiredTimer()})).catch((function(t){e.probeNetwork().then((function(e){var o=M(e,2),r=o[0],i=o[1];n.setError(t,r,i).setEnd()})),ie.warn("UploadController._getAuthorizationKey failed. error:",t)}))}},{key:"_initUploaderMethod",value:function(){var e=this;this.appid&&(this.cos=P?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=P?function(t,n){e.cos.postObject(t,n)}:function(t,n){e.cos.uploadFiles(t,n)})}},{key:"_getAuthorization",value:function(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}},{key:"uploadImage",value:function(e){if(!e.file)return pr(new kt({code:Ot.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:Ht}));var t=this._checkImageType(e.file);if(!0!==t)return t;var n=this._checkImageMime(e.file);if(!0!==n)return n;var o=this._checkImageSize(e.file);if(!0!==o)return o;var r=null;return this.upload(e).then((function(e){return r=e,t="https://".concat(e.location),P?new Promise((function(e,n){wx.getImageInfo({src:t,success:function(t){e({width:t.width,height:t.height})},fail:function(){e({width:0,height:0})}})})):j&&9===$?Promise.resolve({width:0,height:0}):new Promise((function(e,n){var o=new Image;o.onload=function(){e({width:this.width,height:this.height}),o=null},o.onerror=function(){e({width:0,height:0}),o=null},o.src=t}));var t})).then((function(e){return r.width=e.width,r.height=e.height,Promise.resolve(r)}))}},{key:"_checkImageType",value:function(e){var t="";return t=P?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),Gn.indexOf(t.toLowerCase())>=0||pr(new kt({coe:Ot.MESSAGE_IMAGE_TYPES_LIMIT,message:Bt}))}},{key:"_checkImageMime",value:function(e){return!0}},{key:"_checkImageSize",value:function(e){var t=0;return 0===(t=P?e.size:e.files[0].size)?pr(new kt({code:Ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(xt)})):t<20971520||pr(new kt({coe:Ot.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat(jt)}))}},{key:"uploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?(t=new kt({code:Ot.MESSAGE_FILE_SIZE_LIMIT,message:Zt}),pr(t)):0===e.file.files[0].size?(t=new kt({code:Ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(xt)}),pr(t)):this.upload(e):(t=new kt({code:Ot.MESSAGE_FILE_SELECT_FILE_FIRST,message:Qt}),pr(t))}},{key:"uploadVideo",value:function(e){return e.file.videoFile.size>104857600?pr(new kt({code:Ot.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat(zt)})):0===e.file.videoFile.size?pr(new kt({code:Ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(xt)})):-1===bn.indexOf(e.file.videoFile.type)?pr(new kt({code:Ot.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat(Jt)})):P?this.handleVideoUpload({file:e.file.videoFile}):w?this.handleVideoUpload(e):void 0}},{key:"handleVideoUpload",value:function(e){var t=this;return new Promise((function(n,o){t.upload(e).then((function(e){n(e)})).catch((function(){t.upload(e).then((function(e){n(e)})).catch((function(){o(new kt({code:Ot.MESSAGE_VIDEO_UPLOAD_FAIL,message:Wt}))}))}))}))}},{key:"uploadAudio",value:function(e){return e.file?e.file.size>20971520?pr(new kt({code:Ot.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat(Yt)})):0===e.file.size?pr(new kt({code:Ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(xt)})):this.upload(e):pr(new kt({code:Ot.MESSAGE_AUDIO_UPLOAD_FAIL,message:$t}))}},{key:"upload",value:function(e){var t=this;if(!de(this._cosUploadMethod))return ie.warn("UploadController.upload 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#registerPlugin"),pr(new kt({code:Ot.COS_UNDETECTED,message:Gt}));var n=new kr(br);ie.time(Sr);var o=P?e.file:e.file.files[0];return new Promise((function(r,i){var s=P?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),a=t;t._cosUploadMethod(s,(function(e,s){var u=Object.create(null);if(s){if(e||pe(s.files)&&s.files[0].error){var c=new kt({code:Ot.MESSAGE_FILE_UPLOAD_FAIL,message:Xt});return n.setError(c,!0,t.getNetworkType()).setEnd(),ie.log("UploadController.upload failed, error:",s.files[0].error),403===s.files[0].error.statusCode&&(ie.warn("UploadController.upload failed. cos AccessKeyId was invalid, regain auth key!"),t._getAuthorizationKey()),void i(c)}u.fileName=o.name,u.fileSize=o.size,u.fileType=o.type.slice(o.type.indexOf("/")+1).toLowerCase(),u.location=P?s.Location:s.files[0].data.Location;var l=ie.timeEnd(Sr),p=a._formatFileSize(o.size),g=a._formatSpeed(1e3*o.size/l),h="size=".concat(p,",time=").concat(l,"ms,speed=").concat(g);return ie.log("UploadController.upload success name=".concat(o.name,",").concat(h)),r(u),void n.setNetworkType(t.getNetworkType()).setText(h).setEnd()}var d=new kt({code:Ot.MESSAGE_FILE_UPLOAD_FAIL,message:Xt});n.setError(d,!0,a.getNetworkType()).setEnd(),ie.warn("UploadController.upload failed, error:",e),403===e.statusCode&&(ie.warn("UploadController.upload failed. cos AccessKeyId was invalid, regain auth key!"),t._getAuthorizationKey()),i(d)}))}))}},{key:"_formatFileSize",value:function(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}},{key:"_formatSpeed",value:function(e){return e<=1048576?(e/1024).toFixed(1)+"KB/s":(e/1048576).toFixed(1)+"MB/s"}},{key:"_createCosOptionsWeb",value:function(e){var t=this.tim.context.identifier,n=this._genFileName(t,e.to,e.file.files[0].name);return{files:[{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),Body:e.file.files[0]}],SliceSize:1048576,onProgress:function(t){if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(n){ie.warn("onProgress callback error:",n),ie.error(n)}},onFileFinish:function(e,t,n){}}}},{key:"_createCosOptionsWXMiniApp",value:function(e){var t=this.tim.context.identifier,n=this._genFileName(t,e.to,e.file.name),o=e.file.url;return{Bucket:"".concat(this.bucketName,"-").concat(this.appid),Region:this.region,Key:"".concat(this.directory,"/").concat(n),FilePath:o,onProgress:function(t){if(ie.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(n){ie.warn("onProgress callback error:",n),ie.error(n)}}}}},{key:"_genFileName",value:function(e,t,n){return"".concat(e,"-").concat(t,"-").concat(Te(99999),"-").concat(n)}},{key:"reset",value:function(){this._timer&&(clearInterval(this._timer),this._timer=0)}}]),n}(rr),Os=function(e){p(o,e);var n=I(o);function o(e){var t;return i(this,o),(t=n.call(this,e)).FILETYPE={SOUND:2106,FILE:2107,VIDEO:2113},t._bdh_download_server="grouptalk.c2c.qq.com",t._BDHBizID=10001,t._authKey="",t._expireTime=0,t.tim.innerEmitter.on(lo,t._getAuthKey,v(t)),t}return a(o,[{key:"_getAuthKey",value:function(){var e=this;this.request({name:"bigDataHallwayAuthKey",action:"query"}).then((function(t){t.data.authKey&&(e._authKey=t.data.authKey,e._expireTime=parseInt(t.data.expireTime))}))}},{key:"_isFromOlderVersion",value:function(e){return 2!==e.content.downloadFlag}},{key:"parseElements",value:function(e,t){if(!pe(e)||!t)return[];for(var n=[],o=null,r=0;r<e.length;r++)o=e[r],this._needParse(o)?n.push(this._parseElement(o,t)):n.push(e[r]);return n}},{key:"_needParse",value:function(e){return!(!this._isFromOlderVersion(e)||e.type!==t.MSG_AUDIO&&e.type!==t.MSG_FILE&&e.type!==t.MSG_VIDEO)}},{key:"_parseElement",value:function(e,n){switch(e.type){case t.MSG_AUDIO:return this._parseAudioElement(e,n);case t.MSG_FILE:return this._parseFileElement(e,n);case t.MSG_VIDEO:return this._parseVideoElement(e,n)}}},{key:"_parseAudioElement",value:function(e,t){return e.content.url=this._genAudioUrl(e.content.uuid,t),e}},{key:"_parseFileElement",value:function(e,t){return e.content.url=this._genFileUrl(e.content.uuid,t,e.content.fileName),e}},{key:"_parseVideoElement",value:function(e,t){return e.content.url=this._genVideoUrl(e.content.uuid,t),e}},{key:"_genAudioUrl",value:function(e,t){return""===this._authKey?(ie.warn("BigDataHallwayController._genAudioUrl no authKey!"),""):"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(this.tim.context.SDKAppID,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.SOUND,"&openid=").concat(t,"&ver=0")}},{key:"_genFileUrl",value:function(e,t,n){return""===this._authKey?(ie.warn("BigDataHallwayController._genFileUrl no authKey!"),""):(n||(n="".concat(Math.floor(1e5*Math.random()),"-").concat(Date.now())),"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(this.tim.context.SDKAppID,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.FILE,"&openid=").concat(t,"&ver=0&filename=").concat(encodeURIComponent(n)))}},{key:"_genVideoUrl",value:function(e,t){return""===this._authKey?(ie.warn("BigDataHallwayController._genVideoUrl no authKey!"),""):"https://".concat(this._bdh_download_server,"/asn.com/stddownload_common_file?authkey=").concat(this._authKey,"&bid=").concat(this._BDHBizID,"&subbid=").concat(this.tim.context.SDKAppID,"&fileid=").concat(e,"&filetype=").concat(this.FILETYPE.VIDEO,"&openid=").concat(t,"&ver=0")}},{key:"reset",value:function(){this._authKey="",this.expireTime=0}}]),o}(rr);var Rs={app_id:"",event_id:"",api_base:"https://pingtas.qq.com/pingd",prefix:"_mta_",version:"1.3.9",stat_share_app:!1,stat_pull_down_fresh:!1,stat_reach_bottom:!1,stat_param:!0};function As(){try{var e="s"+Ns();return wx.setStorageSync(Rs.prefix+"ssid",e),e}catch(t){}}function Ns(e){for(var t=[0,1,2,3,4,5,6,7,8,9],n=10;1<n;n--){var o=Math.floor(10*Math.random()),r=t[o];t[o]=t[n-1],t[n-1]=r}for(n=o=0;5>n;n++)o=10*o+t[n];return(e||"")+(o+"")+ +new Date}function Ls(){try{var e=getCurrentPages(),t="/";return 0<e.length&&(t=e.pop().__route__),t}catch(n){console.log("get current page path error:"+n)}}function ws(){var e,t={dm:"wechat.apps.xx",url:encodeURIComponent(Ls()+bs(Us.Data.pageQuery)),pvi:"",si:"",ty:0};return t.pvi=((e=function(){try{return wx.getStorageSync(Rs.prefix+"auid")}catch(t){}}())||(e=function(){try{var t=Ns();return wx.setStorageSync(Rs.prefix+"auid",t),t}catch(e){}}(),t.ty=1),e),t.si=function(){var e=function(){try{return wx.getStorageSync(Rs.prefix+"ssid")}catch(e){}}();return e||(e=As()),e}(),t}function Ps(){var e=function(){var e=wx.getSystemInfoSync();return{adt:encodeURIComponent(e.model),scl:e.pixelRatio,scr:e.windowWidth+"x"+e.windowHeight,lg:e.language,fl:e.version,jv:encodeURIComponent(e.system),tz:encodeURIComponent(e.platform)}}();return function(e){wx.getNetworkType({success:function(t){e(t.networkType)}})}((function(e){try{wx.setStorageSync(Rs.prefix+"ntdata",e)}catch(t){}})),e.ct=wx.getStorageSync(Rs.prefix+"ntdata")||"4g",e}function Gs(){var e,t=Us.Data.userInfo,n=[];for(e in t)t.hasOwnProperty(e)&&n.push(e+"="+t[e]);return t=n.join(";"),{r2:Rs.app_id,r4:"wx",ext:"v="+Rs.version+(null!==t&&""!==t?";ui="+encodeURIComponent(t):"")}}function bs(e){if(!Rs.stat_param||!e)return"";e=function(e){if(1>Rs.ignore_params.length)return e;var t,n={};for(t in e)0<=Rs.ignore_params.indexOf(t)||(n[t]=e[t]);return n}(e);var t,n=[];for(t in e)n.push(t+"="+e[t]);return 0<n.length?"?"+n.join("&"):""}var Us={App:{init:function(e){"appID"in e&&(Rs.app_id=e.appID),"eventID"in e&&(Rs.event_id=e.eventID),"statShareApp"in e&&(Rs.stat_share_app=e.statShareApp),"statPullDownFresh"in e&&(Rs.stat_pull_down_fresh=e.statPullDownFresh),"statReachBottom"in e&&(Rs.stat_reach_bottom=e.statReachBottom),"ignoreParams"in e&&(Rs.ignore_params=e.ignoreParams),"statParam"in e&&(Rs.stat_param=e.statParam),As();try{"lauchOpts"in e&&(Us.Data.lanchInfo=e.lauchOpts,Us.Data.lanchInfo.landing=1)}catch(t){}"autoReport"in e&&e.autoReport&&function(){var e=Page;Page=function(t){var n=t.onLoad;t.onLoad=function(e){n&&n.call(this,e),Us.Data.lastPageQuery=Us.Data.pageQuery,Us.Data.pageQuery=e,Us.Data.lastPageUrl=Us.Data.pageUrl,Us.Data.pageUrl=Ls(),Us.Data.show=!1,Us.Page.init()},e(t)}}()}},Page:{init:function(){var e,t=getCurrentPages()[getCurrentPages().length-1];t.onShow&&(e=t.onShow,t.onShow=function(){if(!0===Us.Data.show){var t=Us.Data.lastPageQuery;Us.Data.lastPageQuery=Us.Data.pageQuery,Us.Data.pageQuery=t,Us.Data.lastPageUrl=Us.Data.pageUrl,Us.Data.pageUrl=Ls()}Us.Data.show=!0,Us.Page.stat(),e.apply(this,arguments)}),Rs.stat_pull_down_fresh&&t.onPullDownRefresh&&function(){var e=t.onPullDownRefresh;t.onPullDownRefresh=function(){Us.Event.stat(Rs.prefix+"pulldownfresh",{url:t.__route__}),e.apply(this,arguments)}}(),Rs.stat_reach_bottom&&t.onReachBottom&&function(){var e=t.onReachBottom;t.onReachBottom=function(){Us.Event.stat(Rs.prefix+"reachbottom",{url:t.__route__}),e.apply(this,arguments)}}(),Rs.stat_share_app&&t.onShareAppMessage&&function(){var e=t.onShareAppMessage;t.onShareAppMessage=function(){return Us.Event.stat(Rs.prefix+"shareapp",{url:t.__route__}),e.apply(this,arguments)}}()},multiStat:function(e,t){if(1==t)Us.Page.stat(e);else{var n=getCurrentPages()[getCurrentPages().length-1];n.onShow&&function(){var t=n.onShow;n.onShow=function(){Us.Page.stat(e),t.call(this,arguments)}}()}},stat:function(e){if(""!=Rs.app_id){var t=[],n=Gs();if(e&&(n.r2=e),e=[ws(),n,Ps()],Us.Data.lanchInfo){e.push({ht:Us.Data.lanchInfo.scene}),Us.Data.pageQuery&&Us.Data.pageQuery._mta_ref_id&&e.push({rarg:Us.Data.pageQuery._mta_ref_id});try{1==Us.Data.lanchInfo.landing&&(n.ext+=";lp=1",Us.Data.lanchInfo.landing=0)}catch(i){}}e.push({rdm:"/",rurl:0>=Us.Data.lastPageUrl.length?Us.Data.pageUrl+bs(Us.Data.lastPageQuery):encodeURIComponent(Us.Data.lastPageUrl+bs(Us.Data.lastPageQuery))}),e.push({rand:+new Date}),n=0;for(var o=e.length;n<o;n++)for(var r in e[n])e[n].hasOwnProperty(r)&&t.push(r+"="+(void 0===e[n][r]?"":e[n][r]));wx.request({url:Rs.api_base+"?"+t.join("&").toLowerCase()})}}},Event:{stat:function(e,t){if(""!=Rs.event_id){var n=[],o=ws(),r=Gs();o.dm="wxapps.click",o.url=e,r.r2=Rs.event_id;var i,s=void 0===t?{}:t,a=[];for(i in s)s.hasOwnProperty(i)&&a.push(encodeURIComponent(i)+"="+encodeURIComponent(s[i]));for(s=a.join(";"),r.r5=s,s=0,r=(o=[o,r,Ps(),{rand:+new Date}]).length;s<r;s++)for(var u in o[s])o[s].hasOwnProperty(u)&&n.push(u+"="+(void 0===o[s][u]?"":o[s][u]));wx.request({url:Rs.api_base+"?"+n.join("&").toLowerCase()})}}},Data:{userInfo:null,lanchInfo:null,pageQuery:null,lastPageQuery:null,pageUrl:"",lastPageUrl:"",show:!1}},qs=Us,Fs=function(){function e(){i(this,e);try{qs.App.init({appID:"500690995",eventID:"500691014",autoReport:!1,statParam:!0})}catch(t){}}return a(e,[{key:"report",value:function(e,t){try{qs.Event.stat(e,t)}catch(n){}}},{key:"stat",value:function(){try{qs.Page.stat()}catch(e){}}}]),e}(),xs=function(e){p(n,e);var t=I(n);function n(e){var o;i(this,n),(o=t.call(this,e)).MTA=new Fs;var r=o.tim.innerEmitter;return r.on(Jo,o._stat,v(o)),r.on(zo,o._stat,v(o)),o}return a(n,[{key:"_stat",value:function(){this.MTA.report("sdkappid",{value:this.tim.context.SDKAppID}),this.MTA.report("version",{value:"2.8.0"}),this.MTA.stat()}}]),n}(rr),Vs=function(){function e(t){i(this,e),this._table="timwebii",this._report=[]}return a(e,[{key:"pushIn",value:function(e){ie.debug("SSOLogBody.pushIn",this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;pe(e)&&0!==e.length&&(ie.debug("SSOLogBody.backfill",this._report.length,e.length),(t=this._report).unshift.apply(t,C(e)))}},{key:"getLogsNumInMemory",value:function(){return this._report.length}},{key:"isEmpty",value:function(){return 0===this._report.length}},{key:"_reset",value:function(){this._report.length=0,this._report=[]}},{key:"getTable",value:function(){return this._table}},{key:"getLogsInMemory",value:function(){var e=this._report.slice();return this._reset(),e}}]),e}(),Ks=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e)).TAG="im-ssolog-event",o._reportBody=new Vs,o._version="2.8.0",o.MIN_THRESHOLD=20,o.MAX_THRESHOLD=100,o.WAITING_TIME=6e4,o.INTERVAL=2e4,o._timerID=0,o._resetLastReportTime(),o._startReportTimer(),o._retryCount=0,o.MAX_RETRY_COUNT=3,o.tim.innerEmitter.on(Fo,o._onLoginSuccess,v(o)),o}return a(n,[{key:"reportAtOnce",value:function(){ie.debug("EventStatController.reportAtOnce"),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.tim.storage,n=t.getItem(this.TAG,!1);Ke(n)||(ie.log("EventStatController._onLoginSuccess get ssolog in storage, nums="+n.length),n.forEach((function(t){e._reportBody.pushIn(t)})),t.removeItem(this.TAG,!1))}},{key:"pushIn",value:function(e){e instanceof kr&&(e.setCommonInfo({SDKAppID:this.tim.context.SDKAppID,version:this._version,tinyID:this.tim.context.tinyID,userID:this.tim.loginInfo.identifier,platform:this.getPlatform(),scene:this.tim.context.scene,instanceID:this.tim.context.instanceID}),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD&&this._report())}},{key:"_resetLastReportTime",value:function(){this._lastReportTime=Date.now()}},{key:"_startReportTimer",value:function(){var e=this;this._timerID=setInterval((function(){Date.now()<e._lastReportTime+e.WAITING_TIME||e._reportBody.isEmpty()||e._report()}),this.INTERVAL)}},{key:"_stopReportTimer",value:function(){this._timerID>0&&(clearInterval(this._timerID),this._timerID=0)}},{key:"_report",value:function(){var e=this;if(!this._reportBody.isEmpty()){var t=this._reportBody.getLogsInMemory();this.request({name:"ssoEventStat",action:"create",param:{table:this._reportBody.getTable(),report:t}}).then((function(){e._resetLastReportTime(),e._retryCount>0&&(ie.debug("EventStatController.report retry success"),e._retryCount=0)})).catch((function(n){if(ie.warn("EventStatController.report, networkType:".concat(e.getNetworkType()," error:").concat(Me(n))),e._reportBody.backfill(t),e._reportBody.getLogsNumInMemory()>e.MAX_THRESHOLD||e._retryCount===e.MAX_RETRY_COUNT||0===e._timerID)return e._retryCount=0,void e._flushAtOnce();e._retryCount+=1}))}}},{key:"_flushAtOnce",value:function(){var e=this.tim.storage,t=e.getItem(this.TAG,!1),n=this._reportBody.getLogsInMemory();if(Ke(t))ie.log("EventStatController._flushAtOnce nums="+n.length),e.setItem(this.TAG,n,!0,!1);else{var o=n.concat(t);o.length>this.MAX_THRESHOLD&&(o=o.slice(0,this.MAX_THRESHOLD)),ie.log("EventStatController._flushAtOnce nums="+o.length),e.setItem(this.TAG,o,!0,!1)}}},{key:"reset",value:function(){ie.log("EventStatController.reset"),this._stopReportTimer(),this._report()}}]),n}(rr),Hs="none",Bs="online",js=function(){function e(){i(this,e),this._networkType="",this.maxWaitTime=3e3}return a(e,[{key:"start",value:function(){var e=this;P?(wx.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===Hs?ie.warn("NetMonitor no network, please check!"):ie.info("NetMonitor networkType:".concat(t.networkType))}}),wx.onNetworkStatusChange(this._onWxNetworkStatusChange.bind(this))):this._networkType=Bs}},{key:"_onWxNetworkStatusChange",value:function(e){this._networkType=e.networkType,e.isConnected?ie.info("NetMonitor networkType:".concat(e.networkType)):ie.warn("NetMonitor no network, please check!")}},{key:"probe",value:function(){var e=this;return new Promise((function(t,n){if(P)wx.getNetworkType({success:function(n){e._networkType=n.networkType,n.networkType===Hs?(ie.warn("NetMonitor no network, please check!"),t([!1,n.networkType])):(ie.info("NetMonitor networkType:".concat(n.networkType)),t([!0,n.networkType]))}});else if(window&&window.fetch)fetch("".concat(Re(),"//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=").concat(Math.random())).then((function(e){e.ok?t([!0,Bs]):t([!1,Hs])})).catch((function(e){t([!1,Hs])}));else{var o=new XMLHttpRequest,r=setTimeout((function(){ie.warn("NetMonitor fetch timeout. Probably no network, please check!"),o.abort(),e._networkType=Hs,t([!1,Hs])}),e.maxWaitTime);o.onreadystatechange=function(){4===o.readyState&&(clearTimeout(r),200===o.status||304===o.status?(this._networkType=Bs,t([!0,Bs])):(ie.warn("NetMonitor fetch status:".concat(o.status,". Probably no network, please check!")),this._networkType=Hs,t([!1,Hs])))},o.open("GET","".concat(Re(),"//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=").concat(Math.random())),o.send()}}))}},{key:"getNetworkType",value:function(){return this._networkType}},{key:"reset",value:function(){this._networkType=""}}]),e}(),$s=function(){function e(t){var n=this;i(this,e),pe(t)?(this._map=new Map,t.forEach((function(e){n._map.set(e,[])}))):ie.warn("AverageCalculator.constructor need keys")}return a(e,[{key:"push",value:function(e,t){return!(ge(e)||!this._map.has(e)||!ae(t))&&(this._map.get(e).push(t),!0)}},{key:"getSize",value:function(e){return ge(e)||!this._map.has(e)?-1:this._map.get(e).length}},{key:"getAvg",value:function(e){if(ge(e)||!this._map.has(e))return-1;var t=this._map.get(e),n=t.length;if(0===n)return 0;var o=0;return t.forEach((function(e){o+=e})),t.length=0,this._map.set(e,[]),parseInt(o/n)}},{key:"getMax",value:function(e){return ge(e)||!this._map.has(e)?-1:Math.max.apply(null,this._map.get(e))}},{key:"getMin",value:function(e){return ge(e)||!this._map.has(e)?-1:Math.min.apply(null,this._map.get(e))}},{key:"reset",value:function(){this._map.forEach((function(e){e.length=0}))}}]),e}(),Ys=function(){function e(t){var n=this;i(this,e),pe(t)?(this._map=new Map,t.forEach((function(e){n._map.set(e,{totalCount:0,successCount:0})}))):ie.warn("SuccessRateCalculator.constructor need keys")}return a(e,[{key:"addTotalCount",value:function(e){return!(ge(e)||!this._map.has(e))&&(this._map.get(e).totalCount+=1,!0)}},{key:"addSuccessCount",value:function(e){return!(ge(e)||!this._map.has(e))&&(this._map.get(e).successCount+=1,!0)}},{key:"getSuccessRate",value:function(e){if(ge(e)||!this._map.has(e))return-1;var t=this._map.get(e);if(0===t.totalCount)return 1;var n=parseFloat((t.successCount/t.totalCount).toFixed(2));return n>1&&(n=1),t.totalCount=t.successCount=0,n}},{key:"getTotalCount",value:function(e){return ge(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}},{key:"reset",value:function(){this._map.forEach((function(e){e.totalCount=0,e.successCount=0}))}}]),e}(),Ws=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e)).TABLE="timwebsum",o.TAG="im-ssolog-sumstat",o._items=[dr,mr,fr,_r,vr,yr,Ir,Mr,Cr,Er],o._thresholdMap=new Map,o._thresholdMap.set(dr,100),o._thresholdMap.set(mr,150),o._thresholdMap.set(fr,15),o._thresholdMap.set(_r,6),o._thresholdMap.set(vr,6),o._thresholdMap.set(yr,6),o._thresholdMap.set(Ir,6),o._thresholdMap.set(Mr,6),o._thresholdMap.set(Cr,50),o._thresholdMap.set(Er,50),o._lpID="",o._platform=o.getPlatform(),o._lastReportTime=0,o._statInfoArr=[],o._retryCount=0,o._avgCalc=new $s(o._items),o._successRateCalc=new Ys(o._items),o.tim.innerEmitter.on(Fo,o._onLoginSuccess,v(o)),o}return a(n,[{key:"_onLoginSuccess",value:function(){var e=this,t=this.tim.storage,n=t.getItem(this.TAG,!1);Ke(n)||(ie.log("SumStatController._onLoginSuccess get sumstatlog in storage, nums="+n.length),n.forEach((function(t){e._statInfoArr.push(t)})),t.removeItem(this.TAG,!1))}},{key:"recordLongPollingID",value:function(e){this._lpID=e}},{key:"addTotalCount",value:function(e){this._successRateCalc.addTotalCount(e)?1===this._successRateCalc.getTotalCount(e)&&(this._lastReportTime=Date.now()):ie.warn("SumStatController.addTotalCount invalid key:",e)}},{key:"addSuccessCount",value:function(e){this._successRateCalc.addSuccessCount(e)||ie.warn("SumStatController.addSuccessCount invalid key:",e)}},{key:"addCost",value:function(e,t){this._avgCalc.push(e,t)?(ie.debug("SumStatController.addCost",e,t,this._avgCalc.getSize(e)),this._avgCalc.getSize(e)>=this._thresholdMap.get(e)&&this._report(e)):ie.warn("SumStatController.addCost invalid key or cost:",e,t)}},{key:"_getItemNum",value:function(e){switch(e){case dr:return 1;case mr:return 2;case fr:return 3;case Cr:return 4;case Er:return 5;case _r:return 6;case vr:return 7;case yr:return 8;case Ir:return 9;case Mr:return 10;default:return 100}}},{key:"_getStatInfo",value:function(e){var t=null;return this._avgCalc.getSize(e)>0&&(t={SDKAppID:"".concat(this.tim.context.SDKAppID),version:"".concat("2.8.0"),tinyID:this.tim.context.tinyID,userID:this.tim.loginInfo.identifier,item:this._getItemNum(e),lpID:e===dr?this._lpID:"",platform:this._platform,scene:this.tim.context.scene,networkType:this.getNetworkType(),total:this._successRateCalc.getTotalCount(e),successRate:this._successRateCalc.getSuccessRate(e),avg:this._avgCalc.getAvg(e),timespan:Date.now()-this._lastReportTime,time:Ce()}),t}},{key:"_report",value:function(e){var t=this,n=[],o=null;ge(e)?this._items.forEach((function(e){null!==(o=t._getStatInfo(e))&&n.push(o)})):null!==(o=this._getStatInfo(e))&&n.push(o),ie.debug("SumStatController._report",n),this._statInfoArr.length>0&&(n=n.concat(this.statInfoArr),this._statInfoArr=[]),this._doReport(n)}},{key:"_doReport",value:function(e){var t=this;Ke(e)?ie.warn("SumStatController._doReport statInfoArr is empty, do nothing"):this.request({name:"ssoSumStat",action:"create",param:{table:this.TABLE,report:e}}).then((function(){t._lastReportTime=Date.now(),t._retryCount>0&&(ie.debug("SumStatController._doReport retry success"),t._retryCount=0)})).catch((function(n){ie.warn("SumStatController._doReport, online:".concat(t.getNetworkType()," error:").concat(Me(n)),e),t._retryCount<=1?setTimeout((function(){ie.info("SumStatController._doReport retry",e),t._retryCount+=1,t._doReport(e)}),5e3):(t._retryCount=0,t._statInfoArr=t._statInfoArr.concat(e),t._flushAtOnce())}))}},{key:"_flushAtOnce",value:function(){var e=this.tim.storage,t=e.getItem(this.TAG,!1),n=this._statInfoArr;if(Ke(t))ie.log("SumStatController._flushAtOnce nums="+n.length),e.setItem(this.TAG,n,!0,!1);else{var o=n.concat(t);o.length>10&&(o=o.slice(0,10)),ie.log("SumStatController._flushAtOnce nums="+o.length),e.setItem(this.TAG,o,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){ie.info("SumStatController.reset"),this._report(),this._avgCalc.reset(),this._successRateCalc.reset()}}]),n}(rr),zs=function(){function t(){i(this,t),this._funcMap=new Map}return a(t,[{key:"defense",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);var o=null;return this._funcMap.get(e).has(t)?o=this._funcMap.get(e).get(t):(o=this._pack(e,t,n),this._funcMap.get(e).set(t,o)),o}},{key:"defenseOnce",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return"function"!=typeof t?null:this._pack(e,t,n)}},{key:"find",value:function(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)?this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(ie.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(ie.log("SafetyCallback.find: 找不到 eventName-".concat(e," 对应的 func")),null)}},{key:"delete",value:function(e,t){return"function"==typeof t&&(!!this._funcMap.has(e)&&(!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)))}},{key:"_pack",value:function(t,n,o){return function(){try{n.apply(o,Array.from(arguments))}catch(a){var r=Object.values(e).indexOf(t);if(-1!==r){var i=Object.keys(e)[r];ie.warn("接入侧事件 TIM.EVENT.".concat(i," 对应的回调函数逻辑存在问题,请检查!"),a)}var s=new kr(Li);s.setText("eventName=".concat(t)).setMessage(a.message).setEnd()}}}}]),t}(),Js=function(e){p(n,e);var t=I(n);function n(e){var o;return i(this,n),(o=t.call(this,e))._maybeLostSequencesMap=new Map,o}return a(n,[{key:"onMessageMaybeLost",value:function(e,t,n){this._maybeLostSequencesMap.has(e)||this._maybeLostSequencesMap.set(e,[]);for(var o=this._maybeLostSequencesMap.get(e),r=0;r<n;r++)o.push(t+r);ie.debug("MessageLossController.onMessageMaybeLost. maybeLostSequences:".concat(o))}},{key:"detectMessageLoss",value:function(e,t){var n=this._maybeLostSequencesMap.get(e);if(!Ke(n)&&!Ke(t)){var o=t.filter((function(e){return-1!==n.indexOf(e)}));if(ie.debug("MessageLossController.detectMessageLoss. matchedSequences:".concat(o)),n.length===o.length)ie.info("MessageLossController.detectMessageLoss no message loss. conversationID=".concat(e));else{var r,i=n.filter((function(e){return-1===o.indexOf(e)})),s=i.length;s<=5?r=e+"-"+i.join("-"):(i.sort((function(e,t){return e-t})),r=e+" start:"+i[0]+" end:"+i[s-1]+" count:"+s),new kr(Ti).setText(r).setNetworkType(this.getNetworkType()).setEnd(),ie.warn("MessageLossController.detectMessageLoss message loss detected. conversationID:".concat(e," lostSequences:").concat(i))}n.length=0}}},{key:"reset",value:function(){ie.log("MessageLossController.reset"),this._maybeLostSequencesMap.clear()}}]),n}(rr),Xs=function(e){p(s,e);var n,o=I(s);function s(e){var t;return i(this,s),(t=o.call(this,e))._request=P?new bi:new Gi,t}return a(s,[{key:"sendMessage",value:(n=r(regeneratorRuntime.mark((function e(t){var n,o,r,i,s,a,u,c,l,p,g,h,d,m,f,_,v,y,I;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=this._constructMessageInstance(t))){e.next=3;break}return e.abrupt("return",pr({code:Ot.MESSAGE_SEND_FAIL,message:bt}));case 3:return o=Date.now(),r=Ke(t.GroupId)?"openim/sendmsg":"group_open_http_svc/send_group_msg",i=this.tim.context,s=i.a2Key,a=i.tinyID,u=i.SDKAppID,c=i.identifier,l=!0===this.tim.context.oversea?"api.im.qcloud.com":"webim.tim.qq.com",p="https://"+l+"/v4/"+r+"?platform=10&websdkappid=537048168&v=1.7.3&a2="+s+"&tinyid="+a+"&sdkappid="+u+"&contentType=json&apn=1&reqtime="+Date.now()+"tjg_id="+this._generateTjgID(n),g={url:p,data:t,method:"POST"},this._addSendMessageTotalCount(n),(h=new kr(qr)).setText("".concat(this._generateTjgID(n),"-").concat(n.from,"-").concat(n.to,"-").concat(n.getElements().length)),e.prev=12,e.next=15,this._request.request(g);case 15:if(d=e.sent,m=d.data,f=m.ErrorCode,_=m.ErrorInfo,0===f){e.next=21;break}return h.setCode(f).setMessage(_).setNetworkType(this.getNetworkType()).setEnd(),n.status=We.FAIL,e.abrupt("return",pr(new kt({code:f,message:_||bt,data:{message:n}})));case 21:return this._addSendMessageSuccessCount(n,o),n.status=We.SUCCESS,v=d.data,y=v.MsgTime,I=v.MsgSeq,n.time=y,I&&(n.sequence=I),n.generateMessageID(c),this.tim.messageController.pushToMessageList(n),this.emitInnerEvent(mo,{eventDataList:[{conversationID:n.conversationID,unreadCount:0,type:n.conversationType,subType:n.conversationSubType,lastMessage:n}]}),e.abrupt("return",lr(n));case 32:return e.prev=32,e.t0=e.catch(12),this.probeNetwork().then((function(t){var n=M(t,2),o=n[0],r=n[1];h.setError(e.t0,o,r).setEnd()})),ie.warn("ComboMessageController.sendMessage failed. error:",e.t0),n.status=We.FAIL,e.abrupt("return",pr(new kt({code:Ot.MESSAGE_SEND_FAIL,message:bt,data:{message:n}})));case 38:case"end":return e.stop()}}),e,this,[[12,32]])}))),function(e){return n.apply(this,arguments)})},{key:"_constructMessageInstance",value:function(e){var n=null;try{var o=this.tim.context.identifier,r={};r.currentUser=o,r.from=e.From_Account||o,e.GroupId?(r.conversationID="".concat(t.CONV_GROUP).concat(e.GroupId),r.conversationType=t.CONV_GROUP,r.to=e.GroupId):e.To_Account&&(r.conversationID="".concat(t.CONV_C2C).concat(e.To_Account),r.conversationType=t.CONV_C2C,r.to=e.To_Account),r.time=e.MsgTimeStamp||0,r.random=e.Random||e.MsgRandom||0,r.priority=e.MsgPriority,(n=new Kn(r)).status=We.UNSEND;for(var i,s=e.MsgBody.length,a=0;a<s;a++)"TIMTextElem"===(i=e.MsgBody[a]).MsgType?n.setTextElement(i.MsgContent.Text):"TIMCustomElem"===i.MsgType?n.setCustomElement({data:i.MsgContent.Data||"",description:i.MsgContent.Desc||"",extension:i.MsgContent.Ext||""}):"TIMFaceElem"===i.MsgType&&n.setFaceElement({index:i.MsgContent.Index,data:i.MsgContent.Data});var u=n.getElements();n.payload=u[0].content,n.type=u[0].type}catch(c){n=null,ie.error("ComboMessageController._constructMessageInstance failed. error:",c)}return n}},{key:"_addSendMessageSuccessCount",value:function(e,t){var n=this.tim.sumStatController,o=Math.abs(Date.now()-t);n.addSuccessCount(fr),n.addCost(fr,o);var r=this._getSendMessageSpecifiedKey(e);r&&(n.addSuccessCount(r),n.addCost(r,o))}},{key:"_addSendMessageTotalCount",value:function(e){var t=this.tim.sumStatController;t.addTotalCount(fr);var n=this._getSendMessageSpecifiedKey(e);n&&t.addTotalCount(n)}},{key:"_getSendMessageSpecifiedKey",value:function(e){if(e.conversationType===t.CONV_C2C)return _r;if(e.conversationType===t.CONV_GROUP){var n=this.tim.groupController.getLocalGroupProfile(e.to);if(!n)return;var o=n.type;if(Le(o))return vr;if(we(o))return yr;if(Pe(o))return Ir;if(Ge(o))return Mr}}},{key:"_generateTjgID",value:function(e){return this.tim.context.tinyID+"-"+e.random}},{key:"reset",value:function(){ie.info("ComboMessageController.reset")}}]),s}(rr),Qs=function(){function t(e){i(this,t);var n=new kr(Or);or.mixin(this),this._initOptions(e),this._initMemberVariables(),this._initControllers(),this._initListener(),kr.bindController(this.eventStatController),n.setText("instanceID=".concat(this.loginInfo.instanceID,"-oversea=").concat(this.loginInfo.oversea,"-mp=").concat(P,"-ua=").concat(G)).setEnd(),ie.info("SDK instanceID:".concat(this.loginInfo.instanceID," oversea:").concat(this.loginInfo.oversea," inWxMiniApp:").concat(P,", SDKAppID:").concat(e.SDKAppID,", UserAgent:").concat(G)),this._safetyCallbackFactory=new zs}var n;return a(t,[{key:"login",value:function(e){return ie.time(gr),this._ssoLog=new kr(Rr),this.netMonitor.start(),this.loginInfo.identifier=e.identifier||e.userID,this.loginInfo.userSig=e.userSig,this.signController.login(this.loginInfo)}},{key:"logout",value:function(){var e=this.signController.logout();return this.resetSDK(),e}},{key:"on",value:function(t,n,o){t===e.GROUP_SYSTEM_NOTICE_RECEIVED&&ie.warn("!!!TIM.EVENT.GROUP_SYSTEM_NOTICE_RECEIVED v2.6.0起弃用,为了更好的体验,请在 TIM.EVENT.MESSAGE_RECEIVED 事件回调内接收处理群系统通知,详细请参考:https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/Message.html#.GroupSystemNoticePayload"),ie.debug("on","eventName:".concat(t)),this.outerEmitter.on(t,this._safetyCallbackFactory.defense(t,n,o),o)}},{key:"once",value:function(e,t,n){ie.debug("once","eventName:".concat(e)),this.outerEmitter.once(e,this._safetyCallbackFactory.defenseOnce(e,t,n),n||this)}},{key:"off",value:function(e,t,n,o){ie.debug("off","eventName:".concat(e));var r=this._safetyCallbackFactory.find(e,t);null!==r&&(this.outerEmitter.off(e,r,n,o),this._safetyCallbackFactory.delete(e,t))}},{key:"registerPlugin",value:function(e){var t=this;this.plugins||(this.plugins={}),Object.keys(e).forEach((function(n){t.plugins[n]=e[n]})),new kr(Pr).setText("key=".concat(Object.keys(e))).setEnd()}},{key:"getPlugin",value:function(e){return this.plugins[e]||void 0}},{key:"setLogLevel",value:function(e){if(e<=0){console.log([""," ________ ______ __ __ __ __ ________ _______","| \\| \\| \\ / \\| \\ _ | \\| \\| \\"," \\$$$$$$$$ \\$$$$$$| $$\\ / $$| $$ / \\ | $$| $$$$$$$$| $$$$$$$\\"," | $$ | $$ | $$$\\ / $$$| $$/ $\\| $$| $$__ | $$__/ $$"," | $$ | $$ | $$$$\\ $$$$| $$ $$$\\ $$| $$ \\ | $$ $$"," | $$ | $$ | $$\\$$ $$ $$| $$ $$\\$$\\$$| $$$$$ | $$$$$$$\\"," | $$ _| $$_ | $$ \\$$$| $$| $$$$ \\$$$$| $$_____ | $$__/ $$"," | $$ | $$ \\| $$ \\$ | $$| $$$ \\$$$| $$ \\| $$ $$"," \\$$ \\$$$$$$ \\$$ \\$$ \\$$ \\$$ \\$$$$$$$$ \\$$$$$$$","",""].join("\n")),console.log("%cIM 智能客服,随时随地解决您的问题 →_→ https://cloud.tencent.com/act/event/smarty-service?from=im-doc","color:#ff0000");console.log(["","参考以下文档,会更快解决问题哦!(#^.^#)\n","SDK 更新日志: https://cloud.tencent.com/document/product/269/38492\n","SDK 接口文档: https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html\n","常见问题: https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/tutorial-01-faq.html\n","反馈问题?戳我提 issue: https://github.com/tencentyun/TIMSDK/issues\n","如果您需要在生产环境关闭上面的日志,请 tim.setLogLevel(1)\n"].join("\n"))}ie.setLevel(e)}},{key:"downloadLog",value:function(){var e=document.createElement("a"),t=new Date,n=new Blob(this.getLog());e.download="TIM-"+t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()+"-"+this.loginInfo.SDKAppID+"-"+this.context.identifier+".txt",e.href=URL.createObjectURL(n),e.click(),URL.revokeObjectURL(n)}},{key:"destroy",value:function(){this.logout(),this.outerEmitter.emit(e.SDK_DESTROY,{SDKAppID:this.loginInfo.SDKAppID})}},{key:"createTextMessage",value:function(e){return this.messageController.createTextMessage(e)}},{key:"createImageMessage",value:function(e){return this.messageController.createImageMessage(e)}},{key:"createAudioMessage",value:function(e){return this.messageController.createAudioMessage(e)}},{key:"createVideoMessage",value:function(e){return this.messageController.createVideoMessage(e)}},{key:"createCustomMessage",value:function(e){return this.messageController.createCustomMessage(e)}},{key:"createFaceMessage",value:function(e){return this.messageController.createFaceMessage(e)}},{key:"createFileMessage",value:function(e){return this.messageController.createFileMessage(e)}},{key:"sendMessage",value:function(e,t){return e instanceof Kn?this.messageController.sendMessageInstance(e,t):pr(new kt({code:Ot.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:qt}))}},{key:"callExperimentalAPI",value:(n=r(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("sendComboMessage"!==t){e.next=4;break}return e.next=3,this.comboMessageController.sendMessage(n);case 3:return e.abrupt("return",e.sent);case 4:return e.abrupt("return",pr(new kt({code:Ot.INVALID_OPERATION,message:wn})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"revokeMessage",value:function(e){return this.messageController.revokeMessage(e)}},{key:"resendMessage",value:function(e){return this.messageController.resendMessage(e)}},{key:"getMessageList",value:function(e){return this.messageController.getMessageList(e)}},{key:"setMessageRead",value:function(e){return this.messageController.setMessageRead(e)}},{key:"getConversationList",value:function(){return this.conversationController.getConversationList()}},{key:"getConversationProfile",value:function(e){return this.conversationController.getConversationProfile(e)}},{key:"deleteConversation",value:function(e){return this.conversationController.deleteConversation(e)}},{key:"getMyProfile",value:function(){return this.userController.getMyProfile()}},{key:"getUserProfile",value:function(e){return this.userController.getUserProfile(e)}},{key:"updateMyProfile",value:function(e){return this.userController.updateMyProfile(e)}},{key:"getFriendList",value:function(){return this.userController.getFriendList()}},{key:"deleteFriend",value:function(e){return this.userController.deleteFriend(e)}},{key:"getBlacklist",value:function(){return this.userController.getBlacklist()}},{key:"addToBlacklist",value:function(e){return this.userController.addBlacklist(e)}},{key:"removeFromBlacklist",value:function(e){return this.userController.deleteBlacklist(e)}},{key:"getGroupList",value:function(e){return this.groupController.getGroupList(e)}},{key:"getGroupProfile",value:function(e){return this.groupController.getGroupProfile(e)}},{key:"createGroup",value:function(e){return this.groupController.createGroup(e)}},{key:"dismissGroup",value:function(e){return this.groupController.dismissGroup(e)}},{key:"updateGroupProfile",value:function(e){return this.groupController.updateGroupProfile(e)}},{key:"joinGroup",value:function(e){return this.groupController.joinGroup(e)}},{key:"quitGroup",value:function(e){return this.groupController.quitGroup(e)}},{key:"searchGroupByID",value:function(e){return this.groupController.searchGroupByID(e)}},{key:"changeGroupOwner",value:function(e){return this.groupController.changeGroupOwner(e)}},{key:"handleGroupApplication",value:function(e){return this.groupController.handleGroupApplication(e)}},{key:"setMessageRemindType",value:function(e){return this.groupController.setMessageRemindType(e)}},{key:"getGroupMemberList",value:function(e){return this.groupController.getGroupMemberList(e)}},{key:"getGroupMemberProfile",value:function(e){return this.groupController.getGroupMemberProfile(e)}},{key:"getGroupOnlineMemberCount",value:function(e){return this.groupController.getGroupOnlineMemberCount(e)}},{key:"addGroupMember",value:function(e){return this.groupController.addGroupMember(e)}},{key:"deleteGroupMember",value:function(e){return this.groupController.deleteGroupMember(e)}},{key:"setGroupMemberMuteTime",value:function(e){return this.groupController.setGroupMemberMuteTime(e)}},{key:"setGroupMemberRole",value:function(e){return this.groupController.setGroupMemberRole(e)}},{key:"setGroupMemberNameCard",value:function(e){return this.groupController.setGroupMemberNameCard(e)}},{key:"setGroupMemberCustomField",value:function(e){return this.groupController.setGroupMemberCustomField(e)}},{key:"_initOptions",value:function(e){this.plugins={},this._sdkReloadFlag=!1;var t=e.SDKAppID||0,n=Te();this.context={SDKAppID:t,accountType:n},this.loginInfo={SDKAppID:t,accountType:n,identifier:null,userSig:null,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,avchatroomIDList:[],instanceID:qe()},this.options={runLoopNetType:e.runLoopNetType||ct,enablePointer:e.enablePointer||!1}}},{key:"_initMemberVariables",value:function(){this.innerEmitter=new Is,this.outerEmitter=new Is,cr(this.outerEmitter),this.packageConfig=new Cs(this),this.storage=new ys(this),this.netMonitor=new js,this.outerEmitter._emit=this.outerEmitter.emit,this.outerEmitter.emit=function(e,t){var n=arguments[0],o=[n,{name:arguments[0],data:arguments[1]}];this.outerEmitter._emit.apply(this.outerEmitter,o)}.bind(this),this.innerEmitter._emit=this.innerEmitter.emit,this.innerEmitter.emit=function(e,t){var n;le(arguments[1])&&arguments[1].data?(ie.warn("inner eventData has data property, please check!"),n=[e,{name:arguments[0],data:arguments[1].data}]):n=[e,{name:arguments[0],data:arguments[1]}],this.innerEmitter._emit.apply(this.innerEmitter,n)}.bind(this)}},{key:"_initControllers",value:function(){this.exceptionController=new Vi(this),this.connectionController=new xi(this),this.contextController=new sr(this),this.context=this.contextController.getContext(),this.signController=new Pi(this),this.messageController=new cs(this),this.comboMessageController=new Xs(this),this.conversationController=new ns(this),this.userController=new Ji(this),this.groupController=new fs(this),this.notificationController=new Ss(this),this.bigDataHallwayController=new Os(this),this.statusController=new _s(this),this.uploadController=new ks(this),this.messageLossController=new Js(this),this.eventStatController=new Ks(this),this.sumStatController=new Ws(this),this.mtaReportController=new xs(this),this._initReadyListener()}},{key:"_initListener",value:function(){var e=this;if(this.innerEmitter.on(Xo,this._onSDKReload,this),P&&"function"==typeof wx.onAppShow&&"function"==typeof wx.onAppHide){var t=null;wx.onAppHide((function(){t=new kr(Ni)})),wx.onAppShow((function(){null!==t&&t.setNetworkType(e.netMonitor.getNetworkType()).setEnd()}))}}},{key:"_initReadyListener",value:function(){for(var e=this,t=this.readyList,n=0,o=t.length;n<o;n++)this[t[n]].ready((function(){return e._readyHandle()}))}},{key:"_onSDKReload",value:function(){var e=this;ie.log("sdk reloading..."),this.resetSDK(),this.login(this.loginInfo).then((function(t){e._sdkReloadFlag=!0}))}},{key:"resetSDK",value:function(){var t=this;this.initList.forEach((function(e){t[e].reset&&t[e].reset()})),this.netMonitor.reset(),this.storage.reset(),this.resetReady(),this._initReadyListener(),this.outerEmitter.emit(e.SDK_NOT_READY)}},{key:"_readyHandle",value:function(){for(var t=this.readyList,n=!0,o=0,r=t.length;o<r;o++)if(!this[t[o]].isReady()){n=!1;break}if(n){var i=ie.timeEnd(gr);ie.warn("SDK is ready. cost=".concat(i,"ms")),this.triggerReady(),this.innerEmitter.emit(Jo),this.outerEmitter.emit(e.SDK_READY),this._sdkReloadFlag&&(this.outerEmitter.emit(e.SDK_RELOAD),this.groupController.AVChatRoomHandler.joinAVChatRoomSilently(),this._sdkReloadFlag=!1),this._ssoLog.setNetworkType(this.netMonitor.getNetworkType()).setText(i).setEnd()}}}]),t}();Qs.prototype.readyList=["conversationController"],Qs.prototype.initList=["exceptionController","connectionController","signController","contextController","messageController","comboMessageController","conversationController","userController","groupController","notificationController","eventStatController","sumStatController","messageLossController","statusController"];var Zs={login:"login",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin",getGroupOnlineMemberCount:"getGroupOnlineMemberCount"};function ea(e,t){return!(!e.isReady()&&void 0===Zs[t])||(e.innerEmitter.emit(Ho,new kt({code:Ot.SDK_IS_NOT_READY,message:"".concat(t," ").concat(Pn,",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/module-EVENT.html#.SDK_READY")})),!1)}var ta={},na={};return na.create=function(t){if(t.SDKAppID&&ta[t.SDKAppID])return ta[t.SDKAppID];ie.log("TIM.create");var n=new Qs(t);n.on(e.SDK_DESTROY,(function(e){ta[e.data.SDKAppID]=null,delete ta[e.data.SDKAppID]}));var o=function(e){var t=Object.create(null);return Object.keys(Jn).forEach((function(n){if(e[n]){var o=Jn[n],r=new S;t[o]=function(){var t=Array.from(arguments);return r.use((function(t,o){return ea(e,n)?o():pr(new kt({code:Ot.SDK_IS_NOT_READY,message:"".concat(n," ").concat(Pn,"。")}))})).use((function(e,t){if(!0===He(e,zn[n],o))return t()})).use((function(t,o){return e[n].apply(e,t)})),r.run(t)}}})),t}(n);return ta[t.SDKAppID]=o,ie.log("TIM.create ok"),o},na.TYPES=t,na.EVENT=e,na.VERSION="2.8.0",ie.log("TIM.VERSION: ".concat(na.VERSION)),na}));
|