@datarangers/sdk-javascript 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/es/index.min.js +1 -0
- package/core/lib/index.min.js +1 -0
- package/es/index-base.min.js +1 -1
- package/es/index.min.js +1 -1
- package/es/plugin/ab.js +1 -1
- package/es/plugin/autotrack.js +1 -1
- package/es/plugin/duration.js +1 -1
- package/es/plugin/route.js +1 -1
- package/es/plugin/stay.js +1 -1
- package/lib/index-base.min.js +1 -1
- package/lib/index.min.js +1 -1
- package/lib/plugin/ab.js +1 -1
- package/lib/plugin/autotrack.js +1 -1
- package/lib/plugin/duration.js +1 -1
- package/lib/plugin/route.js +1 -1
- package/lib/plugin/stay.js +1 -1
- package/package.json +2 -2
package/lib/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Object.defineProperty(exports,"__esModule",{value:!0});var e,i=function(){function e(){t(this,"_hooks",void 0),t(this,"_cache",void 0),t(this,"_hooksCache",void 0),this._hooks={},this._cache=[],this._hooksCache={}}var i=e.prototype;return i.on=function(t,e){t&&e&&"function"==typeof e&&(this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e))},i.once=function(t,e){var i=this;if(t&&e&&"function"==typeof e){var n=function(o){e(o),i.off(t,n)};this.on(t,n)}},i.off=function(t,e){if(t&&this._hooks[t]&&this._hooks[t].length)if(e){var i=this._hooks[t].indexOf(e);-1!==i&&this._hooks[t].splice(i,1)}else this._hooks[t]=[]},i.emit=function(t,e,i){if(i){if(!t)return;-1!==this._cache.indexOf(i)?this._emit(t,e):(this._hooksCache.hasOwnProperty(i)||(this._hooksCache[i]={}),this._hooksCache[i].hasOwnProperty(t)||(this._hooksCache[i][t]=[]),this._hooksCache[i][t].push(e))}else this._emit(t,e)},i._emit=function(t,e){t&&this._hooks[t]&&this._hooks[t].length&&[].concat(this._hooks[t]).forEach(function(t){try{t(e)}catch(t){}})},i.set=function(t){t&&-1===this._cache.indexOf(t)&&this._cache.push(t)},e}(),n=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},o=function(t){return Array.isArray(t)},r=(e=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return e+=1}),s=function(t){return function(t,e,i){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i){var n,o=[];i=i<=25?i:i%25;var r=String.fromCharCode(i+97);n=t.split(r);for(var s=0;s<n.length;s++){var a=parseInt(n[s],i);a=1*a^e;var c=String.fromCharCode(a);o.push(c)}return o.join("")}}(t,64,25)},a=function(t){!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)},c=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach(function(e){void 0!==document[e]&&(t=1)}),t},h=function(t){var e=document.createElement("a");return e.href=t,e},l=function(t){var e={};try{var i=h(t).search;(i=i.slice(1)).split("&").forEach(function(t){var i,n,o=t.split("=");o.length&&(i=o[0],n=o[1]);try{e[i]=decodeURIComponent(void 0===n?"":n)}catch(t){e[i]=n}})}catch(t){}return e},u=function(t){for(var e=0,i=0,n=(t+="").length,o=0;o<n;o++)((e=31*e+t.charCodeAt(i++))>0x7fffffffffff||e<-0x800000000000)&&(e&=0xffffffffffff);return e<0&&(e+=0x7ffffffffffff),e};var f=function(t){var e,i,n=[],o=t.length;o%2!=0&&(i=o+1,t=(e=t).length>=i?e:new Array(i-e.length+1).join("0")+e),o=t.length;for(var r=0;r<o;r+=2)n.push(parseInt(t.substr(r,2),16));return n},d=function(){var t=window.navigator.appName,e=window.navigator.userAgent;return-1!==t.indexOf("Microsoft Internet Explorer")&&(-1!==e.indexOf("MSIE 8.0")||-1!==e.indexOf("MSIE 7.0")||-1!==e.indexOf("MSIE 9.0"))},p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t,e){return t(e={exports:{}},e.exports),e.exports}var m=g(function(t,e){var i;i=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var i=arguments[t];for(var n in i)e[n]=i[n]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(n){function o(){}function r(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=t({path:"/"},o.defaults,r)).expires&&(r.expires=new Date(1*new Date+864e5*r.expires)),r.expires=r.expires?r.expires.toUTCString():"";try{var s=JSON.stringify(i);/^[\{\[]/.test(s)&&(i=s)}catch(t){}i=n.write?n.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in r)r[c]&&(a+="; "+c,!0!==r[c]&&(a+="="+r[c].split(";")[0]));return document.cookie=e+"="+i+a}}function s(t,i){if("undefined"!=typeof document){for(var o={},r=document.cookie?document.cookie.split("; "):[],s=0;s<r.length;s++){var a=r[s].split("="),c=a.slice(1).join("=");i||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var h=e(a[0]);if(c=(n.read||n)(c,h)||e(c),i)try{c=JSON.parse(c)}catch(t){}if(o[h]=c,t===h)break}catch(t){}}return t?o[t]:o}}return o.set=r,o.get=function(t){return s(t,!1)},o.getJSON=function(t){return s(t,!0)},o.remove=function(e,i){r(e,"",t(i,{expires:-1}))},o.defaults={},o.withConverter=i,o}(function(){})},t.exports=i()}),v=function(){function e(){t(this,"cache",void 0),this.cache={}}var i=e.prototype;return i.setItem=function(t,e){this.cache[t]=e},i.getItem=function(t){return this.cache[t]},i.removeItem=function(t){this.cache[t]=void 0},e}(),_=function(){function e(){t(this,"support",void 0),this.support=this.isSupportLS()}var i=e.prototype;return i.isSupportLS=function(){try{return localStorage.setItem("_applogtest-test-key","hi"),localStorage.getItem("_applogtest-test-key"),localStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},i.getItem=function(t){try{var e=localStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},i.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},i.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},e}(),y=function(){function e(){t(this,"support",void 0),this.support=this.isSupportSession()}var i=e.prototype;return i.isSupportSession=function(){try{return sessionStorage.setItem("_applogtest-test-key","hi"),sessionStorage.getItem("_applogtest-test-key"),sessionStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},i.getItem=function(t){try{var e=sessionStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},i.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},i.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},e}(),b=function(){function e(){t(this,"local",void 0),t(this,"session",void 0),t(this,"cache",void 0),t(this,"defaultExpireTime",void 0),this.defaultExpireTime=6048e5,this.local=new _,this.session=new y,this.cache=new v}var i=e.prototype;return i.getLocalItem=function(t){return this.local.getItem(t)},i.setLocalItem=function(t,e){this.local.setItem(t,e)},i.removeLocalItem=function(t){this.local.removeItem(t)},i.getSessionItem=function(t){return this.session.getItem(t)},i.setSessionItem=function(t,e){this.session.setItem(t,e)},i.removeSessionItem=function(t){this.session.removeItem(t)},i.getCacheItem=function(t){return this.cache.getItem(t)},i.setCacheItem=function(t,e){this.cache.setItem(t,e)},i.removeCacheItem=function(t){this.cache.removeItem(t)},i.getCookie=function(t,e){try{return m.get(t)}catch(t){return""}},i.setCookie=function(t,e,i,n){void 0===i&&(i=this.defaultExpireTime);try{var o=n||document.domain,r=+new Date+i;m.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},i.removeCookie=function(t,e){try{m.remove(t,{path:"/",domain:e||""})}catch(t){}},e}(),E=function(){function e(e,i,n){t(this,"appid",void 0),t(this,"domain",void 0),t(this,"userAgent",void 0),t(this,"appVersion",void 0),t(this,"utm",void 0),t(this,"cookie_expire",void 0),this.appid=e,this.domain=i,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=n}var i=e.prototype;return i.init=function(){var t=window.navigator.userAgent,e=window.navigator.language,i=document.referrer,n=i?h(i).hostname:"",o=l(window.location.href),r=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(t,e,i,n){var o=new b,r=t?"_tea_utm_cache_"+t:"_tea_utm_cache",s=t?"_$utm_from_url_"+t:"_$utm_from_url",a={},c=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],h={ad_id:Number(e.ad_id)||void 0,campaign_id:Number(e.campaign_id)||void 0,creative_id:Number(e.creative_id)||void 0,utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content,tr_shareuser:e.tr_shareuser,tr_admaster:e.tr_admaster,tr_param1:e.tr_param1,tr_param2:e.tr_param2,tr_param3:e.tr_param3,tr_param4:e.tr_param4};try{var l=!1;for(var u in h)h[u]&&(-1!==c.indexOf(u)?(a.hasOwnProperty("tracer_data")||(a.tracer_data={}),a.tracer_data[u]=h[u]):a[u]=h[u],l=!0);if(l)o.setSessionItem(s,"1"),o.setCookie(r,JSON.stringify(a),n,i);else{var f=o.getCookie(r,i);f&&(a=JSON.parse(f))}o.getSessionItem(s)&&(a.hasOwnProperty("tracer_data")||(a.tracer_data={}),a.tracer_data.$utm_from_url=1)}catch(t){return h}return a}(this.appid,o,this.domain,this.cookie_expire);var s=this.browser(),a=this.os();return{browser:s.browser,browser_version:s.browser_version,platform:r,os_name:a.os_name,os_version:a.os_version,userAgent:t,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(a.os_name),language:e,referrer:i,referrer_host:n,utm:this.utm,latest_data:this.last(i,n)}},i.last=function(t,e){var i="",n="",o="",r=location.hostname,s=!1;if(t&&e&&r!==e){i=t,n=e,s=!0;var a=l(t);a.keyword&&(o=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:n,$latest_search_keyword:o,isLast:s}},i.browser=function(){var t,e,i="",n=""+parseFloat(this.appVersion),o=this.userAgent;return-1!==o.indexOf("Edge")||-1!==o.indexOf("Edg")?(i="Microsoft Edge",-1!==o.indexOf("Edge")?(t=o.indexOf("Edge"),n=o.substring(t+5)):(t=o.indexOf("Edg"),n=o.substring(t+4))):-1!==(t=o.indexOf("MSIE"))?(i="Microsoft Internet Explorer",n=o.substring(t+5)):-1!==(t=o.indexOf("Lark"))?(i="Lark",n=o.substring(t+5,t+11)):-1!==(t=o.indexOf("MetaSr"))?(i="sougoubrowser",n=o.substring(t+7,t+10)):-1!==o.indexOf("MQQBrowser")||-1!==o.indexOf("QQBrowser")?(i="qqbrowser",-1!==o.indexOf("MQQBrowser")?(t=o.indexOf("MQQBrowser"),n=o.substring(t+11,t+15)):-1!==o.indexOf("QQBrowser")&&(t=o.indexOf("QQBrowser"),n=o.substring(t+10,t+17))):-1!==o.indexOf("Chrome")?-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("360"))?(i="360browser",n=o.substring(o.indexOf("Chrome")+7)):-1!==o.indexOf("baidubrowser")||-1!==o.indexOf("BIDUBrowser")?(-1!==o.indexOf("baidubrowser")?(t=o.indexOf("baidubrowser"),n=o.substring(t+13,t+16)):-1!==o.indexOf("BIDUBrowser")&&(t=o.indexOf("BIDUBrowser"),n=o.substring(t+12,t+15)),i="baidubrowser"):-1!==(t=o.indexOf("xiaomi"))?-1!==o.indexOf("openlanguagexiaomi")?(i="openlanguage xiaomi",n=o.substring(t+7,t+13)):(i="xiaomi",n=o.substring(t-7,t-1)):-1!==(t=o.indexOf("TTWebView"))?(i="TTWebView",n=o.substring(t+10,t+23)):(-1!==(t=o.indexOf("Chrome"))||-1!==(t=o.indexOf("Chrome")))&&(i="Chrome",n=o.substring(t+7)):-1!==o.indexOf("Safari")?-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+10,t+16)):-1!==(t=o.indexOf("Safari"))&&(i="Safari",n=o.substring(t+7),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))):-1!==(t=o.indexOf("Firefox"))?(i="Firefox",n=o.substring(t+8)):-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+3,t+8)):-1!==(t=o.indexOf("Opera"))&&(i="Opera",n=o.substring(t+6),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))),-1!==(e=n.indexOf(";"))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(" "))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(")"))&&(n=n.substring(0,e)),{browser:i,browser_version:n}},i.os=function(){for(var t="",e="",i=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],n=0;n<i.length;n++){var o=i[n];if(o.r.test(this.userAgent)){"Mac OS X"===(t=o.s)&&this.isNewIpad()&&(t="iOS");break}}var r=function(t,e){var i=t.exec(e);return i&&i[1]?i[1]:""},s=function(t,e){var i=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+t+")","i").exec(e);return i?i.slice(1)[0]:""};/Windows/.test(t)&&(e=r(/Windows (.*)/,t),t="windows");var a,c;switch(t){case"Mac OS X":e=s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),t="mac";break;case"Android":a=this.userAgent,(c=r(/Android ([\.\_\d]+)/,a))||(c=r(/Android\/([\.\_\d]+)/,a)),e=c,t="android";break;case"iOS":e=this.isNewIpad()?s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(e=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?e[1]+"."+e[2]+"."+(0|e[3]):"",t="ios"}return{os_name:t,os_version:e}},i.getDeviceModel=function(t){var e="";try{if("android"===t)navigator.userAgent.split(";").forEach(function(t){t.indexOf("Build/")>-1&&(e=t.slice(0,t.indexOf("Build/")))});else if("ios"===t||"mac"===t||"windows"===t)if(this.isNewIpad())e="iPad";else{var i=navigator.userAgent.replace("Mozilla/5.0 (",""),n=i.indexOf(";");e=i.slice(0,n)}}catch(t){return e.trim()}return e.trim()},i.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},e}(),S={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},w="0.1.6",T={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},k=function(){function e(e,i){t(this,"regStr",void 0),t(this,"eventNameWhiteList",void 0),t(this,"paramsNameWhiteList",void 0),t(this,"collector",void 0),t(this,"config",void 0),this.collector=e,this.config=i,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","_be_active","$bav2b_slide"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","$user_unique_id_type","_staging_flag","$exposure_type","$direction","$offsetY","$offsetX"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}var i=e.prototype;return i.checkVerify=function(t){var e=this;if(!t||!t.length)return!1;var i=t[0];if(!i)return!1;var n=i.events,o=i.header;if(!n||!n.length)return!1;var r=!0;return n.forEach(function(t){e.checkEventName(t.event)||(r=!1,t.checkEvent="事件名不能以 $ or __开头"),e.checkEventParams(t.params)||(r=!1,t.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(o)||(r=!1),r},i.checkEventName=function(t){return!!t&&this.calculate(t,"event")},i.checkEventParams=function(t){var e=t;"string"==typeof t&&(e=JSON.parse(e));var i=!0;if(!Object.keys(e).length)return i;for(var n in e){if(!this.calculate(n,"params")){i=!1;break}if("string"==typeof e[n]&&e[n].length>1024){console.warn("params: "+n+" can not over 1024 byte, please check;"),i=!1;break}}return i},i.calculate=function(t,e){return-1!==("event"===e?this.eventNameWhiteList:"params"===e?this.paramsNameWhiteList:[]).indexOf(t)||(!new RegExp("^\\$").test(t)&&!new RegExp("^__").test(t)||(console.warn(e+" name: "+t+" can not start with $ or __, pleace check;"),!1))},e}(),D=function(t){return t.Init="init",t.Config="config",t.Start="start",t.Ready="ready",t.TokenComplete="token-complete",t.TokenStorage="token-storage",t.TokenFetch="token-fetch",t.TokenError="token-error",t.ConfigUuid="config-uuid",t.ConfigWebId="config-webid",t.ConfigDomain="config-domain",t.CustomWebId="custom-webid",t.AnonymousId="anonymous-id",t.TokenChange="token-change",t.TokenReset="token-reset",t.ConfigTransform="config-transform",t.EnvTransform="env-transform",t.SessionReset="session-reset",t.SessionResetTime="session-reset-time",t.Event="event",t.Events="events",t.EventNow="event-now",t.CleanEvents="clean-events",t.BeconEvent="becon-event",t.SubmitBefore="submit-before",t.SubmitScuess="submit-scuess",t.SubmitSuccess="submit-success",t.SubmitAfter="submit-after",t.SubmitError="submit-error",t.SubmitVerifyH="submit-verify-h5",t.Stay="stay",t.ResetStay="reset-stay",t.StayReady="stay-ready",t.SetStay="set-stay",t.RouteChange="route-change",t.RouteReady="route-ready",t.Ab="ab",t.AbVar="ab-var",t.AbAllVars="ab-all-vars",t.AbConfig="ab-config",t.AbExternalVersion="ab-external-version",t.AbVersionChangeOn="ab-version-change-on",t.AbVersionChangeOff="ab-version-change-off",t.AbOpenLayer="ab-open-layer",t.AbCloseLayer="ab-close-layer",t.AbReady="ab-ready",t.AbComplete="ab-complete",t.AbTimeout="ab-timeout",t.Profile="profile",t.ProfileSet="profile-set",t.ProfileSetOnce="profile-set-once",t.ProfileUnset="profile-unset",t.ProfileIncrement="profile-increment",t.ProfileAppend="profile-append",t.ProfileClear="profile-clear",t.TrackDuration="track-duration",t.TrackDurationStart="track-duration-start",t.TrackDurationEnd="track-duration-end",t.TrackDurationPause="track-duration-pause",t.TrackDurationResume="tracl-duration-resume",t.Autotrack="autotrack",t.AutotrackReady="autotrack-ready",t.CustomHeader="custom-request-header",t.TracerReady="tracer-ready",t}(D||{}),A=function(t){return t.DEBUGGER_MESSAGE="debugger-message",t.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",t.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",t.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",t.DEBUGGER_MESSAGE_EVENT="debugger-message-event",t.DEVTOOL_WEB_READY="devtool-web-ready",t}({}),x=void 0,C=(new Date).getTimezoneOffset(),M=parseInt(""+-C/60,10),I=60*C,O=function(){function e(e,i){t(this,"collect",void 0),t(this,"envInfo",void 0),t(this,"evtParams",void 0),t(this,"filter",void 0),t(this,"reportErrorCallback",void 0),t(this,"initConfig",void 0),t(this,"sessionStorage",void 0),t(this,"localStorage",void 0),t(this,"storage",void 0),t(this,"configKey",void 0),t(this,"domain",void 0),t(this,"ab_version",void 0),t(this,"ab_cache",void 0),t(this,"is_first_time",!0),t(this,"isLast",void 0),t(this,"configPersist",!1),t(this,"eventCheck",void 0),t(this,"enableClientTransport",!1),this.initConfig=i,this.collect=e;var n=new E(i.app_id,i.cookie_domain||"",i.cookie_expire||7776e6).init();this.eventCheck=new k(e,i);var o="__tea_cache_first_"+i.app_id;this.configKey="__tea_cache_config_"+i.app_id,this.storage=new b,i.configPersist&&(this.configPersist=!0,this.storage=1===i.configPersist?this.sessionStorage:this.localStorage);var r=this.storage.getLocalItem(o);r&&1==r?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(o,"1")),this.envInfo={user:{user_unique_id:x,user_type:x,user_id:x,user_is_auth:x,user_is_login:x,device_id:x,web_id:x,ip_addr_id:x,user_unique_id_type:x,anonymous_id:x},header:{app_id:x,app_name:x,app_install_id:x,install_id:x,app_package:x,app_channel:x,app_version:x,ab_version:x,os_name:n.os_name,os_version:n.os_version,device_model:n.device_model,ab_client:x,traffic_type:x,client_ip:x,device_brand:x,os_api:x,access:x,language:n.language,region:x,app_language:x,app_region:x,creative_id:n.utm.creative_id,ad_id:n.utm.ad_id,campaign_id:n.utm.campaign_id,log_type:x,rnd:x,platform:n.platform,sdk_version:w,sdk_lib:"js",province:x,city:x,timezone:M,tz_offset:I,tz_name:x,sim_region:x,carrier:x,resolution:n.screen_width+"x"+n.screen_height,browser:n.browser,browser_version:n.browser_version,referrer:n.referrer,referrer_host:n.referrer_host,width:n.screen_width,height:n.screen_height,screen_width:n.screen_width,screen_height:n.screen_height,utm_term:n.utm.utm_term,utm_content:n.utm.utm_content,utm_source:n.utm.utm_source,utm_medium:n.utm.utm_medium,utm_campaign:n.utm.utm_campaign,tracer_data:JSON.stringify(n.utm.tracer_data),custom:{},wechat_unionid:x,wechat_openid:x}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(n),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}var i=e.prototype;return i.initDomain=function(){var t=this.initConfig.channel_domain;if(t)this.domain=t;else{var e=this.initConfig.channel;this.domain=s(S[e])}},i.setDomain=function(t){this.domain=t},i.getDomain=function(){return this.domain},i.initABData=function(){var t="__tea_sdk_ab_version_"+this.initConfig.app_id,e=null;if(this.initConfig.ab_cross){var i=this.storage.getCookie(t,this.initConfig.ab_cookie_domain);e=i?JSON.parse(i):null}else e=this.storage.getLocalItem(t);this.setAbCache(e)},i.setAbCache=function(t){this.ab_cache=t},i.getAbCache=function(){return this.ab_cache},i.clearAbCache=function(){this.ab_cache={},this.ab_version=""},i.setAbVersion=function(t){this.ab_version=t},i.getAbVersion=function(){return this.ab_version},i.setEnableClientTransport=function(t){this.enableClientTransport=t},i.getEnableClientTransport=function(){return this.enableClientTransport},i.getUrl=function(t){var e="";switch(t){case"event":e="/list";break;case"webid":e="/webid";break;case"tobid":e="/tobid";break;case"profile":e="/profile/list"}var i="";return this.initConfig.caller&&(i="?sdk_version=0.1.6&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),this.initConfig.enable_encryption&&"event"===t&&"sm"!==this.initConfig.encryption_type&&(i=this.initConfig.caller?i+"&encryption=1":i+"?encryption=1"),this.initConfig.report_url?""+this.initConfig.report_url+i:""+this.getDomain()+e+i},i.setCustom=function(t){if(t&&t.latest_data&&t.latest_data.isLast)for(var e in delete t.latest_data.isLast,this.isLast=!0,t.latest_data)this.envInfo.header.custom[e]=t.latest_data[e]},i.set=function(t){var e=this;Object.keys(t).forEach(function(i){void 0!==t[i]&&null!==t[i]||e.delete(i);try{e.eventCheck.calculate(i,"config")}catch(t){}if("traffic_type"===i&&e.isLast&&(e.envInfo.header.custom.$latest_traffic_source_type=t[i]),"evtParams"===i)e.evtParams=Object.assign({},e.evtParams||{},t.evtParams||{});else if("_staging_flag"===i)e.evtParams=Object.assign({},e.evtParams||{},{_staging_flag:t._staging_flag});else if("reportErrorCallback"===i&&"function"==typeof t[i])e.reportErrorCallback=t[i];else{var n="",o="";if(i.indexOf(".")>-1){var r=i.split(".");n=r[0],o=r[1]}n?"user"===n||"header"===n?e.envInfo[n][o]=t[i]:e.envInfo.header.custom[o]=t[i]:Object.hasOwnProperty.call(e.envInfo.user,i)?["user_type","ip_addr_id"].indexOf(i)>-1?e.envInfo.user[i]=t[i]?Number(t[i]):t[i]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(i)>-1?e.envInfo.user[i]=t[i]?String(t[i]):t[i]:["user_is_auth","user_is_login"].indexOf(i)>-1?e.envInfo.user[i]=Boolean(t[i]):"device_id"===i&&(e.envInfo.user[i]=t[i]):Object.hasOwnProperty.call(e.envInfo.header,i)?e.envInfo.header[i]=t[i]:e.envInfo.header.custom[i]=t[i]}})},i.get=function(t){try{return t?"evtParams"===t?this.evtParams:"reportErrorCallback"===t?this[t]:Object.hasOwnProperty.call(this.envInfo.user,t)?this.envInfo.user[t]:Object.hasOwnProperty.call(this.envInfo.header,t)?this.envInfo.header[t]:JSON.parse(JSON.stringify(this.envInfo[t])):JSON.parse(JSON.stringify(this.envInfo))}catch(t){console.log("get config stringify error "),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},i.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},i.setStore=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};if(e&&Object.keys(t).length){var i=Object.assign(t,e);this.setItem(this.configKey,i)}}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.getStore=function(){try{if(!this.configPersist)return null;var t=this.getItem(this.configKey)||{};return t&&Object.keys(t).length?t:null}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),null}},i.delete=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};e&&Object.hasOwnProperty.call(e,t)&&(delete e[t],this.setItem(this.configKey,e))}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e}(),R=function(){function e(e,i){t(this,"isLog",void 0),t(this,"name",void 0),this.isLog=i||!1,this.name=e||""}var i=e.prototype;return i.info=function(t){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},i.warn=function(t){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},i.error=function(t){this.isLog&&console.error("[instance: "+this.name+"] "+t)},i.throw=function(t){throw this.error(this.name),new Error(t)},e}(),B=function(){function t(t,e){this.native=t.enable_native||t["evitaN".split("").reverse().join("")],this.os=e.get("os_name")}var e=t.prototype;return e.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(t){return console.log("AppLogBridge is not inject"),!1}},e.bridgeReady=function(){var t=this;return new Promise(function(e,i){try{t.bridgeInject()?AppLogBridge.hasStarted(function(t){console.log("AppLogBridge is started? : "+t),t?e(!0):i(!1)}):i(!1)}catch(t){console.log("AppLogBridge, error:"+JSON.stringify(t.stack)),i(!1)}})},e.setNativeAppId=function(t){try{AppLogBridge.setNativeAppId(JSON.stringify(t)),console.log("change bridge appid, event report with appid: "+t)}catch(t){console.error("setNativeAppId error")}},e.setConfig=function(t){var e=this;try{Object.keys(t).forEach(function(i){"user_unique_id"===i?e.setUserUniqueId(t[i]):t[i]?e.addHeaderInfo(i,t[i]):e.removeHeaderInfo(i)})}catch(t){console.error("setConfig error")}},e.setUserUniqueId=function(t){try{AppLogBridge.setUserUniqueId(t)}catch(t){console.error("setUserUniqueId error")}},e.addHeaderInfo=function(t,e){try{AppLogBridge.addHeaderInfo(t,e)}catch(t){console.error("addHeaderInfo error")}},e.setHeaderInfo=function(t){try{AppLogBridge.setHeaderInfo(JSON.stringify(t))}catch(t){console.error("setHeaderInfo error")}},e.removeHeaderInfo=function(t){try{AppLogBridge.removeHeaderInfo(t)}catch(t){console.error("removeHeaderInfo error")}},e.reportPv=function(t){this.onEventV3("predefine_pageview",t)},e.onEventV3=function(t,e){try{AppLogBridge.onEventV3(t,e)}catch(t){console.error("onEventV3 error")}},e.profileSet=function(t){try{AppLogBridge.profileSet(t)}catch(t){console.error("profileSet error")}},e.profileSetOnce=function(t){try{AppLogBridge.profileSetOnce(t)}catch(t){console.error("profileSetOnce error")}},e.profileIncrement=function(t){try{AppLogBridge.profileIncrement(t)}catch(t){console.error("profileIncrement error")}},e.profileUnset=function(t){try{AppLogBridge.profileUnset(t)}catch(t){console.error("profileUnset error")}},e.profileAppend=function(t){try{AppLogBridge.profileAppend(t)}catch(t){console.error("profileAppend error")}},e.setExternalAbVersion=function(t){try{AppLogBridge.setExternalAbVersion(t)}catch(t){console.error("setExternalAbVersion error")}},e.getVar=function(t,e,i){try{"android"===this.os?i(AppLogBridge.getABTestConfigValueForKey(t,e)):AppLogBridge.getABTestConfigValueForKey(t,e,function(t){i(t)})}catch(t){console.error("getVar error"),i(e)}},e.getAllVars=function(t){try{"android"===this.os?t(AppLogBridge.getAllAbTestConfigs()):AppLogBridge.getAllAbTestConfigs(function(e){t(e)})}catch(e){console.error("getAllVars error"),t(null)}},e.getAbSdkVersion=function(t){try{"android"===this.os?t(AppLogBridge.getAbSdkVersion()):AppLogBridge.getAbSdkVersion(function(e){t(e)})}catch(e){console.error("getAbSdkVersion error"),t("")}},t}(),G=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"configManager",void 0),t(this,"eventKey",void 0),t(this,"beconKey",void 0),t(this,"abKey",void 0),t(this,"storgae",void 0),t(this,"reportTimeout",void 0),t(this,"maxReport",void 0),t(this,"reportTime",void 0),t(this,"timeout",void 0),t(this,"eventLimit",50),t(this,"reportUrl",void 0),t(this,"eventCache",[]),t(this,"beconEventCache",[]),t(this,"eventCheck",void 0),t(this,"refer_key",void 0),t(this,"enable_ttwebid",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=t.configManager,this.storgae=new b,this.eventCheck=new k(t,e),this.maxReport=e.max_report||20,this.reportTime=e.reportTime||30,this.timeout=e.timeout||1e5,this.enable_ttwebid=e.enable_ttwebid,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+this.configManager.get("app_id"),this.beconKey="__tea_cache_events_becon_"+this.configManager.get("app_id"),this.abKey="__tea_sdk_ab_version_"+this.configManager.get("app_id"),this.refer_key="__tea_cache_refer_"+this.configManager.get("app_id"),this.collect.on(D.Ready,function(){i.reportAll(!1)}),this.collect.on(D.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(D.Event,function(t){i.event(t)}),this.collect.on(D.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(D.CleanEvents,function(){i.reportAll(!1)}),this.linster()},i.linster=function(){var t=this;window.addEventListener("unload",function(){t.reportAll(!0)},!1),a(function(){t.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.reportAll(!0)},!1)},i.reportAll=function(t){this.report(t),this.reportBecon()},i.event=function(t){var e=this;try{var i=this.storgae.getCacheItem(this.eventKey)||[],n=[].concat(t,i);if(this.storgae.setCacheItem(this.eventKey,n),this.reportTimeout&&clearTimeout(this.reportTimeout),n.length>=this.maxReport)this.report(!1);else{var o=this.reportTime;this.reportTimeout=setTimeout(function(){e.report(!1),e.reportTimeout=null},o)}}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.beconEvent=function(t){var e=this.storgae.getCacheItem(this.beconKey)||[],i=[].concat(t,e);this.storgae.setCacheItem(this.beconKey,i),this.collect.destroy||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(i)),!0))},i.reportBecon=function(){var t=this.storgae.getCacheItem(this.beconKey)||[];t&&t.length&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(t)),!0))},i.report=function(t){if(!this.collect.destroy&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var e=this.storgae.getCacheItem(this.eventKey)||[];e.length&&(this.storgae.removeCacheItem(this.eventKey),this.sliceEvent(e,t))}},i.sliceEvent=function(t,e){if(t.length>this.eventLimit)for(var i=0;i<t.length;i+=this.eventLimit){var n;n=t.slice(i,i+this.eventLimit);var o=this.split(this.merge(n));this.send(o,e)}else{var r=this.split(this.merge(t));this.send(r,e)}},i.handleRefer=function(){var t="";try{if(this.config.spa||this.config.autotrack){var e=this.storgae.getLocalItem(this.refer_key)||{};t=e.routeChange?e.refer_key:this.configManager.get("referrer")}else t=this.configManager.get("referrer")}catch(e){t=document.referrer}return t},i.merge=function(t,e){var i=this,n=this.configManager.get(),o=n.header,r=n.user;o.referrer=this.handleRefer(),o.custom=JSON.stringify(o.custom);var s=this.configManager.get("evtParams"),a=this.configManager.get("user_unique_id_type"),c=t.map(function(t){try{if(Object.keys(s).length&&!e&&(t.params=Object.assign({},t.params,s)),i.collect.dynamicParamsFilter){var n=i.collect.dynamicParamsFilter();Object.keys(n).length&&(t.params=Object.assign({},t.params,n))}a&&(t.params.$user_unique_id_type=a);var o=i.configManager.getAbCache(),c=i.configManager.getAbVersion();return c&&o&&(i.config.disable_ab_reset||o.uuid===r.user_unique_id)&&(t.ab_sdk_version=c),t.session_id=i.collect.sessionManager.getSessionId(),t.params=JSON.stringify(t.params),t}catch(e){return i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}}),h=[];if(!Object.keys(r).length)return console.warn("user info error,cant report"),h;this.config.enable_anonymousid&&delete r.web_id;var l=JSON.parse(JSON.stringify({events:c,user:r,header:o}));return l.local_time=Math.floor(Date.now()/1e3),l.verbose=1,l.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,h.push(l),h},i.split=function(t){return t=t.map(function(t){var e=[];return e.push(t),e})},i.send=function(t,e){var i=this;t.length&&t.forEach(function(t){try{var n=JSON.parse(JSON.stringify(t));i.config.filter&&((n=i.config.filter(n))||console.warn("filter must return data !!")),i.collect.eventFilter&&n&&((n=i.collect.eventFilter(n))||console.warn("filterEvent api must return data !!"));var o=n||t,r=JSON.parse(JSON.stringify(o));if(i.eventCheck.checkVerify(r),!o.length)return;i.collect.emit(D.SubmitBefore,o);var s=i.collect.cryptoData(o);i.collect.requestManager.useRequest({url:i.reportUrl,data:s,success:function(t,e,n,o,s){t&&0!==t.e?(i.collect.emit(D.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:r,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(D.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:r,code:200,status:"success"}))},fail:function(t,e,n,o){i.configManager.get("reportErrorCallback")(t,e),i.collect.emit(D.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,errorMessage:o,endTime:Date.now()}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:r,code:e,failType:"网络异常失败",status:"fail"})},timeout:i.timeout,useBeacon:e,encryption:i.config.enable_encryption,encryption_header:i.config.encryption_header,withCredentials:i.enable_ttwebid}),i.collect.emit(D.SubmitVerifyH,o),i.collect.emit(D.SubmitAfter,o)}catch(t){console.warn("something error, "+JSON.stringify(t.stack)),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}})},e}(),L=function(t){return t?(t^16*Math.random()>>t/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,L)},P=function(){return L().replace(/-/g,"").slice(0,19)},N=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},F=function(){function e(){t(this,"sessionKey",void 0),t(this,"storage",void 0),t(this,"sessionExp",void 0),t(this,"expireTime",void 0),t(this,"disableSession",void 0),t(this,"collect",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.storage=new b,this.sessionKey="__tea_session_id_"+e.app_id,this.expireTime=e.expireTime||18e5,this.disableSession=e.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(D.SessionReset,function(){i.resetSessionId()}),this.collect.on(D.SessionResetTime,function(){i.updateSessionIdTime()}))},i.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:N(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},i.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:N(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},i.getSessionId=function(){var t=this.storage.getSessionItem(this.sessionKey);return this.disableSession?"":t&&t.sessionId?t.sessionId:""},i.resetExpTime=function(){var t=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime))},i.resetSessionId=function(){var t={sessionId:N(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},i.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:N(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},e}(),U=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"storage",void 0),t(this,"configManager",void 0),t(this,"cacheToken",{}),t(this,"tokenKey",void 0),t(this,"tokenReady",void 0),t(this,"tokenType",void 0),t(this,"enableCookie",!1),t(this,"expiresTime",void 0),t(this,"cookieDomain",void 0),t(this,"enableTTwebid",!1),t(this,"enableCustomWebid",!1),t(this,"enableAnonymousid",!1),t(this,"timeout",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=this.collect.configManager,this.storage=new b,this.tokenKey="__tea_cache_tokens_"+e.app_id,this.enableAnonymousid=e.enable_anonymousid,this.enableTTwebid=e.enable_ttwebid,this.enableCustomWebid=e.enable_custom_webid,this.collect.on(D.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(D.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(D.ConfigWebId,function(t){i.setWebId(t)}),this.timeout=e.timeout||3e5,this.enableCookie=e.cross_subdomain,this.expiresTime=e.cookie_expire||6048e5,this.cookieDomain=e.cookie_domain||"",this.checkStorage()},i.checkStorage=function(){var t=this;if(this.enableCookie){var e=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=e&&"string"==typeof e?JSON.parse(e):{}}else this.cacheToken=this.storage.getLocalItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid||this.enableAnonymousid?this.enableAnonymousid?this.completeAnonymous(this.cacheToken):this.enableCustomWebid?this.collect.on(D.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(D.TokenComplete)}):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},i.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:P(),user_unique_id:this.configManager.get("user_unique_id")||P()}):this.remoteWebid()},i.checkEnv=function(){var t=window.navigator.userAgent;if(-1!==t.indexOf("miniProgram")||-1!==t.indexOf("MiniProgram")){var e=l(window.location.href);return!(!e||!e.Web_ID)&&(this.complete({web_id:""+e.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+e.Web_ID}),!0)}return!1},i.remoteWebid=function(){var t=this,e=this.configManager.getUrl("webid"),i={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:i});var n=this.collect.cryptoData(i);this.collect.requestManager.useRequest({url:e,data:n,success:function(e){var i;if(e&&0===e.e)i=e.web_id,t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:e});else{var n=t.getLocalId();i=n,t.collect.configManager.set({localWebId:n}),t.collect.emit(D.TokenError),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:e}),t.collect.logger.warn("appid: "+t.config.app_id+" get webid error, use local webid~")}t.complete({web_id:t.configManager.get("web_id")||i,user_unique_id:t.configManager.get("user_unique_id")||i})},fail:function(){var e=t.getLocalId();t.complete({web_id:t.configManager.get("web_id")||e,user_unique_id:t.configManager.get("user_unique_id")||e}),t.collect.configManager.set({localWebId:e}),t.collect.emit(D.TokenError),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),t.collect.logger.warn("appid: "+t.config.app_id+", get webid error, use local webid~")},timeout:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},i.getLocalId=function(){for(var t=P(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=P(),e++}return t},i.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(D.TokenError),void console.warn("token error");t.timestamp=Date.now(),this.collect.configManager.set({web_id:e,user_unique_id:i}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.completeAnonymous=function(t){var e=t.anonymous_id||N(),i=t.user_unique_id||this.configManager.get("user_unique_id");this.collect.configManager.set({anonymous_id:e,user_unique_id:i||e}),t.anonymous_id=e,t.user_unique_id=i||e,this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.completeTtWid=function(t){var e=t.user_unique_id||"",i=this.configManager.get("user_unique_id");this.configManager.set({user_unique_id:i||e}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.setUuid=function(t){if(t&&-1===["null","undefined","Null","None"].indexOf(t)){var e=String(t),i=this.configManager.get("user_unique_id"),n=this.cacheToken&&this.cacheToken.user_unique_id;if(e===i&&e===n)return;this.configManager.set({user_unique_id:e}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=e,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(D.TokenChange,{type:"uuid",id:t}),this.collect.emit(D.SessionReset)}else this.clearUuid()},i.clearUuid=function(){if(!this.config.enable_ttwebid){var t=this.enableAnonymousid?this.configManager.get("anonymous_id"):this.configManager.get("web_id");this.configManager.get("user_unique_id")!==t&&(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(D.TokenReset))}},i.setAnonymousId=function(t){if(t&&this.enableAnonymousid){var e=this.configManager.get("anonymous_id"),i=this.configManager.get("user_unique_id");e!==t&&(e!==i&&i||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(D.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(D.TokenChange,{type:"anonymous_id",id:t}),this.setStorage(this.cacheToken))}},i.setWebId=function(t){if(t&&!this.config.enable_ttwebid&&!this.enableAnonymousid){var e=this.configManager.get("web_id"),i=this.configManager.get("user_unique_id");i&&i!==e||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(D.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(D.TokenChange,{type:"webid",id:t})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},i.setStorage=function(t){t._type_=this.enableCustomWebid?"custom":"default",delete t["diss".split("").reverse().join("")],this.enableCookie||this.enableTTwebid?this.storage.setCookie(this.tokenKey,t,this.expiresTime,this.cookieDomain):this.storage.setLocalItem(this.tokenKey,t),this.cacheToken=t},i.getReady=function(){return this.tokenReady},i.getTobId=function(){var t=this;this.configManager.getUrl("tobid");var e={app_id:this.config.app_id,user_unique_id:this.configManager.get("user_unique_id"),user_unique_id_type:this.configManager.get("user_unique_id_type")};this.enableAnonymousid?e.anonymous_id=this.configManager.get("anonymous_id"):e.web_id=this.configManager.get("web_id");var i=this.collect.cryptoData(e);return new Promise(function(e){t.collect.requestManager.useRequest({url:t.configManager.getUrl("tobid"),data:i,success:function(i){i&&0===i.e?(e(i.tobid),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),infoType:"sdk"})},timeout:t.timeout,encryption:t.config.enable_encryption,encryption_header:t.config.encryption_header,withCredentials:t.enableTTwebid})})},e}(),q=function(){function e(e,i){var n=this;t(this,"collector",void 0),t(this,"config",void 0),t(this,"errorCode",void 0),t(this,"errorMessage",void 0),t(this,"requestType",void 0),t(this,"supportBeacon",void 0),t(this,"customHeader",void 0),this.collector=e,this.config=i,this.requestType=i.request_type||"xhr",this.supportBeacon=!(!window.navigator||!window.navigator.sendBeacon),this.errorCode={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ERROR:5002,TIMEOUT:5005,FETCH_ERROR:5006},this.errorMessage={BEACON_FALSE:"xhr sendbeacon error",XHR_ERROR:"xhr request error",BEACON:"xhr sendbeacon error",TIMEOUT:"xhr request timeout",FETCH_ERROR:"fetch network error",FETCH_RESPONSE_ERROR:"fetch response error"},this.customHeader=i.custom_request_header||{},this.collector.on(D.CustomHeader,function(t){n.setRequestHeader(t)})}var i=e.prototype;return i.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},i.useFetch=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.status,c=t.timeout,h=t.useBeacon,l=t.encryption,u=t.encryption_header;if(t.withCredentials,window.fetch&&"undefined"!=typeof Request){var f={method:o||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var p=this.collector.configManager.get("browser"),g=this.collector.configManager.get("browser_version");if(g=g.split("."),"Chrome"===p&&g.length&&g[0]&&Number(g[0])<82)return void this.useSendBeacon(t);f.keepalive=!0}var m=l&&!d()?n:JSON.stringify(n),v={"Content-Type":"application/json; charset=utf-8"};l&&u&&(v["Content-Type"]="application/octet-stream;tt-data="+u),f.body=m,f.headers=v;var _=null;_="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var y=setTimeout(function(){_.abort()},c);if(Object.keys(this.customHeader).length)for(var b in this.customHeader)v[b]=this.customHeader[b];f.signal=_.signal;var E=Date.now();try{fetch(i,f).then(function(t){return t.ok||s&&s(n,t.status,E,t.statusText||e.errorMessage.FETCH_RESPONSE_ERROR),t.json()}).then(function(t){clearTimeout(y),r&&r(t,n,a,E,200)}).catch(function(t){clearTimeout(y),s&&s(n,e.errorCode.FETCH_ERROR,E,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK useFetch 发送请求发生了一些问题",level:"error",time:Date.now(),data:e.message||"SDK useFetch has some errors",infoType:"sdk"})}}else h?this.useSendBeacon(t):this.useXhr(t),console.log("your browser not support fetch, use normal request")},i.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,n=t.status,o=t.success,r=t.fail,s=t.encryption,a=t.encryption_header,c=Date.now(),h=JSON.stringify(i);if(s&&a&&!d()){if("undefined"==typeof Blob)return void this.useXhr(t);h=new Blob([i],{type:"application/octet-stream;tt-data="+a})}window.navigator.sendBeacon(e,h)?o&&o({e:0},i,n,c,200):r&&r(i,this.errorCode.BEACON_FALSE,c,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},i.useXhr=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.timeout;t.withCredentials;var c=t.encryption,h=t.encryption_header,l=t.status;try{var u=new XMLHttpRequest;u.open(o||"POST",i,!0);var f=Date.now();if(c&&h?u.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):u.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var p in this.customHeader)u.setRequestHeader(p,this.customHeader[p]);a&&(u.timeout=a,u.ontimeout=function(){s&&s(n,e.errorCode.TIMEOUT,f,e.errorMessage.TIMEOUT)}),u.onload=function(){if(r){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}r(t,n,l,f,u.status)}else s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR)}},u.onerror=function(){s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR),u.abort()},c&&!d()?u.send(n):u.send(JSON.stringify(n))}catch(t){this.collector.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},i.useRequest=function(t){var e=t.useBeacon;this.config.transport&&this.collector.configManager.getEnableClientTransport()?this.useCustomRequest(t):"fetch"!==this.requestType?e?this.useSendBeacon(t):this.useXhr(t):this.useFetch(t)},i.useCustomRequest=function(t){var e=this.config.transport,i=t.url,n=t.data,o=t.success,r=t.fail;if(e)try{e.post({url:i,data:JSON.stringify(n),success:function(t){o&&o(t,n)},fail:function(t){r&&r(t,n)}})}catch(e){this.collector.configManager.setEnableClientTransport(!1),this.useRequest(t)}},e}(),z=function(){function e(e){var i=this;t(this,"element",void 0),t(this,"isDragging",void 0),t(this,"animationFrameId",void 0),t(this,"lastX",void 0),t(this,"lastY",void 0),t(this,"offsetX",void 0),t(this,"offsetY",void 0),t(this,"initialX",void 0),t(this,"initialY",void 0),t(this,"clickAllowed",void 0),t(this,"dragThreshold",void 0),t(this,"enableClick",void 0),t(this,"onMove",function(t){if(i.isDragging){var e=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(i.clickAllowed){var o=Math.abs(e-i.initialX),r=Math.abs(n-i.initialY);(o>i.dragThreshold||r>i.dragThreshold)&&(i.clickAllowed=!1)}i.animationFrameId&&cancelAnimationFrame(i.animationFrameId),i.animationFrameId=requestAnimationFrame(function(){var e=t.touches?t.touches[0].clientX:t.clientX,n=t.touches?t.touches[0].clientY:t.clientY,o=e-i.offsetX,r=n-i.offsetY,s=window.innerWidth-i.element.offsetWidth,a=window.innerHeight-i.element.offsetHeight;o=Math.max(0,Math.min(o,s)),r=Math.max(0,Math.min(r,a)),i.element.style.transform="translate(\n "+(o-i.initialX)+"px, \n "+(r-i.initialY)+"px\n )"})}}),t(this,"onEnd",function(){if(i.isDragging){i.isDragging=!1;var t=new DOMMatrix(getComputedStyle(i.element).transform),e=i.initialX+t.m41,n=i.initialY+t.m42;i.element.style.left=e+"px",i.element.style.top=n+"px",i.element.style.transform="none",i.initialX=e,i.initialY=n,document.removeEventListener("mousemove",i.onMove),document.removeEventListener("mouseup",i.onEnd),document.removeEventListener("touchmove",i.onMove),document.removeEventListener("touchend",i.onEnd),setTimeout(function(){i.clickAllowed=!0},50)}}),this.element=e,this.isDragging=!1,this.enableClick=!1,this.animationFrameId=null,this.lastX=0,this.lastY=0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.clickAllowed=!0,this.dragThreshold=1,this.initPosition(),this.bindEvents(),this.bindClickHandler()}var i=e.prototype;return i.initPosition=function(){var t=this.element.getBoundingClientRect();this.element.style.position="fixed",this.element.style.left=t.left+"px",this.element.style.top=t.top+"px",this.element.style.transform="translate(0, 0)"},i.bindEvents=function(){this.element.addEventListener("mousedown",this.onStart.bind(this)),this.element.addEventListener("touchstart",this.onStart.bind(this))},i.onStart=function(t){t.preventDefault(),this.initialX=t.clientX||t.touches[0].clientX,this.initialY=t.clientY||t.touches[0].clientY;var e=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,n=this.element.getBoundingClientRect();this.initialX=n.left,this.initialY=n.top,this.offsetX=e-this.initialX,this.offsetY=i-this.initialY,this.clickAllowed=!0,this.isDragging=!0,document.addEventListener("mousemove",this.onMove),document.addEventListener("mouseup",this.onEnd),document.addEventListener("touchmove",this.onMove),document.addEventListener("touchend",this.onEnd)},i.bindClickHandler=function(){var t=this;this.element.addEventListener("click",function(e){if(t.enableClick)return t.clickAllowed?void(window&&window.postMessage({type:"devtool:web:open-draw"},location.origin)):(e.stopImmediatePropagation(),void e.preventDefault())})},i.enable=function(){this.enableClick=!0,this.element.style.cursor="pointer",this.element.style.opacity="1"},e}(),V=function(){function e(e,i){t(this,"collect",void 0),t(this,"config",void 0),t(this,"devToolReady",!1),t(this,"devToolOrigin","*"),t(this,"sendAlready",!1),t(this,"app_id",void 0),t(this,"info",void 0),t(this,"log",void 0),t(this,"event",void 0),t(this,"filterEvent",void 0),t(this,"cacheStorgae",void 0),t(this,"loadUrl",void 0),t(this,"trackEnabled",!0),t(this,"currentAppKey",void 0),t(this,"debugButton",void 0),i.disable_debug||"Microsoft Internet Explorer"!==e.configManager.get("browser")&&(this.collect=e,this.config=i,this.app_id=i.app_id,this.trackEnabled=!!i.track_enabled,this.cacheStorgae=new b,this.currentAppKey="__applog_load_devtool_web_"+this.app_id,this.loadUrl=i.devtool_url||"https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/devtool/debug-web.v2.0.1.js",this.filterEvent=new Set(["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","bav2b_page","bav2b_beat","bav2b_page_statistics","bav2b_click","bav2b_page_exposure","_be_active","predefine_pageview","__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append","predefine_page_alive","predefine_page_close","abtest_exposure"]),this.load())}var i=e.prototype;return i.loadScript=function(t){var e=this;try{var i=document.createElement("script");i.src=t,i.onerror=function(){console.log("load DevTool render fail")},i.onload=function(){e.enableDebugButton(),console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(i)}catch(t){console.log("devTool load fail, "+t.message)}},i.parseUrl=function(){var t={};try{var e=window.location.href.split("?")[1].split("&");e.length&&e.forEach(function(e){var i=e.split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])})}catch(t){}return t},i.load=function(){try{var t=this.parseUrl();if(0==t.open_devtool_web)return void this.cacheStorgae.removeLocalItem("__applog_open_devtool_web");if(t.open_devtool_web&&t.app_id){if(parseInt(t.app_id)!==this.app_id)return}else if(!this.getStorage())return;this.loadBaseInfo(),this.loadHook(),this.setStorage(),this.addLintener(),this.loadDevTool()}catch(t){console.log("debug fail, "+t.message)}},i.getStorage=function(){var t=this.cacheStorgae.getLocalItem("__applog_open_devtool_web");return t&&parseInt(t)===this.app_id},i.setStorage=function(){this.cacheStorgae.setLocalItem("__applog_open_devtool_web",this.app_id),this.cacheStorgae.setLocalItem("__applog_devtool_web_track_enable",this.trackEnabled)},i.loadDevTool=function(){1==this.cacheStorgae.getLocalItem(this.currentAppKey)?console.warn("your appid: "+this.app_id+" has load web devtools already, maybe your page has more than two applogsdk and use one appid"):(this.loadDebuggerModule(),this.loadScript(this.loadUrl))},i.loadBaseInfo=function(){if(this.log=[],this.event=[],this.info=[{title:"基本信息",key:"base",type:1,content:[{name:"app_id",desc:"APP_ID",value:this.config.app_id},{name:"channel",desc:"CHANNEL",value:this.config.channel},{name:"domain",desc:"上报域名",value:this.collect.configManager.getDomain()},{name:"sdk_version",desc:"SDK版本",value:w},{name:"sdk_type",desc:"SDK引入方式",value:"npm"}]},{title:"用户信息",key:"user",type:2,content:[{name:"uuid",desc:"UUID",value:this.collect.configManager.get("user").user_unique_id||""},{name:"web_id",desc:"WEB_ID",value:this.collect.configManager.get("user").web_id||""}]},{title:"公共参数信息",type:2,key:"common",content:[{name:"browser",desc:"浏览器",value:this.collect.configManager.get("browser")},{name:"browser_version",desc:"浏览器版本",value:this.collect.configManager.get("browser_version")},{name:"platform",desc:"平台",value:this.collect.configManager.get("platform")},{name:"device_model",desc:"设备型号",value:this.collect.configManager.get("device_model")},{name:"os_name",desc:"操作系统",value:this.collect.configManager.get("os_name")},{name:"os_version",desc:"操作系统版本",value:this.collect.configManager.get("os_version")},{name:"resolution",desc:"屏幕分辨率",value:this.collect.configManager.get("resolution")},{name:"referrer",desc:"来源",value:this.collect.configManager.get("referrer")},{name:"custom",desc:"自定义信息",value:JSON.stringify(this.collect.configManager.get("custom"))}]},{title:"配置信息",key:"config",type:3,content:[{name:"autotrack",desc:"全埋点",value:!!this.config.autotrack},{name:"stay",desc:"停留时长",value:!!this.config.enable_stay_duration}]},{title:"A/B配置信息",key:"ab",type:4,content:[{name:"ab",desc:"A/B实验",value:!!this.config.enable_ab_test}]}],this.config.enable_ab_test){var t=this.getInfo("ab"),e=[{name:"ab",desc:"A/B实验",value:!!this.config.enable_ab_test},{name:"vid",desc:"已曝光VID",value:this.collect.configManager.getAbVersion()},{name:"ab_domain",desc:"A/B域名",value:this.config.ab_channel_domain||s(T[this.config.channel])},{name:"all_values",desc:"全部配置",value:this.collect.configManager.getAbCache()}];t.content=e,this.setInfo("ab",t)}if(this.config.enable_native||this.config.Native){var i={title:"客户端信息",type:3,content:[{name:"native",desc:"是否打通",value:!!this.collect.bridgeReport}]};this.setInfo("native",i)}if(w.includes("tob")){var n=this.getInfo("user");n.content.push({name:"sid",desc:"DISS".split("").reverse().join(""),value:"点击获取"}),this.setInfo("user",n)}},i.getInfo=function(t){var e=null;return this.info.forEach(function(i){i.key===t&&(e=i)}),e},i.setInfo=function(t,e){var i=!1;this.info.forEach(function(n){n.key===t&&(i=!0,n=e)}),i||this.info.push(e)},i.getSecondInfo=function(t,e){var i=this.getInfo(t),n=null;return i.content.forEach(function(t){t.name===e&&(n=t)}),n},i.setSecondInfo=function(t,e,i){var n=this.getInfo(t),o=!1;if(n.content.forEach(function(t){t.name===e&&(t.value=i,o=!0)}),!o){var r={name:e,value:i,desc:e.toLocaleUpperCase()};n.content.push(r)}this.setInfo(t,n)},i.loadHook=function(){var t=this;this.collect.on(A.DEBUGGER_MESSAGE,function(e){switch(e.type){case A.DEBUGGER_MESSAGE_SDK:var i={time:e.time,type:e.logType||"sdk",infoType:e.infoType||"sdk",level:e.level,name:e.info,show:!0,levelShow:!0,needDesc:!!e.data};if(e.data&&(i.desc={content:JSON.stringify(e.data)}),t.updateLog(i),e.secType&&"AB"===e.secType)t.setSecondInfo("ab","vid",t.collect.configManager.getAbVersion()),t.setSecondInfo("ab","all_values",t.collect.configManager.getAbCache());else if("USER"===e.secType)t.setSecondInfo("user","user_unique_id"===e.common?"uuid":e.common,t.collect.configManager.get(e.common));else if("HEADER"===e.secType){var n=t.collect.configManager.get(e.common);t.setSecondInfo("common",e.common,"custom"===e.common?JSON.stringify(n):n)}return void t.updateInfo();case A.DEBUGGER_MESSAGE_EVENT:if(e.data&&e.data.length){var o=e.data[0],r=o.events;if(!r.length)return;r.forEach(function(i){i.checkShow=!0,i.searchShow=!0,i.focusShow=!0,i.status=e.status,i.type=t.filterEvent.has(i.event)?"sdk":"cus",i.verifyType=e.verifyType?"verify":"no",i.info="","fail"===e.status&&(i.info={message:"code: "+e.code+", msg: "+(e.msg||e.failType)})}),t.updateEvent(o)}return}})},i.addLintener=function(){var t=this;window.addEventListener("message",function(e){if(e&&e.data&&"devtool:web:ready"===e.data.type){if(t.devToolOrigin=e.origin,t.devToolReady=!0,t.sendAlready)return;t.sendData("devtool:web:init",{info:t.info,log:t.log,event:t.event,sdk_type:w.includes("tob")?"tob":"inner",appId:t.app_id}),t.sendAlready=!0}e&&e.data&&"devtool:web:ssid"===e.data.type&&t.collect.getToken(function(e){t.setSecondInfo("user","sid",e.tobid),t.updateInfo()})})},i.sendData=function(t,e){try{var i={type:t,payload:e};window&&window.postMessage(i,this.devToolOrigin)}catch(t){}},i.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},i.updateLog=function(t){this.devToolReady?this.sendData("devtool:web:log",t):this.log.push(t)},i.updateEvent=function(t){this.devToolReady?this.sendData("devtool:web:event",t):this.event.push(t)},i.loadDebuggerModule=function(){var t=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");e.appendChild(document.createTextNode("#debugger-applog-web {\n position: fixed;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: not-allowed;\n z-index:1000;\n font-weight:bold;\n opacity: 0.6;\n }")),t.appendChild(e);var i=document.createElement("div");i.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>';var n=document.createElement("div");n.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(i),document.getElementsByTagName("body")[0].appendChild(n);var o=document.getElementById("debugger-applog-web");this.debugButton=new z(o)},i.enableDebugButton=function(){this.debugButton&&this.debugButton.enable()},e}(),H=g(function(t,e){(function(){var e;function i(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function n(){return new i(null)}var o="undefined"!=typeof navigator;o&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(var s=32767&e,a=e>>15;--r>=0;){var c=32767&this[t],h=this[t++]>>15,l=a*c+h*s;o=((c=s*c+((32767&l)<<15)+i[n]+(1073741823&o))>>>30)+(l>>>15)+a*h+(o>>>30),i[n++]=1073741823&c}return o},e=30):o&&"Netscape"!=navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(;--r>=0;){var s=e*this[t++]+i[n]+o;o=Math.floor(s/67108864),i[n++]=67108863&s}return o},e=26):(i.prototype.am=function(t,e,i,n,o,r){for(var s=16383&e,a=e>>14;--r>=0;){var c=16383&this[t],h=this[t++]>>14,l=a*c+h*s;o=((c=s*c+((16383&l)<<14)+i[n]+o)>>28)+(l>>14)+a*h,i[n++]=268435455&c}return o},e=28),i.prototype.DB=e,i.prototype.DM=(1<<e)-1,i.prototype.DV=1<<e;i.prototype.FV=Math.pow(2,52),i.prototype.F1=52-e,i.prototype.F2=2*e-52;var r,s,a=new Array;for(r="0".charCodeAt(0),s=0;s<=9;++s)a[r++]=s;for(r="a".charCodeAt(0),s=10;s<36;++s)a[r++]=s;for(r="A".charCodeAt(0),s=10;s<36;++s)a[r++]=s;function c(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function h(t,e){var i=a[t.charCodeAt(e)];return null==i?-1:i}function l(t){var e=n();return e.fromInt(t),e}function u(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function f(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function p(t,e){return t&e}function g(t,e){return t|e}function m(t,e){return t^e}function v(t,e){return t&~e}function _(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function y(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function E(t){return t}function S(t){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}f.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},f.prototype.revert=function(t){return t},f.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},f.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},f.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(i.ZERO)>0&&this.m.subTo(e,e),e},d.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],n=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var o=t.length,r=!1,s=0;--o>=0;){var a=8==n?255&t[o]:h(t,o);a<0?"-"==t.charAt(o)&&(r=!0):(r=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),r&&i.ZERO.subTo(this,this)},i.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},i.prototype.lShiftTo=function(t,e){var i,n=t%this.DB,o=this.DB-n,r=(1<<o)-1,s=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)e[i+s+1]=this[i]>>o|a,a=(this[i]&r)<<n;for(i=s-1;i>=0;--i)e[i]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,o=this.DB-n,r=(1<<n)-1;e[0]=this[i]>>n;for(var s=i+1;s<this.t;++s)e[s-i-1]|=(this[s]&r)<<o,e[s-i]=this[s]>>n;n>0&&(e[this.t-i-1]|=(this.s&r)<<o),e.t=this.t-i,e.clamp()}},i.prototype.subTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]-t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n-=t[i],e[i++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},i.prototype.multiplyTo=function(t,e){var n=this.abs(),o=t.abs(),r=n.t;for(e.t=r+o.t;--r>=0;)e[r]=0;for(r=0;r<o.t;++r)e[r+n.t]=n.am(0,o[r],e,r,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&i.ZERO.subTo(e,e)},i.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var n=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,n,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,o){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t)return null!=e&&e.fromInt(0),void(null!=o&&this.copyTo(o));null==o&&(o=n());var a=n(),c=this.s,h=t.s,l=this.DB-u(r[r.t-1]);l>0?(r.lShiftTo(l,a),s.lShiftTo(l,o)):(r.copyTo(a),s.copyTo(o));var f=a.t,d=a[f-1];if(0!=d){var p=d*(1<<this.F1)+(f>1?a[f-2]>>this.F2:0),g=this.FV/p,m=(1<<this.F1)/p,v=1<<this.F2,_=o.t,y=_-f,b=null==e?n():e;for(a.dlShiftTo(y,b),o.compareTo(b)>=0&&(o[o.t++]=1,o.subTo(b,o)),i.ONE.dlShiftTo(f,b),b.subTo(a,a);a.t<f;)a[a.t++]=0;for(;--y>=0;){var E=o[--_]==d?this.DM:Math.floor(o[_]*g+(o[_-1]+v)*m);if((o[_]+=a.am(0,E,o,y,0,f))<E)for(a.dlShiftTo(y,b),o.subTo(b,o);o[_]<--E;)o.subTo(b,o)}null!=e&&(o.drShiftTo(f,e),c!=h&&i.ZERO.subTo(e,e)),o.t=f,o.clamp(),l>0&&o.rShiftTo(l,o),c<0&&i.ZERO.subTo(o,o)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},i.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var o=n(),r=n(),s=e.convert(this),a=u(t)-1;for(s.copyTo(o);--a>=0;)if(e.sqrTo(o,r),(t&1<<a)>0)e.mulTo(r,s,o);else{var c=o;o=r,r=c}return e.revert(o)},i.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<<e)-1,o=!1,r="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(i=this[s]>>a)>0&&(o=!0,r=c(i));s>=0;)a<e?(i=(this[s]&(1<<a)-1)<<e-a,i|=this[--s]>>(a+=this.DB-e)):(i=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),i>0&&(o=!0),o&&(r+=c(i));return o?r:"0"},i.prototype.negate=function(){var t=n();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+u(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new f(e):new d(e),this.exp(t,i)},i.ZERO=l(0),i.ONE=l(1),b.prototype.convert=E,b.prototype.revert=E,b.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var w,T,k,D=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/D[D.length-1];function x(){var t;t=(new Date).getTime(),T[k++]^=255&t,T[k++]^=t>>8&255,T[k++]^=t>>16&255,T[k++]^=t>>24&255,k>=G&&(k-=G)}if(i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),o=l(i),r=n(),s=n(),a="";for(this.divRemTo(o,r,s);r.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,r.divRemTo(o,r,s);return s.intValue().toString(t)+a},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),o=Math.pow(e,n),r=!1,s=0,a=0,c=0;c<t.length;++c){var l=h(t,c);l<0?"-"==t.charAt(c)&&0==this.signum()&&(r=!0):(a=e*a+l,++s>=n&&(this.dMultiply(o),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),r&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var o=new Array,r=7&t;o.length=1+(t>>3),e.nextBytes(o),r>0?o[0]&=(1<<r)-1:o[0]=0,this.fromString(o,256)}},i.prototype.bitwiseTo=function(t,e,i){var n,o,r=Math.min(t.t,this.t);for(n=0;n<r;++n)i[n]=e(this[n],t[n]);if(t.t<this.t){for(o=t.s&this.DM,n=r;n<this.t;++n)i[n]=e(this[n],o);i.t=this.t}else{for(o=this.s&this.DM,n=r;n<t.t;++n)i[n]=e(o,t[n]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},i.prototype.changeBit=function(t,e){var n=i.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n},i.prototype.addTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]+t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n+=t[i],e[i++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},i.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},i.prototype.multiplyLowerTo=function(t,e,i){var n,o=Math.min(this.t+t.t,e);for(i.s=0,i.t=o;o>0;)i[--o]=0;for(n=i.t-this.t;o<n;++o)i[o+this.t]=this.am(0,t[o],i,o,0,this.t);for(n=Math.min(t.t,e);o<n;++o)this.am(0,t[o],i,o,0,e-o);i.clamp()},i.prototype.multiplyUpperTo=function(t,e,i){--e;var n=i.t=this.t+t.t-e;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)i[this.t+n-e]=this.am(e-n,t[n],i,0,0,this.t+n-e);i.clamp(),i.drShiftTo(1,i)},i.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),o=e.getLowestSetBit();if(o<=0)return!1;var r=e.shiftRight(o);(t=t+1>>1)>D.length&&(t=D.length);for(var s=n(),a=0;a<t;++a){s.fromInt(D[Math.floor(Math.random()*D.length)]);var c=s.modPow(r,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(e)){for(var h=1;h++<o&&0!=c.compareTo(e);)if(0==(c=c.modPowInt(2,this)).compareTo(i.ONE))return!1;if(0!=c.compareTo(e))return!1}}return!0},i.prototype.clone=function(){var t=n();return this.copyTo(t),t},i.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},i.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,o=0;if(t-- >0)for(n<this.DB&&(i=this[t]>>n)!=(this.s&this.DM)>>n&&(e[o++]=i|this.s<<this.DB-n);t>=0;)n<8?(i=(this[t]&(1<<n)-1)<<8-n,i|=this[--t]>>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&i&&(i|=-256),0==o&&(128&this.s)!=(128&i)&&++o,(o>0||i!=this.s)&&(e[o++]=i);return e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=n();return this.bitwiseTo(t,p,e),e},i.prototype.or=function(t){var e=n();return this.bitwiseTo(t,g,e),e},i.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,m,e),e},i.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,v,e),e},i.prototype.not=function(){for(var t=n(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},i.prototype.shiftLeft=function(t){var e=n();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=n();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},i.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+_(this[t]);return this.s<0?this.t*this.DB:-1},i.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=y(this[i]^e);return t},i.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},i.prototype.setBit=function(t){return this.changeBit(t,g)},i.prototype.clearBit=function(t){return this.changeBit(t,v)},i.prototype.flipBit=function(t){return this.changeBit(t,m)},i.prototype.add=function(t){var e=n();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=n();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=n();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=n();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=n();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=n(),i=n();return this.divRemTo(t,e,i),new Array(e,i)},i.prototype.modPow=function(t,e){var i,o,r=t.bitLength(),s=l(1);if(r<=0)return s;i=r<18?1:r<48?3:r<144?4:r<768?5:6,o=r<8?new f(e):e.isEven()?new S(e):new d(e);var a=new Array,c=3,h=i-1,p=(1<<i)-1;if(a[1]=o.convert(this),i>1){var g=n();for(o.sqrTo(a[1],g);c<=p;)a[c]=n(),o.mulTo(g,a[c-2],a[c]),c+=2}var m,v,_=t.t-1,y=!0,b=n();for(r=u(t[_])-1;_>=0;){for(r>=h?m=t[_]>>r-h&p:(m=(t[_]&(1<<r+1)-1)<<h-r,_>0&&(m|=t[_-1]>>this.DB+r-h)),c=i;!(1&m);)m>>=1,--c;if((r-=c)<0&&(r+=this.DB,--_),y)a[m].copyTo(s),y=!1;else{for(;c>1;)o.sqrTo(s,b),o.sqrTo(b,s),c-=2;c>0?o.sqrTo(s,b):(v=s,s=b,b=v),o.mulTo(b,a[m],s)}for(;_>=0&&!(t[_]&1<<r);)o.sqrTo(s,b),v=s,s=b,b=v,--r<0&&(r=this.DB-1,--_)}return o.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return i.ZERO;for(var n=t.clone(),o=this.clone(),r=l(1),s=l(0),a=l(0),c=l(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(r.isEven()&&s.isEven()||(r.addTo(this,r),s.subTo(t,s)),r.rShiftTo(1,r)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;o.isEven();)o.rShiftTo(1,o),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);n.compareTo(o)>=0?(n.subTo(o,n),e&&r.subTo(a,r),s.subTo(c,s)):(o.subTo(n,o),e&&a.subTo(r,a),c.subTo(s,c))}return 0!=o.compareTo(i.ONE)?i.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},i.prototype.pow=function(t){return this.exp(t,new b)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var o=e.getLowestSetBit(),r=i.getLowestSetBit();if(r<0)return e;for(o<r&&(r=o),r>0&&(e.rShiftTo(r,e),i.rShiftTo(r,i));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=i.getLowestSetBit())>0&&i.rShiftTo(o,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return r>0&&i.lShiftTo(r,i),i},i.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=D[D.length-1]){for(e=0;e<D.length;++e)if(i[0]==D[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<D.length;){for(var n=D[e],o=e+1;o<D.length&&n<A;)n*=D[o++];for(n=i.modInt(n);e<o;)if(n%D[e++]==0)return!1}return i.millerRabin(t)},i.prototype.square=function(){var t=n();return this.squareTo(t),t},i.prototype.Barrett=S,null==T){var C;if(T=new Array,k=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var M=new Uint8Array(32);for(window.crypto.getRandomValues(M),C=0;C<32;++C)T[k++]=M[C]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var I=window.crypto.random(32);for(C=0;C<I.length;++C)T[k++]=255&I.charCodeAt(C)}for(;k<G;)C=Math.floor(65536*Math.random()),T[k++]=C>>>8,T[k++]=255&C;k=0,x()}function O(){if(null==w){for(x(),(w=new B).init(T),k=0;k<T.length;++k)T[k]=0;k=0}return w.next()}function R(){}function B(){this.i=0,this.j=0,this.S=new Array}R.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=O()},B.prototype.init=function(t){var e,i,n;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[i],this.S[i]=n;this.i=0,this.j=0},B.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var G=256;t.exports={default:i,BigInteger:i,SecureRandom:R}}).call(p)});H.BigInteger,H.SecureRandom;const{BigInteger:K}=H;class j{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;return(128+e.length/2).toString(16)+e}getValue(){return""}}class W extends j{constructor(t){super(),this.t="02",t&&(this.v=function(t){let e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{e=e.substr(1);let i=e.length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);let n="";for(let t=0;t<i;t++)n+="f";n=new K(n,16),e=n.xor(t).add(K.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class J extends j{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function X(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function $(t,e){const i=X(t,e),n=t.substr(e+2,2*i);if(!n)return-1;return(+n[0]<8?new K(n,16):new K(n.substr(2),16)).intValue()}function Y(t,e){return e+2*(X(t,e)+1)}var Z={encodeDer(t,e){const i=new W(t),n=new W(e);return new J([i,n]).getEncodedHex()},decodeDer(t){const e=Y(t,0),i=Y(t,e),n=$(t,e),o=t.substr(i,2*n),r=i+o.length,s=Y(t,r),a=$(t,r),c=t.substr(s,2*a);return{r:new K(o,16),s:new K(c,16)}}};const{BigInteger:Q}=H,tt=new Q("2"),et=new Q("3");class it{constructor(t,e){this.x=e,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new it(this.q,this.x.negate().mod(this.q))}add(t){return new it(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new it(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new it(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new it(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new it(this.q,this.x.square().mod(this.q))}}class nt{constructor(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?Q.ONE:n,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(Q.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(Q.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(Q.ZERO)&&!this.y.toBigInteger().equals(Q.ZERO)}negate(){return new nt(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=this.z,o=t.x.toBigInteger(),r=t.y.toBigInteger(),s=t.z,a=this.curve.q,c=e.multiply(s).mod(a),h=o.multiply(n).mod(a),l=c.subtract(h),u=i.multiply(s).mod(a),f=r.multiply(n).mod(a),d=u.subtract(f);if(Q.ZERO.equals(l))return Q.ZERO.equals(d)?this.twice():this.curve.infinity;const p=c.add(h),g=n.multiply(s).mod(a),m=l.square().mod(a),v=l.multiply(m).mod(a),_=g.multiply(d.square()).subtract(p.multiply(m)).mod(a),y=l.multiply(_).mod(a),b=d.multiply(m.multiply(c).subtract(_)).subtract(u.multiply(v)).mod(a),E=v.multiply(g).mod(a);return new nt(this.curve,this.curve.fromBigInteger(y),this.curve.fromBigInteger(b),E)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=this.curve.q,o=this.curve.a.toBigInteger(),r=t.square().multiply(et).add(o.multiply(i.square())).mod(n),s=e.shiftLeft(1).multiply(i).mod(n),a=e.square().mod(n),c=a.multiply(t).multiply(i).mod(n),h=s.square().mod(n),l=r.square().subtract(c.shiftLeft(3)).mod(n),u=s.multiply(l).mod(n),f=r.multiply(c.shiftLeft(2).subtract(l)).subtract(h.shiftLeft(1).multiply(a)).mod(n),d=s.multiply(h).mod(n);return new nt(this.curve,this.curve.fromBigInteger(u),this.curve.fromBigInteger(f),d)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(et),i=this.negate();let n=this;for(let o=e.bitLength()-2;o>0;o--){n=n.twice();const r=e.testBit(o);r!==t.testBit(o)&&(n=n.add(r?this:i))}return n}}var ot={ECPointFp:nt,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new nt(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new it(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const e=this.fromBigInteger(new Q(t.substr(2),16));let i=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new Q("4")).add(Q.ONE),this.q));return i.toBigInteger().mod(tt).equals(new Q(t.substr(0,2),16).subtract(tt))||(i=i.negate()),new nt(this,e,i);case 4:case 6:case 7:const n=(t.length-2)/2,o=t.substr(2,n),r=t.substr(n+2,n);return new nt(this,this.fromBigInteger(new Q(o,16)),this.fromBigInteger(new Q(r,16)));default:return null}}}};const{BigInteger:rt,SecureRandom:st}=H,{ECCurveFp:at}=ot,ct=new st,{curve:ht,G:lt,n:ut}=ft();function ft(){const t=new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new rt("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new at(t,e,i),o=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:o,n:new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function dt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var pt={getGlobalCurve:function(){return ht},generateEcparam:ft,generateKeyPairHex:function(t,e,i){const n=(t?new rt(t,e,i):new rt(ut.bitLength(),ct)).mod(ut.subtract(rt.ONE)).add(rt.ONE),o=dt(n.toString(16),64),r=lt.multiply(n);return{privateKey:o,publicKey:"04"+dt(r.getX().toBigInteger().toString(16),64)+dt(r.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const e=(t.length-2)/2,i=t.substr(2,e);let n="03";return new rt(t.substr(e+2,e),16).mod(new rt("2")).equals(rt.ZERO)&&(n="02"),n+i},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,i=[];for(let n=0;n<e;n++)i[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;const n=[];for(let t=0;t<e;t++){const e=i[t>>>2]>>>24-t%4*8&255;n.push((e>>>4).toString(16)),n.push((15&e).toString(16))}return n.join("")},leftPad:dt,arrayToHex:function(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")},arrayToUtf8:function(t){const e=[];let i=0;for(let n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[i],10)<<24-n%8*4,i++;try{const i=[];for(let n=0;n<t.length;n++){const t=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(t))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const e=[];let i=t.length;i%2!=0&&(t=dt(t,i+1)),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e},verifyPublicKey:function(t){const e=ht.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ht.a)).add(ht.b))},comparePublicKeyHex:function(t,e){const i=ht.decodePointHex(t);if(!i)return!1;const n=ht.decodePointHex(e);return!!n&&i.equals(n)}};const gt=new Uint32Array(68),mt=new Uint32Array(64);function vt(t,e){const i=31&e;return t<<i|t>>>32-i}function _t(t,e){const i=[];for(let n=t.length-1;n>=0;n--)i[n]=255&(t[n]^e[n]);return i}function yt(t){return t^vt(t,9)^vt(t,17)}function bt(t){return t^vt(t,15)^vt(t,23)}function Et(t){let e=8*t.length,i=e%512;i=i>=448?512-i%448-1:448-i-1;const n=new Array((i-7)/8),o=new Array(8);for(let t=0,e=n.length;t<e;t++)n[t]=0;for(let t=0,e=o.length;t<e;t++)o[t]=0;e=e.toString(2);for(let t=7;t>=0;t--)if(e.length>8){const i=e.length-8;o[t]=parseInt(e.substr(i),2),e=e.substr(0,i)}else e.length>0&&(o[t]=parseInt(e,2),e="");const r=new Uint8Array([...t,128,...n,...o]),s=new DataView(r.buffer,0),a=r.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<a;t++){gt.fill(0),mt.fill(0);const e=16*t;for(let t=0;t<16;t++)gt[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)gt[t]=bt(gt[t-16]^gt[t-9]^vt(gt[t-3],15))^vt(gt[t-13],7)^gt[t-6];for(let t=0;t<64;t++)mt[t]=gt[t]^gt[t+4];const i=2043430169,n=2055708042;let o,r,a,h,l,u=c[0],f=c[1],d=c[2],p=c[3],g=c[4],m=c[5],v=c[6],_=c[7];for(let t=0;t<64;t++)l=t>=0&&t<=15?i:n,o=vt(vt(u,12)+g+vt(l,t),7),r=o^vt(u,12),a=(t>=0&&t<=15?u^f^d:u&f|u&d|f&d)+p+r+mt[t],h=(t>=0&&t<=15?g^m^v:g&m|~g&v)+_+o+gt[t],p=d,d=vt(f,9),f=u,u=a,_=v,v=vt(m,19),m=g,g=yt(h);c[0]^=u,c[1]^=f,c[2]^=d,c[3]^=p,c[4]^=g,c[5]^=m,c[6]^=v,c[7]^=_}const h=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];h.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}return h}const St=new Uint8Array(64),wt=new Uint8Array(64);for(let t=0;t<64;t++)St[t]=54,wt[t]=92;var Tt={sm3:Et,hmac:function(t,e){for(e.length>64&&(e=Et(e));e.length<64;)e.push(0);const i=_t(e,St),n=_t(e,wt),o=Et([...i,...t]);return Et([...n,...o])}};const{BigInteger:kt}=H,{encodeDer:Dt,decodeDer:At}=Z,xt=Tt.sm3,{G:Ct,curve:Mt,n:It}=pt.generateEcparam();function Ot(t,e,i="1234567812345678"){i=pt.utf8ToHex(i);const n=pt.leftPad(Ct.curve.a.toBigInteger().toRadix(16),64),o=pt.leftPad(Ct.curve.b.toBigInteger().toRadix(16),64),r=pt.leftPad(Ct.getX().toBigInteger().toRadix(16),64),s=pt.leftPad(Ct.getY().toBigInteger().toRadix(16),64);let a,c;if(128===e.length)a=e.substr(0,64),c=e.substr(64,64);else{const t=Ct.curve.decodePointHex(e);a=pt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=pt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=pt.hexToArray(i+n+o+r+s+a+c),l=4*i.length;h.unshift(255&l),h.unshift(l>>8&255);const u=xt(h);return pt.arrayToHex(xt(u.concat(pt.hexToArray(t))))}function Rt(t){const e=Ct.multiply(new kt(t,16));return"04"+pt.leftPad(e.getX().toBigInteger().toString(16),64)+pt.leftPad(e.getY().toBigInteger().toString(16),64)}function Bt(){const t=pt.generateKeyPairHex(),e=Mt.decodePointHex(t.publicKey);return t.k=new kt(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Gt={generateKeyPairHex:pt.generateKeyPairHex,compressPublicKeyHex:pt.compressPublicKeyHex,comparePublicKeyHex:pt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?pt.hexToArray(pt.utf8ToHex(t)):Array.prototype.slice.call(t),e=pt.getGlobalCurve().decodePointHex(e);const n=pt.generateKeyPairHex(),o=new kt(n.privateKey,16);let r=n.publicKey;r.length>128&&(r=r.substr(r.length-128));const s=e.multiply(o),a=pt.hexToArray(pt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=pt.hexToArray(pt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=pt.arrayToHex(xt([].concat(a,t,c)));let l=1,u=0,f=[];const d=[].concat(a,c),p=()=>{f=xt([...d,l>>24&255,l>>16&255,l>>8&255,255&l]),l++,u=0};p();for(let e=0,i=t.length;e<i;e++)u===f.length&&p(),t[e]^=255&f[u++];const g=pt.arrayToHex(t);return 0===i?r+g+h:r+h+g},doDecrypt:function(t,e,i=1,{output:n="string"}={}){e=new kt(e,16);let o=t.substr(128,64),r=t.substr(192);0===i&&(o=t.substr(t.length-64),r=t.substr(128,t.length-128-64));const s=pt.hexToArray(r),a=pt.getGlobalCurve().decodePointHex("04"+t.substr(0,128));if(!a||!pt.verifyPublicKey("04"+t.substr(0,128)))return"array"===n?[]:"";const c=a.multiply(e),h=pt.hexToArray(pt.leftPad(c.getX().toBigInteger().toRadix(16),64)),l=pt.hexToArray(pt.leftPad(c.getY().toBigInteger().toRadix(16),64));let u=1,f=0,d=[];const p=[].concat(h,l),g=()=>{d=xt([...p,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let t=0,e=s.length;t<e;t++)f===d.length&&g(),s[t]^=255&d[f++];return pt.arrayToHex(xt([].concat(h,s,l)))===o.toLowerCase()?"array"===n?s:pt.arrayToUtf8(s):"array"===n?[]:""},doSignature:function(t,e,{pointPool:i,der:n,hash:o,publicKey:r,userId:s}={}){let a="string"==typeof t?pt.utf8ToHex(t):pt.arrayToHex(t);o&&(a=Ot(a,r=r||Rt(e),s));const c=new kt(e,16),h=new kt(a,16);let l=null,u=null,f=null;do{do{let t;t=i&&i.length?i.pop():Bt(),l=t.k,u=h.add(t.x1).mod(It)}while(u.equals(kt.ZERO)||u.add(l).equals(It));f=c.add(kt.ONE).modInverse(It).multiply(l.subtract(u.multiply(c))).mod(It)}while(f.equals(kt.ZERO));return n?Dt(u,f):pt.leftPad(u.toString(16),64)+pt.leftPad(f.toString(16),64)},doVerifySignature:function(t,e,i,{der:n,hash:o,userId:r}={}){let s,a,c="string"==typeof t?pt.utf8ToHex(t):pt.arrayToHex(t);if(o&&(c=Ot(c,i,r)),n){const t=At(e);s=t.r,a=t.s}else s=new kt(e.substring(0,64),16),a=new kt(e.substring(64),16);const h=It.subtract(kt.ONE);if(s.compareTo(kt.ONE)<0||s.compareTo(h)>0)return!1;if(a.compareTo(kt.ONE)<0||a.compareTo(h)>0)return!1;const l=Mt.decodePointHex(i);if(!l||!pt.verifyPublicKey(i))return!1;const u=new kt(c,16),f=s.add(a).mod(It);if(f.equals(kt.ZERO))return!1;const d=Ct.multiply(a).add(l.multiply(f)),p=u.add(d.getX().toBigInteger()).mod(It);return s.equals(p)},getPublicKeyFromPrivateKey:Rt,getPoint:Bt,verifyPublicKey:pt.verifyPublicKey};const{sm3:Lt,hmac:Pt}=Tt;function Nt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function Ft(t){const e=[];let i=t.length;var n,o;i%2!=0&&(o=i+1,t=(n=t).length>=o?n:new Array(o-n.length+1).join("0")+n),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e}const Ut=16,qt=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],zt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function Vt(t){const e=[];for(let i=0,n=t.length;i<n;i+=2)e.push(parseInt(t.substr(i,2),16));return e}function Ht(t,e){const i=31&e;return t<<i|t>>>32-i}function Kt(t){return(255&qt[t>>>24&255])<<24|(255&qt[t>>>16&255])<<16|(255&qt[t>>>8&255])<<8|255&qt[255&t]}function jt(t){return t^Ht(t,2)^Ht(t,10)^Ht(t,18)^Ht(t,24)}function Wt(t){return t^Ht(t,13)^Ht(t,23)}function Jt(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[4*e],o[1]=255&t[4*e+1],o[2]=255&t[4*e+2],o[3]=255&t[4*e+3],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];for(let t,e=0;e<32;e+=4)t=n[1]^n[2]^n[3]^i[e+0],n[0]^=jt(Kt(t)),t=n[2]^n[3]^n[0]^i[e+1],n[1]^=jt(Kt(t)),t=n[3]^n[0]^n[1]^i[e+2],n[2]^=jt(Kt(t)),t=n[0]^n[1]^n[2]^i[e+3],n[3]^=jt(Kt(t));for(let t=0;t<16;t+=4)e[t]=n[3-t/4]>>>24&255,e[t+1]=n[3-t/4]>>>16&255,e[t+2]=n[3-t/4]>>>8&255,e[t+3]=255&n[3-t/4]}function Xt(t,e,i,{padding:n="pkcs#7",mode:o,iv:r=[],output:s="string"}={}){if("cbc"===o&&("string"==typeof r&&(r=Vt(r)),16!==r.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=Vt(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?0!==i?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Vt(t):[...t],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const e=Ut-t.length%Ut;for(let i=0;i<e;i++)t.push(e)}const a=new Array(32);!function(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[0+4*e],o[1]=255&t[1+4*e],o[2]=255&t[2+4*e],o[3]=255&t[3+4*e],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];n[0]^=2746333894,n[1]^=1453994832,n[2]^=1736282519,n[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=n[1]^n[2]^n[3]^zt[i+0],e[i+0]=n[0]^=Wt(Kt(t)),t=n[2]^n[3]^n[0]^zt[i+1],e[i+1]=n[1]^=Wt(Kt(t)),t=n[3]^n[0]^n[1]^zt[i+2],e[i+2]=n[2]^=Wt(Kt(t)),t=n[0]^n[1]^n[2]^zt[i+3],e[i+3]=n[3]^=Wt(Kt(t));if(0===i)for(let t,i=0;i<16;i++)t=e[i],e[i]=e[31-i],e[31-i]=t}(e,a,i);const c=[];let h=r,l=t.length,u=0;for(;l>=Ut;){const e=t.slice(u,u+16),n=new Array(16);if("cbc"===o)for(let t=0;t<Ut;t++)0!==i&&(e[t]^=h[t]);Jt(e,n,a);for(let t=0;t<Ut;t++)"cbc"===o&&0===i&&(n[t]^=h[t]),c[u+t]=n[t];"cbc"===o&&(h=0!==i?n:e),l-=Ut,u+=Ut}if(("pkcs#5"===n||"pkcs#7"===n)&&0===i){const t=c.length,e=c[t-1];for(let i=1;i<=e;i++)if(c[t-i]!==e)throw new Error("padding is invalid");c.splice(t-e,e)}return"array"!==s?0!==i?c.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join(""):function(t){const e=[];for(let i=0,n=t.length;i<n;i++)t[i]>=240&&t[i]<=247?(e.push(String.fromCodePoint(((7&t[i])<<18)+((63&t[i+1])<<12)+((63&t[i+2])<<6)+(63&t[i+3]))),i+=3):t[i]>=224&&t[i]<=239?(e.push(String.fromCodePoint(((15&t[i])<<12)+((63&t[i+1])<<6)+(63&t[i+2]))),i+=2):t[i]>=192&&t[i]<=223?(e.push(String.fromCodePoint(((31&t[i])<<6)+(63&t[i+1]))),i++):e.push(String.fromCodePoint(t[i]));return e.join("")}(c):c}var $t={sm2:Gt,sm3:function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");let i=e.key;if(!i)throw new Error("invalid key");return i="string"==typeof i?Ft(i):Array.prototype.slice.call(i),Nt(Pt(t,i))}return Nt(Lt(t))},sm4:{encrypt:(t,e,i)=>Xt(t,e,1,i),decrypt:(t,e,i)=>Xt(t,e,0,i)}}.sm2;var Yt=["web_id","user_unique_id"],Zt=function(){function e(e){t(this,"name",void 0),t(this,"hook",void 0),t(this,"inited",void 0),t(this,"logger",void 0),t(this,"Types",void 0),t(this,"configManager",void 0),t(this,"appBridge",void 0),t(this,"eventManager",void 0),t(this,"tokenManager",void 0),t(this,"sessionManager",void 0),t(this,"disableAutoPageView",!1),t(this,"bridgeReport",!1),t(this,"staging",!1),t(this,"initConfig",void 0),t(this,"pluginInstances",[]),t(this,"sended",!1),t(this,"started",!1),t(this,"remotePlugin",void 0),t(this,"eventFilter",void 0),t(this,"destroy",!1),t(this,"adapters",{}),t(this,"sdkReady",!1),t(this,"debugger",void 0),t(this,"eventEncrypt",void 0),t(this,"env",void 0),t(this,"dynamicParamsFilter",void 0),t(this,"publicKey",void 0),t(this,"requestManager",void 0),this.name=e,this.hook=new i,this.logger=new R(e),this.remotePlugin=new Map,this.Types=D}e.usePlugin=function(t,i,n){if(i){for(var o=!1,r=0,s=e.plugins.length;r<s;r++){if(e.plugins[r].name===i){e.plugins[r].plugin=t,e.plugins[r].options=n||{},o=!0;break}}o||e.plugins.push({name:i,plugin:t,options:n})}else e.plugins.push({plugin:t})};var o=e.prototype;return o.init=function(t){var i,o=this;this.inited?console.log("init can be call only one time"):t&&n(t)?t.app_id&&("number"==typeof(i=t.app_id)&&!isNaN(i))?!t.app_key||function(t){return"string"==typeof t}(t.app_key)?(t.channel_domain||-1!==["cn","sg","va"].indexOf(t.channel)||(console.warn("channel must be `cn`, `sg`,`va` !!!"),t.channel="cn"),this.logger=new R(this.name,t.log),this.configManager=new O(this,t),this.appBridge=new B(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.debugger=new V(this,t),this.requestManager=new q(this,t),this.initConfig=t,this.env=t.channel_domain?"self":"public",this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:t,level:"info",time:Date.now()}),t.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport?(this.inited=!0,this.emit(D.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new G,this.tokenManager=new U,this.sessionManager=new F,Promise.all([new Promise(function(t){o.once(D.TokenComplete,function(){t(!0)})}),new Promise(function(t){o.once(D.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,n=e.options,r=Object.assign(o.initConfig,n),s=new i;return s.apply(o,r),t.push(s),t},o.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}o.sdkReady=!0,o.emit(D.Ready),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:o.configManager.get("user")}),o.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(o.configManager.get("user"))),o.logger.info("appid: "+t.app_id+", sdk is ready, version is "+w+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}o.pageView(),o.on(D.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||o.pageView(),o.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(D.TokenReset,function(){o.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(D.RouteChange,function(e){e.init||t.disable_route_report||o.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(D.Init))):console.warn("app_key param is error, must be string, please check!"):console.warn("app_id param is error, must be number, please check!"):console.warn("init params error,please check")},o.config=function(t){if(this.inited)if(t&&n(t))if(this.bridgeReport)this.appBridge.setConfig(t);else{t._staging_flag&&1===t._staging_flag&&(this.staging=!0),t.disable_auto_pv&&(this.disableAutoPageView=!0,delete t.disable_auto_pv);var e=Object.assign({},t);if(this.initConfig&&this.initConfig.configPersist){var i=this.configManager.getStore();i&&(e=Object.assign(i,t)),this.configManager.setStore(t)}var o=e;o.web_id,o.user_unique_id;var r=function(t,e){if(null==t)return{};var i={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;i[n]=t[n]}return i}(o,Yt);e.hasOwnProperty("web_id")&&this.emit(D.ConfigWebId,e.web_id),e.hasOwnProperty("user_unique_id")&&this.emit(D.ConfigUuid,e.user_unique_id),this.configManager.set(r),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:e})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},o.setDomain=function(t){this.configManager&&this.configManager.setDomain(t),this.emit(D.ConfigDomain)},o.getConfig=function(t){return this.configManager.get(t)},o.send=function(){this.start()},o.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(D.Start),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(D.Ready)))},o.event=function(t,e){var i=this;try{if(this.initConfig&&this.initConfig.disable_track_event)return;var n=[];if(Array.isArray(t))t.forEach(function(t){var e=i.processEvent(t[0],t[1]||{});e&&n.push(e)});else{var o=this.processEvent(t,e);if(!o)return;n.push(o)}this.bridgeReport?n.forEach(function(t){var e=t.event,n=t.params;i.appBridge.onEventV3(e,JSON.stringify(n))}):n.length&&(this.emit(D.Event,n),this.emit(D.SessionResetTime))}catch(t){this.logger.warn("something error, please check"),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},o.beconEvent=function(t,e){if(!this.initConfig||!this.initConfig.disable_track_event)if(Array.isArray(t))console.warn("beconEvent not support batch report, please check");else{var i=[],n=this.processEvent(t,e||{});n&&(i.push(n),i.length&&(this.emit(D.BeconEvent,i),this.emit(D.SessionResetTime)))}},o.processEvent=function(t,e){void 0===e&&(e={});try{if(!t)return this.logger.warn("eventName is null, please check"),null;var i=t;/^event\./.test(t)&&(i=t.slice(6));var n,o=e;return"object"!=typeof o&&(o={}),o.profile?delete o.profile:o.event_index=r(),o.local_ms?(n=o.local_ms,delete o.local_ms):n=+new Date,{event:i,params:o,local_time_ms:n,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(i){return this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:i.message}),{event:t,params:e}}},o.dynamicParams=function(t){this.dynamicParamsFilter=t},o.filterEvent=function(t){this.eventFilter=t},o.on=function(t,e){this.hook.on(t,e)},o.once=function(t,e){this.hook.once(t,e)},o.off=function(t,e){this.hook.off(t,e)},o.emit=function(t,e,i){this.hook.emit(t,e,i)},o.set=function(t){this.hook.set(t)},o.pageView=function(){this.disableAutoPageView||this.predefinePageView()},o.predefinePageView=function(t){if(void 0===t&&(t={}),this.inited){var e={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},i=Object.assign({},e,t);this.event("predefine_pageview",i)}else console.warn("predefinePageView should call after init")},o.clearEventCache=function(){this.emit(D.CleanEvents)},o.setWebIDviaUnionID=function(t){if(t){var e=u(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(D.CustomWebId)}},o.setWebIDviaOpenID=function(t){if(t){var e=u(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(D.CustomWebId)}},o.setAnonymousId=function(t){this.emit(D.AnonymousId,t)},o.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},o.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},o.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},o.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(D.ResetStay,{url_path:t,title:e,url:i},D.Stay)},o.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(D.SetStay,{url_path:t,title:e,url:i},D.Stay)},o.getToken=function(t,e){var i=this;if(this.inited){var n=!1,o=function(e){if(!n){n=!0;var o=i.configManager.get().user;return e&&(o.tobid=e,o["diss".split("").reverse().join("")]=e),t(Object.assign({},o))}},r=function(){i.tokenManager.getTobId().then(function(t){o(t)})};this.sdkReady?r():(e&&setTimeout(function(){o()},e),this.on(D.Ready,function(){r()}))}else this.logger.warn("getToken must be use after function init")},o.startTrackEvent=function(t){t&&this.emit(D.TrackDurationStart,t,D.TrackDuration)},o.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(D.TrackDurationEnd,{eventName:t,params:e},D.TrackDuration)},o.pauseTrackEvent=function(t){t&&this.emit(D.TrackDurationPause,t,D.TrackDuration)},o.resumeTrackEvent=function(t){t&&this.emit(D.TrackDurationResume,t,D.TrackDuration)},o.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(D.ProfileSet,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:t})},o.profileSetOnce=function(t){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(t)):this.emit(D.ProfileSetOnce,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:t})},o.profileIncrement=function(t){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(t)):this.emit(D.ProfileIncrement,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:t})},o.profileUnset=function(t){this.bridgeReport?this.appBridge.profileUnset(t):this.emit(D.ProfileUnset,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:t})},o.profileAppend=function(t){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(t)):this.emit(D.ProfileAppend,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:t})},o.setExternalAbVersion=function(t){this.bridgeReport?this.appBridge.setExternalAbVersion(t):this.emit(D.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,D.Ab)},o.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(D.AbVar,{name:t,defaultValue:e,callback:i},D.Ab)},o.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(D.AbAllVars,t,D.Ab)},o.getABconfig=function(t,e){this.emit(D.AbConfig,{params:t,callback:e},D.Ab)},o.getAbSdkVersion=function(t){if(!this.bridgeReport||!t)return this.configManager.getAbVersion()||"";this.appBridge.getAbSdkVersion(t)},o.onAbSdkVersionChange=function(t){var e=this;return this.emit(D.AbVersionChangeOn,t,D.Ab),function(){e.emit(D.AbVersionChangeOff,t,D.Ab)}},o.offAbSdkVersionChange=function(t){this.emit(D.AbVersionChangeOff,t,D.Ab)},o.openOverlayer=function(){this.emit(D.AbOpenLayer,"",D.Ab)},o.closeOverlayer=function(){this.emit(D.AbCloseLayer,"",D.Ab)},o.initCrypto=function(){this.publicKey=this.initConfig.crypto_publicKey||"04BA9E229380DC0E41E10839B0C52A4763D3EDFE8903F3B8E81395523381E03AA995D295BD4A4088792E4785B224F7837EB4D2C7C05973C7AE8687A35ACAE470A0",this.initConfig.encryption_header=this.initConfig.encryption_header||"gm_sm2"},o.cryptoData=function(t){try{if(!this.initConfig.enable_encryption)return t;var e;if("sm"===this.initConfig.encryption_type){var i=(r=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+$t.doEncrypt(r,s,a)),n=f(i);e=new Uint8Array(n)}else e="data="+(o=JSON.stringify(t),window.btoa?window.btoa(encodeURIComponent(o)):encodeURIComponent(o));return e}catch(e){return t}var o,r,s,a},o.destoryInstance=function(){this.destroyInstance()},o.destoryInstace=function(){this.destroyInstance()},o.destroyInstance=function(){this.destroy||(this.destroy=!0,this.off(D.TokenComplete))},e}();t(Zt,"plugins",[]);var Qt="__rangers_ab_style__";var te=function(t){return t[t.Var=0]="Var",t[t.All=1]="All",t}(te||{}),ee=2592e6,ie=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"abOption",void 0),t(this,"fetchUrl",void 0),t(this,"reportUrl",void 0),t(this,"fetchStatus","no"),t(this,"refreshFetchStatus","complete"),t(this,"versions",[]),t(this,"extVersions",[]),t(this,"mulilinkVersions",[]),t(this,"enable_multilink",!1),t(this,"enable_ab_visual",!1),t(this,"editMode",!1),t(this,"callbacks",[]),t(this,"abKey",void 0),t(this,"cacheStorgae",void 0),t(this,"data",null),t(this,"changeListener",new Map),t(this,"fetch",void 0),t(this,"readyStatus",!1),t(this,"types",void 0),t(this,"ab_cross",void 0),t(this,"ab_cookie_domain",void 0),t(this,"exposureCache",[]),t(this,"exposureLimit",void 0),t(this,"ab_batch_time",void 0),t(this,"reportTimeout",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_ab_test){var n=e.enable_multilink,o=e.ab_channel_domain,r=e.enable_ab_visual,a=e.ab_cross,c=e.ab_cookie_domain,h=e.disable_ab_reset,l=o||s(T[e.channel||"cn"]);this.cacheStorgae=new b,this.enable_multilink=n,this.enable_ab_visual=r,this.abKey="__tea_sdk_ab_version_"+e.app_id,this.ab_cross=a,this.ab_cookie_domain=c||"",this.fetchUrl=l+"/service/2/abtest_config/",this.reportUrl=""+t.configManager.getUrl("event"),this.exposureLimit=e.exposure_limit||20,this.ab_batch_time=e.ab_batch_time||500;var u=this.collect.Types;this.types=u,this.collect.on(u.TokenChange,function(t){h||"uuid"===t.type&&i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(u.TokenReset,function(){h||i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(u.AbVar,function(t){var e=t.name,n=t.defaultValue,o=t.callback;i.getVar(e,n,o)}),this.collect.on(u.AbAllVars,function(t){i.getAllVars(t)}),this.collect.on(u.AbConfig,function(t){var e=t.params,n=t.callback;i.getABconfig(e,n)}),this.collect.on(u.AbExternalVersion,function(t){i.setExternalAbVersion(t)}),this.collect.on(u.AbOpenLayer,function(){i.openOverlayer()}),this.collect.on(u.AbCloseLayer,function(){i.closeOverlayer()}),this.collect.on(u.AbVersionChangeOn,function(t){i.changeListener.set(t,t)}),this.collect.on(u.AbVersionChangeOff,function(t){i.changeListener.get(t)&&i.changeListener.delete(t)}),this.loadMode(),(this.enable_ab_visual||this.enable_multilink)&&this.openOverlayer(this.config.multilink_timeout_ms||500),this.checkLocal(),this.ready("ab"),this.readyStatus||(this.fetchAB(),this.readyStatus=!0),this.collect.emit(u.AbReady)}},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.loadMode=function(){},i.checkLocal=function(){var t=this.getABCache(),e=t.ab_version,i=t.ab_ext_version,n=t.ab_version_multilink,o=t.data,r=this.checkFromUrl();r?this.mulilinkVersions.push(r):this.mulilinkVersions=n||[],this.extVersions=i||[],this.versions=e||[],this.data=o;var s=this.versions.concat(this.extVersions);this.enable_multilink&&(s=s.concat(this.mulilinkVersions)),this.configVersions(s.join(","))},i.checkFromUrl=function(){var t=l(window.location.href);return t&&t.vid?t.vid:""},i.updateVersions=function(){var t=this.extVersions.length?this.versions.concat(this.extVersions):this.versions;this.enable_multilink&&(t=t.concat(this.mulilinkVersions)),this.configVersions(t.join(",")),this.updateABCache(),this.changeListener.size>0&&this.changeListener.forEach(function(e){"function"==typeof e&&e(t)})},i.configVersions=function(t){this.collect.configManager.setAbVersion(t)},i.getVar=function(t,e,i){if(!t)throw new Error("variable must not be empty");if(void 0===e)throw new Error("variable no default value");if("function"!=typeof i)throw new Error("callback must be a function");var n={name:t,defaultValue:e,callback:i,type:te.Var};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealVar(n,t):this.callbacks.push(n)},i.getRealVar=function(t,e){var i=t.name,o=t.defaultValue,r=t.callback,s=this.data;if(s){if(n(s[i])){var a=s[i].vid;return"$ab_url"===e?this.mulilinkVersions.includes(a)||this.mulilinkVersions.push(a):this.versions.includes(a)||this.versions.push(a),this.updateVersions(),this.fechEvent(a,e,o),r(s[i].val),void this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 曝光了实验"+i,level:"info",time:Date.now(),data:s[i]})}this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getVar",level:"info",time:Date.now(),data:o}),r(o)}else r(o)},i.getAllVars=function(t){if("function"!=typeof t)throw new Error("callback must be a function");var e={callback:t,type:te.All};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealAllVars(e):this.callbacks.push(e)},i.getRealAllVars=function(t){(0,t.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getAllVars",level:"info",time:Date.now(),data:this.data})},i.fechEvent=function(t,e,i){try{if(this.config.disable_track_event)return;if(!t)return;var n=this.collect.configManager.get(),o=n.header,r=n.user,s=this.getABCache();if(s&&s.uuid&&s.uuid!==r.user_unique_id)return;var a={event:"abtest_exposure",ab_sdk_version:""+t,params:JSON.stringify({app_id:this.config.appId,ab_url:"$ab_url"===e?i:window.location.href}),local_time_ms:Date.now()};o.custom=JSON.stringify(o.custom);var c={events:[a],user:r,header:o};"$ab_url"===e&&window.navigator.sendBeacon?window.navigator.sendBeacon(this.reportUrl,JSON.stringify([c])):this.reportExposure(c)}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.reportExposure=function(t){var e=this;this.exposureCache.push(t),this.reportTimeout&&clearTimeout(this.reportTimeout),this.exposureCache.length>=this.exposureLimit?this.report():this.reportTimeout=setTimeout(function(){e.report(),clearTimeout(e.reportTimeout)},this.ab_batch_time)},i.report=function(){var t=this,e=this.collect.cryptoData(this.exposureCache);this.collect.requestManager.useRequest({url:this.reportUrl,data:e,timeout:1e5,useBeacon:!1,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,type:"event"}),this.exposureCache.forEach(function(e){t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:[e],code:200,status:"success"})}),this.exposureCache=[]},i.setExternalAbVersion=function(t){this.extVersions=[t],this.updateVersions()},i.getABconfig=function(t,e){var i=Object.keys(t);i&&i.length&&this.collect.configManager.set(t),this.fetchAB(e)},i.get=function(t){if(this.ab_cross){var e=this.cacheStorgae.getCookie(t,this.ab_cookie_domain);return e?JSON.parse(e):null}return this.cacheStorgae.getLocalItem(t)},i.set=function(t,e){this.ab_cross?this.cacheStorgae.setCookie(t,e,ee,this.ab_cookie_domain):this.cacheStorgae.setLocalItem(t,e),this.collect.configManager.setAbCache(e)},i.getABCache=function(t){var e={ab_version:[],ab_ext_version:[],ab_version_multilink:[],data:null,timestamp:+new Date,uuid:""};return e=this.get(this.abKey)||e,Date.now()-e.timestamp>=ee?(this.cacheStorgae.removeLocalItem(this.abKey),null):t?e[t]:e},i.updateABCache=function(){var t=this.getABCache();t.ab_version_multilink=this.mulilinkVersions,t.ab_ext_version=this.extVersions,t.ab_version=this.versions,t.timestamp=Date.now(),this.set(this.abKey,t)},i.setAbCache=function(t){var e=this.getABCache();e.data=this.data,e.uuid=t,e.timestamp=Date.now(),this.set(this.abKey,e)},i.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},i.openOverlayer=function(t){var e=this;if(function(){if(!document.getElementById(Qt)){var t="body { opacity: 0 !important; }",e=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Qt,i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)}}(),t)var i=setTimeout(function(){e.closeOverlayer(),clearTimeout(i)},t)},i.closeOverlayer=function(){var t;(t=document.getElementById(Qt))&&t.parentElement.removeChild(t)},i.fetchComplete=function(t,e){var i=this;if(t&&"[object Object]"==Object.prototype.toString.call(t)){this.data=t,this.setAbCache(e);var n=[];Object.keys(t).forEach(function(e){var i=t[e].vid;i&&n.push(i)}),this.versions=this.versions.filter(function(t){return n.includes(t)});var o=t.$ab_url,r=t.$ab_modification;if(r&&r.val&&this.enable_ab_visual){if(this.collect.destroy)return;this.getVar("$ab_modification",window.location.href,function(){i.closeOverlayer()})}else if(o&&this.enable_multilink){this.mulilinkVersions=this.mulilinkVersions.filter(function(t){return n.includes(t)});var s=o.val,a=o.vid;s&&a&&this.getVar("$ab_url",s,function(){i.editMode||(s!==window.location.href?setTimeout(function(){if(!i.collect.destroy){var t=""+s;t=-1===t.indexOf("http")?"https://"+t:t;var e=h(t).host;try{var n=new URL(t);e!==location.host?n.searchParams.append("vid",a):window.history.replaceState("","",t),window.location.href=n.href}catch(e){window.location.href=t}}},100):i.closeOverlayer())})}this.updateVersions()}else this.closeOverlayer();this.callbacks.forEach(function(t){return i[t.type===te.Var?"getRealVar":"getRealAllVars"](t,"")}),this.callbacks=[]},i.fetchAB=function(t){var e=this,i=this.collect.configManager.get(),n=i.header,o=i.user;this.config.enable_anonymousid&&delete o.web_id;var r=o.user_unique_id,s={header:Object.assign({aid:this.config.app_id},o||{},n||{},{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})},a=this.collect.cryptoData(s);this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:s,infoType:"sdk"}),this.collect.requestManager.useRequest({url:this.fetchUrl,data:a,success:function(i){e.fetchStatus="complete",e.refreshFetchStatus="complete";var n=i.data;"success"===i.message?(e.fetchComplete(n,r),t&&t(n)):(e.fetchComplete(null,r),t&&t(null)),e.collect.emit(e.types.AbComplete,n),e.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:n,infoType:"sdk"})},fail:function(){e.fetchStatus="complete",e.refreshFetchStatus="complete",e.fetchComplete(null,r),t&&t(null),e.collect.emit(e.types.AbTimeout),e.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求网络异常",level:"error",logType:"fetch",time:Date.now(),infoType:"sdk"})},timeout:this.config.ab_timeout||1e4,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},i.filterUrl=function(t){try{var e="";-1!==t.indexOf("&multilink=true")?e="&multilink=true[\0-ÿ]*":-1!==t.indexOf("?multilink=true")&&(e="\\?multilink=true[\0-ÿ]*");var i=new RegExp(e,"g");t=t.replace(i,"")}catch(t){}return t},e}(),ne=function(){function e(e,i){t(this,"collect",void 0),t(this,"config",void 0),t(this,"pageStartTime",void 0),t(this,"maxDuration",432e5),t(this,"sessionStartTime",void 0),t(this,"timerHandler",void 0),t(this,"url_path",void 0),t(this,"url",void 0),t(this,"title",void 0),t(this,"set_path",void 0),t(this,"set_url",void 0),t(this,"set_title",void 0),t(this,"aliveDTime",6e4),t(this,"aliveName",void 0),t(this,"disableCallback",void 0),t(this,"customParmas",void 0),t(this,"options",{aliveName:"predefine_page_alive",params:{}}),this.collect=e,this.config=i,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,n(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration))}var i=e.prototype;return i.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageAlive(),this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params},i.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},i.sendEvent=function(t,e){void 0===e&&(e=!1);var i=e?this.aliveDTime:Date.now()-this.sessionStartTime;i<0||i>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,Object.assign({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:i,is_support_visibility_change:c(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:t},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},i.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval(function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)},1e3)},i.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},i.beforeunload=function(){document.hidden||this.sendEvent(!0)},i.enablePageAlive=function(){var t=this;this.timerHandler=this.setUpTimer();var e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},e}(),oe=function(){function e(e,i){var o=this;t(this,"collect",void 0),t(this,"config",void 0),t(this,"pageStartTime",void 0),t(this,"maxDuration",432e5),t(this,"sessionStartTime",void 0),t(this,"timerHandler",void 0),t(this,"url_path",void 0),t(this,"url",void 0),t(this,"title",void 0),t(this,"set_path",void 0),t(this,"set_url",void 0),t(this,"set_title",void 0),t(this,"aliveDTime",6e4),t(this,"aliveName",void 0),t(this,"options",{closeName:"predefine_page_close",params:{}}),t(this,"activeStartTime",void 0),t(this,"activeEndTime",void 0),t(this,"activeTimes",void 0),t(this,"totalTime",void 0),t(this,"disableCallback",void 0),t(this,"customParmas",void 0),t(this,"visibilitychange",function(){"hidden"===document.visibilityState?o.activeEndTime=Date.now():"visible"===document.visibilityState&&(o.activeEndTime&&(o.totalTime+=o.activeEndTime-o.activeStartTime,o.activeTimes+=1),o.activeEndTime=void 0,o.activeStartTime=Date.now())}),t(this,"beforeunload",function(){if(o.totalTime+=(o.activeEndTime||Date.now())-o.activeStartTime,o.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:o.totalTime,page_title:document.title||location.pathname}))}catch(t){}}o.sendEventPageClose()}),this.collect=e,this.config=i,this.maxDuration=i.maxDuration||864e5,this.pageStartTime=Date.now(),n(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration)),this.resetData()}var i=e.prototype;return i.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageClose()},i.disable=function(){this.disableCallback()},i.resetData=function(){this.activeStartTime=void 0===this.activeStartTime?this.pageStartTime:Date.now(),this.activeEndTime=void 0,this.activeTimes=1,this.totalTime=0,this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params,this.resetParams(location.pathname,document.title,location.href)},i.sendEventPageClose=function(){var t=Date.now()-this.pageStartTime;this.totalTime<0||t<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,Object.assign({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:t,is_support_visibility_change:c()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},i.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.enablePageClose=function(){var t=this,e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},e}(),re=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"title",void 0),t(this,"url",void 0),t(this,"url_path",void 0),t(this,"pageAlive",void 0),t(this,"pageClose",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_stay_duration){this.title=document.title||location.pathname,this.url=location.href,this.url_path=location.pathname,this.pageAlive=new ne(t,e),this.pageClose=new oe(t,e);var n=this.collect.Types;this.collect.on(n.ResetStay,function(t){var e=t.url_path,n=t.title,o=t.url;i.resetStayDuration(e,n,o)}),this.collect.on(n.RouteChange,function(t){t.init||e.disable_route_report||i.resetStayDuration()}),this.collect.on(n.SetStay,function(t){var e=t.url_path,n=t.title,o=t.url;i.setStayParmas(e,n,o)}),this.enable(this.url_path,this.title,this.url),this.ready(n.Stay),this.collect.emit(n.StayReady)}},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},i.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},i.setStayParmas=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.pageAlive.setParams(t,e,i),this.pageClose.setParams(t,e,i),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},i.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},i.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},e}(),se=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"cache",void 0),t(this,"duration",void 0),t(this,"reportUrl",void 0),t(this,"eventCheck",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.duration=6e4,this.reportUrl=t.configManager.getDomain()+"/profile/list",this.eventCheck=new k(t,e),this.cache={},this.collect.on(D.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(D.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(D.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(D.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(D.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(D.ProfileClear,function(){i.cache={}}),this.ready(D.Profile)},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.report=function(t,e){var i=this;void 0===e&&(e={});try{if(this.config.disable_track_event)return;var n=[];n.push(this.collect.processEvent(t,e));var o=this.collect.eventManager.merge(n,!0),r=this.collect.cryptoData(o);this.collect.configManager.getUrl("profile");this.collect.requestManager.useRequest({url:this.reportUrl,data:r,timeout:1e5,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,success:function(t,e,n,o,r){t&&0!==t.e?i.collect.emit(D.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:r}):i.collect.emit(D.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:r})},fail:function(t,e,n){i.collect.emit(D.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,endTime:Date.now()})}}),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"})}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.setProfile=function(t){var e=this.formatParams(t);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set",Object.assign({},e,{profile:!0})))},i.setOnceProfile=function(t){var e=this.formatParams(t,!0);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set_once",Object.assign({},e,{profile:!0})))},i.incrementProfile=function(t){t?this.report("__profile_increment",Object.assign({},t,{profile:!0})):console.warn("please check the params, must be object!!!")},i.unsetProfile=function(t){if(t){var e={};e[t]="1",this.report("__profile_unset",Object.assign({},e,{profile:!0}))}else console.warn("please check the key, must be string!!!")},i.appendProfile=function(t){if(t){var e={};for(var i in t)"string"==typeof t[i]||"Array"===Object.prototype.toString.call(t[i]).slice(8,-1)?e[i]=t[i]:console.warn("please check the value of param: "+i+", must be string or array !!!");Object.keys(e).length&&this.report("__profile_append",Object.assign({},e,{profile:!0}))}else console.warn("please check the params, must be object!!!")},i.pushCache=function(t){var e=this;Object.keys(t).forEach(function(i){e.cache[i]={val:e.clone(t[i]),timestamp:Date.now()}})},i.formatParams=function(t,e){var i=this;void 0===e&&(e=!1);try{if(!t||"[object Object]"!==Object.prototype.toString.call(t))return void console.warn("please check the params type, must be object !!!");var n={};for(var o in t)"string"==typeof t[o]||"number"==typeof t[o]||"Array"===Object.prototype.toString.call(t[o]).slice(8,-1)?n[o]=t[o]:console.warn("please check the value of params:"+o+", must be string,number,Array !!!");var r=Object.keys(n);if(!r.length)return;var s=Date.now();return r.filter(function(n){var o=i.cache[n];return e?!o:!(o&&i.compare(o.val,t[n])&&s-o.timestamp<i.duration)}).reduce(function(t,e){return t[e]=n[e],t},{})}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("error")}},i.compare=function(t,e){try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),!1}},i.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},i.unReady=function(){console.warn("sdk is not ready, please use this api after start")},e}(),ae=function(){function e(){var e=this;t(this,"sessionInterval",void 0),t(this,"isSessionhasEvent",void 0),t(this,"startTime",void 0),t(this,"lastTime",void 0),t(this,"collect",void 0),t(this,"clearIntervalFunc",void 0),t(this,"setInterval",function(){e.clearIntervalFunc=function(t,e){void 0===t&&(t=function(){}),void 0===e&&(e=1e3);var i,n=Date.now()+e;return i=window.setTimeout(function o(){var r=Date.now()-n;t(),n+=e,i=window.setTimeout(o,Math.max(0,e-r))},e),function(){window.clearTimeout(i)}}(function(){e.isSessionhasEvent&&e.endCurrentSession()},e.sessionInterval)}),t(this,"clearInterval",function(){e.clearIntervalFunc&&e.clearIntervalFunc()})}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,!e.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var n=this.collect.Types;this.collect.on(n.SessionReset,function(){i.process()})}},i.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},i.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var t=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-t>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}();function ce(t,e){if(void 0===e&&(e="list"),!t)return!1;if(e&&"list"===e){if(["LI","TR","DL"].includes(t.nodeName))return!0;if(t.dataset&&t.dataset.hasOwnProperty("teaIdx"))return!0;if(t.hasAttribute&&t.hasAttribute("data-tea-idx"))return!0}else{if(["A","BUTTON"].includes(t.nodeName))return!0;if(t.dataset&&t.dataset.hasOwnProperty("teaContainer"))return!0;if(t.hasAttribute&&t.hasAttribute("data-tea-container"))return!0;if(t.hasAttribute&&de(t,"ss"))return!0}return!1}var he=function(t,e){return!!de(t,e)};function le(t){for(var e=t;e&&!ce(e,"container");){if("HTML"===e.nodeName||"BODY"===e.nodeName)return t;e=e.parentElement}return e||t}function ue(t){for(var e=t;e&&e.parentNode;){if(e.hasAttribute("data-tea-ignore"))return!0;if("HTML"===e.nodeName||"body"===e.nodeName)return!1;e=e.parentNode}return!1}var fe=function(t,e){return t.hasAttribute?t.hasAttribute(e):t.attributes?!(!t.attributes[e]||!t.attributes[e].specified):void 0},de=function(t,e){if("string"==typeof e)return fe(t,e);if(o(e)){for(var i=!1,n=0;n<e.length;n++){if(fe(t,e[n])){i=!0;break}}return i}},pe=function(t,e){var i={};if("string"==typeof e)fe(t,e)&&(i[e]=t.getAttribute(e));else if(o(e))for(var n=0;n<e.length;n++){fe(t,e[n])&&(i[e[n]]=t.getAttribute(e[n]))}return i};var ge=function(){function e(e,i,n){var o=this;t(this,"config",void 0),t(this,"options",void 0),t(this,"beatTime",void 0),t(this,"statistics",void 0),t(this,"eventHandel",void 0),t(this,"collect",void 0),t(this,"clickEvent",function(t){(function(t,e){if(1!==t.nodeType)return!1;if(!e.svg&&function(t){if("svg"===t.tagName.toLowerCase())return!0;for(var e=t.parentElement,i=!1;e;)"svg"===e.tagName.toLowerCase()?(e=null,i=!0):e=e.parentElement;return i}(t))return!1;if(["HTML","BODY"].includes(t.tagName.toUpperCase()))return!1;var i=t;return!!("none"!==i.style.display&&(ce(i,"container")||e.track_attr&&he(i,e.track_attr)||function(t){if(t.children.length){var e=t.children;return![].slice.call(e).some(function(t){return t.children.length>0})}return!0}(i)))})(t.target,o.options)&&o.eventHandel({eventType:"dom",eventName:"click"},t)}),t(this,"changeEvent",function(t){o.eventHandel({eventType:"dom",eventName:"change"},t)}),t(this,"submitEvent",function(t){o.eventHandel({eventType:"dom",eventName:"submit"},t)}),t(this,"getPageViewEvent",function(t,e){e&&"pushState"===e&&o.eventHandel({eventType:"dom",eventName:"beat"},Object.assign({beat_type:0},t)),o.eventHandel({eventType:"dom",eventName:"page_view"},t)}),t(this,"getPageLoadEvent",function(t){o.eventHandel({eventType:"dom",eventName:"page_statistics"},{lcp:t})}),this.config=n.getConfig().eventConfig,this.collect=i,this.options=e,this.beatTime=e.beat,this.statistics=!1}var i=e.prototype;return i.init=function(t){this.eventHandel=t;var e=this.config.mode;this.addListener(e)},i.addListener=function(t){var e=this;if("proxy-capturing"===t&&(this.config.click&&window.document.addEventListener("click",this.clickEvent,!0),this.config.change&&window.document.addEventListener("change",this.changeEvent,!0),this.config.submit&&window.document.addEventListener("submit",this.submitEvent,!0),this.config.pv&&this.collect.on("route-change",function(t){var i=t.config,n=t.name;e.getPageViewEvent(i,n)}),this.config.beat)){try{"complete"===document.readyState?this.beatEvent(this.beatTime):window.addEventListener("load",function(){e.beatEvent(e.beatTime)});var i=0,n=null;window.addEventListener("scroll",function(){clearTimeout(n),n=setTimeout(o,500),i=document.documentElement.scrollTop||document.body.scrollTop});var o=function(){(document.documentElement.scrollTop||document.body.scrollTop)==i&&e.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:1})}}catch(t){}try{var r=window.performance&&window.performance.getEntriesByType("paint");if(r&&r.length){var s=new PerformanceObserver(function(t){var i=t.getEntries(),n=i[i.length-1],o=n.renderTime||n.loadTime;e.statistics||(e.getPageLoadEvent(o),e.statistics=!0)});s.observe({entryTypes:["largest-contentful-paint"]}),setTimeout(function(){e.statistics||(e.getPageLoadEvent(r[0].startTime||0),e.statistics=!0)},2e3)}else this.getPageLoadEvent(0)}catch(t){this.getPageLoadEvent(0)}}},i.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},i.beatEvent=function(t){var e=this;try{var i;this.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:3}),this.beatTime&&(i=setInterval(function(){e.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:2})},t)),a(function(){e.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),e.beatTime&&clearInterval(i)})}catch(t){}},e}(),me={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},ve=function(){function e(e,i){t(this,"config",void 0),this.config=e,this.config.eventConfig=Object.assign(this.config.eventConfig,i)}var i=e.prototype;return i.getConfig=function(){return this.config},i.setConfig=function(t){return this.config=t},e}();function _e(t){for(var e=[];null!==t.parentElement;)e.push(t),t=t.parentElement;var i=[],n=[];return e.forEach(function(t){var e=function(t){if(null===t)return{str:"",index:0};var e=0,i=t.parentElement;if(i)for(var n=i.children,o=0;o<n.length&&n[o]!==t;o++)n[o].nodeName===t.nodeName&&e++;return{str:[t.nodeName.toLowerCase(),ce(t,"list")?"[]":""].join(""),index:e}}(t),o=e.str,r=e.index;i.unshift(o),n.unshift(r)}),{element_path:"/"+i.join("/"),positions:n}}function ye(t,e,i,n){var o={},r=function(t){if(t){var e=t.getBoundingClientRect(),i=e.width,n=e.height;return{left:e.left,top:e.top,element_width:i,element_height:n}}}(e),s=function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var i=t,n=i.clientX,o=i.clientY,r=e,s=r.left,a=r.top,c=n-s>=0?n-s:0,h=o-a>=0?o-a:0;return{touch_x:Math.floor(c),touch_y:Math.floor(h)}}(t,r),a=r.element_width,c=r.element_height,h=s.touch_x,l=s.touch_y,u=_e(e),f=u.element_path,d=u.positions,p=function(t){var e=le(t),i=[];return function t(e){var n=function(t){var e="";return 3===t.nodeType?e=t.textContent.trim():t.dataset&&t.dataset.hasOwnProperty("teaTitle")||t.hasAttribute("ata-tea-title")?e=t.getAttribute("data-tea-title"):t.hasAttribute("title")?e=t.getAttribute("title"):"INPUT"===t.nodeName&&["button","submit"].includes(t.getAttribute("type"))?e=t.getAttribute("value"):"IMG"===t.nodeName&&t.getAttribute("alt")&&(e=t.getAttribute("alt")),e.slice(0,200)}(e);if(n&&-1===i.indexOf(n)&&i.push(n),e.childNodes.length>0)for(var o=e.childNodes,r=0;r<o.length;r++)8!==o[r].nodeType&&t(o[r])}(e),i}(e),g=window.performance.timing.navigationStart,m=Date.now()-g,v=d.map(function(t){return""+t}),_=null;if(window.TEAVisualEditor&&window.TEAVisualEditor.getOriginXpath&&(_=window.TEAVisualEditor.getOriginXpath({xpath:f,positions:v})),o.element_path=_&&_.xpath||f,o.positions=_&&_.positions||v,n&&!n.text&&(o.texts=p,o.element_title=function(t){if(!t)return"";var e="";return t.textContent?e=t.textContent.trim():t.innerText&&(e=t.innerText.trim()),"input"!==t.tagName&&"INPUT"!==t.tagName||(e=t.value||""),e}(e)),o.element_id=e.getAttribute("id")||"",o.element_class_name=e.getAttribute("class")||"",o.element_type=e.nodeType,o.element_width=Math.floor(a),o.element_height=Math.floor(c),o.touch_x=h,o.touch_y=l,o.page_manual_key="",o.elememt_manual_key="",o.since_page_start_ms=m,o.page_start_ms=g,o.page_path=location.pathname,o.page_host=location.host,i.track_attr&&he(e,i.track_attr)){var y=pe(e,i.track_attr);for(var b in y)o[b]=y[b]}if(i.custom_attr)try{if(he(e,i.custom_attr)){var E=pe(e,i.custom_attr),S=decodeURIComponent(E[i.custom_attr]),w=JSON.parse(S);if(Object.keys(w))for(var T in w)o[T]=w[T]}}catch(t){console.log("custom attr error")}var k=le(e);return"A"===k.tagName&&(o.href=k.getAttribute("href")),!1!==i.src&&("IMG"!==e.tagName||e.getAttribute("src").includes("base64")||(o.src=e.getAttribute("src"))),o}var be=function(t,e,i,n,o){return Object.assign({event:t},ye(e,i,n,o),{is_html:1,page_key:window.location.href,page_title:document.title})},Ee=function(){function e(e,i){t(this,"eventName",void 0),t(this,"ignore",{text:!1}),t(this,"initConfig",void 0),t(this,"options",void 0),this.initConfig=e,this.options=i,this.eventName=i&&"tea"===i.custom?{click:"__bav_click",page:"__bav_page",beat:"__bav_beat",static:"__bav_page_statistics",exposure:"__bav_page_exposure"}:{click:"bav2b_click",page:"bav2b_page",beat:"bav2b_beat",static:"bav2b_page_statistics",exposure:"bav2b_exposure",scroll:"$bav2b_slide"},i&&!1===i.text&&(this.ignore.text=!0),i&&i.exposure&&i.exposure.eventName&&(this.eventName.exposure=i.exposure.eventName)}var i=e.prototype;return i.handleEvent=function(t,e){try{if(ue(t.target))return null;var i="bav2b_click";switch(e){case"click":return i=this.eventName.click,be(i,t,t.target,this.options,this.ignore);case"exposure":return i=this.eventName.exposure,be(i,t,t.target,this.options,this.ignore);case"change":return i="bav2b_change",Object.assign({},be(i,t,t.target,this.options),function(t,e){try{if("bav2b_change"===t)return e.hasAttribute("data-tea-track")?{value:e.value}:{}}catch(t){return{}}}(i,t.target));case"submit":return be(i="bav2b_submit",t,t.target,this.options)}}catch(t){return console.error(t),null}},i.handleViewEvent=function(t){t.event=this.eventName.page,t.page_title=document.title,t.page_total_width=window.innerWidth,t.page_total_height=window.innerHeight;try{var e=window.sessionStorage.getItem("_tea_cache_duration");if(e){var i=JSON.parse(e);t.refer_page_duration_ms=i?i.duration:""}t.scroll_width=document.documentElement.scrollLeft?document.documentElement.scrollLeft+window.innerWidth:window.innerWidth,t.scroll_height=document.documentElement.scrollTop?document.documentElement.scrollTop+window.innerHeight:window.innerHeight,t.page_start_ms=window.performance.timing.navigationStart}catch(t){console.log("page event error "+JSON.stringify(t))}return t},i.handleStatisticsEvent=function(t){var e={};e.event=this.eventName.static,e.is_html=1,e.page_key=location.href,e.refer_page_key=document.referrer||"",e.page_title=document.title,e.page_manual_key=this.initConfig.autotrack.page_manual_key||"",e.refer_page_manual_key="";try{var i=t.lcp,n=window.performance.timing,o=n.loadEventEnd-n.navigationStart;e.page_init_cost_ms=parseInt(i||(o>0?o:0)),e.page_start_ms=n.navigationStart}catch(t){console.log("page_statistics event error "+JSON.stringify(t))}return e},i.handleBeadtEvent=function(t){t.event=this.eventName.beat,t.page_key=window.location.href,t.is_html=1,t.page_title=document.title,t.page_manual_key=this.initConfig.autotrack.page_manual_key||"";try{t.page_viewport_width=window.innerWidth,t.page_viewport_height=window.innerHeight,t.page_total_width=document.documentElement.scrollWidth,t.page_total_height=document.documentElement.scrollHeight,t.scroll_width=document.documentElement.scrollLeft+window.innerWidth,t.scroll_height=document.documentElement.scrollTop+window.innerHeight,t.since_page_start_ms=Date.now()-window.performance.timing.navigationStart,t.page_start_ms=window.performance.timing.navigationStart}catch(t){console.log("beat event error "+JSON.stringify(t))}return t},i.handleExposureEvent=function(t,e){if(ue(e.target))return null;var i=be(t.event||this.eventName.exposure,e,e.target||e,this.options,this.ignore);if(i.$exposure_type=t.exposureType,this.options.exposure.callback){var n=this.options.exposure.callback(i);return n||Object.keys(n).length?n:(console.warn("exposure callback must return data!"),i)}return i},i.handleScrollEvent=function(t,e){var i=be(t.event||this.eventName.scroll,e,e.target||e,this.options,this.ignore);if(i=Object.assign(i,t.params),!this.options.scroll.callback||(i=this.options.scroll.callback(i))||Object.keys(i).length)return i;console.warn("scroll callback must return data!")},e}(),Se=function(){function e(e){t(this,"logFunc",void 0),t(this,"logFuncBecon",void 0),t(this,"collect",void 0),this.collect=e}var i=e.prototype;return i.send=function(t,e){var i=e.event;delete e.event,t&&"becon"===t.eventSend?this.collect.beconEvent(i,e):this.collect.event(i,e)},i.get=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"GET"},e);fetch(t,i)},i.post=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"POST"},e);fetch(t,i)},e}(),we=function(){function e(e,i){t(this,"_instance",void 0),t(this,"_intersection",void 0),t(this,"config",void 0),this._instance=null,this._intersection=e,this.config=i,this._intersection&&this.init()}var i=e.prototype;return i.init=function(){var t=this;if(window.MutationObserver)try{if(this._instance=new MutationObserver(function(e){e.forEach(function(e){"attributes"===e.type&&t.attributeChangeObserve(e),"childList"===e.type&&t.modifyNodeObserve(e)})}),!document||!document.body)return void console.warn("please use sdk api init after body element");var e=!1!==this.config.autotrack.exposure.attributes;this._instance.observe(document.body,{childList:!0,attributes:e,subtree:!0,attributeOldValue:!1})}catch(t){console.log("your browser cannot support MutationObserver,so cannot report exposure event, please update")}else console.log("your browser cannot support MutationObserver,so cannot report exposure event, please update")},i.attributeChangeObserve=function(t){t.target.hasAttribute("data-exposure")?this.exposureAdd(t,"mutation"):this.exposureRemove(t)},i.modifyNodeObserve=function(t){var e=this;Array.prototype.forEach.call(t.addedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e.exposureAdd(t,"intersect"),e.mapChild(t,e.exposureAdd.bind(e))}),Array.prototype.forEach.call(t.removedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e.exposureRemove(t),e.mapChild(t,e.exposureRemove.bind(e))})},i.mapChild=function(t,e){var i=this;1===t.nodeType&&t.children.length&&Array.prototype.forEach.call(t.children,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e(t),i.mapChild(t,e)})},i.exposureAdd=function(t,e){try{this._intersection&&this._intersection.exposureAdd(t,e)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},i.exposureRemove=function(t){try{this._intersection&&this._intersection.exposureRemove(t)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},e}();t(we,"_exposure_observer",null);var Te=function(t){return t[t.EXPOSURE_ONCE=0]="EXPOSURE_ONCE",t[t.LIFECYCLE_SHOW_NEW=3]="LIFECYCLE_SHOW_NEW",t[t.RESUME_FORM_PAGE=6]="RESUME_FORM_PAGE",t[t.RESUME_FORM_BACK=7]="RESUME_FORM_BACK",t[t.NOT_EXPOSURE=-1]="NOT_EXPOSURE",t}(Te||{}),ke=function(){function e(i,n,o){var r=this;t(this,"count",void 0),t(this,"instance",void 0),t(this,"observeMap",void 0),t(this,"ratio",void 0),t(this,"eventHandle",void 0),t(this,"timeLimit",void 0),t(this,"exposureType",void 0),t(this,"hashMap",void 0),t(this,"lastState",void 0),t(this,"backStatus",!1),t(this,"customType",void 0),t(this,"collect",void 0),this.instance=this.buildObserver(),this.collect=i,this.observeMap=e._observer_map,n.autotrack.exposure.ratio?this.ratio=n.autotrack.exposure.ratio:0===n.autotrack.exposure.ratio?this.ratio=0:this.ratio=.5,this.timeLimit=n.autotrack.exposure.stay||0,this.exposureType=Te.NOT_EXPOSURE,this.eventHandle=o,this.hashMap=new Map,this.backStatus=!1,this.lastState=null,this.collect.on("re-start-sdk",function(){r.visibilitychange()}),this.addListen()}var i=e.prototype;return i.buildObserver=function(){var t=this;if(e._observer_instance)return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null;if(window.IntersectionObserver){for(var i=[],n=0;n<=1;n+=.01)i.push(n);i.push(1);try{e._observer_instance=new IntersectionObserver(function(e){e.forEach(function(e){var i=e.target.observeId,n=t.observeMap.get(i),o=(e.target,e.isIntersecting,e.intersectionRatio);if(n.intersectionRatio=o,o<=.1&&(e.target.backStatus=!1),t.observeMap.set(i,n),o<t.ratio)return n.isIntersecting=!1,n.added=!1,n.exposured=!1,n.startTime=Date.now(),void t.observeMap.set(i,n);if(!n.added){if(n.startTime=Date.now(),n.added=!0,n.isIntersecting=!0,t.timeLimit){var r=setTimeout(function(){try{if(n.isIntersecting&&!n.exposured&&t.observeMap.get(i)){var o=t.observeMap.get(i).intersectionRatio;t.exposureEvent(e,o,i,n)}}catch(t){console.log("IntersectionObserver setTimeout error,msg: "+JSON.stringify(t))}},t.timeLimit);n.wait=r}t.observeMap.set(i,n)}Date.now()-n.startTime>=t.timeLimit&&!n.exposured&&t.exposureEvent(e,o,i,n)})},{threshold:i})}catch(t){console.log("IntersectionObserver error,msg: "+JSON.stringify(t))}return e._observer_instance}return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null},i.exposureAdd=function(t,e){var i="mutation"===e?t.target:t,n=i.observeId,o=P();if(n||this.observeMap.has(n)){var r=this.observeMap.get(n);if(r&&i!==r.instance)this.unobserve(i),this.observeMap.delete(n),i.observeId=o,i.visible=!1,this.observeMap.set(o,{instance:i.cloneNode(!0),isIntersecting:!1}),this.observe(i);else{if(!0===i.visible)return;this.handleBoundingExposure(i)}}else i.observeId=o,i.visible=!1,this.observeMap.set(o,{instance:i.cloneNode(!0),isIntersecting:!1}),this.observe(i)},i.exposureRemove=function(t){this.observeMap.has(t.observeId)&&(this.observeMap.delete(t.observeId),this.unobserve(t),t.observeId="",t.visible=!1)},i.exposureEvent=function(t,e,i,n){if(e>=this.ratio){if("0"===t.target.style.opacity||"hidden"===t.target.style.visibility)return;if(!0===n.exposured)return;n.startWait&&clearTimeout(n.startWait);var o=t.target.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:o,exposureType:this.getExposureType(t.target)},t),t.target.visible=!0,t.target.hasExposure=!0,n.startTime=Date.now(),n.exposured=!0}else n.startTime=Date.now(),n.exposured=!1;this.observeMap.set(i,n)},i.observe=function(t){this.instance&&this.instance.observe(t)},i.unobserve=function(t){this.instance&&this.instance.unobserve(t)},i.getExposureDomToExposure=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t.handleBoundingExposure(e)})},i.visibilitychange=function(){var t=this,e=null;"visible"===document.visibilityState?this.timeLimit?e=setTimeout(function(){t.getExposureDomToExposure()},this.timeLimit):this.getExposureDomToExposure():(clearTimeout(e),this.customType=void 0)},i.handleBoundingExposure=function(t){if(this.getBoundingRatio(t)>=this.ratio){t.visible=!0;var e=t.getAttribute&&t.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:e,exposureType:this.customType||Te.RESUME_FORM_BACK},t)}},i.getBoundingRatio=function(t){var e=t.getBoundingClientRect(),i=e.top,n=e.left,o=e.width,r=e.height,s=window.innerWidth||document.documentElement.clientWidth,a=window.innerHeight||document.documentElement.clientHeight;return i>=0&&n>=0&&i<=a&&n<=s?(o>s?s:o)*(a-i)/(o*r):0},i.getExposureType=function(t){return t.visible?!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Te.RESUME_FORM_PAGE:this.exposureType=Te.LIFECYCLE_SHOW_NEW:(t.hasExposure,!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Te.RESUME_FORM_PAGE:this.exposureType=Te.EXPOSURE_ONCE),this.exposureType},i.addListen=function(){var t=this;this.collect.on("set-exposure-type",function(e){t.customType=e});var e,i,n,o,r=this.visibilitychange.bind(this);if(e=document,i="visibilitychange",n=r,o=!1,e.addEventListener?e.addEventListener(i,n,o):e.attachEven?e.attachEven("on"+i,n):e["on"+i]=n,window.addEventListener("hashchange",function(e){var i=t.hashMap.get(e.oldURL);i&&location.href===i.prev?(t.backStatus=!0,t.exposureType=Te.RESUME_FORM_PAGE):(t.backStatus=!1,t.hashMap.set(location.href,{current:e.newURL,prev:e.oldURL}))}),this.collect.bridgeReport){var s=window.history.pushState;history.pushState=function(e){"function"==typeof history.onpushstate&&history.onpushstate({state:e});for(var i=arguments.length,n=new Array(i>1?i-1:0),o=1;o<i;o++)n[o-1]=arguments[o];var r=s.call.apply(s,[history,e].concat(n));return t.lastState=e,r};var a=history.replaceState;history.replaceState=function(e){"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});for(var i=arguments.length,n=new Array(i>1?i-1:0),o=1;o<i;o++)n[o-1]=arguments[o];var r=a.call.apply(a,[history,e].concat(n));return t.lastState=e,r}}else this.collect.on("STATE_CHANGE",function(e){t.lastState=e});return window.addEventListener("popstate",function(e){var i=e.state;i&&i.current&&t.lastState&&t.lastState.back&&i.current===t.lastState.back?(t.backStatus=!0,t.exposureType=Te.RESUME_FORM_PAGE):t.backStatus=!1}),function(){!function(t,e,i,n){t.addEventListener?t.removeEventListener(e,i,n):t.attachEven&&t.detachEven("on"+e,i)}(document,"visibilitychange",r,!1)}},e}();t(ke,"_observer_instance",null),t(ke,"_observer_map",new Map);var De=function(){function e(e,i,n){t(this,"_observer",void 0),t(this,"_intersection",void 0),i.autotrack&&i.autotrack.exposure&&(this._intersection=new ke(e,i,n),this._observer=new we(this._intersection,i),this._intersection&&this._observer?this.initObserver():console.log("your browser version cannot support exposure event, please update~"))}return e.prototype.initObserver=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t._intersection.exposureAdd(e,"intersect")})},e}(),Ae=function(t){return t[t.SCROLL_UP=1]="SCROLL_UP",t[t.SCROLL_DOWN=2]="SCROLL_DOWN",t[t.SCROLL_LEFT=3]="SCROLL_LEFT",t[t.SCROLL_RIGHT=4]="SCROLL_RIGHT",t[t.NOT_SCROLL=-1]="NOT_SCROLL",t}(Ae||{}),xe=function(){function e(e,i){t(this,"eventHandle",void 0),t(this,"distance",30),t(this,"scrollType",void 0),e.autotrack&&e.autotrack.scroll&&(e.autotrack.scroll.distance&&(this.distance=e.autotrack.scroll.distance),this.eventHandle=i,this.addLinstenr(),this.mutation())}var i=e.prototype;return i.addLinstenr=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-scroll]"),function(e){t.scrollHandle(e)})},i.mutation=function(){var t=this;if(window.MutationObserver)try{var e=new MutationObserver(function(e){e.forEach(function(e){"childList"===e.type&&t.modifyNodeObserve(e)})});if(!document||!document.body)return void console.warn("please use sdk api init after body element");e.observe(document.body,{childList:!0,attributes:!0,subtree:!0,attributeOldValue:!1})}catch(t){console.log("your browser cannot support MutationObserver")}else console.log("your browser cannot support MutationObserver")},i.modifyNodeObserve=function(t){var e=this;Array.prototype.forEach.call(t.addedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e.scrollHandle(t),e.mapChild(t,e.scrollHandle.bind(e))}),Array.prototype.forEach.call(t.removedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e.scrollHandle(t,"remove"),e.mapChild(t,e.scrollHandle.bind(e))})},i.mapChild=function(t,e){var i=this;1===t.nodeType&&t.children.length&&Array.prototype.forEach.call(t.children,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e(t),i.mapChild(t,e)})},i.scrollHandle=function(t,e){var i=this;try{var n=t.scrollTop,o=t.scrollLeft,r=null,s=0,a=0,c=function(e){clearTimeout(r),r=setTimeout(function(){var r=t.scrollTop,u=t.scrollLeft,f=e.target&&e.target.getAttribute("data-scroll-event")||"";1===l||2===l?r===c&&(a=c-n,Math.abs(a)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:l,$offsetY:a,$offsetX:s}},e)):3!==l&&4!==l||u===h&&(s=h-o,Math.abs(s)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:l,$offsetY:a,$offsetX:s}},e)),n=c,o=h},100);var c=t.scrollTop,h=t.scrollLeft,l=Ae.NOT_SCROLL;c>n?l=Ae.SCROLL_DOWN:c<n?l=Ae.SCROLL_UP:h>o?l=Ae.SCROLL_LEFT:h<o&&(l=Ae.SCROLL_RIGHT)};return"remove"===e?t.removeEventListener("scroll",c,!1):t.addEventListener("scroll",c,!1),function(){t.removeEventListener("scroll",c,!1)}}catch(t){console.warn("scroll event error",JSON.stringify(t))}},e}(),Ce={hashTag:!1,impr:!1},Me=function(){function e(){t(this,"engine",void 0),t(this,"Listener",void 0),t(this,"EventHandle",void 0),t(this,"Request",void 0),t(this,"Exposure",void 0),t(this,"Scroll",void 0),t(this,"Config",void 0),t(this,"options",void 0),t(this,"destroyed",void 0),t(this,"autoTrackStart",void 0),t(this,"collect",void 0),t(this,"config",void 0)}var i=e.prototype;return i.apply=function(t,e){if(this.autoTrackStart=!1,this.collect=t,this.config=e,e.autotrack&&(!e.autotrack||!e.autotrack.collect_url||e.autotrack.collect_url())){var i=t.Types;this.ready(i.Autotrack),this.collect.emit(i.AutotrackReady)}},i.ready=function(t){this.collect.set(t);var e=this.config.autotrack;e="object"==typeof e?e:{},e=Object.assign(Ce,e),this.destroyed=!1,this.options=e,this.Config=new ve(me,this.options),this.Exposure=new De(this.collect,this.config,this.handle.bind(this)),this.Scroll=new xe(this.config,this.handle.bind(this)),this.Listener=new ge(e,this.collect,this.Config),this.EventHandle=new Ee(this.config,e),this.Request=new Se(this.collect),this.autoTrackStart=!0,this.init()},i.init=function(){this.Listener.init(this.handle.bind(this))},i.handle=function(t,e){try{if(this.config.autotrack.collect_url&&!this.config.autotrack.collect_url())return}catch(t){}this.collect.sdkStop||"dom"===t.eventType&&this.handleDom(t,e)},i.handleDom=function(t,e){try{var i=t.eventName;if("click"===i||"change"===i||"submit"===i){var n=this.EventHandle.handleEvent(e,i);n&&this.Request.send({eventType:"custom"},n)}else if("page_view"===i||"page_statistics"===i){var o;(o="page_view"===i?this.EventHandle.handleViewEvent(e):this.EventHandle.handleStatisticsEvent(e))&&this.Request.send({eventType:"custom"},o)}else if("beat"===i){var r=this.EventHandle.handleBeadtEvent(e),s=t.eventSend;r&&this.Request.send({eventType:"custom",eventSend:s},r)}else if("exposure"===i){var a=this.EventHandle.handleExposureEvent(t,e);a&&this.Request.send({eventType:"custom"},a)}else if("scroll"===i){var c=this.EventHandle.handleScrollEvent(t,e);c&&this.Request.send({eventType:"custom"},c)}}catch(t){console.log("handel dom event error "+JSON.stringify(t))}},i.destroy=function(){if(!this.autoTrackStart)return console.warn("engine is undefined, make sure you have called autoTrack.start()");this.autoTrackStart=!1,this.Listener.removeListener()},e}(),Ie=function(){function e(){t(this,"storage",void 0),t(this,"lastLocation",void 0),t(this,"autotrack",!1),t(this,"spa",!1),t(this,"fncArray",void 0),t(this,"collect",void 0),t(this,"config",void 0),t(this,"cache_key",void 0),t(this,"cache",{}),t(this,"appid",void 0),t(this,"allowHash",!1)}var i=e.prototype;return i.apply=function(t,e){if(e.spa||e.autotrack){var i=t.Types;this.collect=t,this.config=e,this.appid=e.app_id,this.allowHash=e.allow_hash,this.fncArray=new Map,this.setKey(),this.setLocation(),this.hack(),this.init(),this.listener(),t.emit(i.RouteReady)}},i.setKey=function(){this.storage=new b,this.cache_key="__tea_cache_refer_"+this.appid,this.cache={refer_key:"",refer_title:document.title||location.pathname,refer_manual_key:"",routeChange:!1},this.config.autotrack&&"object"==typeof this.config.autotrack&&this.config.autotrack.page_manual_key&&(this.cache.refer_manual_key=this.config.autotrack.page_manual_key),this.storage.setLocalItem(this.cache_key,this.cache)},i.hack=function(){var t=this,e=window.history.pushState;history.pushState=function(i){"function"==typeof history.onpushstate&&history.onpushstate({state:i});for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];var s=e.call.apply(e,[history,i].concat(o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a,"pushState"),s}};var i=history.replaceState;history.replaceState=function(e){"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];var s=i.call.apply(i,[history,e].concat(o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a),s}}},i.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},i.getLocation=function(){return this.lastLocation},i.init=function(){var t=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:t,init:!0})},i.listener=function(){var t=this,e=null;window.addEventListener("hashchange",function(i){if(t.lastLocation!==window.location.href&&(clearTimeout(e),t.allowHash)){t.setReferCache(t.lastLocation),t.lastLocation=window.location.href;var n=t.getPopStateChangeEventData();t.sendPv(n)}}),window.addEventListener("popstate",function(i){t.lastLocation!==window.location.href&&(e=setTimeout(function(){t.setReferCache(t.lastLocation),t.lastLocation=window.location.href;var e=t.getPopStateChangeEventData();t.sendPv(e)},10))})},i.getPopStateChangeEventData=function(){var t=this.pageConfig();return t.is_back=0,t},i.pageConfig=function(){try{var t=this.storage.getLocalItem(this.cache_key)||{},e=!1,i=this.storage.getLocalItem("__tea_cache_first_"+this.appid);return e=!i||1!=i,{is_html:1,url:location.href,referrer:this.handleRefer(),page_key:location.href,refer_page_key:this.handleRefer(),page_title:document.title||location.pathname,page_manual_key:this.config.autotrack&&this.config.autotrack.page_manual_key||"",refer_page_manual_key:t&&t.refer_manual_key||"",refer_page_title:t&&t.refer_title||"",page_path:location.pathname,page_host:location.host,is_first_time:""+e}}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),{}}},i.sendPv=function(t,e){this.collect.emit("route-change",{config:t,init:!1})},i.handleRefer=function(){var t="";try{var e=this.storage.getLocalItem()||{};t=e.routeChange?e.refer_key:this.collect.configManager.get("referrer")}catch(e){t=document.referrer}return t},i.setReferCache=function(t){var e=this.storage.getLocalItem(this.cache_key)||{};e.refer_key=t,e.routeChange=!0,this.storage.setLocalItem(this.cache_key,e)},e}(),Oe=500,Re=5005;var Be=function(){function e(){t(this,"collector",void 0),t(this,"config",void 0),t(this,"eventStorage",void 0),t(this,"domain",void 0),t(this,"verifyReady",!1),t(this,"cleanStatus",!1),t(this,"key",void 0),t(this,"heart",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collector=t,this.config=e,this.eventStorage=[],this.collector.on("submit-verify-h5",function(t){t&&t.length&&i.eventStore(t[0])}),this.checkUrl(),this.heartbeat()},i.checkUrl=function(){var t=window.location.href,e=l(t);e._r_d_&&e._r_c_k_?(this.verifyReady=!0,this.domain=e._r_d_,this.key=e._r_c_k_,this.checkCache()):this.collector.off("submit-verify-h5")},i.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},i.heartbeat=function(){var t=this;this.heart=setInterval(function(){var e={event:"simulator_test__",local_time_ms:Date.now()},i=t.collector.configManager.get(),n=i.header,o={events:[e],user:i.user,header:n};t.eventStore(o)},6e4)},i.eventStore=function(t){this.cleanStatus||(this.verifyReady?this.postVerify(t):this.eventStorage.push(t))},i.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},i.postVerify=function(t){var e=this;try{var i=JSON.parse(JSON.stringify(t));o(t)?i.forEach(function(t){e.fetchLog(t)}):this.fetchLog(i)}catch(t){console.log("web verify post error ~")}},i.fetchLog=function(t){!function(t,e,i,n,o,r,s,a,c,h){try{var l=new XMLHttpRequest,u=a||"POST";l.open(u,""+t,!0),c&&h?l.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):l.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&l.setRequestHeader("X-MCS-AppKey",""+s),n&&(l.withCredentials=!0),i&&(l.timeout=i,l.ontimeout=function(){r&&r(e,Re)}),l.onload=function(){if(o){var t=null;if(l.responseText){try{t=JSON.parse(l.responseText)}catch(e){t={}}o(t,e)}}},l.onerror=function(){l.abort(),r&&r(e,Oe)},c?l.send(e):l.send(JSON.stringify(e))}catch(t){}}(this.domain+"/simulator/h5/log?connection_key="+this.key,t,2e4,!1)},i.leave=function(){var t=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.cleanVerify()}),a(function(){t.cleanVerify()})},e}(),Ge=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"storage",void 0),t(this,"eventKey",void 0),t(this,"storageNum",void 0),t(this,"eventUrl",void 0),t(this,"retryNum",void 0),t(this,"retryInterval",void 0),t(this,"retryWaitTime",3e3),t(this,"retryStatus",!1),t(this,"retryCacheStatus",!1),t(this,"errorCache",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroy)){var n=t.Types;this.storage=new b,this.eventUrl=this.collect.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+e.app_id,this.storageNum=e.storage_num||50,this.retryNum=e.retry_num||3,this.retryInterval=1e3,t.on(n.SubmitError,function(t){"f_data"===t.type&&i.storeData(t)}),t.on(n.Ready,function(){i.checkStorage()})}},i.retryRightNow=function(t){var e=this;if(this.retryStatus)this.errorCache.push(t);else{var i=0;this.retryStatus=!0;var n=setInterval(function(){if(3===i)return e.storeData(e.errorCache),e.retryStatus=!1,void clearInterval(n);var o=t.eventData;e.fetchData(o,function(){e.retryStatus=!1,clearInterval(n),e.retryCacheStatus&&e.errorCache.splice(0,1),e.errorCache.length&&(e.retryCacheStatus=!0,e.retryRightNow(e.errorCache[0]))},function(){i++})},this.retryInterval)}},i.storeData=function(t){var e=this.storage.getLocalItem(this.eventKey),i=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=i,this.storage.setLocalItem(this.eventKey,e))},i.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getLocalItem(this.eventKey);if(!e||!Object.keys(e).length)return;var i={events:[{event:"ontest",params:{app_id:this.config.app_id},local_time_ms:Date.now()}],user:{user_unique_id:this.collect.configManager.get("web_id")},header:{}};this.fetchData([i],function(){var i=JSON.parse(JSON.stringify(e)),n=function(n){t.fetchData(e[n],function(){delete i[n],t.storage.setLocalItem(t.eventKey,i)},function(){},!1)};for(var o in e)n(o)},function(){},!0)}catch(t){console.warn("error check storage")}},i.fetchData=function(t,e,i,n){this.collect.requestManager.useRequest({url:this.eventUrl,data:t,timeout:3e4,success:function(){e&&e()},fail:function(){i&&i(),console.log("network error,compensate report failk")},app_key:n&&!this.config.channel_domain?"566f58151b0ed37e":""})},e}(),Le=function(){function e(){t(this,"collector",void 0),t(this,"config",void 0),t(this,"TrackMap",void 0),t(this,"Types",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collector=t,this.config=e;var n=t.Types;t.on(n.TrackDurationStart,function(t){i.trackStart(t)}),t.on(n.TrackDurationEnd,function(t){i.trackEnd(t)}),t.on(n.TrackDurationPause,function(t){i.trackPause(t)}),t.on(n.TrackDurationResume,function(t){i.trackResume(t)}),this.Types=n,this.TrackMap=new Map,this.ready(n.TrackDuration)},i.ready=function(t){var e=this;if(this.collector.set(t),this.collector.hook._hooksCache.hasOwnProperty(t)){var i=this.collector.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collector.hook.emit(t,i)})};for(var o in i)n(o)}},i.trackStart=function(t){this.TrackMap.set(t,{startTime:Date.now(),isPause:!1,pauseTime:0,resumeTime:0})},i.trackEnd=function(t){var e=t.eventName,i=t.params;if(this.TrackMap.has(e)){var n=this.TrackMap.get(e),o=0;o=n.isPause?n.pauseTime-n.startTime:n.resumeTime?n.pauseTime-n.startTime+(Date.now()-n.resumeTime):Date.now()-n.startTime;var r=Object.assign(i,{event_duration:o});this.collector.event(e,r),this.cleanTrack(e)}},i.trackPause=function(t){if(this.TrackMap.has(t)){var e=this.TrackMap.get(t);e.isPause||(e.isPause=!0,e.pauseTime=Date.now(),this.TrackMap.set(t,e))}},i.trackResume=function(t){if(this.TrackMap.has(t)){var e=this.TrackMap.get(t);e.isPause&&(e.isPause=!1,e.resumeTime=Date.now(),this.TrackMap.set(t,e))}},i.cleanTrack=function(t){this.TrackMap.delete(t)},e}();Zt.usePlugin(ie,"ab"),Zt.usePlugin(re,"stay"),Zt.usePlugin(Ge,"store"),Zt.usePlugin(Me,"autotrack"),Zt.usePlugin(Le,"trackDuration"),Zt.usePlugin(Be,"verify"),Zt.usePlugin(se,"profile"),Zt.usePlugin(ae,"heartbeat"),Zt.usePlugin(Ie,"route");var Pe=new Zt("default"),Ne=Zt;exports.Collector=Ne,exports.default=Pe;
|
|
1
|
+
"use strict";function t(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i;if("undefined"!=typeof Symbol&&void 0!==(i=t[Symbol.toPrimitive])){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Object.defineProperty(exports,"__esModule",{value:!0});var e,i=function(){function e(){t(this,"_hooks",void 0),t(this,"_cache",void 0),t(this,"_hooksCache",void 0),this._hooks={},this._cache=[],this._hooksCache={}}var i=e.prototype;return i.on=function(t,e){t&&e&&"function"==typeof e&&(this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e))},i.once=function(t,e){var i=this;if(t&&e&&"function"==typeof e){var n=function(o){e(o),i.off(t,n)};this.on(t,n)}},i.off=function(t,e){if(t&&this._hooks[t]&&this._hooks[t].length)if(e){var i=this._hooks[t].indexOf(e);-1!==i&&this._hooks[t].splice(i,1)}else this._hooks[t]=[]},i.emit=function(t,e,i){if(i){if(!t)return;-1!==this._cache.indexOf(i)?this._emit(t,e):(this._hooksCache.hasOwnProperty(i)||(this._hooksCache[i]={}),this._hooksCache[i].hasOwnProperty(t)||(this._hooksCache[i][t]=[]),this._hooksCache[i][t].push(e))}else this._emit(t,e)},i._emit=function(t,e){t&&this._hooks[t]&&this._hooks[t].length&&[].concat(this._hooks[t]).forEach(function(t){try{t(e)}catch(t){}})},i.set=function(t){t&&-1===this._cache.indexOf(t)&&this._cache.push(t)},e}(),n=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},o=function(t){return Array.isArray(t)},r=(e=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return e+=1}),s=function(t){return function(t,e,i){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i){var n,o=[];i=i<=25?i:i%25;var r=String.fromCharCode(i+97);n=t.split(r);for(var s=0;s<n.length;s++){var a=parseInt(n[s],i);a=1*a^e;var c=String.fromCharCode(a);o.push(c)}return o.join("")}}(t,64,25)},a=function(t){!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)},c=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach(function(e){void 0!==document[e]&&(t=1)}),t},h=function(t){var e=document.createElement("a");return e.href=t,e},l=function(t){var e={};try{var i=h(t).search;(i=i.slice(1)).split("&").forEach(function(t){var i,n,o=t.split("=");o.length&&(i=o[0],n=o[1]);try{e[i]=decodeURIComponent(void 0===n?"":n)}catch(t){e[i]=n}})}catch(t){}return e},u=function(t){for(var e=0,i=0,n=(t+="").length,o=0;o<n;o++)((e=31*e+t.charCodeAt(i++))>0x7fffffffffff||e<-0x800000000000)&&(e&=0xffffffffffff);return e<0&&(e+=0x7ffffffffffff),e};var f=function(t){var e,i,n=[],o=t.length;o%2!=0&&(i=o+1,t=(e=t).length>=i?e:new Array(i-e.length+1).join("0")+e),o=t.length;for(var r=0;r<o;r+=2)n.push(parseInt(t.substr(r,2),16));return n},d=function(){var t=window.navigator.appName,e=window.navigator.userAgent;return-1!==t.indexOf("Microsoft Internet Explorer")&&(-1!==e.indexOf("MSIE 8.0")||-1!==e.indexOf("MSIE 7.0")||-1!==e.indexOf("MSIE 9.0"))},p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(t,e){return t(e={exports:{}},e.exports),e.exports}var m=g(function(t,e){var i;i=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var i=arguments[t];for(var n in i)e[n]=i[n]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(n){function o(){}function r(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=t({path:"/"},o.defaults,r)).expires&&(r.expires=new Date(1*new Date+864e5*r.expires)),r.expires=r.expires?r.expires.toUTCString():"";try{var s=JSON.stringify(i);/^[\{\[]/.test(s)&&(i=s)}catch(t){}i=n.write?n.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var c in r)r[c]&&(a+="; "+c,!0!==r[c]&&(a+="="+r[c].split(";")[0]));return document.cookie=e+"="+i+a}}function s(t,i){if("undefined"!=typeof document){for(var o={},r=document.cookie?document.cookie.split("; "):[],s=0;s<r.length;s++){var a=r[s].split("="),c=a.slice(1).join("=");i||'"'!==c.charAt(0)||(c=c.slice(1,-1));try{var h=e(a[0]);if(c=(n.read||n)(c,h)||e(c),i)try{c=JSON.parse(c)}catch(t){}if(o[h]=c,t===h)break}catch(t){}}return t?o[t]:o}}return o.set=r,o.get=function(t){return s(t,!1)},o.getJSON=function(t){return s(t,!0)},o.remove=function(e,i){r(e,"",t(i,{expires:-1}))},o.defaults={},o.withConverter=i,o}(function(){})},t.exports=i()}),v=function(){function e(){t(this,"cache",void 0),this.cache={}}var i=e.prototype;return i.setItem=function(t,e){this.cache[t]=e},i.getItem=function(t){return this.cache[t]},i.removeItem=function(t){this.cache[t]=void 0},e}(),_=function(){function e(){t(this,"support",void 0),this.support=this.isSupportLS()}var i=e.prototype;return i.isSupportLS=function(){try{return localStorage.setItem("_applogtest-test-key","hi"),localStorage.getItem("_applogtest-test-key"),localStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},i.getItem=function(t){try{var e=localStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},i.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},i.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},e}(),y=function(){function e(){t(this,"support",void 0),this.support=this.isSupportSession()}var i=e.prototype;return i.isSupportSession=function(){try{return sessionStorage.setItem("_applogtest-test-key","hi"),sessionStorage.getItem("_applogtest-test-key"),sessionStorage.removeItem("_applogtest-test-key"),!0}catch(t){return!1}},i.getItem=function(t){try{var e=sessionStorage.getItem(t),i=e;try{e&&"string"==typeof e&&(i=JSON.parse(e))}catch(t){}return i||{}}catch(t){}return{}},i.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},i.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},e}(),b=function(){function e(){t(this,"local",void 0),t(this,"session",void 0),t(this,"cache",void 0),t(this,"defaultExpireTime",void 0),this.defaultExpireTime=6048e5,this.local=new _,this.session=new y,this.cache=new v}var i=e.prototype;return i.getLocalItem=function(t){return this.local.getItem(t)},i.setLocalItem=function(t,e){this.local.setItem(t,e)},i.removeLocalItem=function(t){this.local.removeItem(t)},i.getSessionItem=function(t){return this.session.getItem(t)},i.setSessionItem=function(t,e){this.session.setItem(t,e)},i.removeSessionItem=function(t){this.session.removeItem(t)},i.getCacheItem=function(t){return this.cache.getItem(t)},i.setCacheItem=function(t,e){this.cache.setItem(t,e)},i.removeCacheItem=function(t){this.cache.removeItem(t)},i.getCookie=function(t,e){try{return m.get(t)}catch(t){return""}},i.setCookie=function(t,e,i,n){void 0===i&&(i=this.defaultExpireTime);try{var o=n||document.domain,r=+new Date+i;m.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},i.removeCookie=function(t,e){try{m.remove(t,{path:"/",domain:e||""})}catch(t){}},e}(),E=function(){function e(e,i,n){t(this,"appid",void 0),t(this,"domain",void 0),t(this,"userAgent",void 0),t(this,"appVersion",void 0),t(this,"utm",void 0),t(this,"cookie_expire",void 0),this.appid=e,this.domain=i,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=n}var i=e.prototype;return i.init=function(){var t=window.navigator.userAgent,e=window.navigator.language,i=document.referrer,n=i?h(i).hostname:"",o=l(window.location.href),r=/Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion)?"wap":"web";this.utm=function(t,e,i,n){var o=new b,r=t?"_tea_utm_cache_"+t:"_tea_utm_cache",s=t?"_$utm_from_url_"+t:"_$utm_from_url",a={},c=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],h={ad_id:Number(e.ad_id)||void 0,campaign_id:Number(e.campaign_id)||void 0,creative_id:Number(e.creative_id)||void 0,utm_source:e.utm_source,utm_medium:e.utm_medium,utm_campaign:e.utm_campaign,utm_term:e.utm_term,utm_content:e.utm_content,tr_shareuser:e.tr_shareuser,tr_admaster:e.tr_admaster,tr_param1:e.tr_param1,tr_param2:e.tr_param2,tr_param3:e.tr_param3,tr_param4:e.tr_param4};try{var l=!1;for(var u in h)h[u]&&(-1!==c.indexOf(u)?(a.hasOwnProperty("tracer_data")||(a.tracer_data={}),a.tracer_data[u]=h[u]):a[u]=h[u],l=!0);if(l)o.setSessionItem(s,"1"),o.setCookie(r,JSON.stringify(a),n,i);else{var f=o.getCookie(r,i);f&&(a=JSON.parse(f))}o.getSessionItem(s)&&(a.hasOwnProperty("tracer_data")||(a.tracer_data={}),a.tracer_data.$utm_from_url=1)}catch(t){return h}return a}(this.appid,o,this.domain,this.cookie_expire);var s=this.browser(),a=this.os();return{browser:s.browser,browser_version:s.browser_version,platform:r,os_name:a.os_name,os_version:a.os_version,userAgent:t,screen_width:window.screen&&window.screen.width,screen_height:window.screen&&window.screen.height,device_model:this.getDeviceModel(a.os_name),language:e,referrer:i,referrer_host:n,utm:this.utm,latest_data:this.last(i,n)}},i.last=function(t,e){var i="",n="",o="",r=location.hostname,s=!1;if(t&&e&&r!==e){i=t,n=e,s=!0;var a=l(t);a.keyword&&(o=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:n,$latest_search_keyword:o,isLast:s}},i.browser=function(){var t,e,i="",n=""+parseFloat(this.appVersion),o=this.userAgent;return-1!==o.indexOf("Edge")||-1!==o.indexOf("Edg")?(i="Microsoft Edge",-1!==o.indexOf("Edge")?(t=o.indexOf("Edge"),n=o.substring(t+5)):(t=o.indexOf("Edg"),n=o.substring(t+4))):-1!==(t=o.indexOf("MSIE"))?(i="Microsoft Internet Explorer",n=o.substring(t+5)):-1!==(t=o.indexOf("Lark"))?(i="Lark",n=o.substring(t+5,t+11)):-1!==(t=o.indexOf("MetaSr"))?(i="sougoubrowser",n=o.substring(t+7,t+10)):-1!==o.indexOf("MQQBrowser")||-1!==o.indexOf("QQBrowser")?(i="qqbrowser",-1!==o.indexOf("MQQBrowser")?(t=o.indexOf("MQQBrowser"),n=o.substring(t+11,t+15)):-1!==o.indexOf("QQBrowser")&&(t=o.indexOf("QQBrowser"),n=o.substring(t+10,t+17))):-1!==o.indexOf("Chrome")?-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("360"))?(i="360browser",n=o.substring(o.indexOf("Chrome")+7)):-1!==o.indexOf("baidubrowser")||-1!==o.indexOf("BIDUBrowser")?(-1!==o.indexOf("baidubrowser")?(t=o.indexOf("baidubrowser"),n=o.substring(t+13,t+16)):-1!==o.indexOf("BIDUBrowser")&&(t=o.indexOf("BIDUBrowser"),n=o.substring(t+12,t+15)),i="baidubrowser"):-1!==(t=o.indexOf("xiaomi"))?-1!==o.indexOf("openlanguagexiaomi")?(i="openlanguage xiaomi",n=o.substring(t+7,t+13)):(i="xiaomi",n=o.substring(t-7,t-1)):-1!==(t=o.indexOf("TTWebView"))?(i="TTWebView",n=o.substring(t+10,t+23)):(-1!==(t=o.indexOf("Chrome"))||-1!==(t=o.indexOf("Chrome")))&&(i="Chrome",n=o.substring(t+7)):-1!==o.indexOf("Safari")?-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+10,t+16)):-1!==(t=o.indexOf("Safari"))&&(i="Safari",n=o.substring(t+7),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))):-1!==(t=o.indexOf("Firefox"))?(i="Firefox",n=o.substring(t+8)):-1!==(t=o.indexOf("MicroMessenger"))?(i="weixin",n=o.substring(t+15,t+20)):-1!==(t=o.indexOf("QQ"))?(i="qqbrowser",n=o.substring(t+3,t+8)):-1!==(t=o.indexOf("Opera"))&&(i="Opera",n=o.substring(t+6),-1!==(t=o.indexOf("Version"))&&(n=o.substring(t+8))),-1!==(e=n.indexOf(";"))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(" "))&&(n=n.substring(0,e)),-1!==(e=n.indexOf(")"))&&(n=n.substring(0,e)),{browser:i,browser_version:n}},i.os=function(){for(var t="",e="",i=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Android",r:/Android/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}],n=0;n<i.length;n++){var o=i[n];if(o.r.test(this.userAgent)){"Mac OS X"===(t=o.s)&&this.isNewIpad()&&(t="iOS");break}}var r=function(t,e){var i=t.exec(e);return i&&i[1]?i[1]:""},s=function(t,e){var i=RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:"+t+")","i").exec(e);return i?i.slice(1)[0]:""};/Windows/.test(t)&&(e=r(/Windows (.*)/,t),t="windows");var a,c;switch(t){case"Mac OS X":e=s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent),t="mac";break;case"Android":a=this.userAgent,(c=r(/Android ([\.\_\d]+)/,a))||(c=r(/Android\/([\.\_\d]+)/,a)),e=c,t="android";break;case"iOS":e=this.isNewIpad()?s("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?",this.userAgent):(e=/OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion))?e[1]+"."+e[2]+"."+(0|e[3]):"",t="ios"}return{os_name:t,os_version:e}},i.getDeviceModel=function(t){var e="";try{if("android"===t)navigator.userAgent.split(";").forEach(function(t){t.indexOf("Build/")>-1&&(e=t.slice(0,t.indexOf("Build/")))});else if("ios"===t||"mac"===t||"windows"===t)if(this.isNewIpad())e="iPad";else{var i=navigator.userAgent.replace("Mozilla/5.0 (",""),n=i.indexOf(";");e=i.slice(0,n)}}catch(t){return e.trim()}return e.trim()},i.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},e}(),S={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},w="0.1.7",T={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},k=function(){function e(e,i){t(this,"regStr",void 0),t(this,"eventNameWhiteList",void 0),t(this,"paramsNameWhiteList",void 0),t(this,"collector",void 0),t(this,"config",void 0),this.collector=e,this.config=i,this.eventNameWhiteList=["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","_be_active","$bav2b_slide"],this.paramsNameWhiteList=["$inactive","$inline","$target_uuid_list","$source_uuid","$is_spider","$source_id","$is_first_time","$user_unique_id_type","_staging_flag","$exposure_type","$direction","$offsetY","$offsetX"],this.regStr=new RegExp("^[a-zA-Z0-9][a-z0-9A-Z_.-]{1,255}$")}var i=e.prototype;return i.checkVerify=function(t){var e=this;if(!t||!t.length)return!1;var i=t[0];if(!i)return!1;var n=i.events,o=i.header;if(!n||!n.length)return!1;var r=!0;return n.forEach(function(t){e.checkEventName(t.event)||(r=!1,t.checkEvent="事件名不能以 $ or __开头"),e.checkEventParams(t.params)||(r=!1,t.checkParams="属性名不能以 $ or __开头")}),this.checkEventParams(o)||(r=!1),r},i.checkEventName=function(t){return!!t&&this.calculate(t,"event")},i.checkEventParams=function(t){var e=t;"string"==typeof t&&(e=JSON.parse(e));var i=!0;if(!Object.keys(e).length)return i;for(var n in e){if(!this.calculate(n,"params")){i=!1;break}if("string"==typeof e[n]&&e[n].length>1024){console.warn("params: "+n+" can not over 1024 byte, please check;"),i=!1;break}}return i},i.calculate=function(t,e){return-1!==("event"===e?this.eventNameWhiteList:"params"===e?this.paramsNameWhiteList:[]).indexOf(t)||(!new RegExp("^\\$").test(t)&&!new RegExp("^__").test(t)||(console.warn(e+" name: "+t+" can not start with $ or __, pleace check;"),!1))},e}(),D=function(t){return t.Init="init",t.Config="config",t.Start="start",t.Ready="ready",t.TokenComplete="token-complete",t.TokenStorage="token-storage",t.TokenFetch="token-fetch",t.TokenError="token-error",t.ConfigUuid="config-uuid",t.ConfigWebId="config-webid",t.ConfigDomain="config-domain",t.CustomWebId="custom-webid",t.AnonymousId="anonymous-id",t.TokenChange="token-change",t.TokenReset="token-reset",t.ConfigTransform="config-transform",t.EnvTransform="env-transform",t.SessionReset="session-reset",t.SessionResetTime="session-reset-time",t.Event="event",t.Events="events",t.EventNow="event-now",t.CleanEvents="clean-events",t.BeconEvent="becon-event",t.SubmitBefore="submit-before",t.SubmitScuess="submit-scuess",t.SubmitSuccess="submit-success",t.SubmitAfter="submit-after",t.SubmitError="submit-error",t.SubmitVerifyH="submit-verify-h5",t.Stay="stay",t.ResetStay="reset-stay",t.StayReady="stay-ready",t.SetStay="set-stay",t.RouteChange="route-change",t.RouteReady="route-ready",t.Ab="ab",t.AbVar="ab-var",t.AbAllVars="ab-all-vars",t.AbConfig="ab-config",t.AbExternalVersion="ab-external-version",t.AbVersionChangeOn="ab-version-change-on",t.AbVersionChangeOff="ab-version-change-off",t.AbOpenLayer="ab-open-layer",t.AbCloseLayer="ab-close-layer",t.AbReady="ab-ready",t.AbComplete="ab-complete",t.AbTimeout="ab-timeout",t.Profile="profile",t.ProfileSet="profile-set",t.ProfileSetOnce="profile-set-once",t.ProfileUnset="profile-unset",t.ProfileIncrement="profile-increment",t.ProfileAppend="profile-append",t.ProfileClear="profile-clear",t.TrackDuration="track-duration",t.TrackDurationStart="track-duration-start",t.TrackDurationEnd="track-duration-end",t.TrackDurationPause="track-duration-pause",t.TrackDurationResume="tracl-duration-resume",t.Autotrack="autotrack",t.AutotrackReady="autotrack-ready",t.CustomHeader="custom-request-header",t.TracerReady="tracer-ready",t}(D||{}),A=function(t){return t.DEBUGGER_MESSAGE="debugger-message",t.DEBUGGER_MESSAGE_SDK="debugger-message-sdk",t.DEBUGGER_MESSAGE_FETCH="debugger-message-fetch",t.DEBUGGER_MESSAGE_FETCH_RESULT="debugger-message-fetch-result",t.DEBUGGER_MESSAGE_EVENT="debugger-message-event",t.DEVTOOL_WEB_READY="devtool-web-ready",t}({}),x=void 0,C=(new Date).getTimezoneOffset(),M=parseInt(""+-C/60,10),I=60*C,O=function(){function e(e,i){t(this,"collect",void 0),t(this,"envInfo",void 0),t(this,"evtParams",void 0),t(this,"filter",void 0),t(this,"reportErrorCallback",void 0),t(this,"initConfig",void 0),t(this,"sessionStorage",void 0),t(this,"localStorage",void 0),t(this,"storage",void 0),t(this,"configKey",void 0),t(this,"domain",void 0),t(this,"ab_version",void 0),t(this,"ab_cache",void 0),t(this,"is_first_time",!0),t(this,"isLast",void 0),t(this,"configPersist",!1),t(this,"eventCheck",void 0),t(this,"enableClientTransport",!1),this.initConfig=i,this.collect=e;var n=new E(i.app_id,i.cookie_domain||"",i.cookie_expire||7776e6).init();this.eventCheck=new k(e,i);var o="__tea_cache_first_"+i.app_id;this.configKey="__tea_cache_config_"+i.app_id,this.storage=new b,i.configPersist&&(this.configPersist=!0,this.storage=1===i.configPersist?this.sessionStorage:this.localStorage);var r=this.storage.getLocalItem(o);r&&1==r?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(o,"1")),this.envInfo={user:{user_unique_id:x,user_type:x,user_id:x,user_is_auth:x,user_is_login:x,device_id:x,web_id:x,ip_addr_id:x,user_unique_id_type:x,anonymous_id:x},header:{app_id:x,app_name:x,app_install_id:x,install_id:x,app_package:x,app_channel:x,app_version:x,ab_version:x,os_name:n.os_name,os_version:n.os_version,device_model:n.device_model,ab_client:x,traffic_type:x,client_ip:x,device_brand:x,os_api:x,access:x,language:n.language,region:x,app_language:x,app_region:x,creative_id:n.utm.creative_id,ad_id:n.utm.ad_id,campaign_id:n.utm.campaign_id,log_type:x,rnd:x,platform:n.platform,sdk_version:w,sdk_lib:"js",province:x,city:x,timezone:M,tz_offset:I,tz_name:x,sim_region:x,carrier:x,resolution:n.screen_width+"x"+n.screen_height,browser:n.browser,browser_version:n.browser_version,referrer:n.referrer,referrer_host:n.referrer_host,width:n.screen_width,height:n.screen_height,screen_width:n.screen_width,screen_height:n.screen_height,utm_term:n.utm.utm_term,utm_content:n.utm.utm_content,utm_source:n.utm.utm_source,utm_medium:n.utm.utm_medium,utm_campaign:n.utm.utm_campaign,tracer_data:JSON.stringify(n.utm.tracer_data),custom:{},wechat_unionid:x,wechat_openid:x}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(n),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}var i=e.prototype;return i.initDomain=function(){var t=this.initConfig.channel_domain;if(t)this.domain=t;else{var e=this.initConfig.channel;this.domain=s(S[e])}},i.setDomain=function(t){this.domain=t},i.getDomain=function(){return this.domain},i.initABData=function(){var t="__tea_sdk_ab_version_"+this.initConfig.app_id,e=null;if(this.initConfig.ab_cross){var i=this.storage.getCookie(t,this.initConfig.ab_cookie_domain);e=i?JSON.parse(i):null}else e=this.storage.getLocalItem(t);this.setAbCache(e)},i.setAbCache=function(t){this.ab_cache=t},i.getAbCache=function(){return this.ab_cache},i.clearAbCache=function(){this.ab_cache={},this.ab_version=""},i.setAbVersion=function(t){this.ab_version=t},i.getAbVersion=function(){return this.ab_version},i.setEnableClientTransport=function(t){this.enableClientTransport=t},i.getEnableClientTransport=function(){return this.enableClientTransport},i.getUrl=function(t){var e="";switch(t){case"event":e="/list";break;case"webid":e="/webid";break;case"tobid":e="/tobid";break;case"profile":e="/profile/list"}var i="";return this.initConfig.caller&&(i="?sdk_version=0.1.7&sdk_name=web&app_id="+this.initConfig.app_id+"&caller="+this.initConfig.caller),this.initConfig.enable_encryption&&"event"===t&&"sm"!==this.initConfig.encryption_type&&(i=this.initConfig.caller?i+"&encryption=1":i+"?encryption=1"),this.initConfig.report_url?""+this.initConfig.report_url+i:""+this.getDomain()+e+i},i.setCustom=function(t){if(t&&t.latest_data&&t.latest_data.isLast)for(var e in delete t.latest_data.isLast,this.isLast=!0,t.latest_data)this.envInfo.header.custom[e]=t.latest_data[e]},i.set=function(t){var e=this;Object.keys(t).forEach(function(i){void 0!==t[i]&&null!==t[i]||e.delete(i);try{e.eventCheck.calculate(i,"config")}catch(t){}if("traffic_type"===i&&e.isLast&&(e.envInfo.header.custom.$latest_traffic_source_type=t[i]),"evtParams"===i)e.evtParams=Object.assign({},e.evtParams||{},t.evtParams||{});else if("_staging_flag"===i)e.evtParams=Object.assign({},e.evtParams||{},{_staging_flag:t._staging_flag});else if("reportErrorCallback"===i&&"function"==typeof t[i])e.reportErrorCallback=t[i];else{var n="",o="";if(i.indexOf(".")>-1){var r=i.split(".");n=r[0],o=r[1]}n?"user"===n||"header"===n?e.envInfo[n][o]=t[i]:e.envInfo.header.custom[o]=t[i]:Object.hasOwnProperty.call(e.envInfo.user,i)?["user_type","ip_addr_id"].indexOf(i)>-1?e.envInfo.user[i]=t[i]?Number(t[i]):t[i]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(i)>-1?e.envInfo.user[i]=t[i]?String(t[i]):t[i]:["user_is_auth","user_is_login"].indexOf(i)>-1?e.envInfo.user[i]=Boolean(t[i]):"device_id"===i&&(e.envInfo.user[i]=t[i]):Object.hasOwnProperty.call(e.envInfo.header,i)?e.envInfo.header[i]=t[i]:e.envInfo.header.custom[i]=t[i]}})},i.get=function(t){try{return t?"evtParams"===t?this.evtParams:"reportErrorCallback"===t?this[t]:Object.hasOwnProperty.call(this.envInfo.user,t)?this.envInfo.user[t]:Object.hasOwnProperty.call(this.envInfo.header,t)?this.envInfo.header[t]:JSON.parse(JSON.stringify(this.envInfo[t])):JSON.parse(JSON.stringify(this.envInfo))}catch(t){console.log("get config stringify error "),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},i.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},i.setStore=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};if(e&&Object.keys(t).length){var i=Object.assign(t,e);this.setItem(this.configKey,i)}}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.getStore=function(){try{if(!this.configPersist)return null;var t=this.getItem(this.configKey)||{};return t&&Object.keys(t).length?t:null}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),null}},i.delete=function(t){try{if(!this.configPersist)return;var e=this.getItem(this.configKey)||{};e&&Object.hasOwnProperty.call(e,t)&&(delete e[t],this.setItem(this.configKey,e))}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e}(),R=function(){function e(e,i){t(this,"isLog",void 0),t(this,"name",void 0),this.isLog=i||!1,this.name=e||""}var i=e.prototype;return i.info=function(t){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},i.warn=function(t){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},i.error=function(t){this.isLog&&console.error("[instance: "+this.name+"] "+t)},i.throw=function(t){throw this.error(this.name),new Error(t)},e}(),B=function(){function t(t,e){this.native=t.enable_native||t["evitaN".split("").reverse().join("")],this.os=e.get("os_name")}var e=t.prototype;return e.bridgeInject=function(){try{return!!this.native&&(AppLogBridge?(console.log("AppLogBridge is injected"),!0):(console.log("AppLogBridge is not inject"),!1))}catch(t){return console.log("AppLogBridge is not inject"),!1}},e.bridgeReady=function(){var t=this;return new Promise(function(e,i){try{t.bridgeInject()?AppLogBridge.hasStarted(function(t){console.log("AppLogBridge is started? : "+t),t?e(!0):i(!1)}):i(!1)}catch(t){console.log("AppLogBridge, error:"+JSON.stringify(t.stack)),i(!1)}})},e.setNativeAppId=function(t){try{AppLogBridge.setNativeAppId(JSON.stringify(t)),console.log("change bridge appid, event report with appid: "+t)}catch(t){console.error("setNativeAppId error")}},e.setConfig=function(t){var e=this;try{Object.keys(t).forEach(function(i){"user_unique_id"===i?e.setUserUniqueId(t[i]):t[i]?e.addHeaderInfo(i,t[i]):e.removeHeaderInfo(i)})}catch(t){console.error("setConfig error")}},e.setUserUniqueId=function(t){try{AppLogBridge.setUserUniqueId(t)}catch(t){console.error("setUserUniqueId error")}},e.addHeaderInfo=function(t,e){try{AppLogBridge.addHeaderInfo(t,e)}catch(t){console.error("addHeaderInfo error")}},e.setHeaderInfo=function(t){try{AppLogBridge.setHeaderInfo(JSON.stringify(t))}catch(t){console.error("setHeaderInfo error")}},e.removeHeaderInfo=function(t){try{AppLogBridge.removeHeaderInfo(t)}catch(t){console.error("removeHeaderInfo error")}},e.reportPv=function(t){this.onEventV3("predefine_pageview",t)},e.onEventV3=function(t,e){try{AppLogBridge.onEventV3(t,e)}catch(t){console.error("onEventV3 error")}},e.profileSet=function(t){try{AppLogBridge.profileSet(t)}catch(t){console.error("profileSet error")}},e.profileSetOnce=function(t){try{AppLogBridge.profileSetOnce(t)}catch(t){console.error("profileSetOnce error")}},e.profileIncrement=function(t){try{AppLogBridge.profileIncrement(t)}catch(t){console.error("profileIncrement error")}},e.profileUnset=function(t){try{AppLogBridge.profileUnset(t)}catch(t){console.error("profileUnset error")}},e.profileAppend=function(t){try{AppLogBridge.profileAppend(t)}catch(t){console.error("profileAppend error")}},e.setExternalAbVersion=function(t){try{AppLogBridge.setExternalAbVersion(t)}catch(t){console.error("setExternalAbVersion error")}},e.getVar=function(t,e,i){try{"android"===this.os?i(AppLogBridge.getABTestConfigValueForKey(t,e)):AppLogBridge.getABTestConfigValueForKey(t,e,function(t){i(t)})}catch(t){console.error("getVar error"),i(e)}},e.getAllVars=function(t){try{"android"===this.os?t(AppLogBridge.getAllAbTestConfigs()):AppLogBridge.getAllAbTestConfigs(function(e){t(e)})}catch(e){console.error("getAllVars error"),t(null)}},e.getAbSdkVersion=function(t){try{"android"===this.os?t(AppLogBridge.getAbSdkVersion()):AppLogBridge.getAbSdkVersion(function(e){t(e)})}catch(e){console.error("getAbSdkVersion error"),t("")}},t}(),G=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"configManager",void 0),t(this,"eventKey",void 0),t(this,"beconKey",void 0),t(this,"abKey",void 0),t(this,"storgae",void 0),t(this,"reportTimeout",void 0),t(this,"maxReport",void 0),t(this,"reportTime",void 0),t(this,"timeout",void 0),t(this,"eventLimit",50),t(this,"reportUrl",void 0),t(this,"eventCache",[]),t(this,"beconEventCache",[]),t(this,"eventCheck",void 0),t(this,"refer_key",void 0),t(this,"enable_ttwebid",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=t.configManager,this.storgae=new b,this.eventCheck=new k(t,e),this.maxReport=e.max_report||20,this.reportTime=e.reportTime||30,this.timeout=e.timeout||1e5,this.enable_ttwebid=e.enable_ttwebid,this.reportUrl=this.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+this.configManager.get("app_id"),this.beconKey="__tea_cache_events_becon_"+this.configManager.get("app_id"),this.abKey="__tea_sdk_ab_version_"+this.configManager.get("app_id"),this.refer_key="__tea_cache_refer_"+this.configManager.get("app_id"),this.collect.on(D.Ready,function(){i.reportAll(!1)}),this.collect.on(D.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(D.Event,function(t){i.event(t)}),this.collect.on(D.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(D.CleanEvents,function(){i.reportAll(!1)}),this.linster()},i.linster=function(){var t=this;window.addEventListener("unload",function(){t.reportAll(!0)},!1),a(function(){t.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.reportAll(!0)},!1)},i.reportAll=function(t){this.report(t),this.reportBecon()},i.event=function(t){var e=this;try{var i=this.storgae.getCacheItem(this.eventKey)||[],n=[].concat(t,i);if(this.storgae.setCacheItem(this.eventKey,n),this.reportTimeout&&clearTimeout(this.reportTimeout),n.length>=this.maxReport)this.report(!1);else{var o=this.reportTime;this.reportTimeout=setTimeout(function(){e.report(!1),e.reportTimeout=null},o)}}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.beconEvent=function(t){var e=this.storgae.getCacheItem(this.beconKey)||[],i=[].concat(t,e);this.storgae.setCacheItem(this.beconKey,i),this.collect.destroy||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(i)),!0))},i.reportBecon=function(){var t=this.storgae.getCacheItem(this.beconKey)||[];t&&t.length&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(t)),!0))},i.report=function(t){if(!this.collect.destroy&&this.collect.tokenManager.getReady()&&this.collect.sdkReady){var e=this.storgae.getCacheItem(this.eventKey)||[];e.length&&(this.storgae.removeCacheItem(this.eventKey),this.sliceEvent(e,t))}},i.sliceEvent=function(t,e){if(t.length>this.eventLimit)for(var i=0;i<t.length;i+=this.eventLimit){var n;n=t.slice(i,i+this.eventLimit);var o=this.split(this.merge(n));this.send(o,e)}else{var r=this.split(this.merge(t));this.send(r,e)}},i.handleRefer=function(){var t="";try{if(this.config.spa||this.config.autotrack){var e=this.storgae.getLocalItem(this.refer_key)||{};t=e.routeChange?e.refer_key:this.configManager.get("referrer")}else t=this.configManager.get("referrer")}catch(e){t=document.referrer}return t},i.merge=function(t,e){var i=this,n=this.configManager.get(),o=n.header,r=n.user;o.referrer=this.handleRefer(),o.custom=JSON.stringify(o.custom);var s=this.configManager.get("evtParams"),a=this.configManager.get("user_unique_id_type"),c=t.map(function(t){try{if(Object.keys(s).length&&!e&&(t.params=Object.assign({},t.params,s)),i.collect.dynamicParamsFilter){var n=i.collect.dynamicParamsFilter();Object.keys(n).length&&(t.params=Object.assign({},t.params,n))}a&&(t.params.$user_unique_id_type=a);var o=i.configManager.getAbCache(),c=i.configManager.getAbVersion();return c&&o&&(i.config.disable_ab_reset||o.uuid===r.user_unique_id)&&(t.ab_sdk_version=c),t.session_id=i.collect.sessionManager.getSessionId(),t.params=JSON.stringify(t.params),t}catch(e){return i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}}),h=[];if(!Object.keys(r).length)return console.warn("user info error,cant report"),h;this.config.enable_anonymousid&&delete r.web_id;var l=JSON.parse(JSON.stringify({events:c,user:r,header:o}));return l.local_time=Math.floor(Date.now()/1e3),l.verbose=1,l.user_unique_type=this.config.enable_ttwebid?this.config.user_unique_type:void 0,h.push(l),h},i.split=function(t){return t=t.map(function(t){var e=[];return e.push(t),e})},i.send=function(t,e){var i=this;t.length&&t.forEach(function(t){try{var n=JSON.parse(JSON.stringify(t));i.config.filter&&((n=i.config.filter(n))||console.warn("filter must return data !!")),i.collect.eventFilter&&n&&((n=i.collect.eventFilter(n))||console.warn("filterEvent api must return data !!"));var o=n||t,r=JSON.parse(JSON.stringify(o));if(i.eventCheck.checkVerify(r),!o.length)return;i.collect.emit(D.SubmitBefore,o);var s=i.collect.cryptoData(o);i.collect.requestManager.useRequest({url:i.reportUrl,data:s,success:function(t,e,n,o,s){t&&0!==t.e?(i.collect.emit(D.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:r,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(D.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:r,code:200,status:"success"}))},fail:function(t,e,n,o){i.configManager.get("reportErrorCallback")(t,e),i.collect.emit(D.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,errorMessage:o,endTime:Date.now()}),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报网络异常",time:Date.now(),data:r,code:e,failType:"网络异常失败",status:"fail"})},timeout:i.timeout,useBeacon:e,encryption:i.config.enable_encryption,encryption_header:i.config.encryption_header,withCredentials:i.enable_ttwebid}),i.collect.emit(D.SubmitVerifyH,o),i.collect.emit(D.SubmitAfter,o)}catch(t){console.warn("something error, "+JSON.stringify(t.stack)),i.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}})},e}(),L=function(t){return t?(t^16*Math.random()>>t/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,L)},P=function(){return L().replace(/-/g,"").slice(0,19)},N=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},F=function(){function e(){t(this,"sessionKey",void 0),t(this,"storage",void 0),t(this,"sessionExp",void 0),t(this,"expireTime",void 0),t(this,"disableSession",void 0),t(this,"collect",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.storage=new b,this.sessionKey="__tea_session_id_"+e.app_id,this.expireTime=e.expireTime||18e5,this.disableSession=e.disable_session,this.disableSession||(this.setSessionId(),this.collect.on(D.SessionReset,function(){i.resetSessionId()}),this.collect.on(D.SessionResetTime,function(){i.updateSessionIdTime()}))},i.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:N(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},i.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:N(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},i.getSessionId=function(){var t=this.storage.getSessionItem(this.sessionKey);return this.disableSession?"":t&&t.sessionId?t.sessionId:""},i.resetExpTime=function(){var t=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime))},i.resetSessionId=function(){var t={sessionId:N(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},i.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:N(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},e}(),U=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"storage",void 0),t(this,"configManager",void 0),t(this,"cacheToken",{}),t(this,"tokenKey",void 0),t(this,"tokenReady",void 0),t(this,"tokenType",void 0),t(this,"enableCookie",!1),t(this,"expiresTime",void 0),t(this,"cookieDomain",void 0),t(this,"enableTTwebid",!1),t(this,"enableCustomWebid",!1),t(this,"enableAnonymousid",!1),t(this,"timeout",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=this.collect.configManager,this.storage=new b,this.tokenKey="__tea_cache_tokens_"+e.app_id,this.enableAnonymousid=e.enable_anonymousid,this.enableTTwebid=e.enable_ttwebid,this.enableCustomWebid=e.enable_custom_webid,this.collect.on(D.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(D.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(D.ConfigWebId,function(t){i.setWebId(t)}),this.timeout=e.timeout||3e5,this.enableCookie=e.cross_subdomain,this.expiresTime=e.cookie_expire||6048e5,this.cookieDomain=e.cookie_domain||"",this.checkStorage()},i.checkStorage=function(){var t=this;if(this.enableCookie){var e=this.storage.getCookie(this.tokenKey,this.cookieDomain);this.cacheToken=e&&"string"==typeof e?JSON.parse(e):{}}else this.cacheToken=this.storage.getLocalItem(this.tokenKey)||{};this.tokenType=this.cacheToken&&this.cacheToken._type_?this.cacheToken._type_:"default","custom"!==this.tokenType||this.enableCustomWebid||this.enableAnonymousid?this.enableAnonymousid?this.completeAnonymous(this.cacheToken):this.enableCustomWebid?this.collect.on(D.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(D.TokenComplete)}):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},i.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:P(),user_unique_id:this.configManager.get("user_unique_id")||P()}):this.remoteWebid()},i.checkEnv=function(){var t=window.navigator.userAgent;if(-1!==t.indexOf("miniProgram")||-1!==t.indexOf("MiniProgram")){var e=l(window.location.href);return!(!e||!e.Web_ID)&&(this.complete({web_id:""+e.Web_ID,user_unique_id:this.configManager.get("user_unique_id")||""+e.Web_ID}),!0)}return!1},i.remoteWebid=function(){var t=this,e=this.configManager.getUrl("webid"),i={app_key:this.config.app_key,app_id:this.config.app_id,url:location.href,user_agent:window.navigator.userAgent,referer:document.referrer,user_unique_id:""};this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 发起WEBID请求",logType:"fetch",level:"info",time:Date.now(),data:i});var n=this.collect.cryptoData(i);this.collect.requestManager.useRequest({url:e,data:n,success:function(e){var i;if(e&&0===e.e)i=e.web_id,t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求成功",logType:"fetch",level:"info",time:Date.now(),data:e});else{var n=t.getLocalId();i=n,t.collect.configManager.set({localWebId:n}),t.collect.emit(D.TokenError),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求返回值异常",logType:"fetch",level:"warn",time:Date.now(),data:e}),t.collect.logger.warn("appid: "+t.config.app_id+" get webid error, use local webid~")}t.complete({web_id:t.configManager.get("web_id")||i,user_unique_id:t.configManager.get("user_unique_id")||i})},fail:function(){var e=t.getLocalId();t.complete({web_id:t.configManager.get("web_id")||e,user_unique_id:t.configManager.get("user_unique_id")||e}),t.collect.configManager.set({localWebId:e}),t.collect.emit(D.TokenError),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"WEBID请求网络异常",logType:"fetch",level:"error",time:Date.now(),data:null}),t.collect.logger.warn("appid: "+t.config.app_id+", get webid error, use local webid~")},timeout:this.timeout,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},i.getLocalId=function(){for(var t=P(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=P(),e++}return t},i.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(D.TokenError),void console.warn("token error");t.timestamp=Date.now(),this.collect.configManager.set({web_id:e,user_unique_id:i}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.completeAnonymous=function(t){var e=t.anonymous_id||N(),i=t.user_unique_id||this.configManager.get("user_unique_id");this.collect.configManager.set({anonymous_id:e,user_unique_id:i||e}),t.anonymous_id=e,t.user_unique_id=i||e,this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.completeTtWid=function(t){var e=t.user_unique_id||"",i=this.configManager.get("user_unique_id");this.configManager.set({user_unique_id:i||e}),this.setStorage(t),this.tokenReady=!0,this.collect.emit(D.TokenComplete)},i.setUuid=function(t){if(t&&-1===["null","undefined","Null","None"].indexOf(t)){var e=String(t),i=this.configManager.get("user_unique_id"),n=this.cacheToken&&this.cacheToken.user_unique_id;if(e===i&&e===n)return;this.configManager.set({user_unique_id:e}),this.cacheToken||(this.cacheToken={}),this.cacheToken.user_unique_id=e,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(D.TokenChange,{type:"uuid",id:t}),this.collect.emit(D.SessionReset)}else this.clearUuid()},i.clearUuid=function(){if(!this.config.enable_ttwebid){var t=this.enableAnonymousid?this.configManager.get("anonymous_id"):this.configManager.get("web_id");this.configManager.get("user_unique_id")!==t&&(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken),this.collect.emit(D.TokenReset))}},i.setAnonymousId=function(t){if(t&&this.enableAnonymousid){var e=this.configManager.get("anonymous_id"),i=this.configManager.get("user_unique_id");e!==t&&(e!==i&&i||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(D.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(D.TokenChange,{type:"anonymous_id",id:t}),this.setStorage(this.cacheToken))}},i.setWebId=function(t){if(t&&!this.config.enable_ttwebid&&!this.enableAnonymousid){var e=this.configManager.get("web_id"),i=this.configManager.get("user_unique_id");i&&i!==e||(this.configManager.set({user_unique_id:t}),this.cacheToken.user_unique_id=t,this.collect.emit(D.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(D.TokenChange,{type:"webid",id:t})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},i.setStorage=function(t){t._type_=this.enableCustomWebid?"custom":"default",delete t["diss".split("").reverse().join("")],this.enableCookie||this.enableTTwebid?this.storage.setCookie(this.tokenKey,t,this.expiresTime,this.cookieDomain):this.storage.setLocalItem(this.tokenKey,t),this.cacheToken=t},i.getReady=function(){return this.tokenReady},i.getTobId=function(){var t=this;this.configManager.getUrl("tobid");var e={app_id:this.config.app_id,user_unique_id:this.configManager.get("user_unique_id"),user_unique_id_type:this.configManager.get("user_unique_id_type")};this.enableAnonymousid?e.anonymous_id=this.configManager.get("anonymous_id"):e.web_id=this.configManager.get("web_id");var i=this.collect.cryptoData(e);return new Promise(function(e){t.collect.requestManager.useRequest({url:t.configManager.getUrl("tobid"),data:i,success:function(i){i&&0===i.e?(e(i.tobid),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),infoType:"sdk"})},timeout:t.timeout,encryption:t.config.enable_encryption,encryption_header:t.config.encryption_header,withCredentials:t.enableTTwebid})})},e}(),q=function(){function e(e,i){var n=this;t(this,"collector",void 0),t(this,"config",void 0),t(this,"errorCode",void 0),t(this,"errorMessage",void 0),t(this,"requestType",void 0),t(this,"supportBeacon",void 0),t(this,"customHeader",void 0),this.collector=e,this.config=i,this.requestType=i.request_type||"xhr",this.supportBeacon=!(!window.navigator||!window.navigator.sendBeacon),this.errorCode={NO_URL:4001,IMG_ON:4e3,IMG_CATCH:4002,BEACON_FALSE:4003,XHR_ERROR:5002,TIMEOUT:5005,FETCH_ERROR:5006},this.errorMessage={BEACON_FALSE:"xhr sendbeacon error",XHR_ERROR:"xhr request error",BEACON:"xhr sendbeacon error",TIMEOUT:"xhr request timeout",FETCH_ERROR:"fetch network error",FETCH_RESPONSE_ERROR:"fetch response error"},this.customHeader=i.custom_request_header||{},this.collector.on(D.CustomHeader,function(t){n.setRequestHeader(t)})}var i=e.prototype;return i.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},i.useFetch=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.status,c=t.timeout,h=t.useBeacon,l=t.encryption,u=t.encryption_header;if(t.withCredentials,window.fetch&&"undefined"!=typeof Request){var f={method:o||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var p=this.collector.configManager.get("browser"),g=this.collector.configManager.get("browser_version");if(g=g.split("."),"Chrome"===p&&g.length&&g[0]&&Number(g[0])<82)return void this.useSendBeacon(t);f.keepalive=!0}var m=l&&!d()?n:JSON.stringify(n),v={"Content-Type":"application/json; charset=utf-8"};l&&u&&(v["Content-Type"]="application/octet-stream;tt-data="+u),f.body=m,f.headers=v;var _=null;_="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var y=setTimeout(function(){_.abort()},c);if(Object.keys(this.customHeader).length)for(var b in this.customHeader)v[b]=this.customHeader[b];f.signal=_.signal;var E=Date.now();try{fetch(i,f).then(function(t){return t.ok||s&&s(n,t.status,E,t.statusText||e.errorMessage.FETCH_RESPONSE_ERROR),t.json()}).then(function(t){clearTimeout(y),r&&r(t,n,a,E,200)}).catch(function(t){clearTimeout(y),s&&s(n,e.errorCode.FETCH_ERROR,E,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK useFetch 发送请求发生了一些问题",level:"error",time:Date.now(),data:e.message||"SDK useFetch has some errors",infoType:"sdk"})}}else h?this.useSendBeacon(t):this.useXhr(t),console.log("your browser not support fetch, use normal request")},i.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,n=t.status,o=t.success,r=t.fail,s=t.encryption,a=t.encryption_header,c=Date.now(),h=JSON.stringify(i);if(s&&a&&!d()){if("undefined"==typeof Blob)return void this.useXhr(t);h=new Blob([i],{type:"application/octet-stream;tt-data="+a})}window.navigator.sendBeacon(e,h)?o&&o({e:0},i,n,c,200):r&&r(i,this.errorCode.BEACON_FALSE,c,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},i.useXhr=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.timeout;t.withCredentials;var c=t.encryption,h=t.encryption_header,l=t.status;try{var u=new XMLHttpRequest;u.open(o||"POST",i,!0);var f=Date.now();if(c&&h?u.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):u.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var p in this.customHeader)u.setRequestHeader(p,this.customHeader[p]);a&&(u.timeout=a,u.ontimeout=function(){s&&s(n,e.errorCode.TIMEOUT,f,e.errorMessage.TIMEOUT)}),u.onload=function(){if(r){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}r(t,n,l,f,u.status)}else s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR)}},u.onerror=function(){s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR),u.abort()},c&&!d()?u.send(n):u.send(JSON.stringify(n))}catch(t){this.collector.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},i.useRequest=function(t){var e=t.useBeacon;this.config.transport&&this.collector.configManager.getEnableClientTransport()?this.useCustomRequest(t):"fetch"!==this.requestType?e?this.useSendBeacon(t):this.useXhr(t):this.useFetch(t)},i.useCustomRequest=function(t){var e=this.config.transport,i=t.url,n=t.data,o=t.success,r=t.fail;if(e)try{e.post({url:i,data:JSON.stringify(n),success:function(t){o&&o(t,n)},fail:function(t){r&&r(t,n)}})}catch(e){this.collector.configManager.setEnableClientTransport(!1),this.useRequest(t)}},e}(),z=function(){function e(e){var i=this;t(this,"element",void 0),t(this,"isDragging",void 0),t(this,"animationFrameId",void 0),t(this,"lastX",void 0),t(this,"lastY",void 0),t(this,"offsetX",void 0),t(this,"offsetY",void 0),t(this,"initialX",void 0),t(this,"initialY",void 0),t(this,"clickAllowed",void 0),t(this,"dragThreshold",void 0),t(this,"enableClick",void 0),t(this,"onMove",function(t){if(i.isDragging){var e=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(i.clickAllowed){var o=Math.abs(e-i.initialX),r=Math.abs(n-i.initialY);(o>i.dragThreshold||r>i.dragThreshold)&&(i.clickAllowed=!1)}i.animationFrameId&&cancelAnimationFrame(i.animationFrameId),i.animationFrameId=requestAnimationFrame(function(){var e=t.touches?t.touches[0].clientX:t.clientX,n=t.touches?t.touches[0].clientY:t.clientY,o=e-i.offsetX,r=n-i.offsetY,s=window.innerWidth-i.element.offsetWidth,a=window.innerHeight-i.element.offsetHeight;o=Math.max(0,Math.min(o,s)),r=Math.max(0,Math.min(r,a)),i.element.style.transform="translate(\n "+(o-i.initialX)+"px, \n "+(r-i.initialY)+"px\n )"})}}),t(this,"onEnd",function(){if(i.isDragging){i.isDragging=!1;var t=new DOMMatrix(getComputedStyle(i.element).transform),e=i.initialX+t.m41,n=i.initialY+t.m42;i.element.style.left=e+"px",i.element.style.top=n+"px",i.element.style.transform="none",i.initialX=e,i.initialY=n,document.removeEventListener("mousemove",i.onMove),document.removeEventListener("mouseup",i.onEnd),document.removeEventListener("touchmove",i.onMove),document.removeEventListener("touchend",i.onEnd),setTimeout(function(){i.clickAllowed=!0},50)}}),this.element=e,this.isDragging=!1,this.enableClick=!1,this.animationFrameId=null,this.lastX=0,this.lastY=0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.clickAllowed=!0,this.dragThreshold=1,this.initPosition(),this.bindEvents(),this.bindClickHandler()}var i=e.prototype;return i.initPosition=function(){var t=this.element.getBoundingClientRect();this.element.style.position="fixed",this.element.style.left=t.left+"px",this.element.style.top=t.top+"px",this.element.style.transform="translate(0, 0)"},i.bindEvents=function(){this.element.addEventListener("mousedown",this.onStart.bind(this)),this.element.addEventListener("touchstart",this.onStart.bind(this))},i.onStart=function(t){t.preventDefault(),this.initialX=t.clientX||t.touches[0].clientX,this.initialY=t.clientY||t.touches[0].clientY;var e=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,n=this.element.getBoundingClientRect();this.initialX=n.left,this.initialY=n.top,this.offsetX=e-this.initialX,this.offsetY=i-this.initialY,this.clickAllowed=!0,this.isDragging=!0,document.addEventListener("mousemove",this.onMove),document.addEventListener("mouseup",this.onEnd),document.addEventListener("touchmove",this.onMove),document.addEventListener("touchend",this.onEnd)},i.bindClickHandler=function(){var t=this;this.element.addEventListener("click",function(e){if(t.enableClick)return t.clickAllowed?void(window&&window.postMessage({type:"devtool:web:open-draw"},location.origin)):(e.stopImmediatePropagation(),void e.preventDefault())})},i.enable=function(){this.enableClick=!0,this.element.style.cursor="pointer",this.element.style.opacity="1"},e}(),V=function(){function e(e,i){t(this,"collect",void 0),t(this,"config",void 0),t(this,"devToolReady",!1),t(this,"devToolOrigin","*"),t(this,"sendAlready",!1),t(this,"app_id",void 0),t(this,"info",void 0),t(this,"log",void 0),t(this,"event",void 0),t(this,"filterEvent",void 0),t(this,"cacheStorgae",void 0),t(this,"loadUrl",void 0),t(this,"trackEnabled",!0),t(this,"currentAppKey",void 0),t(this,"debugButton",void 0),i.disable_debug||"Microsoft Internet Explorer"!==e.configManager.get("browser")&&(this.collect=e,this.config=i,this.app_id=i.app_id,this.trackEnabled=!!i.track_enabled,this.cacheStorgae=new b,this.currentAppKey="__applog_load_devtool_web_"+this.app_id,this.loadUrl=i.devtool_url||"https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/devtool/debug-web.v2.0.1.js",this.filterEvent=new Set(["__bav_page","__bav_beat","__bav_page_statistics","__bav_click","__bav_page_exposure","bav2b_page","bav2b_beat","bav2b_page_statistics","bav2b_click","bav2b_page_exposure","_be_active","predefine_pageview","__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append","predefine_page_alive","predefine_page_close","abtest_exposure"]),this.load())}var i=e.prototype;return i.loadScript=function(t){var e=this;try{var i=document.createElement("script");i.src=t,i.onerror=function(){console.log("load DevTool render fail")},i.onload=function(){e.enableDebugButton(),console.log("load DevTool render success")},document.getElementsByTagName("body")[0].appendChild(i)}catch(t){console.log("devTool load fail, "+t.message)}},i.parseUrl=function(){var t={};try{var e=window.location.href.split("?")[1].split("&");e.length&&e.forEach(function(e){var i=e.split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])})}catch(t){}return t},i.load=function(){try{var t=this.parseUrl();if(0==t.open_devtool_web)return void this.cacheStorgae.removeLocalItem("__applog_open_devtool_web");if(t.open_devtool_web&&t.app_id){if(parseInt(t.app_id)!==this.app_id)return}else if(!this.getStorage())return;this.loadBaseInfo(),this.loadHook(),this.setStorage(),this.addLintener(),this.loadDevTool()}catch(t){console.log("debug fail, "+t.message)}},i.getStorage=function(){var t=this.cacheStorgae.getLocalItem("__applog_open_devtool_web");return t&&parseInt(t)===this.app_id},i.setStorage=function(){this.cacheStorgae.setLocalItem("__applog_open_devtool_web",this.app_id),this.cacheStorgae.setLocalItem("__applog_devtool_web_track_enable",this.trackEnabled)},i.loadDevTool=function(){1==this.cacheStorgae.getLocalItem(this.currentAppKey)?console.warn("your appid: "+this.app_id+" has load web devtools already, maybe your page has more than two applogsdk and use one appid"):(this.loadDebuggerModule(),this.loadScript(this.loadUrl))},i.loadBaseInfo=function(){if(this.log=[],this.event=[],this.info=[{title:"基本信息",key:"base",type:1,content:[{name:"app_id",desc:"APP_ID",value:this.config.app_id},{name:"channel",desc:"CHANNEL",value:this.config.channel},{name:"domain",desc:"上报域名",value:this.collect.configManager.getDomain()},{name:"sdk_version",desc:"SDK版本",value:w},{name:"sdk_type",desc:"SDK引入方式",value:"npm"}]},{title:"用户信息",key:"user",type:2,content:[{name:"uuid",desc:"UUID",value:this.collect.configManager.get("user").user_unique_id||""},{name:"web_id",desc:"WEB_ID",value:this.collect.configManager.get("user").web_id||""}]},{title:"公共参数信息",type:2,key:"common",content:[{name:"browser",desc:"浏览器",value:this.collect.configManager.get("browser")},{name:"browser_version",desc:"浏览器版本",value:this.collect.configManager.get("browser_version")},{name:"platform",desc:"平台",value:this.collect.configManager.get("platform")},{name:"device_model",desc:"设备型号",value:this.collect.configManager.get("device_model")},{name:"os_name",desc:"操作系统",value:this.collect.configManager.get("os_name")},{name:"os_version",desc:"操作系统版本",value:this.collect.configManager.get("os_version")},{name:"resolution",desc:"屏幕分辨率",value:this.collect.configManager.get("resolution")},{name:"referrer",desc:"来源",value:this.collect.configManager.get("referrer")},{name:"custom",desc:"自定义信息",value:JSON.stringify(this.collect.configManager.get("custom"))}]},{title:"配置信息",key:"config",type:3,content:[{name:"autotrack",desc:"全埋点",value:!!this.config.autotrack},{name:"stay",desc:"停留时长",value:!!this.config.enable_stay_duration}]},{title:"A/B配置信息",key:"ab",type:4,content:[{name:"ab",desc:"A/B实验",value:!!this.config.enable_ab_test}]}],this.config.enable_ab_test){var t=this.getInfo("ab"),e=[{name:"ab",desc:"A/B实验",value:!!this.config.enable_ab_test},{name:"vid",desc:"已曝光VID",value:this.collect.configManager.getAbVersion()},{name:"ab_domain",desc:"A/B域名",value:this.config.ab_channel_domain||s(T[this.config.channel])},{name:"all_values",desc:"全部配置",value:this.collect.configManager.getAbCache()}];t.content=e,this.setInfo("ab",t)}if(this.config.enable_native||this.config.Native){var i={title:"客户端信息",type:3,content:[{name:"native",desc:"是否打通",value:!!this.collect.bridgeReport}]};this.setInfo("native",i)}if(w.includes("tob")){var n=this.getInfo("user");n.content.push({name:"sid",desc:"DISS".split("").reverse().join(""),value:"点击获取"}),this.setInfo("user",n)}},i.getInfo=function(t){var e=null;return this.info.forEach(function(i){i.key===t&&(e=i)}),e},i.setInfo=function(t,e){var i=!1;this.info.forEach(function(n){n.key===t&&(i=!0,n=e)}),i||this.info.push(e)},i.getSecondInfo=function(t,e){var i=this.getInfo(t),n=null;return i.content.forEach(function(t){t.name===e&&(n=t)}),n},i.setSecondInfo=function(t,e,i){var n=this.getInfo(t),o=!1;if(n.content.forEach(function(t){t.name===e&&(t.value=i,o=!0)}),!o){var r={name:e,value:i,desc:e.toLocaleUpperCase()};n.content.push(r)}this.setInfo(t,n)},i.loadHook=function(){var t=this;this.collect.on(A.DEBUGGER_MESSAGE,function(e){switch(e.type){case A.DEBUGGER_MESSAGE_SDK:var i={time:e.time,type:e.logType||"sdk",infoType:e.infoType||"sdk",level:e.level,name:e.info,show:!0,levelShow:!0,needDesc:!!e.data};if(e.data&&(i.desc={content:JSON.stringify(e.data)}),t.updateLog(i),e.secType&&"AB"===e.secType)t.setSecondInfo("ab","vid",t.collect.configManager.getAbVersion()),t.setSecondInfo("ab","all_values",t.collect.configManager.getAbCache());else if("USER"===e.secType)t.setSecondInfo("user","user_unique_id"===e.common?"uuid":e.common,t.collect.configManager.get(e.common));else if("HEADER"===e.secType){var n=t.collect.configManager.get(e.common);t.setSecondInfo("common",e.common,"custom"===e.common?JSON.stringify(n):n)}return void t.updateInfo();case A.DEBUGGER_MESSAGE_EVENT:if(e.data&&e.data.length){var o=e.data[0],r=o.events;if(!r.length)return;r.forEach(function(i){i.checkShow=!0,i.searchShow=!0,i.focusShow=!0,i.status=e.status,i.type=t.filterEvent.has(i.event)?"sdk":"cus",i.verifyType=e.verifyType?"verify":"no",i.info="","fail"===e.status&&(i.info={message:"code: "+e.code+", msg: "+(e.msg||e.failType)})}),t.updateEvent(o)}return}})},i.addLintener=function(){var t=this;window.addEventListener("message",function(e){if(e&&e.data&&"devtool:web:ready"===e.data.type){if(t.devToolOrigin=e.origin,t.devToolReady=!0,t.sendAlready)return;t.sendData("devtool:web:init",{info:t.info,log:t.log,event:t.event,sdk_type:w.includes("tob")?"tob":"inner",appId:t.app_id}),t.sendAlready=!0}e&&e.data&&"devtool:web:ssid"===e.data.type&&t.collect.getToken(function(e){t.setSecondInfo("user","sid",e.tobid),t.updateInfo()})})},i.sendData=function(t,e){try{var i={type:t,payload:e};window&&window.postMessage(i,this.devToolOrigin)}catch(t){}},i.updateInfo=function(){this.devToolReady&&this.sendData("devtool:web:info",this.info)},i.updateLog=function(t){this.devToolReady?this.sendData("devtool:web:log",t):this.log.push(t)},i.updateEvent=function(t){this.devToolReady?this.sendData("devtool:web:event",t):this.event.push(t)},i.loadDebuggerModule=function(){var t=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");e.appendChild(document.createTextNode("#debugger-applog-web {\n position: fixed;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: not-allowed;\n z-index:1000;\n font-weight:bold;\n opacity: 0.6;\n }")),t.appendChild(e);var i=document.createElement("div");i.innerHTML='<div id="debugger-applog-web" class="debugger-applog-web">AppLog调试</div>';var n=document.createElement("div");n.innerHTML='<div id="debugger-container" class="debugger-container"></div>',document.getElementsByTagName("body")[0].appendChild(i),document.getElementsByTagName("body")[0].appendChild(n);var o=document.getElementById("debugger-applog-web");this.debugButton=new z(o)},i.enableDebugButton=function(){this.debugButton&&this.debugButton.enable()},e}(),H=g(function(t,e){(function(){var e;function i(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function n(){return new i(null)}var o="undefined"!=typeof navigator;o&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(var s=32767&e,a=e>>15;--r>=0;){var c=32767&this[t],h=this[t++]>>15,l=a*c+h*s;o=((c=s*c+((32767&l)<<15)+i[n]+(1073741823&o))>>>30)+(l>>>15)+a*h+(o>>>30),i[n++]=1073741823&c}return o},e=30):o&&"Netscape"!=navigator.appName?(i.prototype.am=function(t,e,i,n,o,r){for(;--r>=0;){var s=e*this[t++]+i[n]+o;o=Math.floor(s/67108864),i[n++]=67108863&s}return o},e=26):(i.prototype.am=function(t,e,i,n,o,r){for(var s=16383&e,a=e>>14;--r>=0;){var c=16383&this[t],h=this[t++]>>14,l=a*c+h*s;o=((c=s*c+((16383&l)<<14)+i[n]+o)>>28)+(l>>14)+a*h,i[n++]=268435455&c}return o},e=28),i.prototype.DB=e,i.prototype.DM=(1<<e)-1,i.prototype.DV=1<<e;i.prototype.FV=Math.pow(2,52),i.prototype.F1=52-e,i.prototype.F2=2*e-52;var r,s,a=new Array;for(r="0".charCodeAt(0),s=0;s<=9;++s)a[r++]=s;for(r="a".charCodeAt(0),s=10;s<36;++s)a[r++]=s;for(r="A".charCodeAt(0),s=10;s<36;++s)a[r++]=s;function c(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function h(t,e){var i=a[t.charCodeAt(e)];return null==i?-1:i}function l(t){var e=n();return e.fromInt(t),e}function u(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function f(t){this.m=t}function d(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function p(t,e){return t&e}function g(t,e){return t|e}function m(t,e){return t^e}function v(t,e){return t&~e}function _(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function y(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function b(){}function E(t){return t}function S(t){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}f.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},f.prototype.revert=function(t){return t},f.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},f.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},f.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},d.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(i.ZERO)>0&&this.m.subTo(e,e),e},d.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},d.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],n=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},d.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var o=t.length,r=!1,s=0;--o>=0;){var a=8==n?255&t[o]:h(t,o);a<0?"-"==t.charAt(o)&&(r=!0):(r=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),r&&i.ZERO.subTo(this,this)},i.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},i.prototype.lShiftTo=function(t,e){var i,n=t%this.DB,o=this.DB-n,r=(1<<o)-1,s=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)e[i+s+1]=this[i]>>o|a,a=(this[i]&r)<<n;for(i=s-1;i>=0;--i)e[i]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,o=this.DB-n,r=(1<<n)-1;e[0]=this[i]>>n;for(var s=i+1;s<this.t;++s)e[s-i-1]|=(this[s]&r)<<o,e[s-i]=this[s]>>n;n>0&&(e[this.t-i-1]|=(this.s&r)<<o),e.t=this.t-i,e.clamp()}},i.prototype.subTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]-t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n-=t[i],e[i++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},i.prototype.multiplyTo=function(t,e){var n=this.abs(),o=t.abs(),r=n.t;for(e.t=r+o.t;--r>=0;)e[r]=0;for(r=0;r<o.t;++r)e[r+n.t]=n.am(0,o[r],e,r,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&i.ZERO.subTo(e,e)},i.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var n=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,n,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,o){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t)return null!=e&&e.fromInt(0),void(null!=o&&this.copyTo(o));null==o&&(o=n());var a=n(),c=this.s,h=t.s,l=this.DB-u(r[r.t-1]);l>0?(r.lShiftTo(l,a),s.lShiftTo(l,o)):(r.copyTo(a),s.copyTo(o));var f=a.t,d=a[f-1];if(0!=d){var p=d*(1<<this.F1)+(f>1?a[f-2]>>this.F2:0),g=this.FV/p,m=(1<<this.F1)/p,v=1<<this.F2,_=o.t,y=_-f,b=null==e?n():e;for(a.dlShiftTo(y,b),o.compareTo(b)>=0&&(o[o.t++]=1,o.subTo(b,o)),i.ONE.dlShiftTo(f,b),b.subTo(a,a);a.t<f;)a[a.t++]=0;for(;--y>=0;){var E=o[--_]==d?this.DM:Math.floor(o[_]*g+(o[_-1]+v)*m);if((o[_]+=a.am(0,E,o,y,0,f))<E)for(a.dlShiftTo(y,b),o.subTo(b,o);o[_]<--E;)o.subTo(b,o)}null!=e&&(o.drShiftTo(f,e),c!=h&&i.ZERO.subTo(e,e)),o.t=f,o.clamp(),l>0&&o.rShiftTo(l,o),c<0&&i.ZERO.subTo(o,o)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},i.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var o=n(),r=n(),s=e.convert(this),a=u(t)-1;for(s.copyTo(o);--a>=0;)if(e.sqrTo(o,r),(t&1<<a)>0)e.mulTo(r,s,o);else{var c=o;o=r,r=c}return e.revert(o)},i.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<<e)-1,o=!1,r="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(i=this[s]>>a)>0&&(o=!0,r=c(i));s>=0;)a<e?(i=(this[s]&(1<<a)-1)<<e-a,i|=this[--s]>>(a+=this.DB-e)):(i=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),i>0&&(o=!0),o&&(r+=c(i));return o?r:"0"},i.prototype.negate=function(){var t=n();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+u(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new f(e):new d(e),this.exp(t,i)},i.ZERO=l(0),i.ONE=l(1),b.prototype.convert=E,b.prototype.revert=E,b.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},b.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var w,T,k,D=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/D[D.length-1];function x(){var t;t=(new Date).getTime(),T[k++]^=255&t,T[k++]^=t>>8&255,T[k++]^=t>>16&255,T[k++]^=t>>24&255,k>=G&&(k-=G)}if(i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),o=l(i),r=n(),s=n(),a="";for(this.divRemTo(o,r,s);r.signum()>0;)a=(i+s.intValue()).toString(t).substr(1)+a,r.divRemTo(o,r,s);return s.intValue().toString(t)+a},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),o=Math.pow(e,n),r=!1,s=0,a=0,c=0;c<t.length;++c){var l=h(t,c);l<0?"-"==t.charAt(c)&&0==this.signum()&&(r=!0):(a=e*a+l,++s>=n&&(this.dMultiply(o),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),r&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var o=new Array,r=7&t;o.length=1+(t>>3),e.nextBytes(o),r>0?o[0]&=(1<<r)-1:o[0]=0,this.fromString(o,256)}},i.prototype.bitwiseTo=function(t,e,i){var n,o,r=Math.min(t.t,this.t);for(n=0;n<r;++n)i[n]=e(this[n],t[n]);if(t.t<this.t){for(o=t.s&this.DM,n=r;n<this.t;++n)i[n]=e(this[n],o);i.t=this.t}else{for(o=this.s&this.DM,n=r;n<t.t;++n)i[n]=e(o,t[n]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},i.prototype.changeBit=function(t,e){var n=i.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n},i.prototype.addTo=function(t,e){for(var i=0,n=0,o=Math.min(t.t,this.t);i<o;)n+=this[i]+t[i],e[i++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;i<this.t;)n+=this[i],e[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<t.t;)n+=t[i],e[i++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},i.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},i.prototype.multiplyLowerTo=function(t,e,i){var n,o=Math.min(this.t+t.t,e);for(i.s=0,i.t=o;o>0;)i[--o]=0;for(n=i.t-this.t;o<n;++o)i[o+this.t]=this.am(0,t[o],i,o,0,this.t);for(n=Math.min(t.t,e);o<n;++o)this.am(0,t[o],i,o,0,e-o);i.clamp()},i.prototype.multiplyUpperTo=function(t,e,i){--e;var n=i.t=this.t+t.t-e;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)i[this.t+n-e]=this.am(e-n,t[n],i,0,0,this.t+n-e);i.clamp(),i.drShiftTo(1,i)},i.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),o=e.getLowestSetBit();if(o<=0)return!1;var r=e.shiftRight(o);(t=t+1>>1)>D.length&&(t=D.length);for(var s=n(),a=0;a<t;++a){s.fromInt(D[Math.floor(Math.random()*D.length)]);var c=s.modPow(r,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(e)){for(var h=1;h++<o&&0!=c.compareTo(e);)if(0==(c=c.modPowInt(2,this)).compareTo(i.ONE))return!1;if(0!=c.compareTo(e))return!1}}return!0},i.prototype.clone=function(){var t=n();return this.copyTo(t),t},i.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},i.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,o=0;if(t-- >0)for(n<this.DB&&(i=this[t]>>n)!=(this.s&this.DM)>>n&&(e[o++]=i|this.s<<this.DB-n);t>=0;)n<8?(i=(this[t]&(1<<n)-1)<<8-n,i|=this[--t]>>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&i&&(i|=-256),0==o&&(128&this.s)!=(128&i)&&++o,(o>0||i!=this.s)&&(e[o++]=i);return e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=n();return this.bitwiseTo(t,p,e),e},i.prototype.or=function(t){var e=n();return this.bitwiseTo(t,g,e),e},i.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,m,e),e},i.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,v,e),e},i.prototype.not=function(){for(var t=n(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},i.prototype.shiftLeft=function(t){var e=n();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=n();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},i.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+_(this[t]);return this.s<0?this.t*this.DB:-1},i.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=y(this[i]^e);return t},i.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},i.prototype.setBit=function(t){return this.changeBit(t,g)},i.prototype.clearBit=function(t){return this.changeBit(t,v)},i.prototype.flipBit=function(t){return this.changeBit(t,m)},i.prototype.add=function(t){var e=n();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=n();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=n();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=n();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=n();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=n(),i=n();return this.divRemTo(t,e,i),new Array(e,i)},i.prototype.modPow=function(t,e){var i,o,r=t.bitLength(),s=l(1);if(r<=0)return s;i=r<18?1:r<48?3:r<144?4:r<768?5:6,o=r<8?new f(e):e.isEven()?new S(e):new d(e);var a=new Array,c=3,h=i-1,p=(1<<i)-1;if(a[1]=o.convert(this),i>1){var g=n();for(o.sqrTo(a[1],g);c<=p;)a[c]=n(),o.mulTo(g,a[c-2],a[c]),c+=2}var m,v,_=t.t-1,y=!0,b=n();for(r=u(t[_])-1;_>=0;){for(r>=h?m=t[_]>>r-h&p:(m=(t[_]&(1<<r+1)-1)<<h-r,_>0&&(m|=t[_-1]>>this.DB+r-h)),c=i;!(1&m);)m>>=1,--c;if((r-=c)<0&&(r+=this.DB,--_),y)a[m].copyTo(s),y=!1;else{for(;c>1;)o.sqrTo(s,b),o.sqrTo(b,s),c-=2;c>0?o.sqrTo(s,b):(v=s,s=b,b=v),o.mulTo(b,a[m],s)}for(;_>=0&&!(t[_]&1<<r);)o.sqrTo(s,b),v=s,s=b,b=v,--r<0&&(r=this.DB-1,--_)}return o.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return i.ZERO;for(var n=t.clone(),o=this.clone(),r=l(1),s=l(0),a=l(0),c=l(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(r.isEven()&&s.isEven()||(r.addTo(this,r),s.subTo(t,s)),r.rShiftTo(1,r)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;o.isEven();)o.rShiftTo(1,o),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);n.compareTo(o)>=0?(n.subTo(o,n),e&&r.subTo(a,r),s.subTo(c,s)):(o.subTo(n,o),e&&a.subTo(r,a),c.subTo(s,c))}return 0!=o.compareTo(i.ONE)?i.ZERO:c.compareTo(t)>=0?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},i.prototype.pow=function(t){return this.exp(t,new b)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var o=e.getLowestSetBit(),r=i.getLowestSetBit();if(r<0)return e;for(o<r&&(r=o),r>0&&(e.rShiftTo(r,e),i.rShiftTo(r,i));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=i.getLowestSetBit())>0&&i.rShiftTo(o,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return r>0&&i.lShiftTo(r,i),i},i.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=D[D.length-1]){for(e=0;e<D.length;++e)if(i[0]==D[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<D.length;){for(var n=D[e],o=e+1;o<D.length&&n<A;)n*=D[o++];for(n=i.modInt(n);e<o;)if(n%D[e++]==0)return!1}return i.millerRabin(t)},i.prototype.square=function(){var t=n();return this.squareTo(t),t},i.prototype.Barrett=S,null==T){var C;if(T=new Array,k=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var M=new Uint8Array(32);for(window.crypto.getRandomValues(M),C=0;C<32;++C)T[k++]=M[C]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var I=window.crypto.random(32);for(C=0;C<I.length;++C)T[k++]=255&I.charCodeAt(C)}for(;k<G;)C=Math.floor(65536*Math.random()),T[k++]=C>>>8,T[k++]=255&C;k=0,x()}function O(){if(null==w){for(x(),(w=new B).init(T),k=0;k<T.length;++k)T[k]=0;k=0}return w.next()}function R(){}function B(){this.i=0,this.j=0,this.S=new Array}R.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=O()},B.prototype.init=function(t){var e,i,n;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[i],this.S[i]=n;this.i=0,this.j=0},B.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var G=256;t.exports={default:i,BigInteger:i,SecureRandom:R}}).call(p)});H.BigInteger,H.SecureRandom;const{BigInteger:K}=H;class j{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;return(128+e.length/2).toString(16)+e}getValue(){return""}}class W extends j{constructor(t){super(),this.t="02",t&&(this.v=function(t){let e=t.toString(16);if("-"!==e[0])e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{e=e.substr(1);let i=e.length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);let n="";for(let t=0;t<i;t++)n+="f";n=new K(n,16),e=n.xor(t).add(K.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class J extends j{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function X(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function $(t,e){const i=X(t,e),n=t.substr(e+2,2*i);if(!n)return-1;return(+n[0]<8?new K(n,16):new K(n.substr(2),16)).intValue()}function Y(t,e){return e+2*(X(t,e)+1)}var Z={encodeDer(t,e){const i=new W(t),n=new W(e);return new J([i,n]).getEncodedHex()},decodeDer(t){const e=Y(t,0),i=Y(t,e),n=$(t,e),o=t.substr(i,2*n),r=i+o.length,s=Y(t,r),a=$(t,r),c=t.substr(s,2*a);return{r:new K(o,16),s:new K(c,16)}}};const{BigInteger:Q}=H,tt=new Q("2"),et=new Q("3");class it{constructor(t,e){this.x=e,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new it(this.q,this.x.negate().mod(this.q))}add(t){return new it(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new it(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new it(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new it(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new it(this.q,this.x.square().mod(this.q))}}class nt{constructor(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?Q.ONE:n,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(Q.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(Q.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(Q.ZERO)&&!this.y.toBigInteger().equals(Q.ZERO)}negate(){return new nt(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=this.z,o=t.x.toBigInteger(),r=t.y.toBigInteger(),s=t.z,a=this.curve.q,c=e.multiply(s).mod(a),h=o.multiply(n).mod(a),l=c.subtract(h),u=i.multiply(s).mod(a),f=r.multiply(n).mod(a),d=u.subtract(f);if(Q.ZERO.equals(l))return Q.ZERO.equals(d)?this.twice():this.curve.infinity;const p=c.add(h),g=n.multiply(s).mod(a),m=l.square().mod(a),v=l.multiply(m).mod(a),_=g.multiply(d.square()).subtract(p.multiply(m)).mod(a),y=l.multiply(_).mod(a),b=d.multiply(m.multiply(c).subtract(_)).subtract(u.multiply(v)).mod(a),E=v.multiply(g).mod(a);return new nt(this.curve,this.curve.fromBigInteger(y),this.curve.fromBigInteger(b),E)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=this.curve.q,o=this.curve.a.toBigInteger(),r=t.square().multiply(et).add(o.multiply(i.square())).mod(n),s=e.shiftLeft(1).multiply(i).mod(n),a=e.square().mod(n),c=a.multiply(t).multiply(i).mod(n),h=s.square().mod(n),l=r.square().subtract(c.shiftLeft(3)).mod(n),u=s.multiply(l).mod(n),f=r.multiply(c.shiftLeft(2).subtract(l)).subtract(h.shiftLeft(1).multiply(a)).mod(n),d=s.multiply(h).mod(n);return new nt(this.curve,this.curve.fromBigInteger(u),this.curve.fromBigInteger(f),d)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(et),i=this.negate();let n=this;for(let o=e.bitLength()-2;o>0;o--){n=n.twice();const r=e.testBit(o);r!==t.testBit(o)&&(n=n.add(r?this:i))}return n}}var ot={ECPointFp:nt,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new nt(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new it(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const e=this.fromBigInteger(new Q(t.substr(2),16));let i=this.fromBigInteger(e.multiply(e.square()).add(e.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new Q("4")).add(Q.ONE),this.q));return i.toBigInteger().mod(tt).equals(new Q(t.substr(0,2),16).subtract(tt))||(i=i.negate()),new nt(this,e,i);case 4:case 6:case 7:const n=(t.length-2)/2,o=t.substr(2,n),r=t.substr(n+2,n);return new nt(this,this.fromBigInteger(new Q(o,16)),this.fromBigInteger(new Q(r,16)));default:return null}}}};const{BigInteger:rt,SecureRandom:st}=H,{ECCurveFp:at}=ot,ct=new st,{curve:ht,G:lt,n:ut}=ft();function ft(){const t=new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new rt("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new at(t,e,i),o=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:o,n:new rt("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function dt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var pt={getGlobalCurve:function(){return ht},generateEcparam:ft,generateKeyPairHex:function(t,e,i){const n=(t?new rt(t,e,i):new rt(ut.bitLength(),ct)).mod(ut.subtract(rt.ONE)).add(rt.ONE),o=dt(n.toString(16),64),r=lt.multiply(n);return{privateKey:o,publicKey:"04"+dt(r.getX().toBigInteger().toString(16),64)+dt(r.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const e=(t.length-2)/2,i=t.substr(2,e);let n="03";return new rt(t.substr(e+2,e),16).mod(new rt("2")).equals(rt.ZERO)&&(n="02"),n+i},utf8ToHex:function(t){const e=(t=unescape(encodeURIComponent(t))).length,i=[];for(let n=0;n<e;n++)i[n>>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;const n=[];for(let t=0;t<e;t++){const e=i[t>>>2]>>>24-t%4*8&255;n.push((e>>>4).toString(16)),n.push((15&e).toString(16))}return n.join("")},leftPad:dt,arrayToHex:function(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")},arrayToUtf8:function(t){const e=[];let i=0;for(let n=0;n<2*t.length;n+=2)e[n>>>3]|=parseInt(t[i],10)<<24-n%8*4,i++;try{const i=[];for(let n=0;n<t.length;n++){const t=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(t))}return decodeURIComponent(escape(i.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const e=[];let i=t.length;i%2!=0&&(t=dt(t,i+1)),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e},verifyPublicKey:function(t){const e=ht.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ht.a)).add(ht.b))},comparePublicKeyHex:function(t,e){const i=ht.decodePointHex(t);if(!i)return!1;const n=ht.decodePointHex(e);return!!n&&i.equals(n)}};const gt=new Uint32Array(68),mt=new Uint32Array(64);function vt(t,e){const i=31&e;return t<<i|t>>>32-i}function _t(t,e){const i=[];for(let n=t.length-1;n>=0;n--)i[n]=255&(t[n]^e[n]);return i}function yt(t){return t^vt(t,9)^vt(t,17)}function bt(t){return t^vt(t,15)^vt(t,23)}function Et(t){let e=8*t.length,i=e%512;i=i>=448?512-i%448-1:448-i-1;const n=new Array((i-7)/8),o=new Array(8);for(let t=0,e=n.length;t<e;t++)n[t]=0;for(let t=0,e=o.length;t<e;t++)o[t]=0;e=e.toString(2);for(let t=7;t>=0;t--)if(e.length>8){const i=e.length-8;o[t]=parseInt(e.substr(i),2),e=e.substr(0,i)}else e.length>0&&(o[t]=parseInt(e,2),e="");const r=new Uint8Array([...t,128,...n,...o]),s=new DataView(r.buffer,0),a=r.length/64,c=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<a;t++){gt.fill(0),mt.fill(0);const e=16*t;for(let t=0;t<16;t++)gt[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)gt[t]=bt(gt[t-16]^gt[t-9]^vt(gt[t-3],15))^vt(gt[t-13],7)^gt[t-6];for(let t=0;t<64;t++)mt[t]=gt[t]^gt[t+4];const i=2043430169,n=2055708042;let o,r,a,h,l,u=c[0],f=c[1],d=c[2],p=c[3],g=c[4],m=c[5],v=c[6],_=c[7];for(let t=0;t<64;t++)l=t>=0&&t<=15?i:n,o=vt(vt(u,12)+g+vt(l,t),7),r=o^vt(u,12),a=(t>=0&&t<=15?u^f^d:u&f|u&d|f&d)+p+r+mt[t],h=(t>=0&&t<=15?g^m^v:g&m|~g&v)+_+o+gt[t],p=d,d=vt(f,9),f=u,u=a,_=v,v=vt(m,19),m=g,g=yt(h);c[0]^=u,c[1]^=f,c[2]^=d,c[3]^=p,c[4]^=g,c[5]^=m,c[6]^=v,c[7]^=_}const h=[];for(let t=0,e=c.length;t<e;t++){const e=c[t];h.push((4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e)}return h}const St=new Uint8Array(64),wt=new Uint8Array(64);for(let t=0;t<64;t++)St[t]=54,wt[t]=92;var Tt={sm3:Et,hmac:function(t,e){for(e.length>64&&(e=Et(e));e.length<64;)e.push(0);const i=_t(e,St),n=_t(e,wt),o=Et([...i,...t]);return Et([...n,...o])}};const{BigInteger:kt}=H,{encodeDer:Dt,decodeDer:At}=Z,xt=Tt.sm3,{G:Ct,curve:Mt,n:It}=pt.generateEcparam();function Ot(t,e,i="1234567812345678"){i=pt.utf8ToHex(i);const n=pt.leftPad(Ct.curve.a.toBigInteger().toRadix(16),64),o=pt.leftPad(Ct.curve.b.toBigInteger().toRadix(16),64),r=pt.leftPad(Ct.getX().toBigInteger().toRadix(16),64),s=pt.leftPad(Ct.getY().toBigInteger().toRadix(16),64);let a,c;if(128===e.length)a=e.substr(0,64),c=e.substr(64,64);else{const t=Ct.curve.decodePointHex(e);a=pt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=pt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=pt.hexToArray(i+n+o+r+s+a+c),l=4*i.length;h.unshift(255&l),h.unshift(l>>8&255);const u=xt(h);return pt.arrayToHex(xt(u.concat(pt.hexToArray(t))))}function Rt(t){const e=Ct.multiply(new kt(t,16));return"04"+pt.leftPad(e.getX().toBigInteger().toString(16),64)+pt.leftPad(e.getY().toBigInteger().toString(16),64)}function Bt(){const t=pt.generateKeyPairHex(),e=Mt.decodePointHex(t.publicKey);return t.k=new kt(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Gt={generateKeyPairHex:pt.generateKeyPairHex,compressPublicKeyHex:pt.compressPublicKeyHex,comparePublicKeyHex:pt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?pt.hexToArray(pt.utf8ToHex(t)):Array.prototype.slice.call(t),e=pt.getGlobalCurve().decodePointHex(e);const n=pt.generateKeyPairHex(),o=new kt(n.privateKey,16);let r=n.publicKey;r.length>128&&(r=r.substr(r.length-128));const s=e.multiply(o),a=pt.hexToArray(pt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=pt.hexToArray(pt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=pt.arrayToHex(xt([].concat(a,t,c)));let l=1,u=0,f=[];const d=[].concat(a,c),p=()=>{f=xt([...d,l>>24&255,l>>16&255,l>>8&255,255&l]),l++,u=0};p();for(let e=0,i=t.length;e<i;e++)u===f.length&&p(),t[e]^=255&f[u++];const g=pt.arrayToHex(t);return 0===i?r+g+h:r+h+g},doDecrypt:function(t,e,i=1,{output:n="string"}={}){e=new kt(e,16);let o=t.substr(128,64),r=t.substr(192);0===i&&(o=t.substr(t.length-64),r=t.substr(128,t.length-128-64));const s=pt.hexToArray(r),a=pt.getGlobalCurve().decodePointHex("04"+t.substr(0,128));if(!a||!pt.verifyPublicKey("04"+t.substr(0,128)))return"array"===n?[]:"";const c=a.multiply(e),h=pt.hexToArray(pt.leftPad(c.getX().toBigInteger().toRadix(16),64)),l=pt.hexToArray(pt.leftPad(c.getY().toBigInteger().toRadix(16),64));let u=1,f=0,d=[];const p=[].concat(h,l),g=()=>{d=xt([...p,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,f=0};g();for(let t=0,e=s.length;t<e;t++)f===d.length&&g(),s[t]^=255&d[f++];return pt.arrayToHex(xt([].concat(h,s,l)))===o.toLowerCase()?"array"===n?s:pt.arrayToUtf8(s):"array"===n?[]:""},doSignature:function(t,e,{pointPool:i,der:n,hash:o,publicKey:r,userId:s}={}){let a="string"==typeof t?pt.utf8ToHex(t):pt.arrayToHex(t);o&&(a=Ot(a,r=r||Rt(e),s));const c=new kt(e,16),h=new kt(a,16);let l=null,u=null,f=null;do{do{let t;t=i&&i.length?i.pop():Bt(),l=t.k,u=h.add(t.x1).mod(It)}while(u.equals(kt.ZERO)||u.add(l).equals(It));f=c.add(kt.ONE).modInverse(It).multiply(l.subtract(u.multiply(c))).mod(It)}while(f.equals(kt.ZERO));return n?Dt(u,f):pt.leftPad(u.toString(16),64)+pt.leftPad(f.toString(16),64)},doVerifySignature:function(t,e,i,{der:n,hash:o,userId:r}={}){let s,a,c="string"==typeof t?pt.utf8ToHex(t):pt.arrayToHex(t);if(o&&(c=Ot(c,i,r)),n){const t=At(e);s=t.r,a=t.s}else s=new kt(e.substring(0,64),16),a=new kt(e.substring(64),16);const h=It.subtract(kt.ONE);if(s.compareTo(kt.ONE)<0||s.compareTo(h)>0)return!1;if(a.compareTo(kt.ONE)<0||a.compareTo(h)>0)return!1;const l=Mt.decodePointHex(i);if(!l||!pt.verifyPublicKey(i))return!1;const u=new kt(c,16),f=s.add(a).mod(It);if(f.equals(kt.ZERO))return!1;const d=Ct.multiply(a).add(l.multiply(f)),p=u.add(d.getX().toBigInteger()).mod(It);return s.equals(p)},getPublicKeyFromPrivateKey:Rt,getPoint:Bt,verifyPublicKey:pt.verifyPublicKey};const{sm3:Lt,hmac:Pt}=Tt;function Nt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function Ft(t){const e=[];let i=t.length;var n,o;i%2!=0&&(o=i+1,t=(n=t).length>=o?n:new Array(o-n.length+1).join("0")+n),i=t.length;for(let n=0;n<i;n+=2)e.push(parseInt(t.substr(n,2),16));return e}const Ut=16,qt=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],zt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function Vt(t){const e=[];for(let i=0,n=t.length;i<n;i+=2)e.push(parseInt(t.substr(i,2),16));return e}function Ht(t,e){const i=31&e;return t<<i|t>>>32-i}function Kt(t){return(255&qt[t>>>24&255])<<24|(255&qt[t>>>16&255])<<16|(255&qt[t>>>8&255])<<8|255&qt[255&t]}function jt(t){return t^Ht(t,2)^Ht(t,10)^Ht(t,18)^Ht(t,24)}function Wt(t){return t^Ht(t,13)^Ht(t,23)}function Jt(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[4*e],o[1]=255&t[4*e+1],o[2]=255&t[4*e+2],o[3]=255&t[4*e+3],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];for(let t,e=0;e<32;e+=4)t=n[1]^n[2]^n[3]^i[e+0],n[0]^=jt(Kt(t)),t=n[2]^n[3]^n[0]^i[e+1],n[1]^=jt(Kt(t)),t=n[3]^n[0]^n[1]^i[e+2],n[2]^=jt(Kt(t)),t=n[0]^n[1]^n[2]^i[e+3],n[3]^=jt(Kt(t));for(let t=0;t<16;t+=4)e[t]=n[3-t/4]>>>24&255,e[t+1]=n[3-t/4]>>>16&255,e[t+2]=n[3-t/4]>>>8&255,e[t+3]=255&n[3-t/4]}function Xt(t,e,i,{padding:n="pkcs#7",mode:o,iv:r=[],output:s="string"}={}){if("cbc"===o&&("string"==typeof r&&(r=Vt(r)),16!==r.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=Vt(e)),16!==e.length)throw new Error("key is invalid");if(t="string"==typeof t?0!==i?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Vt(t):[...t],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const e=Ut-t.length%Ut;for(let i=0;i<e;i++)t.push(e)}const a=new Array(32);!function(t,e,i){const n=new Array(4),o=new Array(4);for(let e=0;e<4;e++)o[0]=255&t[0+4*e],o[1]=255&t[1+4*e],o[2]=255&t[2+4*e],o[3]=255&t[3+4*e],n[e]=o[0]<<24|o[1]<<16|o[2]<<8|o[3];n[0]^=2746333894,n[1]^=1453994832,n[2]^=1736282519,n[3]^=2993693404;for(let t,i=0;i<32;i+=4)t=n[1]^n[2]^n[3]^zt[i+0],e[i+0]=n[0]^=Wt(Kt(t)),t=n[2]^n[3]^n[0]^zt[i+1],e[i+1]=n[1]^=Wt(Kt(t)),t=n[3]^n[0]^n[1]^zt[i+2],e[i+2]=n[2]^=Wt(Kt(t)),t=n[0]^n[1]^n[2]^zt[i+3],e[i+3]=n[3]^=Wt(Kt(t));if(0===i)for(let t,i=0;i<16;i++)t=e[i],e[i]=e[31-i],e[31-i]=t}(e,a,i);const c=[];let h=r,l=t.length,u=0;for(;l>=Ut;){const e=t.slice(u,u+16),n=new Array(16);if("cbc"===o)for(let t=0;t<Ut;t++)0!==i&&(e[t]^=h[t]);Jt(e,n,a);for(let t=0;t<Ut;t++)"cbc"===o&&0===i&&(n[t]^=h[t]),c[u+t]=n[t];"cbc"===o&&(h=0!==i?n:e),l-=Ut,u+=Ut}if(("pkcs#5"===n||"pkcs#7"===n)&&0===i){const t=c.length,e=c[t-1];for(let i=1;i<=e;i++)if(c[t-i]!==e)throw new Error("padding is invalid");c.splice(t-e,e)}return"array"!==s?0!==i?c.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join(""):function(t){const e=[];for(let i=0,n=t.length;i<n;i++)t[i]>=240&&t[i]<=247?(e.push(String.fromCodePoint(((7&t[i])<<18)+((63&t[i+1])<<12)+((63&t[i+2])<<6)+(63&t[i+3]))),i+=3):t[i]>=224&&t[i]<=239?(e.push(String.fromCodePoint(((15&t[i])<<12)+((63&t[i+1])<<6)+(63&t[i+2]))),i+=2):t[i]>=192&&t[i]<=223?(e.push(String.fromCodePoint(((31&t[i])<<6)+(63&t[i+1]))),i++):e.push(String.fromCodePoint(t[i]));return e.join("")}(c):c}var $t={sm2:Gt,sm3:function(t,e){if(t="string"==typeof t?function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t.codePointAt(i);if(n<=127)e.push(n);else if(n<=2047)e.push(192|n>>>6),e.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)e.push(224|n>>>12),e.push(128|n>>>6&63),e.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw e.push(n),new Error("input is not supported");i++,e.push(240|n>>>18&28),e.push(128|n>>>12&63),e.push(128|n>>>6&63),e.push(128|63&n)}}return e}(t):Array.prototype.slice.call(t),e){if("hmac"!==(e.mode||"hmac"))throw new Error("invalid mode");let i=e.key;if(!i)throw new Error("invalid key");return i="string"==typeof i?Ft(i):Array.prototype.slice.call(i),Nt(Pt(t,i))}return Nt(Lt(t))},sm4:{encrypt:(t,e,i)=>Xt(t,e,1,i),decrypt:(t,e,i)=>Xt(t,e,0,i)}}.sm2;var Yt=["web_id","user_unique_id"],Zt=function(){function e(e){t(this,"name",void 0),t(this,"hook",void 0),t(this,"inited",void 0),t(this,"logger",void 0),t(this,"Types",void 0),t(this,"configManager",void 0),t(this,"appBridge",void 0),t(this,"eventManager",void 0),t(this,"tokenManager",void 0),t(this,"sessionManager",void 0),t(this,"disableAutoPageView",!1),t(this,"bridgeReport",!1),t(this,"staging",!1),t(this,"initConfig",void 0),t(this,"pluginInstances",[]),t(this,"sended",!1),t(this,"started",!1),t(this,"remotePlugin",void 0),t(this,"eventFilter",void 0),t(this,"destroy",!1),t(this,"adapters",{}),t(this,"sdkReady",!1),t(this,"debugger",void 0),t(this,"eventEncrypt",void 0),t(this,"env",void 0),t(this,"dynamicParamsFilter",void 0),t(this,"publicKey",void 0),t(this,"requestManager",void 0),this.name=e,this.hook=new i,this.logger=new R(e),this.remotePlugin=new Map,this.Types=D}e.usePlugin=function(t,i,n){if(i){for(var o=!1,r=0,s=e.plugins.length;r<s;r++){if(e.plugins[r].name===i){e.plugins[r].plugin=t,e.plugins[r].options=n||{},o=!0;break}}o||e.plugins.push({name:i,plugin:t,options:n})}else e.plugins.push({plugin:t})};var o=e.prototype;return o.init=function(t){var i,o=this;this.inited?console.log("init can be call only one time"):t&&n(t)?t.app_id&&("number"==typeof(i=t.app_id)&&!isNaN(i))?!t.app_key||function(t){return"string"==typeof t}(t.app_key)?(t.channel_domain||-1!==["cn","sg","va"].indexOf(t.channel)||(console.warn("channel must be `cn`, `sg`,`va` !!!"),t.channel="cn"),this.logger=new R(this.name,t.log),this.configManager=new O(this,t),this.appBridge=new B(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.debugger=new V(this,t),this.requestManager=new q(this,t),this.initConfig=t,this.env=t.channel_domain?"self":"public",this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行INIT",data:t,level:"info",time:Date.now()}),t.disable_auto_pv&&(this.disableAutoPageView=!0),this.bridgeReport?(this.inited=!0,this.emit(D.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new G,this.tokenManager=new U,this.sessionManager=new F,Promise.all([new Promise(function(t){o.once(D.TokenComplete,function(){t(!0)})}),new Promise(function(t){o.once(D.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,n=e.options,r=Object.assign(o.initConfig,n),s=new i;return s.apply(o,r),t.push(s),t},o.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}o.sdkReady=!0,o.emit(D.Ready),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:o.configManager.get("user")}),o.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(o.configManager.get("user"))),o.logger.info("appid: "+t.app_id+", sdk is ready, version is "+w+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}o.pageView(),o.on(D.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||o.pageView(),o.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(D.TokenReset,function(){o.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(o.configManager.get("user"))),o.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:o.configManager.get("user")})}),o.on(D.RouteChange,function(e){e.init||t.disable_route_report||o.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(D.Init))):console.warn("app_key param is error, must be string, please check!"):console.warn("app_id param is error, must be number, please check!"):console.warn("init params error,please check")},o.config=function(t){if(this.inited)if(t&&n(t))if(this.bridgeReport)this.appBridge.setConfig(t);else{t._staging_flag&&1===t._staging_flag&&(this.staging=!0),t.disable_auto_pv&&(this.disableAutoPageView=!0,delete t.disable_auto_pv);var e=Object.assign({},t);if(this.initConfig&&this.initConfig.configPersist){var i=this.configManager.getStore();i&&(e=Object.assign(i,t)),this.configManager.setStore(t)}var o=e;o.web_id,o.user_unique_id;var r=function(t,e){if(null==t)return{};var i={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;i[n]=t[n]}return i}(o,Yt);e.hasOwnProperty("web_id")&&this.emit(D.ConfigWebId,e.web_id),e.hasOwnProperty("user_unique_id")&&this.emit(D.ConfigUuid,e.user_unique_id),this.configManager.set(r),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:e})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},o.setDomain=function(t){this.configManager&&this.configManager.setDomain(t),this.emit(D.ConfigDomain)},o.getConfig=function(t){return this.configManager.get(t)},o.send=function(){this.start()},o.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(D.Start),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(D.Ready)))},o.event=function(t,e){var i=this;try{if(this.initConfig&&this.initConfig.disable_track_event)return;var n=[];if(Array.isArray(t))t.forEach(function(t){var e=i.processEvent(t[0],t[1]||{});e&&n.push(e)});else{var o=this.processEvent(t,e);if(!o)return;n.push(o)}this.bridgeReport?n.forEach(function(t){var e=t.event,n=t.params;i.appBridge.onEventV3(e,JSON.stringify(n))}):n.length&&(this.emit(D.Event,n),this.emit(D.SessionResetTime))}catch(t){this.logger.warn("something error, please check"),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},o.beconEvent=function(t,e){if(!this.initConfig||!this.initConfig.disable_track_event)if(Array.isArray(t))console.warn("beconEvent not support batch report, please check");else{var i=[],n=this.processEvent(t,e||{});n&&(i.push(n),i.length&&(this.emit(D.BeconEvent,i),this.emit(D.SessionResetTime)))}},o.processEvent=function(t,e){void 0===e&&(e={});try{if(!t)return this.logger.warn("eventName is null, please check"),null;var i=t;/^event\./.test(t)&&(i=t.slice(6));var n,o=e;return"object"!=typeof o&&(o={}),o.profile?delete o.profile:o.event_index=r(),o.local_ms?(n=o.local_ms,delete o.local_ms):n=+new Date,{event:i,params:o,local_time_ms:n,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(i){return this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:i.message}),{event:t,params:e}}},o.dynamicParams=function(t){this.dynamicParamsFilter=t},o.filterEvent=function(t){this.eventFilter=t},o.on=function(t,e){this.hook.on(t,e)},o.once=function(t,e){this.hook.once(t,e)},o.off=function(t,e){this.hook.off(t,e)},o.emit=function(t,e,i){this.hook.emit(t,e,i)},o.set=function(t){this.hook.set(t)},o.pageView=function(){this.disableAutoPageView||this.predefinePageView()},o.predefinePageView=function(t){if(void 0===t&&(t={}),this.inited){var e={title:document.title||location.pathname,url:location.href,url_path:location.pathname,time:Date.now(),referrer:window.document.referrer,$is_first_time:""+(this.configManager&&this.configManager.is_first_time||!1)},i=Object.assign({},e,t);this.event("predefine_pageview",i)}else console.warn("predefinePageView should call after init")},o.clearEventCache=function(){this.emit(D.CleanEvents)},o.setWebIDviaUnionID=function(t){if(t){var e=u(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(D.CustomWebId)}},o.setWebIDviaOpenID=function(t){if(t){var e=u(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(D.CustomWebId)}},o.setAnonymousId=function(t){this.emit(D.AnonymousId,t)},o.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},o.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},o.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},o.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(D.ResetStay,{url_path:t,title:e,url:i},D.Stay)},o.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(D.SetStay,{url_path:t,title:e,url:i},D.Stay)},o.getToken=function(t,e){var i=this;if(this.inited){var n=!1,o=function(e){if(!n){n=!0;var o=i.configManager.get().user;return e&&(o.tobid=e,o["diss".split("").reverse().join("")]=e),t(Object.assign({},o))}},r=function(){i.tokenManager.getTobId().then(function(t){o(t)})};this.sdkReady?r():(e&&setTimeout(function(){o()},e),this.on(D.Ready,function(){r()}))}else this.logger.warn("getToken must be use after function init")},o.startTrackEvent=function(t){t&&this.emit(D.TrackDurationStart,t,D.TrackDuration)},o.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(D.TrackDurationEnd,{eventName:t,params:e},D.TrackDuration)},o.pauseTrackEvent=function(t){t&&this.emit(D.TrackDurationPause,t,D.TrackDuration)},o.resumeTrackEvent=function(t){t&&this.emit(D.TrackDurationResume,t,D.TrackDuration)},o.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(D.ProfileSet,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:t})},o.profileSetOnce=function(t){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(t)):this.emit(D.ProfileSetOnce,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:t})},o.profileIncrement=function(t){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(t)):this.emit(D.ProfileIncrement,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:t})},o.profileUnset=function(t){this.bridgeReport?this.appBridge.profileUnset(t):this.emit(D.ProfileUnset,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:t})},o.profileAppend=function(t){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(t)):this.emit(D.ProfileAppend,t,D.Profile),this.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:t})},o.setExternalAbVersion=function(t){this.bridgeReport?this.appBridge.setExternalAbVersion(t):this.emit(D.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,D.Ab)},o.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(D.AbVar,{name:t,defaultValue:e,callback:i},D.Ab)},o.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(D.AbAllVars,t,D.Ab)},o.getABconfig=function(t,e){this.emit(D.AbConfig,{params:t,callback:e},D.Ab)},o.getAbSdkVersion=function(t){if(!this.bridgeReport||!t)return this.configManager.getAbVersion()||"";this.appBridge.getAbSdkVersion(t)},o.onAbSdkVersionChange=function(t){var e=this;return this.emit(D.AbVersionChangeOn,t,D.Ab),function(){e.emit(D.AbVersionChangeOff,t,D.Ab)}},o.offAbSdkVersionChange=function(t){this.emit(D.AbVersionChangeOff,t,D.Ab)},o.openOverlayer=function(){this.emit(D.AbOpenLayer,"",D.Ab)},o.closeOverlayer=function(){this.emit(D.AbCloseLayer,"",D.Ab)},o.initCrypto=function(){this.publicKey=this.initConfig.crypto_publicKey||"04BA9E229380DC0E41E10839B0C52A4763D3EDFE8903F3B8E81395523381E03AA995D295BD4A4088792E4785B224F7837EB4D2C7C05973C7AE8687A35ACAE470A0",this.initConfig.encryption_header=this.initConfig.encryption_header||"gm_sm2"},o.cryptoData=function(t){try{if(!this.initConfig.enable_encryption)return t;var e;if("sm"===this.initConfig.encryption_type){var i=(r=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+$t.doEncrypt(r,s,a)),n=f(i);e=new Uint8Array(n)}else e="data="+(o=JSON.stringify(t),window.btoa?window.btoa(encodeURIComponent(o)):encodeURIComponent(o));return e}catch(e){return t}var o,r,s,a},o.destoryInstance=function(){this.destroyInstance()},o.destoryInstace=function(){this.destroyInstance()},o.destroyInstance=function(){this.destroy||(this.destroy=!0,this.off(D.TokenComplete))},e}();t(Zt,"plugins",[]);var Qt="__rangers_ab_style__";var te=function(t){return t[t.Var=0]="Var",t[t.All=1]="All",t}(te||{}),ee=2592e6,ie=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"abOption",void 0),t(this,"fetchUrl",void 0),t(this,"reportUrl",void 0),t(this,"fetchStatus","no"),t(this,"refreshFetchStatus","complete"),t(this,"versions",[]),t(this,"extVersions",[]),t(this,"mulilinkVersions",[]),t(this,"enable_multilink",!1),t(this,"enable_ab_visual",!1),t(this,"editMode",!1),t(this,"callbacks",[]),t(this,"abKey",void 0),t(this,"cacheStorgae",void 0),t(this,"data",null),t(this,"changeListener",new Map),t(this,"fetch",void 0),t(this,"readyStatus",!1),t(this,"types",void 0),t(this,"ab_cross",void 0),t(this,"ab_cookie_domain",void 0),t(this,"exposureCache",[]),t(this,"exposureLimit",void 0),t(this,"ab_batch_time",void 0),t(this,"reportTimeout",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_ab_test){var n=e.enable_multilink,o=e.ab_channel_domain,r=e.enable_ab_visual,a=e.ab_cross,c=e.ab_cookie_domain,h=e.disable_ab_reset,l=o||s(T[e.channel||"cn"]);this.cacheStorgae=new b,this.enable_multilink=n,this.enable_ab_visual=r,this.abKey="__tea_sdk_ab_version_"+e.app_id,this.ab_cross=a,this.ab_cookie_domain=c||"",this.fetchUrl=l+"/service/2/abtest_config/",this.reportUrl=""+t.configManager.getUrl("event"),this.exposureLimit=e.exposure_limit||20,this.ab_batch_time=e.ab_batch_time||500;var u=this.collect.Types;this.types=u,this.collect.on(u.TokenChange,function(t){h||"uuid"===t.type&&i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(u.TokenReset,function(){h||i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(u.AbVar,function(t){var e=t.name,n=t.defaultValue,o=t.callback;i.getVar(e,n,o)}),this.collect.on(u.AbAllVars,function(t){i.getAllVars(t)}),this.collect.on(u.AbConfig,function(t){var e=t.params,n=t.callback;i.getABconfig(e,n)}),this.collect.on(u.AbExternalVersion,function(t){i.setExternalAbVersion(t)}),this.collect.on(u.AbOpenLayer,function(){i.openOverlayer()}),this.collect.on(u.AbCloseLayer,function(){i.closeOverlayer()}),this.collect.on(u.AbVersionChangeOn,function(t){i.changeListener.set(t,t)}),this.collect.on(u.AbVersionChangeOff,function(t){i.changeListener.get(t)&&i.changeListener.delete(t)}),this.loadMode(),(this.enable_ab_visual||this.enable_multilink)&&this.openOverlayer(this.config.multilink_timeout_ms||500),this.checkLocal(),this.ready("ab"),this.readyStatus||(this.fetchAB(),this.readyStatus=!0),this.collect.emit(u.AbReady)}},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.loadMode=function(){},i.checkLocal=function(){var t=this.getABCache(),e=t.ab_version,i=t.ab_ext_version,n=t.ab_version_multilink,o=t.data,r=this.checkFromUrl();r?this.mulilinkVersions.push(r):this.mulilinkVersions=n||[],this.extVersions=i||[],this.versions=e||[],this.data=o;var s=this.versions.concat(this.extVersions);this.enable_multilink&&(s=s.concat(this.mulilinkVersions)),this.configVersions(s.join(","))},i.checkFromUrl=function(){var t=l(window.location.href);return t&&t.vid?t.vid:""},i.updateVersions=function(){var t=this.extVersions.length?this.versions.concat(this.extVersions):this.versions;this.enable_multilink&&(t=t.concat(this.mulilinkVersions)),this.configVersions(t.join(",")),this.updateABCache(),this.changeListener.size>0&&this.changeListener.forEach(function(e){"function"==typeof e&&e(t)})},i.configVersions=function(t){this.collect.configManager.setAbVersion(t)},i.getVar=function(t,e,i){if(!t)throw new Error("variable must not be empty");if(void 0===e)throw new Error("variable no default value");if("function"!=typeof i)throw new Error("callback must be a function");var n={name:t,defaultValue:e,callback:i,type:te.Var};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealVar(n,t):this.callbacks.push(n)},i.getRealVar=function(t,e){var i=t.name,o=t.defaultValue,r=t.callback,s=this.data;if(s){if(n(s[i])){var a=s[i].vid;return"$ab_url"===e?this.mulilinkVersions.includes(a)||this.mulilinkVersions.push(a):this.versions.includes(a)||this.versions.push(a),this.updateVersions(),this.fechEvent(a,e,o),r(s[i].val),void this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 曝光了实验"+i,level:"info",time:Date.now(),data:s[i]})}this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getVar",level:"info",time:Date.now(),data:o}),r(o)}else r(o)},i.getAllVars=function(t){if("function"!=typeof t)throw new Error("callback must be a function");var e={callback:t,type:te.All};"complete"===this.fetchStatus&&"complete"===this.refreshFetchStatus?this.getRealAllVars(e):this.callbacks.push(e)},i.getRealAllVars=function(t){(0,t.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getAllVars",level:"info",time:Date.now(),data:this.data})},i.fechEvent=function(t,e,i){try{if(this.config.disable_track_event)return;if(!t)return;var n=this.collect.configManager.get(),o=n.header,r=n.user,s=this.getABCache();if(s&&s.uuid&&s.uuid!==r.user_unique_id)return;var a={event:"abtest_exposure",ab_sdk_version:""+t,params:JSON.stringify({app_id:this.config.appId,ab_url:"$ab_url"===e?i:window.location.href}),local_time_ms:Date.now()};o.custom=JSON.stringify(o.custom);var c={events:[a],user:r,header:o};"$ab_url"===e&&window.navigator.sendBeacon?window.navigator.sendBeacon(this.reportUrl,JSON.stringify([c])):this.reportExposure(c)}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.reportExposure=function(t){var e=this;this.exposureCache.push(t),this.reportTimeout&&clearTimeout(this.reportTimeout),this.exposureCache.length>=this.exposureLimit?this.report():this.reportTimeout=setTimeout(function(){e.report(),clearTimeout(e.reportTimeout)},this.ab_batch_time)},i.report=function(){var t=this,e=this.collect.cryptoData(this.exposureCache);this.collect.requestManager.useRequest({url:this.reportUrl,data:e,timeout:1e5,useBeacon:!1,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,type:"event"}),this.exposureCache.forEach(function(e){t.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:[e],code:200,status:"success"})}),this.exposureCache=[]},i.setExternalAbVersion=function(t){this.extVersions=[t],this.updateVersions()},i.getABconfig=function(t,e){var i=Object.keys(t);i&&i.length&&this.collect.configManager.set(t),this.fetchAB(e)},i.get=function(t){if(this.ab_cross){var e=this.cacheStorgae.getCookie(t,this.ab_cookie_domain);return e?JSON.parse(e):null}return this.cacheStorgae.getLocalItem(t)},i.set=function(t,e){this.ab_cross?this.cacheStorgae.setCookie(t,e,ee,this.ab_cookie_domain):this.cacheStorgae.setLocalItem(t,e),this.collect.configManager.setAbCache(e)},i.getABCache=function(t){var e={ab_version:[],ab_ext_version:[],ab_version_multilink:[],data:null,timestamp:+new Date,uuid:""};return e=this.get(this.abKey)||e,Date.now()-e.timestamp>=ee?(this.cacheStorgae.removeLocalItem(this.abKey),null):t?e[t]:e},i.updateABCache=function(){var t=this.getABCache();t.ab_version_multilink=this.mulilinkVersions,t.ab_ext_version=this.extVersions,t.ab_version=this.versions,t.timestamp=Date.now(),this.set(this.abKey,t)},i.setAbCache=function(t){var e=this.getABCache();e.data=this.data,e.uuid=t,e.timestamp=Date.now(),this.set(this.abKey,e)},i.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},i.openOverlayer=function(t){var e=this;if(function(){if(!document.getElementById(Qt)){var t="body { opacity: 0 !important; }",e=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Qt,i.type="text/css",i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)}}(),t)var i=setTimeout(function(){e.closeOverlayer(),clearTimeout(i)},t)},i.closeOverlayer=function(){var t;(t=document.getElementById(Qt))&&t.parentElement.removeChild(t)},i.fetchComplete=function(t,e){var i=this;if(t&&"[object Object]"==Object.prototype.toString.call(t)){this.data=t,this.setAbCache(e);var n=[];Object.keys(t).forEach(function(e){var i=t[e].vid;i&&n.push(i)}),this.versions=this.versions.filter(function(t){return n.includes(t)});var o=t.$ab_url,r=t.$ab_modification;if(r&&r.val&&this.enable_ab_visual){if(this.collect.destroy)return;this.getVar("$ab_modification",window.location.href,function(){i.closeOverlayer()})}else if(o&&this.enable_multilink){this.mulilinkVersions=this.mulilinkVersions.filter(function(t){return n.includes(t)});var s=o.val,a=o.vid;s&&a&&this.getVar("$ab_url",s,function(){i.editMode||(s!==window.location.href?setTimeout(function(){if(!i.collect.destroy){var t=""+s;t=-1===t.indexOf("http")?"https://"+t:t;var e=h(t).host;try{var n=new URL(t);e!==location.host?n.searchParams.append("vid",a):window.history.replaceState("","",t),window.location.href=n.href}catch(e){window.location.href=t}}},100):i.closeOverlayer())})}this.updateVersions()}else this.closeOverlayer();this.callbacks.forEach(function(t){return i[t.type===te.Var?"getRealVar":"getRealAllVars"](t,"")}),this.callbacks=[]},i.fetchAB=function(t){var e=this,i=this.collect.configManager.get(),n=i.header,o=i.user;this.config.enable_anonymousid&&delete o.web_id;var r=o.user_unique_id,s={header:Object.assign({aid:this.config.app_id},o||{},n||{},{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})},a=this.collect.cryptoData(s);this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:s,infoType:"sdk"}),this.collect.requestManager.useRequest({url:this.fetchUrl,data:a,success:function(i){e.fetchStatus="complete",e.refreshFetchStatus="complete";var n=i.data;"success"===i.message?(e.fetchComplete(n,r),t&&t(n)):(e.fetchComplete(null,r),t&&t(null)),e.collect.emit(e.types.AbComplete,n),e.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:n,infoType:"sdk"})},fail:function(){e.fetchStatus="complete",e.refreshFetchStatus="complete",e.fetchComplete(null,r),t&&t(null),e.collect.emit(e.types.AbTimeout),e.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求网络异常",level:"error",logType:"fetch",time:Date.now(),infoType:"sdk"})},timeout:this.config.ab_timeout||1e4,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header})},i.filterUrl=function(t){try{var e="";-1!==t.indexOf("&multilink=true")?e="&multilink=true[\0-ÿ]*":-1!==t.indexOf("?multilink=true")&&(e="\\?multilink=true[\0-ÿ]*");var i=new RegExp(e,"g");t=t.replace(i,"")}catch(t){}return t},e}(),ne=function(){function e(e,i){t(this,"collect",void 0),t(this,"config",void 0),t(this,"pageStartTime",void 0),t(this,"maxDuration",432e5),t(this,"sessionStartTime",void 0),t(this,"timerHandler",void 0),t(this,"url_path",void 0),t(this,"url",void 0),t(this,"title",void 0),t(this,"set_path",void 0),t(this,"set_url",void 0),t(this,"set_title",void 0),t(this,"aliveDTime",6e4),t(this,"aliveName",void 0),t(this,"disableCallback",void 0),t(this,"customParmas",void 0),t(this,"options",{aliveName:"predefine_page_alive",params:{}}),this.collect=e,this.config=i,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,n(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration))}var i=e.prototype;return i.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageAlive(),this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params},i.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},i.sendEvent=function(t,e){void 0===e&&(e=!1);var i=e?this.aliveDTime:Date.now()-this.sessionStartTime;i<0||i>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,Object.assign({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:i,is_support_visibility_change:c(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:t},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},i.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval(function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)},1e3)},i.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},i.beforeunload=function(){document.hidden||this.sendEvent(!0)},i.enablePageAlive=function(){var t=this;this.timerHandler=this.setUpTimer();var e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},e}(),oe=function(){function e(e,i){var o=this;t(this,"collect",void 0),t(this,"config",void 0),t(this,"pageStartTime",void 0),t(this,"maxDuration",432e5),t(this,"sessionStartTime",void 0),t(this,"timerHandler",void 0),t(this,"url_path",void 0),t(this,"url",void 0),t(this,"title",void 0),t(this,"set_path",void 0),t(this,"set_url",void 0),t(this,"set_title",void 0),t(this,"aliveDTime",6e4),t(this,"aliveName",void 0),t(this,"options",{closeName:"predefine_page_close",params:{}}),t(this,"activeStartTime",void 0),t(this,"activeEndTime",void 0),t(this,"activeTimes",void 0),t(this,"totalTime",void 0),t(this,"disableCallback",void 0),t(this,"customParmas",void 0),t(this,"visibilitychange",function(){"hidden"===document.visibilityState?o.activeEndTime=Date.now():"visible"===document.visibilityState&&(o.activeEndTime&&(o.totalTime+=o.activeEndTime-o.activeStartTime,o.activeTimes+=1),o.activeEndTime=void 0,o.activeStartTime=Date.now())}),t(this,"beforeunload",function(){if(o.totalTime+=(o.activeEndTime||Date.now())-o.activeStartTime,o.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:o.totalTime,page_title:document.title||location.pathname}))}catch(t){}}o.sendEventPageClose()}),this.collect=e,this.config=i,this.maxDuration=i.maxDuration||864e5,this.pageStartTime=Date.now(),n(i.enable_stay_duration)&&(this.options=Object.assign(this.options,i.enable_stay_duration)),this.resetData()}var i=e.prototype;return i.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},i.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},i.enable=function(t,e,i){this.url_path=t||this.url_path,this.url=i||this.url,this.title=e||this.title,this.disableCallback=this.enablePageClose()},i.disable=function(){this.disableCallback()},i.resetData=function(){this.activeStartTime=void 0===this.activeStartTime?this.pageStartTime:Date.now(),this.activeEndTime=void 0,this.activeTimes=1,this.totalTime=0,this.options.params instanceof Function?this.customParmas=this.options.params():this.customParmas=this.options.params,this.resetParams(location.pathname,document.title,location.href)},i.sendEventPageClose=function(){var t=Date.now()-this.pageStartTime;this.totalTime<0||t<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,Object.assign({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:t,is_support_visibility_change:c()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},i.getParams=function(t){switch(t){case"url_path":return this.set_path||this.url_path||location.pathname;case"title":return this.set_title||this.title||document.title||location.pathname;case"url":return this.set_url||this.url||location.href}},i.enablePageClose=function(){var t=this,e=this.visibilitychange.bind(this),i=this.beforeunload.bind(this);return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",i),function(){t.beforeunload(),document.removeEventListener("visibilitychange",e),window.removeEventListener("beforeunload",i),window.removeEventListener("pagehide",i)}},e}(),re=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"title",void 0),t(this,"url",void 0),t(this,"url_path",void 0),t(this,"pageAlive",void 0),t(this,"pageClose",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,this.config=e,this.config.enable_stay_duration){this.title=document.title||location.pathname,this.url=location.href,this.url_path=location.pathname,this.pageAlive=new ne(t,e),this.pageClose=new oe(t,e);var n=this.collect.Types;this.collect.on(n.ResetStay,function(t){var e=t.url_path,n=t.title,o=t.url;i.resetStayDuration(e,n,o)}),this.collect.on(n.RouteChange,function(t){t.init||e.disable_route_report||i.resetStayDuration()}),this.collect.on(n.SetStay,function(t){var e=t.url_path,n=t.title,o=t.url;i.setStayParmas(e,n,o)}),this.enable(this.url_path,this.title,this.url),this.ready(n.Stay),this.collect.emit(n.StayReady)}},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},i.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},i.setStayParmas=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.pageAlive.setParams(t,e,i),this.pageClose.setParams(t,e,i),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},i.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},i.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},e}(),se=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"cache",void 0),t(this,"duration",void 0),t(this,"reportUrl",void 0),t(this,"eventCheck",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.duration=6e4,this.reportUrl=t.configManager.getDomain()+"/profile/list",this.eventCheck=new k(t,e),this.cache={},this.collect.on(D.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(D.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(D.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(D.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(D.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(D.ProfileClear,function(){i.cache={}}),this.ready(D.Profile)},i.ready=function(t){var e=this;if(this.collect.set(t),this.collect.hook._hooksCache.hasOwnProperty(t)){var i=this.collect.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collect.hook.emit(t,i)})};for(var o in i)n(o)}},i.report=function(t,e){var i=this;void 0===e&&(e={});try{if(this.config.disable_track_event)return;var n=[];n.push(this.collect.processEvent(t,e));var o=this.collect.eventManager.merge(n,!0),r=this.collect.cryptoData(o);this.collect.configManager.getUrl("profile");this.collect.requestManager.useRequest({url:this.reportUrl,data:r,timeout:1e5,encryption:this.config.enable_encryption,encryption_header:this.config.encryption_header,zip:!0,success:function(t,e,n,o,r){t&&0!==t.e?i.collect.emit(D.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:r}):i.collect.emit(D.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:r})},fail:function(t,e,n){i.collect.emit(D.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,endTime:Date.now()})}}),this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"})}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},i.setProfile=function(t){var e=this.formatParams(t);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set",Object.assign({},e,{profile:!0})))},i.setOnceProfile=function(t){var e=this.formatParams(t,!0);e&&Object.keys(e).length&&(this.pushCache(e),this.report("__profile_set_once",Object.assign({},e,{profile:!0})))},i.incrementProfile=function(t){t?this.report("__profile_increment",Object.assign({},t,{profile:!0})):console.warn("please check the params, must be object!!!")},i.unsetProfile=function(t){if(t){var e={};e[t]="1",this.report("__profile_unset",Object.assign({},e,{profile:!0}))}else console.warn("please check the key, must be string!!!")},i.appendProfile=function(t){if(t){var e={};for(var i in t)"string"==typeof t[i]||"Array"===Object.prototype.toString.call(t[i]).slice(8,-1)?e[i]=t[i]:console.warn("please check the value of param: "+i+", must be string or array !!!");Object.keys(e).length&&this.report("__profile_append",Object.assign({},e,{profile:!0}))}else console.warn("please check the params, must be object!!!")},i.pushCache=function(t){var e=this;Object.keys(t).forEach(function(i){e.cache[i]={val:e.clone(t[i]),timestamp:Date.now()}})},i.formatParams=function(t,e){var i=this;void 0===e&&(e=!1);try{if(!t||"[object Object]"!==Object.prototype.toString.call(t))return void console.warn("please check the params type, must be object !!!");var n={};for(var o in t)"string"==typeof t[o]||"number"==typeof t[o]||"Array"===Object.prototype.toString.call(t[o]).slice(8,-1)?n[o]=t[o]:console.warn("please check the value of params:"+o+", must be string,number,Array !!!");var r=Object.keys(n);if(!r.length)return;var s=Date.now();return r.filter(function(n){var o=i.cache[n];return e?!o:!(o&&i.compare(o.val,t[n])&&s-o.timestamp<i.duration)}).reduce(function(t,e){return t[e]=n[e],t},{})}catch(t){this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("error")}},i.compare=function(t,e){try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),!1}},i.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},i.unReady=function(){console.warn("sdk is not ready, please use this api after start")},e}(),ae=function(){function e(){var e=this;t(this,"sessionInterval",void 0),t(this,"isSessionhasEvent",void 0),t(this,"startTime",void 0),t(this,"lastTime",void 0),t(this,"collect",void 0),t(this,"clearIntervalFunc",void 0),t(this,"setInterval",function(){e.clearIntervalFunc=function(t,e){void 0===t&&(t=function(){}),void 0===e&&(e=1e3);var i,n=Date.now()+e;return i=window.setTimeout(function o(){var r=Date.now()-n;t(),n+=e,i=window.setTimeout(o,Math.max(0,e-r))},e),function(){window.clearTimeout(i)}}(function(){e.isSessionhasEvent&&e.endCurrentSession()},e.sessionInterval)}),t(this,"clearInterval",function(){e.clearIntervalFunc&&e.clearIntervalFunc()})}var i=e.prototype;return i.apply=function(t,e){var i=this;if(this.collect=t,!e.disable_heartbeat){this.sessionInterval=6e4,this.startTime=0,this.lastTime=0,this.setInterval();var n=this.collect.Types;this.collect.on(n.SessionReset,function(){i.process()})}},i.endCurrentSession=function(){this.collect.event("_be_active",{start_time:this.startTime,end_time:this.lastTime,url:window.location.href,referrer:window.document.referrer,title:document.title||location.pathname}),this.isSessionhasEvent=!1,this.startTime=0},i.process=function(){this.isSessionhasEvent||(this.isSessionhasEvent=!0,this.startTime=+new Date);var t=this.lastTime||+new Date;this.lastTime=+new Date,this.lastTime-t>this.sessionInterval&&(this.clearInterval(),this.endCurrentSession(),this.setInterval())},e}();function ce(t,e){if(void 0===e&&(e="list"),!t)return!1;if(e&&"list"===e){if(["LI","TR","DL"].includes(t.nodeName))return!0;if(t.dataset&&t.dataset.hasOwnProperty("teaIdx"))return!0;if(t.hasAttribute&&t.hasAttribute("data-tea-idx"))return!0}else{if(["A","BUTTON"].includes(t.nodeName))return!0;if(t.dataset&&t.dataset.hasOwnProperty("teaContainer"))return!0;if(t.hasAttribute&&t.hasAttribute("data-tea-container"))return!0;if(t.hasAttribute&&de(t,"ss"))return!0}return!1}var he=function(t,e){return!!de(t,e)};function le(t){for(var e=t;e&&!ce(e,"container");){if("HTML"===e.nodeName||"BODY"===e.nodeName)return t;e=e.parentElement}return e||t}function ue(t){for(var e=t;e&&e.parentNode;){if(e.hasAttribute("data-tea-ignore"))return!0;if("HTML"===e.nodeName||"body"===e.nodeName)return!1;e=e.parentNode}return!1}var fe=function(t,e){return t.hasAttribute?t.hasAttribute(e):t.attributes?!(!t.attributes[e]||!t.attributes[e].specified):void 0},de=function(t,e){if("string"==typeof e)return fe(t,e);if(o(e)){for(var i=!1,n=0;n<e.length;n++){if(fe(t,e[n])){i=!0;break}}return i}},pe=function(t,e){var i={};if("string"==typeof e)fe(t,e)&&(i[e]=t.getAttribute(e));else if(o(e))for(var n=0;n<e.length;n++){fe(t,e[n])&&(i[e[n]]=t.getAttribute(e[n]))}return i};var ge=function(){function e(e,i,n){var o=this;t(this,"config",void 0),t(this,"options",void 0),t(this,"beatTime",void 0),t(this,"statistics",void 0),t(this,"eventHandel",void 0),t(this,"collect",void 0),t(this,"clickEvent",function(t){(function(t,e){if(1!==t.nodeType)return!1;if(!e.svg&&function(t){if("svg"===t.tagName.toLowerCase())return!0;for(var e=t.parentElement,i=!1;e;)"svg"===e.tagName.toLowerCase()?(e=null,i=!0):e=e.parentElement;return i}(t))return!1;if(["HTML","BODY"].includes(t.tagName.toUpperCase()))return!1;var i=t;return!!("none"!==i.style.display&&(ce(i,"container")||e.track_attr&&he(i,e.track_attr)||function(t){if(t.children.length){var e=t.children;return![].slice.call(e).some(function(t){return t.children.length>0})}return!0}(i)))})(t.target,o.options)&&o.eventHandel({eventType:"dom",eventName:"click"},t)}),t(this,"changeEvent",function(t){o.eventHandel({eventType:"dom",eventName:"change"},t)}),t(this,"submitEvent",function(t){o.eventHandel({eventType:"dom",eventName:"submit"},t)}),t(this,"getPageViewEvent",function(t,e){e&&"pushState"===e&&o.eventHandel({eventType:"dom",eventName:"beat"},Object.assign({beat_type:0},t)),o.eventHandel({eventType:"dom",eventName:"page_view"},t)}),t(this,"getPageLoadEvent",function(t){o.eventHandel({eventType:"dom",eventName:"page_statistics"},{lcp:t})}),this.config=n.getConfig().eventConfig,this.collect=i,this.options=e,this.beatTime=e.beat,this.statistics=!1}var i=e.prototype;return i.init=function(t){this.eventHandel=t;var e=this.config.mode;this.addListener(e)},i.addListener=function(t){var e=this;if("proxy-capturing"===t&&(this.config.click&&window.document.addEventListener("click",this.clickEvent,!0),this.config.change&&window.document.addEventListener("change",this.changeEvent,!0),this.config.submit&&window.document.addEventListener("submit",this.submitEvent,!0),this.config.pv&&this.collect.on("route-change",function(t){var i=t.config,n=t.name;e.getPageViewEvent(i,n)}),this.config.beat)){try{"complete"===document.readyState?this.beatEvent(this.beatTime):window.addEventListener("load",function(){e.beatEvent(e.beatTime)});var i=0,n=null;window.addEventListener("scroll",function(){clearTimeout(n),n=setTimeout(o,500),i=document.documentElement.scrollTop||document.body.scrollTop});var o=function(){(document.documentElement.scrollTop||document.body.scrollTop)==i&&e.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:1})}}catch(t){}try{var r=window.performance&&window.performance.getEntriesByType("paint");if(r&&r.length){var s=new PerformanceObserver(function(t){var i=t.getEntries(),n=i[i.length-1],o=n.renderTime||n.loadTime;e.statistics||(e.getPageLoadEvent(o),e.statistics=!0)});s.observe({entryTypes:["largest-contentful-paint"]}),setTimeout(function(){e.statistics||(e.getPageLoadEvent(r[0].startTime||0),e.statistics=!0)},2e3)}else this.getPageLoadEvent(0)}catch(t){this.getPageLoadEvent(0)}}},i.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},i.beatEvent=function(t){var e=this;try{var i;this.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:3}),this.beatTime&&(i=setInterval(function(){e.eventHandel({eventType:"dom",eventName:"beat"},{beat_type:2})},t)),a(function(){e.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),e.beatTime&&clearInterval(i)})}catch(t){}},e}(),me={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},ve=function(){function e(e,i){t(this,"config",void 0),this.config=e,this.config.eventConfig=Object.assign(this.config.eventConfig,i)}var i=e.prototype;return i.getConfig=function(){return this.config},i.setConfig=function(t){return this.config=t},e}();function _e(t){for(var e=[];null!==t.parentElement;)e.push(t),t=t.parentElement;var i=[],n=[];return e.forEach(function(t){var e=function(t){if(null===t)return{str:"",index:0};var e=0,i=t.parentElement;if(i)for(var n=i.children,o=0;o<n.length&&n[o]!==t;o++)n[o].nodeName===t.nodeName&&e++;return{str:[t.nodeName.toLowerCase(),ce(t,"list")?"[]":""].join(""),index:e}}(t),o=e.str,r=e.index;i.unshift(o),n.unshift(r)}),{element_path:"/"+i.join("/"),positions:n}}function ye(t,e,i,n){var o={},r=function(t){if(t){var e=t.getBoundingClientRect(),i=e.width,n=e.height;return{left:e.left,top:e.top,element_width:i,element_height:n}}}(e),s=function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var i=t,n=i.clientX,o=i.clientY,r=e,s=r.left,a=r.top,c=n-s>=0?n-s:0,h=o-a>=0?o-a:0;return{touch_x:Math.floor(c),touch_y:Math.floor(h)}}(t,r),a=r.element_width,c=r.element_height,h=s.touch_x,l=s.touch_y,u=_e(e),f=u.element_path,d=u.positions,p=function(t){var e=le(t),i=[];return function t(e){var n=function(t){var e="";return 3===t.nodeType?e=t.textContent.trim():t.dataset&&t.dataset.hasOwnProperty("teaTitle")||t.hasAttribute("ata-tea-title")?e=t.getAttribute("data-tea-title"):t.hasAttribute("title")?e=t.getAttribute("title"):"INPUT"===t.nodeName&&["button","submit"].includes(t.getAttribute("type"))?e=t.getAttribute("value"):"IMG"===t.nodeName&&t.getAttribute("alt")&&(e=t.getAttribute("alt")),e.slice(0,200)}(e);if(n&&-1===i.indexOf(n)&&i.push(n),e.childNodes.length>0)for(var o=e.childNodes,r=0;r<o.length;r++)8!==o[r].nodeType&&t(o[r])}(e),i}(e),g=window.performance.timing.navigationStart,m=Date.now()-g,v=d.map(function(t){return""+t}),_=null;if(window.TEAVisualEditor&&window.TEAVisualEditor.getOriginXpath&&(_=window.TEAVisualEditor.getOriginXpath({xpath:f,positions:v})),o.element_path=_&&_.xpath||f,o.positions=_&&_.positions||v,n&&!n.text&&(o.texts=p,o.element_title=function(t){if(!t)return"";var e="";return t.textContent?e=t.textContent.trim():t.innerText&&(e=t.innerText.trim()),"input"!==t.tagName&&"INPUT"!==t.tagName||(e=t.value||""),e}(e)),o.element_id=e.getAttribute("id")||"",o.element_class_name=e.getAttribute("class")||"",o.element_type=e.nodeType,o.element_width=Math.floor(a),o.element_height=Math.floor(c),o.touch_x=h,o.touch_y=l,o.page_manual_key="",o.elememt_manual_key="",o.since_page_start_ms=m,o.page_start_ms=g,o.page_path=location.pathname,o.page_host=location.host,i.track_attr&&he(e,i.track_attr)){var y=pe(e,i.track_attr);for(var b in y)o[b]=y[b]}if(i.custom_attr)try{if(he(e,i.custom_attr)){var E=pe(e,i.custom_attr),S=decodeURIComponent(E[i.custom_attr]),w=JSON.parse(S);if(Object.keys(w))for(var T in w)o[T]=w[T]}}catch(t){console.log("custom attr error")}var k=le(e);return"A"===k.tagName&&(o.href=k.getAttribute("href")),!1!==i.src&&("IMG"!==e.tagName||e.getAttribute("src").includes("base64")||(o.src=e.getAttribute("src"))),o}var be=function(t,e,i,n,o){return Object.assign({event:t},ye(e,i,n,o),{is_html:1,page_key:window.location.href,page_title:document.title})},Ee=function(){function e(e,i){t(this,"eventName",void 0),t(this,"ignore",{text:!1}),t(this,"initConfig",void 0),t(this,"options",void 0),this.initConfig=e,this.options=i,this.eventName=i&&"tea"===i.custom?{click:"__bav_click",page:"__bav_page",beat:"__bav_beat",static:"__bav_page_statistics",exposure:"__bav_page_exposure"}:{click:"bav2b_click",page:"bav2b_page",beat:"bav2b_beat",static:"bav2b_page_statistics",exposure:"bav2b_exposure",scroll:"$bav2b_slide"},i&&!1===i.text&&(this.ignore.text=!0),i&&i.exposure&&i.exposure.eventName&&(this.eventName.exposure=i.exposure.eventName)}var i=e.prototype;return i.handleEvent=function(t,e){try{if(ue(t.target))return null;var i="bav2b_click";switch(e){case"click":return i=this.eventName.click,be(i,t,t.target,this.options,this.ignore);case"exposure":return i=this.eventName.exposure,be(i,t,t.target,this.options,this.ignore);case"change":return i="bav2b_change",Object.assign({},be(i,t,t.target,this.options),function(t,e){try{if("bav2b_change"===t)return e.hasAttribute("data-tea-track")?{value:e.value}:{}}catch(t){return{}}}(i,t.target));case"submit":return be(i="bav2b_submit",t,t.target,this.options)}}catch(t){return console.error(t),null}},i.handleViewEvent=function(t){t.event=this.eventName.page,t.page_title=document.title,t.page_total_width=window.innerWidth,t.page_total_height=window.innerHeight;try{var e=window.sessionStorage.getItem("_tea_cache_duration");if(e){var i=JSON.parse(e);t.refer_page_duration_ms=i?i.duration:""}t.scroll_width=document.documentElement.scrollLeft?document.documentElement.scrollLeft+window.innerWidth:window.innerWidth,t.scroll_height=document.documentElement.scrollTop?document.documentElement.scrollTop+window.innerHeight:window.innerHeight,t.page_start_ms=window.performance.timing.navigationStart}catch(t){console.log("page event error "+JSON.stringify(t))}return t},i.handleStatisticsEvent=function(t){var e={};e.event=this.eventName.static,e.is_html=1,e.page_key=location.href,e.refer_page_key=document.referrer||"",e.page_title=document.title,e.page_manual_key=this.initConfig.autotrack.page_manual_key||"",e.refer_page_manual_key="";try{var i=t.lcp,n=window.performance.timing,o=n.loadEventEnd-n.navigationStart;e.page_init_cost_ms=parseInt(i||(o>0?o:0)),e.page_start_ms=n.navigationStart}catch(t){console.log("page_statistics event error "+JSON.stringify(t))}return e},i.handleBeadtEvent=function(t){t.event=this.eventName.beat,t.page_key=window.location.href,t.is_html=1,t.page_title=document.title,t.page_manual_key=this.initConfig.autotrack.page_manual_key||"";try{t.page_viewport_width=window.innerWidth,t.page_viewport_height=window.innerHeight,t.page_total_width=document.documentElement.scrollWidth,t.page_total_height=document.documentElement.scrollHeight,t.scroll_width=document.documentElement.scrollLeft+window.innerWidth,t.scroll_height=document.documentElement.scrollTop+window.innerHeight,t.since_page_start_ms=Date.now()-window.performance.timing.navigationStart,t.page_start_ms=window.performance.timing.navigationStart}catch(t){console.log("beat event error "+JSON.stringify(t))}return t},i.handleExposureEvent=function(t,e){if(ue(e.target))return null;var i=be(t.event||this.eventName.exposure,e,e.target||e,this.options,this.ignore);if(i.$exposure_type=t.exposureType,this.options.exposure.callback){var n=this.options.exposure.callback(i);return n||Object.keys(n).length?n:(console.warn("exposure callback must return data!"),i)}return i},i.handleScrollEvent=function(t,e){var i=be(t.event||this.eventName.scroll,e,e.target||e,this.options,this.ignore);if(i=Object.assign(i,t.params),!this.options.scroll.callback||(i=this.options.scroll.callback(i))||Object.keys(i).length)return i;console.warn("scroll callback must return data!")},e}(),Se=function(){function e(e){t(this,"logFunc",void 0),t(this,"logFuncBecon",void 0),t(this,"collect",void 0),this.collect=e}var i=e.prototype;return i.send=function(t,e){var i=e.event;delete e.event,t&&"becon"===t.eventSend?this.collect.beconEvent(i,e):this.collect.event(i,e)},i.get=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"GET"},e);fetch(t,i)},i.post=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"POST"},e);fetch(t,i)},e}(),we=function(){function e(e,i){t(this,"_instance",void 0),t(this,"_intersection",void 0),t(this,"config",void 0),this._instance=null,this._intersection=e,this.config=i,this._intersection&&this.init()}var i=e.prototype;return i.init=function(){var t=this;if(window.MutationObserver)try{if(this._instance=new MutationObserver(function(e){e.forEach(function(e){"attributes"===e.type&&t.attributeChangeObserve(e),"childList"===e.type&&t.modifyNodeObserve(e)})}),!document||!document.body)return void console.warn("please use sdk api init after body element");var e=!1!==this.config.autotrack.exposure.attributes;this._instance.observe(document.body,{childList:!0,attributes:e,subtree:!0,attributeOldValue:!1})}catch(t){console.log("your browser cannot support MutationObserver,so cannot report exposure event, please update")}else console.log("your browser cannot support MutationObserver,so cannot report exposure event, please update")},i.attributeChangeObserve=function(t){t.target.hasAttribute("data-exposure")?this.exposureAdd(t,"mutation"):this.exposureRemove(t)},i.modifyNodeObserve=function(t){var e=this;Array.prototype.forEach.call(t.addedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e.exposureAdd(t,"intersect"),e.mapChild(t,e.exposureAdd.bind(e))}),Array.prototype.forEach.call(t.removedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e.exposureRemove(t),e.mapChild(t,e.exposureRemove.bind(e))})},i.mapChild=function(t,e){var i=this;1===t.nodeType&&t.children.length&&Array.prototype.forEach.call(t.children,function(t){1===t.nodeType&&t.hasAttribute("data-exposure")&&e(t),i.mapChild(t,e)})},i.exposureAdd=function(t,e){try{this._intersection&&this._intersection.exposureAdd(t,e)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},i.exposureRemove=function(t){try{this._intersection&&this._intersection.exposureRemove(t)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},e}();t(we,"_exposure_observer",null);var Te=function(t){return t[t.EXPOSURE_ONCE=0]="EXPOSURE_ONCE",t[t.LIFECYCLE_SHOW_NEW=3]="LIFECYCLE_SHOW_NEW",t[t.RESUME_FORM_PAGE=6]="RESUME_FORM_PAGE",t[t.RESUME_FORM_BACK=7]="RESUME_FORM_BACK",t[t.NOT_EXPOSURE=-1]="NOT_EXPOSURE",t}(Te||{}),ke=function(){function e(i,n,o){var r=this;t(this,"count",void 0),t(this,"instance",void 0),t(this,"observeMap",void 0),t(this,"ratio",void 0),t(this,"eventHandle",void 0),t(this,"timeLimit",void 0),t(this,"exposureType",void 0),t(this,"hashMap",void 0),t(this,"lastState",void 0),t(this,"backStatus",!1),t(this,"customType",void 0),t(this,"collect",void 0),this.instance=this.buildObserver(),this.collect=i,this.observeMap=e._observer_map,n.autotrack.exposure.ratio?this.ratio=n.autotrack.exposure.ratio:0===n.autotrack.exposure.ratio?this.ratio=0:this.ratio=.5,this.timeLimit=n.autotrack.exposure.stay||0,this.exposureType=Te.NOT_EXPOSURE,this.eventHandle=o,this.hashMap=new Map,this.backStatus=!1,this.lastState=null,this.collect.on("re-start-sdk",function(){r.visibilitychange()}),this.addListen()}var i=e.prototype;return i.buildObserver=function(){var t=this;if(e._observer_instance)return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null;if(window.IntersectionObserver){for(var i=[],n=0;n<=1;n+=.01)i.push(n);i.push(1);try{e._observer_instance=new IntersectionObserver(function(e){e.forEach(function(e){var i=e.target.observeId,n=t.observeMap.get(i),o=(e.target,e.isIntersecting,e.intersectionRatio);if(n.intersectionRatio=o,o<=.1&&(e.target.backStatus=!1),t.observeMap.set(i,n),o<t.ratio)return n.isIntersecting=!1,n.added=!1,n.exposured=!1,n.startTime=Date.now(),void t.observeMap.set(i,n);if(!n.added){if(n.startTime=Date.now(),n.added=!0,n.isIntersecting=!0,t.timeLimit){var r=setTimeout(function(){try{if(n.isIntersecting&&!n.exposured&&t.observeMap.get(i)){var o=t.observeMap.get(i).intersectionRatio;t.exposureEvent(e,o,i,n)}}catch(t){console.log("IntersectionObserver setTimeout error,msg: "+JSON.stringify(t))}},t.timeLimit);n.wait=r}t.observeMap.set(i,n)}Date.now()-n.startTime>=t.timeLimit&&!n.exposured&&t.exposureEvent(e,o,i,n)})},{threshold:i})}catch(t){console.log("IntersectionObserver error,msg: "+JSON.stringify(t))}return e._observer_instance}return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null},i.exposureAdd=function(t,e){var i="mutation"===e?t.target:t,n=i.observeId,o=P();if(n||this.observeMap.has(n)){var r=this.observeMap.get(n);if(r&&i!==r.instance)this.unobserve(i),this.observeMap.delete(n),i.observeId=o,i.visible=!1,this.observeMap.set(o,{instance:i.cloneNode(!0),isIntersecting:!1}),this.observe(i);else{if(!0===i.visible)return;this.handleBoundingExposure(i)}}else i.observeId=o,i.visible=!1,this.observeMap.set(o,{instance:i.cloneNode(!0),isIntersecting:!1}),this.observe(i)},i.exposureRemove=function(t){this.observeMap.has(t.observeId)&&(this.observeMap.delete(t.observeId),this.unobserve(t),t.observeId="",t.visible=!1)},i.exposureEvent=function(t,e,i,n){if(e>=this.ratio){if("0"===t.target.style.opacity||"hidden"===t.target.style.visibility)return;if(!0===n.exposured)return;n.startWait&&clearTimeout(n.startWait);var o=t.target.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:o,exposureType:this.getExposureType(t.target)},t),t.target.visible=!0,t.target.hasExposure=!0,n.startTime=Date.now(),n.exposured=!0}else n.startTime=Date.now(),n.exposured=!1;this.observeMap.set(i,n)},i.observe=function(t){this.instance&&this.instance.observe(t)},i.unobserve=function(t){this.instance&&this.instance.unobserve(t)},i.getExposureDomToExposure=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t.handleBoundingExposure(e)})},i.visibilitychange=function(){var t=this,e=null;"visible"===document.visibilityState?this.timeLimit?e=setTimeout(function(){t.getExposureDomToExposure()},this.timeLimit):this.getExposureDomToExposure():(clearTimeout(e),this.customType=void 0)},i.handleBoundingExposure=function(t){if(this.getBoundingRatio(t)>=this.ratio){t.visible=!0;var e=t.getAttribute&&t.getAttribute("data-exposure-event");this.eventHandle({eventType:"dom",eventName:"exposure",event:e,exposureType:this.customType||Te.RESUME_FORM_BACK},t)}},i.getBoundingRatio=function(t){var e=t.getBoundingClientRect(),i=e.top,n=e.left,o=e.width,r=e.height,s=window.innerWidth||document.documentElement.clientWidth,a=window.innerHeight||document.documentElement.clientHeight;return i>=0&&n>=0&&i<=a&&n<=s?(o>s?s:o)*(a-i)/(o*r):0},i.getExposureType=function(t){return t.visible?!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Te.RESUME_FORM_PAGE:this.exposureType=Te.LIFECYCLE_SHOW_NEW:(t.hasExposure,!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Te.RESUME_FORM_PAGE:this.exposureType=Te.EXPOSURE_ONCE),this.exposureType},i.addListen=function(){var t=this;this.collect.on("set-exposure-type",function(e){t.customType=e});var e,i,n,o,r=this.visibilitychange.bind(this);if(e=document,i="visibilitychange",n=r,o=!1,e.addEventListener?e.addEventListener(i,n,o):e.attachEven?e.attachEven("on"+i,n):e["on"+i]=n,window.addEventListener("hashchange",function(e){var i=t.hashMap.get(e.oldURL);i&&location.href===i.prev?(t.backStatus=!0,t.exposureType=Te.RESUME_FORM_PAGE):(t.backStatus=!1,t.hashMap.set(location.href,{current:e.newURL,prev:e.oldURL}))}),this.collect.bridgeReport){var s=window.history.pushState;history.pushState=function(e){"function"==typeof history.onpushstate&&history.onpushstate({state:e});for(var i=arguments.length,n=new Array(i>1?i-1:0),o=1;o<i;o++)n[o-1]=arguments[o];var r=s.call.apply(s,[history,e].concat(n));return t.lastState=e,r};var a=history.replaceState;history.replaceState=function(e){"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});for(var i=arguments.length,n=new Array(i>1?i-1:0),o=1;o<i;o++)n[o-1]=arguments[o];var r=a.call.apply(a,[history,e].concat(n));return t.lastState=e,r}}else this.collect.on("STATE_CHANGE",function(e){t.lastState=e});return window.addEventListener("popstate",function(e){var i=e.state;i&&i.current&&t.lastState&&t.lastState.back&&i.current===t.lastState.back?(t.backStatus=!0,t.exposureType=Te.RESUME_FORM_PAGE):t.backStatus=!1}),function(){!function(t,e,i,n){t.addEventListener?t.removeEventListener(e,i,n):t.attachEven&&t.detachEven("on"+e,i)}(document,"visibilitychange",r,!1)}},e}();t(ke,"_observer_instance",null),t(ke,"_observer_map",new Map);var De=function(){function e(e,i,n){t(this,"_observer",void 0),t(this,"_intersection",void 0),i.autotrack&&i.autotrack.exposure&&(this._intersection=new ke(e,i,n),this._observer=new we(this._intersection,i),this._intersection&&this._observer?this.initObserver():console.log("your browser version cannot support exposure event, please update~"))}return e.prototype.initObserver=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t._intersection.exposureAdd(e,"intersect")})},e}(),Ae=function(t){return t[t.SCROLL_UP=1]="SCROLL_UP",t[t.SCROLL_DOWN=2]="SCROLL_DOWN",t[t.SCROLL_LEFT=3]="SCROLL_LEFT",t[t.SCROLL_RIGHT=4]="SCROLL_RIGHT",t[t.NOT_SCROLL=-1]="NOT_SCROLL",t}(Ae||{}),xe=function(){function e(e,i){t(this,"eventHandle",void 0),t(this,"distance",30),t(this,"scrollType",void 0),e.autotrack&&e.autotrack.scroll&&(e.autotrack.scroll.distance&&(this.distance=e.autotrack.scroll.distance),this.eventHandle=i,this.addLinstenr(),this.mutation())}var i=e.prototype;return i.addLinstenr=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-scroll]"),function(e){t.scrollHandle(e)})},i.mutation=function(){var t=this;if(window.MutationObserver)try{var e=new MutationObserver(function(e){e.forEach(function(e){"childList"===e.type&&t.modifyNodeObserve(e)})});if(!document||!document.body)return void console.warn("please use sdk api init after body element");e.observe(document.body,{childList:!0,attributes:!0,subtree:!0,attributeOldValue:!1})}catch(t){console.log("your browser cannot support MutationObserver")}else console.log("your browser cannot support MutationObserver")},i.modifyNodeObserve=function(t){var e=this;Array.prototype.forEach.call(t.addedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e.scrollHandle(t),e.mapChild(t,e.scrollHandle.bind(e))}),Array.prototype.forEach.call(t.removedNodes,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e.scrollHandle(t,"remove"),e.mapChild(t,e.scrollHandle.bind(e))})},i.mapChild=function(t,e){var i=this;1===t.nodeType&&t.children.length&&Array.prototype.forEach.call(t.children,function(t){1===t.nodeType&&t.hasAttribute("data-scroll")&&e(t),i.mapChild(t,e)})},i.scrollHandle=function(t,e){var i=this;try{var n=t.scrollTop,o=t.scrollLeft,r=null,s=0,a=0,c=function(e){clearTimeout(r),r=setTimeout(function(){var r=t.scrollTop,u=t.scrollLeft,f=e.target&&e.target.getAttribute("data-scroll-event")||"";1===l||2===l?r===c&&(a=c-n,Math.abs(a)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:l,$offsetY:a,$offsetX:s}},e)):3!==l&&4!==l||u===h&&(s=h-o,Math.abs(s)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:f,params:{$direction:l,$offsetY:a,$offsetX:s}},e)),n=c,o=h},100);var c=t.scrollTop,h=t.scrollLeft,l=Ae.NOT_SCROLL;c>n?l=Ae.SCROLL_DOWN:c<n?l=Ae.SCROLL_UP:h>o?l=Ae.SCROLL_LEFT:h<o&&(l=Ae.SCROLL_RIGHT)};return"remove"===e?t.removeEventListener("scroll",c,!1):t.addEventListener("scroll",c,!1),function(){t.removeEventListener("scroll",c,!1)}}catch(t){console.warn("scroll event error",JSON.stringify(t))}},e}(),Ce={hashTag:!1,impr:!1},Me=function(){function e(){t(this,"engine",void 0),t(this,"Listener",void 0),t(this,"EventHandle",void 0),t(this,"Request",void 0),t(this,"Exposure",void 0),t(this,"Scroll",void 0),t(this,"Config",void 0),t(this,"options",void 0),t(this,"destroyed",void 0),t(this,"autoTrackStart",void 0),t(this,"collect",void 0),t(this,"config",void 0)}var i=e.prototype;return i.apply=function(t,e){if(this.autoTrackStart=!1,this.collect=t,this.config=e,e.autotrack&&(!e.autotrack||!e.autotrack.collect_url||e.autotrack.collect_url())){var i=t.Types;this.ready(i.Autotrack),this.collect.emit(i.AutotrackReady)}},i.ready=function(t){this.collect.set(t);var e=this.config.autotrack;e="object"==typeof e?e:{},e=Object.assign(Ce,e),this.destroyed=!1,this.options=e,this.Config=new ve(me,this.options),this.Exposure=new De(this.collect,this.config,this.handle.bind(this)),this.Scroll=new xe(this.config,this.handle.bind(this)),this.Listener=new ge(e,this.collect,this.Config),this.EventHandle=new Ee(this.config,e),this.Request=new Se(this.collect),this.autoTrackStart=!0,this.init()},i.init=function(){this.Listener.init(this.handle.bind(this))},i.handle=function(t,e){try{if(this.config.autotrack.collect_url&&!this.config.autotrack.collect_url())return}catch(t){}this.collect.sdkStop||"dom"===t.eventType&&this.handleDom(t,e)},i.handleDom=function(t,e){try{var i=t.eventName;if("click"===i||"change"===i||"submit"===i){var n=this.EventHandle.handleEvent(e,i);n&&this.Request.send({eventType:"custom"},n)}else if("page_view"===i||"page_statistics"===i){var o;(o="page_view"===i?this.EventHandle.handleViewEvent(e):this.EventHandle.handleStatisticsEvent(e))&&this.Request.send({eventType:"custom"},o)}else if("beat"===i){var r=this.EventHandle.handleBeadtEvent(e),s=t.eventSend;r&&this.Request.send({eventType:"custom",eventSend:s},r)}else if("exposure"===i){var a=this.EventHandle.handleExposureEvent(t,e);a&&this.Request.send({eventType:"custom"},a)}else if("scroll"===i){var c=this.EventHandle.handleScrollEvent(t,e);c&&this.Request.send({eventType:"custom"},c)}}catch(t){console.log("handel dom event error "+JSON.stringify(t))}},i.destroy=function(){if(!this.autoTrackStart)return console.warn("engine is undefined, make sure you have called autoTrack.start()");this.autoTrackStart=!1,this.Listener.removeListener()},e}(),Ie=function(){function e(){t(this,"storage",void 0),t(this,"lastLocation",void 0),t(this,"autotrack",!1),t(this,"spa",!1),t(this,"fncArray",void 0),t(this,"collect",void 0),t(this,"config",void 0),t(this,"cache_key",void 0),t(this,"cache",{}),t(this,"appid",void 0),t(this,"allowHash",!1)}var i=e.prototype;return i.apply=function(t,e){if(e.spa||e.autotrack){var i=t.Types;this.collect=t,this.config=e,this.appid=e.app_id,this.allowHash=e.allow_hash,this.fncArray=new Map,this.setKey(),this.setLocation(),this.hack(),this.init(),this.listener(),t.emit(i.RouteReady)}},i.setKey=function(){this.storage=new b,this.cache_key="__tea_cache_refer_"+this.appid,this.cache={refer_key:"",refer_title:document.title||location.pathname,refer_manual_key:"",routeChange:!1},this.config.autotrack&&"object"==typeof this.config.autotrack&&this.config.autotrack.page_manual_key&&(this.cache.refer_manual_key=this.config.autotrack.page_manual_key),this.storage.setLocalItem(this.cache_key,this.cache)},i.hack=function(){var t=this,e=window.history.pushState;history.pushState=function(i){"function"==typeof history.onpushstate&&history.onpushstate({state:i});for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];var s=e.call.apply(e,[history,i].concat(o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a,"pushState"),s}};var i=history.replaceState;history.replaceState=function(e){"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];var s=i.call.apply(i,[history,e].concat(o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a),s}}},i.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},i.getLocation=function(){return this.lastLocation},i.init=function(){var t=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:t,init:!0})},i.listener=function(){var t=this,e=null;window.addEventListener("hashchange",function(i){if(t.lastLocation!==window.location.href&&(clearTimeout(e),t.allowHash)){t.setReferCache(t.lastLocation),t.lastLocation=window.location.href;var n=t.getPopStateChangeEventData();t.sendPv(n)}}),window.addEventListener("popstate",function(i){t.lastLocation!==window.location.href&&(e=setTimeout(function(){t.setReferCache(t.lastLocation),t.lastLocation=window.location.href;var e=t.getPopStateChangeEventData();t.sendPv(e)},10))})},i.getPopStateChangeEventData=function(){var t=this.pageConfig();return t.is_back=0,t},i.pageConfig=function(){try{var t=this.storage.getLocalItem(this.cache_key)||{},e=!1,i=this.storage.getLocalItem("__tea_cache_first_"+this.appid);return e=!i||1!=i,{is_html:1,url:location.href,referrer:this.handleRefer(),page_key:location.href,refer_page_key:this.handleRefer(),page_title:document.title||location.pathname,page_manual_key:this.config.autotrack&&this.config.autotrack.page_manual_key||"",refer_page_manual_key:t&&t.refer_manual_key||"",refer_page_title:t&&t.refer_title||"",page_path:location.pathname,page_host:location.host,is_first_time:""+e}}catch(t){return this.collect.emit(A.DEBUGGER_MESSAGE,{type:A.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),{}}},i.sendPv=function(t,e){this.collect.emit("route-change",{config:t,init:!1})},i.handleRefer=function(){var t="";try{var e=this.storage.getLocalItem()||{};t=e.routeChange?e.refer_key:this.collect.configManager.get("referrer")}catch(e){t=document.referrer}return t},i.setReferCache=function(t){var e=this.storage.getLocalItem(this.cache_key)||{};e.refer_key=t,e.routeChange=!0,this.storage.setLocalItem(this.cache_key,e)},e}(),Oe=500,Re=5005;var Be=function(){function e(){t(this,"collector",void 0),t(this,"config",void 0),t(this,"eventStorage",void 0),t(this,"domain",void 0),t(this,"verifyReady",!1),t(this,"cleanStatus",!1),t(this,"key",void 0),t(this,"heart",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collector=t,this.config=e,this.eventStorage=[],this.collector.on("submit-verify-h5",function(t){t&&t.length&&i.eventStore(t[0])}),this.checkUrl(),this.heartbeat()},i.checkUrl=function(){var t=window.location.href,e=l(t);e._r_d_&&e._r_c_k_?(this.verifyReady=!0,this.domain=e._r_d_,this.key=e._r_c_k_,this.checkCache()):this.collector.off("submit-verify-h5")},i.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},i.heartbeat=function(){var t=this;this.heart=setInterval(function(){var e={event:"simulator_test__",local_time_ms:Date.now()},i=t.collector.configManager.get(),n=i.header,o={events:[e],user:i.user,header:n};t.eventStore(o)},6e4)},i.eventStore=function(t){this.cleanStatus||(this.verifyReady?this.postVerify(t):this.eventStorage.push(t))},i.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},i.postVerify=function(t){var e=this;try{var i=JSON.parse(JSON.stringify(t));o(t)?i.forEach(function(t){e.fetchLog(t)}):this.fetchLog(i)}catch(t){console.log("web verify post error ~")}},i.fetchLog=function(t){!function(t,e,i,n,o,r,s,a,c,h){try{var l=new XMLHttpRequest,u=a||"POST";l.open(u,""+t,!0),c&&h?l.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):l.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&l.setRequestHeader("X-MCS-AppKey",""+s),n&&(l.withCredentials=!0),i&&(l.timeout=i,l.ontimeout=function(){r&&r(e,Re)}),l.onload=function(){if(o){var t=null;if(l.responseText){try{t=JSON.parse(l.responseText)}catch(e){t={}}o(t,e)}}},l.onerror=function(){l.abort(),r&&r(e,Oe)},c?l.send(e):l.send(JSON.stringify(e))}catch(t){}}(this.domain+"/simulator/h5/log?connection_key="+this.key,t,2e4,!1)},i.leave=function(){var t=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.cleanVerify()}),a(function(){t.cleanVerify()})},e}(),Ge=function(){function e(){t(this,"collect",void 0),t(this,"config",void 0),t(this,"storage",void 0),t(this,"eventKey",void 0),t(this,"storageNum",void 0),t(this,"eventUrl",void 0),t(this,"retryNum",void 0),t(this,"retryInterval",void 0),t(this,"retryWaitTime",3e3),t(this,"retryStatus",!1),t(this,"retryCacheStatus",!1),t(this,"errorCache",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroy)){var n=t.Types;this.storage=new b,this.eventUrl=this.collect.configManager.getUrl("event"),this.eventKey="__tea_cache_events_"+e.app_id,this.storageNum=e.storage_num||50,this.retryNum=e.retry_num||3,this.retryInterval=1e3,t.on(n.SubmitError,function(t){"f_data"===t.type&&i.storeData(t)}),t.on(n.Ready,function(){i.checkStorage()})}},i.retryRightNow=function(t){var e=this;if(this.retryStatus)this.errorCache.push(t);else{var i=0;this.retryStatus=!0;var n=setInterval(function(){if(3===i)return e.storeData(e.errorCache),e.retryStatus=!1,void clearInterval(n);var o=t.eventData;e.fetchData(o,function(){e.retryStatus=!1,clearInterval(n),e.retryCacheStatus&&e.errorCache.splice(0,1),e.errorCache.length&&(e.retryCacheStatus=!0,e.retryRightNow(e.errorCache[0]))},function(){i++})},this.retryInterval)}},i.storeData=function(t){var e=this.storage.getLocalItem(this.eventKey),i=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=i,this.storage.setLocalItem(this.eventKey,e))},i.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getLocalItem(this.eventKey);if(!e||!Object.keys(e).length)return;var i={events:[{event:"ontest",params:{app_id:this.config.app_id},local_time_ms:Date.now()}],user:{user_unique_id:this.collect.configManager.get("web_id")},header:{}};this.fetchData([i],function(){var i=JSON.parse(JSON.stringify(e)),n=function(n){t.fetchData(e[n],function(){delete i[n],t.storage.setLocalItem(t.eventKey,i)},function(){},!1)};for(var o in e)n(o)},function(){},!0)}catch(t){console.warn("error check storage")}},i.fetchData=function(t,e,i,n){this.collect.requestManager.useRequest({url:this.eventUrl,data:t,timeout:3e4,success:function(){e&&e()},fail:function(){i&&i(),console.log("network error,compensate report failk")},app_key:n&&!this.config.channel_domain?"566f58151b0ed37e":""})},e}(),Le=function(){function e(){t(this,"collector",void 0),t(this,"config",void 0),t(this,"TrackMap",void 0),t(this,"Types",void 0)}var i=e.prototype;return i.apply=function(t,e){var i=this;this.collector=t,this.config=e;var n=t.Types;t.on(n.TrackDurationStart,function(t){i.trackStart(t)}),t.on(n.TrackDurationEnd,function(t){i.trackEnd(t)}),t.on(n.TrackDurationPause,function(t){i.trackPause(t)}),t.on(n.TrackDurationResume,function(t){i.trackResume(t)}),this.Types=n,this.TrackMap=new Map,this.ready(n.TrackDuration)},i.ready=function(t){var e=this;if(this.collector.set(t),this.collector.hook._hooksCache.hasOwnProperty(t)){var i=this.collector.hook._hooksCache[t];if(!Object.keys(i).length)return;var n=function(t){i[t].length&&i[t].forEach(function(i){e.collector.hook.emit(t,i)})};for(var o in i)n(o)}},i.trackStart=function(t){this.TrackMap.set(t,{startTime:Date.now(),isPause:!1,pauseTime:0,resumeTime:0})},i.trackEnd=function(t){var e=t.eventName,i=t.params;if(this.TrackMap.has(e)){var n=this.TrackMap.get(e),o=0;o=n.isPause?n.pauseTime-n.startTime:n.resumeTime?n.pauseTime-n.startTime+(Date.now()-n.resumeTime):Date.now()-n.startTime;var r=Object.assign(i,{event_duration:o});this.collector.event(e,r),this.cleanTrack(e)}},i.trackPause=function(t){if(this.TrackMap.has(t)){var e=this.TrackMap.get(t);e.isPause||(e.isPause=!0,e.pauseTime=Date.now(),this.TrackMap.set(t,e))}},i.trackResume=function(t){if(this.TrackMap.has(t)){var e=this.TrackMap.get(t);e.isPause&&(e.isPause=!1,e.resumeTime=Date.now(),this.TrackMap.set(t,e))}},i.cleanTrack=function(t){this.TrackMap.delete(t)},e}();Zt.usePlugin(ie,"ab"),Zt.usePlugin(re,"stay"),Zt.usePlugin(Ge,"store"),Zt.usePlugin(Me,"autotrack"),Zt.usePlugin(Le,"trackDuration"),Zt.usePlugin(Be,"verify"),Zt.usePlugin(se,"profile"),Zt.usePlugin(ae,"heartbeat"),Zt.usePlugin(Ie,"route");var Pe=new Zt("default"),Ne=Zt;exports.Collector=Ne,exports.default=Pe;
|