12345678910 |
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TSignaling=t():e.TSignaling=t()}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";n.d(t,"e",(function(){return g})),n.d(t,"g",(function(){return m})),n.d(t,"c",(function(){return _})),n.d(t,"f",(function(){return v})),n.d(t,"b",(function(){return I})),n.d(t,"d",(function(){return M})),n.d(t,"a",(function(){return T})),n.d(t,"h",(function(){return S}));const o="undefined"!=typeof window,r=("undefined"!=typeof wx&&wx.getSystemInfoSync,o&&window.navigator&&window.navigator.userAgent||""),i=/AppleWebKit\/([\d.]+)/i.exec(r),s=(i&&parseFloat(i.pop()),/iPad/i.test(r)),a=/iPhone/i.test(r)&&!s,u=/iPod/i.test(r),c=a||s||u,l=(function(){const e=r.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),/Android/i.test(r)),p=function(){const e=r.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),h=(l&&/webkit/i.test(r),/Firefox/i.test(r),/Edge/i.test(r)),d=!h&&/Chrome/i.test(r),f=(function(){const e=r.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(r),/MSIE\s8\.0/.test(r),function(){const e=/MSIE\s(\d+)\.\d/.exec(r);let t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(r)&&/rv:11.0/.test(r)&&(t=11)}(),/Safari/i.test(r),/TBS\/\d+/i.test(r));(function(){const e=r.match(/TBS\/(\d+)/i);if(e&&e[1])e[1]})(),!f&&/MQQBrowser\/\d+/i.test(r),!f&&/ QQBrowser\/\d+/i.test(r),/(micromessenger|webbrowser)/i.test(r),/Windows/i.test(r),/MAC OS X/i.test(r),/MicroMessenger/i.test(r);n(2),n(1);const g=function(e){return"map"===C(e)},m=function(e){return"set"===C(e)},_=function(e){return"file"===C(e)},v=function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n},y=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===C(e)},I=function(e){return y(e)||function(e){return null!==e&&"object"==typeof e}(e)},M=function(e){return e instanceof Error},C=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()};let E=0;Date.now||(Date.now=function(){return(new Date).getTime()});const T={now:function(){0===E&&(E=Date.now()-1);const e=Date.now()-E;return e>4294967295?(E+=4294967295,Date.now()-E):e},utc:function(){return Math.round(Date.now()/1e3)}},S=function(e){return JSON.stringify(e,["message","code"])}},function(e,t,n){"use strict";n.r(t);var o=n(3),r=n(0);let i=0;const s=new Map;function a(){const e=new Date;return"TSignaling "+e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())+":"}const u={_data:[],_length:0,_visible:!1,arguments2String(e){let t;if(1===e.length)t=a()+e[0];else{t=a();for(let n=0,o=e.length;n<o;n++)Object(r.b)(e[n])?Object(r.d)(e[n])?t+=Object(r.h)(e[n]):t+=JSON.stringify(e[n]):t+=e[n],t+=" "}return t},debug:function(){if(i<=-1){const e=this.arguments2String(arguments);u.record(e,"debug"),o.a.debug(e)}},log:function(){if(i<=0){const e=this.arguments2String(arguments);u.record(e,"log"),o.a.log(e)}},info:function(){if(i<=1){const e=this.arguments2String(arguments);u.record(e,"info"),o.a.info(e)}},warn:function(){if(i<=2){const e=this.arguments2String(arguments);u.record(e,"warn"),o.a.warn(e)}},error:function(){if(i<=3){const e=this.arguments2String(arguments);u.record(e,"error"),o.a.error(e)}},time:function(e){s.set(e,r.a.now())},timeEnd:function(e){if(s.has(e)){const t=r.a.now()-s.get(e);return s.delete(e),t}return o.a.warn(`未找到对应label: ${e}, 请在调用 logger.timeEnd 前,调用 logger.time`),0},setLevel:function(e){e<4&&o.a.log(a()+"set level from "+i+" to "+e),i=e},record:function(e,t){1100===u._length&&(u._data.splice(0,100),u._length=1e3),u._length++,u._data.push(`${e} [${t}] \n`)},getLog:function(){return u._data}};t.default=u},function(e,t,n){"use strict";n.r(t);t.default={MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",ENTER_ROOM_SUCCESS:"JoinedSuccess",ALREADY_IN_ROOM:"AlreadyInGroup"}},function(e,t,n){"use strict";(function(e){let n,o;n="undefined"!=typeof console?console:void 0!==e&&e.console?e.console:"undefined"!=typeof window&&window.console?window.console:{};const r=function(){},i=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let s=i.length;for(;s--;)o=i[s],console[o]||(n[o]=r);n.methods=i,t.a=n}).call(this,n(6))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={NEW_INVITATION_RECEIVED:"ts_new_invitation_received",INVITEE_ACCEPTED:"ts_invitee_accepted",INVITEE_REJECTED:"ts_invitee_rejected",INVITATION_CANCELLED:"ts_invitation_cancelled",INVITATION_TIMEOUT:"ts_invitation_timeout",SDK_READY:"ts_im_ready",SDK_NOT_READY:"ts_im_not_ready",TEXT_MESSAGE_RECEIVED:"ts_text_message_received",CUSTOM_MESSAGE_RECEIVED:"ts_custom_message_received",REMOTE_USER_JOIN:"ts_remote_user_join",REMOTE_USER_LEAVE:"ts_remote_user_leave",KICKED_OUT:"ts_kicked_out",NET_STATE_CHANGE:"ts_net_state_change"}},function(e,t){function n(e){return e=window.localStorage?localStorage.getItem(e)||sessionStorage.getItem(e):(e=document.cookie.match(new RegExp("(?:^|;\\s)"+e+"=(.*?)(?:;\\s|$)")))?e[1]:""}function o(e,t,n){if(window.localStorage)try{n?localStorage.setItem(e,t):sessionStorage.setItem(e,t)}catch(e){}else document.cookie=e+"="+t+";path=/;domain="+function(){var e=window.location.host,t=e.split(".");return 2<t.length&&(e=({"com.cn":1,"js.cn":1,"net.cn":1,"gov.cn":1,"com.hk":1,"co.nz":1}[t.slice(-2).join(".")]?t.slice(-3):t.slice(-2)).join(".")),e}()+(n?";expires="+n:"")}function r(e,t){var n,o={};if(void 0===t)var r=window.location,i=r.host,s=r.pathname,a=r.search.substr(1),u=r.hash;else i=(r=t.match(/\w+:\/\/((?:[\w-]+\.)+\w+)(?::\d+)?(\/[^\?\\"'\|:<>]*)?(?:\?([^'"\\<>#]*))?(?:#(\w+))?/i)||[])[1],s=r[2],a=r[3],u=r[4];return void 0!==u&&(u=u.replace(/"|'|<|>/gi,"M")),a&&function(){for(var e=a.split("&"),t=0,n=e.length;t<n;t++)if(-1!=e[t].indexOf("=")){var r=e[t].indexOf("="),i=e[t].slice(0,r);r=e[t].slice(r+1),o[i]=r}}(),a=function(){if(void 0===a)return a;for(var t=a.split("&"),n=[],o=0,r=t.length;o<r;o++)if(-1!=t[o].indexOf("=")){var i=t[o].indexOf("="),s=t[o].slice(0,i);i=t[o].slice(i+1),e.ignoreParams&&-1!=e.ignoreParams.indexOf(s)||n.push(s+"="+i)}return n.join("&")}(),u&&function(){for(var e=0==u.indexOf("#")?u.substr(1).split("&"):u.split("&"),t=0,o=e.length;t<o;t++)if(-1!=e[t].indexOf("=")){var r=e[t].indexOf("="),i=e[t].slice(0,r);if(r=e[t].slice(r+1),"adtag"===i.toLowerCase()){n=r;break}}}(),{host:i,path:s,search:a,hash:u,param:o,adtag:n}}function i(e){var t,i=r(e),a={dm:i.host,pvi:"",si:"",url:i.path,arg:encodeURIComponent(i.search||"").substr(0,512),ty:0};return a.pvi=function(){var t=new Date((new Date).getTime()+63072e6).toGMTString();if(e.userReport){var r=n("pgv_uid");r&&r==e.user.user_id||(a.ty=1,o("pgv_uid",e.user.user_id,t)),r=e.user.user_id}else(r=n("pgv_pvi"))||(a.ty=1,o("pgv_pvi",r=s(),t));return r}(),a.si=((t=n("pgv_si"))||o("pgv_si",t=s("s")),t),a.url=function(){var t=i.path;return e.senseQuery&&(t+=i.search?"?"+encodeURIComponent(i.search||"").substr(0,512):""),e.senseHash&&(t+=i.hash?encodeURIComponent(i.hash):""),t}(),a}function s(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 a(e){return{r2:e.sid}}function u(e){var t={};if(e){var n,o=[];for(n in e)e.hasOwnProperty(n)&&o.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));e=o.join(";"),t.ext=e}return t}function c(e){var t=r(e,document.referrer);return e=r(e),{rdm:t.host,rurl:t.path,rarg:encodeURIComponent(t.search||"").substr(0,512),adt:e.param.ADTAG||e.param.adtag||e.param.CKTAG||e.param.cktag||e.param.PTAG||e.param.ptag||e.adtag}}function l(){try{var e=navigator,t=screen||{width:"",height:"",colorDepth:""},n={scr:t.width+"x"+t.height,scl:t.colorDepth+"-bit",lg:(e.language||e.userLanguage).toLowerCase(),tz:(new Date).getTimezoneOffset()/60}}catch(e){return{}}return n}e.exports={conf:{},version:"2.0.19",init:function(e){var t={sid:0,cid:0,autoReport:0,senseHash:0,senseQuery:0,userReport:0,performanceMonitor:0,ignoreParams:[]};if(e)for(var n in e)e.hasOwnProperty(n)&&t.hasOwnProperty(n)&&(t[n]=e[n]);this.conf=t,this.conf.autoReport&&this.pgv()},pgv:function(){var e=this.conf,t=[],n=this.version;if(e.sid)if(!e.userReport||e.user&&e.user.user_id&&!parseInt(e.user.user_id,10)!==conf.user.user_id){for(var o=0,r=[i(e),c(e),a(e),l(),u({version:n}),{random:+new Date}],s=r.length;o<s;o++)for(var p in r[o])r[o].hasOwnProperty(p)&&t.push(p+"="+(void 0===r[o][p]?"":r[o][p]));var h=function(e){e="https://pingtas.qq.com/webview/pingd?"+e.join("&").toLowerCase();var t=new Image;t.onload=t.onerror=t.onabort=function(){t=t.onload=t.onerror=t.onabort=null},t.src=e};h(t),e.performanceMonitor&&(t=function(){for(var t=function(){if(window.performance){var e=window.performance.timing,t={value:e.domainLookupEnd-e.domainLookupStart},n={value:e.connectEnd-e.connectStart},o={value:e.responseStart-(e.requestStart||e.responseStart+1)},r=e.responseEnd-e.responseStart;e.domContentLoadedEventStart?0>r&&(r=0):r=-1,e={domainLookupTime:t,connectTime:n,requestTime:o,resourcesLoadedTime:{value:r},domParsingTime:{value:e.domContentLoadedEventStart?e.domInteractive-e.domLoading:-1},domContentLoadedTime:{value:e.domContentLoadedEventStart?e.domContentLoadedEventStart-e.fetchStart:-1}}}else e="";return e}(),o=[],r=[],s=0,a=[i(e),{r2:e.cid},l(),{random:+new Date}],c=a.length;s<c;s++)for(var p in a[s])a[s].hasOwnProperty(p)&&r.push(p+"="+(void 0===a[s][p]?"":a[s][p]));for(p in t)t.hasOwnProperty(p)&&("domContentLoadedTime"==p?r.push("r3="+t[p].value):o.push(t[p].value));t=u({pfm:o.join("_"),version:n}),r.push("ext="+t.ext),h(r)},void 0!==window.performance&&void 0!==window.performance.timing&&0!=window.performance.timing.loadEventEnd?t():window.attachEvent?window.attachEvent("onload",t):window.addEventListener&&window.addEventListener("load",t,!1))}else console.log("MTA H5分析错误提示:您选择了用户统计uv,请设置业务的user_id,需为int类型");else console.log("MTA H5分析错误提示:您没有设置sid")},clickStat:function(e,t){var n=this.conf,o=[],r=i(n),s=a(n);if(n.cid){r.dm="taclick",r.url=e,s.r2=n.cid,s.r5=function(e){e=void 0===e?{}:e;var t,n=[];for(t in e)e.hasOwnProperty(t)&&n.push(t+"="+encodeURIComponent(e[t]));return n.join(";")}(t);var p=0;for(r=(n=[r,c(n),s,l(),u({version:this.version}),{random:+new Date}]).length;p<r;p++)for(var h in n[p])n[p].hasOwnProperty(h)&&o.push(h+"="+(void 0===n[p][h]?"":n[p][h]));o="https://pingtas.qq.com/webview/pingd?"+o.join("&");var d=new Image;d.onload=d.onerror=d.onabort=function(){d=d.onload=d.onerror=d.onabort=null},d.src=o}else console.log("MTA H5分析错误提示:您没有设置cid,请到管理台开通自定义事件并更新统计代码")},clickShare:function(e){var t,n,o=this.conf,s=r(o),p=void 0===(s=s.param.CKTAG||s.param.ckatg)?[]:s.split(".");if(o.cid){s=[];var h=i(o),d=a(o);for(h.dm="taclick_share",h.url="mtah5-share-"+e,d.r2=o.cid,d.r5=(n=[],2===(t=p).length&&"mtah5_share"==t[0]&&n.push(t[0]+"="+t[1]),n.join(";")),e=0,h=(o=[h,c(o),d,l(),u({version:this.version}),{random:+new Date}]).length;e<h;e++)for(var f in o[e])o[e].hasOwnProperty(f)&&s.push(f+"="+(void 0===o[e][f]?"":o[e][f]));f="https://pingtas.qq.com/webview/pingd?"+s.join("&");var g=new Image;g.onload=g.onerror=g.onabort=function(){g=g.onload=g.onerror=g.onabort=null},g.src=f}else console.log("MTA H5分析错误提示:您没有设置cid,请到管理台开通自定义事件并更新统计代码")}}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(8),s=n(9),a=n(4),u=n(2),c=n(1),l=n(10),p=n(11),h=n(12),d=n(13),f=n(15),g=n(16).version,m=function(){function e(e){if(this._outerEmitter=null,this._safetyCallbackFactory=null,this._tim=null,this._imSDKAppID=0,this._userID=null,this._groupID="",this._isHandling=!1,this._inviteInfoMap=new Map,c.default.info("TSignaling version:"+g),l.default(e.SDKAppID))return c.default.error("TSignaling 请传入 SDKAppID !!!"),null;this._outerEmitter=new s.default,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._safetyCallbackFactory=new p.default,this._tim=f.create({SDKAppID:e.SDKAppID}),this._imSDKAppID=e.SDKAppID,this._tim.on(f.EVENT.SDK_READY,this._onIMReady.bind(this)),this._tim.on(f.EVENT.SDK_NOT_READY,this._onIMNotReady.bind(this)),this._tim.on(f.EVENT.KICKED_OUT,this._onKickedOut.bind(this)),this._tim.on(f.EVENT.NET_STATE_CHANGE,this._onNetStateChange.bind(this)),this._tim.on(f.EVENT.MESSAGE_RECEIVED,this._onMessageReceived.bind(this))}return e.prototype.setLogLevel=function(e){c.default.setLevel(e),this._tim.setLogLevel(e)},e.prototype.login=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){return c.default.log("TSignaling.login",e),this._userID=e.userID,[2,this._tim.login(e)]}))}))},e.prototype.logout=function(){return o(this,void 0,void 0,(function(){return r(this,(function(e){return c.default.log("TSignaling.logout"),this._userID="",this._inviteInfoMap.clear(),[2,this._tim.logout()]}))}))},e.prototype.on=function(e,t,n){c.default.log("TSignaling.on eventName:"+e),this._outerEmitter.on(e,this._safetyCallbackFactory.defense(e,t,n),n)},e.prototype.joinGroup=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){return c.default.log("TSignaling.joinGroup groupID:"+e),this._groupID=e,[2,this._tim.joinGroup({groupID:e})]}))}))},e.prototype.quitGroup=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){return c.default.log("TSignaling.quitGroup groupID:"+e),[2,this._tim.quitGroup(e)]}))}))},e.prototype.sendTextMessage=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){return t=this._tim.createTextMessage({to:e.to,conversationType:!0===e.groupFlag?f.TYPES.CONV_GROUP:f.TYPES.CONV_C2C,priority:e.priority||f.TYPES.MSG_PRIORITY_NORMAL,payload:{text:e.text}}),[2,this._tim.sendMessage(t)]}))}))},e.prototype.sendCustomMessage=function(e){return o(this,void 0,void 0,(function(){var t;return r(this,(function(n){return t=this._tim.createCustomMessage({to:e.to,conversationType:!0===e.groupFlag?f.TYPES.CONV_GROUP:f.TYPES.CONV_C2C,priority:e.priority||f.TYPES.MSG_PRIORITY_NORMAL,payload:{data:e.data||"",description:e.description||"",extension:e.extension||""}}),[2,this._tim.sendMessage(t)]}))}))},e.prototype.invite=function(e){return o(this,void 0,void 0,(function(){var t,n,o,s,a,u;return r(this,(function(r){switch(r.label){case 0:return t=d.generate(),c.default.log("TSignaling.invite",e,"inviteID="+t),l.default(e)||l.default(e.userID)?[2,Promise.reject({code:i.ErrorCode.ERR_INVALID_PARAMETERS,message:"userID is invalid"})]:(n=e.userID,o=e.data,s=e.timeout,a={businessID:i.BusinessID.SIGNAL,inviteID:t,inviter:this._userID,actionType:i.ActionType.INVITE,inviteeList:[n],data:o,timeout:l.default(s)?0:s,groupID:""},[4,this._sendCustomMessage(n,a)]);case 1:return 0===(u=r.sent()).code?(c.default.log("TSignaling.invite ok"),this._inviteInfoMap.set(t,a),this._startTimer(a,!0),[2,{inviteID:t,code:u.code,data:u.data}]):[2,u]}}))}))},e.prototype.inviteInGroup=function(e){return o(this,void 0,void 0,(function(){var t,n,o,s,a,u,p;return r(this,(function(r){switch(r.label){case 0:return t=d.generate(),c.default.log("TSignaling.inviteInGroup",e,"inviteID="+t),l.default(e)||l.default(e.groupID)?[2,Promise.reject({code:i.ErrorCode.ERR_INVALID_PARAMETERS,message:"groupID is invalid"})]:(n=e.groupID,o=e.inviteeList,s=e.data,a=e.timeout,u={businessID:i.BusinessID.SIGNAL,inviteID:t,inviter:this._userID,actionType:i.ActionType.INVITE,inviteeList:o,data:s,timeout:l.default(a)?0:a,groupID:n},[4,this._sendCustomMessage(n,u)]);case 1:return 0===(p=r.sent()).code?(c.default.log("TSignaling.inviteInGroup ok"),this._inviteInfoMap.set(t,u),this._startTimer(u,!0),[2,{inviteID:t,code:p.code,data:p.data}]):[2,p]}}))}))},e.prototype.cancel=function(e){return o(this,void 0,void 0,(function(){var t,n,o,s,a,u,p,h,d;return r(this,(function(r){switch(r.label){case 0:return c.default.log("TSignaling.cancel",e),l.default(e)||l.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling?[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"})]:[3,1];case 1:return this._isHandling=!0,t=e.inviteID,n=e.data,o=this._inviteInfoMap.get(t),s=o.inviter,a=o.groupID,u=o.inviteeList,s!==this._userID?[3,3]:(p={businessID:i.BusinessID.SIGNAL,inviteID:t,inviter:s,actionType:i.ActionType.CANCEL_INVITE,inviteeList:u,data:n,timeout:0,groupID:a},h=a||u[0],[4,this._sendCustomMessage(h,p)]);case 2:return d=r.sent(),this._isHandling=!1,d&&0===d.code?(c.default.log("TSignaling.cancel ok"),this._deleteInviteInfoByID(t),[2,{inviteID:t,code:d.code,data:d.data}]):[2,d];case 3:return c.default.error("TSignaling.cancel unmatched inviter="+s+" and userID="+this._userID),this._isHandling=!1,[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_NO_PERMISSION,message:"信令请求无权限,比如取消非自己发起的邀请,接受或则拒绝非发给自己的邀请"})]}}))}))},e.prototype.accept=function(e){return o(this,void 0,void 0,(function(){var t,n,o,s,a,u,p,h;return r(this,(function(r){switch(r.label){case 0:return c.default.log("TSignaling.accept",e),l.default(e)||l.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling?[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"})]:[3,1];case 1:return this._isHandling=!0,t=e.inviteID,n=e.data,o=this._inviteInfoMap.get(t),s=o.inviter,a=o.groupID,o.inviteeList.includes(this._userID)?(u={businessID:i.BusinessID.SIGNAL,inviteID:t,inviter:s,actionType:i.ActionType.ACCEPT_INVITE,inviteeList:[this._userID],data:n,timeout:0,groupID:a},p=a||s,[4,this._sendCustomMessage(p,u)]):[3,3];case 2:return h=r.sent(),this._isHandling=!1,h&&0===h.code?(c.default.log("TSignaling.accept ok"),this._updateLocalInviteInfo(u),[2,{inviteID:t,code:h.code,data:h.data}]):[2,h];case 3:return c.default.error("TSignaling.accept inviteeList do not include userID="+this._userID+". inviteID="+t+" groupID="+a),this._isHandling=!1,[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"})]}}))}))},e.prototype.reject=function(e){return o(this,void 0,void 0,(function(){var t,n,o,s,a,u,p,h;return r(this,(function(r){switch(r.label){case 0:return c.default.log("TSignaling.reject",e),l.default(e)||l.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling?[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"})]:[3,1];case 1:return this._isHandling=!0,t=e.inviteID,n=e.data,o=this._inviteInfoMap.get(t),s=o.inviter,a=o.groupID,o.inviteeList.includes(this._userID)?(u={businessID:i.BusinessID.SIGNAL,inviteID:t,inviter:s,actionType:i.ActionType.REJECT_INVITE,inviteeList:[this._userID],data:n,timeout:0,groupID:a},p=a||s,[4,this._sendCustomMessage(p,u)]):[3,3];case 2:return h=r.sent(),this._isHandling=!1,h&&0===h.code?(c.default.log("TSignaling.reject ok"),this._updateLocalInviteInfo(u),[2,{inviteID:t,code:h.code,data:h.data}]):[2,h];case 3:return c.default.error("TSignaling.reject inviteeList do not include userID="+this._userID+". inviteID="+t+" groupID="+a),this._isHandling=!1,[2,Promise.reject({code:i.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"})]}}))}))},e.prototype._stat=function(){h.default.clickStat("sdkappid",{value:this._imSDKAppID}),h.default.clickStat("tsignaling_version",{value:g}),h.default.pgv()},e.prototype._onIMReady=function(e){c.default.log("TSignaling._onIMReady"),this._stat(),this._outerEmitter.emit(a.default.SDK_READY)},e.prototype._onIMNotReady=function(e){c.default.log("TSignaling.onSdkNotReady"),this._outerEmitter.emit(a.default.SDK_NOT_READY)},e.prototype._onKickedOut=function(e){c.default.log("TSignaling._onKickedOut"),this._outerEmitter.emit(a.default.KICKED_OUT,e.data)},e.prototype._onNetStateChange=function(e){c.default.log("TSignaling._onNetStateChange"),this._outerEmitter.emit(a.default.NET_STATE_CHANGE,e.data)},e.prototype._onMessageReceived=function(e){var t=this,n=e.data,o=n.filter((function(e){return e.type===f.TYPES.MSG_TEXT}));l.default(o)||this._outerEmitter.emit(a.default.TEXT_MESSAGE_RECEIVED,o);var r=n.filter((function(e){return e.type===f.TYPES.MSG_GRP_TIP&&e.payload.operationType===f.TYPES.GRP_TIP_MBR_JOIN}));l.default(r)||this._outerEmitter.emit(a.default.REMOTE_USER_JOIN,r);var s=n.filter((function(e){return e.type===f.TYPES.MSG_GRP_TIP&&e.payload.operationType===f.TYPES.GRP_TIP_MBR_QUIT}));l.default(s)||this._outerEmitter.emit(a.default.REMOTE_USER_LEAVE,s);var u=n.filter((function(e){return e.type===f.TYPES.MSG_CUSTOM})),p=[];u.forEach((function(e){var n,o=e.payload.data,r=!0;try{n=JSON.parse(o)}catch(e){r=!1}if(r){var s=n.businessID,a=n.actionType;if(1===s)switch(console.warn("信令消息类型",a),a){case i.ActionType.INVITE:t._onNewInvitationReceived(n);break;case i.ActionType.REJECT_INVITE:t._onInviteeRejected(n);break;case i.ActionType.ACCEPT_INVITE:t._onInviteeAccepted(n);break;case i.ActionType.CANCEL_INVITE:t._onInvitationCancelled(n);break;case i.ActionType.INVITE_TIMEOUT:t._onInvitationTimeout(n)}else c.default.warn("TSignaling._onMessageReceived unknown businessID="+s),p.push(e)}else p.push(e)})),l.default(p)||this._outerEmitter.emit(a.default.CUSTOM_MESSAGE_RECEIVED,p)},e.prototype._hasLocalInviteInfo=function(e,t){var n=e.inviteID,o=e.groupID;if(!this._inviteInfoMap.has(n))return!1;var r=this._inviteInfoMap.get(n).inviteeList;return!o||(t?r.length>0:r.length>0&&r.includes(this._userID))},e.prototype._startTimer=function(e,t){var n=this;void 0===t&&(t=!0);var o=e.timeout;if(c.default.log("TSignaling._startTimer timeout="+o+" isInvitator="+t),0!==o)var r=t?o+5:o,i=1,s=setInterval((function(){var o=n._hasLocalInviteInfo(e,t);i<r&&o?++i:(o&&n._sendTimeoutNotice(e,t),clearInterval(s))}),1e3)},e.prototype._sendTimeoutNotice=function(e,t){return o(this,void 0,void 0,(function(){var n,o,s,u,l,p,h,d;return r(this,(function(r){switch(r.label){case 0:return n=e.inviteID,o=e.groupID,s=e.inviteeList,u=e.inviter,l=e.data,p=t?o||s[0]:o||u,c.default.log("TSignaling._sendTimeoutNotice inviteID="+n+" to="+p+" isInvitator="+t),h={businessID:i.BusinessID.SIGNAL,inviteID:n,inviter:u,actionType:i.ActionType.INVITE_TIMEOUT,inviteeList:t?s:[this._userID],data:l,timeout:0,groupID:o},[4,this._sendCustomMessage(p,h)];case 1:return(d=r.sent())&&0===d.code&&(this._outerEmitter.emit(a.default.INVITATION_TIMEOUT,{inviteID:n,inviteeList:h.inviteeList,isSelfTimeout:!0}),t?this._deleteInviteInfoByID(n):this._updateLocalInviteInfo(h)),[2,d]}}))}))},e.prototype._onNewInvitationReceived=function(t){var n=t.inviteID,o=t.inviter,r=t.inviteeList,i=t.groupID,s=r.includes(this._userID);c.default.log("TSignaling._onNewInvitationReceived",t,"myselfIncluded="+s),(i&&s||!i)&&(this._inviteInfoMap.set(n,t),this._outerEmitter.emit(e.EVENT.NEW_INVITATION_RECEIVED,{inviteID:n,inviter:o,groupID:i,inviteeList:r,data:t.data||""}),this._startTimer(t,!1))},e.prototype._onInviteeRejected=function(e){var t=e.inviteID,n=e.inviter,o=e.groupID,r=this._inviteInfoMap.has(t);c.default.log("TSignaling._onInviteeRejected inviteID="+t+" hasInviteID="+r+" inviter="+n+" groupID="+o),(o&&r||!o)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(a.default.INVITEE_REJECTED,{inviteID:t,invitee:e.inviteeList[0],data:e.data||""}))},e.prototype._onInviteeAccepted=function(e){var t=e.inviteID,n=e.inviter,o=e.groupID,r=this._inviteInfoMap.has(t);c.default.log("TSignaling._onInviteeAccepted inviteID="+t+" hasInviteID="+r+" inviter="+n+" groupID="+o),(o&&r||!o)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(a.default.INVITEE_ACCEPTED,{inviteID:t,invitee:e.inviteeList[0],data:e.data||""}))},e.prototype._onInvitationCancelled=function(e){var t=e.inviteID,n=e.inviter,o=e.groupID,r=this._inviteInfoMap.has(t);c.default.log("TSignaling._onInvitationCancelled inviteID="+t+" hasInviteID="+r+" inviter="+n+" groupID="+o),(o&&r||!o)&&(this._deleteInviteInfoByID(t),this._outerEmitter.emit(a.default.INVITATION_CANCELLED,{inviteID:t,inviter:n,data:e.data||""}))},e.prototype._onInvitationTimeout=function(e){var t=e.inviteID,n=e.inviter,o=e.groupID,r=this._inviteInfoMap.has(t);c.default.log("TSignaling._onInvitationTimeout inviteID="+t+" hasInviteID="+r+" inviter="+n+" groupID="+o),(o&&r||!o)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(a.default.INVITATION_TIMEOUT,{inviteID:t,inviteeList:e.inviteeList,isSelfTimeout:!1}))},e.prototype._updateLocalInviteInfo=function(e){var t=e.inviteID,n=e.inviter,o=e.inviteeList,r=e.groupID;if(c.default.log("TSignaling._updateLocalInviteInfo inviteID="+t+" inviter="+n+" groupID="+r),r){if(this._inviteInfoMap.has(t)){var i=o[0],s=this._inviteInfoMap.get(t).inviteeList;s.includes(i)&&(s.splice(s.indexOf(i),1),c.default.log("TSignaling._updateLocalInviteInfo remove "+i+" from localInviteeList. "+s.length+" invitees left")),0===s.length&&this._deleteInviteInfoByID(t)}}else this._deleteInviteInfoByID(t)},e.prototype._deleteInviteInfoByID=function(e){this._inviteInfoMap.has(e)&&(c.default.log("TSignaling._deleteInviteInfoByID remove "+e+" from inviteInfoMap."),this._inviteInfoMap.delete(e))},e.prototype._sendCustomMessage=function(e,t){return o(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){return n=t.groupID,o=this._tim.createCustomMessage({to:e,conversationType:n?f.TYPES.CONV_GROUP:f.TYPES.CONV_C2C,priority:f.TYPES.MSG_PRIORITY_HIGH,payload:{data:JSON.stringify(t)}}),t.actionType===i.ActionType.INVITE?[2,this._tim.sendMessage(o,{offlinePushInfo:{title:"",description:"您有一个通话请求",androidOPPOChannelID:""}})]:[2,this._tim.sendMessage(o)]}))}))},e.EVENT=a.default,e.TYPES=u.default,e}();t.default=m},function(e,t,n){"use strict";var o,r,i;Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorCode=t.BusinessID=t.ActionType=void 0,function(e){e[e.INVITE=1]="INVITE",e[e.CANCEL_INVITE=2]="CANCEL_INVITE",e[e.ACCEPT_INVITE=3]="ACCEPT_INVITE",e[e.REJECT_INVITE=4]="REJECT_INVITE",e[e.INVITE_TIMEOUT=5]="INVITE_TIMEOUT"}(o||(o={})),t.ActionType=o,function(e){e[e.SIGNAL=1]="SIGNAL"}(r||(r={})),t.BusinessID=r,function(e){e[e.ERR_INVALID_PARAMETERS=6017]="ERR_INVALID_PARAMETERS",e[e.ERR_SDK_SIGNALING_INVALID_INVITE_ID=8010]="ERR_SDK_SIGNALING_INVALID_INVITE_ID",e[e.ERR_SDK_SIGNALING_NO_PERMISSION=8011]="ERR_SDK_SIGNALING_NO_PERMISSION"}(i||(i={})),t.ErrorCode=i},function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return s}));const o=Function.prototype.apply,r=new WeakMap;function i(e){return r.has(e)||r.set(e,{}),r.get(e)}class s{constructor(e=null,t=console){const n=i(this);return n._events=new Set,n._callbacks={},n._console=t,n._maxListeners=null===e?null:parseInt(e,10),this}_addCallback(e,t,n,o){return this._getCallbacks(e).push({callback:t,context:n,weight:o}),this._getCallbacks(e).sort((e,t)=>e.weight>t.weight),this}_getCallbacks(e){return i(this)._callbacks[e]}_getCallbackIndex(e,t){return this._has(e)?this._getCallbacks(e).findIndex(e=>e.callback===t):null}_achieveMaxListener(e){return null!==i(this)._maxListeners&&i(this)._maxListeners<=this.listenersNumber(e)}_callbackIsExists(e,t,n){const o=this._getCallbackIndex(e,t),r=-1!==o?this._getCallbacks(e)[o]:void 0;return-1!==o&&r&&r.context===n}_has(e){return i(this)._events.has(e)}on(e,t,n=null,o=1){const r=i(this);if("function"!=typeof t)throw new TypeError(t+" is not a function");return this._has(e)?(this._achieveMaxListener(e)&&r._console.warn(`Max listeners (${r._maxListeners}) for event "${e}" is reached!`),this._callbackIsExists(...arguments)&&r._console.warn(`Event "${e}" already has the callback ${t}.`)):(r._events.add(e),r._callbacks[e]=[]),this._addCallback(...arguments),this}once(e,t,n=null,r=1){const i=(...r)=>(this.off(e,i),o.call(t,n,r));return this.on(e,i,n,r)}off(e,t=null){const n=i(this);let o;return this._has(e)&&(null===t?(n._events.delete(e),n._callbacks[e]=null):(o=this._getCallbackIndex(e,t),-1!==o&&(n._callbacks[e].splice(o,1),this.off(...arguments)))),this}emit(e,...t){return this._has(e)&&this._getCallbacks(e).forEach(e=>o.call(e.callback,e.context,t)),this}clear(){const e=i(this);return e._events.clear(),e._callbacks={},this}listenersNumber(e){return this._has(e)?this._getCallbacks(e).length:null}}},function(e,t,n){"use strict";n.r(t);var o=n(0);const r=Object.prototype.hasOwnProperty;t.default=function(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(Object(o.f)(e)){for(const t in e)if(r.call(e,t))return!1;return!0}return!!(Object(o.e)(e)||Object(o.g)(e)||Object(o.c)(e))&&0===e.size}},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n(4),i=n.n(r);t.default=class{constructor(){this._funcMap=new Map}defense(e,t,n){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);let 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}defenseOnce(e,t,n){return"function"!=typeof t?null:this._pack(e,t,n)}find(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):(o.default.log(`SafetyCallback.find: 找不到 func —— ${e}/${""!==t.name?t.name:"[anonymous]"}`),null):(o.default.log(`SafetyCallback.find: 找不到 eventName-${e} 对应的 func`),null)}delete(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)))}_pack(e,t,n){return function(){try{t.apply(n,Array.from(arguments))}catch(t){const n=Object.values(i.a).indexOf(e),r=Object.keys(i.a)[n];o.default.error(`接入侧事件 EVENT.${r} 对应的回调函数逻辑存在问题,请检查!`,t)}}}}},function(e,t,n){"use strict";n.r(t);var o=n(5),r=n.n(o);r.a.init({sid:"500721619",cid:"500721777",autoReport:0,senseHash:0,senseQuery:0,performanceMonitor:0,ignoreParams:[]}),t.default=r.a},function(e,t,n){
- /**
- * UUID.js - RFC-compliant UUID Generator for JavaScript
- *
- * @file
- * @author LiosK
- * @version v4.2.5
- * @license Apache License 2.0: Copyright (c) 2010-2020 LiosK
- */
- var o;o=function(t){"use strict";function o(){var e=r._getRandomInt;this.timestamp=0,this.sequence=e(14),this.node=1099511627776*(1|e(8))+e(40),this.tick=e(4)}function r(){}return r.generate=function(){var e=r._getRandomInt,t=r._hexAligner;return t(e(32),8)+"-"+t(e(16),4)+"-"+t(16384|e(12),4)+"-"+t(32768|e(14),4)+"-"+t(e(48),12)},r._getRandomInt=function(e){if(e<0||e>53)return NaN;var t=0|1073741824*Math.random();return e>30?t+1073741824*(0|Math.random()*(1<<e-30)):t>>>30-e},r._hexAligner=function(e,t){for(var n=e.toString(16),o=t-n.length,r="0";o>0;o>>>=1,r+=r)1&o&&(n=r+n);return n},r.overwrittenUUID=t,function(){var e=r._getRandomInt;r.useMathRandom=function(){r._getRandomInt=e};var t=null,o=e;"undefined"!=typeof window&&(t=window.crypto||window.msCrypto)?t.getRandomValues&&"undefined"!=typeof Uint32Array&&(o=function(e){if(e<0||e>53)return NaN;var n=new Uint32Array(e>32?2:1);return n=t.getRandomValues(n)||n,e>32?n[0]+4294967296*(n[1]>>>64-e):n[0]>>>32-e}):(t=n(14))&&t.randomBytes&&(o=function(e){if(e<0||e>53)return NaN;var n=t.randomBytes(e>32?8:4),o=n.readUInt32BE(0);return e>32?o+4294967296*(n.readUInt32BE(4)>>>64-e):o>>>32-e}),r._getRandomInt=o}(),r.FIELD_NAMES=["timeLow","timeMid","timeHiAndVersion","clockSeqHiAndReserved","clockSeqLow","node"],r.FIELD_SIZES=[32,16,16,8,8,48],r.genV4=function(){var e=r._getRandomInt;return(new r)._init(e(32),e(16),16384|e(12),128|e(6),e(8),e(48))},r.parse=function(e){var t;if(t=/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(e)){var n=t[1]||"",o=t[8]||"";if(n+o===""||"{"===n&&"}"===o||"urn:uuid:"===n.toLowerCase()&&""===o)return(new r)._init(parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16),parseInt(t[5],16),parseInt(t[6],16),parseInt(t[7],16))}return null},r.prototype._init=function(){var e=r.FIELD_NAMES,t=r.FIELD_SIZES,n=r._binAligner,o=r._hexAligner;this.intFields=new Array(6),this.bitFields=new Array(6),this.hexFields=new Array(6);for(var i=0;i<6;i++){var s=parseInt(arguments[i]||0);this.intFields[i]=this.intFields[e[i]]=s,this.bitFields[i]=this.bitFields[e[i]]=n(s,t[i]),this.hexFields[i]=this.hexFields[e[i]]=o(s,t[i]>>>2)}return this.version=this.intFields.timeHiAndVersion>>>12&15,this.bitString=this.bitFields.join(""),this.hexNoDelim=this.hexFields.join(""),this.hexString=this.hexFields[0]+"-"+this.hexFields[1]+"-"+this.hexFields[2]+"-"+this.hexFields[3]+this.hexFields[4]+"-"+this.hexFields[5],this.urn="urn:uuid:"+this.hexString,this},r._binAligner=function(e,t){for(var n=e.toString(2),o=t-n.length,r="0";o>0;o>>>=1,r+=r)1&o&&(n=r+n);return n},r.prototype.toString=function(){return this.hexString},r.prototype.equals=function(e){if(!(e instanceof r))return!1;for(var t=0;t<6;t++)if(this.intFields[t]!==e.intFields[t])return!1;return!0},r.NIL=(new r)._init(0,0,0,0,0,0),r.genV1=function(){null==r._state&&r.resetState();var e=(new Date).getTime(),t=r._state;e!=t.timestamp?(e<t.timestamp&&t.sequence++,t.timestamp=e,t.tick=r._getRandomInt(4)):Math.random()<r._tsRatio&&t.tick<9984?t.tick+=1+r._getRandomInt(4):t.sequence++;var n=r._getTimeFieldValues(t.timestamp),o=n.low+t.tick,i=4095&n.hi|4096;t.sequence&=16383;var s=t.sequence>>>8|128,a=255&t.sequence;return(new r)._init(o,n.mid,i,s,a,t.node)},r.resetState=function(){r._state=new o},r._tsRatio=1/4,r._state=null,r._getTimeFieldValues=function(e){var t=e-Date.UTC(1582,9,15),n=t/4294967296*1e4&268435455;return{low:1e4*(268435455&t)%4294967296,mid:65535&n,hi:n>>>16,timestamp:t}},"object"==typeof e.exports&&(e.exports=r),r}(o)},function(e,t){},function(e,t,n){(function(t){e.exports=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"},n={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 o(e){return(o="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 r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 s(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(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 c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(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 p(e){return(p=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 f(e,t,n){return(f=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 g(e){var t="function"==typeof Map?new Map:void 0;return(g=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 f(e,arguments,p(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),h(o,e)})(e)}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?m(e):t}function v(e){return function(){var t,n=p(e);if(d()){var o=p(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return _(this,t)}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){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(e){r=!0,i=e}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}return n}}(e,t)||M(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 I(e){return function(e){if(Array.isArray(e))return C(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||M(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 M(e,t){if(e){if("string"==typeof e)return C(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(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}function C(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 E(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=M(e))){var t=0,n=function(){};return{s:n,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:n}}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 o,r,i=!0,s=!1;return{s:function(){o=e[Symbol.iterator]()},n:function(){var e=o.next();return i=e.done,e},e:function(e){s=!0,r=e},f:function(){try{i||null==o.return||o.return()}finally{if(s)throw r}}}}var T=function(){function e(){r(this,e),this.cache=[],this.options=null}return s(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}(),S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{};function D(e,t){return e(t={exports:{}},t.exports),t.exports}var k,A,R,N=D((function(e,t){var n,o,r,i,s,a,u,c,l,p,h,d,f,g,m,_,v,y;e.exports=(n="function"==typeof Promise,o="object"==typeof self?self:S,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,h=s&&"function"==typeof Set.prototype.entries,d=i&&"function"==typeof Map.prototype.entries,f=h&&Object.getPrototypeOf((new Set).entries()),g=d&&Object.getPrototypeOf((new Map).entries()),m=l&&"function"==typeof Array.prototype[Symbol.iterator],_=m&&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===g?"Map Iterator":s&&l===f?"Set Iterator":m&&l===_?"Array Iterator":v&&l===y?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(8,-1)})})),w="undefined"!=typeof window,O="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync,L=w&&window.navigator&&window.navigator.userAgent||"",b=/AppleWebKit\/([\d.]+)/i.exec(L),P=(b&&parseFloat(b.pop()),/iPad/i.test(L),/iPhone/i.test(L),/iPod/i.test(L),(k=L.match(/OS (\d+)_/i))&&k[1]&&k[1],/Android/i.test(L)),G=(function(){var e=L.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat(e[1]+"."+e[2])}(),P&&/webkit/i.test(L),/Firefox/i.test(L),!/Edge/i.test(L)&&/Chrome/i.test(L),function(){var e=L.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(L)),U=(/MSIE\s8\.0/.test(L),function(){var e=/MSIE\s(\d+)\.\d/.exec(L),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(L)&&/rv:11.0/.test(L)&&(t=11),t}()),x=(/Safari/i.test(L),/TBS\/\d+/i.test(L)),q=(function(){var e=L.match(/TBS\/(\d+)/i);e&&e[1]&&e[1]}(),!x&&/MQQBrowser\/\d+/i.test(L),!x&&/ QQBrowser\/\d+/i.test(L),/(micromessenger|webbrowser)/i.test(L)),F=(/Windows/i.test(L),/MAC OS X/i.test(L),/MicroMessenger/i.test(L),void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});A="undefined"!=typeof console?console:void 0!==F&&F.console?F.console:"undefined"!=typeof window&&window.console?window.console:{};for(var V=function(){},K=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],H=K.length;H--;)R=K[H],console[R]||(A[R]=V);A.methods=K;var B=A,j=0,Y=new Map;function $(){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 W={_data:[],_length:0,_visible:!1,arguments2String:function(e){var t;if(1===e.length)t=$()+e[0];else{t=$();for(var n=0,o=e.length;n<o;n++)ne(e[n])?re(e[n])?t+=le(e[n]):t+=JSON.stringify(e[n]):t+=e[n],t+=" "}return t},debug:function(){if(j<=-1){var e=this.arguments2String(arguments);W.record(e,"debug"),B.debug(e)}},log:function(){if(j<=0){var e=this.arguments2String(arguments);W.record(e,"log"),B.log(e)}},info:function(){if(j<=1){var e=this.arguments2String(arguments);W.record(e,"info"),B.info(e)}},warn:function(){if(j<=2){var e=this.arguments2String(arguments);W.record(e,"warn"),B.warn(e)}},error:function(){if(j<=3){var e=this.arguments2String(arguments);W.record(e,"error"),B.error(e)}},time:function(e){Y.set(e,ue.now())},timeEnd:function(e){if(Y.has(e)){var t=ue.now()-Y.get(e);return Y.delete(e),t}return B.warn("未找到对应label: ".concat(e,", 请在调用 logger.timeEnd 前,调用 logger.time")),0},setLevel:function(e){e<4&&B.log($()+"set level from "+j+" to "+e),j=e},record:function(e,t){1100===W._length&&(W._data.splice(0,100),W._length=1e3),W._length++,W._data.push("".concat(e," [").concat(t,"] \n"))},getLog:function(){return W._data}},z=function(e){return"file"===ie(e)},J=function(e){return null!==e&&("number"==typeof e&&!isNaN(e-0)||"object"===o(e)&&e.constructor===Number)},X=function(e){return"string"==typeof e},Q=function(e){return null!==e&&"object"===o(e)},Z=function(e){if("object"!==o(e)||null===e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;for(var n=t;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n},ee=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===ie(e)},te=function(e){return void 0===e},ne=function(e){return ee(e)||Q(e)},oe=function(e){return"function"==typeof e},re=function(e){return e instanceof Error},ie=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},se=function(e){if("string"!=typeof e)return!1;var t=e[0];return!/[^a-zA-Z0-9]/.test(t)},ae=0;Date.now||(Date.now=function(){return(new Date).getTime()});var ue={now:function(){0===ae&&(ae=Date.now()-1);var e=Date.now()-ae;return e>4294967295?(ae+=4294967295,Date.now()-ae):e},utc:function(){return Math.round(Date.now()/1e3)}},ce=function e(t,n,o,r){if(!ne(t)||!ne(n))return 0;for(var i,s=0,a=Object.keys(n),u=0,c=a.length;u<c;u++)if(i=a[u],!(te(n[i])||o&&o.includes(i)))if(ne(t[i])&&ne(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},le=function(e){return JSON.stringify(e,["message","code"])},pe=function(){var e,t=new Date,n=t.toISOString(),o=t.getTimezoneOffset()/60;return e=o<0?o>-10?"+0"+Math.abs(100*o):"+"+Math.abs(100*o):o>=10?"-"+100*o:"-0"+100*o,n.replace("Z",e)},he=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},de=function(e){var t=e||99999999;return Math.round(Math.random()*t)},fe="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ge=fe.length,me=function(e,t){for(var n in e)if(e[n]===t)return!0;return!1},_e={},ve=function(){if(O)return"https:";var e=window.location.protocol;return["http:","https:"].indexOf(e)<0&&(e="http:"),e},ye=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function Ie(e,t){ee(e)&&ee(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})})):W.warn("updateCustomField target 或 source 不是数组,忽略此次更新。")}var Me=function(e){return e===n.GRP_PUBLIC},Ce=function(e){return e===n.GRP_MEETING},Ee=function(e){return e===n.GRP_AVCHATROOM},Te=function(e){return X(e)&&e===n.CONV_SYSTEM};function Se(e,t){var n={};return Object.keys(e).forEach((function(o){n[o]=t(e[o],o)})),n}var De=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(Z(e)){for(var t in e)if(De.call(e,t))return!1;return!0}return!("map"!==ie(e)&&!function(e){return"set"===ie(e)}(e)&&!z(e))&&0===e.size}function Ae(e,t,n){if(void 0===t)return!0;var o=!0;if("object"===N(t).toLowerCase())Object.keys(t).forEach((function(r){var i=1===e.length?e[0][r]:void 0;o=!!Re(i,t[r],n,r)&&o}));else if("array"===N(t).toLowerCase())for(var r=0;r<t.length;r++)o=!!Re(e[r],t[r],n,t[r].name)&&o;if(o)return o;throw new Error("Params validate failed.")}function Re(e,t,n,o){if(void 0===t)return!0;var r=!0;return t.required&&ke(e)&&(B.error("TIM [".concat(n,'] Missing required params: "').concat(o,'".')),r=!1),ke(e)||N(e).toLowerCase()===t.type.toLowerCase()||(B.error("TIM [".concat(n,'] Invalid params: type check failed for "').concat(o,'".Expected ').concat(t.type,".")),r=!1),t.validator&&!t.validator(e)&&(B.error("TIM [".concat(n,"] Invalid params: custom validator check failed for params.")),r=!1),r}var Ne="JoinedSuccess",we="WaitAdminApproval",Oe=0,Le=1,be=0,Pe="unSend",Ge="success",Ue="fail",xe="notStart",qe="pengding",Fe="resolved",Ve="rejected",Ke=function(){function e(t){r(this,e),this.type=n.MSG_TEXT,this.content={text:t.text||""}}return s(e,[{key:"setText",value:function(e){this.content.text=e}},{key:"sendable",value:function(){return 0!==this.content.text.length}}]),e}(),He={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}},Be={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"},je={UNKNOWN:"Gender_Type_Unknown",FEMALE:"Gender_Type_Female",MALE:"Gender_Type_Male"},Ye={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},$e={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},We=function(){function e(t){r(this,e),this._imageMemoryURL="",this._file=t.file,O?this.createImageDataASURLInWXMiniApp(t.file):this.createImageDataASURLInWeb(t.file),this._initImageInfoModel(),this.type=n.MSG_IMAGE,this._percent=0,this.content={imageFormat:t.imageFormat||He.IMAGE_FORMAT.UNKNOWN,uuid:t.uuid,imageInfoArray:[]},this.initImageInfoArray(t.imageInfoArray),this._defaultImage="http://imgcache.qq.com/open/qcloud/video/act/webim-images/default.jpg",this._autoFixUrl()}return s(e,[{key:"_initImageInfoModel",value:function(){var e=this;this._ImageInfoModel=function(t){this.instanceID=de(9999999),this.sizeType=t.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},setImageUrl:function(e){e&&(this.imageUrl=e)},getImageUrl:function(){return this.imageUrl}}}},{key:"initImageInfoArray",value:function(e){for(var t=2,n=null,o=null;t>=0;)o=void 0===e||void 0===e[t]?{type:0,size:0,width:0,height:0,url:""}:e[t],(n=new this._ImageInfoModel(o)).setSizeType(t+1),this.addImageInfo(n),t--}},{key:"updateImageInfoArray",value:function(e){for(var t,n=this.content.imageInfoArray.length,o=0;o<n;o++)t=this.content.imageInfoArray[o],e.size&&(t.size=e.size),e.url&&t.setImageUrl(e.url),e.width&&(t.width=e.width),e.height&&(t.height=e.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=He.IMAGE_FORMAT[e.toUpperCase()]||He.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:"sendable",value:function(){return 0!==this.content.imageInfoArray.length&&""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size}}]),e}(),ze=function(){function e(t){r(this,e),this.type=n.MSG_FACE,this.content=t||null}return s(e,[{key:"sendable",value:function(){return null!==this.content}}]),e}(),Je=function(){function e(t){r(this,e),this.type=n.MSG_AUDIO,this._percent=0,this.content={downloadFlag:2,second:t.second,size:t.size,url:t.url,remoteAudioUrl:"",uuid:t.uuid}}return s(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}(),Xe={from:!0,groupID:!0,groupName:!0,to:!0},Qe=function(){function e(t){r(this,e),this.type=n.MSG_GRP_TIP,this.content={},this._initContent(t)}return s(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 W.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;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];Xe[o]&&(this.content.groupProfile[o]=e[o])}}}]),e}(),Ze={from:!0,groupID:!0,name:!0,to:!0},et=function(){function e(t){r(this,e),this.type=n.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(t)}return s(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];Ze[o]&&(this.content.groupProfile[o]=e[o])}}}]),e}(),tt={70001:"UserSig 已过期,请重新生成。建议 UserSig 有效期设置不小于24小时。",70002:"UserSig 长度为0,请检查传入的 UserSig 是否正确。",70003:"UserSig 非法,请使用官网提供的 API 重新生成 UserSig(https://cloud.tencent.com/document/product/269/32688)。",70005:"UserSig 非法,请使用官网提供的 API 重新生成 UserSig(https://cloud.tencent.com/document/product/269/32688)。",70009:"UserSig 验证失败,可能因为生成 UserSig 时混用了其他 SDKAppID 的私钥或密钥导致,请使用对应 SDKAppID 下的私钥或密钥重新生成 UserSig(https://cloud.tencent.com/document/product/269/32688)。",70013:"请求中的 UserID 与生成 UserSig 时使用的 UserID 不匹配,您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。",70014:"请求中的 SDKAppID 与生成 UserSig 时使用的 SDKAppID 不匹配,您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。",70016:"密钥不存在,UserSig 验证失败,请在即时通信 IM 控制台获取密钥(https://cloud.tencent.com/document/product/269/32578#.E8.8E.B7.E5.8F.96.E5.AF.86.E9.92.A5)。",70020:"SDKAppID 未找到,请在即时通信 IM 控制台确认应用信息。",70050:"UserSig 验证次数过于频繁。请检查 UserSig 是否正确,并于1分钟后重新验证。您可以在即时通信 IM 控制台的【开发辅助工具(https://console.cloud.tencent.com/im-detail/tool-usersig)】页面校验 UserSig。",70051:"帐号被拉入黑名单。",70052:"UserSig 已经失效,请重新生成,再次尝试。",70107:"因安全原因被限制登录,请不要频繁登录。",70169:"请求的用户帐号不存在。",70114:"服务端内部超时,请稍后重试。",70202:"服务端内部超时,请稍后重试。",70206:"请求中批量数量不合法。",70402:"参数非法,请检查必填字段是否填充,或者字段的填充是否满足协议要求。",70403:"请求失败,需要 App 管理员权限。",70398:"帐号数超限。如需创建多于100个帐号,请将应用升级为专业版,具体操作指引请参见购买指引(https://cloud.tencent.com/document/product/269/32458)。",70500:"服务端内部错误,请稍后重试。",71e3:"删除帐号失败。仅支持删除体验版帐号,您当前应用为专业版,暂不支持帐号删除。",20001:"请求包非法。",20002:"UserSig 或 A2 失效。",20003:"消息发送方或接收方 UserID 无效或不存在,请检查 UserID 是否已导入即时通信 IM。",20004:"网络异常,请重试。",20005:"服务端内部错误,请重试。",20006:"触发发送单聊消息之前回调,App 后台返回禁止下发该消息。",20007:"发送单聊消息,被对方拉黑,禁止发送。消息发送状态默认展示为失败,您可以登录控制台修改该场景下的消息发送状态展示结果,具体操作请参见消息保留设置(https://cloud.tencent.com/document/product/269/38656)。",20009:"消息发送双方互相不是好友,禁止发送(配置单聊消息校验好友关系才会出现)。",20010:"发送单聊消息,自己不是对方的好友(单向关系),禁止发送。",20011:"发送单聊消息,对方不是自己的好友(单向关系),禁止发送。",20012:"发送方被禁言,该条消息被禁止发送。",20016:"消息撤回超过了时间限制(默认2分钟)。",20018:"删除漫游内部错误。",90001:"JSON 格式解析失败,请检查请求包是否符合 JSON 规范。",90002:"JSON 格式请求包中 MsgBody 不符合消息格式描述,或者 MsgBody 不是 Array 类型,请参考 TIMMsgElement 对象的定义(https://cloud.tencent.com/document/product/269/2720#.E6.B6.88.E6.81.AF.E5.85.83.E7.B4.A0-timmsgelement)。",90003:"JSON 格式请求包体中缺少 To_Account 字段或者 To_Account 帐号不存在。",90005:"JSON 格式请求包体中缺少 MsgRandom 字段或者 MsgRandom 字段不是 Integer 类型。",90006:"JSON 格式请求包体中缺少 MsgTimeStamp 字段或者 MsgTimeStamp 字段不是 Integer 类型。",90007:"JSON 格式请求包体中 MsgBody 类型不是 Array 类型,请将其修改为 Array 类型。",90008:"JSON 格式请求包体中缺少 From_Account 字段或者 From_Account 帐号不存在。",90009:"请求需要 App 管理员权限。",90010:"JSON 格式请求包不符合消息格式描述,请参考 TIMMsgElement 对象的定义(https://cloud.tencent.com/document/product/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:"JSON 格式请求包体中 SyncOtherMachine 字段不是 Integer 类型。",90044:"JSON 格式请求包体中 MsgLifeTime 字段不是 Integer 类型。",90048:"请求的用户帐号不存在。",90054:"撤回请求中的 MsgKey 不合法。",90994:"服务内部错误,请重试。",90995:"服务内部错误,请重试。",91e3:"服务内部错误,请重试。",90992:"服务内部错误,请重试;如果所有请求都返回该错误码,且 App 配置了第三方回调,请检查 App 服务端是否正常向即时通信 IM 后台服务端返回回调结果。",93e3:"JSON 数据包超长,消息包体请不要超过8k。",91101:"Web 端长轮询被踢(Web 端同时在线实例个数超出限制)。",10002:"服务端内部错误,请重试。",10003:"请求中的接口名称错误,请核对接口名称并重试。",10004:"参数非法,请根据错误描述检查请求是否正确。",10005:"请求包体中携带的帐号数量过多。",10006:"操作频率限制,请尝试降低调用的频率。",10007:"操作权限不足,例如 Work 群组中普通成员尝试执行踢人操作,但只有 App 管理员才有权限。",10008:"请求非法,可能是请求中携带的签名信息验证不正确,请再次尝试。",10009:"该群不允许群主主动退出。",10010:"群组不存在,或者曾经存在过,但是目前已经被解散。",10011:"解析 JSON 包体失败,请检查包体的格式是否符合 JSON 格式。",10012:"发起操作的 UserID 非法,请检查发起操作的用户 UserID 是否填写正确。",10013:"被邀请加入的用户已经是群成员。",10014:"群已满员,无法将请求中的用户加入群组,如果是批量加人,可以尝试减少加入用户的数量。",10015:"找不到指定 ID 的群组。",10016:"App 后台通过第三方回调拒绝本次操作。",10017:"因被禁言而不能发送消息,请检查发送者是否被设置禁言。",10018:"应答包长度超过最大包长(1MB),请求的内容过多,请尝试减少单次请求的数据量。",10019:"请求的用户帐号不存在。",10021:"群组 ID 已被使用,请选择其他的群组 ID。",10023:"发消息的频率超限,请延长两次发消息时间的间隔。",10024:"此邀请或者申请请求已经被处理。",10025:"群组 ID 已被使用,并且操作者为群主,可以直接使用。",10026:"该 SDKAppID 请求的命令字已被禁用。",10030:"请求撤回的消息不存在。",10031:"消息撤回超过了时间限制(默认2分钟)。",10032:"请求撤回的消息不支持撤回操作。",10033:"群组类型不支持消息撤回操作。",10034:"该消息类型不支持删除操作。",10035:"直播群和在线成员广播大群不支持删除消息。",10036:"直播群创建数量超过了限制,请参考价格说明(https://cloud.tencent.com/document/product/269/11673)购买预付费套餐“IM直播群”。",10037:"单个用户可创建和加入的群组数量超过了限制,请参考价格说明(https://cloud.tencent.com/document/product/269/11673)购买或升级预付费套餐“单人可创建与加入群组数”。",10038:"群成员数量超过限制,请参考价格说明(https://cloud.tencent.com/document/product/269/11673)购买或升级预付费套餐“扩展群人数上限”。",10041:"该应用(SDKAppID)已配置不支持群消息撤回。"},nt=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this)).code=e.code,o.message=tt[e.code]||e.message,o.data=e.data||{},o}return n}(g(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,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="MessageController.constructor() 需要参数 options",it="无法发送空文件",st="回调函数运行时遇到错误,请检查接入侧代码",at="文件大小超过100M,无法发送 ",ut="AVChatRoom 类型的群不支持邀请群成员",ct="updateMyProfile 无标配资料字段或自定义资料字段",lt="意料外的通知条件",pt="_syncOffset 丢失",ht=["jpg","jpeg","gif","png"],dt=["mp4"],ft=function(){function e(t){r(this,e);var o=this._check(t);if(o instanceof nt)throw o;this.type=n.MSG_FILE,this._percent=0;var i=this._getFileInfo(t);this.content={downloadFlag:2,fileUrl:t.url||"",uuid:t.uuid,fileName:i.name||"",fileSize:i.size||0}}return s(e,[{key:"_getFileInfo",value:function(e){if(e.fileName&&e.fileSize)return{size:e.fileSize,name:e.fileName};if(O)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 nt({code:ot.MESSAGE_FILE_SIZE_LIMIT,message:"".concat(at,": ").concat(104857600," bytes")})}},{key:"sendable",value:function(){return""!==this.content.fileUrl&&""!==this.content.fileName&&0!==this.content.fileSize}}]),e}(),gt=function(){function e(t){r(this,e),this.type=n.MSG_CUSTOM,this.content={data:t.data||"",description:t.description||"",extension:t.extension||""}}return s(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}(),mt=function(){function e(t){r(this,e),this.type=n.MSG_VIDEO,this._percent=0,this.content={remoteVideoUrl:t.remoteVideoUrl,videoFormat:t.videoFormat,videoSecond:parseInt(t.videoSecond,10),videoSize:t.videoSize,videoUrl:t.videoUrl,videoDownloadFlag:2,videoUUID:t.videoUUID,thumbUUID:t.thumbUUID,thumbFormat:t.thumbFormat,thumbWidth:t.thumbWidth,thumbHeight:t.thumbHeight,thumbSize:t.thumbSize,thumbDownloadFlag:2,thumbUrl:t.thumbUrl}}return s(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}(),_t=function e(t){r(this,e),this.type=n.MSG_GEO,this.content=t},vt={1:n.MSG_PRIORITY_HIGH,2:n.MSG_PRIORITY_NORMAL,3:n.MSG_PRIORITY_LOW,4:n.MSG_PRIORITY_LOWEST},yt=function(){function e(t){r(this,e),this.ID="",this.conversationID=t.conversationID||null,this.conversationType=t.conversationType||n.CONV_C2C,this.conversationSubType=t.conversationSubType,this.time=t.time||Math.ceil(Date.now()/1e3),this.sequence=t.sequence||0,this.clientSequence=t.clientSequence||t.sequence||0,this.random=t.random||de(),this.priority=this._computePriority(t.priority),this.nick="",this.avatar="",this.isPeerRead=!1,this._elements=[],this.isPlaceMessage=t.isPlaceMessage||0,this.isRevoked=2===t.isPlaceMessage||8===t.msgFlagBits,this.geo={},this.from=t.from||null,this.to=t.to||null,this.flow="",this.isSystemMessage=t.isSystemMessage||!1,this.protocol=t.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=t.status||Ge,this.reInitialize(t.currentUser),this.extractGroupInfo(t.groupProfile||null)}return s(e,[{key:"getElements",value:function(){return this._elements}},{key:"extractGroupInfo",value:function(e){null!==e&&(X(e.fromAccountNick)&&(this.nick=e.fromAccountNick),X(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?Ge:Pe,!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?(W.warn("".concat(this._elements[0].type,' need "boolean : sendable()" method')),!1):this._elements[0].sendable())}},{key:"_initTo",value:function(e){this.conversationType===n.CONV_GROUP&&(this.to=e.groupID)}},{key:"_initielizeSequence",value:function(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return W.error("autoincrementIndex(string: key) need key parameter"),!1;if(void 0===_e[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);_e[e]=parseInt([n,o,r,"0001"].join("")),n=null,o=null,r=null,W.warn("utils.autoincrementIndex() create new sequence : ".concat(e," = ").concat(_e[e]))}return _e[e]++}(e)),0===this.sequence&&this.conversationType===n.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 t=this.to,o="",r=this.conversationType;r!==n.CONV_SYSTEM?(o=r===n.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID="".concat(r).concat(o)):this.conversationID=n.CONV_SYSTEM}},{key:"isElement",value:function(e){return e instanceof Ke||e instanceof We||e instanceof ze||e instanceof Je||e instanceof ft||e instanceof mt||e instanceof Qe||e instanceof et||e instanceof gt||e instanceof _t}},{key:"setElement",value:function(e){var t=this;if(this.isElement(e))return this._elements=[e],void this._initProxy();var o=function(e){switch(e.type){case n.MSG_TEXT:t.setTextElement(e.content);break;case n.MSG_IMAGE:t.setImageElement(e.content);break;case n.MSG_AUDIO:t.setAudioElement(e.content);break;case n.MSG_FILE:t.setFileElement(e.content);break;case n.MSG_VIDEO:t.setVideoElement(e.content);break;case n.MSG_CUSTOM:t.setCustomElement(e.content);break;case n.MSG_GEO:t.setGEOElement(e.content);break;case n.MSG_GRP_TIP:t.setGroupTipElement(e.content);break;case n.MSG_GRP_SYS_NOTICE:t.setGroupSystemNoticeElement(e.content);break;case n.MSG_FACE:t.setFaceElement(e.content);break;default:W.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 Ke({text:t});this._elements.push(n)}},{key:"setImageElement",value:function(e){var t=new We(e);this._elements.push(t)}},{key:"setAudioElement",value:function(e){var t=new Je(e);this._elements.push(t)}},{key:"setFileElement",value:function(e){var t=new ft(e);this._elements.push(t)}},{key:"setVideoElement",value:function(e){var t=new mt(e);this._elements.push(t)}},{key:"setGEOElement",value:function(e){var t=new _t(e);this._elements.push(t)}},{key:"setCustomElement",value:function(e){var t=new gt(e);this._elements.push(t)}},{key:"setGroupTipElement",value:function(e){var t={},o=e.operationType;ke(e.memberInfoList)||o!==n.GRP_TIP_MBR_JOIN&&o!==n.GRP_TIP_MBR_KICKED_OUT?e.operatorInfo&&(t=e.operatorInfo):t=e.memberInfoList[0];var r=t,i=r.nick,s=r.avatar;X(i)&&(this.nick=i),X(s)&&(this.avatar=s);var a=new Qe(e);this._elements.push(a)}},{key:"setGroupSystemNoticeElement",value:function(e){var t=new et(e);this._elements.push(t)}},{key:"setFaceElement",value:function(e){var t=new ze(e);this._elements.push(t)}},{key:"setIsRead",value:function(e){this.isRead=e}},{key:"_computePriority",value:function(e){if(te(e))return n.MSG_PRIORITY_NORMAL;if(X(e)&&-1!==Object.values(vt).indexOf(e))return e;if(J(e)){var t=""+e;if(-1!==Object.keys(vt).indexOf(t))return vt[t]}return n.MSG_PRIORITY_NORMAL}},{key:"elements",get:function(){return W.warn("!!!Message 实例的 elements 属性即将废弃,请尽快修改。使用 type 和 payload 属性处理单条消息,兼容组合消息使用 _elements 属性!!!"),this._elements}}]),e}(),It=function(e){return!(!e||!(function(e){return X(e)&&e.slice(0,3)===n.CONV_C2C}(e)||function(e){return X(e)&&e.slice(0,5)===n.CONV_GROUP}(e)||Te(e))&&(console.warn("非法的会话 ID:".concat(e,"。会话 ID 组成方式:\n C2C + userID(单聊)\n GROUP + groupID(群聊)\n @TIM#SYSTEM(系统通知会话)")),1))},Mt={login:{userID:{type:"String",required:!0},userSig:{type:"String",required:!0}},addToBlacklist:{userIDList:{type:"Array",required:!0}},mutilParam:[{name:"paramName",type:"Number",required:!0},{name:"paramName",type:"String",required:!0}],on:[{name:"eventName",type:"String",validator:function(e){return"string"==typeof e&&0!==e.length||(console.warn("on 接口的 eventName 参数必须是 String 类型,且不能为空。"),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn("on 接口的 handler 参数必须是 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("once 接口的 eventName 参数必须是 String 类型,且不能为空。"),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn("once 接口的 handler 参数必须是 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("off 接口的 eventName 参数必须是 String 类型,且不能为空。"),!1)}},{name:"handler",type:"Function",validator:function(e){return"function"!=typeof e?(console.warn("off 接口的 handler 参数必须是 Function 类型。"),!1):(""===e.name&&console.warn("off 接口的 handler 参数为匿名函数,无法取消订阅。"),!0)}}],sendMessage:[{name:"message",type:"Object",required:!0}],getMessageList:{conversationID:{type:"String",required:!0,validator:function(e){return It(e)}},nextReqMessageID:{type:"String"},count:{type:"Number",validator:function(e){return!(!te(e)&&!/^[1-9][0-9]*$/.test(e)&&(console.warn("getMessageList 接口的 count 参数必须为正整数"),1))}}},setMessageRead:{conversationID:{type:"String",required:!0,validator:function(e){return It(e)}}},getConversationProfile:[{name:"conversationID",type:"String",required:!0,validator:function(e){return It(e)}}],deleteConversation:[{name:"conversationID",type:"String",required:!0,validator:function(e){return It(e)}}],getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:{type:"String",required:!0},groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:{type:"Array",required:!0}},createGroup:{name:{type:"String",required:!0}},joinGroup:{groupID:{type:"String",required:!0},type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",type:"String",required:!0}],handleApplication:{message:{type:"Object",required:!0},handleAction:{type:"String",required:!0},handleMessage:{type:"String"}},changeGroupOwner:{groupID:{type:"String",required:!0},newOwnerID:{type:"String",required:!0}},updateGroupProfile:{groupID:{type:"String",required:!0},muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",type:"String",required:!0}],searchGroupByID:[{name:"groupID",type:"String",required:!0}],getGroupMemberList:{groupID:{type:"String",required:!0},offset:{type:"Number"},count:{type:"Number"}},getGroupMemberProfile:{groupID:{type:"String",required:!0},userIDList:{type:"Array",required:!0},memberCustomFieldFilter:{type:"Array"}},addGroupMemeber:{groupID:{type:"String",required:!0},userIDList:{type:"Array",required:!0}},setGroupMemberRole:{groupID:{type:"String",required:!0},userID:{type:"String",required:!0},role:{type:"String",required:!0}},setGroupMemberMuteTime:{groupID:{type:"String",required:!0},userID:{type:"String",required:!0},muteTime:{type:"Number",validator:function(e){return e>=0}}},setGroupMemberNameCard:{groupID:{type:"String",required:!0},userID:{type:"String"},nameCard:{type:"String",required:!0,validator:function(e){return!0!==/^\s+$/.test(e)}}},setMessageRemindType:{groupID:{type:"String",required:!0},messageRemindType:{type:"String",required:!0}},setGroupMemberCustomField:{groupID:{type:"String",required:!0},userID:{type:"String"},memberCustomField:{type:"Array",required:!0}},deleteGroupMember:{groupID:{type:"String",required:!0}},createTextMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){return X(e.text)?0!==e.text.length||(console.warn("createTextMessage 消息内容不能为空。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createTextMessage"),!1):(console.warn("createTextMessage payload.text 类型必须为字符串。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createTextMessage"),!1)}}},createCustomMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){return e.data&&!X(e.data)?(console.warn("createCustomMessage payload.data 类型必须为 String。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createCustomMessage"),!1):e.description&&!X(e.description)?(console.warn("createCustomMessage payload.description 类型必须为 String。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createCustomMessage"),!1):!(e.extension&&!X(e.extension)&&(console.warn("createCustomMessage payload.extension 类型必须为 String。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createCustomMessage"),1))}}},createImageMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){if(te(e.file))return console.warn("createImageMessage payload.file 不能为 undefined。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createImageMessage"),!1;if(w){if(!(e.file instanceof HTMLInputElement||z(e.file)))return console.warn("createImageMessage payload.file 的类型必须是 HTMLInputElement 或 File。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createImageMessage"),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn("createImageMessage 您没有选择文件,无法发送。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createImageMessage"),!1}return!0},onProgress:{type:"Function",required:!1,validator:function(e){return te(e)&&console.warn("createImageMessage 没有 onProgress 回调,您将无法获取图片上传进度。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createImageMessage"),!0}}}},createAudioMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0},onProgress:{type:"Function",required:!1,validator:function(e){return te(e)&&console.warn("createAudioMessage 没有 onProgress 回调,您将无法获取音频上传进度。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createAudioMessage"),!0}}},createVideoMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){if(te(e.file))return console.warn("createVideoMessage payload.file 不能为 undefined。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createVideoMessage"),!1;if(w){if(!(e.file instanceof HTMLInputElement||z(e.file)))return console.warn("createVideoMessage payload.file 的类型必须是 HTMLInputElement 或 File。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createVideoMessage"),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn("createVideoMessage 您没有选择文件,无法发送。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createVideoMessage"),!1}return!0}},onProgress:{type:"Function",required:!1,validator:function(e){return te(e)&&console.warn("createVideoMessage 没有 onProgress 回调,您将无法获取视频上传进度。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createVideoMessage"),!0}}},createFaceMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){return!(!Z(e)||(J(e.index)?!X(e.data)&&(console.warn("createFaceMessage payload.data 类型必须为 String!"),1):(console.warn("createFaceMessage payload.index 类型必须为 Number!"),1)))}}},createFileMessage:{to:{type:"String",required:!0},conversationType:{type:"String",required:!0},payload:{type:"Object",required:!0,validator:function(e){if(te(e.file))return console.warn("createFileMessage payload.file 不能为 undefined。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createFileMessage"),!1;if(w){if(!(e.file instanceof HTMLInputElement||z(e.file)))return console.warn("createFileMessage payload.file 的类型必须是 HTMLInputElement 或 File。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createFileMessage"),!1;if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return console.warn("createFileMessage 您没有选择文件,无法发送。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createFileMessage"),!1}return!0}},onProgress:{type:"Function",required:!1,validator:function(e){return te(e)&&console.warn("createFileMessage 没有 onProgress 回调,您将无法获取文件上传进度。请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#createFileMessage"),!0}}},revokeMessage:[{name:"message",type:"Object",required:!0,validator:function(e){return e instanceof yt?e.conversationType===n.CONV_SYSTEM?(console.warn("revokeMessage 不能撤回系统会话消息,只能撤回单聊消息或群消息"),!1):!0!==e.isRevoked||(console.warn("revokeMessage 消息已经被撤回,请勿重复操作"),!1):(console.warn("revokeMessage 参数 message 必须为 Message(https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/Message.html) 实例。"),!1)}}],getUserProfile:{userIDList:{type:"Array",validator:function(e){return ee(e)?(0===e.length&&console.warn("getUserProfile userIDList 不能为空数组,请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#getUserProfile"),!0):(console.warn("getUserProfile userIDList 必须为数组,请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#getUserProfile"),!1)}}},updateMyProfile:{profileCustomField:{type:"Array",validator:function(e){return!!te(e)||!!ee(e)||(console.warn("updateMyProfile profileCustomField 必须为数组,请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile"),!1)}}}},Ct={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",getMyProfile:"getMyProfile",getUserProfile:"getUserProfile",updateMyProfile:"updateMyProfile",getBlacklist:"getBlacklist",addToBlacklist:"addToBlacklist",removeFromBlacklist:"removeFromBlacklist",getFriendList:"getFriendList"},Et="1.7.3",Tt="537048168",St="10",Dt="protobuf",kt="json",At={HOST:{TYPE:3,ACCESS_LAYER_TYPES:{SANDBOX:1,TEST:2,PRODUCTION:3},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"},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;switch(e){case this.ACCESS_LAYER_TYPES.SANDBOX:this.CURRENT=this.SANDBOX,this.TYPE=this.ACCESS_LAYER_TYPES.SANDBOX;break;case this.ACCESS_LAYER_TYPES.TEST:this.CURRENT=this.TEST,this.TYPE=this.ACCESS_LAYER_TYPES.TEST;break;default:this.CURRENT=this.PRODUCTION,this.TYPE=this.ACCESS_LAYER_TYPES.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"},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"}};At.HOST.setCurrent(At.HOST.ACCESS_LAYER_TYPES.PRODUCTION);var Rt={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"]},Nt="_contextWasUpdated",wt="_contextWasReset",Ot="_a2KeyAndTinyIDUpdated",Lt="_specifiedConfigUpdated",bt="_noticeIsSynchronizing",Pt="_noticeIsSynchronized",Gt="_messageSent",Ut="_syncMessageProcessing",xt="_syncMessageFinished",qt="_receiveInstantMessage",Ft="_receiveGroupInstantMessage",Vt="_receveGroupSystemNotice",Kt="_messageRevoked",Ht="_longPollGetIDFailed",Bt="_longPollRequestFailed",jt="_longPollResponseOK",Yt="_longPollKickedOut",$t="_longPollMitipuleDeviceKickedOut",Wt="_longPollGetNewC2CNotice",zt="_longPollGetNewGroupMessages",Jt="_longPollGetNewGroupTips",Xt="_longPollGetNewGroupNotice",Qt="_longPollGetNewFriendMessages",Zt="_longPollProfileModified",en=" _longpollGroupMessageRevoked",tn="_longpollC2CMessageRevoked",nn="_longpollC2CMessageReadReceipt",on="_avlongPollRequestFailed",rn="_avlongPollResponseOK",sn="_onGroupListUpdated",an="_loginSuccess",un="_signLogoutExcuting",cn="_logoutSuccess",ln="_a2keyExpired",pn="_errorHasBeenDetected",hn="_onConversationListUpdated",dn="_onConversationListProfileUpdated",fn="_conversationDeleted",gn="onProfileUpdated",mn="joinAVChatRoomSuccess",_n="joinAVChatRoomSuccessNoAuth",vn="_sdkStateReady",yn="_sdkReload";function In(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");var n;return t=Object.assign({pascalCase:!1},t),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=Mn(e)),n=e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(function(e,t){return t.toUpperCase()})).replace(/\d+(\w|$)/g,(function(e){return e.toUpperCase()})),t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n)}var Mn=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 Cn(e,t,n){var o=[],r=0,i=function e(t,n){if(++r>10)return r--,t;if(ee(t)){var i=t.map((function(t){return Q(t)?e(t,n):t}));return r--,i}if(Q(t)){var s=(a=t,u=function(e,t){if(!se(t))return!1;if((s=t)!==In(s)){for(var r=!0,i=0;i<Rt.ignoreKeyWord.length;i++)if(t.includes(Rt.ignoreKeyWord[i])){r=!1;break}r&&o.push(t)}var s;return te(n[t])?function(e){return"OPPOChannelID"===e?e:e[0].toUpperCase()+In(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=Se(s,(function(t,o){return ee(t)||Q(t)?e(t,n):t})),r--,s}var a,u,c}(e,t=c({},Rt.request,{},t));return o.length>0&&n.innerEmitter.emit(pn,{code:ot.CONVERTOR_IRREGULAR_PARAMS,message:"不规范的参数名称"}),i}var En=function(){function e(t){var n=this;r(this,e),this.url="",this.requestData=null,this.method=t.method||"POST",this.callback=function(e){return function e(t,n){if(n=c({},Rt.response,{},n),ee(t))return t.map((function(t){return Q(t)?e(t,n):t}));if(Q(t)){var o=(r=t,i=function(e,t){return te(n[t])?In(t):n[t]},s={},Object.keys(r).forEach((function(e){s[i(r[e],e)]=r[e]})),s);return Se(o,(function(t){return ee(t)||Q(t)?e(t,n):t}))}var r,i,s}(e=t.decode(e),n._getResponseMap(t))},this._initializeServerMap(),this._initializeURL(t),this._initializeRequestData(t)}return s(e,[{key:"_initializeServerMap",value:function(){this._serverMap=Object.create(null);var e="";for(var t in At.NAME)if(Object.prototype.hasOwnProperty.call(At.NAME,t))switch(e=At.NAME[t]){case At.NAME.PIC:this._serverMap[e]=At.HOST.CURRENT.PIC;break;case At.NAME.IM_COS_SIGN:this._serverMap[e]=At.HOST.CURRENT.COS;break;default:this._serverMap[e]=At.HOST.CURRENT.COMMON}}},{key:"_getHost",value:function(e){if(void 0!==this._serverMap[e])return this._serverMap[e];throw new nt({code:ot.NETWORK_UNDEFINED_SERVER_NAME,message:"打包错误,未定义的 serverName"})}},{key:"_initializeURL",value:function(e){var t=e.serverName,n=e.cmd,o=this._getHost(t),r="".concat(o,"/").concat(At.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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&se(n)&&null!==e[n]&&("object"!==o(e[n])?t[n]=e[n]:t[n]=this._requestDataCleaner.bind(this)(e[n]));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 Tn(e){this.mixin(e)}Tn.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 Sn=function(){function e(t){r(this,e),Tn.mixin(this),this.tim=t}return s(e,[{key:"isLoggedIn",value:function(){return this.tim.context.login===Le||!!this.tim.context.a2Key}},{key:"createTransportCapsule",value:function(e){var t=this.tim.packageConfig.get(e);return t?new En(t):null}},{key:"request",value:function(e){var t=this.createTransportCapsule(e);return t||W.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(){W.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 q?e="wechat":O&&(e="wxmp"),e}}]),e}(),Dn=function(){function e(t,n){r(this,e),this.data=t,this._innerEmitter=n,this.defaultData={},Object.assign(this.defaultData,t),this.initGetterAndSetter()}return s(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(Nt,{key:e,value:t})}},{key:"reset",value:function(){for(var e in W.log("Context.reset"),this.data)Object.prototype.hasOwnProperty.call(this.data,e)&&(this.data[e]=this.defaultData.hasOwnProperty(e)?this.defaultData[e]:null)}}]),e}(),kn=function(e){l(n,e);var t=v(n);function n(e){var o;r(this,n);var i=(o=t.call(this,e)).tim.loginInfo;return o._context=new Dn({login:be,SDKAppID:i.SDKAppID,appIDAt3rd:null,accountType:i.accountType,identifier:i.identifier,tinyID:null,identifierNick:i.identifierNick,userSig:i.userSig,a2Key:null,contentType:"json",apn:1,unlimitedAVChatRoom:i.unlimitedAVChatRoom,scene:i.scene},o.tim.innerEmitter),o._initListener(),o}return s(n,[{key:"reset",value:function(){this._context.reset(),this.emitInnerEvent(wt)}},{key:"_initListener",value:function(){this.tim.innerEmitter.on(Nt,this._onContextMemberChange,this),this.tim.innerEmitter.on(an,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(Ot),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=be:this._context.login=null!==this._context.a2Key?Le:be)}}]),n}(Sn),An=function e(t){r(this,e),this.code=0,this.data=t||{}},Rn=null,Nn=function(e){return e instanceof An?(W.warn("IMPromise.resolve 此函数会自动用options创建IMResponse实例,调用侧不需创建,建议修改!"),Promise.resolve(e)):Promise.resolve(new An(e))},wn=function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof nt)return n&&null!==Rn&&Rn.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){var o=new nt({code:ot.UNCAUGHT_ERROR,message:t.message});return n&&null!==Rn&&Rn.emit(e.ERROR,o),Promise.reject(o)}if(te(t)||te(t.code)||te(t.message))W.error("IMPromise.reject 必须指定code(错误码)和message(错误信息)!!!");else{if(J(t.code)&&X(t.message)){var r=new nt(t);return n&&null!==Rn&&Rn.emit(e.ERROR,r),Promise.reject(r)}W.error("IMPromise.reject code(错误码)必须为数字,message(错误信息)必须为字符串!!!")}},On="sdkReady",Ln="longpolling",bn="longpollingAV",Pn="sendMessage",Gn="sendMessageC2C",Un="sendMessageGroupWork",xn="sendMessageGroupPublic",qn="sendMessageGroupMeeting",Fn="sendMessageGroupAV",Vn="messageReceived",Kn="messageReceivedAV",Hn="initGroupList",Bn=function(){function e(){r(this,e),this.SDKAppID="",this.version="",this.tinyID="",this.userID="",this.platform="",this.method="",this.time="",this.startts=0,this.endts=0,this.timespan=0,this.codeint=0,this.message="",this.text="",this.msgType="",this.networkType="",this.platform="",this.scene="",this._sentFlag=!1}return s(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;this.SDKAppID="".concat(t),this.version="".concat(n),this.tinyID=o,this.userID=r,this.platform=i,this.scene=s,this.time=pe(),this.startts&&this.endts&&!this.timespan&&(this.timespan=Math.abs(this.endts-this.startts))}},{key:"setMethod",value:function(e){return this.method=e,this}},{key:"setStart",value:function(){this.startts=Date.now()}},{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("未连接到网络"))),this):(W.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setCode",value:function(e){return te(e)||this._sentFlag||("ECONNABORTED"===e&&(this.codeint=103),J(e)?this.codeint=e:W.warn("SSOLogData.setCode value not a number, please check!",e,o(e))),this}},{key:"setMessage",value:function(e){return te(e)||this._sentFlag?this:X(e)?(this.message=e,this):this}},{key:"setText",value:function(e){return J(e)?this.text=e.toString():X(e)&&(this.text=e),this}},{key:"setMessageType",value:function(e){return this.msgType=e,this}},{key:"setNetworkType",value:function(e){return te(e)?W.warn("SSOLogData.setNetworkType value is undefined, please check!"):this.networkType=e,this}}],[{key:"bindController",value:function(t){e.prototype._eventStatController=t}}]),e}(),jn="kickedOut",Yn="emptyMessageBody",$n="applyJoinGroup",Wn="longPollingError",zn="callbackFunctionError",Jn=function(t){l(i,t);var o=v(i);function i(e){var t;return r(this,i),(t=o.call(this,e))._initializeListener(),t}return s(i,[{key:"login",value:function(e){if(this.isLoggedIn()){var t="您已经登录账号".concat(e.identifier,"!如需切换账号登录,请先调用 logout 接口登出,再调用 login 接口登录。");return W.warn(t),Nn({actionStatus:"OK",errorCode:0,errorInfo:t,repeatLogin:!0})}W.log("SignController.login userID=",e.identifier),W.time("login");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):wn(n)}},{key:"_isLoginCurrentUser",value:function(e){return this.tim.context.identifier===e}},{key:"_initializeListener",value:function(){var e=this.tim.innerEmitter;e.on(Yt,this._onMultipleAccountKickedOut,this),e.on($t,this._onMultipleDeviceKickedOut,this),e.on(ln,this._onUserSigExpired,this)}},{key:"_accessLayer",value:function(){var e=this,t=new Bn;return t.setMethod("accessLayer").setStart(),W.log("SignController._accessLayer."),this.request({name:"accessLayer",action:"query"}).then((function(n){return t.setCode(0).setNetworkType(e.getNetworkType()).setText(n.data.webImAccessLayer).setEnd(),W.log("SignController._accessLayer ok. webImAccessLayer=".concat(n.data.webImAccessLayer)),1===n.data.webImAccessLayer&&At.HOST.setCurrent(n.data.webImAccessLayer),e._login()})).catch((function(n){return e.probeNetwork().then((function(o){var r=y(o,2),i=r[0],s=r[1];t.setError(n,i,s).setEnd(!0),e.tim.eventStatController.reportAtOnce()})),W.error("SignController._accessLayer failed. error:",n),wn(n)}))}},{key:"_login",value:function(){var e=this,t=new Bn;return t.setMethod("login").setStart(),this.request({name:"login",action:"query"}).then((function(n){var o=null;if(!n.data.tinyID)throw o=new nt({code:ot.NO_TINYID,message:"无 tinyID"}),t.setError(o,!0,e.getNetworkType()).setEnd(),o;if(!n.data.a2Key)throw o=new nt({code:ot.NO_A2KEY,message:"无 a2key"}),t.setError(o,!0,e.getNetworkType()).setEnd(),o;return t.setCode(0).setNetworkType(e.getNetworkType()).setText("".concat(e.tim.loginInfo.identifier)).setEnd(),W.log("SignController.login ok. userID=".concat(e.tim.loginInfo.identifier," loginCost=").concat(W.timeEnd("login"),"ms")),e.emitInnerEvent(an,{a2Key:n.data.a2Key,tinyID:n.data.tinyID}),Nn(n.data)})).catch((function(n){return e.probeNetwork().then((function(e){var o=y(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd(!0)})),W.error("SignController.login failed. error:",n),wn(n)}))}},{key:"logout",value:function(){var e=new Bn;return e.setMethod("logout").setStart(),e.setCode(0).setNetworkType(this.getNetworkType()).setText("userID=".concat(this.tim.loginInfo.identifier," type=").concat("longPollLogout")).setEnd(!0),W.info("SignController.logout"),this.emitInnerEvent(un),this._logout(1).then(this._emitLogoutSuccess.bind(this)).catch(this._emitLogoutSuccess.bind(this))}},{key:"_logout",value:function(e){var t=this.tim.notificationController,n=0===e?"logout":"longPollLogout",o=0===e?{name:n,action:"query"}:{name:n,action:"query",param:{longPollID:t.getLongPollID()}};return this.request(o).catch((function(e){return W.error("SignController._logout error:",e),wn(e)}))}},{key:"_checkLoginInfo",value:function(e){var t=0,n="";return null===e.SDKAppID?(t=ot.NO_SDKAPPID,n="无 SDKAppID"):null===e.accountType?(t=ot.NO_ACCOUNT_TYPE,n="无 accountType"):null===e.identifier?(t=ot.NO_IDENTIFIER,n="无 userID"):null===e.userSig&&(t=ot.NO_USERSIG,n="无 userSig"),ke(t)||ke(n)?{}:{code:t,message:n}}},{key:"_emitLogoutSuccess",value:function(){return this.emitInnerEvent(cn),Nn({})}},{key:"_onMultipleAccountKickedOut",value:function(){var t=this,o=new Bn;o.setMethod(jn).setStart(),o.setCode(0).setNetworkType(this.getNetworkType()).setText(n.KICKED_OUT_MULT_ACCOUNT).setEnd(!0),W.warn("SignController._onMultipleAccountKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)),this.tim.logout().then((function(){t.emitOuterEvent(e.KICKED_OUT,{type:n.KICKED_OUT_MULT_ACCOUNT})}))}},{key:"_onMultipleDeviceKickedOut",value:function(){var t=this,o=new Bn;o.setMethod(jn).setStart(),o.setCode(0).setNetworkType(this.getNetworkType()).setText(n.KICKED_OUT_MULT_DEVICE).setEnd(!0),W.warn("SignController._onMultipleDeviceKickedOut kicked out. userID=".concat(this.tim.loginInfo.identifier)),this.tim.logout().then((function(){t.emitOuterEvent(e.KICKED_OUT,{type:n.KICKED_OUT_MULT_DEVICE})}))}},{key:"_onUserSigExpired",value:function(){var t=new Bn;t.setMethod(jn).setStart(),t.setCode(0).setNetworkType(this.getNetworkType()).setText(n.KICKED_OUT_USERSIG_EXPIRED).setEnd(!0),W.warn("SignController._onUserSigExpired: userSig 签名过期被踢下线"),this.emitOuterEvent(e.KICKED_OUT,{type:n.KICKED_OUT_USERSIG_EXPIRED}),this.tim.resetSDK()}},{key:"reset",value:function(){W.info("SignController.reset")}}]),i}(Sn),Xn=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}},Qn=Object.prototype.toString;function Zn(e){return"[object Array]"===Qn.call(e)}function eo(e){return void 0===e}function to(e){return null!==e&&"object"==typeof e}function no(e){return"[object Function]"===Qn.call(e)}function oo(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Zn(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(null,e[r],r,e)}var ro={isArray:Zn,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Qn.call(e)},isBuffer:function(e){return null!==e&&!eo(e)&&null!==e.constructor&&!eo(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:to,isUndefined:eo,isDate:function(e){return"[object Date]"===Qn.call(e)},isFile:function(e){return"[object File]"===Qn.call(e)},isBlob:function(e){return"[object Blob]"===Qn.call(e)},isFunction:no,isStream:function(e){return to(e)&&no(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:oo,merge:function e(){var t={};function n(n,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,r=arguments.length;o<r;o++)oo(arguments[o],n);return t},deepMerge:function e(){var t={};function n(n,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]="object"==typeof n?e({},n):n}for(var o=0,r=arguments.length;o<r;o++)oo(arguments[o],n);return t},extend:function(e,t,n){return oo(t,(function(t,o){e[o]=n&&"function"==typeof t?Xn(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function io(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var so=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(ro.isURLSearchParams(t))o=t.toString();else{var r=[];ro.forEach(t,(function(e,t){null!=e&&(ro.isArray(e)?t+="[]":e=[e],ro.forEach(e,(function(e){ro.isDate(e)?e=e.toISOString():ro.isObject(e)&&(e=JSON.stringify(e)),r.push(io(t)+"="+io(e))})))})),o=r.join("&")}if(o){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e};function ao(){this.handlers=[]}ao.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},ao.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},ao.prototype.forEach=function(e){ro.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var uo=ao,co=function(e,t,n){return ro.forEach(n,(function(n){e=n(e,t)})),e},lo=function(e){return!(!e||!e.__CANCEL__)};function po(){throw new Error("setTimeout has not been defined")}function ho(){throw new Error("clearTimeout has not been defined")}var fo=po,go=ho;function mo(e){if(fo===setTimeout)return setTimeout(e,0);if((fo===po||!fo)&&setTimeout)return fo=setTimeout,setTimeout(e,0);try{return fo(e,0)}catch(t){try{return fo.call(null,e,0)}catch(t){return fo.call(this,e,0)}}}"function"==typeof F.setTimeout&&(fo=setTimeout),"function"==typeof F.clearTimeout&&(go=clearTimeout);var _o,vo=[],yo=!1,Io=-1;function Mo(){yo&&_o&&(yo=!1,_o.length?vo=_o.concat(vo):Io=-1,vo.length&&Co())}function Co(){if(!yo){var e=mo(Mo);yo=!0;for(var t=vo.length;t;){for(_o=vo,vo=[];++Io<t;)_o&&_o[Io].run();Io=-1,t=vo.length}_o=null,yo=!1,function(e){if(go===clearTimeout)return clearTimeout(e);if((go===ho||!go)&&clearTimeout)return go=clearTimeout,clearTimeout(e);try{go(e)}catch(t){try{return go.call(null,e)}catch(t){return go.call(this,e)}}}(e)}}function Eo(e,t){this.fun=e,this.array=t}function To(){}Eo.prototype.run=function(){this.fun.apply(null,this.array)};var So=To,Do=To,ko=To,Ao=To,Ro=To,No=To,wo=To,Oo=F.performance||{},Lo=Oo.now||Oo.mozNow||Oo.msNow||Oo.oNow||Oo.webkitNow||function(){return(new Date).getTime()},bo=new Date,Po={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];vo.push(new Eo(e,t)),1!==vo.length||yo||mo(Co)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:So,addListener:Do,once:ko,off:Ao,removeListener:Ro,removeAllListeners:No,emit:wo,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Lo.call(Oo),n=Math.floor(t),o=Math.floor(t%1*1e9);return e&&(n-=e[0],(o-=e[1])<0&&(n--,o+=1e9)),[n,o]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-bo)/1e3}},Go=function(e,t){ro.forEach(e,(function(n,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[o])}))},Uo=function(e,t,n,o,r){return function(e,t,n,o,r){return e.config=t,n&&(e.code=n),e.request=o,e.response=r,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,o,r)},xo=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],qo=ro.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var o=e;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=ro.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},Fo=ro.isStandardBrowserEnv()?{write:function(e,t,n,o,r,i){var s=[];s.push(e+"="+encodeURIComponent(t)),ro.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),ro.isString(o)&&s.push("path="+o),ro.isString(r)&&s.push("domain="+r),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Vo={"Content-Type":"application/x-www-form-urlencoded"};function Ko(e,t){!ro.isUndefined(e)&&ro.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Ho,Bo={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==Po&&"[object process]"===Object.prototype.toString.call(Po))&&(Ho=function(e){return new Promise((function(t,n){var o=e.data,r=e.headers;ro.isFormData(o)&&delete r["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password||"";r.Authorization="Basic "+btoa(s+":"+a)}var u,c,l=(u=e.baseURL,c=e.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(c)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(u,c):c);if(i.open(e.method.toUpperCase(),so(l,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var o,r,s,a,u,c="getAllResponseHeaders"in i?(o=i.getAllResponseHeaders(),u={},o?(ro.forEach(o.split("\n"),(function(e){if(a=e.indexOf(":"),r=ro.trim(e.substr(0,a)).toLowerCase(),s=ro.trim(e.substr(a+1)),r){if(u[r]&&xo.indexOf(r)>=0)return;u[r]="set-cookie"===r?(u[r]?u[r]:[]).concat([s]):u[r]?u[r]+", "+s:s}})),u):u):null,l={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:c,config:e,request:i};!function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(Uo("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,l),i=null}},i.onabort=function(){i&&(n(Uo("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(Uo("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Uo(t,e,"ECONNABORTED",i)),i=null},ro.isStandardBrowserEnv()){var p=Fo,h=(e.withCredentials||qo(l))&&e.xsrfCookieName?p.read(e.xsrfCookieName):void 0;h&&(r[e.xsrfHeaderName]=h)}if("setRequestHeader"in i&&ro.forEach(r,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete r[t]:i.setRequestHeader(t,e)})),ro.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),void 0===o&&(o=null),i.send(o)}))}),Ho),transformRequest:[function(e,t){return Go(t,"Accept"),Go(t,"Content-Type"),ro.isFormData(e)||ro.isArrayBuffer(e)||ro.isBuffer(e)||ro.isStream(e)||ro.isFile(e)||ro.isBlob(e)?e:ro.isArrayBufferView(e)?e.buffer:ro.isURLSearchParams(e)?(Ko(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):ro.isObject(e)?(Ko(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};ro.forEach(["delete","get","head"],(function(e){Bo.headers[e]={}})),ro.forEach(["post","put","patch"],(function(e){Bo.headers[e]=ro.merge(Vo)}));var jo=Bo;function Yo(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var $o=function(e){return Yo(e),e.headers=e.headers||{},e.data=co(e.data,e.headers,e.transformRequest),e.headers=ro.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ro.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||jo.adapter)(e).then((function(t){return Yo(e),t.data=co(t.data,t.headers,e.transformResponse),t}),(function(t){return lo(t)||(Yo(e),t&&t.response&&(t.response.data=co(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Wo=function(e,t){t=t||{};var n={},o=["url","method","params","data"],r=["headers","auth","proxy"],i=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];ro.forEach(o,(function(e){void 0!==t[e]&&(n[e]=t[e])})),ro.forEach(r,(function(o){ro.isObject(t[o])?n[o]=ro.deepMerge(e[o],t[o]):void 0!==t[o]?n[o]=t[o]:ro.isObject(e[o])?n[o]=ro.deepMerge(e[o]):void 0!==e[o]&&(n[o]=e[o])})),ro.forEach(i,(function(o){void 0!==t[o]?n[o]=t[o]:void 0!==e[o]&&(n[o]=e[o])}));var s=o.concat(r).concat(i),a=Object.keys(t).filter((function(e){return-1===s.indexOf(e)}));return ro.forEach(a,(function(o){void 0!==t[o]?n[o]=t[o]:void 0!==e[o]&&(n[o]=e[o])})),n};function zo(e){this.defaults=e,this.interceptors={request:new uo,response:new uo}}zo.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Wo(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[$o,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},zo.prototype.getUri=function(e){return e=Wo(this.defaults,e),so(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ro.forEach(["delete","get","head","options"],(function(e){zo.prototype[e]=function(t,n){return this.request(ro.merge(n||{},{method:e,url:t}))}})),ro.forEach(["post","put","patch"],(function(e){zo.prototype[e]=function(t,n,o){return this.request(ro.merge(o||{},{method:e,url:t,data:n}))}}));var Jo=zo;function Xo(e){this.message=e}Xo.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Xo.prototype.__CANCEL__=!0;var Qo=Xo;function Zo(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new Qo(e),t(n.reason))}))}Zo.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Zo.source=function(){var e;return{token:new Zo((function(t){e=t})),cancel:e}};var er=Zo;function tr(e){var t=new Jo(e),n=Xn(Jo.prototype.request,t);return ro.extend(n,Jo.prototype,t),ro.extend(n,t),n}var nr=tr(jo);nr.Axios=Jo,nr.create=function(e){return tr(Wo(nr.defaults,e))},nr.Cancel=Qo,nr.CancelToken=er,nr.isCancel=lo,nr.all=function(e){return Promise.all(e)},nr.spread=function(e){return function(t){return e.apply(null,t)}};var or=nr,rr=nr;or.default=rr;var ir=or,sr=ir.create({timeout:3e4,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});sr.interceptors.response.use((function(e){var t=e.data,n=t.error_code,o=t.ErrorCode;return J(n)&&(o=n),o!==Oe&&(e.data.ErrorCode=Number(o)),e}),(function(e){return"Network Error"===e.message&&(!0===sr.defaults.withCredentials&&W.warn("Network Error, try to close `IMAxios.defaults.withCredentials` to false. (IMAxios.js)"),sr.defaults.withCredentials=!1),Promise.reject(e)}));var ar=function(){function e(){r(this,e)}return s(e,[{key:"request",value:function(e){console.warn("请注意: ConnectionBase.request() 方法必须被派生类重写:"),console.log("参数如下:\n * @param {String} options.url string 是 开发者服务器接口地址\n * @param {*} options.data - string/object/ArrayBuffer 否 请求的参数\n * @param {Object} options.header - Object 否 设置请求的 header,\n * @param {String} options.method - string GET 否 HTTP 请求方法\n * @param {String} options.dataType - string json 否 返回的数据格式\n * @param {String} options.responseType - string text 否 响应的数据类型\n * @param {Boolean} isRetry - string text false 是否为重试的请求\n ")}},{key:"_checkOptions",value:function(e){if(0==!!e.url)throw new nt({code:ot.NETWORK_BASE_OPTIONS_NO_URL,message:"网络层初始化错误,缺少 URL 参数"})}},{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}(),ur=function(e){l(n,e);var t=v(n);function n(){var e;return r(this,n),(e=t.call(this)).retry=2,e}return s(n,[{key:"request",value:function(e){return this._checkOptions(e),this._initOptions(e),this._requestWithRetry({url:e.url,data:e.data,method:e.method})}},{key:"_requestWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return sr(e).catch((function(o){return t.retry&&n<t.retry?t._requestWithRetry(e,++n):wn(new nt({code:o.code||"",message:o.message||""}))}))}}]),n}(ar),cr=[],lr=[],pr="undefined"!=typeof Uint8Array?Uint8Array:Array,hr=!1;function dr(){hr=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,n=e.length;t<n;++t)cr[t]=e[t],lr[e.charCodeAt(t)]=t;lr["-".charCodeAt(0)]=62,lr["_".charCodeAt(0)]=63}function fr(e,t,n){for(var o,r,i=[],s=t;s<n;s+=3)o=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(cr[(r=o)>>18&63]+cr[r>>12&63]+cr[r>>6&63]+cr[63&r]);return i.join("")}function gr(e){var t;hr||dr();for(var n=e.length,o=n%3,r="",i=[],s=0,a=n-o;s<a;s+=16383)i.push(fr(e,s,s+16383>a?a:s+16383));return 1===o?(t=e[n-1],r+=cr[t>>2],r+=cr[t<<4&63],r+="=="):2===o&&(t=(e[n-2]<<8)+e[n-1],r+=cr[t>>10],r+=cr[t>>4&63],r+=cr[t<<2&63],r+="="),i.push(r),i.join("")}function mr(e,t,n,o,r){var i,s,a=8*r-o-1,u=(1<<a)-1,c=u>>1,l=-7,p=n?r-1:0,h=n?-1:1,d=e[t+p];for(p+=h,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+e[t+p],p+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=o;l>0;s=256*s+e[t+p],p+=h,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,o),i-=c}return(d?-1:1)*s*Math.pow(2,i-o)}function _r(e,t,n,o,r,i){var s,a,u,c=8*i-r-1,l=(1<<c)-1,p=l>>1,h=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=o?0:i-1,f=o?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+p>=1?h/u:h*Math.pow(2,1-p))*u>=2&&(s++,u/=2),s+p>=l?(a=0,s=l):s+p>=1?(a=(t*u-1)*Math.pow(2,r),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,r),s=0));r>=8;e[n+d]=255&a,d+=f,a/=256,r-=8);for(s=s<<r|a,c+=r;c>0;e[n+d]=255&s,d+=f,s/=256,c-=8);e[n+d-f]|=128*g}var vr={}.toString,yr=Array.isArray||function(e){return"[object Array]"==vr.call(e)};function Ir(){return Cr.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Mr(e,t){if(Ir()<t)throw new RangeError("Invalid typed array length");return Cr.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Cr.prototype:(null===e&&(e=new Cr(t)),e.length=t),e}function Cr(e,t,n){if(!(Cr.TYPED_ARRAY_SUPPORT||this instanceof Cr))return new Cr(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Sr(this,e)}return Er(this,e,t,n)}function Er(e,t,n,o){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,o){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(o||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===o?new Uint8Array(t):void 0===o?new Uint8Array(t,n):new Uint8Array(t,n,o),Cr.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Cr.prototype:e=Dr(e,t),e}(e,t,n,o):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Cr.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var o=0|Rr(t,n),r=(e=Mr(e,o)).write(t,n);return r!==o&&(e=e.slice(0,r)),e}(e,t,n):function(e,t){if(Ar(t)){var n=0|kr(t.length);return 0===(e=Mr(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(o=t.length)!=o?Mr(e,0):Dr(e,t);if("Buffer"===t.type&&yr(t.data))return Dr(e,t.data)}var o;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Tr(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Sr(e,t){if(Tr(t),e=Mr(e,t<0?0:0|kr(t)),!Cr.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Dr(e,t){var n=t.length<0?0:0|kr(t.length);e=Mr(e,n);for(var o=0;o<n;o+=1)e[o]=255&t[o];return e}function kr(e){if(e>=Ir())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ir().toString(16)+" bytes");return 0|e}function Ar(e){return!(null==e||!e._isBuffer)}function Rr(e,t){if(Ar(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return ti(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ni(e).length;default:if(o)return ti(e).length;t=(""+t).toLowerCase(),o=!0}}function Nr(e,t,n){var o=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Br(this,t,n);case"utf8":case"utf-8":return Vr(this,t,n);case"ascii":return Kr(this,t,n);case"latin1":case"binary":return Hr(this,t,n);case"base64":return Fr(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jr(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function wr(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function Or(e,t,n,o,r){if(0===e.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=Cr.from(t,o)),Ar(t))return 0===t.length?-1:Lr(e,t,n,o,r);if("number"==typeof t)return t&=255,Cr.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Lr(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function Lr(e,t,n,o,r){var i,s=1,a=e.length,u=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){var l=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var p=!0,h=0;h<u;h++)if(c(e,i+h)!==c(t,h)){p=!1;break}if(p)return i}return-1}function br(e,t,n,o){n=Number(n)||0;var r=e.length-n;o?(o=Number(o))>r&&(o=r):o=r;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s<o;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function Pr(e,t,n,o){return oi(ti(t,e.length-n),e,n,o)}function Gr(e,t,n,o){return oi(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,o)}function Ur(e,t,n,o){return Gr(e,t,n,o)}function xr(e,t,n,o){return oi(ni(t),e,n,o)}function qr(e,t,n,o){return oi(function(e,t){for(var n,o,r,i=[],s=0;s<e.length&&!((t-=2)<0);++s)o=(n=e.charCodeAt(s))>>8,r=n%256,i.push(r),i.push(o);return i}(t,e.length-n),e,n,o)}function Fr(e,t,n){return 0===t&&n===e.length?gr(e):gr(e.slice(t,n))}function Vr(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r<n;){var i,s,a,u,c=e[r],l=null,p=c>239?4:c>223?3:c>191?2:1;if(r+p<=n)switch(p){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[r+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[r+1],s=e[r+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[r+1],s=e[r+2],a=e[r+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,p=1):l>65535&&(l-=65536,o.push(l>>>10&1023|55296),l=56320|1023&l),o.push(l),r+=p}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);for(var n="",o=0;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=4096));return n}(o)}function Kr(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(127&e[r]);return o}function Hr(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(e[r]);return o}function Br(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var r="",i=t;i<n;++i)r+=ei(e[i]);return r}function jr(e,t,n){for(var o=e.slice(t,n),r="",i=0;i<o.length;i+=2)r+=String.fromCharCode(o[i]+256*o[i+1]);return r}function Yr(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function $r(e,t,n,o,r,i){if(!Ar(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<i)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}function Wr(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r<i;++r)e[n+r]=(t&255<<8*(o?r:1-r))>>>8*(o?r:1-r)}function zr(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r<i;++r)e[n+r]=t>>>8*(o?r:3-r)&255}function Jr(e,t,n,o,r,i){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Xr(e,t,n,o,r){return r||Jr(e,0,n,4),_r(e,t,n,o,23,4),n+4}function Qr(e,t,n,o,r){return r||Jr(e,0,n,8),_r(e,t,n,o,52,8),n+8}Cr.TYPED_ARRAY_SUPPORT=void 0===F.TYPED_ARRAY_SUPPORT||F.TYPED_ARRAY_SUPPORT,Cr.poolSize=8192,Cr._augment=function(e){return e.__proto__=Cr.prototype,e},Cr.from=function(e,t,n){return Er(null,e,t,n)},Cr.TYPED_ARRAY_SUPPORT&&(Cr.prototype.__proto__=Uint8Array.prototype,Cr.__proto__=Uint8Array),Cr.alloc=function(e,t,n){return function(e,t,n,o){return Tr(t),t<=0?Mr(e,t):void 0!==n?"string"==typeof o?Mr(e,t).fill(n,o):Mr(e,t).fill(n):Mr(e,t)}(null,e,t,n)},Cr.allocUnsafe=function(e){return Sr(null,e)},Cr.allocUnsafeSlow=function(e){return Sr(null,e)},Cr.isBuffer=function(e){return null!=e&&(!!e._isBuffer||ri(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ri(e.slice(0,0))}(e))},Cr.compare=function(e,t){if(!Ar(e)||!Ar(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,o=t.length,r=0,i=Math.min(n,o);r<i;++r)if(e[r]!==t[r]){n=e[r],o=t[r];break}return n<o?-1:o<n?1:0},Cr.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Cr.concat=function(e,t){if(!yr(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Cr.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var o=Cr.allocUnsafe(t),r=0;for(n=0;n<e.length;++n){var i=e[n];if(!Ar(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(o,r),r+=i.length}return o},Cr.byteLength=Rr,Cr.prototype._isBuffer=!0,Cr.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)wr(this,t,t+1);return this},Cr.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)wr(this,t,t+3),wr(this,t+1,t+2);return this},Cr.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)wr(this,t,t+7),wr(this,t+1,t+6),wr(this,t+2,t+5),wr(this,t+3,t+4);return this},Cr.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Vr(this,0,e):Nr.apply(this,arguments)},Cr.prototype.equals=function(e){if(!Ar(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Cr.compare(this,e)},Cr.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Cr.prototype.compare=function(e,t,n,o,r){if(!Ar(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===o&&(o=0),void 0===r&&(r=this.length),t<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(o>=r&&t>=n)return 0;if(o>=r)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(o,r),c=e.slice(t,n),l=0;l<a;++l)if(u[l]!==c[l]){i=u[l],s=c[l];break}return i<s?-1:s<i?1:0},Cr.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Cr.prototype.indexOf=function(e,t,n){return Or(this,e,t,n,!0)},Cr.prototype.lastIndexOf=function(e,t,n){return Or(this,e,t,n,!1)},Cr.prototype.write=function(e,t,n,o){if(void 0===t)o="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)o=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var r=this.length-t;if((void 0===n||n>r)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){case"hex":return br(this,e,t,n);case"utf8":case"utf-8":return Pr(this,e,t,n);case"ascii":return Gr(this,e,t,n);case"latin1":case"binary":return Ur(this,e,t,n);case"base64":return xr(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qr(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},Cr.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},Cr.prototype.slice=function(e,t){var n,o=this.length;if((e=~~e)<0?(e+=o)<0&&(e=0):e>o&&(e=o),(t=void 0===t?o:~~t)<0?(t+=o)<0&&(t=0):t>o&&(t=o),t<e&&(t=e),Cr.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Cr.prototype;else{var r=t-e;n=new Cr(r,void 0);for(var i=0;i<r;++i)n[i]=this[i+e]}return n},Cr.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Yr(e,t,this.length);for(var o=this[e],r=1,i=0;++i<t&&(r*=256);)o+=this[e+i]*r;return o},Cr.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Yr(e,t,this.length);for(var o=this[e+--t],r=1;t>0&&(r*=256);)o+=this[e+--t]*r;return o},Cr.prototype.readUInt8=function(e,t){return t||Yr(e,1,this.length),this[e]},Cr.prototype.readUInt16LE=function(e,t){return t||Yr(e,2,this.length),this[e]|this[e+1]<<8},Cr.prototype.readUInt16BE=function(e,t){return t||Yr(e,2,this.length),this[e]<<8|this[e+1]},Cr.prototype.readUInt32LE=function(e,t){return t||Yr(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Cr.prototype.readUInt32BE=function(e,t){return t||Yr(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Cr.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Yr(e,t,this.length);for(var o=this[e],r=1,i=0;++i<t&&(r*=256);)o+=this[e+i]*r;return o>=(r*=128)&&(o-=Math.pow(2,8*t)),o},Cr.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Yr(e,t,this.length);for(var o=t,r=1,i=this[e+--o];o>0&&(r*=256);)i+=this[e+--o]*r;return i>=(r*=128)&&(i-=Math.pow(2,8*t)),i},Cr.prototype.readInt8=function(e,t){return t||Yr(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Cr.prototype.readInt16LE=function(e,t){t||Yr(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Cr.prototype.readInt16BE=function(e,t){t||Yr(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Cr.prototype.readInt32LE=function(e,t){return t||Yr(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Cr.prototype.readInt32BE=function(e,t){return t||Yr(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Cr.prototype.readFloatLE=function(e,t){return t||Yr(e,4,this.length),mr(this,e,!0,23,4)},Cr.prototype.readFloatBE=function(e,t){return t||Yr(e,4,this.length),mr(this,e,!1,23,4)},Cr.prototype.readDoubleLE=function(e,t){return t||Yr(e,8,this.length),mr(this,e,!0,52,8)},Cr.prototype.readDoubleBE=function(e,t){return t||Yr(e,8,this.length),mr(this,e,!1,52,8)},Cr.prototype.writeUIntLE=function(e,t,n,o){e=+e,t|=0,n|=0,o||$r(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,i=0;for(this[t]=255&e;++i<n&&(r*=256);)this[t+i]=e/r&255;return t+n},Cr.prototype.writeUIntBE=function(e,t,n,o){e=+e,t|=0,n|=0,o||$r(this,e,t,n,Math.pow(2,8*n)-1,0);var r=n-1,i=1;for(this[t+r]=255&e;--r>=0&&(i*=256);)this[t+r]=e/i&255;return t+n},Cr.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,1,255,0),Cr.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Cr.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,2,65535,0),Cr.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Wr(this,e,t,!0),t+2},Cr.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,2,65535,0),Cr.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Wr(this,e,t,!1),t+2},Cr.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,4,4294967295,0),Cr.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):zr(this,e,t,!0),t+4},Cr.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,4,4294967295,0),Cr.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):zr(this,e,t,!1),t+4},Cr.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);$r(this,e,t,n,r-1,-r)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},Cr.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);$r(this,e,t,n,r-1,-r)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},Cr.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,1,127,-128),Cr.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Cr.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,2,32767,-32768),Cr.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Wr(this,e,t,!0),t+2},Cr.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,2,32767,-32768),Cr.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Wr(this,e,t,!1),t+2},Cr.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,4,2147483647,-2147483648),Cr.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):zr(this,e,t,!0),t+4},Cr.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||$r(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Cr.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):zr(this,e,t,!1),t+4},Cr.prototype.writeFloatLE=function(e,t,n){return Xr(this,e,t,!0,n)},Cr.prototype.writeFloatBE=function(e,t,n){return Xr(this,e,t,!1,n)},Cr.prototype.writeDoubleLE=function(e,t,n){return Qr(this,e,t,!0,n)},Cr.prototype.writeDoubleBE=function(e,t,n){return Qr(this,e,t,!1,n)},Cr.prototype.copy=function(e,t,n,o){if(n||(n=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);var r,i=o-n;if(this===e&&n<t&&t<o)for(r=i-1;r>=0;--r)e[r+t]=this[r+n];else if(i<1e3||!Cr.TYPED_ARRAY_SUPPORT)for(r=0;r<i;++r)e[r+t]=this[r+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},Cr.prototype.fill=function(e,t,n,o){if("string"==typeof e){if("string"==typeof t?(o=t,t=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),1===e.length){var r=e.charCodeAt(0);r<256&&(e=r)}if(void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!Cr.isEncoding(o))throw new TypeError("Unknown encoding: "+o)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=Ar(e)?e:ti(new Cr(e,o).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var Zr=/[^+\/0-9A-Za-z-_]/g;function ei(e){return e<16?"0"+e.toString(16):e.toString(16)}function ti(e,t){var n;t=t||1/0;for(var o=e.length,r=null,i=[],s=0;s<o;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&i.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function ni(e){return function(e){var t,n,o,r,i,s;hr||dr();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[a-2]?2:"="===e[a-1]?1:0,s=new pr(3*a/4-i),o=i>0?a-4:a;var u=0;for(t=0,n=0;t<o;t+=4,n+=3)r=lr[e.charCodeAt(t)]<<18|lr[e.charCodeAt(t+1)]<<12|lr[e.charCodeAt(t+2)]<<6|lr[e.charCodeAt(t+3)],s[u++]=r>>16&255,s[u++]=r>>8&255,s[u++]=255&r;return 2===i?(r=lr[e.charCodeAt(t)]<<2|lr[e.charCodeAt(t+1)]>>4,s[u++]=255&r):1===i&&(r=lr[e.charCodeAt(t)]<<10|lr[e.charCodeAt(t+1)]<<4|lr[e.charCodeAt(t+2)]>>2,s[u++]=r>>8&255,s[u++]=255&r),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Zr,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function oi(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function ri(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ii=function(e){l(n,e);var t=v(n);function n(){var e;return r(this,n),(e=t.call(this)).retry=2,e._request=e.promisify(wx.request),e}return s(n,[{key:"request",value:function(e){return this._checkOptions(e),this._initOptions(e),e=c({},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(X(o.errMsg)){if(o.errMsg.includes("abort"))return Nn({});if(o.errMsg.includes("timeout"))return t.retry>0&&n<t.retry?t._requestWithRetry(e,++n):wn(new nt({code:ot.NETWORK_TIMEOUT,message:o.errMsg}));if(o.errMsg.includes("fail"))return t.retry>0&&n<t.retry?t._requestWithRetry(e,++n):wn(new nt({code:ot.NETWORK_ERROR,message:o.errMsg}))}return wn(new nt(c({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"number"==typeof n&&(o=n),o!==Oe&&(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&&oe(r.abort)&&r.abort()}))}))}}}]),n}(ar),si=function(){function e(){r(this,e),this.request=0,this.success=0,this.fail=0,this.reportRate=10,this.requestTimeCost=[]}return s(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));W.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}(),ai=ir.create({timeout:6e3,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});ai.interceptors.response.use((function(e){var t=e.data,n=t.error_code,o=t.ErrorCode;return J(n)&&(o=n),o!==Oe&&(e.data.ErrorCode=Number(o)),e}),(function(e){return"Network Error"===e.message&&(!0===ai.defaults.withCredentials&&W.warn("Network Error, try to close `IMAxiosAVChatroom.defaults.withCredentials` to false. (IMAxiosAVChatroom.js)"),ai.defaults.withCredentials=!1),Promise.reject(e)}));var ui=ir.CancelToken,ci=function(){function e(t){r(this,e),this._initializeOptions(t),this._initializeMembers(),this.status=new si}return s(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:"getIndex",value:function(){return this._index}},{key:"isRunning",value:function(){return!this._stoped}},{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.options.isAVChatRoomLoop?this.requestor=ai:this.requestor=sr,W.log("XHRRunLoop._initializeMembers isAVChatRoomLoop=".concat(!!this.options.isAVChatRoomLoop)),this.abort=null}},{key:"start",value:function(){0===this._seedID?(this._stoped=!1,this._send()):W.log('XHRRunLoop.start(), XHRRunLoop is running now, if you want to restart runLoop , please run "stop()" first.')}},{key:"_reset",value:function(){W.log("XHRRunLoop._reset(), reset long poll _intervalTime",this._intervalTime),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===Oe?this._intervalTimeDecrease():this._intervalTimeIncrease()}},{key:"_send",value:function(){var e=this;if(!0!==this._requestStatus){this._requestStatus=!0,this.status.request++,"function"==typeof this.options.before&&this.options.before(this.options.pack.requestData);var t=Date.now(),n=0;this.requestor.request({url:this.options.pack.getUrl(),data:this.options.pack.requestData,method:this.options.pack.method,cancelToken:new ui((function(t){e.abort=t}))}).then((function(o){if(e._intervalTimeAdjustmentBaseOnResponseData.bind(e)(o.data),e._retryCount>0&&(e._retryCount=0),e.status.success++,n=Date.now(),e.status.setRequestTime(t,n),o.data.timecost=n-t,"function"==typeof e.options.success)try{e.options.success({pack:e.options.pack,error:!1,data:e.options.pack.callback(o.data)})}catch(e){W.warn("XHRRunLoop._send(), error:",e)}e._requestStatus=!1,!1===e._stoped&&(e._seedID=setTimeout(e._send.bind(e),e._intervalTime)),e.status.report()})).catch((function(o){if(e.status.fail++,e._retryCount++,e._intervalTimeAdjustment.bind(e)(),!1===e._stoped&&(e._seedID=setTimeout(e._send.bind(e),e._intervalTime)),e._requestStatus=!1,"function"==typeof e.options.fail&&void 0!==o.request)try{e.options.fail({pack:e.options.pack,error:o,data:!1})}catch(e){W.warn("XHRRunLoop._send(), fail callback error:",e),W.error(e)}n=Date.now(),e.status.setRequestTime(t,n),e.status.report()}))}}},{key:"stop",value:function(){this._clearAllTimeOut(),this._stoped=!0}},{key:"_clearAllTimeOut",value:function(){clearTimeout(this._seedID),this._seedID=0}}]),e}(),li=function(){function e(t){r(this,e),this._initializeOptions(t),this._initializeMembers(),this.status=new si}return s(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 ii,this.abort=null}},{key:"start",value:function(){0===this._seedID?(this._stoped=!1,this._send()):W.log('WXRunLoop.start(): WXRunLoop is running now, if you want to restart runLoop , please run "stop()" first.')}},{key:"_reset",value:function(){W.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===Oe?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(e){W.warn("WXRunLoop._send(), error:",e)}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(e){W.warn("WXRunLoop._send(), fail callback error:",e),W.error(e)}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}(),pi=function(){function e(t){r(this,e),this.tim=t,this.httpConnection=O?new ii:new ur,this.keepAliveConnections=[]}return s(e,[{key:"initializeListener",value:function(){this.tim.innerEmitter.on(un,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!==Oe?wn(new nt({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 O?new li(e):(2===this.tim.options.runLoopNetType||this.tim.options.runLoopNetType,new ci(e))}},{key:"clearAll",value:function(){this.conn.cancelAll()}},{key:"reset",value:function(){this.keepAliveConnections=[]}}]),e}(),hi=function(){function t(e){r(this,t),this.tim=e,this.tim.innerEmitter.on(pn,this._onErrorDetected,this)}return s(t,[{key:"_onErrorDetected",value:function(t){var n=t.data,o=new Bn;o.setMethod("exceptionError").setStart(),o.setCode(0).setText("code=".concat(n.code," message=").concat(n.message)).setNetworkType(this.tim.netMonitor.getNetworkType()).setEnd(),n.code?W.warn("Oops! code:".concat(n.code," message:").concat(n.message)):W.warn("Oops! message:".concat(n.message," stack:").concat(n.stack)),this.tim.outerEmitter.emit(e.ERROR,n)}}]),t}(),di=function(){function e(t){var o=this;r(this,e),ke(t)||(this.userID=t.userID||"",this.nick=t.nick||"",this.gender=t.gender||"",this.birthday=t.birthday||0,this.location=t.location||"",this.selfSignature=t.selfSignature||"",this.allowType=t.allowType||n.ALLOW_TYPE_ALLOW_ANY,this.language=t.language||0,this.avatar=t.avatar||"",this.messageSettings=t.messageSettings||0,this.adminForbidType=t.adminForbidType||n.FORBID_TYPE_NONE,this.level=t.level||0,this.role=t.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],ke(t.profileCustomField)||t.profileCustomField.forEach((function(e){o.profileCustomField.push({key:e.key,value:e.value})})))}return s(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],!X(r.key)||-1===r.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"自定义资料字段的前缀必须是 Tag_Profile_Custom"};if(!X(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])&&!X(e[s])&&!J(e[s])){n="key:"+s+", invalid value:"+e[s],t=!1;continue}switch(s){case"nick":X(e[s])||(n="nick should be a string",t=!1),he(e[s])>500&&(n="nick name limited: must less than or equal to ".concat(500," bytes, current size: ").concat(he(e[s])," bytes"),t=!1);break;case"gender":me(je,e.gender)||(n="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":J(e.birthday)||(n="birthday should be a number",t=!1);break;case"location":X(e.location)||(n="location should be a string",t=!1);break;case"selfSignature":X(e.selfSignature)||(n="selfSignature should be a string",t=!1);break;case"allowType":me($e,e.allowType)||(n="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":J(e.language)||(n="language should be a number",t=!1);break;case"avatar":X(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":me(Ye,e.adminForbidType)||(n="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":J(e.level)||(n="level should be a number",t=!1);break;case"role":J(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}(),fi=function(){function t(e){r(this,t),this.userController=e,this.TAG="profile",this.Actions={Q:"query",U:"update"},this.accountProfileMap=new Map,this.expirationTime=864e5}return s(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&&(W.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 Nn(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 Bn;l.setMethod("getUserProfile").setText(n.length>5?"userIDList.length=".concat(n.length):"userIDList=".concat(n)).setStart();var p=this.userController.generateConfig(this.TAG,this.Actions.Q,e);return this.userController.request(p).then((function(e){l.setCode(0).setNetworkType(t.userController.getNetworkType()).setEnd(),W.info("ProfileHandler.getUserProfile ok");var n=t._handleResponse(e).concat(i);return u?(t.userController.onGotMyProfile(),new An(n[0])):new An(n)})).catch((function(e){return t.userController.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];l.setError(e,o,r).setEnd()})),W.error("ProfileHandler.getUserProfile error:",e),wn(e)}))}},{key:"getMyProfile",value:function(){var e=this.userController.getMyAccount();if(W.log("ProfileHandler.getMyProfile myAccount="+e),this._fillMap(),this._containsAccount(e)){var t=this._getProfileFromMap(e);return W.debug("ProfileHandler.getMyProfile from cache, myProfile:"+JSON.stringify(t)),this.userController.onGotMyProfile(),Nn(t)}return this.getUserProfile({fromAccount:e,userIDList:[e],bFromGetMyProfile:!0})}},{key:"_handleResponse",value:function(e){for(var t,n,o=ue.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 W.log("ProfileHandler._handleResponse cost "+(ue.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 Be.NICK:n.nick=t[o].value;break;case Be.GENDER:n.gender=t[o].value;break;case Be.BIRTHDAY:n.birthday=t[o].value;break;case Be.LOCATION:n.location=t[o].value;break;case Be.SELFSIGNATURE:n.selfSignature=t[o].value;break;case Be.ALLOWTYPE:n.allowType=t[o].value;break;case Be.LANGUAGE:n.language=t[o].value;break;case Be.AVATAR:n.avatar=t[o].value;break;case Be.MESSAGESETTINGS:n.messageSettings=t[o].value;break;case Be.ADMINFORBIDTYPE:n.adminForbidType=t[o].value;break;case Be.LEVEL:n.level=t[o].value;break;case Be.ROLE:n.role=t[o].value;break;default:W.warn("ProfileHandler._handleResponse unkown tag->",t[o].tag,t[o].value)}return n}},{key:"updateMyProfile",value:function(t){var n=this,o=new Bn;o.setMethod("updateMyProfile").setText(JSON.stringify(t)).setStart();var r=(new di).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(),W.error("ProfileHandler.updateMyProfile info:".concat(r.tips,",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")),wn({code:ot.UPDATE_PROFILE_INVALID_PARAM,message:"传入 updateMyProfile 接口的参数无效"});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:Be[s.toUpperCase()],value:t[s]}));if(0===i.length)return o.setCode(ot.UPDATE_PROFILE_NO_KEY).setMessage(ct).setNetworkType(this.userController.getNetworkType()).setEnd(),W.error("ProfileHandler.updateMyProfile info:".concat(ct,",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#updateMyProfile")),wn({code:ot.UPDATE_PROFILE_NO_KEY,message:ct});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.setCode(0).setNetworkType(n.userController.getNetworkType()).setEnd(),W.info("ProfileHandler.updateMyProfile ok");var i=n._updateMap(n.userController.getMyAccount(),t);return n.userController.emitOuterEvent(e.PROFILE_UPDATED,[i]),Nn(i)})).catch((function(e){return n.userController.probeNetwork().then((function(t){var n=y(t,2),r=n[0],i=n[1];o.setError(e,r,i).setEnd()})),W.error("ProfileHandler.updateMyProfile error:",e),wn(e)}))}},{key:"onProfileModified",value:function(t){var n=t.data;if(!ke(n)){var o,r,i=n.length;W.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(gn,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]);W.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&&Ie(n.profileCustomField,t.profileCustomField),ce(n,t,["profileCustomField"]),n.lastUpdatedTime=o):(n=new di(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=I(this.accountProfileMap.values()),n=this.userController.tim.storage;W.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),ce(o,t)>0&&r.push(n)):r.push(t.userID));0!==r.length&&(W.info("ProfileHandler.onConversationsProfileUpdated toAccount:",r),this.getUserProfile({userIDList:r}))}},{key:"reset",value:function(){this._flushMap(!0),this.accountProfileMap.clear()}}]),t}(),gi=function(){function e(t){r(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 s(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}(),mi=function e(t,n){r(this,e),this.userID=t;var o={};if(o.userID=t,!ke(n))for(var i=0,s=n.length;i<s;i++)switch(n[i].tag){case Be.NICK:o.nick=n[i].value;break;case Be.GENDER:o.gender=n[i].value;break;case Be.BIRTHDAY:o.birthday=n[i].value;break;case Be.LOCATION:o.location=n[i].value;break;case Be.SELFSIGNATURE:o.selfSignature=n[i].value;break;case Be.ALLOWTYPE:o.allowType=n[i].value;break;case Be.LANGUAGE:o.language=n[i].value;break;case Be.AVATAR:o.avatar=n[i].value;break;case Be.MESSAGESETTINGS:o.messageSettings=n[i].value;break;case Be.ADMINFORBIDTYPE:o.adminForbidType=n[i].value;break;case Be.LEVEL:o.level=n[i].value;break;case Be.ROLE:o.role=n[i].value;break;default:W.debug("snsProfileItem unkown tag->",n[i].tag)}this.profile=new di(o)},_i=function(){function e(t){r(this,e),this.userController=t,this.TAG="friend",this.Actions={G:"get",D:"delete"},this.friends=new Map,this.pointer=new gi}return s(e,[{key:"isMyFriend",value:function(e){var t=this.friends.has(e);return t||W.debug("FriendHandler.isMyFriend "+e+" is not my friend"),t}},{key:"_transformFriendList",value:function(e){if(!ke(e)&&!ke(e.infoItem)){W.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 mi(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(),W.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){W.info("FriendHandler.getFriendList ok"),e._transformFriendList(t.data);var n=I(e.friends.values());return Nn(n)})).catch((function(e){return W.error("FriendHandler.getFriendList error:",e),wn(e)}))}},{key:"deleteFriend",value:function(e){if(!Array.isArray(e.toAccount))return W.error("FriendHandler.deleteFriend options.toAccount 必需是数组"),wn({code:ot.DEL_FRIEND_INVALID_PARAM,message:"传入 deleteFriend 接口的参数无效"});e.toAccount.length>1e3&&(W.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 W.info("FriendHandler.deleteFriend ok"),Nn()})).catch((function(e){return W.error("FriendHandler.deleteFriend error:",e),wn(e)}))}}]),e}(),vi=function e(t){r(this,e),ke||(this.userID=t.userID||"",this.timeStamp=t.timeStamp||0)},yi=function(){function t(e){r(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 s(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 Bn;n.setMethod("getBlacklist").setStart();var 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.setCode(0).setNetworkType(e.userController.getNetworkType()).setText(o).setEnd(),W.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=y(e,2),r=o[0],i=o[1];n.setError(t,r,i).setEnd()})),W.error("BlacklistHandler.getBlacklist error:",t),wn(t)}))}},{key:"addBlacklist",value:function(e){var t=this,n=new Bn;if(n.setMethod("addToBlacklist").setStart(),!ee(e.userIDList))return n.setCode(ot.ADD_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.addBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(),W.error("BlacklistHandler.addBlacklist options.userIDList 必需是数组"),wn({code:ot.ADD_BLACKLIST_INVALID_PARAM,message:"传入 addToBlacklist 接口的参数无效"});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("不能拉黑自己").setNetworkType(this.userController.getNetworkType()).setEnd(),W.error("BlacklistHandler.addBlacklist 不能把自己拉黑"),wn({code:ot.CANNOT_ADD_SELF_TO_BLACKLIST,message:"不能拉黑自己"});e.userIDList.includes(o)&&(e.userIDList=e.userIDList.filter((function(e){return e!==o})),W.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.setCode(0).setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setEnd(),W.info("BlacklistHandler.addBlacklist ok"),t._handleResponse(o.data.resultItem,!0),t._onBlacklistUpdated()})).catch((function(e){return t.userController.probeNetwork().then((function(t){var o=y(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),W.error("BlacklistHandler.addBlacklist error:",e),wn(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,(te(r)||0===r)&&(t?((n=this.blacklistMap.has(o)?this.blacklistMap.get(o):new vi).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)));W.log("BlacklistHandler._handleResponse total="+this.blacklistMap.size+" bAdd="+t)}},{key:"deleteBlacklist",value:function(e){var t=this,n=new Bn;if(n.setMethod("removeFromBlacklist").setStart(),!ee(e.userIDList))return n.setCode(ot.DEL_BLACKLIST_INVALID_PARAM).setMessage("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组").setNetworkType(this.userController.getNetworkType()).setEnd(),W.error("BlacklistHandler.deleteBlacklist options.userIDList 必需是数组"),wn({code:ot.DEL_BLACKLIST_INVALID_PARAM,message:"传入 removeFromBlacklist 接口的参数无效"});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.setCode(0).setNetworkType(t.userController.getNetworkType()).setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setEnd(),W.info("BlacklistHandler.deleteBlacklist ok"),t._handleResponse(o.data.resultItem,!1),t._onBlacklistUpdated()})).catch((function(e){return t.userController.probeNetwork().then((function(t){var o=y(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),W.error("BlacklistHandler.deleteBlacklist error:",e),wn(e)}))}},{key:"_onBlacklistUpdated",value:function(){var t=I(this.blacklistMap.keys());return this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,t),Nn(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&&(W.log("BlacklistHandler.handleBlackListDelAccount delCount="+o.length+" : "+o.join(",")),this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,I(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 vi({userID:n})),o.push(n));o.length>0&&(W.log("BlacklistHandler.handleBlackListAddAccount addCount="+o.length+" : "+o.join(",")),this.userController.emitOuterEvent(e.BLACKLIST_UPDATED,I(this.blacklistMap.keys())))}},{key:"reset",value:function(){this.blacklistMap.clear(),this.startIndex=0,this.maxLimited=100,this.curruentSequence=0}}]),t}(),Ii=function(){function e(t){r(this,e),this.userController=t,this.TAG="applyC2C",this.Actions={C:"create",G:"get",D:"delete",U:"update"}}return s(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}(),Mi=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e)).profileHandler=new fi(m(o)),o.friendHandler=new _i(m(o)),o.blacklistHandler=new yi(m(o)),o.applyC2CHandler=new Ii(m(o)),o._initializeListener(),o}return s(n,[{key:"_initializeListener",value:function(e){var t=this.tim.innerEmitter;t.on(Ot,this.onContextUpdated,this),t.on(Zt,this.onProfileModified,this),t.on(Qt,this.onNewFriendMessages,this),t.on(dn,this.onConversationsProfileUpdated,this)}},{key:"onContextUpdated",value:function(e){var t=this.tim.context;0!=!!t.a2Key&&0!=!!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){W.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(){W.info("UserController.reset"),this.resetReady(),this.profileHandler.reset(),this.blacklistHandler.reset(),this.checkTimes=0}}]),n}(Sn),Ci=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers"],Ei=function(){function e(t){r(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.maxMemberNum="",this.joinOption="",this.groupCustomField=[],this.muteAllMembers=void 0,this._initGroup(t)}return s(e,[{key:"_initGroup",value:function(e){for(var t in e)Ci.indexOf(t)<0||("selfInfo"!==t?this[t]=e[t]:this.updateSelfInfo(e[t]))}},{key:"updateGroup",value:function(e){e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),te(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField&&Ie(this.groupCustomField,e.groupCustomField),ce(this,e,["members","errorCode","lastMsgTime","groupCustomField"])}},{key:"updateSelfInfo",value:function(e){var t=e.nameCard,n=e.joinTime,o=e.role,r=e.messageRemindType;ce(this.selfInfo,{nameCard:t,joinTime:n,role:o,messageRemindType:r},[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function(e){this.selfInfo.nameCard=e}}]),e}(),Ti=function(e,t){if(te(t))return"";switch(e){case n.MSG_TEXT:return t.text;case n.MSG_IMAGE:return"[图片]";case n.MSG_GEO:return"[位置]";case n.MSG_AUDIO:return"[语音]";case n.MSG_VIDEO:return"[视频]";case n.MSG_FILE:return"[文件]";case n.MSG_CUSTOM:return"[自定义消息]";case n.MSG_GRP_TIP:return"[群提示消息]";case n.MSG_GRP_SYS_NOTICE:return"[群系统通知]";case n.MSG_FACE:return"[动画表情]";default:return""}},Si=function(e){return te(e)?{lastTime:0,lastSequence:0,fromAccount:0,messageForShow:"",payload:null,type:"",isRevoked:!1}:e instanceof yt?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Ti(e.type,e.payload),payload:e.payload||null,type:e.type||null,isRevoked:!1}:c({},e,{isRevoked:!1,messageForShow:Ti(e.type,e.payload)})},Di=function(){function e(t){r(this,e),this.conversationID=t.conversationID||"",this.unreadCount=t.unreadCount||0,this.type=t.type||"",this.lastMessage=Si(t.lastMessage),t.lastMsgTime&&(this.lastMessage.lastTime=t.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=t.peerReadTime||0,this._initProfile(t)}return s(e,[{key:"_initProfile",value:function(e){var t=this;Object.keys(e).forEach((function(n){switch(n){case"userProfile":t.userProfile=e.userProfile;break;case"groupProfile":t.groupProfile=e.groupProfile}})),te(this.userProfile)&&this.type===n.CONV_C2C?this.userProfile=new di({userID:e.conversationID.replace("C2C","")}):te(this.groupProfile)&&this.type===n.CONV_GROUP&&(this.groupProfile=new Ei({groupID:e.conversationID.replace("GROUP","")}))}},{key:"updateUnreadCount",value:function(e,t){te(e)||(Ce(this.subType)||Ee(this.subType)?this.unreadCount=0:t&&this.type===n.CONV_GROUP?this.unreadCount=e:this.unreadCount=this.unreadCount+e)}},{key:"updateLastMessage",value:function(e){this.lastMessage=Si(e)}},{key:"reduceUnreadCount",value:function(){this.unreadCount>=1&&(this.unreadCount-=1)}},{key:"isLastMessageRevoked",value:function(e){var t=e.sequence,o=e.time;return this.type===n.CONV_C2C&&t===this.lastMessage.lastSequence&&o===this.lastMessage.lastTime||this.type===n.CONV_GROUP&&t===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}(),ki=function(t){l(i,t);var o=v(i);function i(e){var t;return r(this,i),(t=o.call(this,e)).pagingStatus=xe,t.pagingTimeStamp=0,t.conversationMap=new Map,t.tempGroupList=[],t._initListeners(),t}return s(i,[{key:"hasLocalConversationMap",value:function(){return this.conversationMap.size>0}},{key:"_createLocalConversation",value:function(e){return this.conversationMap.has(e)?this.conversationMap.get(e):(W.log("ConversationController._createLocalConversation conversationID:".concat(e)),new Di({conversationID:e,type:e.slice(0,3)===n.CONV_C2C?n.CONV_C2C:n.CONV_GROUP}))}},{key:"hasLocalConversation",value:function(e){return this.conversationMap.has(e)}},{key:"getConversationList",value:function(){var e=this;W.log("ConversationController.getConversationList."),this.pagingStatus===Ve&&(W.log("ConversationController.getConversationList. continue to sync conversationList"),this._syncConversationList());var t=new Bn;return t.setMethod("getConversationList").setStart(),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.setCode(0).setText(r.length).setNetworkType(e.getNetworkType()).setEnd(),W.log("ConversationController.getConversationList ok."),Nn({conversationList:e.getLocalConversationList()})})).catch((function(n){return e.probeNetwork().then((function(e){var o=y(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd()})),W.error("ConversationController.getConversationList error:",n),wn(n)}))}},{key:"_syncConversationList",value:function(){var e=this,t=new Bn;return t.setMethod("syncConversationList").setStart(),this.pagingStatus===xe&&this.conversationMap.clear(),this._autoPagingSyncConversationList().then((function(n){return e.pagingStatus=Fe,e._setStorageConversationList(),e._handleC2CPeerReadTime(),t.setCode(0).setText("".concat(e.conversationMap.size)).setNetworkType(e.getNetworkType()).setEnd(),n})).catch((function(n){return e.pagingStatus=Ve,t.setText(e.pagingTimeStamp),e.probeNetwork().then((function(e){var o=y(e,2),r=o[0],i=o[1];t.setError(n,r,i).setEnd()})),wn(n)}))}},{key:"_autoPagingSyncConversationList",value:function(){var e=this;return this.pagingStatus=qe,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(W.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():Nn()}))}},{key:"_handleC2CPeerReadTime",value:function(){var e,t=this.tim.messageController,o=E(this.conversationMap);try{for(o.s();!(e=o.n()).done;){var r=y(e.value,2),i=r[0],s=r[1];s.type===n.CONV_C2C&&(W.debug("ConversationController._handleC2CPeerReadTime",i,s.peerReadTime),t.recordPeerReadTime(i,s.peerReadTime))}}catch(e){o.e(e)}finally{o.f()}}},{key:"getConversationProfile",value:function(e){var t=this,o=this.conversationMap.has(e)?this.conversationMap.get(e):this._createLocalConversation(e);if(o._isInfoCompleted||o.type===n.CONV_SYSTEM)return Nn({conversation:o});var r=new Bn;return r.setMethod("getConversationProfile").setStart(),W.log("ConversationController.getConversationProfile. conversationID:".concat(e," lastMessage:"),o.lastMessage),this._updateUserOrGroupProfileCompletely(o).then((function(n){return r.setCode(0).setNetworkType(t.getNetworkType()).setText("conversationID=".concat(e," unreadCount=").concat(n.data.conversation.unreadCount)).setEnd(),W.log("ConversationController.getConversationProfile ok. conversationID:",e),n})).catch((function(n){return t.probeNetwork().then((function(t){var o=y(t,2),i=o[0],s=o[1];r.setError(n,i,s).setText("conversationID=".concat(e)).setEnd()})),W.error("ConversationController.getConversationProfile error:",n),wn(n)}))}},{key:"deleteConversation",value:function(e){var t=this,o={};if(!this.conversationMap.has(e)){var r=new nt({code:ot.CONVERSATION_NOT_FOUND,message:"没有找到相应的会话,请检查传入参数"});return wn(r)}switch(this.conversationMap.get(e).type){case n.CONV_C2C:o.type=1,o.toAccount=e.replace(n.CONV_C2C,"");break;case n.CONV_GROUP:o.type=2,o.toGroupID=e.replace(n.CONV_GROUP,"");break;case n.CONV_SYSTEM:return this.tim.groupController.deleteGroupSystemNotice({messageList:this.tim.messageController.getLocalMessageList(e)}),this.deleteLocalConversation(e),Nn({conversationID:e});default:var i=new nt({code:ot.CONVERSATION_UN_RECORDED_TYPE,message:"未记录的会话类型"});return wn(i)}var s=new Bn;return s.setMethod("deleteConversation").setText("conversationID=".concat(e)).setStart(),W.log("ConversationController.deleteConversation. conversationID=".concat(e)),this.tim.setMessageRead({conversationID:e}).then((function(){return t.request({name:"conversation",action:"delete",param:o})})).then((function(){return s.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("ConversationController.deleteConversation ok."),t.deleteLocalConversation(e),Nn({conversationID:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];s.setError(e,o,r).setEnd()})),W.error("ConversationController.deleteConversation error:",e),wn(e)}))}},{key:"getLocalConversationList",value:function(){return I(this.conversationMap.values())}},{key:"getLocalConversation",value:function(e){return this.conversationMap.get(e)}},{key:"_initLocalConversationList",value:function(){var e=new Bn;e.setMethod("getConversationListInStorage").setStart(),W.time("initConversationList"),W.log("ConversationController._initLocalConversationList init");var t=this._getStorageConversationList();if(t){for(var n=t.length,o=0;o<n;o++)this.conversationMap.set(t[o].conversationID,new Di(t[o]));this._emitConversationUpdate(!0,!1),e.setCode(0).setNetworkType(this.getNetworkType()).setText(n).setEnd()}else e.setCode(0).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(Ot,this._initLocalConversationList,this),this.tim.innerEmitter.on(Gt,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(Ut,this._handleSyncMessages,this),this.tim.innerEmitter.on(xt,this._handleSyncMessages,this),this.tim.innerEmitter.on(qt,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(Ft,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(Vt,this._onSendOrReceiveMessage,this),this.tim.innerEmitter.on(sn,this._onGroupListUpdated,this),this.tim.innerEmitter.on(gn,this._updateConversationUserProfile,this),this.tim.innerEmitter.on(Kt,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;ee(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 t=this,o=[];e.forEach((function(e){t.conversationMap.has(e.conversationID)||e.type!==n.CONV_C2C||o.push(e.conversationID.replace(n.CONV_C2C,""))})),o.length>0&&(W.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(I(o.conversations),I(this.conversationMap)))),t||this._updateUserOrGroupProfile(o.newerConversations)}},{key:"_updateTempConversations",value:function(e,t,o){for(var r=[],i=[],s=0,a=e.length;s<a;s++){var u=new Di(e[s]),c=this.conversationMap.get(u.conversationID);if(this.conversationMap.has(u.conversationID)){var l=["unreadCount","allowType","adminForbidType","payload"];o&&l.push("lastMessage"),ce(c,u,l,[null,void 0,"",0,NaN]),c.updateUnreadCount(u.unreadCount,t),o||(c.lastMessage.payload=e[s].lastMessage.payload),this.conversationMap.delete(c.conversationID),r.push([c.conversationID,c])}else{if(u.type===n.CONV_GROUP){var p=u.groupProfile.groupID,h=this.tim.groupController.getLocalGroupProfile(p);h&&(u.groupProfile=h,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 t=this;if(0!==e.length){var o=[],r=[];e.forEach((function(e){if(e.type===n.CONV_C2C)o.push(e.toAccount);else if(e.type===n.CONV_GROUP){var i=e.toAccount;t.tim.groupController.hasLocalGroup(i)?e.groupProfile=t.tim.groupController.getLocalGroupProfile(i):r.push(i)}})),o.length>0&&this.tim.getUserProfile({userIDList:o}).then((function(e){var n=e.data;ee(n)?n.forEach((function(e){t.conversationMap.get("C2C".concat(e.userID)).userProfile=e})):t.conversationMap.get("C2C".concat(n.userID)).userProfile=n})),r.length>0&&this.tim.groupController.getGroupProfileAdvance({groupIDList:r,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((function(e){e.data.successGroupList.forEach((function(e){var n="GROUP".concat(e.groupID);if(t.conversationMap.has(n)){var o=t.conversationMap.get(n);ce(o.groupProfile,e,[],[null,void 0,"",0,NaN]),!o.subType&&e.type&&(o.subType=e.type)}}))}))}}},{key:"_updateUserOrGroupProfileCompletely",value:function(e){var t=this;return e.type===n.CONV_C2C?this.tim.getUserProfile({userIDList:[e.toAccount]}).then((function(n){var o=n.data;return 0===o.length?wn(new nt({code:ot.USER_OR_GROUP_NOT_FOUND,message:"没有找到相应的用户或群组,请检查传入参数"})):(e.userProfile=o[0],e._isInfoCompleted=!0,t._unshiftConversation(e),Nn({conversation:e}))})):this.tim.getGroupProfile({groupID:e.toAccount}).then((function(n){return e.groupProfile=n.data.group,e._isInfoCompleted=!0,t._unshiftConversation(e),Nn({conversation:e})}))}},{key:"_unshiftConversation",value:function(e){e instanceof Di&&!this.conversationMap.has(e.conversationID)&&(this.conversationMap=new Map([[e.conversationID,e]].concat(I(this.conversationMap))),this._setStorageConversationList(),this._emitConversationUpdate(!0,!1))}},{key:"deleteLocalConversation",value:function(e){this.conversationMap.delete(e),this._setStorageConversationList(),this.emitInnerEvent(fn,e),this._emitConversationUpdate(!0,!1)}},{key:"_getConversationOptions",value:function(e){var t=[],n=e.filter((function(e){var t=e.lastMsg;return Z(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 di(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 Ei({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage}),unreadCount:e.unreadCount,peerReadTime:0}}));return t.length>0&&this.emitInnerEvent(dn,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=I(this.conversationMap.values());n&&this.emitInnerEvent(hn,o),t&&this.emitOuterEvent(e.CONVERSATION_LIST_UPDATED,o)}},{key:"_conversationMapTreeShaking",value:function(e){var t=this,o=new Map(I(this.conversationMap));e.forEach((function(e){return o.delete(e.conversationID)})),o.has(n.CONV_SYSTEM)&&o.delete(n.CONV_SYSTEM);var r=this.tim.groupController.getJoinedAVChatRoom();r&&r.forEach((function(e){o.delete("".concat(n.CONV_GROUP).concat(e))})),I(o.keys()).forEach((function(e){return t.conversationMap.delete(e)}))}},{key:"reset",value:function(){this.pagingStatus=xe,this.pagingTimeStamp=0,this.conversationMap.clear(),this.resetReady(),this.tim.innerEmitter.once(Ot,this._initLocalConversationList,this)}}]),i}(Sn),Ai=function(){function e(t){if(r(this,e),void 0===t)throw new nt({code:ot.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,message:rt});if(void 0===t.tim)throw new nt({code:ot.MESSAGE_LIST_CONSTRUCTOR_NEED_OPTIONS,message:"".concat(rt,".tim")});this.list=new Map,this.tim=t.tim,this._initializeOptions(t)}return s(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){ee(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(W.debug("revoke message",e,t,n),this.list.has(e)){var o,r=E(this.list.get(e));try{for(r.s();!(o=r.n()).done;){var i=y(o.value,2)[1];if(i.sequence===t&&!i.isRevoked&&(te(n)||i.random===n))return i.isRevoked=!0,i}}catch(e){r.e(e)}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=E(this.list.get(e));try{for(r.s();!(o=r.n()).done;){var i=y(o.value,2)[1];i.time<=t&&!i.isPeerRead&&"out"===i.flow&&(i.isPeerRead=!0,n.push(i))}}catch(e){r.e(e)}finally{r.f()}W.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)?I(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}(),Ri=function(){function e(t){r(this,e),this.tim=t}return s(e,[{key:"setMessageRead",value:function(e){var t=e.conversationID,o=e.messageID,r=this.tim.conversationController.getLocalConversation(t);if(W.log("ReadReportHandler.setMessageRead conversationID=".concat(t," unreadCount=").concat(r?r.unreadCount:0)),!r||0===r.unreadCount)return Nn();var i=o?this.tim.messageController.getLocalMessage(t,o):null;switch(r.type){case n.CONV_C2C:return this._setC2CMessageRead({conversationID:t,lastMessageTime:i?i.time:r.lastMessage.lastTime});case n.CONV_GROUP:return this._setGroupMessageRead({conversationID:t,lastMessageSeq:i?i.sequence:r.lastMessage.lastSequence});case n.CONV_SYSTEM:return r.unreadCount=0,Nn();default:return Nn()}}},{key:"_setC2CMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageTime;W.log("ReadReportHandler._setC2CMessageRead conversationID=".concat(n," lastMessageTime=").concat(o)),J(o)||W.warn("ReadReportHandler._setC2CMessageRead 请勿修改 Conversation.lastMessage.lastTime,否则可能会导致已读上报结果不准确");var r=new Bn;return r.setMethod("setC2CMessageRead").setText("".concat(n,"-").concat(o)).setStart(),this.tim.messageController.request({name:"conversation",action:"setC2CMessageRead",param:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:n.replace("C2C",""),lastMessageTime:o,receipt:1}]}}}).then((function(){return r.setCode(0).setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(),W.log("ReadReportHandler._setC2CMessageRead ok."),t._updateIsReadAfterReadReport({conversationID:n,lastMessageTime:o}),t._updateUnreadCount(n),new An})).catch((function(e){return t.tim.netMonitor.probe().then((function(t){var n=y(t,2),o=n[0],i=n[1];r.setError(e,o,i).setEnd()})),W.log("ReadReportHandler._setC2CMessageRead failed. ".concat(le(e))),wn(e)}))}},{key:"_setGroupMessageRead",value:function(e){var t=this,n=e.conversationID,o=e.lastMessageSeq;W.log("ReadReportHandler._setGroupMessageRead conversationID=".concat(n," lastMessageSeq=").concat(o)),J(o)||W.warn("ReadReportHandler._setGroupMessageRead 请勿修改 Conversation.lastMessage.lastSequence,否则可能会导致已读上报结果不准确");var r=new Bn;return r.setMethod("setGroupMessageRead").setText("".concat(n,"-").concat(o)).setStart(),this.tim.messageController.request({name:"conversation",action:"setGroupMessageRead",param:{groupID:n.replace("GROUP",""),messageReadSeq:o}}).then((function(){return r.setCode(0).setNetworkType(t.tim.netMonitor.getNetworkType()).setEnd(),W.log("ReadReportHandler._setGroupMessageRead ok."),t._updateIsReadAfterReadReport({conversationID:n,lastMessageSeq:o}),t._updateUnreadCount(n),new An})).catch((function(e){return t.tim.netMonitor.probe().then((function(t){var n=y(t,2),o=n[0],i=n[1];r.setError(e,o,i).setEnd()})),W.log("ReadReportHandler._setGroupMessageRead failed. ".concat(le(e))),wn(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,W.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 t=this.tim,o=t.conversationController,r=t.messageController,i=o.getLocalConversation(e),s=r.getLocalMessageList(e);if(i&&0!==s.length&&!Te(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===n.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}(),Ni=function(){function e(t){var n=t.tim,o=t.messageController;r(this,e),this.tim=n,this.messageController=o,this.completedMap=new Map,this._initListener()}return s(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 W.log("GetMessageHandler.getMessageList not available in avchatroom. conversationID=".concat(n)),Nn({messageList:[],nextReqMessageID:"",isCompleted:!0});(te(r)||r>15)&&(r=15);var i=this._computeLeftCount({conversationID:n,nextReqMessageID:o});return W.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 An(t._computeResult({conversationID:n,nextReqMessageID:o,count:r,leftCount:i}))})):(W.log("GetMessageHandler.getMessageList. get messagelist from memory"),Nn(this._computeResult({conversationID:n,nextReqMessageID:o,count:r,leftCount:i})))}},{key:"setCompleted",value:function(e){W.log("GetMessageHandler.setCompleted. conversationID=".concat(e)),this.completedMap.set(e,!0)}},{key:"deleteCompletedItem",value:function(e){W.log("GetMessageHandler.deleteCompletedItem. conversationID=".concat(e)),this.completedMap.delete(e)}},{key:"_initListener",value:function(){var e=this;this.tim.innerEmitter.on(vn,(function(){e.setCompleted(n.CONV_SYSTEM)})),this.tim.innerEmitter.on(mn,(function(t){var o=t.data;e.setCompleted("".concat(n.CONV_GROUP).concat(o))}))}},{key:"_getMessageListSize",value:function(e){return this.messageController.getLocalMessageList(e).length}},{key:"_needGetHistory",value:function(e){var t=e.conversationID,o=e.leftCount,r=e.count,i=this.tim.conversationController.getLocalConversation(t),s=!!i&&i.type===n.CONV_SYSTEM,a=!!i&&i.subType===n.GRP_AVCHATROOM;return!s&&!a&&o<r&&!this.completedMap.has(t)}},{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 W.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(){W.log("GetMessageHandler.reset"),this.completedMap.clear()}}]),e}(),wi=function e(t){r(this,e),this.value=t,this.next=null},Oi=function(){function e(t){r(this,e),this.MAX_LENGTH=t,this.pTail=null,this.pNodeToDel=null,this.map=new Map,W.log("SinglyLinkedList init MAX_LENGTH=".concat(this.MAX_LENGTH))}return s(e,[{key:"pushIn",value:function(e){var t=new wi(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}(),Li=function(){function e(t){r(this,e),this.tim=t}return s(e,[{key:"upload",value:function(e){switch(e.type){case n.MSG_IMAGE:return this._uploadImage(e);case n.MSG_FILE:return this._uploadFile(e);case n.MSG_AUDIO:return this._uploadAudio(e);case n.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),oe(i.onProgress))try{i.onProgress(e)}catch(e){return wn(new nt({code:ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(st)}))}}}).then((function(e){var t,n=e.location,o=e.fileType,i=e.fileSize,s=ye(n);return r.updateImageFormat(o),r.updateImageInfoArray({size:i,url:s}),t=r._imageMemoryURL,O?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})}})})):G&&9===U?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}))})).then((function(t){var n=t.width,o=t.height;return r.updateImageInfoArray({width:n,height:o}),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),oe(i.onProgress))try{i.onProgress(e)}catch(e){return wn(new nt({code:ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(st)}))}}}).then((function(t){var n=t.location,o=ye(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),oe(i.onProgress))try{i.onProgress(e)}catch(e){return wn(new nt({code:ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(st)}))}}}).then((function(t){var n=t.location,o=ye(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),oe(i.onProgress))try{i.onProgress(e)}catch(e){return wn(new nt({code:ot.MESSAGE_ONPROGRESS_FUNCTION_ERROR,message:"".concat(st)}))}}}).then((function(t){var n=ye(t.location);return r.updateVideoUrl(n),e}))}}]),e}(),bi=function(t){l(i,t);var o=v(i);function i(e){var t;return r(this,i),(t=o.call(this,e))._initializeMembers(),t._initializeListener(),t._initialzeHandlers(),t.messageOptionMap=new Map,t}return s(i,[{key:"_initializeMembers",value:function(){this.messagesList=new Ai({tim:this.tim}),this.currentMessageKey={},this.singlyLinkedList=new Oi(100),this._peerReadTimeMap=new Map}},{key:"_initialzeHandlers",value:function(){this.readReportHandler=new Ri(this.tim,this),this.getMessageHandler=new Ni({messageController:this,tim:this.tim}),this.uploadFileHandler=new Li(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(Wt,this._onReceiveC2CMessage,this),e.on(bt,this._onSyncMessagesProcessing,this),e.on(Pt,this._onSyncMessagesFinished,this),e.on(zt,this._onReceiveGroupMessage,this),e.on(Jt,this._onReceiveGroupTips,this),e.on(Xt,this._onReceiveSystemNotice,this),e.on(en,this._onReceiveGroupMessageRevokedNotice,this),e.on(tn,this._onReceiveC2CMessageRevokedNotice,this),e.on(nn,this._onC2CMessageReadReceipt,this),e.on(fn,this._clearConversationMessages,this)}},{key:"_guardForAVChatRoom",value:function(e){if(e.conversationType===n.CONV_GROUP){var t=this.tim.groupController,o=e.to;return t.hasLocalGroup(o)?Promise.resolve():t.getGroupProfile({groupID:o}).then((function(t){var r=t.data.group.type;return W.log("MessageController._guardForAVChatRoom. groupID=".concat(o," type=").concat(r)),r===n.GRP_AVCHATROOM?(W.warn("MessageController._guardForAVChatRoom sendMessage not allowed. userId=".concat(e.from," 未加入群 groupID=").concat(o,"。发消息前先使用 joinGroup 接口申请加群,详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#joinGroup")),wn(new nt({code:ot.MESSAGE_SEND_FAIL,message:"消息发送失败",data:{message:e}}))):Promise.resolve()}))}return Promise.resolve()}},{key:"sendMessageInstance",value:function(e,t){var o,r=this,i=null;switch(e.conversationType){case n.CONV_C2C:i=this._handleOnSendC2CMessageSuccess.bind(this);break;case n.CONV_GROUP:i=this._handleOnSendGroupMessageSuccess.bind(this);break;default:return wn(new nt({code:ot.MESSAGE_SEND_INVALID_CONVERSATION_TYPE,message:'Message.conversationType 只能为 "C2C" 或 "GROUP"'}))}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===n.CONV_C2C?i=r._createC2CMessagePack(e,t):e.conversationType===n.CONV_GROUP&&(i=r._createGroupMessagePack(e,t)),r.request(i)):wn({code:ot.MESSAGE_FILE_URL_IS_EMPTY,message:"缺少必要的参数文件 URL"})})).then((function(t){return r._addSendMessageSuccessCount(e,o),e.conversationType===n.CONV_GROUP&&(e.sequence=t.data.sequence,e.time=t.data.time,e.generateMessageID(r.tim.context.identifier)),r.messagesList.pushIn(e),i(e,t.data),r.messageOptionMap.delete(e.messageID),r.emitInnerEvent(Gt,{eventDataList:[{conversationID:e.conversationID,unreadCount:0,type:e.conversationType,subType:e.conversationSubType,lastMessage:e}]}),new An({message:e})})).catch((function(t){e.status=Ue;var n=new Bn;return n.setMethod("sendMessage").setMessageType(e.type).setText("".concat(r._generateTjgID(e),"-").concat(e.type,"-").concat(e.from,"-").concat(e.to)).setStart(),r.probeNetwork().then((function(e){var o=y(e,2),r=o[0],i=o[1];n.setError(t,r,i).setEnd()})),W.error("MessageController.sendMessageInstance error:",t),wn(new nt({code:t&&t.code?t.code:ot.MESSAGE_SEND_FAIL,message:t&&t.message?t.message:"消息发送失败",data:{message:e}}))}))}))}},{key:"_getSendMessageSpecifiedKey",value:function(e){if(e.conversationType===n.CONV_C2C)return Gn;if(e.conversationType===n.CONV_GROUP){var t=this.tim.groupController.getLocalGroupProfile(e.to);if(!t)return;var o=t.type;if(function(e){return e===n.GRP_WORK}(o))return Un;if(Me(o))return xn;if(Ce(o))return qn;if(Ee(o))return Fn}}},{key:"_addSendMessageTotalCount",value:function(e){var t=this.tim.sumStatController;t.addTotalCount(Pn);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(Pn),n.addCost(Pn,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=Pe,this.sendMessageInstance(e)}},{key:"_isFileLikeMessage",value:function(e){return[n.MSG_IMAGE,n.MSG_FILE,n.MSG_AUDIO,n.MSG_VIDEO].indexOf(e.type)>=0}},{key:"_resendBinaryTypeMessage",value:function(){}},{key:"_canIUseOnlineOnlyFlag",value:function(e){var t=this.tim.groupController.getJoinedAVChatRoom();return!t||!t.includes(e.to)||e.conversationType!==n.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=Ge,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=Ge}},{key:"_onReceiveC2CMessage",value:function(t){W.debug("MessageController._onReceiveC2CMessage nums=".concat(t.data.length));var o=Date.now(),r=this._newC2CMessageStoredAndSummary({notifiesList:t.data,type:n.CONV_C2C,C2CRemainingUnreadList:t.C2CRemainingUnreadList}),i=r.eventDataList,s=r.result;if(i.length>0&&this.emitInnerEvent(qt,{eventDataList:i,result:s}),s.length>0){var a=this.tim.sumStatController;a.addTotalCount(Vn),a.addSuccessCount(Vn),a.addCost(Vn,Date.now()-o),this.emitOuterEvent(e.MESSAGE_RECEIVED,s)}}},{key:"_onReceiveGroupMessage",value:function(t){W.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(Ft,{eventDataList:r,result:i,isGroupTip:!1}),i.length>0){var s=this.tim.sumStatController;s.addTotalCount(Vn),s.addSuccessCount(Vn),s.addCost(Vn,Date.now()-n),this.emitOuterEvent(e.MESSAGE_RECEIVED,i)}}},{key:"_onReceiveGroupTips",value:function(t){var n=Date.now(),o=t.data;W.debug("MessageController._onReceiveGroupTips nums=".concat(o.length));var r=this.newGroupTipsStoredAndSummary(o),i=r.eventDataList,s=r.result;if(i.length>0&&this.emitInnerEvent(Ft,{eventDataList:i,result:s,isGroupTip:!0}),s.length>0){var a=this.tim.sumStatController;a.addTotalCount(Vn),a.addSuccessCount(Vn),a.addCost(Vn,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;W.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(Vt,{eventDataList:a,result:u,type:i}),u.length>0&&"poll"===i){var c=this.tim.sumStatController;c.addTotalCount(Vn),c.addSuccessCount(Vn),c.addCost(Vn,Date.now()-n),this.emitOuterEvent(e.MESSAGE_RECEIVED,u)}}},{key:"_onReceiveGroupMessageRevokedNotice",value:function(t){var n=this;W.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(Kt,o),this.emitOuterEvent(e.MESSAGE_REVOKED,o))}},{key:"_onReceiveC2CMessageRevokedNotice",value:function(t){var n=this;W.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(Kt,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;W.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(t,o){if(t.startsWith(n.CONV_C2C)&&o>0){var r=this.messagesList.updateMessageIsPeerReadProperty(t,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 Bn;return n.setMethod("getPeerReadTime").setStart(),W.log("MessageController.getPeerReadTime userIDList:".concat(e)),this.request({name:"c2cPeerReadTime",action:"get",param:{userIDList:e}}).then((function(o){var r=o.data.peerReadTimeList;W.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.setCode(0).setNetworkType(t.getNetworkType()).setText(i).setEnd()})).catch((function(e){t.probeNetwork().then((function(t){var o=y(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),W.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 t=e.notifiesList,o=e.type,r=e.C2CRemainingUnreadList,i=e.isFromSync,s=null,a=[],u=[],c={},l=this.tim.bigDataHallwayController,p=0,h=t.length;p<h;p++){var d=t[p];d.currentUser=this.tim.context.identifier,d.conversationType=o,d.isSystemMessage=!!d.isSystemMessage,s=new yt(d),d.elements=l.parseElements(d.elements,d.from),s.setElement(d.elements),(i||this._pushIntoNoticeResult(u,s))&&(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(ee(r))for(var f=function(e,t){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:n.CONV_C2C,lastMsgTime:r[e].lastMsgTime})},g=0,m=r.length;g<m;g++)f(g);return{eventDataList:a,result:u}}},{key:"newGroupMessageStoredAndSummary",value:function(e){var t=null,o=[],r={},i=[],s=n.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];l.currentUser=this.tim.context.identifier,l.conversationType=s,l.isSystemMessage=!!l.isSystemMessage,t=new yt(l),l.elements=a.parseElements(l.elements,l.from),t.setElement(l.elements),this._isMessageFromAVChatroom(t)||this._pushIntoNoticeResult(i,t)&&(void 0===r[t.conversationID]?r[t.conversationID]=o.push({conversationID:t.conversationID,unreadCount:"out"===t.flow?0:1,type:t.conversationType,subType:t.conversationSubType,lastMessage:t})-1:(o[r[t.conversationID]].type=t.conversationType,o[r[t.conversationID]].subType=t.conversationSubType,o[r[t.conversationID]].lastMessage=t,"in"===t.flow&&o[r[t.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 t=null,o=[],r=[],i={},s=0,a=e.length;s<a;s++){var u=e[s];u.currentUser=this.tim.context.identifier,u.conversationType=n.CONV_GROUP,(t=new yt(u)).setElement({type:n.MSG_GRP_TIP,content:c({},u.elements,{groupProfile:u.groupProfile})}),t.isSystemMessage=!1,this._isMessageFromAVChatroom(t)||this._pushIntoNoticeResult(r,t)&&(void 0===i[t.conversationID]?i[t.conversationID]=o.push({conversationID:t.conversationID,unreadCount:"out"===t.flow?0:1,type:t.conversationType,subType:t.conversationSubType,lastMessage:t})-1:(o[i[t.conversationID]].type=t.conversationType,o[i[t.conversationID]].subType=t.conversationSubType,o[i[t.conversationID]].lastMessage=t,"in"===t.flow&&o[i[t.conversationID]].unreadCount++))}return{eventDataList:o,result:r}}},{key:"newSystemNoticeStoredAndSummary",value:function(e){var t=e.notifiesList,o=e.type,r=null,i=t.length,s=0,a=[],u={conversationID:n.CONV_SYSTEM,unreadCount:0,type:n.CONV_SYSTEM,subType:null,lastMessage:null};for(s=0;s<i;s++){var l=t[s];15!==l.elements.operationType&&(l.currentUser=this.tim.context.identifier,l.conversationType=n.CONV_SYSTEM,l.conversationID=n.CONV_SYSTEM,(r=new yt(l)).setElement({type:n.MSG_GRP_SYS_NOTICE,content:c({},l.elements,{groupProfile:l.groupProfile})}),r.isSystemMessage=!0,(1===r.sequence&&1===r.random||2===r.sequence&&2===r.random)&&(r.sequence=de(),r.random=de(),r.generateMessageID(l.currentUser),W.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 t=this._newC2CMessageStoredAndSummary({notifiesList:e.data,type:n.CONV_C2C,isFromSync:!0,C2CRemainingUnreadList:e.C2CRemainingUnreadList}),o=t.eventDataList,r=t.result;this.emitInnerEvent(Ut,{eventDataList:o,result:r})}},{key:"_onSyncMessagesFinished",value:function(e){this.triggerReady();var t=this._newC2CMessageStoredAndSummary({notifiesList:e.data.messageList,type:n.CONV_C2C,isFromSync:!0,C2CRemainingUnreadList:e.data.C2CRemainingUnreadList}),o=t.eventDataList,r=t.result;this.emitInnerEvent(xt,{eventDataList:o,result:r})}},{key:"getHistoryMessages",value:function(e){if(e.conversationID===n.CONV_SYSTEM)return Nn();!e.count&&(e.count=15),e.count>20&&(e.count=20);var t=this.messagesList.getLocalOldestMessageByConversationID(e.conversationID);t||((t={}).time=0,t.sequence=0,0===e.conversationID.indexOf(n.CONV_C2C)?(t.to=e.conversationID.replace(n.CONV_C2C,""),t.conversationType=n.CONV_C2C):0===e.conversationID.indexOf(n.CONV_GROUP)&&(t.to=e.conversationID.replace(n.CONV_GROUP,""),t.conversationType=n.CONV_GROUP));var o="";switch(t.conversationType){case n.CONV_C2C:return o=e.conversationID.replace(n.CONV_C2C,""),this.getC2CRoamMessages({conversationID:e.conversationID,peerAccount:o,count:e.count,lastMessageTime:void 0===this.currentMessageKey[e.conversationID]?0:t.time});case n.CONV_GROUP:return this.getGroupRoamMessages({conversationID:e.conversationID,groupID:t.to,count:e.count,sequence:t.sequence-1});default:return Nn()}}},{key:"getC2CRoamMessages",value:function(e){var t=this,o=e.conversationID,r=void 0!==this.currentMessageKey[o]?this.currentMessageKey[o]:"";W.log("MessageController.getC2CRoamMessages toAccount=".concat(e.peerAccount," count=").concat(e.count||15," lastMessageTime=").concat(e.lastMessageTime||0," messageKey=").concat(r));var i=new Bn;return i.setMethod("getC2CRoamingMessages").setStart(),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;te(c)?W.log("MessageController.getC2CRoamMessages ok. complete=".concat(u," but messageList is undefined!")):W.log("MessageController.getC2CRoamMessages ok. complete=".concat(u," nums=").concat(c.length)),i.setCode(0).setNetworkType(t.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&&t.getMessageHandler.setCompleted(o);var l=t._roamMessageStore(c,n.CONV_C2C,o);t.readReportHandler.updateIsRead(o),t.currentMessageKey[o]=s.data.messageKey;var p=t._peerReadTimeMap.get(o);if(W.log("MessageController.getC2CRoamMessages update isPeerRead property. conversationID=".concat(o," peerReadTime=").concat(p)),p)t._updateMessageIsPeerReadProperty(o,p);else{var h=o.replace(n.CONV_C2C,"");t.getPeerReadTime([h]).then((function(){t._updateMessageIsPeerReadProperty(o,t._peerReadTimeMap.get(o))}))}return l})).catch((function(n){return t.probeNetwork().then((function(t){var o=y(t,2),s=o[0],a=o[1];i.setError(n,s,a).setText("".concat(e.peerAccount,"-").concat(e.count||15,"-").concat(e.lastMessageTime||0,"-").concat(r)).setEnd()})),W.warn("MessageController.getC2CRoamMessages failed. ".concat(n)),wn(n)}))}},{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 t=this,o=new Bn,r=0;return this._computeLastSequence(e).then((function(n){return r=n,W.log("MessageController.getGroupRoamMessages groupID=".concat(e.groupID," lastSequence=").concat(r)),o.setMethod("getGroupRoamingMessages").setStart(),t.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;te(a)?W.log("MessageController.getGroupRoamMessages ok. complete=".concat(u," but messageList is undefined!")):W.log("MessageController.getGroupRoamMessages ok. complete=".concat(u," nums=").concat(a.length)),o.setCode(0).setNetworkType(t.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 t.getMessageHandler.setCompleted(c),[];var l=t._roamMessageStore(a,n.CONV_GROUP,c);return t.readReportHandler.updateIsRead(c),t._patchConversationLastMessage(c),l})).catch((function(n){return t.probeNetwork().then((function(t){var i=y(t,2),s=i[0],a=i[1];o.setError(n,s,a).setText("".concat(e.groupID,"-").concat(r)).setEnd()})),W.warn("MessageController.getGroupRoamMessages failed. ".concat(n)),wn(n)}))}},{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];W.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]:[],t=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,l=t===n.CONV_GROUP,p=this.tim.bigDataHallwayController,h=function(){s=l?e.length-1:0,a=l?0:e.length},d=function(){l?--s:++s},f=function(){return l?s>=a:s<a};for(h();f();d())if(l&&1===e[s].sequence&&this.getMessageHandler.setCompleted(o),1!==e[s].isPlaceMessage)if((r=new yt(e[s])).to=e[s].to,r.isSystemMessage=!!e[s].isSystemMessage,r.conversationType=t,e[s].event===He.JSON.TYPE.GROUP.TIP?u={type:n.MSG_GRP_TIP,content:c({},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 g=new Bn;g.setMethod(Yn).setText("from:".concat(r.from," to:").concat(r.to," sequence:").concat(r.sequence," event:").concat(e[s].event)).setStart(),g.setCode(0).setNetworkType(this.getNetworkType()).setEnd()}else r.setElement(u),r.reInitialize(this.tim.context.identifier),i.push(r);return this.messagesList.unshift(i),h=d=f=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 yt&&this.messagesList.remove(e)}},{key:"revokeMessage",value:function(e){var t,o=this;e.conversationType===n.CONV_C2C?t={name:"c2cMessageWillBeRevoked",action:"create",param:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}}:e.conversationType===n.CONV_GROUP&&(t={name:"groupMessageWillBeRevoked",action:"create",param:{to:e.to,msgSeqList:[{msgSeq:e.sequence}]}});var r=new Bn;return r.setMethod("revokeMessage").setMessageType(e.type).setText("".concat(this._generateTjgID(e),"-").concat(e.type,"-").concat(e.from,"-").concat(e.to)).setStart(),this.request(t).then((function(t){var n=t.data.recallRetList;if(!ke(n)&&0!==n[0].retCode){var i=new nt({code:n[0].retCode,message:tt[n[0].retCode]||"消息撤回失败",data:{message:e}});return r.setCode(i.code).setMessage(i.message).setEnd(),wn(i)}return W.info("MessageController.revokeMessage ok. ID=".concat(e.ID)),e.isRevoked=!0,r.setCode(0).setEnd(),o.emitInnerEvent(Kt,[e]),new An({message:e})})).catch((function(t){o.probeNetwork().then((function(e){var n=y(e,2),o=n[0],i=n[1];r.setError(t,o,i).setEnd()}));var n=new nt({code:t&&t.code?t.code:ot.MESSAGE_REVOKE_FAIL,message:t&&t.message?t.message:"消息撤回失败",data:{message:e}});return W.warn("MessageController.revokeMessage failed. ID=".concat(e.ID," code=").concat(n.code," message=").concat(n.message)),wn(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 yt(e),n="string"==typeof e.payload?e.payload:e.payload.text,o=new Ke({text:n});return t.setElement(o),t}},{key:"createCustomMessage",value:function(e){e.currentUser=this.tim.context.identifier;var t=new yt(e),n=new gt({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 yt(e);if(O){var n=e.payload.file;if(z(n))return void W.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&&z(e.payload.file)){var i=e.payload.file;e.payload.file={files:[i]}}var s=new We({imageFormat:He.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(!O){if(w&&z(e.payload.file)){var t=e.payload.file;e.payload.file={files:[t]}}e.currentUser=this.tim.context.identifier;var n=new yt(e),o=new ft({uuid:this._generateUUID(),file:e.payload.file});return n.setElement(o),this.messageOptionMap.set(n.messageID,e),n}W.warn("微信小程序目前不支持选择文件, createFileMessage 接口不可用!")}},{key:"createAudioMessage",value:function(e){if(O){var t=e.payload.file;if(O){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 yt(e),r=new Je({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}W.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(O){if(z(e.payload.file))return void W.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(z(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 yt(e),s=new mt({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 yt(e),n=new ze(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+=fe[Math.floor(Math.random()*ge)];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))}}]),i}(Sn),Pi=function(){function e(t){r(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 s(e,[{key:"_initMember",value:function(e){this.updateMember(e)}},{key:"updateMember",value:function(e){var t=[null,void 0,"",0,NaN];e.memberCustomField&&Ie(this.memberCustomField,e.memberCustomField),ce(this,e,["memberCustomField"],t)}},{key:"updateRole",value:function(e){["Owner","Admin","Member"].indexOf(e)<0||(this.role=e)}},{key:"updateMuteUntil",value:function(e){te(e)||(this.muteUntil=Math.floor((Date.now()+1e3*e)/1e3))}},{key:"updateNameCard",value:function(e){te(e)||(this.nameCard=e)}},{key:"updateMemberCustomField",value:function(e){e&&Ie(this.memberCustomField,e)}}]),e}(),Gi=function(){function e(t){r(this,e),this.tim=t.tim,this.groupController=t.groupController,this._initListeners()}return s(e,[{key:"_initListeners",value:function(){this.tim.innerEmitter.on(Ft,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:W.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&&J(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&&J(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&&J(n)&&(r.memberNum=n),this.groupController.deleteLocalGroupMembers(o,e.payload.userIDList)}},{key:"_onMemberSetAdmin",value:function(e){var t=this,o=e.payload.groupProfile.groupID;e.payload.userIDList.forEach((function(e){var r=t.groupController.getLocalGroupMemberInfo(o,e);r&&r.updateRole(n.GRP_MBR_ROLE_ADMIN)}))}},{key:"_onMemberCancelledAdmin",value:function(e){var t=this,o=e.payload.groupProfile.groupID;e.payload.userIDList.forEach((function(e){var r=t.groupController.getLocalGroupMemberInfo(o,e);r&&r.updateRole(n.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,t){var o=e.groupID,r=this.groupController.getLocalGroupProfile(o),i=this.tim.context.identifier;if(i===t.ownerID){r.updateGroup({selfInfo:{role:n.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(n.GRP_MBR_ROLE_OWNER),u&&u.updateRole(n.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}(),Ui=function(){function t(e){r(this,t),this.groupController=e.groupController,this.tim=e.tim,this.pendencyMap=new Map,this._initLiceners()}return s(t,[{key:"_initLiceners",value:function(){this.tim.innerEmitter.on(Vt,this._onReceivedGroupSystemNotice,this),this.tim.innerEmitter.on(Pt,this._clearGroupSystemNotice,this)}},{key:"_clearGroupSystemNotice",value:function(){var e=this;this.getPendencyList().then((function(t){t.forEach((function(t){e.pendencyMap.set("".concat(t.from,"_").concat(t.groupID,"_").concat(t.to),t)}));var o=e.tim.messageController.getLocalMessageList(n.CONV_SYSTEM),r=[];o.forEach((function(t){var n=t.payload,o=n.operatorID,i=n.operationType,s=n.groupProfile;if(1===i){var a="".concat(o,"_").concat(s.groupID,"_").concat(s.to),u=e.pendencyMap.get(a);u&&J(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(I(o),I(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:255})}}))}},{key:"_onApplyGroupRequest",value:function(t){this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:1})}},{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:2})}},{key:"_onApplyGroupRequestRefused",value:function(t){this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:3})}},{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:4})}},{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:5})}},{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:7})}},{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:8})}},{key:"_onSetManager",value:function(t){var o=t.payload.groupProfile,r=o.to,i=o.groupID,s=this.groupController.getLocalGroupMemberInfo(i,r);s&&s.updateRole(n.GRP_MBR_ROLE_ADMIN),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:9})}},{key:"_onDeleteManager",value:function(t){var o=t.payload.groupProfile,r=o.to,i=o.groupID,s=this.groupController.getLocalGroupMemberInfo(i,r);s&&s.updateRole(n.GRP_MBR_ROLE_MEMBER),this.groupController.emitOuterEvent(e.GROUP_SYSTEM_NOTICE_RECEIVED,{message:t,type:10})}},{key:"reset",value:function(){this.pendencyMap.clear()}}]),t}(),xi={3:!0,4:!0,5:!0,6:!0},qi=function(){function t(e){var n=e.tim,o=e.groupController;r(this,t),this.tim=n,this.groupController=o,this.sequencesLinkedList=new Oi(100),this.receivedMessageCount=0,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._joinedGroupMap=new Map,this._reportMessageStackedCount=0}return s(t,[{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?I(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),W.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(),W.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()?Nn({status:Ne,group:o}):Nn({status:Ne})}))}},{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(te(o))return wn(new nt({code:ot.CANNOT_JOIN_NON_AVCHATROOM_WITHOUT_LOGIN,message:"非 AVChatRoom 类型的群组不允许匿名加群,请先登录后再加群"}));W.log("AVChatRoomHandler.joinWithoutAuth ok. groupID:",e.groupID),t.groupController.emitInnerEvent(_n),t.groupController.emitInnerEvent(mn,e.groupID);var r=new Ei({groupID:e.groupID});return t.startRunLoop({group:r,longPollingKey:o}),new An({status:Ne})})).catch((function(t){return W.error("AVChatRoomHandler.joinWithoutAuth error:".concat(le(t),". groupID:").concat(e.groupID)),wn(t)}))}},{key:"_precheck",value:function(){if(this.tim.context.unlimitedAVChatRoom)return Promise.resolve();if(!this.hasJoinedAVChatRoom())return Promise.resolve();var e=y(this._joinedGroupMap.entries().next().value,2),t=e[0],o=e[1];if(this.groupController.isLoggedIn()){if(o.selfInfo.role!==n.GRP_MBR_ROLE_OWNER&&o.ownerID!==this.tim.loginInfo.identifier)return this.groupController.quitGroup(t);this.groupController.deleteLocalGroupAndConversation(t)}else this.groupController.deleteLocalGroupAndConversation(t);return this.reset(t),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(bn)}},{key:"_handleSuccess",value:function(e,t){this.tim.sumStatController.addSuccessCount(bn),this.tim.sumStatController.addCost(bn,t.data.timecost);var n=t.data,o=n.errorCode,r=n.errorInfo,i=n.key,s=n.nextSeq,a=n.rspMsgList;if(o!==Oe){var u=this._pollingRequestInfoMap.get(e),c=new Bn;c.setMethod(Wn).setStart();var 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 X(i)&&J(s)&&this._pollingRequestInfoMap.set(e,{key:i,startSeq:s}),ee(a)&&a.length>0&&(a.forEach((function(e){e.to=e.groupID})),this._dispatchNotice(a));this.groupController.emitInnerEvent(rn)}},{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;W.log("AVChatRoomHandler._handleFailure request timed out. url=".concat(t," data=").concat(n))}else W.log("AVChatRoomHandler._handleFailure request timed out");else W.log("AVChatRoomHandler._handleFailure request failed due to network error");this.groupController.emitInnerEvent(on)}},{key:"_dispatchNotice",value:function(t){if(ee(t)&&0!==t.length){var o=Date.now(),r=null,i=[],s=[],a=t.length;a>1&&t.sort((function(e,t){return e.sequence-t.sequence}));for(var u=0;u<a;u++)if(xi[t[u].event]){if(this.receivedMessageCount+=1,r=this.packMessage(t[u],t[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===n.CONV_SYSTEM&&s.push(r),i.push(r))}}else W.warn("AVChatRoomHandler._dispatchMessage 未处理的 event 类型:",t[u].event);if(s.length>0&&this.groupController.emitInnerEvent(Vt,{result:s,eventDataList:[],type:"poll"}),0!==i.length){var h=this.packConversationOption(i);h.length>0&&this.groupController.emitInnerEvent(Ft,{eventDataList:h,type:"poll"}),W.debug("AVChatRoomHandler._dispatchNotice nums=".concat(i.length));var d=this.tim.sumStatController;d.addTotalCount(Kn),d.addSuccessCount(Kn),d.addCost(Kn,Date.now()-o),this._checkMessageStacked(i),this.groupController.emitOuterEvent(e.MESSAGE_RECEIVED,i)}}}},{key:"_checkMessageStacked",value:function(e){var t=e.length;if(t>=100&&(W.warn("AVChatRoomHandler.checkMessageStacked 直播群消息堆积数:".concat(e.length,'!可能会导致微信小程序渲染时遇到 "Dom limit exceeded" 的错误,建议接入侧此时只渲染最近的10条消息')),this._reportMessageStackedCount<5)){var n=new Bn;n.setMethod("messageStacked").setStart(),n.setCode(0).setNetworkType(this.groupController.getNetworkType()).setText("nums=".concat(t," groupID=").concat(I(this._joinedGroupMap.keys()))).setEnd(),this._reportMessageStackedCount+=1}}},{key:"_isMessageSentByCurrentInstance",value:function(e){return!!this.tim.messageController.isMessageSentByCurrentInstance(e)}},{key:"packMessage",value:function(e,t){e.currentUser=this.tim.context.identifier,e.conversationType=5===t?n.CONV_SYSTEM:n.CONV_GROUP,e.isSystemMessage=!!e.isSystemMessage;var o=new yt(e),r=this.packElements(e,t);return o.setElement(r),o}},{key:"packElements",value:function(e,t){return 4===t||6===t?{type:n.MSG_GRP_TIP,content:c({},e.elements,{groupProfile:e.groupProfile})}:5===t?{type:n.MSG_GRP_SYS_NOTICE,content:c({},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 I(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 Bn;t.forEach((function(t){n.setMethod("joinAVChatRoomSilently").setStart(),e.groupController.joinGroup({groupID:t}).then((function(o){W.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){W.warn("AVChatRoomHandler.joinAVChatRoomSilently silently join group failed:".concat(le(o))),n.setMessage("".concat(t,"-").concat(JSON.stringify(o))).setCode(o.code).setNetworkType(e.groupController.getNetworkType()).setEnd(!0)}))}))}}},{key:"reset",value:function(e){if(0!==this._pollingInstanceMap.size){if(e)W.log("AVChatRoomHandler.reset groupID=".concat(e)),this.stop(e),this._pollingInstanceMap.delete(e),this._joinedGroupMap.delete(e),this._pollingRequestInfoMap.delete(e);else{W.log("AVChatRoomHandler.reset all");var t,n=E(this._pollingInstanceMap.keys());try{for(n.s();!(t=n.n()).done;){var o=t.value;this.stop(o)}}catch(e){n.e(e)}finally{n.f()}this._pollingInstanceMap.clear(),this._joinedGroupMap.clear(),this._pollingRequestInfoMap.clear()}this.sequencesLinkedList.reset(),this.receivedMessageCount=0,this._reportMessageStackedCount=0,this._deleteAVChatRoomID(e)}}}]),t}(),Fi=function(t){l(i,t);var o=v(i);function i(e){var t;return r(this,i),(t=o.call(this,e)).groupMap=new Map,t.groupMemberListMap=new Map,t.groupNoticeHandler=new Ui({tim:e,groupController:m(t)}),t.groupTipsHandler=new Gi({tim:e,groupController:m(t)}),t.AVChatRoomHandler=new qi({tim:e,groupController:m(t)}),t._initListeners(),t}return s(i,[{key:"createGroup",value:function(e){var t=this;if(!["Public","Private","ChatRoom","AVChatRoom"].includes(e.type)){var o=new nt({code:ot.ILLEGAL_GROUP_TYPE,message:"非法的群类型,请检查传入参数"});return wn(o)}Ee(e.type)&&!te(e.memberList)&&e.memberList.length>0&&(W.warn("GroupController.createGroup 创建AVChatRoom时不能添加群成员,自动忽略该字段"),e.memberList=void 0),Me(e.type)||te(e.joinOption)||(W.warn("GroupController.createGroup 创建Work/Meeting/AVChatRoom群时不能设置字段:joinOption,自动忽略该字段"),e.joinOption=void 0);var r=new Bn;return r.setMethod("createGroup").setStart(),W.log("GroupController.createGroup."),this.request({name:"group",action:"create",param:e}).then((function(o){if(r.setCode(0).setNetworkType(t.getNetworkType()).setText("groupType=".concat(e.type," groupID=").concat(o.data.groupID)).setEnd(),W.log("GroupController.createGroup ok. groupID:",o.data.groupID),e.type===n.GRP_AVCHATROOM)return t.getGroupProfile({groupID:o.data.groupID});t.updateGroupMap([c({},e,{groupID:o.data.groupID})]);var i=t.tim.createCustomMessage({to:o.data.groupID,conversationType:n.CONV_GROUP,payload:{data:"group_create",extension:"".concat(t.tim.context.identifier,"创建群组")}});return t.tim.sendMessage(i),t.emitGroupListUpdate(),t.getGroupProfile({groupID:o.data.groupID})})).then((function(e){var t=e.data.group;return t.selfInfo.messageRemindType=n.MSG_REMIND_ACPT_AND_NOTE,t.selfInfo.role=n.GRP_MBR_ROLE_OWNER,e})).catch((function(n){return r.setText("groupType=".concat(e.type)),t.probeNetwork().then((function(e){var t=y(e,2),o=t[0],i=t[1];r.setError(n,o,i).setEnd()})),W.error("GroupController.createGroup error:",n),wn(n)}))}},{key:"joinGroup",value:function(e){var t=this,o=e.groupID;if(e.type===n.GRP_WORK){var r=new nt({code:ot.CANNOT_JOIN_WORK,message:"不能加入 Work 类型的群组"});return wn(r)}if(this.hasLocalGroup(o)){if(!this.isLoggedIn())return Nn({status:n.JOIN_STATUS_ALREADY_IN_GROUP});var i=new Bn;return i.setMethod($n).setStart(),this.getGroupProfile({groupID:o}).then((function(e){return i.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(o," joinedStatus=").concat(n.JOIN_STATUS_ALREADY_IN_GROUP)).setEnd(),Nn({status:n.JOIN_STATUS_ALREADY_IN_GROUP})})).catch((function(n){return i.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(o," unjoined")).setEnd(),W.warn("GroupController.joinGroup ".concat(o," was unjoined, now join!")),t.groupMap.delete(o),t.applyJoinGroup(e)}))}return W.log("GroupController.joinGroup. groupID:",o),this.isLoggedIn()?this.applyJoinGroup(e):this.AVChatRoomHandler.joinWithoutAuth(e)}},{key:"quitGroup",value:function(e){var t=this;W.log("GroupController.quitGroup. groupID:",e);var n=this.AVChatRoomHandler.checkJoinedAVChatRoomByID(e);if(n&&!this.isLoggedIn())return W.log("GroupController.quitGroup anonymously ok. groupID:",e),this.deleteLocalGroupAndConversation(e),this.AVChatRoomHandler.reset(e),Nn({groupID:e});var o=new Bn;return o.setMethod("quitGroup").setStart(),this.request({name:"group",action:"quitGroup",param:{groupID:e}}).then((function(){return o.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(e)).setEnd(),W.log("GroupController.quitGroup ok. groupID:",e),n&&t.AVChatRoomHandler.reset(e),t.deleteLocalGroupAndConversation(e),new An({groupID:e})})).catch((function(n){return o.setText("groupID=".concat(e)),t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];o.setError(n,r,i).setEnd()})),W.error("GroupController.quitGroup error. error:".concat(le(n)," groupID:").concat(e)),wn(n)}))}},{key:"changeGroupOwner",value:function(e){var t=this;if(this.hasLocalGroup(e.groupID)&&this.getLocalGroupProfile(e.groupID).type===n.GRP_AVCHATROOM)return wn(new nt({code:ot.CANNOT_CHANGE_OWNER_IN_AVCHATROOM,message:"AVChatRoom 类型的群组不能转让群主"}));if(e.newOwnerID===this.tim.loginInfo.identifier)return wn(new nt({code:ot.CANNOT_CHANGE_OWNER_TO_SELF,message:"不能把群主转让给自己"}));var o=new Bn;return o.setMethod("changeGroupOwner").setStart(),W.log("GroupController.changeGroupOwner. groupID:",e.groupID),this.request({name:"group",action:"changeGroupOwner",param:e}).then((function(){o.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(),W.log("GroupController.changeGroupOwner ok. groupID:",e.groupID);var n=e.groupID,r=e.newOwnerID;t.groupMap.get(n).ownerID=r;var i=t.groupMemberListMap.get(n);if(i instanceof Map){var s=i.get(t.tim.loginInfo.identifier);te(s)||(s.updateRole("Member"),t.groupMap.get(n).selfInfo.role="Member");var a=i.get(r);te(a)||a.updateRole("Owner")}return t.emitGroupListUpdate(!0,!1),new An({group:t.groupMap.get(n)})})).catch((function(n){return o.setText("groupID=".concat(e.groupID)),t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];o.setError(n,r,i).setEnd()})),W.error("GroupController.changeGroupOwner error:".concat(le(n)," groupID:").concat(e.groupID)),wn(n)}))}},{key:"dismissGroup",value:function(e){var t=this;if(this.hasLocalGroup(e)&&this.getLocalGroupProfile(e).type===n.GRP_WORK)return wn(new nt({code:ot.CANNOT_DISMISS_WORK,message:"不能解散 Work 类型的群组"}));var o=new Bn;return o.setMethod("dismissGroup").setStart(),W.log("GroupController.dismissGroup. groupID:".concat(e)),this.request({name:"group",action:"destroyGroup",param:{groupID:e}}).then((function(){return o.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(e)).setEnd(),W.log("GroupController.dismissGroup ok. groupID:".concat(e)),t.deleteLocalGroupAndConversation(e),t.checkJoinedAVChatRoomByID(e)&&t.AVChatRoomHandler.reset(e),new An({groupID:e})})).catch((function(n){return o.setText("groupID=".concat(e)),t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];o.setError(n,r,i).setEnd()})),W.error("GroupController.dismissGroup error:".concat(le(n)," groupID:").concat(e)),wn(n)}))}},{key:"updateGroupProfile",value:function(e){var t=this;!this.hasLocalGroup(e.groupID)||Me(this.getLocalGroupProfile(e.groupID).type)||te(e.joinOption)||(W.warn("GroupController.updateGroupProfile Work/Meeting/AVChatRoom群不能设置字段:joinOption,自动忽略该字段"),e.joinOption=void 0),te(e.muteAllMembers)||(e.muteAllMembers?e.muteAllMembers="On":e.muteAllMembers="Off");var n=new Bn;return n.setMethod("updateGroupProfile").setStart(),n.setText(JSON.stringify(e)),W.log("GroupController.updateGroupProfile. groupID:",e.groupID),this.request({name:"group",action:"updateGroupProfile",param:e}).then((function(){return n.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.updateGroupProfile ok. groupID:",e.groupID),t.hasLocalGroup(e.groupID)&&(t.groupMap.get(e.groupID).updateGroup(e),t._setStorageGroupList()),new An({group:t.groupMap.get(e.groupID)})})).catch((function(o){return t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];n.setError(o,r,i).setEnd()})),W.log("GroupController.updateGroupProfile failed. error:".concat(le(o)," groupID:").concat(e.groupID)),wn(o)}))}},{key:"setGroupMemberRole",value:function(e){var t=this,o=e.groupID,r=e.userID,i=e.role,s=this.groupMap.get(o);if(s.selfInfo.role!==n.GRP_MBR_ROLE_OWNER)return wn(new nt({code:ot.NOT_OWNER,message:"你不是群主,只有群主才有权限操作"}));if([n.GRP_WORK,n.GRP_AVCHATROOM].includes(s.type))return wn(new nt({code:ot.CANNOT_SET_MEMBER_ROLE_IN_WORK_AND_AVCHATROOM,message:"不能在 Work / AVChatRoom 类型的群中设置群成员身份"}));if([n.GRP_MBR_ROLE_ADMIN,n.GRP_MBR_ROLE_MEMBER].indexOf(i)<0)return wn(new nt({code:ot.INVALID_MEMBER_ROLE,message:"不合法的群成员身份,请检查传入参数"}));if(r===this.tim.loginInfo.identifier)return wn(new nt({code:ot.CANNOT_SET_SELF_MEMBER_ROLE,message:"不能设置自己的群成员身份,请检查传入参数"}));var a=new Bn;return a.setMethod("setGroupMemberRole").setStart(),a.setText("groupID=".concat(o," userID=").concat(r," role=").concat(i)),W.log("GroupController.setGroupMemberRole. groupID:".concat(o,". userID: ").concat(r)),this._modifyGroupMemberInfo({groupID:o,userID:r,role:i}).then((function(e){return a.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.setGroupMemberRole ok. groupID:".concat(o,". userID: ").concat(r)),new An({group:s,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];a.setError(e,o,r).setEnd()})),W.error("GroupController.setGroupMemberRole error:".concat(le(e)," groupID:").concat(o," userID:").concat(r)),wn(e)}))}},{key:"setGroupMemberMuteTime",value:function(e){var t=this,n=e.groupID,o=e.userID,r=e.muteTime;if(o===this.tim.loginInfo.identifier)return wn(new nt({code:ot.CANNOT_MUTE_SELF,message:"不能将自己禁言,请检查传入参数"}));W.log("GroupController.setGroupMemberMuteTime. groupID:".concat(n,". userID: ").concat(o));var i=new Bn;return i.setMethod("setGroupMemberMuteTime").setStart(),i.setText("groupID=".concat(n," userID=").concat(o," muteTime=").concat(r)),this._modifyGroupMemberInfo({groupID:n,userID:o,muteTime:r}).then((function(e){return i.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.setGroupMemberMuteTime ok. groupID:".concat(n,". userID: ").concat(o)),new An({group:t.getLocalGroupProfile(n),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];i.setError(e,o,r).setEnd()})),W.error("GroupController.setGroupMemberMuteTime error:".concat(le(e)," groupID:").concat(n," userID:").concat(o)),wn(e)}))}},{key:"setMessageRemindType",value:function(e){var t=this,n=new Bn;n.setMethod("setMessageRemindType").setStart(),n.setText("groupID=".concat(e.groupID," userID=").concat(e.userID||this.tim.loginInfo.identifier)),W.log("GroupController.setMessageRemindType. groupID:".concat(e.groupID,". userID: ").concat(e.userID||this.tim.loginInfo.identifier));var o=e.groupID,r=e.messageRemindType;return this._modifyGroupMemberInfo({groupID:o,messageRemindType:r,userID:this.tim.loginInfo.identifier}).then((function(){n.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.setMessageRemindType ok. groupID:".concat(e.groupID," userID:").concat(e.userID||t.tim.loginInfo.identifier));var o=t.getLocalGroupProfile(e.groupID);return o&&(o.selfInfo.messageRemindType=r),new An({group:o})})).catch((function(o){return t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];n.setError(o,r,i).setEnd()})),W.error("GroupController.setMessageRemindType error:".concat(le(o)," groupID:").concat(e.groupID," userID:").concat(e.userID||t.tim.loginInfo.identifier)),wn(o)}))}},{key:"setGroupMemberNameCard",value:function(e){var t=this,n=e.groupID,o=e.userID,r=void 0===o?this.tim.loginInfo.identifier:o,i=e.nameCard;W.log("GroupController.setGroupMemberNameCard. groupID:".concat(n,". userID: ").concat(r));var s=new Bn;return s.setMethod("setGroupMemberNameCard").setStart(),s.setText("groupID=".concat(n," userID=").concat(r," nameCard=").concat(i)),this._modifyGroupMemberInfo({groupID:n,userID:r,nameCard:i}).then((function(e){W.log("GroupController.setGroupMemberNameCard ok. groupID:".concat(n,". userID: ").concat(r)),s.setCode(0).setNetworkType(t.getNetworkType()).setEnd();var o=t.getLocalGroupProfile(n);return r===t.tim.loginInfo.identifier&&o&&o.setSelfNameCard(i),new An({group:o,member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];s.setError(e,o,r).setEnd()})),W.error("GroupController.setGroupMemberNameCard error:".concat(le(e)," groupID:").concat(n," userID:").concat(r)),wn(e)}))}},{key:"setGroupMemberCustomField",value:function(e){var t=this,n=e.groupID,o=e.userID,r=void 0===o?this.tim.loginInfo.identifier:o,i=e.memberCustomField;W.log("GroupController.setGroupMemberCustomField. groupID:".concat(n,". userID: ").concat(r));var s=new Bn;return s.setMethod("setGroupMemberCustomField").setStart(),s.setText("groupID=".concat(n," userID=").concat(r," memberCustomField=").concat(i)),this._modifyGroupMemberInfo({groupID:n,userID:r,memberCustomField:i}).then((function(e){return s.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.setGroupMemberCustomField ok. groupID:".concat(n,". userID: ").concat(r)),new An({group:t.groupMap.get(n),member:e})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];s.setError(e,o,r).setEnd()})),W.error("GroupController.setGroupMemberCustomField error:".concat(le(e)," groupID:").concat(n," userID:").concat(r)),wn(e)}))}},{key:"getGroupList",value:function(e){var t=this,n=new Bn;n.setMethod("getGroupList").setStart(),W.log("GroupController.getGroupList");var o={introduction:"Introduction",notification:"Notification",createTime:"CreateTime",ownerID:"Owner_Account",lastInfoTime:"LastInfoTime",memberNum:"MemberNum",maxMemberNum:"MaxMemberNum",joinOption:"ApplyJoinOption",muteAllMembers:"ShutUpAllMember"},r=["Type","Name","FaceUrl","NextMsgSeq","LastMsgTime"];return e&&e.groupProfileFilter&&e.groupProfileFilter.forEach((function(e){o[e]&&r.push(o[e])})),this.request({name:"group",action:"list",param:{responseFilter:{groupBaseInfoFilter:r,selfInfoFilter:["Role","JoinTime","MsgFlag"]}}}).then((function(e){var o=e.data.groups;return W.log("GroupController.getGroupList ok. nums=".concat(o.length)),t._groupListTreeShaking(o),t.updateGroupMap(o),n.setCode(0).setNetworkType(t.getNetworkType()).setText("".concat(o.length,"-afterTreeshaking-").concat(t.groupMap.size)).setEnd(),t.tempConversationList&&(W.log("GroupController.getGroupList update last message with tempConversationList, nums=".concat(t.tempConversationList.length)),t._handleUpdateGroupLastMessage({data:t.tempConversationList}),t.tempConversationList=null),t.emitGroupListUpdate(),new An({groupList:t.getLocalGroups()})})).catch((function(e){return t.probeNetwork().then((function(t){var o=y(t,2),r=o[0],i=o[1];n.setError(e,r,i).setEnd()})),W.error("GroupController.getGroupList error:",e),wn(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=new Bn;a.setMethod("getGroupMemberList").setStart(),W.log("GroupController.getGroupMemberList groupID: ".concat(n," offset: ").concat(r," count: ").concat(s));var u=[];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 ee(r)&&0!==r.length?(t.hasLocalGroup(n)&&(t.getLocalGroupProfile(n).memberNum=i),u=t._updateLocalGroupMemberMap(n,r),t.tim.getUserProfile({userIDList:r.map((function(e){return e.userID})),tagList:[Be.NICK,Be.AVATAR]})):Promise.resolve([])})).then((function(e){var o=e.data;if(!ee(o)||0===o.length)return Nn({memberList:[]});var i=o.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));return t._updateLocalGroupMemberMap(n,i),a.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(n," offset=").concat(r," count=").concat(s)).setEnd(),W.log("GroupController.getGroupMemberList ok."),new An({memberList:u})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];a.setError(e,o,r).setEnd()})),W.error("GroupController.getGroupMemberList error:",e),wn(e)}))}},{key:"getLocalGroups",value:function(){return I(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=new Bn;n.setMethod("getGroupProfile").setStart(),W.log("GroupController.getGroupProfile. groupID:",e.groupID);var o=e.groupID,r=e.groupCustomFieldFilter,i={groupIDList:[o],responseFilter:{groupBaseInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember"],groupCustomFieldFilter:r}};return this.getGroupProfileAdvance(i).then((function(r){var i,s=r.data,a=s.successGroupList,u=s.failureGroupList;return W.log("GroupController.getGroupProfile ok. groupID:".concat(e.groupID)),u.length>0?wn(u[0]):(Ee(a[0].type)&&!t.hasLocalGroup(o)?i=new Ei(a[0]):(t.updateGroupMap(a),i=t.getLocalGroupProfile(o)),n.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(i.groupID," type=").concat(i.type," muteAllMembers=").concat(i.muteAllMembers," ownerID=").concat(i.ownerID)).setEnd(),i&&i.selfInfo&&!i.selfInfo.nameCard?t.updateSelfInfo(i).then((function(e){return new An({group:e})})):new An({group:i}))})).catch((function(o){return t.probeNetwork().then((function(t){var r=y(t,2),i=r[0],s=r[1];n.setError(o,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),W.error("GroupController.getGroupProfile error:".concat(le(o)," groupID:").concat(e.groupID)),wn(o)}))}},{key:"getGroupMemberProfile",value:function(e){var t=this,n=new Bn;n.setMethod("getGroupMemberProfile").setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setStart(),W.log("GroupController.getGroupMemberProfile groupID:".concat(e.groupID," userIDList:").concat(e.userIDList.join(","))),e.userIDList.length>50&&(e.userIDList=e.userIDList.slice(0,50));var o=e.groupID,r=e.userIDList;return this._getGroupMemberProfileAdvance(c({},e,{userIDList:r})).then((function(e){var n=e.data.members;return ee(n)&&0!==n.length?(t._updateLocalGroupMemberMap(o,n),t.tim.getUserProfile({userIDList:n.map((function(e){return e.userID})),tagList:[Be.NICK,Be.AVATAR]})):Nn([])})).then((function(e){var i=e.data.map((function(e){return{userID:e.userID,nick:e.nick,avatar:e.avatar}}));t._updateLocalGroupMemberMap(o,i);var s=r.filter((function(e){return t.hasLocalGroupMember(o,e)})).map((function(e){return t.getLocalGroupMemberInfo(o,e)}));return n.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),new An({memberList:s})}))}},{key:"_getGroupMemberProfileAdvance",value:function(e){return this.request({name:"group",action:"getGroupMemberProfile",param:c({},e,{memberInfoFilter:e.memberInfoFilter?e.memberInfoFilter:["Role","JoinTime","NameCard","ShutUpUntil"]})})}},{key:"updateSelfInfo",value:function(e){var t=e.groupID;W.log("GroupController.updateSelfInfo groupID:",t);var n={groupID:t,userIDList:[this.tim.loginInfo.identifier]};return this.getGroupMemberProfile(n).then((function(n){var o=n.data.memberList;return W.log("GroupController.updateSelfInfo ok. groupID:",t),e&&0!==o.length&&e.updateSelfInfo(o[0]),e}))}},{key:"addGroupMember",value:function(e){var t=this,n=new Bn;n.setMethod("addGroupMember").setText("groupID=".concat(e.groupID)).setStart();var o=this.getLocalGroupProfile(e.groupID);if(Ee(o.type)){var r=new nt({code:ot.CANNOT_ADD_MEMBER_IN_AVCHATROOM,message:ut});return n.setCode(ot.CANNOT_ADD_MEMBER_IN_AVCHATROOM).setMessage(ut).setNetworkType(this.getNetworkType()).setText("groupID=".concat(e.groupID," groupType=").concat(o.type)).setEnd(),wn(r)}return e.userIDList=e.userIDList.map((function(e){return{userID:e}})),W.log("GroupController.addGroupMember. groupID:",e.groupID),this.request({name:"group",action:"addGroupMember",param:e}).then((function(r){var i=r.data.members;n.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID)).setEnd(),W.log("GroupController.addGroupMember ok. groupID:",e.groupID);var s=i.filter((function(e){return 1===e.result})).map((function(e){return e.userID})),a=i.filter((function(e){return 0===e.result})).map((function(e){return e.userID})),u=i.filter((function(e){return 2===e.result})).map((function(e){return e.userID}));return 0===s.length?new An({successUserIDList:s,failureUserIDList:a,existedUserIDList:u}):(o.memberNum+=s.length,new An({successUserIDList:s,failureUserIDList:a,existedUserIDList:u,group:o}))})).catch((function(o){return t.probeNetwork().then((function(t){var r=y(t,2),i=r[0],s=r[1];n.setError(o,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),W.error("GroupController.addGroupMember error:".concat(le(o)," groupID:").concat(e.groupID)),wn(o)}))}},{key:"deleteGroupMember",value:function(e){var t=this,o=new Bn;o.setMethod("deleteGroupMember").setText(e.userIDList.length>5?"userIDList.length=".concat(e.userIDList.length):"userIDList=".concat(e.userIDList)).setStart(),W.log("GroupController.deleteGroupMember groupID:".concat(e.groupID," userIDList:").concat(e.userIDList));var r=this.getLocalGroupProfile(e.groupID);return r.type===n.GRP_AVCHATROOM?wn(new nt({code:ot.CANNOT_KICK_MEMBER_IN_AVCHATROOM,message:"不能在 AVChatRoom 类型的群组踢人"})):this.request({name:"group",action:"deleteGroupMember",param:e}).then((function(){return o.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.deleteGroupMember ok"),r.memberNum--,t.deleteLocalGroupMembers(e.groupID,e.userIDList),new An({group:r,userIDList:e.userIDList})})).catch((function(n){return t.probeNetwork().then((function(t){var r=y(t,2),i=r[0],s=r[1];o.setError(n,i,s).setText("groupID=".concat(e.groupID)).setEnd()})),W.error("GroupController.deleteGroupMember error:".concat(le(n)," groupID:").concat(e.groupID)),wn(n)}))}},{key:"searchGroupByID",value:function(e){var t=this,n={groupIDList:[e]},o=new Bn;return o.setMethod("searchGroupByID").setText("groupID=".concat(e)).setStart(),W.log("GroupController.searchGroupByID. groupID:".concat(e)),this.request({name:"group",action:"searchGroupByID",param:n}).then((function(n){var r=n.data.groupProfile;if(r[0].errorCode!==Oe)throw new nt({code:r[0].errorCode,message:r[0].errorInfo});return o.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.searchGroupByID ok. groupID:".concat(e)),new An({group:new Ei(r[0])})})).catch((function(n){return t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];o.setError(n,r,i).setEnd()})),W.warn("GroupController.searchGroupByID error:".concat(le(n)," groupID:").concat(e)),wn(n)}))}},{key:"applyJoinGroup",value:function(e){var t=this,n=new Bn;return n.setMethod($n).setStart(),this.request({name:"group",action:"applyJoinGroup",param:e}).then((function(o){var r=o.data,i=r.joinedStatus,s=r.longPollingKey;switch(n.setCode(0).setNetworkType(t.getNetworkType()).setText("groupID=".concat(e.groupID," joinedStatus=").concat(i)).setEnd(),W.log("GroupController.joinGroup ok. groupID:".concat(e.groupID," joinedStatus:").concat(i," longPollingKey:").concat(s)),i){case we:return new An({status:we});case Ne:return t.getGroupProfile({groupID:e.groupID}).then((function(n){var o=n.data.group,r={status:Ne,group:o};return te(s)?(t.emitGroupListUpdate(!0,!1),new An(r)):(t.emitInnerEvent(mn,e.groupID),t.AVChatRoomHandler.startRunLoop({longPollingKey:s,group:o}))}));default:var a=new nt({code:ot.JOIN_GROUP_FAIL,message:"加群失败,请检查传入参数或重试"});return W.error("GroupController.joinGroup error:".concat(le(a)," groupID:").concat(e.groupID)),wn(a)}})).catch((function(o){return n.setText("groupID=".concat(e.groupID)),t.probeNetwork().then((function(e){var t=y(e,2),r=t[0],i=t[1];n.setError(o,r,i).setEnd()})),W.error("GroupController.joinGroup error:".concat(le(o)," groupID:").concat(e.groupID)),wn(o)}))}},{key:"applyJoinAVChatRoom",value:function(e){return this.AVChatRoomHandler.applyJoinAVChatRoom(e)}},{key:"handleGroupApplication",value:function(e){var t=this,n=e.message.payload,o=n.groupProfile.groupID,r=n.authentication,i=n.messageKey,s=n.operatorID,a=new Bn;return a.setMethod("handleGroupApplication").setText("groupID=".concat(o)).setStart(),W.log("GroupController.handleApplication. groupID:",o),this.request({name:"group",action:"handleApplyJoinGroup",param:c({},e,{applicant:s,groupID:o,authentication:r,messageKey:i})}).then((function(){return a.setCode(0).setNetworkType(t.getNetworkType()).setEnd(),W.log("GroupController.handleApplication ok. groupID:",o),t.deleteGroupSystemNotice({messageList:[e.message]}),new An({group:t.getLocalGroupProfile(o)})})).catch((function(e){return t.probeNetwork().then((function(t){var n=y(t,2),o=n[0],r=n[1];a.setError(e,o,r).setEnd()})),W.error("GroupController.handleApplication error. error:".concat(le(e)," groupID:").concat(o)),wn(e)}))}},{key:"deleteGroupSystemNotice",value:function(e){var t=this;return ee(e.messageList)&&0!==e.messageList.length?(W.log("GroupController.deleteGroupSystemNotice "+e.messageList.map((function(e){return e.ID}))),this.request({name:"group",action:"deleteGroupSystemNotice",param:{messageListToDelete:e.messageList.map((function(e){return{from:n.CONV_SYSTEM,messageSeq:e.clientSequence,messageRandom:e.random}}))}}).then((function(){return W.log("GroupController.deleteGroupSystemNotice ok"),e.messageList.forEach((function(e){t.tim.messageController.deleteLocalMessage(e)})),new An})).catch((function(e){return W.error("GroupController.deleteGroupSystemNotice error:",e),wn(e)}))):Nn()}},{key:"getGroupProfileAdvance",value:function(e){return ee(e.groupIDList)&&e.groupIDList.length>50&&(W.warn("GroupController.getGroupProfileAdvance 获取群资料的数量不能超过50个"),e.groupIDList.length=50),W.log("GroupController.getGroupProfileAdvance. groupIDList:",e.groupIDList),this.request({name:"group",action:"query",param:e}).then((function(e){W.log("GroupController.getGroupProfileAdvance ok.");var t=e.data.groups,n=t.filter((function(e){return te(e.errorCode)||e.errorCode===Oe})),o=t.filter((function(e){return e.errorCode&&e.errorCode!==Oe})).map((function(e){return new nt({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}})}));return new An({successGroupList:n,failureGroupList:o})})).catch((function(t){return W.error("GroupController.getGroupProfileAdvance error:".concat(le(t)," groupIDList:").concat(e.groupIDList)),wn(t)}))}},{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=new Bn;t.setMethod("getGroupListInStorage").setStart(),W.time(Hn),W.log("GroupController._initGroupList");var n=this._getStorageGroupList();ee(n)&&n.length>0?(n.forEach((function(t){e.groupMap.set(t.groupID,new Ei(t))})),this.emitGroupListUpdate(!0,!1),t.setCode(0).setNetworkType(this.getNetworkType()).setText(this.groupMap.size).setEnd()):t.setCode(0).setNetworkType(this.getNetworkType()).setText(0).setEnd(),this.triggerReady(),W.log("GroupController._initGroupList ok. initCost=".concat(W.timeEnd(Hn),"ms")),this.getGroupList()}},{key:"_initListeners",value:function(){var e=this.tim.innerEmitter;e.once(Ot,this._initGroupList,this),e.on(hn,this._handleUpdateGroupLastMessage,this),e.on(Ft,this._handleReceivedGroupMessage,this),e.on(gn,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(sn,o),t&&this.emitOuterEvent(e.GROUP_LIST_UPDATED,o)}},{key:"_handleReceivedGroupMessage",value:function(e){var t=this,o=e.data.eventDataList;Array.isArray(o)&&o.forEach((function(e){var o=e.conversationID.replace(n.CONV_GROUP,"");t.groupMap.has(o)&&(t.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 t=e.data;if(W.log("GroupController._handleUpdateGroupLastMessage convNums=".concat(t.length," groupNums=").concat(this.groupMap.size)),0!==this.groupMap.size){for(var o,r,i,s=!1,a=0,u=t.length;a<u;a++)(o=t[a]).conversationID&&o.type!==n.CONV_GROUP&&(r=o.conversationID.split(/^GROUP/)[1],(i=this.getLocalGroupProfile(r))&&(i.lastMessage=o.lastMessage,s=!0));s&&(this.groupMap=this._sortLocalGroupList(this.groupMap),this.emitGroupListUpdate(!0,!1))}else this.tempConversationList=t}},{key:"_sortLocalGroupList",value:function(e){var t=I(e).filter((function(e){var t=y(e,2);return t[0],!ke(t[1].lastMessage)}));return t.sort((function(e,t){return t[1].lastMessage.lastTime-e[1].lastMessage.lastTime})),new Map([].concat(I(t),I(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!Ee(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 Ei(e))})),this._setStorageGroupList()}},{key:"_updateLocalGroupMemberMap",value:function(e,t){var n=this;return ee(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 Pi(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 te(e.muteTime)||r.updateMuteUntil(e.muteTime),te(e.role)||r.updateRole(e.role),te(e.nameCard)||r.updateNameCard(e.nameCard),te(e.memberCustomField)||r.updateMemberCustomField(e.memberCustomField),r}return t.getGroupMemberProfile({groupID:n,userIDList:[o]}).then((function(e){return y(e.data.memberList,1)[0]}))}))}},{key:"_groupListTreeShaking",value:function(e){for(var t=new Map(I(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=I(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=new Bn;n.setMethod("getGroupLastSequence").setStart();var o=0;if(this.hasLocalGroup(e)){var r=this.getLocalGroupProfile(e);if(r.lastMessage.lastSequence>0)return o=r.lastMessage.lastSequence,W.log("GroupController.getGroupLastSequence got lastSequence=".concat(o," from local group profile[lastMessage.lastSequence]. groupID=").concat(e)),n.setCode(0).setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(o," from local group profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(),Promise.resolve(o);if(r.nextMessageSeq>1)return o=r.nextMessageSeq-1,W.log("GroupController.getGroupLastSequence got lastSequence=".concat(o," from local group profile[nextMessageSeq]. groupID=").concat(e)),n.setCode(0).setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(o," from local group profile[nextMessageSeq]. groupID=").concat(e)).setEnd(),Promise.resolve(o)}var i="GROUP".concat(e),s=this.tim.conversationController.getLocalConversation(i);if(s&&s.lastMessage.lastSequence)return o=s.lastMessage.lastSequence,W.log("GroupController.getGroupLastSequence got lastSequence=".concat(o," from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)),n.setCode(0).setNetworkType(this.getNetworkType()).setText("got lastSequence=".concat(o," from local conversation profile[lastMessage.lastSequence]. groupID=").concat(e)).setEnd(),Promise.resolve(o);var a={groupIDList:[e],responseFilter:{groupBaseInfoFilter:["NextMsgSeq"]}};return this.getGroupProfileAdvance(a).then((function(r){var i=r.data.successGroupList;return ke(i)?W.log("GroupController.getGroupLastSequence successGroupList is empty. groupID=".concat(e)):(o=i[0].nextMessageSeq-1,W.log("GroupController.getGroupLastSequence got lastSequence=".concat(o," from getGroupProfileAdvance. groupID=").concat(e))),n.setCode(0).setNetworkType(t.getNetworkType()).setText("got lastSequence=".concat(o," from getGroupProfileAdvance. groupID=").concat(e)).setEnd(),o})).catch((function(o){return t.probeNetwork().then((function(t){var r=y(t,2),i=r[0],s=r[1];n.setError(o,i,s).setText("get lastSequence failed from getGroupProfileAdvance. groupID=".concat(e)).setEnd()})),W.warn("GroupController.getGroupLastSequence failed. ".concat(o)),wn(o)}))}},{key:"reset",value:function(){this.groupMap.clear(),this.groupMemberListMap.clear(),this.resetReady(),this.groupNoticeHandler.reset(),this.AVChatRoomHandler.reset(),this.tim.innerEmitter.once(Ot,this._initGroupList,this)}}]),i}(Sn),Vi=function(t){l(i,t);var o=v(i);function i(e){var t;r(this,i),(t=o.call(this,e)).REALTIME_MESSAGE_TIMEOUT=3e5,t.LONGPOLLING_ID_TIMEOUT=3e5,t._currentState=n.NET_STATE_CONNECTED,t._status={OPENIM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0},AVCHATROOM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0}};var s=t.tim.innerEmitter;return s.on(Ht,t._onGetLongPollIDFailed,m(t)),s.on(jt,t._onOpenIMResponseOK,m(t)),s.on(Bt,t._onOpenIMRequestFailed,m(t)),s.on(rn,t._onAVChatroomResponseOK,m(t)),s.on(on,t._onAVChatroomRequestFailed,m(t)),t}return s(i,[{key:"_onGetLongPollIDFailed",value:function(){this._currentState!==n.NET_STATE_DISCONNECTED&&this._emitNetStateChangeEvent(n.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 t=this._status[e],o=Date.now();if(0!==t.lastResponseReceivedTime){var r=o-t.lastResponseReceivedTime;W.debug("StatusController._onResponseOK key=".concat(e," currentState=").concat(this._currentState," interval=").concat(r," failedCount=").concat(t.failedCount," jitterCount=").concat(t.jitterCount)),t.failedCount>0&&(t.failedCount=0,t.jitterCount+=1,this._currentState!==n.NET_STATE_CONNECTED&&this._emitNetStateChangeEvent(n.NET_STATE_CONNECTED));var i=new Bn;r<=this.LONGPOLLING_ID_TIMEOUT?t.jitterCount>=3&&(i.setMethod("networkJitter").setStart(),i.setCode(0).setText("".concat(e,"-").concat(r,"-").concat(t.jitterCount)).setNetworkType(this.getNetworkType()).setEnd(),t.jitterCount=0):(i.setMethod("sdkReload").setStart(),i.setCode(0).setText("".concat(e,"-").concat(r)).setNetworkType(this.getNetworkType()).setEnd(),W.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(yn)),t.lastResponseReceivedTime=o}else t.lastResponseReceivedTime=o}},{key:"_onRequestFailed",value:function(e){var t=this,o=this._status[e];Date.now()-o.lastResponseReceivedTime>=this.LONGPOLLING_ID_TIMEOUT?this._currentState!==n.NET_STATE_DISCONNECTED&&(W.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable more than 5min. key=".concat(e," networkType=").concat(this.getNetworkType())),this._emitNetStateChangeEvent(n.NET_STATE_DISCONNECTED)):(o.failedCount+=1,o.failedCount>5?this.probeNetwork().then((function(r){var i=y(r,2),s=i[0],a=i[1];s?(t._currentState!==n.NET_STATE_CONNECTING&&t._emitNetStateChangeEvent(n.NET_STATE_CONNECTING),W.warn("StatusController._onRequestFailed, connecting, network jitter. key=".concat(e," networkType=").concat(a))):(t._currentState!==n.NET_STATE_DISCONNECTED&&t._emitNetStateChangeEvent(n.NET_STATE_DISCONNECTED),W.warn("StatusController._onRequestFailed, disconnected, longpolling unavailable. key=".concat(e," networkType=").concat(a))),o.failedCount=0,o.jitterCount=0})):this._currentState===n.NET_STATE_CONNECTED&&this._emitNetStateChangeEvent(n.NET_STATE_CONNECTING))}},{key:"_emitNetStateChangeEvent",value:function(t){W.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(){W.log("StatusController.reset"),this._currentState=n.NET_STATE_CONNECTED,this._status={OPENIM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0},AVCHATROOM:{lastResponseReceivedTime:0,jitterCount:0,failedCount:0}}}}]),i}(Sn);function Ki(){return null}var Hi=function(){function e(t){r(this,e),this.tim=t,this.isWX=O,this.storageQueue=new Map,this.checkTimes=0,this.checkTimer=setInterval(this._onCheckTimer.bind(this),1e3),this._errorTolerantHandle()}return s(e,[{key:"_errorTolerantHandle",value:function(){!this.isWX&&te(window.localStorage)&&(this.getItem=Ki,this.setItem=Ki,this.removeItem=Ki,this.clear=Ki)}},{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=E(this.storageQueue);try{for(t.s();!(e=t.n()).done;){var n=y(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(e){t.e(e)}finally{t.f()}this.storageQueue.clear()}catch(e){W.warn("Storage._doFlush error",e)}}},{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(e){W.warn("Storage.getItem error:",e)}}},{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){W.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(e){W.warn("Storage.removeItem error:",e)}}},{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(e){W.warn("Storage.getSize error:",e)}}},{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}(),Bi=D((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 h,d=l.length;for(c=0;c<d;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(h=1,u=new Array(p-1);h<p;h++)u[h-1]=arguments[h];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})),ji=function(e){var t,n,o,r,i;return ke(e.context)?(t="",n=0,o=0,r=0,i=1):(t=e.context.a2Key,n=e.context.tinyID,o=e.context.SDKAppID,r=e.context.contentType,i=e.context.apn),{platform:St,websdkappid:Tt,v:Et,a2:t,tinyid:n,sdkappid:o,contentType:r,apn:i,reqtime:function(){return+new Date}}},Yi=function(){function e(t){r(this,e),this.tim=t,this.tim.innerEmitter.on(Nt,this._update,this),this.tim.innerEmitter.on(wt,this._update,this),this.tim.innerEmitter.on(Lt,this._updateSpecifiedConfig,this),this._initConfig()}return s(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,n=e.action,r=e.param,i=e.tjgID;if(te(this.config[t])||te(this.config[t][n]))throw new nt({code:ot.NETWORK_PACKAGE_UNDEFINED,message:"".concat("未定义的 packageConfig",": PackageConfig.").concat(t)});var s=function e(t){if(0===Object.getOwnPropertyNames(t).length)return Object.create(null);var n=Array.isArray(t)?[]:Object.create(null),r="";for(var i in t)null!==t[i]?void 0!==t[i]?(r=o(t[i]),["string","number","function","boolean"].indexOf(r)>=0?n[i]=t[i]:n[i]=e(t[i])):n[i]=void 0:n[i]=null;return n}(this.config[t][n]);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,n=e.value;if(0!=!!t){var r=t.split(".");r.length<=0||function e(t,n,r,i){var s=n[r];"object"===o(t[s])?e(t[s],n,r+1,i):t[s]=i}(this.config,r,0,n)}}},{key:"_initConfig",value:function(){var e;this.config={},this.config.accessLayer=(e=this.tim,{create:null,query:{serverName:At.NAME.WEB_IM,cmd:At.CMD.ACCESS_LAYER,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:{platform:St,identifier:e.context.identifier,usersig:e.context.userSig,contentType:e.context.contentType,apn:null!==e.context?e.context.apn:1,websdkappid:Tt,v:Et},requestData:{}},update:null,delete:null}),this.config.login=function(e){return{create:null,query:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.LOGIN,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:{websdkappid:Tt,v:Et,platform:St,identifier:e.loginInfo.identifier,usersig:e.loginInfo.userSig,sdkappid:e.loginInfo.SDKAppID,accounttype:e.loginInfo.accountType,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,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:At.NAME.OPEN_IM,cmd:At.CMD.LOGOUT_ALL,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:{websdkappid:Tt,v:Et,platform:St,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:"",sdkappid:null!==e.loginInfo?e.loginInfo.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:"",reqtime:+new Date/1e3},requestData:{}},update:null,delete:null}}(this.tim),this.config.longPollLogout=function(e){return{create:null,query:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.LOGOUT_LONG_POLL,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:{websdkappid:Tt,v:Et,platform:St,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return Date.now()}},requestData:{longPollID:""},keyMaps:{request:{longPollID:"LongPollingId"}}},update:null,delete:null}}(this.tim),this.config.profile=function(e){var t=ji(e),n=At.NAME.PROFILE,o=At.CHANNEL.XHR,r=kt;return{query:{serverName:n,cmd:At.CMD.PORTRAIT_GET,channel:o,protocol:r,method:"POST",queryString:t,requestData:{fromAccount:"",userItem:[]},keyMaps:{request:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}},update:{serverName:n,cmd:At.CMD.PORTRAIT_SET,channel:o,protocol:r,method:"POST",queryString:t,requestData:{fromAccount:"",profileItem:[{tag:Be.NICK,value:""},{tag:Be.GENDER,value:""},{tag:Be.ALLOWTYPE,value:""},{tag:Be.AVATAR,value:""}]}}}}(this.tim),this.config.group=function(e){var t={websdkappid:Tt,v:Et,platform:St,a2:null!==e.context&&e.context.a2Key?e.context.a2Key:void 0,tinyid:null!==e.context&&e.context.tinyID?e.context.tinyID:void 0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,accounttype:null!==e.context?e.context.accountType:0},o={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"}};return{create:{serverName:At.NAME.GROUP,cmd:At.CMD.CREATE_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{type:n.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:o},list:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_JOINED_GROUPS,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{userID:e.loginInfo.identifier,limit:void 0,offset:void 0,groupType:void 0,responseFilter:void 0},keyMaps:o},query:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_GROUP_INFO,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupIDList:void 0,responseFilter:void 0},keyMaps:o},getGroupMemberProfile:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_GROUP_MEMBER_INFO,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMaps:{request:c({},o.request,{userIDList:"Member_List_Account"}),response:o.response}},getGroupMemberList:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_GROUP_MEMBER_LIST,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,limit:0,offset:0,memberRoleFilter:void 0,memberInfoFilter:void 0},keyMaps:o},quitGroup:{serverName:At.NAME.GROUP,cmd:At.CMD.QUIT_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0}},changeGroupOwner:{serverName:At.NAME.GROUP,cmd:At.CMD.CHANGE_GROUP_OWNER,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,newOwnerID:void 0},keyMaps:o},destroyGroup:{serverName:At.NAME.GROUP,cmd:At.CMD.DESTROY_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0}},updateGroupProfile:{serverName:At.NAME.GROUP,cmd:At.CMD.MODIFY_GROUP_INFO,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,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:c({},o.request,{groupCustomField:"AppDefinedData"}),response:o.response}},modifyGroupMemberInfo:{serverName:At.NAME.GROUP,cmd:At.CMD.MODIFY_GROUP_MEMBER_INFO,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMaps:o},addGroupMember:{serverName:At.NAME.GROUP,cmd:At.CMD.ADD_GROUP_MEMBER,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,silence:void 0,userIDList:void 0},keyMaps:o},deleteGroupMember:{serverName:At.NAME.GROUP,cmd:At.CMD.DELETE_GROUP_MEMBER,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,userIDList:void 0,reason:void 0},keyMaps:{request:{userIDList:"MemberToDel_Account"}}},searchGroupByID:{serverName:At.NAME.GROUP,cmd:At.CMD.SEARCH_GROUP_BY_ID,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,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:{serverName:At.NAME.GROUP,cmd:At.CMD.APPLY_JOIN_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0},keyMaps:o},applyJoinAVChatRoom:{serverName:At.NAME.BIG_GROUP_NO_AUTH,cmd:At.CMD.APPLY_JOIN_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:{websdkappid:Tt,v:Et,platform:St,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,accounttype:null!==e.context?e.context.accountType:0},requestData:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0},keyMaps:o},handleApplyJoinGroup:{serverName:At.NAME.GROUP,cmd:At.CMD.HANDLE_APPLY_JOIN_GROUP,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,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:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.DELETE_GROUP_SYSTEM_MESSAGE,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{messageListToDelete:void 0},keyMaps:{request:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}},getGroupPendency:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_GROUP_PENDENCY,channel:At.CHANNEL.XHR,protocol:kt,queryString:t,requestData:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMaps:{request:{handleAccount:"Handle_Account"}}}}}(this.tim),this.config.longPollID=function(e){return{create:{},query:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.GET_LONG_POLL_ID,channel:At.CHANNEL.XHR,protocol:kt,queryString:{websdkappid:Tt,v:Et,platform:St,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:+new Date/1e3},requestData:{},keyMaps:{response:{LongPollingId:"longPollingID"}}},update:{},delete:{}}}(this.tim),this.config.longPoll=function(e){var t={websdkappid:Tt,v:Et,platform:St,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,accounttype:null!==e.context?e.loginInfo.accountType:0,apn:null!==e.context?e.context.apn:1,reqtime:Math.ceil(+new Date/1e3)};return{create:{},query:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.LONG_POLL,channel:At.CHANNEL.AUTO,protocol:kt,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=ji(e),n=At.NAME.FRIEND,o=At.CHANNEL.XHR,r=kt;return{create:{serverName:n,cmd:At.CMD.FRIEND_ADD,channel:o,protocol:r,queryString:t,requestData:{fromAccount:"",addFriendItem:[]}},get:{serverName:n,cmd:At.CMD.GET_PENDENCY,channel:o,protocol:r,queryString:t,requestData:{fromAccount:"",pendencyType:"Pendency_Type_ComeIn"}},update:{serverName:n,cmd:At.CMD.RESPONSE_PENDENCY,channel:o,protocol:r,queryString:t,requestData:{fromAccount:"",responseFriendItem:[]}},delete:{serverName:n,cmd:At.CMD.DELETE_PENDENCY,channel:o,protocol:r,queryString:t,requestData:{fromAccount:"",toAccount:[],pendencyType:"Pendency_Type_ComeIn"}}}}(this.tim),this.config.friend=function(e){var t=ji(e),n=At.NAME.FRIEND,o=At.CHANNEL.XHR,r=kt;return{get:{serverName:n,cmd:At.CMD.FRIEND_GET_ALL,channel:o,protocol:r,method:"POST",queryString:t,requestData:{fromAccount:"",timeStamp:0,tagList:[Be.NICK,"Tag_SNS_IM_Remark",Be.AVATAR]},keyMaps:{request:{},response:{}}},delete:{serverName:n,cmd:At.CMD.FRIEND_DELETE,channel:o,protocol:r,method:"POST",queryString:t,requestData:{fromAccount:"",toAccount:[],deleteType:"Delete_Type_Single"}}}}(this.tim),this.config.blacklist=function(e){var t=ji(e);return{create:{serverName:At.NAME.FRIEND,cmd:At.CMD.ADD_BLACKLIST,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{fromAccount:"",toAccount:[]}},get:{serverName:At.NAME.FRIEND,cmd:At.CMD.GET_BLACKLIST,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{fromAccount:"",startIndex:0,maxLimited:30,lastSequence:0}},delete:{serverName:At.NAME.FRIEND,cmd:At.CMD.DELETE_BLACKLIST,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{fromAccount:"",toAccount:[]}},update:{}}}(this.tim),this.config.c2cMessage=function(e){var t={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,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"}};return{create:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.SEND_MESSAGE,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,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:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.GET_C2C_ROAM_MESSAGES,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMsg:1},keyMaps:n}}}(this.tim),this.config.c2cMessageWillBeRevoked=function(e){var t={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return+new Date}};return{create:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.REVOKE_C2C_MESSAGE,channel:At.CHANNEL.XHR,protocol:kt,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={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return+new Date}};return{get:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.GET_PEER_READ_TIME,channel:At.CHANNEL.XHR,protocol:kt,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={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,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"}};return{create:{serverName:At.NAME.GROUP,cmd:At.CMD.SEND_GROUP_MESSAGE,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,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:{serverName:At.NAME.GROUP,cmd:At.CMD.GET_GROUP_ROAM_MESSAGES,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{withRecalledMsg:1,groupID:"",count:15,sequence:""},keyMaps:n},update:null,delete:null}}(this.tim),this.config.groupMessageWillBeRevoked=function(e){var t={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return+new Date}};return{create:{serverName:At.NAME.GROUP,cmd:At.CMD.REVOKE_GROUP_MESSAGE,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{to:"",msgSeqList:[]},keyMaps:{request:{to:"GroupId",msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}}}(this.tim),this.config.conversation=function(e){var t={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1};return{query:{serverName:At.NAME.RECENT_CONTACT,cmd:At.CMD.GET_CONVERSATION_LIST,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{fromAccount:e.loginInfo.identifier,count:0},keyMaps:{request:{},response:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq"}}},pagingQuery:{serverName:At.NAME.RECENT_CONTACT,cmd:At.CMD.PAGING_GET_CONVERSATION_LIST,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,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:{serverName:At.NAME.RECENT_CONTACT,cmd:At.CMD.DELETE_CONVERSATION,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{fromAccount:e.loginInfo.identifier,toAccount:void 0,type:1,toGroupID:void 0},keyMaps:{request:{toGroupID:"ToGroupid"}}},setC2CMessageRead:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.SET_C2C_MESSAGE_READ,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{C2CMsgReaded:void 0},keyMaps:{request:{lastMessageTime:"LastedMsgTime"}}},setGroupMessageRead:{serverName:At.NAME.GROUP,cmd:At.CMD.SET_GROUP_MESSAGE_READ,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{groupID:void 0,messageReadSeq:void 0},keyMaps:{request:{messageReadSeq:"MsgReadedSeq"}}}}}(this.tim),this.config.syncMessage=function(e){var t={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return[Math.ceil(+new Date),Math.random()].join("")}};return{create:null,query:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.GET_MESSAGES,channel:At.CHANNEL.XHR,protocol:kt,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=At.NAME.BIG_GROUP_LONG_POLLING_NO_AUTH,n={websdkappid:Tt,v:Et,platform:St,sdkappid:e.loginInfo.SDKAppID,accounttype:"792",apn:1,reqtime:function(){return+new Date}};return(e.context.login===Le||e.context.a2Key)&&(t=At.NAME.BIG_GROUP_LONG_POLLING,n.apn=e.context.apn,n.a2=e.context.a2Key,n.tinyid=e.context.tinyID),{startLongPoll:{serverName:t,cmd:At.CMD.AVCHATROOM_LONG_POLL,channel:At.CHANNEL.XHR,protocol:kt,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={platform:St,websdkappid:Tt,v:Et,a2:null!==e.context?e.context.a2Key:"",tinyid:null!==e.context?e.context.tinyID:0,sdkappid:null!==e.context?e.context.SDKAppID:0,contentType:null!==e.context?e.context.contentType:0,apn:null!==e.context?e.context.apn:1,reqtime:function(){return Date.now()}};return{create:{serverName:At.NAME.OPEN_IM,cmd:At.CMD.FILE_UPLOAD,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:t,requestData:{appVersion:"2.1",fromAccount:"",toAccount:"",sequence:0,time:function(){return Math.ceil(Date.now()/1e3)},random:function(){return de()},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:function(){return e.loginInfo.SDKAppID},identifier:function(){return e.loginInfo.identifier},userSig:function(){return e.context.userSig}};return{create:null,query:{serverName:At.NAME.IM_COS_SIGN,cmd:At.CMD.COS_SIGN,channel:At.CHANNEL.XHR,protocol:kt,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:At.NAME.OPEN_IM,cmd:At.CMD.BIG_DATA_HALLWAY_AUTH_KEY,channel:At.CHANNEL.XHR,protocol:kt,method:"POST",queryString:{websdkappid:Tt,v:Et,platform:St,sdkappid:e.loginInfo.SDKAppID,accounttype:"792",apn:null!==e.context?e.context.apn:1,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:At.NAME.IM_OPEN_STAT,cmd:At.CMD.TIM_WEB_REPORT,channel:At.CHANNEL.AUTO,protocol:kt,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;return null!==e.context&&(t={sdkappid:e.context.SDKAppID,reqtime:Math.ceil(+new Date/1e3)}),{create:{serverName:At.NAME.IM_OPEN_STAT,cmd:At.CMD.TIM_WEB_REPORT,channel:At.CHANNEL.AUTO,protocol:kt,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 Cn(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 Cn(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 kt:return function(e){if("string"===o(e))try{return JSON.parse(e)}catch(t){return e}return e};case Dt:return function(e){return e};default:return function(e){return W.warn("PackageConfig._initEncoder(), unknow response type, data: ",JSON.stringify(e)),e}}}},{key:"_initDecoder",value:function(e){switch(e.protocol){case kt:return function(e){if("string"===o(e))try{return JSON.parse(e)}catch(t){return e}return e};case Dt:return function(e){return e};default:return function(e){return W.warn("PackageConfig._initDecoder(), unknow response type, data: ",e),e}}}}]),e}(),$i=function(){for(var e=[],t=Wi(arguments),n=0;n<arguments.length;n++)Number.isInteger(arguments[n])?e.push(arguments[n]):e.push(1==!!arguments[n]?"1":"0");return e.join(t)},Wi=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},zi={C2CMessageArray:1,groupMessageArray:1,groupTips:1,C2CNotifyMessageArray:1,profileModify:1,friendListMod:1},Ji=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e))._initialization(),o}return s(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(Wt,t)}},{key:"_groupMessageArrayChannel",value:function(e,t,n){this.emitInnerEvent(zt,t)}},{key:"_groupTipsChannel",value:function(e,t,n){var o=this;switch(e){case 4:case 6:this.emitInnerEvent(Jt,t);break;case 5:t.forEach((function(e){ee(e.elements.revokedInfos)?o.emitInnerEvent(en,t):o.emitInnerEvent(Xt,{groupSystemNotices:t,type:n})}));break;default:W.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($t):o.hasOwnProperty("sysCmdMsgNotify")?this.emitInnerEvent("_longPollNoticeReceiveSystemOrders"):o.hasOwnProperty("c2cMessageRevokedNotify")?this.emitInnerEvent(tn,t):o.hasOwnProperty("c2cMessageReadReceipt")&&this.emitInnerEvent(nn,t)}}},{key:"_profileModifyChannel",value:function(e,t,n){this.emitInnerEvent(Zt,t)}},{key:"_friendListModChannel",value:function(e,t,n){this.emitInnerEvent(Qt,t)}},{key:"_dispatchNotice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"poll";if(ee(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!==zi[e]})),oe(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(lt,": ").concat(a,", ").concat(r),this.emitInnerEvent(pn,new nt({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(Ln)}},{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(Ot,this._startSyncMessages,this),e.on(cn,this.closeNoticeChannel,this)}},{key:"openNoticeChannel",value:function(){W.log("NotificationController.openNoticeChannel"),this._getLongPollID()}},{key:"closeNoticeChannel",value:function(){W.log("NotificationController.closeNoticeChannel"),(this._runLoop instanceof ci||this._runLoop instanceof li)&&(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 Bn;t.setMethod("getLongPollID").setStart(),this.request({name:"longPollID",action:"query"}).then((function(n){var o=n.data.longPollingID;e._onGetLongPollIDSuccess(o),t.setCode(0).setText("longPollingID=".concat(o)).setNetworkType(e.getNetworkType()).setEnd()})).catch((function(n){var o=new nt({code:n.code||ot.GET_LONGPOLL_ID_FAILED,message:n.message||"获取 longpolling id 失败"});e.emitInnerEvent(Ht),e.emitInnerEvent(pn,o),e.probeNetwork().then((function(e){var n=y(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(Lt,[{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){W.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 W.log("NotificationController._startLongPoll is running...")}},{key:"_onNoticeReceived",value:function(e){var t=e.data;if(t.errorCode!==Oe){var n=new Bn;n.setMethod(Wn).setStart(),n.setMessage(t.errorInfo||JSON.stringify(t)).setCode(t.errorCode).setNetworkType(this.getNetworkType()).setEnd(!0),this._onResponseError(t)}else this.emitInnerEvent(jt);this.tim.sumStatController.addSuccessCount(Ln),this.tim.sumStatController.addCost(Ln,t.timecost),e.data.eventArray&&this._dispatchNotice(e.data.eventArray)}},{key:"_onResponseError",value:function(e){switch(e.errorCode){case ot.LONG_POLL_KICK_OUT:W.warn("NotificationController._onResponseError, longPollingID=".concat(this._longPollID," was kicked out")),this.emitInnerEvent(Yt),this.closeNoticeChannel();break;case ot.MESSAGE_A2KEY_EXPIRED:case ot.ACCOUNT_A2KEY_EXPIRED:this.emitInnerEvent(ln);break;default:te(e.errorCode)||te(e.errorInfo)?W.log("NotificationController._onResponseError, errorCode or errorInfo undefined!",e):this.emitInnerEvent(pn,new nt({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;W.log("NotificationController._onNoticeFail request timed out. url=".concat(t," data=").concat(n))}else W.log("NotificationController._onNoticeFail request timed out.");else W.log("NotificationController._onNoticeFail request failed due to network error");this.emitInnerEvent(Bt)}},{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($i(n.cookie,n.syncFlag)){case"00":case"01":e.emitInnerEvent(pn,{code:ot.NOTICE_RUNLOOP_OFFSET_LOST,message:pt});break;case"10":case"11":n.eventArray&&e._dispatchNotice(n.eventArray,"sync"),e._syncNoticeList=e._syncNoticeList.concat(n.messageList),e.emitInnerEvent(bt,{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(Pt,{messageList:n.messageList,C2CRemainingUnreadList:n.C2CRemainingUnreadList}),e._syncOffset=n.cookie,e._syncNoticeList=[],e._syncMessagesIsRunning=!1,e._syncMessagesFinished=!0}})).catch((function(t){e._syncMessagesIsRunning=!1,W.error("NotificationController.syncMessage failed. error:",t)}))}}]),n}(Sn),Xi=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e)).COSSDK=null,o._cosUploadMethod=null,o.expiredTimeLimit=300,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(Ot,o._init,m(o)),o.triggerReady(),o}return s(n,[{key:"_expiredTimer",value:function(){var e=this;this._timer=setInterval((function(){Math.ceil(Date.now()/1e3)>=e.cosOptions.expiredTime-60&&(e._getAuthorizationKey(),clearInterval(e._timer))}),3e4)}},{key:"_init",value:function(){var e=O?"cos-wx-sdk":"cos-js-sdk";this.COSSDK=this.tim.getPlugin(e),this.COSSDK?this._getAuthorizationKey():W.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 Bn;n.setMethod("getCosAuthKey").setStart(),this.request({name:"cosSig",action:"query",param:{duration:this.expiredTimeLimit}}).then((function(o){W.log("UploadController._getAuthorizationKey ok. data:",o.data);var r=o.data,i=r.expiredTime-t;n.setCode(0).setText("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(n){var o=y(n,2),r=o[0],i=o[1];e.setError(t,r,i).setEnd()})),W.warn("UploadController._getAuthorizationKey failed. error:",t)}))}},{key:"_initUploaderMethod",value:function(){var e=this;this.appid&&(this.cos=O?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=O?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 wn(new nt({code:ot.MESSAGE_IMAGE_SELECT_FILE_FIRST,message:"请先选择一个图片"}));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);return!0!==o?o:this.upload(e)}},{key:"_checkImageType",value:function(e){var t="";return t=O?e.url.slice(e.url.lastIndexOf(".")+1):e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1),ht.indexOf(t.toLowerCase())>=0||wn(new nt({coe:ot.MESSAGE_IMAGE_TYPES_LIMIT,message:"只允许上传 jpg png jpeg gif 格式的图片"}))}},{key:"_checkImageMime",value:function(e){return!0}},{key:"_checkImageSize",value:function(e){var t;return 0===(t=O?e.size:e.files[0].size)?wn(new nt({code:ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(it)})):t<20971520||wn(new nt({coe:ot.MESSAGE_IMAGE_SIZE_LIMIT,message:"".concat("图片大小超过20M,无法发送")}))}},{key:"uploadFile",value:function(e){var t=null;return e.file?e.file.files[0].size>104857600?(t=new nt({code:ot.MESSAGE_FILE_SIZE_LIMIT,message:at}),wn(t)):0===e.file.files[0].size?(t=new nt({code:ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(it)}),wn(t)):this.upload(e):(t=new nt({code:ot.MESSAGE_FILE_SELECT_FILE_FIRST,message:"请先选择一个文件"}),wn(t))}},{key:"uploadVideo",value:function(e){return e.file.videoFile.size>104857600?wn(new nt({code:ot.MESSAGE_VIDEO_SIZE_LIMIT,message:"".concat("视频大小超过100M,无法发送")})):0===e.file.videoFile.size?wn(new nt({code:ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(it)})):-1===dt.indexOf(e.file.videoFile.type)?wn(new nt({code:ot.MESSAGE_VIDEO_TYPES_LIMIT,message:"".concat("只允许上传 mp4 格式的视频")})):O?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 nt({code:ot.MESSAGE_VIDEO_UPLOAD_FAIL,message:"视频上传失败"}))}))}))}))}},{key:"uploadAudio",value:function(e){return e.file?e.file.size>20971520?wn(new nt({code:ot.MESSAGE_AUDIO_SIZE_LIMIT,message:"".concat("语音大小大于20M,无法发送")})):0===e.file.size?wn(new nt({code:ot.MESSAGE_FILE_IS_EMPTY,message:"".concat(it)})):this.upload(e):wn(new nt({code:ot.MESSAGE_AUDIO_UPLOAD_FAIL,message:"语音上传失败"}))}},{key:"upload",value:function(e){var t=this;if(!oe(this._cosUploadMethod))return W.warn("UploadController.upload 没有检测到上传插件,将无法发送图片、音频、视频、文件等类型的消息。详细请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/SDK.html#registerPlugin"),wn(new nt({code:ot.COS_UNDETECTED,message:"未检测到 COS 上传插件"}));var n=new Bn;n.setMethod("upload").setStart(),W.time("upload");var o=O?e.file:e.file.files[0];return new Promise((function(r,i){var s=O?t._createCosOptionsWXMiniApp(e):t._createCosOptionsWeb(e),a=t;t._cosUploadMethod(s,(function(e,s){var u=Object.create(null);if(s){if(e||ee(s.files)&&s.files[0].error){var c=new nt({code:ot.MESSAGE_FILE_UPLOAD_FAIL,message:"文件上传失败"});return n.setError(c,!0,t.getNetworkType()).setEnd(),W.log("UploadController.upload failed, error:",s.files[0].error),403===s.files[0].error.statusCode&&(W.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=O?s.Location:s.files[0].data.Location;var l=W.timeEnd("upload"),p=a._formatFileSize(o.size),h=a._formatSpeed(1e3*o.size/l),d="size=".concat(p,",time=").concat(l,"ms,speed=").concat(h);return W.log("UploadController.upload success name=".concat(o.name,",").concat(d)),r(u),void n.setCode(0).setNetworkType(t.getNetworkType()).setText(d).setEnd()}var f=new nt({code:ot.MESSAGE_FILE_UPLOAD_FAIL,message:"文件上传失败"});n.setError(f,!0,a.getNetworkType()).setEnd(),W.warn("UploadController.upload failed, error:",e),403===e.statusCode&&(W.warn("UploadController.upload failed. cos AccessKeyId was invalid, regain auth key!"),t._getAuthorizationKey()),i(f)}))}))}},{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(e){W.warn("onProgress callback error:",e),W.error(e)}},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(W.log(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(e){W.warn("onProgress callback error:",e),W.error(e)}}}}},{key:"_genFileName",value:function(e,t,n){return"".concat(e,"-").concat(t,"-").concat(de(99999),"-").concat(n)}},{key:"reset",value:function(){this._timer&&(clearInterval(this._timer),this._timer=0)}}]),n}(Sn),Qi=function(e){l(o,e);var t=v(o);function o(e){var n;return r(this,o),(n=t.call(this,e)).FILETYPE={SOUND:2106,FILE:2107,VIDEO:2113},n._bdh_download_server="grouptalk.c2c.qq.com",n._BDHBizID=10001,n._authKey="",n._expireTime=0,n.tim.innerEmitter.on(Ot,n._getAuthKey,m(n)),n}return s(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(!ee(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!==n.MSG_AUDIO&&e.type!==n.MSG_FILE&&e.type!==n.MSG_VIDEO)}},{key:"_parseElement",value:function(e,t){switch(e.type){case n.MSG_AUDIO:return this._parseAudioElement(e,t);case n.MSG_FILE:return this._parseFileElement(e,t);case n.MSG_VIDEO:return this._parseVideoElement(e,t)}}},{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?(W.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?(W.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?(W.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}(Sn),Zi={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 es(){try{var e="s"+ts();return wx.setStorageSync(Zi.prefix+"ssid",e),e}catch(e){}}function ts(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 ns(){try{var e=getCurrentPages(),t="/";return 0<e.length&&(t=e.pop().__route__),t}catch(e){console.log("get current page path error:"+e)}}function os(){var e,t={dm:"wechat.apps.xx",url:encodeURIComponent(ns()+ss(as.Data.pageQuery)),pvi:"",si:"",ty:0};return t.pvi=((e=function(){try{return wx.getStorageSync(Zi.prefix+"auid")}catch(e){}}())||(e=function(){try{var e=ts();return wx.setStorageSync(Zi.prefix+"auid",e),e}catch(e){}}(),t.ty=1),e),t.si=function(){var e=function(){try{return wx.getStorageSync(Zi.prefix+"ssid")}catch(e){}}();return e||(e=es()),e}(),t}function rs(){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 wx.getNetworkType({success:function(e){!function(e){try{wx.setStorageSync(Zi.prefix+"ntdata",e)}catch(e){}}(e.networkType)}}),e.ct=wx.getStorageSync(Zi.prefix+"ntdata")||"4g",e}function is(){var e,t=as.Data.userInfo,n=[];for(e in t)t.hasOwnProperty(e)&&n.push(e+"="+t[e]);return t=n.join(";"),{r2:Zi.app_id,r4:"wx",ext:"v="+Zi.version+(null!==t&&""!==t?";ui="+encodeURIComponent(t):"")}}function ss(e){if(!Zi.stat_param||!e)return"";e=function(e){if(1>Zi.ignore_params.length)return e;var t,n={};for(t in e)0<=Zi.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 as={App:{init:function(e){"appID"in e&&(Zi.app_id=e.appID),"eventID"in e&&(Zi.event_id=e.eventID),"statShareApp"in e&&(Zi.stat_share_app=e.statShareApp),"statPullDownFresh"in e&&(Zi.stat_pull_down_fresh=e.statPullDownFresh),"statReachBottom"in e&&(Zi.stat_reach_bottom=e.statReachBottom),"ignoreParams"in e&&(Zi.ignore_params=e.ignoreParams),"statParam"in e&&(Zi.stat_param=e.statParam),es();try{"lauchOpts"in e&&(as.Data.lanchInfo=e.lauchOpts,as.Data.lanchInfo.landing=1)}catch(e){}"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),as.Data.lastPageQuery=as.Data.pageQuery,as.Data.pageQuery=e,as.Data.lastPageUrl=as.Data.pageUrl,as.Data.pageUrl=ns(),as.Data.show=!1,as.Page.init()},e(t)}}()}},Page:{init:function(){var e,t=getCurrentPages()[getCurrentPages().length-1];t.onShow&&(e=t.onShow,t.onShow=function(){if(!0===as.Data.show){var t=as.Data.lastPageQuery;as.Data.lastPageQuery=as.Data.pageQuery,as.Data.pageQuery=t,as.Data.lastPageUrl=as.Data.pageUrl,as.Data.pageUrl=ns()}as.Data.show=!0,as.Page.stat(),e.apply(this,arguments)}),Zi.stat_pull_down_fresh&&t.onPullDownRefresh&&function(){var e=t.onPullDownRefresh;t.onPullDownRefresh=function(){as.Event.stat(Zi.prefix+"pulldownfresh",{url:t.__route__}),e.apply(this,arguments)}}(),Zi.stat_reach_bottom&&t.onReachBottom&&function(){var e=t.onReachBottom;t.onReachBottom=function(){as.Event.stat(Zi.prefix+"reachbottom",{url:t.__route__}),e.apply(this,arguments)}}(),Zi.stat_share_app&&t.onShareAppMessage&&function(){var e=t.onShareAppMessage;t.onShareAppMessage=function(){return as.Event.stat(Zi.prefix+"shareapp",{url:t.__route__}),e.apply(this,arguments)}}()},multiStat:function(e,t){if(1==t)as.Page.stat(e);else{var n=getCurrentPages()[getCurrentPages().length-1];n.onShow&&function(){var t=n.onShow;n.onShow=function(){as.Page.stat(e),t.call(this,arguments)}}()}},stat:function(e){if(""!=Zi.app_id){var t=[],n=is();if(e&&(n.r2=e),e=[os(),n,rs()],as.Data.lanchInfo){e.push({ht:as.Data.lanchInfo.scene}),as.Data.pageQuery&&as.Data.pageQuery._mta_ref_id&&e.push({rarg:as.Data.pageQuery._mta_ref_id});try{1==as.Data.lanchInfo.landing&&(n.ext+=";lp=1",as.Data.lanchInfo.landing=0)}catch(e){}}e.push({rdm:"/",rurl:0>=as.Data.lastPageUrl.length?as.Data.pageUrl+ss(as.Data.lastPageQuery):encodeURIComponent(as.Data.lastPageUrl+ss(as.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:Zi.api_base+"?"+t.join("&").toLowerCase()})}}},Event:{stat:function(e,t){if(""!=Zi.event_id){var n=[],o=os(),r=is();o.dm="wxapps.click",o.url=e,r.r2=Zi.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,rs(),{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:Zi.api_base+"?"+n.join("&").toLowerCase()})}}},Data:{userInfo:null,lanchInfo:null,pageQuery:null,lastPageQuery:null,pageUrl:"",lastPageUrl:"",show:!1}},us=as,cs=function(){function e(){r(this,e),this.cache=[],this.MtaWX=null,this._init()}return s(e,[{key:"report",value:function(e,t){var n=this;try{w?window.MtaH5?(window.MtaH5.clickStat(e,t),this.cache.length>0&&(this.cache.forEach((function(e){var t=e.name,n=e.param;window.MtaH5.clickStat(t,n)})),this.cache=[])):this.cache.push({name:e,param:t}):O&&(this.MtaWX?(this.MtaWX.Event.stat(e,t),this.cache.length>0&&(this.cache.forEach((function(e){var t=e.name,o=e.param;n.MtaWX.Event.stat(t,o)})),this.cache=[])):this.cache.push({name:e,param:t}))}catch(e){}}},{key:"stat",value:function(){try{w&&window.MtaH5?window.MtaH5.pgv():O&&this.MtaWX&&this.MtaWX.Page.stat()}catch(e){}}},{key:"_init",value:function(){try{if(w){window._mtac={autoReport:0};var e=document.createElement("script"),t=ve();e.src="".concat(t,"//pingjs.qq.com/h5/stats.js?v2.0.4"),e.setAttribute("name","MTAH5"),e.setAttribute("sid","500690998"),e.setAttribute("cid","500691017");var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)}else O&&(this.MtaWX=us,this.MtaWX.App.init({appID:"500690995",eventID:"500691014",autoReport:!1,statParam:!0}))}catch(e){}}}]),e}(),ls=function(e){l(n,e);var t=v(n);function n(e){var o;r(this,n),(o=t.call(this,e)).MTA=new cs;var i=o.tim.innerEmitter;return i.on(vn,o._stat,m(o)),i.on(_n,o._stat,m(o)),o}return s(n,[{key:"_stat",value:function(){this.MTA.report("sdkappid",{value:this.tim.context.SDKAppID}),this.MTA.report("version",{value:Ss.VERSION}),this.MTA.stat()}}]),n}(Sn),ps=function(){function e(t){r(this,e),this._table="timwebii",this._report=[]}return s(e,[{key:"pushIn",value:function(e){W.debug("SSOLogBody.pushIn",this._report.length,e),this._report.push(e)}},{key:"backfill",value:function(e){var t;ee(e)&&0!==e.length&&(W.debug("SSOLogBody.backfill",this._report.length,e.length),(t=this._report).unshift.apply(t,I(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}(),hs=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e)).TAG="im-ssolog-event",o._reportBody=new ps,o._version="2.7.7",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(an,o._onLoginSuccess,m(o)),o}return s(n,[{key:"reportAtOnce",value:function(){W.debug("EventStatController.reportAtOnce"),this._report()}},{key:"_onLoginSuccess",value:function(){var e=this,t=this.tim.storage,n=t.getItem(this.TAG,!1);ke(n)||(W.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 Bn&&(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}),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&&(W.debug("EventStatController.report retry success"),e._retryCount=0)})).catch((function(n){if(W.warn("EventStatController.report, networkType:".concat(e.getNetworkType()," error:").concat(le(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))W.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)),W.log("EventStatController._flushAtOnce nums="+o.length),e.setItem(this.TAG,o,!0,!1)}}},{key:"reset",value:function(){W.log("EventStatController.reset"),this._stopReportTimer(),this._report()}}]),n}(Sn),ds="none",fs="online",gs=function(){function e(){r(this,e),this._networkType="",this.maxWaitTime=3e3}return s(e,[{key:"start",value:function(){var e=this;O?(wx.getNetworkType({success:function(t){e._networkType=t.networkType,t.networkType===ds?W.warn("NetMonitor no network, please check!"):W.info("NetMonitor networkType:".concat(t.networkType))}}),wx.onNetworkStatusChange(this._onWxNetworkStatusChange.bind(this))):this._networkType=fs}},{key:"_onWxNetworkStatusChange",value:function(e){this._networkType=e.networkType,e.isConnected?W.info("NetMonitor networkType:".concat(e.networkType)):W.warn("NetMonitor no network, please check!")}},{key:"probe",value:function(){var e=this;return new Promise((function(t,n){if(O)wx.getNetworkType({success:function(n){e._networkType=n.networkType,n.networkType===ds?(W.warn("NetMonitor no network, please check!"),t([!1,n.networkType])):(W.info("NetMonitor networkType:".concat(n.networkType)),t([!0,n.networkType]))}});else if(window&&window.fetch)fetch("".concat(ve(),"//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=").concat(Math.random())).then((function(e){e.ok?t([!0,fs]):t([!1,ds])})).catch((function(e){t([!1,ds])}));else{var o=new XMLHttpRequest,r=setTimeout((function(){W.warn("NetMonitor fetch timeout. Probably no network, please check!"),o.abort(),e._networkType=ds,t([!1,ds])}),e.maxWaitTime);o.onreadystatechange=function(){4===o.readyState&&(clearTimeout(r),200===o.status||304===o.status?(this._networkType=fs,t([!0,fs])):(W.warn("NetMonitor fetch status:".concat(o.status,". Probably no network, please check!")),this._networkType=ds,t([!1,ds])))},o.open("GET","".concat(ve(),"//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}(),ms=function(){function e(t){var n=this;r(this,e),ee(t)?(this._map=new Map,t.forEach((function(e){n._map.set(e,[])}))):W.warn("AverageCalculator.constructor need keys")}return s(e,[{key:"push",value:function(e,t){return!(te(e)||!this._map.has(e)||!J(t)||(this._map.get(e).push(t),0))}},{key:"getSize",value:function(e){return te(e)||!this._map.has(e)?-1:this._map.get(e).length}},{key:"getAvg",value:function(e){if(te(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 te(e)||!this._map.has(e)?-1:Math.max.apply(null,this._map.get(e))}},{key:"getMin",value:function(e){return te(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}(),_s=function(){function e(t){var n=this;r(this,e),ee(t)?(this._map=new Map,t.forEach((function(e){n._map.set(e,{totalCount:0,successCount:0})}))):W.warn("SuccessRateCalculator.constructor need keys")}return s(e,[{key:"addTotalCount",value:function(e){return!(te(e)||!this._map.has(e)||(this._map.get(e).totalCount+=1,0))}},{key:"addSuccessCount",value:function(e){return!(te(e)||!this._map.has(e)||(this._map.get(e).successCount+=1,0))}},{key:"getSuccessRate",value:function(e){if(te(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 te(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}(),vs=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e)).TABLE="timwebsum",o.TAG="im-ssolog-sumstat",o._items=[Ln,bn,Pn,Gn,Un,xn,qn,Fn,Vn,Kn],o._thresholdMap=new Map,o._thresholdMap.set(Ln,100),o._thresholdMap.set(bn,150),o._thresholdMap.set(Pn,15),o._thresholdMap.set(Gn,6),o._thresholdMap.set(Un,6),o._thresholdMap.set(xn,6),o._thresholdMap.set(qn,6),o._thresholdMap.set(Fn,6),o._thresholdMap.set(Vn,50),o._thresholdMap.set(Kn,50),o._lpID="",o._platform=o.getPlatform(),o._lastReportTime=0,o._statInfoArr=[],o._retryCount=0,o._avgCalc=new ms(o._items),o._successRateCalc=new _s(o._items),o.tim.innerEmitter.on(an,o._onLoginSuccess,m(o)),o}return s(n,[{key:"_onLoginSuccess",value:function(){var e=this,t=this.tim.storage,n=t.getItem(this.TAG,!1);ke(n)||(W.log("SumStatController._onLoginSuccess get sumstatlog in storage, nums="+n.length),n.forEach((function(t){e._statInfoArr.pushIn(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()):W.warn("SumStatController.addTotalCount invalid key:",e)}},{key:"addSuccessCount",value:function(e){this._successRateCalc.addSuccessCount(e)||W.warn("SumStatController.addSuccessCount invalid key:",e)}},{key:"addCost",value:function(e,t){this._avgCalc.push(e,t)?(W.debug("SumStatController.addCost",e,t,this._avgCalc.getSize(e)),this._avgCalc.getSize(e)>=this._thresholdMap.get(e)&&this._report(e)):W.warn("SumStatController.addCost invalid key or cost:",e,t)}},{key:"_getItemNum",value:function(e){switch(e){case Ln:return 1;case bn:return 2;case Pn:return 3;case Vn:return 4;case Kn:return 5;case Gn:return 6;case Un:return 7;case xn:return 8;case qn:return 9;case Fn: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.7.7"),tinyID:this.tim.context.tinyID,userID:this.tim.loginInfo.identifier,item:this._getItemNum(e),lpID:e===Ln?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:pe()}),t}},{key:"_report",value:function(e){var t=this,n=[],o=null;te(e)?this._items.forEach((function(e){null!==(o=t._getStatInfo(e))&&n.push(o)})):null!==(o=this._getStatInfo(e))&&n.push(o),W.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)?W.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&&(W.debug("SumStatController._doReport retry success"),t._retryCount=0)})).catch((function(n){W.warn("SumStatController._doReport, online:".concat(t.getNetworkType()," error:").concat(le(n)),e),t._retryCount<=1?setTimeout((function(){W.info("SumStatController._doReport retry",e),t._retryCount+=1,t._doReport(e)}),5e3):(t._retryCount=0,t._statInfoArr=t._statInfoArr.concat(e),t._flusgAtOnce())}))}},{key:"_flushAtOnce",value:function(){var e=this.tim.storage,t=e.getItem(this.TAG,!1),n=this._statInfoArr;if(ke(t))W.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)),W.log("SumStatController._flushAtOnce nums="+o.length),e.setItem(this.TAG,o,!0,!1)}this._statInfoArr=[]}},{key:"reset",value:function(){W.info("SumStatController.reset"),this._report(),this._avgCalc.reset(),this._successRateCalc.reset()}}]),n}(Sn),ys=function(){function e(){r(this,e),this._funcMap=new Map}return s(e,[{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):(W.log("SafetyCallback.find: 找不到 func —— ".concat(e,"/").concat(""!==t.name?t.name:"[anonymous]")),null):(W.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(e,t,n){return function(){try{t.apply(n,Array.from(arguments))}catch(t){var o=new Bn;o.setMethod(zn).setText("eventName=".concat(e)).setStart(),o.setCode(0).setMessage(t.message).setEnd()}}}}]),e}(),Is=function(e){l(n,e);var t=v(n);function n(e){var o;return r(this,n),(o=t.call(this,e))._maybeLostSequencesMap=new Map,o}return s(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);W.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(W.debug("MessageLossController.detectMessageLoss. matchedSequences:".concat(o)),n.length===o.length)W.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);var a=new Bn;a.setMethod("messageLoss").setStart(),a.setCode(0).setText(r).setNetworkType(this.getNetworkType()).setEnd(),W.warn("MessageLossController.detectMessageLoss message loss detected. conversationID:".concat(e," lostSequences:").concat(i))}n.length=0}}},{key:"reset",value:function(){W.log("MessageLossController.reset"),this._maybeLostSequencesMap.clear()}}]),n}(Sn),Ms=function(){function t(e){r(this,t);var n=new Bn;n.setMethod("sdkConstruct").setStart(),Tn.mixin(this),this._initOptions(e),this._initMemberVariables(),this._initControllers(),this._initListener(),Bn.bindController(this.eventStatController),n.setCode(0).setText("mp=".concat(O,"-ua=").concat(L)).setEnd(),W.info("SDK inWxMiniApp:".concat(O,", SDKAppID:").concat(e.SDKAppID,", UserAgent:").concat(L)),this._safetyCallbackFactory=new ys}return s(t,[{key:"login",value:function(e){return W.time(On),this._ssoLog=new Bn,this._ssoLog.setMethod("sdkReady").setStart(),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&&W.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"),W.debug("on","eventName:".concat(t)),this.outerEmitter.on(t,this._safetyCallbackFactory.defense(t,n,o),o)}},{key:"once",value:function(e,t,n){W.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){W.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]}));var n=new Bn;n.setMethod("registerPlugin").setStart(),n.setCode(0).setText("key=".concat(Object.keys(e))).setEnd()}},{key:"getPlugin",value:function(e){return this.plugins[e]||void 0}},{key:"setLogLevel",value:function(e){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"))),W.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 yt?this.messageController.sendMessageInstance(e,t):wn(new nt({code:ot.MESSAGE_SEND_NEED_MESSAGE_INSTANCE,message:"需要 Message 的实例"}))}},{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:"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=de();this.context={SDKAppID:t,accountType:n},this.loginInfo={SDKAppID:t,accountType:n,identifier:null,userSig:null,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",avchatroomIDList:[]},this.options={runLoopNetType:e.runLoopNetType||2,enablePointer:e.enablePointer||!1}}},{key:"_initMemberVariables",value:function(){this.innerEmitter=new Bi,this.outerEmitter=new Bi,function(e){Rn=e}(this.outerEmitter),this.packageConfig=new Yi(this),this.storage=new Hi(this),this.netMonitor=new gs,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;Z(arguments[1])&&arguments[1].data?(W.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 hi(this),this.connectionController=new pi(this),this.contextController=new kn(this),this.context=this.contextController.getContext(),this.signController=new Jn(this),this.messageController=new bi(this),this.conversationController=new ki(this),this.userController=new Mi(this),this.groupController=new Fi(this),this.notificationController=new Ji(this),this.bigDataHallwayController=new Qi(this),this.statusController=new Vi(this),this.uploadController=new Xi(this),this.messageLossController=new Is(this),this.eventStatController=new hs(this),this.sumStatController=new vs(this),this.mtaReportController=new ls(this),this._initReadyListener()}},{key:"_initListener",value:function(){var e=this;if(this.innerEmitter.on(yn,this._onSDKReload,this),O&&"function"==typeof wx.onAppShow&&"function"==typeof wx.onAppHide){var t=null;wx.onAppHide((function(){(t=new Bn).setMethod("mpHideToShow").setStart()})),wx.onAppShow((function(){null!==t&&t.setCode(0).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;W.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=W.timeEnd(On);W.warn("SDK is ready. cost=".concat(i,"ms")),this.triggerReady(),this.innerEmitter.emit(vn),this.outerEmitter.emit(e.SDK_READY),this._sdkReloadFlag&&(this.outerEmitter.emit(e.SDK_RELOAD),this.groupController.AVChatRoomHandler.joinAVChatRoomSilently(),this._sdkReloadFlag=!1),this._ssoLog.setCode(0).setNetworkType(this.netMonitor.getNetworkType()).setText(i).setEnd()}}}]),t}();Ms.prototype.readyList=["conversationController"],Ms.prototype.initList=["exceptionController","connectionController","signController","contextController","messageController","conversationController","userController","groupController","notificationController","eventStatController","sumStatController","messageLossController","statusController"];var Cs={login:"login",on:"on",off:"off",ready:"ready",setLogLevel:"setLogLevel",joinGroup:"joinGroup",quitGroup:"quitGroup",registerPlugin:"registerPlugin"};function Es(e,t){return!(!e.isReady()&&void 0===Cs[t]&&(e.innerEmitter.emit(pn,new nt({code:ot.SDK_IS_NOT_READY,message:"".concat(t," ").concat("接口需要 SDK 处于 ready 状态后才能调用",",请参考 https://imsdk-1252463788.file.myqcloud.com/IM_DOC/Web/module-EVENT.html#.SDK_READY")})),1))}var Ts={},Ss={create:function(t){if(t.SDKAppID&&Ts[t.SDKAppID])return Ts[t.SDKAppID];W.log("TIM.create");var n=new Ms(t);n.on(e.SDK_DESTROY,(function(e){Ts[e.data.SDKAppID]=null,delete Ts[e.data.SDKAppID]}));var o=function(e){var t=Object.create(null);return Object.keys(Ct).forEach((function(n){if(e[n]){var o=Ct[n],r=new T;t[o]=function(){var t=Array.from(arguments);return r.use((function(t,o){if(Es(e,n))return o()})).use((function(e,t){if(!0===Ae(e,Mt[n],o))return t()})).use((function(t,o){return e[n].apply(e,t)})),r.run(t)}}})),t}(n);return Ts[t.SDKAppID]=o,W.log("TIM.create ok"),o}};return Ss.TYPES=n,Ss.EVENT=e,Ss.VERSION="2.7.7",W.log("TIM.VERSION: ".concat(Ss.VERSION)),Ss}()}).call(this,n(6))},function(e){e.exports=JSON.parse('{"name":"tsignaling","version":"0.2.1","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js"},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.3","webpack":"^4.43.0","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"EventEmitter":"^1.0.0","docdash-blue":"^1.1.3","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","mta-h5-analysis":"^2.0.15","pretty":"^2.0.0","replace":"^1.2.0","tim-js-sdk":"^2.7.7","tim-wx-sdk":"^2.7.7","uuidjs":"^4.2.5"}}')}]).default}));
|