aegis.global.min.js 66 KB

12345678910
  1. /**
  2. * =================================================================
  3. * aegis-web-sdk@1.37.5 (c) 2023 TencentCloud Real User Monitoring.
  4. * Author pumpkincai.
  5. * Last Release Time Mon Jun 26 2023 14:20:23 GMT+0800 (中国标准时间).
  6. * Released under the MIT License.
  7. * Thanks for supporting RUM & Aegis!
  8. * =================================================================
  9. **/
  10. var Aegis=function(){"use strict";var _,j;function H(e){this.name="__st"+(1e9*Math.random()>>>0)+_+"__",null!=e&&e.forEach(this.add,this),_+=1}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{configurable:!0,writable:!0,value:function(e){if(null===this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var o=arguments[1],i=0;i<n;){var r=t[i];if(e.call(o,r,i,t))return r;i+=1}}}),window.WeakSet||(_=Date.now()%1e9,H.prototype.add=function(e){var t=this.name;return e[t]||Object.defineProperty(e,t,{value:!0,writable:!0}),this},H.prototype.delete=function(e){return!!e[this.name]&&!(e[this.name]=void 0)},H.prototype.has=function(e){return!!e[this.name]},j=H,Object.defineProperty(window,"WeakSet",{value:function(e){return new j(e)}})),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(o=arguments[n]))for(var o=Object(o),i=Object.keys(Object(o)),r=0,a=i.length;r<a;r++){var s=i[r],c=Object.getOwnPropertyDescriptor(o,s);null!=c&&c.enumerable&&(t[s]=o[s])}return t}});var B=function(e,t){return(B=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(e,t)},E=function(){return(E=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function u(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var o=Array(e),i=0,t=0;t<n;t++)for(var r=arguments[t],a=0,s=r.length;a<s;a++,i++)o[i]=r[a];return o}function D(t){try{return encodeURIComponent(decodeURIComponent(t))}catch(e){return t}}var n,F=/_?t(\d)?(imestamp)?=\d+&?/g,M=["aegis.qq.com","tamaegis.com","/aegis-sdk","rumt-","/flog.core.min.js","pingfore.qq.com","pingfore.tencent.com","zhiyan.tencent-cloud.net","h.trace.qq.com","btrace.qq.com","beacon.qq.com","dmplog.qq.com","qq.com/report","svibeacon.onezapp.com","cube.weixinbridge.com","doubleclick.net","pcmgrmonitor.3g.qq.com","report.qqweb.qq.com","tpstelemetry.tencent.com","insight.cloud.tencent.com","facebook.com","facebook.net","google","yahoo.com","twitter.com","ga-audiences","report.idqqimg.com","arms-retcode.aliyuncs.com","px.effirst.com","sentry","hot-update.json","u.c.b.r.o.w.s.e.r","report.url.cn","sockjs-node","m3u8"],W=["ResizeObserver loop limit exceeded","Failed to execute 'transaction'","window.indexedDB.deleteDatabase is not a function"],V=["ext1","ext2","ext3","level","trace","tag","seq","code"],X=["static","fetch"],G=(e.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},e.prototype.on=function(e,t,n){var o;if(void 0===n&&(n=0),this)return(o=this.eventsList[e])||(this.eventsList[e]=[],o=this.eventsList[e]),-1===this.indexOf(o,t)&&o.push({name:e,type:n||0,callback:t}),this},e.prototype.one=function(e,t){this.on(e,t,1)},e.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(n){if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}}return null}},e.prototype.clear=function(){this.eventsList={}},e),J=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={};return t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,fe(n)};function e(){var a=this;this.emit=function(e,t){if(a){var n;if(null!=(o=a.eventsList[e])&&o.length)for(var o=o.slice(),i=0;i<o.length;i++){n=o[i];try{var r=n.callback.apply(a,[t]);if(1===n.type&&a.remove(e,n.callback),!1===r)break}catch(e){throw e}}return a}},this.eventsList={}}(o=n=n||{})[o.number=-1]="number",o.string="";function $(e,t){return"number"==typeof e||"string"==typeof e?e:t?n.string:n.number}function P(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function K(e,t){return void 0===t&&(t=2048),String(e).replace(F,"").slice(0,t)}function Q(e){return"string"==typeof e&&/^\//.test(e)?"https:"===(null===location||void 0===location?void 0:location.protocol):/^https/.test(e)}function Y(e,t,n){var o,i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler))return{code:void 0===(r=(i=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx,null==n?void 0:n.payload)||{}).code)?"unknown":r,isErr:i.isErr};if(!(e="string"==typeof e?JSON.parse(e):e))return{code:"unknown",isErr:!1};"function"==typeof(null==(o=null==t?void 0:t.ret)?void 0:o.join)&&(ue=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,a=Object.getOwnPropertyNames(e).filter(function(e){return-1!==ue.indexOf(e.toLowerCase())});return a.length?{code:""+(r="未知"!==(r=e[a[0]])&&""!==r?r:"unknown"),isErr:0!==r&&"0"!==r&&"unknown"!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function L(e,t,n){try{var o="function"==typeof t?t(e,null==n?void 0:n.url)||"":e;return de(o).slice(0,102400)}catch(e){return""}}function z(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function l(t,e){return"string"!=typeof t||!t||e&&-1<t.indexOf(e)||ge.test(t)||M.some(function(e){return-1<t.indexOf(e)})}function Z(n,o){var i,r=[],a=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){Array.isArray(e)?r=r.concat(e):r.push(e),o&&r.length>=o||n.sendNow&&0<r.length?(r=me(r),t(r.splice(0,r.length)),i&&clearTimeout(i)):(i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(r=me(r)).length&&t(r.splice(0,r.length))},a.delay))}}function ee(e,t){return Array.isArray(e)?t(e.map(function(e){return t=E(E({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(O).join(" ")}),V.forEach(function(e){t[e]||delete t[e]}),t;var t})):t([E(E({},e),{msg:"string"==typeof e.msg?e.msg:O(e.msg)})])}function te(c,u){return function(e,t){var n,o,i,r=Array.isArray(e),a=r?e:[e],s=(c.lifeCycle.emit("beforeRequest",e),c.config.beforeRequest);(a="function"==typeof s?a.map(function(t){try{var e=s({logs:t,logType:u});return(null==e?void 0:e.logType)===u&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):a).length&&(n=a,e=V,!Array.isArray(n)||n.length<=1||(o=[],i=[],!(i="string"==typeof e?[e]:e))||i.length<=0||(i.forEach(function(t){n.forEach(function(e){null!=e&&e[t]&&o.push(t)})}),0<o.length&&(n=n.map(function(e){var t={};return o.forEach(function(e){t[e]=""}),E(E({},t),e)}))),a=n,t(r?a:a[0]))}}function ne(i){return function(e,t){i.lifeCycle.emit("modifyRequest",e);var n=i.config.modifyRequest;if("function"==typeof n)try{var o=n(e);"object"==typeof o&&"url"in o&&(e=o)}catch(e){console.error(e)}t(e)}}function oe(o){return function(e,t){null!=(n=o.lifeCycle)&&n.emit("afterRequest",e);var n=(o.config||{}).afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function m(n){if(n&&n.reduce&&n.length)return 1===n.length?function(e,t){n[0](e,t||Ee)}:n.reduce(function(n,o){return function(e,t){return void 0===t&&(t=Ee),n(e,function(e){return null==o?void 0:o(e,t)})}});throw new TypeError("createPipeline need at least one function param")}function ie(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function re(){return void 0!==window.performance&&"function"==typeof performance.clearResourceTimings&&"function"==typeof performance.getEntriesByType&&"function"==typeof performance.now}function ae(t,n){function o(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||(t(e),n&&(removeEventListener("visibilitychange",o,!0),removeEventListener("pagehide",o,!0)))}addEventListener("visibilitychange",o,!0),addEventListener("pagehide",o,!0)}function t(e){return-1!==Pe.indexOf(e)}var x,R,f,se=["application/xhtml+xml","application/xml","application/pdf","application/pkcs12","application/javascript","application/x-javascript","application/ecmascript","application/vnd.mspowerpoint","application/vnd.apple.mpegurl","application/ogg","text/css","text/javascript","image","audio","video","video/mp2t"],ce=/\.(json|js|css|jpg|jpeg|png|svg|apng|webp|gif|bmp|mp4|mp3|ts|mpeg|wav|webm|ogg|flv|m3u8|ttf|woff2|otf|eot|woff|html|htm|shtml|shtm|)$/gi,ue=["ret","retcode","code","errcode"],le=function(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}},O=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,le(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,le(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},fe=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,le())||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},de=function(n,o){void 0===o&&(o=3);var i,r,a,s="";return Array.isArray(n)?(s+="[",i=n.length,n.forEach(function(e,t){s=(s+="object"==typeof e&&1<o?de(e,o-1):he(e))+(t===i-1?"":",")}),s+="]"):n instanceof Object?(s="{",r=Object.keys(n),a=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<o?s+='"'+e+'":'+de(n[e],o-1):s+=pe(e,n[e]),s+=t===a-1||t<a-1&&void 0===n[r[t+1]]?"":","}),s+="}"):s+=n,s},pe=function(e,t){var n=typeof t,o="";return"string"==n||"object"==n?o+='"'+e+'":"'+t+'"':"function"==typeof t?o+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?o+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(o+='"'+e+'": '+t),o},he=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},ge=/data:(image|text|application|font)\/.*;base64/,me=((o=x=x||{}).INFO_ALL="-1",o.API_RESPONSE="1",o.INFO="2",o.ERROR="4",o.PROMISE_ERROR="8",o.AJAX_ERROR="16",o.SCRIPT_ERROR="32",o.IMAGE_ERROR="64",o.CSS_ERROR="128",o.CONSOLE_ERROR="256",o.MEDIA_ERROR="512",o.RET_ERROR="1024",o.REPORT="2048",o.PV="4096",o.EVENT="8192",o.PAGE_NOT_FOUND_ERROR="16384",o.WEBSOCKET_ERROR="32768",o.BRIDGE_ERROR="65536",o.LAZY_LOAD_ERROR="131072",(o=R=R||{}).LOG="log",o.SPEED="speed",o.PERFORMANCE="performance",o.OFFLINE="offline",o.WHITE_LIST="whiteList",o.VITALS="vitals",o.PV="pv",o.CUSTOM_PV="customPV",o.EVENT="event",o.CUSTOM="custom",o.SDK_ERROR="sdkError",o.SET_DATA="setData",o.LOAD_PACKAGE="loadPackage",(o=f=f||{}).production="production",o.development="development",o.gray="gray",o.pre="pre",o.daily="daily",o.local="local",o.test="test",o.others="others",function(e){return e.filter(function(n,o){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&o<t})})}),ve=function(e){e.level===x.INFO_ALL&&(e.level=x.INFO)},v={},y={},ye=function(e){return v[e]||(v[e]=setTimeout(function(){y[e]={},v[e]=null},6e4)),v[e]},we=function(e){return(Array.isArray(e)?e:[e]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:x.INFO,msg:""})})},be=function(o){return function(e){return o.sendPipeline([function(e,n){return n({url:o.config.url||"",data:J(we(e)),method:"post",contentType:"application/json",type:R.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=o.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])}})}],R.LOG)(e)}},Ee=function(){},o=(Object.defineProperty(w.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.37.5"},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),x},enumerable:!1,configurable:!0}),w.prototype.init=function(e){this.setConfig(e);for(var t=0;t<w.installedPlugins.length;t++)try{w.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},w.prototype.setConfig=function(e){Object.assign(this.config,e);var e=this.config,t=e.id,n=e.uin,o=e.version,i=e.ext1,r=e.ext2,a=e.ext3,s=e.aid,c=e.env,u=void 0===c?"production":c,c=e.pageUrl,e=this.bean.id!==t||this.bean.uin!==n||this.bean.aid!==s;return this.bean.id=t||"",this.bean.uin=n||"",this.bean.version=o||"1.37.5",this.bean.aid=s||"",this.bean.env=function(){switch(u){case f.production:case f.development:case f.gray:case f.pre:case f.daily:case f.local:case f.test:case f.others:return 1;default:return}}()?u:f.others,c&&this.extendBean("from",encodeURIComponent(c.slice(0,2048))),i&&this.extendBean("ext1",encodeURIComponent(i)),r&&this.extendBean("ext2",encodeURIComponent(r)),a&&this.extendBean("ext3",encodeURIComponent(a)),e&&this.lifeCycle.emit("onConfigChange",this.config),this.config},w.use=function(e){-1===w.installedPlugins.indexOf(e)&&e.aegisPlugin&&w.installedPlugins.push(e)},w.unuse=function(e){e=w.installedPlugins.indexOf(e);-1!==e&&w.installedPlugins.splice(e,1)},w.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:x.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,E({},e[0]),{level:x.INFO}),this.normalLogPipeline(n)},w.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:x.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,E({},e[0]),{level:x.INFO_ALL}),this.normalLogPipeline(n)},w.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:x.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,E({},e[0])),this.normalLogPipeline(n)},w.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:x.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,E({},e[0]),{level:x.ERROR}),this.normalLogPipeline(n)},w.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},w.prototype.reportPv=function(n){var o,i=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),o=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+i.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:i.config.url+"/"+n+"?"+o,addBean:!1,type:R.CUSTOM_PV})}],R.CUSTOM_PV)(null))},w.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?("string"!=typeof e.name&&(console.warn("reportEvent params name must be string"),e.name=String(e.name)),this.eventPipeline(e)):console.warn("reportEvent params error"))},w.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},w.prototype.reportT=function(e){var t=e.name,n=e.duration,o=e.ext1,o=void 0===o?"":o,i=e.ext2,i=void 0===i?"":i,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof i&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,i,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},w.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},w.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},w.prototype.submitCustomTime=function(e,t,n,o,i,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:o||this.config.ext2,ext3:i||this.config.ext3,from:r||void 0})},w.prototype.extendBean=function(e,t){this.bean[e]=t},w.prototype.sendPipeline=function(e,t){var n,r=this;return m(u([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},te(n=this,t)],e,[ne(this),function(o,i){r.request(o,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,i({isErr:!1,result:t,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(e=null==o?void 0:o.success)&&e.call.apply(e,u([o],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];60<=++r.failRequestCount&&r.destroy(),-1<(""+t[0]).indexOf("403 forbidden")&&r.destroy(),i({isErr:!0,result:t,logType:null==o?void 0:o.type,logs:null==o?void 0:o.log}),null!=(e=null==o?void 0:o.fail)&&e.call.apply(e,u([o],t))})},oe(this)]))},w.prototype.send=function(e,i,r){var t=this;return m([ne(this),function(n,o){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!1,result:e,logType:n.type,logs:n.log}),null!=i&&i.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o({isErr:!0,result:e,logType:n.type,logs:n.log}),null!=r&&r.apply(void 0,e)})},oe(this)])(e)},w.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},w.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},w.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(O(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.37.5)",addBean:!1,method:"get",type:R.SDK_ERROR,log:e})}],R.SDK_ERROR)(e)},w.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,o=w.instances.indexOf(this);-1!==o&&w.instances.splice(o,1);for(var i=w.installedPlugins.length-1;0<=i;i--)try{w.installedPlugins[i].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var r=this;r.constructor!==Object&&ie(r,this),r=Object.getPrototypeOf(r););0===w.instances.length&&(o=Object.getPrototypeOf(this).constructor,ie(o),ie(w))}},w.version="1.37.5",w.instances=[],w.logType=x,w.environment=f,w.installedPlugins=[],w),i=(a.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},a.prototype.unpatch=function(e){var t=this.instances.indexOf(e);-1!==t&&(this.instances.splice(t,1),0===this.instances.length)&&this.uninstall(e)},a.prototype.countInstance=function(){return this.instances.length},a.prototype.uninstall=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.destroy)&&t.apply(this,[e])},a.prototype.walk=function(n){var o=this;this.instances.forEach(function(e){var t=o.canUse(e);t&&n(e,t)})},a.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},a.prototype.getConfig=function(e){return null==(e=e.config)?void 0:e[this.name]},a.prototype.exist=function(e){return-1===this.instances.indexOf(e)},a.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null==(t=null==(t=this.option)?void 0:t.init))||t.call(this.option,this.getConfig(e))},a.prototype.triggerOnNewAegis=function(e){var t;null!=(t=null==(t=this.option)?void 0:t.onNewAegis)&&t.call(this.option,e,this.getConfig(e))},a),Re=new i({name:"aid",aid:"",init:function(e){try{var t=!0!==e&&e||window.localStorage.getItem("AEGIS_ID");t||(t=z(),window.localStorage.setItem("AEGIS_ID",t)),this.aid=t}catch(e){}},onNewAegis:function(e){e.bean.aid=this.aid,e.config.aid=this.aid}}),Oe=function(t){var n;return t.payload?(n={},Object.keys(t).forEach(function(e){"payload"!==e&&(n[e]=t[e])}),n):t},Se=new i({name:"reportAssetSpeed"}),Te=Se=new i({name:"reportAssetSpeed",collectCur:0,collectEntryType:"resource",ASSETS_INITIATOR_TYPE:["img","css","script","link","audio","video"],onNewAegis:function(e){var t=this;re()&&(this.collectSuccessLog(e),this.collectFailLog(e),performance.onresourcetimingbufferfull=function(){t.collectCur=0,performance.clearResourceTimings()})},publish:function(t,n){this.$walk(function(e){e===n&&e.speedLogPipeline(t)})},publishMany:function(e,t){for(var n=t.config,o=0,i=e.length;o<i;o++){var r=e[o];-1===this.ASSETS_INITIATOR_TYPE.indexOf(r.initiatorType)||l(r.name,n.hostUrl)||this.publish(this.generateLog(r,n),t)}},collectSuccessLog:function(n){var e,t,o=this;"function"==typeof window.PerformanceObserver?(this.publishMany(performance.getEntriesByType(this.collectEntryType),n),(e=new window.PerformanceObserver(function(e){o.publishMany(e.getEntries(),n)})).observe({entryTypes:[this.collectEntryType]}),n.lifeCycle.on("destroy",function(){0===Se.countInstance()&&e.disconnect()})):(t=setInterval(function(){var e=performance.getEntriesByType(o.collectEntryType),t=e.slice(o.collectCur);o.collectCur=e.length,o.publishMany(t,n)},3e3),n.lifeCycle.on("destroy",function(){0===Se.countInstance()&&clearInterval(t)}))},collectFailLog:function(o){function e(e){var t,n;e&&(e=e.target||e.srcElement,!(t=(null==e?void 0:e.src)||(null==e?void 0:e.href))||"string"!=typeof t||-1<window.location.href.indexOf(t)||(e="function"==typeof(null==(e=r.api)?void 0:e.resourceTypeHandler)?null==(e=r.api)?void 0:e.resourceTypeHandler(t):"",n=performance.getEntriesByType(i.collectEntryType).find(function(e){return e.name===t}),l(t,r.hostUrl))||(n={url:K(t),status:400,duration:Number(((null==n?void 0:n.duration)||0).toFixed(2)),method:"get",type:e||"static",isHttps:Q(t),urlQuery:P(t,!0),nextHopProtocol:"",domainLookup:0,connectTime:0},i.publish(n,o)))}var i=this,r=o.config;window.document.addEventListener("error",e,!0),o.lifeCycle.on("destroy",function(){0===Se.countInstance()&&window.document.removeEventListener("error",e,!0)})},generateLog:function(e,t){var t="function"==typeof(null==(n=t.api)?void 0:n.resourceTypeHandler)?null==(n=t.api)?void 0:n.resourceTypeHandler(e.name):"",n=e.transferSize;return{url:K(e.name),method:"get",duration:Number(e.duration.toFixed(2)),status:200,type:t||"static",isHttps:Q(e.name),nextHopProtocol:e.nextHopProtocol||"",urlQuery:P(e.name,!0),domainLookup:$(e.domainLookupEnd-e.domainLookupStart),connectTime:$(e.connectEnd-e.connectStart),transferSize:0<n?n:-1}},collectNotReportedLog:function(e){var t,n;re()&&(t=(n=performance.getEntriesByType(this.collectEntryType)).length,"function"!=typeof window.PerformanceObserver)&&this.collectCur!==t&&(n=n.slice(this.collectCur),this.collectCur=t,this.publishMany(n,e,!0))},destroy:function(){this.option.publish=function(){}}}),Pe=window.navigator.userAgent.toLowerCase(),r={};function a(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function w(e){var n,t,o,i,a,r,s,c,u,l,f,d,p,h,g=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new G,this.bean={},this.normalLogPipeline=m([Z(this,5),ee,function(e,t){var o=n.config;t(e=e.map(function(e){var t,n=o.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null==(t=e.msg)?void 0:t.substring(0,n)}catch(t){e.msg=O(e.msg).substring(0,o.maxLength)}return e}))},(h=(n=this).config,function(e,t){var n="number"==typeof h.repeat?h.repeat:60;if(n<=0)return t(e);var o=(null==h?void 0:h.id)+"_error",i=y[o]||{};t(e.filter(function(e){if(e.level===x.ERROR||e.level===x.PROMISE_ERROR||e.level===x.AJAX_ERROR||e.level===x.SCRIPT_ERROR||e.level===x.IMAGE_ERROR||e.level===x.CSS_ERROR||e.level===x.MEDIA_ERROR||e.level===x.RET_ERROR||e.level===x.BRIDGE_ERROR||e.level===x.PAGE_NOT_FOUND_ERROR||e.level===x.WEBSOCKET_ERROR||e.level===x.LAZY_LOAD_ERROR){e=e.msg.slice(0,200);if(i[e]>n)return v[o]||ye(o),!1;i[e]=1+~~i[e],y[o]=i}return!0}))}),(d=this.lifeCycle.emit,p=this.config,function(e,t){var n,o=p.logCreated;return"function"==typeof o?(n=e.filter(function(e){return!1!==o(e)}),d("beforeWrite",n),t(n)):(d("beforeWrite",e),t(e))}),(f=this,setTimeout(function(){var e=f.config,t=e.pvUrl,n=void 0===t?"":t,t=e.spa,e=-1<["web-sdk","mp-sdk"].indexOf("web-sdk");n&&(e&&!t||!e)&&f.sendPipeline([function(e,t){t({url:n,type:R.PV})}],R.PV)(null)},100),function(e,t){t(e)}),(u=c=s=!1,l=[],(a=this).lifeCycle.on("onConfigChange",function(){r&&clearTimeout(r),r=setTimeout(function(){var e,n;!u&&a.config&&(u=!0,e=a.config.whiteListUrl,(n=void 0===e?"":e)&&a.sendPipeline([function(e,t){t({url:n,type:R.WHITE_LIST,success:function(e){c=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,o=t.result,i=void 0===o?{}:o,r=(0===n&&(s=i.is_in_white_list,a.isWhiteList=s,0<=i.rate)&&i.rate<=1&&(a.config.random=i.rate,a.isGetSample=!1),a.isWhiteList&&l.length?be(a)(l.splice(0),function(){}):!a.isWhiteList&&l.length&&(l.length=0),a.config.onWhitelist);"function"==typeof r&&r(s)}catch(e){}},fail:function(){c=!0}})}],R.WHITE_LIST)(null),u=!1)},a.config.uin?50:500)}),a.lifeCycle.on("destroy",function(){l.length=0}),function(e,t){var n;s||null!=(n=null==(n=a.config)?void 0:n.api)&&n.reportRequest?t(e.concat(l.splice(0)).map(function(e){return ve(e),e})):(n=e.filter(function(e){return e.level!==x.INFO&&e.level!==x.API_RESPONSE?(ve(e),!0):(c||(l.push(e),200<=l.length&&(l.length=200)),!1)})).length&&t(n)}),function(e,t){try{var n=JSON.parse(JSON.stringify(e)),o=(g.lifeCycle.emit("beforeReport",n),g.config.beforeReport);(e="function"==typeof o?e.filter(function(e){return!1!==o(e)}):e).length&&t(e)}catch(e){}},be(this)]),this.eventPipeline=m([Z(this,10),(i=this,function(e){i.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||i.config.ext1||"",ext2:e.ext2||i.config.ext2||"",ext3:e.ext3||i.config.ext3||""}});t({url:i.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:R.EVENT,log:e})}],R.EVENT)(e)})]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=m([Z(this,10),(o=this,function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:R.CUSTOM,log:e})}],R.CUSTOM)(e)})]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),w.instances.push(this)}function Le(){return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,function(e){return(e^(16*Math.random()&15)>>e/4).toString(16)})}r.macos=function(){return t("mac")},r.ios=function(){return r.iphone()||r.ipod()||r.ipad()},r.iphone=function(){return!r.windows()&&t("iphone")},r.ipod=function(){return t("ipod")},r.ipad=function(){var e="MacIntel"===navigator.platform&&1<navigator.maxTouchPoints;return t("ipad")||e},r.android=function(){return!r.windows()&&t("android")},r.androidPhone=function(){return r.android()&&t("mobile")},r.androidTablet=function(){return r.android()&&!t("mobile")},r.blackberry=function(){return t("blackberry")||t("bb10")},r.blackberryPhone=function(){return r.blackberry()&&!t("tablet")},r.blackberryTablet=function(){return r.blackberry()&&t("tablet")},r.windows=function(){return t("windows")},r.windowsPhone=function(){return r.windows()&&t("phone")},r.windowsTablet=function(){return r.windows()&&t("touch")&&!r.windowsPhone()},r.fxos=function(){return(t("(mobile")||t("(tablet"))&&t(" rv:")},r.fxosPhone=function(){return r.fxos()&&t("mobile")},r.fxosTablet=function(){return r.fxos()&&t("tablet")},r.meego=function(){return t("meego")},r.cordova=function(){return window.cordova&&"file:"===location.protocol},r.nodeWebkit=function(){return"object"==typeof window.process},r.mobile=function(){return r.androidPhone()||r.iphone()||r.ipod()||r.windowsPhone()||r.blackberryPhone()||r.fxosPhone()||r.meego()},r.tablet=function(){return r.ipad()||r.androidTablet()||r.blackberryTablet()||r.windowsTablet()||r.fxosTablet()},r.desktop=function(){return!r.tablet()&&!r.mobile()},r.isIE=function(){return"ActiveXObject"in window};var xe={generateTraceId:Ce(16),generateSpanId:Ce(8)},ke=Array(32);function Ce(t){return function(){for(var e=0;e<2*t;e++)ke[e]=Math.floor(16*Math.random())+48,58<=ke[e]&&(ke[e]+=39);return String.fromCharCode.apply(null,ke.slice(0,2*t))}}function Ie(e){var t,n="";return n="object"==typeof e&&(t=(e=function(e,t){for(var n=0;n<t.length;n++){var o=t[n],i=e[o]||"function"==typeof e.get&&e.get(o);if(i)return[o,i]}return["",""]}(e,Object.keys(He)))[0],e=e[1],t)?He[t](e):n}function k(o,e,i){return null!=e&&e.length&&"object"==typeof o?e.reduce(function(e,t){var n=o instanceof Headers?o.get(t):o[t];return n?e+(""===e?"\n":"\n\n")+i+" header "+t+": "+n:e},""):""}var Ae,Ne,qe,Ue,s,_e,je,He={sw8:function(e){e=e.split("-")[1];return e?atob(e):""},traceparent:function(e){return e.split("-")[1]},b3:function(e){return e.split("-")[0]},"sentry-trace":function(e){return e.split("-")[0]}},Be=(p.prototype.generate=function(e,t){if(void 0===t&&(t={}),this.url=e,!this.isUrlIgnored()&&this.isUrlInTraceUrls()&&this.traceType){switch(this.traceType){case"traceparent":this.traceId=this.createTraceparent();break;case"b3":this.traceId=this.createB3();break;case"sw8":this.traceId=this.createSw8();break;case"sentry-trace":this.traceId=this.createSentryTrace();break;default:return console.warn("this trace key "+this.traceType+" is not supported"),void(this.traceId="")}return t[this.traceType]&&(this.traceId=t[this.traceType]),{name:this.traceType,value:this.traceId}}},p.prototype.createTraceparent=function(){var e=xe.generateSpanId();return"00-"+xe.generateTraceId()+"-"+e+"-0"+Number(1).toString(16)},p.prototype.createB3=function(){var e=xe.generateSpanId();return xe.generateTraceId()+"-"+e+"-1"},p.prototype.createSw8=function(){var e=new URL(location.href),t=z(),n=z();return"1-"+String(btoa(n))+"-"+String(btoa(t))+"-1-"+String(btoa("aegis"))+"-"+String(btoa("1.37.5"))+"-"+String(btoa(encodeURI(location.pathname)))+"-"+String(btoa(e.host))},p.prototype.createSentryTrace=function(){var e=Le().substring(16);return Le()+"-"+e+"-1"},p.prototype.isUrlIgnored=function(){if(Array.isArray(this.ignoreUrls)&&0!==this.ignoreUrls.length)for(var e=0,t=this.ignoreUrls;e<t.length;e++){var n=t[e];if(this.urlMatches(this.url,n))return!0}return!1},p.prototype.isUrlInTraceUrls=function(){if(!this.urls)return!0;if(Array.isArray(this.urls)){if(0===this.urls.length)return!1;for(var e=0,t=this.urls;e<t.length;e++){var n=t[e];if(this.urlMatches(this.url,n))return!0}}return!1},p.prototype.urlMatches=function(e,t){return"string"==typeof t?e===t:!!e.match(t)},p),De=!1,c=[],Fe=/^\/[^/]/,Me=!1,d=[],We=(new i({name:"reportApiSpeed"}),new i({name:"reportApiSpeed",override:!1,onNewAegis:function(e){var t,n;this.override||(null!=(n=e.config.api)&&n.injectTraceHeader&&(this.traceRequestHeader=new Be(n.injectTraceHeader,null!=(t=null==n?void 0:n.injectTraceIgnoreUrls)?t:[],null==n?void 0:n.injectTraceUrls)),this.override=!0,this.overrideFetch(e.config,e),this.overrideXhr(e.config,e))},getRequestType:function(e,t,n){void 0===t&&(t="");var o,i,e="function"==typeof(null==(i=e.api)?void 0:i.resourceTypeHandler)?null==(i=e.api)?void 0:i.resourceTypeHandler(n):"";return-1===X.indexOf(e)&&(o=void 0===t?"":t,i=(void 0===n?"":n).split("?")[0],e=ce.test(i)||se.some(function(e){return-1!==String(o).indexOf(e)})?"static":"fetch"),e},overrideFetch:function(m,v){var y=this,e=m.api,e={name:this.name,traceRequestHeader:null!=e&&e.injectTraceHeader?this.traceRequestHeader:null,then:function(f,d,p,h){var e,g;l(p,m.hostUrl)||(e=f.headers?f.headers.get("content-type"):"","fetch"===(g=y.getRequestType(m,e,p))?f.clone().text().then(function(n){var e,o=f.status<=0||400<=f.status,t=(null==(t=m.api)?void 0:t.reqHeaders)||[],i=k(null==h?void 0:h.headers,t,"req"),t=(null==(t=m.api)?void 0:t.resHeaders)||[],r=k(f.headers,t,"res"),a=Ie(null==h?void 0:h.headers),t=Y(n,m.api,{url:p,ctx:f,payload:null==h?void 0:h.body}),s=t.code,c=t.isErr,t=null==(t=m.api)?void 0:t.apiDetail,u=t?L(null==h?void 0:h.body,null==(e=m.api)?void 0:e.reqParamHandler,{url:p}):"",l=t?L(n,null==(e=m.api)?void 0:e.resBodyHandler,{url:p,ctx:f}):"";setTimeout(function(){var e=y.getPerformanceEntryByUrl(m,{url:p,duration:d,type:g,status:f.status||0,method:(null==h?void 0:h.method)||"get"}),t=(o?"FETCH_ERROR: "+n+" \n\n":"")+"fetch req url: "+p+" \n \nres status: "+(f.status||0)+" \n \nres duration: "+e.duration+"ms \n \nreq method: "+((null==h?void 0:h.method)||"get")+" \n \nres retcode: "+s+"\n \nreq param: "+u+"\n \nres data: "+l+"\n "+i+"\n "+r;e.payload=null==h?void 0:h.body,e.ret=s,e.isErr=+c,y.publishNormalLog({msg:t,level:o?x.AJAX_ERROR:c?x.RET_ERROR:x.API_RESPONSE,code:s,trace:a},v),y.publishSpeed(e,v)},0)}):setTimeout(function(){var e=y.getPerformanceEntryByUrl(m,{url:p,duration:d,type:g,status:f.status||0,method:(null==h?void 0:h.method)||"get"});e.type="static",e.urlQuery=P(p,!0),y.publishSpeed(e,v)},0))},catch:function(t,n,o,i){var r,e,a,s,c;throw l(o,m.hostUrl)||(r=y.getRequestType(m,"",o),e=(null==(e=m.api)?void 0:e.reqHeaders)||[],a=k(null==i?void 0:i.headers,e,"req"),s=Ie(null==i?void 0:i.headers),c=null!=(e=m.api)&&e.apiDetail?L(null==i?void 0:i.body,null==(e=m.api)?void 0:e.reqParamHandler,{url:o}):"",setTimeout(function(){var e=y.getPerformanceEntryByUrl(m,{url:o,duration:n,type:r,status:0,method:(null==i?void 0:i.method)||"get"}),e=(y.publishSpeed(e,v),"AJAX_ERROR: "+t+"\n \nreq url: "+o+"\n \nres status: 0\n \nres duration: "+e.duration+"ms\n \nreq method: "+((null==i?void 0:i.method)||"get")+"\n \nreq param: "+c+"\n "+a);y.publishNormalLog({msg:e,level:x.AJAX_ERROR,code:-400,trace:s},v)},0)),t}},u=(this.hackFetchOptions=e,this.hackFetchOptions);if(d.find(function(e){return e.name===u.name}))throw new Error("name '"+u.name+"' is already in hackFetch option list");d.push(u),!Me&&window.fetch&&(Me=!0,Ue=window.fetch,window.fetch=function(e,i){void 0===i&&(i={});var t,n,r="string"==typeof e?e:null==e?void 0:e.url,o=(Fe.test(r)&&(r=""+location.origin+r),(u||{}).traceRequestHeader);o&&(n=(i||{}).headers,t=(n=o.generate(r,o=void 0===n?{}:n)||{}).name,n=n.value)&&t&&(i.headers=Object.assign(o,((o={})[t]=n,o)));for(var a=0;a<d.length;a++){var s=d[a];try{"function"==typeof s.beforeFetch&&s.beforeFetch(r,i)}catch(e){}}var c=Date.now();return Ue(e,i).then(function(e){for(var t=e.clone(),n=0;n<d.length;n++){var o=d[n];try{"function"==typeof o.then&&o.then(t,Date.now()-c,r,i)}catch(e){}}return t}).catch(function(e){for(var t=0;t<d.length;t++){var n=d[t];try{"function"==typeof n.catch&&n.catch(e,Date.now()-c,r,i)}catch(e){}}throw e})})},overrideXhr:function(O,S){var t,T=this,e={name:this.name,send:function(E,R){var e,t,n=Date.now();((null==O?void 0:O.api)||{}).injectTraceHeader&&(e=(t=T.traceRequestHeader.generate(E.aegisUrl)||{}).name,t=t.value,e)&&t&&E.setRequestHeader(e,t),E.addEventListener("loadend",function(){var v,y,e,w,b=E.aegisUrl||"";l(b,O.hostUrl)||"abort"===E.failType||(v="",(E.failType||!E.status||400<=E.status)&&(v=E.failType||"failed"),y=Date.now()-n,e=E.getResponseHeader("content-type"),w=T.getRequestType(O,e,b),setTimeout(function(){var o=T.getPerformanceEntryByUrl(O,{url:b,duration:y,type:w,status:E.status,method:E.aegisMethod||"get"});if("fetch"===w){var e=(null==(e=O.api)?void 0:e.reqHeaders)||[],i=k(E.aegisXhrReqHeader,e,"req"),e=(null==(e=O.api)?void 0:e.resHeaders)||[],t=E.getAllResponseHeaders().split("\r\n").reduce(function(e,t){t=t.split(": ");return t[0]&&t[1]&&(e[t[0]]=t[1]),e},{}),r=k(t,e,"res"),a=Ie(E.aegisXhrReqHeader),e=null==(t=O.api)?void 0:t.apiDetail,s=e?L(R,null==(t=O.api)?void 0:t.reqParamHandler,{url:b}):"",c=e?L(E.response,null==(t=O.api)?void 0:t.resBodyHandler,{url:b}):"";try{var n,u,l,f,d=E.response,p=O.api,h={url:b,ctx:E,payload:R},g=function(e){var t=e.code,e=e.isErr,n=(v?"AJAX_ERROR: request "+v+" \n\n":"")+"fetch req url: "+b+" \n \nres status: "+o.status+"\n \nres duration: "+o.duration+"ms\n \nreq method: "+o.method+"\n \nres retcode: "+t+"\n \nreq param: "+s+"\n \nres data: "+c+"\n "+i+"\n "+r;o.ret=t,o.isErr=+e,o.payload=R,T.publishNormalLog({msg:n,level:v?x.AJAX_ERROR:e?x.RET_ERROR:x.API_RESPONSE,code:t,trace:a},S),T.publishSpeed(o,S)};try{if("function"==typeof(null==p?void 0:p.retCodeHandlerAsync))return void p.retCodeHandlerAsync(d,null==h?void 0:h.url,null==h?void 0:h.ctx,function(e){var t=e.code,e=e.isErr;null!=g&&g({code:void 0===t?"unknown":t,isErr:e})});if("function"==typeof(null==p?void 0:p.retCodeHandler))return void(l=(u=p.retCodeHandler(d,null==h?void 0:h.url,null==h?void 0:h.ctx,null==h?void 0:h.payload)||{}).code,f=u.isErr,null!=g&&g({code:void 0===l?"unknown":l,isErr:f}));if(!(d="string"==typeof d?JSON.parse(d):d))return void(null!=g&&g({code:"unknown",isErr:!1}));"function"==typeof(null==(n=null==p?void 0:p.ret)?void 0:n.join)&&(ue=[].concat(p.ret.map(function(e){return e.toLowerCase()})));var m=Object.getOwnPropertyNames(d).filter(function(e){return-1!==ue.indexOf(e.toLowerCase())});if(m.length)return void("未知"!==(l=d[m[0]])&&""!==l||(l="unknown"),null!=g&&g({code:""+l,isErr:0!==l&&"0"!==l&&"unknown"!==l}));null!=g&&g({code:"unknown",isErr:!1})}catch(d){null!=g&&g({code:"unknown",isErr:!1})}}catch(e){o.ret="unknown",T.publishSpeed(o,S)}}else o.type="static",o.urlQuery=P(b,!0),T.publishSpeed(o,S)},0))}),["abort","error","timeout"].map(function(e){E.addEventListener(e,function(){E.failType=e})})}};this.hackXHROptions=e,t=this.hackXHROptions,c.find(function(e){return e.name===t.name})||(c.push(t),!De&&window.XMLHttpRequest&&(Ae=window.XMLHttpRequest.prototype.send,Ne=window.XMLHttpRequest.prototype.open,qe=window.XMLHttpRequest.prototype.setRequestHeader,De=!0,window.XMLHttpRequest.prototype.open=function(){this.aegisMethod=arguments[0];var e=arguments[1];if(Fe.test(e)&&(e=""+location.origin+e),this.aegisUrl=e,this.aegisXhrStartTime=Date.now(),this.sendByAegis)r.isIE()||(this.timeout=5e3);else for(var t=0;t<c.length;t++){var n=c[t];try{"function"==typeof n.open&&n.open(this)}catch(e){}}return Ne.apply(this,arguments)},window.XMLHttpRequest.prototype.setRequestHeader=function(){var e,t=arguments[0],n=arguments[1];if(this.aegisXhrReqHeader=null!=(e=this.aegisXhrReqHeader)?e:{},!(-1<["traceparent","b3","sw8","sentry-trace"].indexOf(t)&&(this.aegisXhrReqHeader[t]||(arguments[1]=n),this.aegisXhrReqHeader[t])))return this.aegisXhrReqHeader[t]=arguments[1],qe.apply(this,arguments)},window.XMLHttpRequest.prototype.send=function(){if(!this.sendByAegis)for(var e=0;e<c.length;e++){var t=c[e];try{"function"==typeof t.send&&t.send(this,arguments[0])}catch(e){}}return Ae.apply(this,arguments)}))},getPerformanceEntryByUrl:function(e,t){if(null!=(e=e.api)&&e.usePerformanceTiming&&"string"==typeof t.url){e=null==(e=performance.getEntriesByName(t.url))?void 0:e.pop();if(e)return{url:t.url,isHttps:Q(t.url),method:t.method,type:t.type,status:t.status,duration:Number(e.duration.toFixed(2)),nextHopProtocol:e.nextHopProtocol||"",domainLookup:$(e.domainLookupEnd-e.domainLookupStart),connectTime:$(e.connectEnd-e.connectStart)}}return{url:t.url,isHttps:Q(t.url),method:t.method,type:t.type,status:t.status,duration:Number(t.duration.toFixed(2)),nextHopProtocol:"",domainLookup:n.number,connectTime:n.number}},publishSpeed:function(n){var o=this;this.$walk(function(e){var t=o.$getConfig(e);"fetch"===n.type&&t&&"function"==typeof t.urlHandler?e.speedLogPipeline(E(E({},n),{url:P(t.urlHandler(n.url,n.payload))})):(n.url=P(n.url),e.speedLogPipeline(n))})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},destroy:function(){var t,n,e;this.option.publishSpeed=function(){},this.option.publishNormalLog=function(){},this.option.hackXHROptions&&(t=this.option.hackXHROptions,-1!==(e=c.findIndex(function(e){return e.name===t.name})))&&c.splice(e,1),this.option.hackFetchOptions&&(n=this.option.hackFetchOptions,-1!==(e=d.findIndex(function(e){return e.name===n.name})))&&d.splice(e,1),this.option.override=!1}})),Ve={},Xe=new i({name:"reportBridgeSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.overrideBridge(e))},publishSpeed:function(t,n){this.$walk(function(e){e===n&&e.speedLogPipeline(t)})},overrideBridge:function(c){var u=this,l=c.config;l.reportBridgeSpeed&&l.h5Bridge&&l.h5BridgeFunc.length&&l.h5BridgeFunc.forEach(function(e){var s=l.h5Bridge[e];Ve[e]=s,l.h5Bridge[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=e[0],i=e[1],n=e[2],r=e[3],a=Date.now();s(o,i,n,function(e){var t=Y(e,l.api),n=t.code,t=t.isErr,n={url:o+"-"+i,name:o+"-"+i,duration:Date.now()-a,type:"bridge",ret:n,isErr:+t};u.publishSpeed(n,c),r(e)})}})},unHackBridge:function(t){Object.keys(Ve).forEach(function(e){Ve[e]&&(t.config.h5Bridge[e]=Ve[e])}),Ve={}},destroy:function(e){this.option.publishSpeed=function(){},this.option.unHackBridge(e),this.option.override=!1}});function p(e,t,n){void 0===n&&(n=null),this.traceType=e,this.ignoreUrls=t,this.urls=n}(T=s=s||{})[T.unknown=100]="unknown",T[T.wifi=1]="wifi",T[T.net2g=2]="net2g",T[T.net3g=3]="net3g",T[T.net4g=4]="net4g",T[T.net5g=5]="net5g",T[T.net6g=6]="net6g",(T=_e=_e||{})[T.android=1]="android",T[T.ios=2]="ios",T[T.windows=3]="windows",T[T.macos=4]="macos",T[T.linux=5]="linux",T[T.other=100]="other",(T=je=je||{})[T.unknown=100]="unknown",T[T.normal=0]="normal",T[T.weak=1]="weak",T[T.disconnected=2]="disconnected";function h(e,t,n,o){return void 0===n&&(n=15e3),void 0===o&&(o=0),(t=void 0===t?0:t)<=e&&e<=n?e:o}var g,b,Ge,Je,$e,S,Ke,Qe,Ye,T=new i({name:"device",onNewAegis:function(e){e.extendBean("platform",this.getPlatform()),e.extendBean("netType",s.unknown),this.getDpi(e),this.refreshNetworkTypeToBean(e),this.refreshNetworkStatusToBean(e)},getDpi:function(e){e.extendBean("vp",Math.round(window.innerWidth)+" * "+Math.round(window.innerHeight)),window.screen&&e.extendBean("sr",Math.round(window.screen.width)+" * "+Math.round(window.screen.height))},getPlatform:function(){var t={android:/\bAndroid\s*([^;]+)/,ios:/\b(iPad|iPhone|iPod)\b.*? OS ([\d_]+)/,windows:/\b(Windows NT)/,macos:/\b(Mac OS)/,linux:/\b(Linux)/i},e=Object.keys(t).find(function(e){return t[e].test(navigator.userAgent)});return e?_e[e]:_e.other},refreshNetworkTypeToBean:function(t){var n=this,e=t.config;e&&("function"==typeof e.getNetworkType?e.getNetworkType:ze)(function(e){s[e]||(e=s.unknown),t.extendBean("netType",e),n.NetworkRefreshTimer=setTimeout(function(){n.refreshNetworkTypeToBean(t),clearTimeout(n.NetworkRefreshTimer)},1e4)})},refreshNetworkStatusToBean:function(t){var e,n=this,o=t.config;o&&null!=(e="function"==typeof o.getNetworkStatus?o.getNetworkStatus:e)&&e(function(e){void 0===je[e]&&(e=je.unknown),t.extendBean("netStatus",e),n.NetworkStatusRefreshTimer=setTimeout(function(){n.refreshNetworkStatusToBean(t),clearTimeout(n.NetworkStatusRefreshTimer)},1e4)})}}),ze=function(e){var t="",n=navigator.userAgent.match(/NetType\/(\w+)/);n?t=n[1]:navigator.connection&&(t=navigator.connection.effectiveType||navigator.connection.type),e((n=t=t||"unknown",0<=(n=String(n).toLowerCase()).indexOf("4g")?s.net4g:0<=n.indexOf("wifi")?s.wifi:0<=n.indexOf("5g")?s.net5g:0<=n.indexOf("6g")?s.net6g:0<=n.indexOf("3g")?s.net3g:0<=n.indexOf("2g")?s.net2g:s.unknown))},Ze=window.WebSocket,C=[],et={construct:function(e,t){var a=new e(t[0],t[1]);return a.originSend=a.send,a.addEventListener("error",function(e){var e=(null==e?void 0:e.currentTarget)||{},t=e.url,n=e.readyState;null!=C&&C.forEach(function(e){e=e.onErr;null!=e&&e({msg:"无法获知具体错误信息,需在浏览器控制台查看!",readyState:n,connectUrl:t})})}),Object.defineProperty(a,"send",{get:function(){return function(e){null!=(t=a.originSend)&&t.call(a,e);var t=a.readyState,e=WebSocket.OPEN,n=WebSocket.CLOSED,o=WebSocket.CONNECTING,i=WebSocket.CLOSING;if(t!==e){var r={readyState:t,connectUrl:a.url};switch(t){case n:C.forEach(function(e){e=e.sendErr;null!=e&&e(E({msg:"消息发送失败,连接已关闭!"},r))});break;case o:C.forEach(function(e){(0,e.sendErr)(E({msg:"消息发送失败,正在连接中!"},r))});break;case i:C.forEach(function(e){(0,e.sendErr)(E({msg:"消息发送失败,连接正在关闭!"},r))})}}}}}),a}},tt=new i({name:"onError"}),nt=tt=new i({name:"onError",onNewAegis:function(e){this.startListen(e)},startListen:function(i){function e(e){(e=e&&O(e.reason))&&s.publishErrorLog({msg:"PROMISE_ERROR: "+e,level:x.PROMISE_ERROR},i)}function t(e){var t;if(e=(null==e?void 0:e.target)||(null==e?void 0:e.srcElement)){var n=e.src||e.href||"",e=e.tagName,e=void 0===e?"script":e;if(!(l(t=n,i.config.hostUrl)||-1<window.location.href.indexOf(t))){var o={msg:e+" load fail: "+n,level:x.INFO};if(/\.js$/.test(n))o.level=x.SCRIPT_ERROR;else if(/\.css$/.test(n))o.level=x.CSS_ERROR;else switch(e.toLowerCase()){case"script":o.level=x.SCRIPT_ERROR;break;case"link":o.level=x.CSS_ERROR;break;case"img":o.level=x.IMAGE_ERROR;break;case"audio":case"video":o.level=x.MEDIA_ERROR;break;default:return}s.publishErrorLog(o,i)}}}var n,o,r,a,s=this,c=window.onerror;window.onerror=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n,o=O(e[0]);"string"!=typeof(n=o)||!n||W.some(function(e){return-1<n.indexOf(e)})||M.some(function(e){return-1<n.indexOf(e)})||s.publishErrorLog({msg:(o||"")+" @ ("+(O(e[1])||"")+":"+(e[2]||0)+":"+(e[3]||0)+")\n \n"+O(e[4]||""),level:x.ERROR},i),null!=c&&c.call.apply(c,u([window],e))},window.addEventListener("unhandledrejection",e);window.document.addEventListener("error",t,!0),i.lifeCycle.on("destroy",function(){0===tt.countInstance()&&(window.document.removeEventListener("unhandledrejection",e),window.document.removeEventListener("error",t,!0))}),i.config.websocketHack&&(n={key:i.config.id+"-"+this.name,onErr:function(e){var t;null!=(t=s.publishWsErrorLog)&&t.call(s,e,i)},sendErr:function(e){var t;null!=(t=s.publishWsErrorLog)&&t.call(s,e,i)}},this.hackWebsocketConfig=n,n=this.hackWebsocketConfig,window.Proxy)&&window.WebSocket&&(o=window.WebSocket,window&&!o.isHack&&(r=new Proxy(WebSocket,et),o.isHack=!0,window.WebSocket=r),a=n,C.find(function(e){return e.key===a.key})||a&&C.push(a))},publishErrorLog:function(t,n){this.$walk(function(e){e===n&&e.normalLogPipeline(t)})},publishWsErrorLog:function(e,t){var n=e.connectUrl,o=e.msg,e=e.readyState;this.publishErrorLog({msg:"WEBSOCKET_ERROR: \n connect: "+n+"\n readyState: "+e+"\n msg: "+o,level:x.WEBSOCKET_ERROR},t)},destroy:function(){var t,e;this.option.publishErrorLog=function(){},this.option.hackWebsocketConfig&&(t=this.option.hackWebsocketConfig,window.WebSocket=Ze,-1!==(e=C.findIndex(function(e){return e.key===t.key})))&&C.splice(e,1)}}),ot=(new i({name:"pagePerformance"}),3),it=new i({name:"pagePerformance",onNewAegis:function(e){re()&&(g?this.publish(g,e):this.startCalcPerformance(e))},publish:function(e,t){var s=this;this.$walk(function(a){a===t&&a.sendPipeline([function(e,t){var n,o=[];for(n in e)o.push(n+"="+e[n]);var i,r=s.$getConfig(a);if(r)return i=-1===(null==(i=a.config.performanceUrl)?void 0:i.indexOf("?"))?"?":"&","function"==typeof r.urlHandler?t({url:a.config.performanceUrl+i+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:R.PERFORMANCE,log:e}):t({url:a.config.performanceUrl+i+o.join("&"),type:R.PERFORMANCE,log:e})}],R.PERFORMANCE)(e)})},startCalcPerformance:function(n){var o=this;try{this.getFirstScreenTiming(n,function(e){var t=performance.timing;t&&(g={dnsLookup:h(t.domainLookupEnd-t.domainLookupStart),tcp:h(t.connectEnd-t.connectStart),ssl:h(0===t.secureConnectionStart?0:t.requestStart-t.secureConnectionStart),ttfb:h(t.responseStart-t.requestStart),contentDownload:h(t.responseEnd-t.responseStart),domParse:h(t.domInteractive-t.domLoading,0,15e3,1070),resourceDownload:h(t.loadEventStart-t.domInteractive,0,15e3,1070),firstScreenTiming:h(Math.floor(e),0,15e3,15e3)},(t=n.config).extraPerformanceData&&"{}"!==JSON.stringify(t.extraPerformanceData)&&(t=(e=t.extraPerformanceData).engineInit,e=e.bundleLoad,g=E(E({},g),{engineInit:h(t,0,1e4),bundleLoad:h(e,0,1e4)})),o.publish(g,n))})}catch(n){}},getFirstScreenTiming:function(s,c){s.lifeCycle.on("destroy",function(){h&&clearTimeout(h)});var u=this,n=["script","style","link","br"],l=[],f={},d=new MutationObserver(function(e){var t={roots:[],rootsDomNum:[],time:performance.now()};e.forEach(function(e){e&&e.addedNodes&&e.addedNodes.forEach&&e.addedNodes.forEach(function(e){1===e.nodeType&&e.hasAttribute("AEGIS-FIRST-SCREEN-TIMING")?(Object.prototype.hasOwnProperty.apply(f,[t.time])||(f[t.time]=[]),f[t.time].push(e)):1!==e.nodeType||-1!==n.indexOf(e.nodeName.toLocaleLowerCase())||u.isEleInArray(e,t.roots)||e.hasAttribute("AEGIS-IGNORE-FIRST-SCREEN-TIMING")||(t.roots.push(e),t.rootsDomNum.push(u.walkAndCount(e)||0))})}),t.roots.length&&l.push(t)}),p=(d.observe(document,{childList:!0,subtree:!0}),function(o){(o=void 0===o?0:o)||(i=0,(e=Object.keys(f)).length?(o=Math.max.apply(null,e),("object"!=typeof(null==(e=s.config)?void 0:e.pagePerformance)||null!=(e=s.config.pagePerformance)&&e.firstScreenInfo)&&(s.firstScreenInfo={element:null==(e=f[o])?void 0:e[0],timing:o,markDoms:f})):l.forEach(function(e){for(var t,n=0;n<e.roots.length;n++)e.rootsDomNum[n]>i&&u.isInFirstScreen(e.roots[n])&&(i=e.rootsDomNum[n],o=e.time,"object"!=typeof(null==(t=s.config)?void 0:t.pagePerformance)||null!=(t=s.config.pagePerformance)&&t.firstScreenInfo)&&(s.firstScreenInfo={element:e.roots[n],timing:o})}),l.length=0,Object.keys(f).forEach(function(e){f[e]=f[e].map(function(e){var t={tagName:e.tagName},n=e.attributes;if(!n)return e;for(var o=0;o<n.length;o++){var i=n[o];i.name&&(t[i.name]=e.getAttribute(i.name))}return t})}));var i,e=performance.timing,t=e.domInteractive-e.domLoading,e=e.loadEventStart-e.domInteractive,n=o;h=null;for(var r=0,a=[t,e,n];r<a.length;r++)if(a[r]<=0&&0<ot){h=setTimeout(function(){return p(n)},3e3);break}h?--ot:(d.disconnect(),null!=c&&c(o))}),h=setTimeout(function(){return p()},3e3)},isEleInArray:function(e,t){return!(!e||e===document.documentElement)&&(-1!==t.indexOf(e)||this.isEleInArray(e.parentElement,t))},isInFirstScreen:function(e){var t,n;return!(!e||"function"!=typeof e.getBoundingClientRect)&&(e=e.getBoundingClientRect(),t=window.innerHeight,n=window.innerWidth,0<=e.left)&&e.left<n&&0<=e.top&&e.top<t&&0<e.width&&0<e.height},walkAndCount:function(e){var t=0;if(e&&1===e.nodeType){t+=1;var n=e.children;if(null!=n&&n.length)for(var o=0;o<n.length;o++)t+=this.walkAndCount(n[o])}return t}});function rt(){$e=[],Ge=-1,b=null,ct(addEventListener)}function at(e,t){b||(b=t,Ge=e,Je=new Date,ct(removeEventListener),st())}function st(){var t;0<=Ge&&Ge<Je-Ke&&(t={entryType:"first-input",name:b.type,target:b.target,cancelable:b.cancelable,startTime:b.timeStamp,processingStart:b.timeStamp+Ge},$e.forEach(function(e){e(t)}),$e=[])}function ct(t){["mousedown","keydown","touchstart","pointerdown"].forEach(function(e){return t(e,Qe,S)})}S={passive:!0,capture:!0},Ke=new Date,Qe=function(e){var t,n,o,i;function r(){at(n,o),i()}function a(){i()}e.cancelable&&(t=(1e12<e.timeStamp?new Date:performance.now())-e.timeStamp,"pointerdown"==e.type?(n=t,o=e,i=function(){removeEventListener("pointerup",r,S),removeEventListener("pointercancel",a,S)},addEventListener("pointerup",r,S),addEventListener("pointercancel",a,S)):at(t,e))},Ye="hidden"===document.visibilityState?0:1/0,addEventListener("visibilitychange",function e(t){"hidden"===document.visibilityState&&(Ye=t.timeStamp,removeEventListener("visibilitychange",e,!0))},!0),rt(),self.webVitals={firstInputPolyfill:function(e){$e.push(e),st()},resetFirstInputPolyfill:rt,get firstHiddenTime(){return Ye}};function I(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v1-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}}function ut(e,t){try{var n;if(PerformanceObserver.supportedEntryTypes.includes(e))if("first-input"!==e||"PerformanceEventTiming"in self)return(n=new PerformanceObserver(function(e){return e.getEntries().map(t)})).observe({type:e,buffered:!0}),n}catch(e){}}function lt(t){addEventListener("pageshow",function(e){e.persisted&&t(e)},!0)}function A(e,t,n){var o;return function(){0<=t.value&&(n||N.has(t)||"hidden"===document.visibilityState)&&(t.delta=t.value-(o||0),t.delta||void 0===o)&&(o=t.value,e(t))}}function ft(){vt(function(e){e=e.timeStamp;yt=e},!0)}function dt(){return yt<0&&((yt=self.webVitals.firstHiddenTime)===1/0&&ft(),lt(function(){setTimeout(function(){yt="hidden"===document.visibilityState?0:1/0,ft()},0)})),{get timeStamp(){return yt}}}function pt(e){var t=e.name;0<(e=e.value)&&(wt[t]=e)}function ht(e,h){function g(e){b=e}function m(e){y=y.concat(e)}function v(e,t){w={conds:e=void 0===e?{}:e,params:t=void 0===t?{}:t}}var y=[],w=null,b=null;q.useAsyncPlugin(e,{exportsConstructor:"Flog",onAegisInit:function(e){e.lifeCycle.on("beforeWrite",m),e.lifeCycle.on("uploadLogs",v),e.lifeCycle.on("onConfigChange",g)},onAegisInitAndPluginLoaded:function(o,e){var t,n,i,r,a,s,c=h.dbConfig,c=void 0===c?{}:c,u=h.url,u=void 0===u?q.urls.aegisCollect:u,l=h.offlineLogExp,l=void 0===l?3:l,f=h.id,d=h.uin,u=(null!=(t=o.lifeCycle)&&t.remove("beforeWrite",m),null!=(t=o.lifeCycle)&&t.remove("uploadLogs",v),null!=(t=o.lifeCycle)&&t.remove("onConfigChange",g),Object.assign({lookupUrl:u+"/offlineAuto?id="+f,preservedDay:l,id:f,uin:d,aid:(null==(t=o.bean)?void 0:t.aid)||"",beforeRequest:o.config.beforeRequest,afterRequest:o.config.afterRequest},c,{sessionId:q.sessionID}));try{var p=new e(u);y.forEach(function(e){p.add(E(E({},e),{level:e.level===x.INFO_ALL?x.INFO:e.level}))}),null!=(n=o.lifeCycle)&&n.on("beforeWrite",function(e){(e=void 0===e?[]:e).forEach(function(e){p.add(E(E({},e),{level:e.level===x.INFO_ALL?x.INFO:e.level}))})}),null!=(i=o.lifeCycle)&&i.on("uploadLogs",function(e,t){var n;void 0===e&&(e={}),void 0===t&&(t={}),p.uploadLogs(Object.assign({id:h.id,uin:h.uin,aid:null==(n=o.bean)?void 0:n.aid},e),t)}),null!=(r=o.lifeCycle)&&r.on("onConfigChange",function(e){p.setConfig(e)}),null!=(a=o.lifeCycle)&&a.on("destroy",function(){0===Rt.countInstance()&&(y.length=0,"function"==typeof((w=null)==p?void 0:p.destroy))&&p.destroy()}),p.on("PERREVENT",function(e){o.sendPipeline([function(e,t){n={msg:O(e),level:x.INFO};var n=(n=Array.isArray(n)?n:[n]).map(function(t,n){return Object.getOwnPropertyNames(t).map(function(e){return D(e)+"["+n+"]="+(void 0===t[e]?"":D(t[e]))}).join("&")}).join("&")+(n.length?"&count="+n.length:"");t({type:R.OFFLINE,data:n,contentType:"application/x-www-form-urlencoded",method:"post",addBean:!1,url:h.url+"?id=893&sessionId="+q.sessionID+"&uin="+h.uin+"&from="+h.id+"&count=1&version=1.37.5",log:e})}],R.OFFLINE)(e)}),b&&(p.setConfig(b),b=null),w&&(null!=(s=o.lifeCycle)&&s.emit("uploadLogs",w.conds,w.params),w=null),o.flog=p}catch(o){console.log(o)}}})}var gt,mt,vt=function(t,n){function o(e){"pagehide"!==e.type&&"hidden"!==document.visibilityState||(t(e),n&&(removeEventListener("visibilitychange",o,!0),removeEventListener("pagehide",o,!0)))}addEventListener("visibilitychange",o,!0),addEventListener("pagehide",o,!0)},N=new("function"==typeof WeakSet?WeakSet:Set),yt=-1,wt=(new i({name:"webVitals"}),{FCP:-1,LCP:-1,FID:-1,CLS:-1}),bt=new i({name:"webVitals",onNewAegis:function(e){if(re()&&"function"==typeof window.PerformanceObserver&&"function"==typeof performance.getEntriesByName)try{v=pt,w=dt(),b=I("FCP"),E=performance.getEntriesByName("first-contentful-paint")[0],R=E?null:ut("paint",T),(E||R)&&(y=A(v,b,void 0),E&&T(E),lt(function(e){b=I("FCP"),y=A(v,b,void 0),requestAnimationFrame(function(){requestAnimationFrame(function(){b.value=performance.now()-e.timeStamp,N.add(b),y()})})})),f=pt,h=dt(),g=I("LCP"),(m=ut("largest-contentful-paint",S))&&(d=A(f,g,void 0),p=function(){N.has(g)||(m.takeRecords().map(S),m.disconnect(),N.add(g),d())},["keydown","click"].forEach(function(e){addEventListener(e,p,{once:!0,capture:!0})}),vt(p,!0),lt(function(e){g=I("LCP"),d=A(f,g,void 0),requestAnimationFrame(function(){requestAnimationFrame(function(){g.value=performance.now()-e.timeStamp,N.add(g),d()})})})),a=pt,s=dt(),c=I("FID"),u=ut("first-input",O),l=A(a,c,void 0),u&&vt(function(){u.takeRecords().map(O),u.disconnect()},!0),u||window.webVitals.firstInputPolyfill(O),lt(function(){c=I("FID"),l=A(a,c,void 0),window.webVitals.resetFirstInputPolyfill(),window.webVitals.firstInputPolyfill(O)}),n=pt,i=I("CLS",0),(r=ut("layout-shift",t))&&(o=A(n,i,void 0),vt(function(){r.takeRecords().map(t),o()}),lt(function(){i=I("CLS",0),o=A(n,i,void 0)})),ae(this.publish.bind(this,e),!0)}catch(e){}function t(e){e.hadRecentInput||(i.value+=e.value,i.entries.push(e),o())}var n,o,i,r,a,s,c,u,l,f,d,p,h,g,m,v,y,w,b,E,R;function O(e){e.startTime<s.timeStamp&&(c.value=e.processingStart-e.startTime,c.entries.push(e),N.add(c),l())}function S(e){var t=e.startTime;t<h.timeStamp&&(g.value=t,g.entries.push(e)),d()}function T(e){"first-contentful-paint"===e.name&&(R&&R.disconnect(),e.startTime<w.timeStamp)&&(b.value=e.startTime,b.entries.push(e),N.add(b),y())}},publish:function(t){this.$walk(function(r){var e;r===t&&null!=(e=r.sendPipeline)&&e.call(r,[function(e,t){var n,o=[];for(n in e)o.push(n+"="+e[n]);var i=-1===(null==(i=null==(i=r.config)?void 0:i.performanceUrl)?void 0:i.indexOf("?"))?"?":"&";t({url:r.config.webVitalsUrl+i+o.join("&"),type:R.VITALS,log:e,sendBeacon:!0})}],R.VITALS)(wt)})},destroy:function(){this.option.publish=function(){}}}),Et=0,q=(B(mt=U,o=gt=o),mt.prototype=null===o?Object.create(o):(Tt.prototype=o.prototype,new Tt),U.prototype.getBean=function(t){var n=this;return void 0===t&&(t=[]),""+Object.getOwnPropertyNames(this.bean).filter(function(e){return-1===t.indexOf(e)}).map(function(e){return"from"===e?"from="+n.getCurrentPageUrl():e+"="+n.bean[e]}).join("&")},U.prototype.getCurrentPageUrl=function(){var e=this.config.pageUrl||location.href,e=(e="function"==typeof this.config.urlHandler?this.config.urlHandler():e).slice(0,2048);return encodeURIComponent(e)},U.prototype.ready=function(){function r(){var e,n,o,i;t.reportRequestQueue.length&&(e=t.reportRequestQueue.splice(0,1)[0],n=e.options,o=e.success,i=e.fail,t.$request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return null==o?void 0:o.apply(n,e)}finally{r()}},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return null==i?void 0:i.apply(n,e)}finally{r()}}))}var t=this;r(),this.isReportReady=!0},U.prototype.request=function(e,t,n){this.config.reportImmediately||this.isReportReady?this.$request(e,t,n):this.reportRequestQueue.push({options:e,success:t,fail:n})},U.prototype.$request=function(e,t,n){var o,i,r,a;if(e&&"string"==typeof e.url&&""!==e.url&&this.bean.id)return a=e.url,!1!==e.addBean&&(a=a+(-1===a.indexOf("?")?"?":"&")+this.getBean(e.beanFilter)),e.url=a,a=e.method||"get",(e=(i=this.config.onBeforeRequest)?i(e,this):e)?e.url?void((null!=e&&e.sendBeacon||this.sendNow)&&"function"==typeof(null===navigator||void 0===navigator?void 0:navigator.sendBeacon)?navigator.sendBeacon(e.url,e.data):((o=new XMLHttpRequest).sendByAegis=!0,o.addEventListener("readystatechange",function(){4===o.readyState&&(400<=o.status||0===o.status?null!=n&&n(o.response):null!=t&&t(o.response))}),"get"===a.toLocaleLowerCase()?(o.open("get",(i=e.url,r=e.data,"string"!=typeof i?"":"object"==typeof r&&r?(a=Object.getOwnPropertyNames(r).map(function(e){var t=r[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI"),i+(-1===i.indexOf("?")?"?":"&")+a):i)),o.send()):(o.open("post",e.url),e.contentType&&o.setRequestHeader("Content-Type",e.contentType),"string"==typeof e.data&&(e.data=e.data.replace(/eval/gi,"evaI")),o.send(e.data)))):console.warn("Please handle the parameters reasonably, options.url is necessary"):console.warn("Sending request blocked")},U.useAsyncPlugin=function(a,e){var t=(e=void 0===e?{}:e).exportsConstructor,s=void 0===t?"aegis-plugin-"+Et:t,t=e.onAegisInit,c=void 0===t?function(){}:t,t=e.onAegisInitAndPluginLoaded,u=void 0===t?function(){}:t;if(Et+=1,"string"!=typeof a)throw new TypeError("useAsyncPlugin first param must be string");if("function"!=typeof c||"function"!=typeof u)throw new TypeError("onAegisInit and onAegisInitAndPluginLoaded must be function");this.use(new i({name:"asyncPlugin",onNewAegis:function(t){try{c(t),U.asyncPlugin[a]?u(t,window[U.asyncPlugin[a]]):(e=a,n=s,o=function(e){e||(U.asyncPlugin[a]=s,e=window[s],u(t,e))},i=document.createElement("script"),r=document.head,"function"==typeof n&&(o=n,n=""),i.src=e,i.setAttribute("name",n),i.name=n,i.setAttribute("crossorigin","anonymous"),i.crossorigin="anonymous",i.defer=!0,i.hasLoaded=!1,i.onreadystatechange=function(){i.hasLoaded||i.readyState&&"loaded"!==i.readyState&&"complete"!==i.readyState||(i.hasLoaded=!0,"function"==typeof o&&o(!1),setTimeout(function(){r.contains(i)&&r.removeChild(i)}))},i.onload=i.onreadystatechange,i.onerror=function(){"function"==typeof o&&o(!0),setTimeout(function(){r.contains(i)&&r.removeChild(i)})},"complete"===document.readyState?r.appendChild(i):window.addEventListener("load",function(){r.appendChild(i)}))}catch(e){console.log("error on below is caused by "+a+" "),console.error(e)}var e,n,o,i,r}}))},U.prototype.publishPluginsLogs=function(){var e=U.installedPlugins.find(function(e){return"reportAssetSpeed"===e.name});null!=e&&e.option.collectNotReportedLog(this)},U.prototype.uploadLogs=function(e,t){var n;void 0===e&&(e={}),void 0===t&&(t={}),null!=(n=this.lifeCycle)&&n.emit("uploadLogs",e,t)},U.sessionID="session-"+Date.now(),U.asyncPlugin={},U.urls={aegisCollect:"https://aegis.qq.com/collect",flog:"https://cdn-go.cn/vasdev/web_webpersistance_v2/v1.8.2/flog.core.min.js"},U),Rt=new i({name:"offlineLog"}),o=Rt=new i({name:"offlineLog",onNewAegis:function(e){ht(q.urls.flog,e.config)}}),Ot=(new i({name:"spa"}),["replaceState","pushState","popstate","hashchange"]),St=new i({name:"spa",originFireUrl:"",onNewAegis:function(t){var n=this;history.pushState=this.wr("pushState")||history.pushState,history.replaceState=this.wr("replaceState")||history.replaceState,this.sendPv=this.sendPv.bind(this),t.config.spa&&this.sendPv(t),Ot.forEach(function(e){return window.addEventListener(e,function(){return n.sendPv.call(n,t)})})},wr:function(n){var o=history[n],e="__"+n+"__hasWrittenByTamSpa";return"function"==typeof o&&!history[e]&&(Object.defineProperty(history,e,{value:!0,enumerable:!1}),function(){var e=o.apply(this,arguments),t=null;return"function"==typeof Event?t=new Event(n):(t=document.createEvent("HTMLEvents")).initEvent(n,!1,!0),window.dispatchEvent(t),e})},sendPv:function(i){var r=this;setTimeout(function(){var o=location.href,t=location.pathname+location.hash+i.config.id;r.$walk(function(e){var n;e===i&&(n=e.config.pvUrl)&&t&&t!==r.originFireUrl&&(e.sendPipeline([function(e,t){t({url:n+"?from="+encodeURIComponent(o),beanFilter:["from"],type:R.PV})}],R.PV)(null),r.originFireUrl=t)})},0)},destroy:function(){this.option.sendPv=function(){}}});function U(e){var t,n,o,a,s=gt.call(this,e)||this;s.sendNow=!1,s.isReportReady=!1,s.reportRequestQueue=[],s.speedLogPipeline=m([Z(s),(a=s.config,function(e,t){var n,o,i,r="number"==typeof a.repeat?a.repeat:60;!a.speedSample||r<=0?t(e):(n=(null==a?void 0:a.id)||"0",o=y[n]||{},Array.isArray(e)?(i=e.filter(function(e){var t=!o[e.url]||o[e.url]<r;return t?(o[e.url]=1+~~o[e.url],y[n]=o):v[n]||ye(n),t})).length&&t(i):!o[e.url]||o[e.url]<r?(o[e.url]=1+~~o[e.url],y[n]=o,t(e)):v[n]||ye(n))}),(o=s,function(t,n){ze(function(e){o.extendBean("netType",e),n(t)})}),function(e,t){null!=(n=s.lifeCycle)&&n.emit("beforeReportSpeed",e);var n,o=s.config.beforeReportSpeed;if((e="function"==typeof o?e.filter(function(e){return!1!==o(e)}):e).length)return t(e)},function(e,t){t(e.map(function(e){return void 0!==e.payload&&delete e.payload,e}))},function(e){return s.sendPipeline([function(e,t){var n,o,i,r;t({type:R.SPEED,url:""+s.config.speedUrl,method:"post",data:(t=e,n=E(E({},s.bean),{from:s.getCurrentPageUrl()}),i={fetch:[],static:[],bridge:[]},r=new FormData,Array.isArray(t)?t.forEach(function(e){var t=Oe(e);i[e.type].push(t)}):(o=Oe(t),i[t.type].push(o)),r.append("payload",fe(E({duration:i},n))),r),log:e})}],R.SPEED)(e)}]),e.asyncPlugin=!0;try{"undefined"!=typeof document&&(e.uin=e.uin||(null!=(t=document.cookie.match(/\buin=\D+(\d*)/))?t:[])[1]||(null!=(n=document.cookie.match(/\bilive_uin=\D*(\d+)/))?n:[])[1]||""),s.init(e),s.extendBean("sessionId",U.sessionID),s.extendBean("from",s.getCurrentPageUrl()),"undefined"!=typeof document&&s.extendBean("referer",encodeURIComponent(document.referrer||"")),e.ext1&&s.extendBean("ext1",encodeURIComponent(e.ext1)),e.ext2&&s.extendBean("ext2",encodeURIComponent(e.ext2)),e.ext3&&s.extendBean("ext3",encodeURIComponent(e.ext3))}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),s.sendSDKError(e)}return s}function Tt(){this.constructor=mt}new i({name:"ie"}),new i({name:"onClose"});var Pt=new i({name:"onClose",onNewAegis:function(n){var o,i=this;r.desktop()?(o=window.onunload,window.onunload=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.publishNotReportedLog(n),null!=o&&o.call.apply(o,u([window],e))}):ae(this.publishNotReportedLog.bind(this,n),!0)},publishNotReportedLog:function(t){var n=this;this.$walk(function(e){e===t&&(e.sendNow=!0,e.publishPluginsLogs(),n.publishThrottlePipeLogs(e))})},publishThrottlePipeLogs:function(e){null!=e&&e.speedLogPipeline([]),null!=e&&e.eventPipeline([]),null!=e&&e.customTimePipeline([]),null!=e&&e.normalLogPipeline([])}});return new i({name:"aid"}),q.use(nt),q.use(We),q.use(Te),q.use(it),q.use(bt),q.use(Re),q.use(T),q.use(o),q.use(St),q.use(Pt),q.use(Xe),q}();