@datarangers/sdk-javascript 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){return t=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return s}function i(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t}var n,o=function(){function t(){this._hooks={},this._cache=[],this._hooksCache={}}return t.prototype.on=function(t,e){t&&e&&"function"==typeof e&&(this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e))},t.prototype.once=function(t,e){var i=this;if(t&&e&&"function"==typeof e){this.on(t,function n(o){e(o),i.off(t,n)})}},t.prototype.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]=[]},t.prototype.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)},t.prototype._emit=function(t,e){t&&this._hooks[t]&&this._hooks[t].length&&i(this._hooks[t]).forEach(function(t){try{t(e)}catch(t){}})},t.prototype.set=function(t){t&&-1===this._cache.indexOf(t)&&this._cache.push(t)},t}(),r=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},s=function(t){return Array.isArray(t)},a=(n=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return n+=1}),c=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)},h=function(t){!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)},u=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach(function(e){void 0!==document[e]&&(t=1)}),t},l=function(t){var e=document.createElement("a");return e.href=t,e},p=function(t){var e={};try{var i=l(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},f=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 d=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},g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t,e){return t(e={exports:{}},e.exports),e.exports}var y=m(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 t(){this.cache={}}return t.prototype.setItem=function(t,e){this.cache[t]=e},t.prototype.getItem=function(t){return this.cache[t]},t.prototype.removeItem=function(t){this.cache[t]=void 0},t.prototype.getCookie=function(t){this.getItem(t)},t.prototype.setCookie=function(t,e){this.setItem(t,e)},t}();var _,b,E={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{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{localStorage.removeItem(t)}catch(t){}},getCookie:function(t,e){try{return y.get(t)}catch(t){return""}},setCookie:function(t,e,i,n){try{var o=n||document.domain,r=+new Date+i;y.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},S={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{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{sessionStorage.removeItem(t)}catch(t){}},getCookie:function(t){this.getItem(t)},setCookie:function(t,e){this.setItem(t,e)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},w=function(){function t(t,e){this._storage=e&&"session"===e?S:!t&&E.isSupportLS?E:new v}return t.prototype.getItem=function(t){return this._storage.getItem(t)},t.prototype.setItem=function(t,e){this._storage.setItem(t,e)},t.prototype.getCookie=function(t,e){return this._storage.getCookie(t,e)},t.prototype.setCookie=function(t,e,i,n){this._storage.setCookie(t,e,i,n)},t.prototype.removeItem=function(t){this._storage.removeItem(t)},t}(),T=function(){function t(t,e,i){this.appid=t,this.domain=e,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=i}return t.prototype.init=function(){var t=window.navigator.userAgent,e=window.navigator.language,i=document.referrer,n=i?l(i).hostname:"",o=p(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 w(!1),r=new w(!1,"session"),s=t?"_tea_utm_cache_"+t:"_tea_utm_cache",a=t?"_$utm_from_url_"+t:"_$utm_from_url",c={},h=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],u={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 p in u)u[p]&&(-1!==h.indexOf(p)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[p]=u[p]):c[p]=u[p],l=!0);if(l)r.setItem(a,"1"),o.setCookie(s,JSON.stringify(c),n,i);else{var f=o.getCookie(s,i);f&&(c=JSON.parse(f))}r.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(t){return u}return c}(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)}},t.prototype.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=p(t);a.keyword&&(o=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:n,$latest_search_keyword:o,isLast:s}},t.prototype.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}},t.prototype.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}},t.prototype.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()},t.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},t}(),k=function(){function t(){this.cache={}}return t.prototype.setItem=function(t,e){this.cache[t]=e},t.prototype.getItem=function(t){return this.cache[t]},t.prototype.removeItem=function(t){this.cache[t]=void 0},t}(),D=function(){function t(){this.support=this.isSupportLS()}return t.prototype.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}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},t}(),A=function(){function t(){this.support=this.isSupportSession()}return t.prototype.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}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},t}(),C=function(){function t(){this.defaultExpireTime=6048e5,this.local=new D,this.session=new A,this.cache=new k}return t.prototype.getLocalItem=function(t){return this.local.getItem(t)},t.prototype.setLocalItem=function(t,e){this.local.setItem(t,e)},t.prototype.removeLocalItem=function(t){this.local.removeItem(t)},t.prototype.getSessionItem=function(t){return this.session.getItem(t)},t.prototype.setSessionItem=function(t,e){this.session.setItem(t,e)},t.prototype.removeSessionItem=function(t){this.session.removeItem(t)},t.prototype.getCacheItem=function(t){return this.cache.getItem(t)},t.prototype.setCacheItem=function(t,e){this.cache.setItem(t,e)},t.prototype.removeCacheItem=function(t){this.cache.removeItem(t)},t.prototype.getCookie=function(t,e){try{return y.get(t)}catch(t){return""}},t.prototype.setCookie=function(t,e,i,n){void 0===i&&(i=this.defaultExpireTime);try{var o=n||document.domain,r=+new Date+i;y.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},t.prototype.removeCookie=function(t,e){try{y.remove(t,{path:"/",domain:e||""})}catch(t){}},t}(),I={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},x="0.1.0",O={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},R=function(){function t(t,e){this.collector=t,this.config=e,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}$")}return t.prototype.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},t.prototype.checkEventName=function(t){return!!t&&this.calculate(t,"event")},t.prototype.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},t.prototype.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))},t}();!function(t){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"}(_||(_={})),function(t){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"}(b||(b={}));var M=_,B=void 0,G=(new Date).getTimezoneOffset(),P=parseInt(""+-G/60,10),L=60*G,N=function(){function e(t,e){this.is_first_time=!0,this.configPersist=!1,this.enableClientTransport=!1,this.initConfig=e,this.collect=t;var i=new T(e.app_id,e.cookie_domain||"",e.cookie_expire||7776e6).init();this.eventCheck=new R(t,e);var n="__tea_cache_first_"+e.app_id;this.configKey="__tea_cache_config_"+e.app_id,this.storage=new C,e.configPersist&&(this.configPersist=!0,this.storage=1===e.configPersist?this.sessionStorage:this.localStorage);var o=this.storage.getLocalItem(n);o&&1==o?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(n,"1")),this.envInfo={user:{user_unique_id:B,user_type:B,user_id:B,user_is_auth:B,user_is_login:B,device_id:B,web_id:B,ip_addr_id:B,user_unique_id_type:B,anonymous_id:B},header:{app_id:B,app_name:B,app_install_id:B,install_id:B,app_package:B,app_channel:B,app_version:B,ab_version:B,os_name:i.os_name,os_version:i.os_version,device_model:i.device_model,ab_client:B,traffic_type:B,client_ip:B,device_brand:B,os_api:B,access:B,language:i.language,region:B,app_language:B,app_region:B,creative_id:i.utm.creative_id,ad_id:i.utm.ad_id,campaign_id:i.utm.campaign_id,log_type:B,rnd:B,platform:i.platform,sdk_version:x,sdk_lib:"js",province:B,city:B,timezone:P,tz_offset:L,tz_name:B,sim_region:B,carrier:B,resolution:i.screen_width+"x"+i.screen_height,browser:i.browser,browser_version:i.browser_version,referrer:i.referrer,referrer_host:i.referrer_host,width:i.screen_width,height:i.screen_height,screen_width:i.screen_width,screen_height:i.screen_height,utm_term:i.utm.utm_term,utm_content:i.utm.utm_content,utm_source:i.utm.utm_source,utm_medium:i.utm.utm_medium,utm_campaign:i.utm.utm_campaign,tracer_data:JSON.stringify(i.utm.tracer_data),custom:{},wechat_unionid:B,wechat_openid:B}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(i),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}return e.prototype.initDomain=function(){var t=this.initConfig.channel_domain;if(t)this.domain=t;else{var e=this.initConfig.channel;this.domain=c(I[e])}},e.prototype.setDomain=function(t){this.domain=t},e.prototype.getDomain=function(){return this.domain},e.prototype.initABData=function(){var t="__tea_sdk_ab_version_"+this.initConfig.app_id,e=null;if(this.initConfig.ab_cross){var i=this.localStorage.getCookie(t,this.initConfig.ab_cookie_domain);e=i?JSON.parse(i):null}else e=this.localStorage.getItem(t);this.setAbCache(e)},e.prototype.setAbCache=function(t){this.ab_cache=t},e.prototype.getAbCache=function(){return this.ab_cache},e.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},e.prototype.setAbVersion=function(t){this.ab_version=t},e.prototype.getAbVersion=function(){return this.ab_version},e.prototype.setEnableClientTransport=function(t){this.enableClientTransport=t},e.prototype.getEnableClientTransport=function(){return this.enableClientTransport},e.prototype.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.0&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},e.prototype.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]},e.prototype.set=function(e){var i=this;Object.keys(e).forEach(function(n){void 0!==e[n]&&null!==e[n]||i.delete(n);try{i.eventCheck.calculate(n,"config")}catch(t){}if("traffic_type"===n&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=e[n]),"evtParams"===n)i.evtParams=t({},i.evtParams||{},e.evtParams||{});else if("_staging_flag"===n)i.evtParams=t({},i.evtParams||{},{_staging_flag:e._staging_flag});else if("reportErrorCallback"===n&&"function"==typeof e[n])i.reportErrorCallback=e[n];else{var o="",r="";if(n.indexOf(".")>-1){var s=n.split(".");o=s[0],r=s[1]}o?"user"===o||"header"===o?i.envInfo[o][r]=e[n]:i.envInfo.header.custom[r]=e[n]:Object.hasOwnProperty.call(i.envInfo.user,n)?["user_type","ip_addr_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?Number(e[n]):e[n]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?String(e[n]):e[n]:["user_is_auth","user_is_login"].indexOf(n)>-1?i.envInfo.user[n]=Boolean(e[n]):"device_id"===n&&(i.envInfo.user[n]=e[n]):Object.hasOwnProperty.call(i.envInfo.header,n)?i.envInfo.header[n]=e[n]:i.envInfo.header.custom[n]=e[n]}})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},e.prototype.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),null}},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e}(),F=function(){function t(t,e){this.isLog=e||!1,this.name=t||""}return t.prototype.info=function(t){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.warn=function(t){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.error=function(t){this.isLog&&console.error("[instance: "+this.name+"] "+t)},t.prototype.throw=function(t){throw this.error(this.name),new Error(t)},t}(),U=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}(),q=function(){function e(){this.eventLimit=50,this.eventCache=[],this.beconEventCache=[]}return e.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=t.configManager,this.storgae=new C,this.eventCheck=new R(t,e),this.maxReport=e.max_report||20,this.reportTime=e.reportTime||30,this.timeout=e.timeout||1e5,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(M.Ready,function(){i.reportAll(!1)}),this.collect.on(M.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(M.Event,function(t){i.event(t)}),this.collect.on(M.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(M.CleanEvents,function(){i.reportAll(!1)}),this.linster()},e.prototype.linster=function(){var t=this;window.addEventListener("unload",function(){t.reportAll(!0)},!1),h(function(){t.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.reportAll(!0)},!1)},e.prototype.reportAll=function(t){this.report(t),this.reportBecon()},e.prototype.event=function(t){var e=this;try{var n=i(t,this.storgae.getCacheItem(this.eventKey)||[]);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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.beconEvent=function(t){var e=i(t,this.storgae.getCacheItem(this.beconKey)||[]);this.storgae.setCacheItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},e.prototype.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))},e.prototype.report=function(t){if(!this.collect.destroyInstance&&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))}},e.prototype.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{o=this.split(this.merge(t));this.send(o,e)}},e.prototype.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},e.prototype.merge=function(e,i){var n=this,o=this.configManager.get(),r=o.header,s=o.user;r.referrer=this.handleRefer(),r.custom=JSON.stringify(r.custom);var a=this.configManager.get("evtParams"),c=this.configManager.get("user_unique_id_type"),h=e.map(function(e){try{if(Object.keys(a).length&&!i&&(e.params=t({},e.params,a)),n.collect.dynamicParamsFilter){var o=n.collect.dynamicParamsFilter();Object.keys(o).length&&(e.params=t({},e.params,o))}c&&(e.params.$user_unique_id_type=c);var r=n.configManager.getAbCache(),h=n.configManager.getAbVersion();return h&&r&&(n.config.disable_ab_reset||r.uuid===s.user_unique_id)&&(e.ab_sdk_version=h),e.session_id=n.collect.sessionManager.getSessionId(),e.params=JSON.stringify(e.params),e}catch(t){return n.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),e}}),u=[];if(!Object.keys(s).length)return console.warn("user info error,cant report"),u;this.config.enable_anonymousid&&delete s.web_id;var l=JSON.parse(JSON.stringify({events:h,user:s,header:r}));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,u.push(l),u},e.prototype.split=function(t){return t=t.map(function(t){var e=[];return e.push(t),e})},e.prototype.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(M.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(M.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:r,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(M.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,errorMessage:o,endTime:Date.now()}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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}),i.collect.emit(M.SubmitVerifyH,o),i.collect.emit(M.SubmitAfter,o)}catch(t){console.warn("something error, "+JSON.stringify(t.stack)),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}})},e}(),z=function t(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},V=function(){return z().replace(/-/g,"").slice(0,19)},H=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)})},K=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.storage=new C,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(M.SessionReset,function(){i.resetSessionId()}),this.collect.on(M.SessionResetTime,function(){i.updateSessionIdTime()}))},t.prototype.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:H(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},t.prototype.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:H(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},t.prototype.getSessionId=function(){var t=this.storage.getSessionItem(this.sessionKey);return this.disableSession?"":t&&t.sessionId?t.sessionId:""},t.prototype.resetExpTime=function(){var t=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime))},t.prototype.resetSessionId=function(){var t={sessionId:H(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},t.prototype.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:H(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},t}(),j=function(){function t(){this.cacheToken={},this.enableCookie=!1,this.enableTTwebid=!1,this.enableCustomWebid=!1,this.enableAnonymousid=!1}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=this.collect.configManager,this.storage=new C,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(M.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(M.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(M.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()},t.prototype.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(M.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(M.TokenComplete)}):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},t.prototype.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:V(),user_unique_id:this.configManager.get("user_unique_id")||V()}):this.remoteWebid()},t.prototype.checkEnv=function(){var t=window.navigator.userAgent;if(-1!==t.indexOf("miniProgram")||-1!==t.indexOf("MiniProgram")){var e=p(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},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.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(b.DEBUGGER_MESSAGE,{type:b.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(M.TokenError),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.TokenError),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})},t.prototype.getLocalId=function(){for(var t=V(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=V(),e++}return t},t.prototype.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(M.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(M.TokenComplete)},t.prototype.completeAnonymous=function(t){var e=t.anonymous_id||H(),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(M.TokenComplete)},t.prototype.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(M.TokenComplete)},t.prototype.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(M.TokenChange,{type:"uuid",id:t}),this.collect.emit(M.SessionReset)}else this.clearUuid()},t.prototype.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(M.TokenReset))}},t.prototype.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(M.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(M.TokenChange,{type:"anonymous_id",id:t}),this.setStorage(this.cacheToken))}},t.prototype.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(M.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(M.TokenChange,{type:"webid",id:t})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},t.prototype.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},t.prototype.getReady=function(){return this.tokenReady},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})})},t}(),J=function(){function t(t,e){var i=this;this.collector=t,this.config=e,this.requestType=e.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=e.custom_request_header||{},this.collector.on(M.CustomHeader,function(t){i.setRequestHeader(t)})}return t.prototype.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},t.prototype.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,u=t.encryption,l=t.encryption_header;if(window.fetch&&"undefined"!=typeof Request){var p={method:o||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var f=this.collector.configManager.get("browser"),d=this.collector.configManager.get("browser_version");if(d=d.split("."),"Chrome"===f&&d.length&&d[0]&&Number(d[0])<82)return void this.useSendBeacon(t);p.keepalive=!0}var g=JSON.stringify(n),m={"Content-Type":"application/json; charset=utf-8"};u&&l&&(m["Content-Type"]="application/octet-stream;tt-data="+l),p.body=g,p.headers=m;var y=null;y="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var v=setTimeout(function(){y.abort()},c);if(Object.keys(this.customHeader).length)for(var _ in this.customHeader)m[_]=this.customHeader[_];p.signal=y.signal;var E=Date.now();try{fetch(i,p).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(v),r&&r(t,n,a,E,200)}).catch(function(t){clearTimeout(v),s&&s(n,e.errorCode.FETCH_ERROR,E,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(b.DEBUGGER_MESSAGE,{type:b.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")},t.prototype.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,n=t.status,o=t.success,r=t.fail,s=Date.now();window.navigator.sendBeacon(e,JSON.stringify(i))?o&&o({e:0},i,n,s,200):r&&r(i,this.errorCode.BEACON_FALSE,s,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},t.prototype.useXhr=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.timeout,c=t.withCredentials,h=t.encryption,u=t.encryption_header,l=t.status;try{var p=new XMLHttpRequest;p.open(o||"POST",i,!0);var f=Date.now();if(p.setRequestHeader("Content-Type","application/json; charset=utf-8"),h&&u?p.setRequestHeader("Content-Type","application/octet-stream;tt-data="+u):p.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var d in this.customHeader)p.setRequestHeader(d,this.customHeader[d]);c&&(p.withCredentials=!0),a&&(p.timeout=a,p.ontimeout=function(){s&&s(n,e.errorCode.TIMEOUT,f,e.errorMessage.TIMEOUT)}),p.onload=function(){if(r){var t=null;if(p.responseText){try{t=JSON.parse(p.responseText)}catch(e){t={}}r(t,n,l,f,p.status)}else s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR)}},p.onerror=function(){s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR),p.abort()},p.send(JSON.stringify(n))}catch(t){this.collector.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},t.prototype.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)},t.prototype.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)}},t}(),W=m(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,u=a*c+h*s;o=((c=s*c+((32767&u)<<15)+i[n]+(1073741823&o))>>>30)+(u>>>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,u=a*c+h*s;o=((c=s*c+((16383&u)<<14)+i[n]+o)>>28)+(u>>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 u(t){var e=n();return e.fromInt(t),e}function l(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 p(t){this.m=t}function f(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 d(t,e){return t&e}function g(t,e){return t|e}function m(t,e){return t^e}function y(t,e){return t&~e}function v(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 _(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}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},f.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},f.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},f.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)},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)},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,u=this.DB-l(r[r.t-1]);u>0?(r.lShiftTo(u,a),s.lShiftTo(u,o)):(r.copyTo(a),s.copyTo(o));var p=a.t,f=a[p-1];if(0!=f){var d=f*(1<<this.F1)+(p>1?a[p-2]>>this.F2:0),g=this.FV/d,m=(1<<this.F1)/d,y=1<<this.F2,v=o.t,_=v-p,b=null==e?n():e;for(a.dlShiftTo(_,b),o.compareTo(b)>=0&&(o[o.t++]=1,o.subTo(b,o)),i.ONE.dlShiftTo(p,b),b.subTo(a,a);a.t<p;)a[a.t++]=0;for(;--_>=0;){var E=o[--v]==f?this.DM:Math.floor(o[v]*g+(o[v-1]+y)*m);if((o[v]+=a.am(0,E,o,_,0,p))<E)for(a.dlShiftTo(_,b),o.subTo(b,o);o[v]<--E;)o.subTo(b,o)}null!=e&&(o.drShiftTo(p,e),c!=h&&i.ZERO.subTo(e,e)),o.t=p,o.clamp(),u>0&&o.rShiftTo(u,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=l(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)+l(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 p(e):new f(e),this.exp(t,i)},i.ZERO=u(0),i.ONE=u(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 C(){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=u(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 u=h(t,c);u<0?"-"==t.charAt(c)&&0==this.signum()&&(r=!0):(a=e*a+u,++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,d,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,y,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+v(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+=_(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,y)},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=u(1);if(r<=0)return s;i=r<18?1:r<48?3:r<144?4:r<768?5:6,o=r<8?new p(e):e.isEven()?new S(e):new f(e);var a=new Array,c=3,h=i-1,d=(1<<i)-1;if(a[1]=o.convert(this),i>1){var g=n();for(o.sqrTo(a[1],g);c<=d;)a[c]=n(),o.mulTo(g,a[c-2],a[c]),c+=2}var m,y,v=t.t-1,_=!0,b=n();for(r=l(t[v])-1;v>=0;){for(r>=h?m=t[v]>>r-h&d:(m=(t[v]&(1<<r+1)-1)<<h-r,v>0&&(m|=t[v-1]>>this.DB+r-h)),c=i;!(1&m);)m>>=1,--c;if((r-=c)<0&&(r+=this.DB,--v),_)a[m].copyTo(s),_=!1;else{for(;c>1;)o.sqrTo(s,b),o.sqrTo(b,s),c-=2;c>0?o.sqrTo(s,b):(y=s,s=b,b=y),o.mulTo(b,a[m],s)}for(;v>=0&&!(t[v]&1<<r);)o.sqrTo(s,b),y=s,s=b,b=y,--r<0&&(r=this.DB-1,--v)}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=u(1),s=u(0),a=u(0),c=u(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 I;if(T=new Array,k=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var x=new Uint8Array(32);for(window.crypto.getRandomValues(x),I=0;I<32;++I)T[k++]=x[I]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var O=window.crypto.random(32);for(I=0;I<O.length;++I)T[k++]=255&O.charCodeAt(I)}for(;k<G;)I=Math.floor(65536*Math.random()),T[k++]=I>>>8,T[k++]=255&I;k=0,C()}function R(){if(null==w){for(C(),(w=new B).init(T),k=0;k<T.length;++k)T[k]=0;k=0}return w.next()}function M(){}function B(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=R()},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:M}}).call(g)});W.BigInteger,W.SecureRandom;const{BigInteger:X}=W;class ${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 Z extends ${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 X(n,16),e=n.xor(t).add(X.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class Y extends ${constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function Q(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function tt(t,e){const i=Q(t,e),n=t.substr(e+2,2*i);if(!n)return-1;return(+n[0]<8?new X(n,16):new X(n.substr(2),16)).intValue()}function et(t,e){return e+2*(Q(t,e)+1)}var it={encodeDer(t,e){const i=new Z(t),n=new Z(e);return new Y([i,n]).getEncodedHex()},decodeDer(t){const e=et(t,0),i=et(t,e),n=tt(t,e),o=t.substr(i,2*n),r=i+o.length,s=et(t,r),a=tt(t,r),c=t.substr(s,2*a);return{r:new X(o,16),s:new X(c,16)}}};const{BigInteger:nt}=W,ot=new nt("2"),rt=new nt("3");class st{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 st(this.q,this.x.negate().mod(this.q))}add(t){return new st(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new st(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new st(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new st(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new st(this.q,this.x.square().mod(this.q))}}class at{constructor(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?nt.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(nt.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(nt.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(nt.ZERO)&&!this.y.toBigInteger().equals(nt.ZERO)}negate(){return new at(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),u=c.subtract(h),l=i.multiply(s).mod(a),p=r.multiply(n).mod(a),f=l.subtract(p);if(nt.ZERO.equals(u))return nt.ZERO.equals(f)?this.twice():this.curve.infinity;const d=c.add(h),g=n.multiply(s).mod(a),m=u.square().mod(a),y=u.multiply(m).mod(a),v=g.multiply(f.square()).subtract(d.multiply(m)).mod(a),_=u.multiply(v).mod(a),b=f.multiply(m.multiply(c).subtract(v)).subtract(l.multiply(y)).mod(a),E=y.multiply(g).mod(a);return new at(this.curve,this.curve.fromBigInteger(_),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(rt).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),u=r.square().subtract(c.shiftLeft(3)).mod(n),l=s.multiply(u).mod(n),p=r.multiply(c.shiftLeft(2).subtract(u)).subtract(h.shiftLeft(1).multiply(a)).mod(n),f=s.multiply(h).mod(n);return new at(this.curve,this.curve.fromBigInteger(l),this.curve.fromBigInteger(p),f)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(rt),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 ct={ECPointFp:at,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new at(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 st(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 nt(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 nt("4")).add(nt.ONE),this.q));return i.toBigInteger().mod(ot).equals(new nt(t.substr(0,2),16).subtract(ot))||(i=i.negate()),new at(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 at(this,this.fromBigInteger(new nt(o,16)),this.fromBigInteger(new nt(r,16)));default:return null}}}};const{BigInteger:ht,SecureRandom:ut}=W,{ECCurveFp:lt}=ct,pt=new ut,{curve:ft,G:dt,n:gt}=mt();function mt(){const t=new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new ht("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new lt(t,e,i),o=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:o,n:new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function yt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var vt={getGlobalCurve:function(){return ft},generateEcparam:mt,generateKeyPairHex:function(t,e,i){const n=(t?new ht(t,e,i):new ht(gt.bitLength(),pt)).mod(gt.subtract(ht.ONE)).add(ht.ONE),o=yt(n.toString(16),64),r=dt.multiply(n);return{privateKey:o,publicKey:"04"+yt(r.getX().toBigInteger().toString(16),64)+yt(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 ht(t.substr(e+2,e),16).mod(new ht("2")).equals(ht.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:yt,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=yt(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=ft.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ft.a)).add(ft.b))},comparePublicKeyHex:function(t,e){const i=ft.decodePointHex(t);if(!i)return!1;const n=ft.decodePointHex(e);return!!n&&i.equals(n)}};const _t=new Uint32Array(68),bt=new Uint32Array(64);function Et(t,e){const i=31&e;return t<<i|t>>>32-i}function St(t,e){const i=[];for(let n=t.length-1;n>=0;n--)i[n]=255&(t[n]^e[n]);return i}function wt(t){return t^Et(t,9)^Et(t,17)}function Tt(t){return t^Et(t,15)^Et(t,23)}function kt(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++){_t.fill(0),bt.fill(0);const e=16*t;for(let t=0;t<16;t++)_t[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)_t[t]=Tt(_t[t-16]^_t[t-9]^Et(_t[t-3],15))^Et(_t[t-13],7)^_t[t-6];for(let t=0;t<64;t++)bt[t]=_t[t]^_t[t+4];const i=2043430169,n=2055708042;let o,r,a,h,u,l=c[0],p=c[1],f=c[2],d=c[3],g=c[4],m=c[5],y=c[6],v=c[7];for(let t=0;t<64;t++)u=t>=0&&t<=15?i:n,o=Et(Et(l,12)+g+Et(u,t),7),r=o^Et(l,12),a=(t>=0&&t<=15?l^p^f:l&p|l&f|p&f)+d+r+bt[t],h=(t>=0&&t<=15?g^m^y:g&m|~g&y)+v+o+_t[t],d=f,f=Et(p,9),p=l,l=a,v=y,y=Et(m,19),m=g,g=wt(h);c[0]^=l,c[1]^=p,c[2]^=f,c[3]^=d,c[4]^=g,c[5]^=m,c[6]^=y,c[7]^=v}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 Dt=new Uint8Array(64),At=new Uint8Array(64);for(let t=0;t<64;t++)Dt[t]=54,At[t]=92;var Ct={sm3:kt,hmac:function(t,e){for(e.length>64&&(e=kt(e));e.length<64;)e.push(0);const i=St(e,Dt),n=St(e,At),o=kt([...i,...t]);return kt([...n,...o])}};const{BigInteger:It}=W,{encodeDer:xt,decodeDer:Ot}=it,Rt=Ct.sm3,{G:Mt,curve:Bt,n:Gt}=vt.generateEcparam();function Pt(t,e,i="1234567812345678"){i=vt.utf8ToHex(i);const n=vt.leftPad(Mt.curve.a.toBigInteger().toRadix(16),64),o=vt.leftPad(Mt.curve.b.toBigInteger().toRadix(16),64),r=vt.leftPad(Mt.getX().toBigInteger().toRadix(16),64),s=vt.leftPad(Mt.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=Mt.curve.decodePointHex(e);a=vt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=vt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=vt.hexToArray(i+n+o+r+s+a+c),u=4*i.length;h.unshift(255&u),h.unshift(u>>8&255);const l=Rt(h);return vt.arrayToHex(Rt(l.concat(vt.hexToArray(t))))}function Lt(){const t=vt.generateKeyPairHex(),e=Bt.decodePointHex(t.publicKey);return t.k=new It(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Nt={generateKeyPairHex:vt.generateKeyPairHex,compressPublicKeyHex:vt.compressPublicKeyHex,comparePublicKeyHex:vt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?vt.hexToArray(vt.utf8ToHex(t)):Array.prototype.slice.call(t),e=vt.getGlobalCurve().decodePointHex(e);const n=vt.generateKeyPairHex(),o=new It(n.privateKey,16);let r=n.publicKey;r.length>128&&(r=r.substr(r.length-128));const s=e.multiply(o),a=vt.hexToArray(vt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=vt.hexToArray(vt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=vt.arrayToHex(Rt([].concat(a,t,c)));let u=1,l=0,p=[];const f=[].concat(a,c),d=()=>{p=Rt([...f,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,l=0};d();for(let e=0,i=t.length;e<i;e++)l===p.length&&d(),t[e]^=255&p[l++];const g=vt.arrayToHex(t);return 0===i?r+g+h:r+h+g},doDecrypt:function(t,e,i=1,{output:n="string"}={}){e=new It(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=vt.hexToArray(r),a=vt.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=vt.hexToArray(vt.leftPad(a.getX().toBigInteger().toRadix(16),64)),h=vt.hexToArray(vt.leftPad(a.getY().toBigInteger().toRadix(16),64));let u=1,l=0,p=[];const f=[].concat(c,h),d=()=>{p=Rt([...f,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,l=0};d();for(let t=0,e=s.length;t<e;t++)l===p.length&&d(),s[t]^=255&p[l++];return vt.arrayToHex(Rt([].concat(c,s,h)))===o.toLowerCase()?"array"===n?s:vt.arrayToUtf8(s):"array"===n?[]:""},doSignature:function(t,e,{pointPool:i,der:n,hash:o,publicKey:r,userId:s}={}){let a="string"==typeof t?vt.utf8ToHex(t):vt.arrayToHex(t);o&&(r=r||function(t){const e=Mt.multiply(new It(t,16)),i=vt.leftPad(e.getX().toBigInteger().toString(16),64),n=vt.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+i+n}(e),a=Pt(a,r,s));const c=new It(e,16),h=new It(a,16);let u=null,l=null,p=null;do{do{let t;t=i&&i.length?i.pop():Lt(),u=t.k,l=h.add(t.x1).mod(Gt)}while(l.equals(It.ZERO)||l.add(u).equals(Gt));p=c.add(It.ONE).modInverse(Gt).multiply(u.subtract(l.multiply(c))).mod(Gt)}while(p.equals(It.ZERO));return n?xt(l,p):vt.leftPad(l.toString(16),64)+vt.leftPad(p.toString(16),64)},doVerifySignature:function(t,e,i,{der:n,hash:o,userId:r}={}){let s,a,c="string"==typeof t?vt.utf8ToHex(t):vt.arrayToHex(t);if(o&&(c=Pt(c,i,r)),n){const t=Ot(e);s=t.r,a=t.s}else s=new It(e.substring(0,64),16),a=new It(e.substring(64),16);const h=Bt.decodePointHex(i),u=new It(c,16),l=s.add(a).mod(Gt);if(l.equals(It.ZERO))return!1;const p=Mt.multiply(a).add(h.multiply(l)),f=u.add(p.getX().toBigInteger()).mod(Gt);return s.equals(f)},getPoint:Lt,verifyPublicKey:vt.verifyPublicKey};const{sm3:Ft,hmac:Ut}=Ct;function qt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function zt(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 Vt=16,Ht=[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],Kt=[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 jt(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 Jt(t,e){return t<<e|t>>>32-e}function Wt(t){return(255&Ht[t>>>24&255])<<24|(255&Ht[t>>>16&255])<<16|(255&Ht[t>>>8&255])<<8|255&Ht[255&t]}function Xt(t){return t^Jt(t,2)^Jt(t,10)^Jt(t,18)^Jt(t,24)}function $t(t){return t^Jt(t,13)^Jt(t,23)}function Zt(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]^=Xt(Wt(t)),t=n[2]^n[3]^n[0]^i[e+1],n[1]^=Xt(Wt(t)),t=n[3]^n[0]^n[1]^i[e+2],n[2]^=Xt(Wt(t)),t=n[0]^n[1]^n[2]^i[e+3],n[3]^=Xt(Wt(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 Yt(t,e,i,{padding:n="pkcs#7",mode:o,iv:r=[],output:s="string"}={}){if("cbc"===o&&("string"==typeof r&&(r=jt(r)),16!==r.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=jt(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):jt(t):[...t],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const e=Vt-t.length%Vt;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]^Kt[i+0],e[i+0]=n[0]^=$t(Wt(t)),t=n[2]^n[3]^n[0]^Kt[i+1],e[i+1]=n[1]^=$t(Wt(t)),t=n[3]^n[0]^n[1]^Kt[i+2],e[i+2]=n[2]^=$t(Wt(t)),t=n[0]^n[1]^n[2]^Kt[i+3],e[i+3]=n[3]^=$t(Wt(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,u=t.length,l=0;for(;u>=Vt;){const e=t.slice(l,l+16),n=new Array(16);if("cbc"===o)for(let t=0;t<Vt;t++)0!==i&&(e[t]^=h[t]);Zt(e,n,a);for(let t=0;t<Vt;t++)"cbc"===o&&0===i&&(n[t]^=h[t]),c[l+t]=n[t];"cbc"===o&&(h=0!==i?n:e),u-=Vt,l+=Vt}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 Qt={sm2:Nt,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?zt(i):Array.prototype.slice.call(i),qt(Ut(t,i))}return qt(Ft(t))},sm4:{encrypt:(t,e,i)=>Yt(t,e,1,i),decrypt:(t,e,i)=>Yt(t,e,0,i)}}.sm2;var te,ee=function(){function e(t){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.adapters={},this.sdkReady=!1,this.name=t,this.hook=new o,this.logger=new F(t),this.remotePlugin=new Map,this.Types=M}return 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})},e.prototype.init=function(t){var i,n=this;this.inited?console.log("init can be call only one time"):t&&r(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 F(this.name,t.log),this.configManager=new N(this,t),this.appBridge=new U(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.requestManager=new J(this,t),this.initConfig=t,this.env=t.channel_domain?"self":"public",this.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new q,this.tokenManager=new j,this.sessionManager=new K,Promise.all([new Promise(function(t){n.once(M.TokenComplete,function(){t(!0)})}),new Promise(function(t){n.once(M.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,o=e.options,r=Object.assign(n.initConfig,o),s=new i;return s.apply(n,r),t.push(s),t},n.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.sdkReady=!0,n.emit(M.Ready),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:n.configManager.get("user")}),n.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(n.configManager.get("user"))),n.logger.info("appid: "+t.app_id+", sdk is ready, version is "+x+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.pageView(),n.on(M.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||n.pageView(),n.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})}),n.on(M.TokenReset,function(){n.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})}),n.on(M.RouteChange,function(e){e.init||t.disable_route_report||n.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(M.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")},e.prototype.config=function(e){if(this.inited)if(e&&r(e))if(this.bridgeReport)this.appBridge.setConfig(e);else{e._staging_flag&&1===e._staging_flag&&(this.staging=!0),e.disable_auto_pv&&(this.disableAutoPageView=!0,delete e.disable_auto_pv);var i=t({},e);if(this.initConfig&&this.initConfig.configPersist){var n=this.configManager.getStore();n&&(i=Object.assign(n,e)),this.configManager.setStore(e)}i.web_id,i.user_unique_id;var o=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(i[n[o]]=t[n[o]])}return i}(i,["web_id","user_unique_id"]);i.hasOwnProperty("web_id")&&this.emit(M.ConfigWebId,i.web_id),i.hasOwnProperty("user_unique_id")&&this.emit(M.ConfigUuid,i.user_unique_id),this.configManager.set(o),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:i})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},e.prototype.setDomain=function(t){this.configManager&&this.configManager.setDomain(t),this.emit(M.ConfigDomain)},e.prototype.getConfig=function(t){return this.configManager.get(t)},e.prototype.send=function(){this.start()},e.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(M.Start),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(M.Ready)))},e.prototype.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(M.Event,n),this.emit(M.SessionResetTime))}catch(t){this.logger.warn("something error, please check"),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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(M.BeconEvent,i),this.emit(M.SessionResetTime)))}},e.prototype.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=e;"object"!=typeof n&&(n={}),n.profile?delete n.profile:n.event_index=a();var o=void 0;return n.local_ms?(o=n.local_ms,delete n.local_ms):o=+new Date,{event:i,params:n,local_time_ms:o,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(i){return this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:i.message}),{event:t,params:e}}},e.prototype.dynamicParams=function(t){this.dynamicParamsFilter=t},e.prototype.filterEvent=function(t){this.eventFilter=t},e.prototype.on=function(t,e){this.hook.on(t,e)},e.prototype.once=function(t,e){this.hook.once(t,e)},e.prototype.off=function(t,e){this.hook.off(t,e)},e.prototype.emit=function(t,e,i){this.hook.emit(t,e,i)},e.prototype.set=function(t){this.hook.set(t)},e.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},e.prototype.predefinePageView=function(e){if(void 0===e&&(e={}),this.inited){var i={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)},n=t({},i,e);this.event("predefine_pageview",n)}else console.warn("predefinePageView should call after init")},e.prototype.clearEventCache=function(){this.emit(M.CleanEvents)},e.prototype.setWebIDviaUnionID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(M.CustomWebId)}},e.prototype.setWebIDviaOpenID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(M.CustomWebId)}},e.prototype.setAnonymousId=function(t){this.emit(M.AnonymousId,t)},e.prototype.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},e.prototype.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},e.prototype.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},e.prototype.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(M.ResetStay,{url_path:t,title:e,url:i},M.Stay)},e.prototype.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(M.SetStay,{url_path:t,title:e,url:i},M.Stay)},e.prototype.getToken=function(e,i){var n=this;if(this.inited){var o=!1,r=function(i){if(!o){o=!0;var r=n.configManager.get().user;return i&&(r.tobid=i,r["diss".split("").reverse().join("")]=i),e(t({},r))}},s=function(){n.tokenManager.getTobId().then(function(t){r(t)})};this.sdkReady?s():(i&&setTimeout(function(){r()},i),this.on(M.Ready,function(){s()}))}else this.logger.warn("getToken must be use after function init")},e.prototype.startTrackEvent=function(t){t&&this.emit(M.TrackDurationStart,t,M.TrackDuration)},e.prototype.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(M.TrackDurationEnd,{eventName:t,params:e},M.TrackDuration)},e.prototype.pauseTrackEvent=function(t){t&&this.emit(M.TrackDurationPause,t,M.TrackDuration)},e.prototype.resumeTrackEvent=function(t){t&&this.emit(M.TrackDurationResume,t,M.TrackDuration)},e.prototype.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(M.ProfileSet,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:t})},e.prototype.profileSetOnce=function(t){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(t)):this.emit(M.ProfileSetOnce,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:t})},e.prototype.profileIncrement=function(t){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(t)):this.emit(M.ProfileIncrement,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:t})},e.prototype.profileUnset=function(t){this.bridgeReport?this.appBridge.profileUnset(t):this.emit(M.ProfileUnset,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:t})},e.prototype.profileAppend=function(t){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(t)):this.emit(M.ProfileAppend,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:t})},e.prototype.setExternalAbVersion=function(t){this.bridgeReport?this.appBridge.setExternalAbVersion(t):this.emit(M.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,M.Ab)},e.prototype.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(M.AbVar,{name:t,defaultValue:e,callback:i},M.Ab)},e.prototype.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(M.AbAllVars,t,M.Ab)},e.prototype.getABconfig=function(t,e){this.emit(M.AbConfig,{params:t,callback:e},M.Ab)},e.prototype.getAbSdkVersion=function(t){if(!this.bridgeReport||!t)return this.configManager.getAbVersion()||"";this.appBridge.getAbSdkVersion(t)},e.prototype.onAbSdkVersionChange=function(t){var e=this;return this.emit(M.AbVersionChangeOn,t,M.Ab),function(){e.emit(M.AbVersionChangeOff,t,M.Ab)}},e.prototype.offAbSdkVersionChange=function(t){this.emit(M.AbVersionChangeOff,t,M.Ab)},e.prototype.openOverlayer=function(){this.emit(M.AbOpenLayer,"",M.Ab)},e.prototype.closeOverlayer=function(){this.emit(M.AbCloseLayer,"",M.Ab)},e.prototype.initCrypto=function(){this.publicKey=this.initConfig.crypto_publicKey||"04BA9E229380DC0E41E10839B0C52A4763D3EDFE8903F3B8E81395523381E03AA995D295BD4A4088792E4785B224F7837EB4D2C7C05973C7AE8687A35ACAE470A0"},e.prototype.cryptoData=function(t){try{if(!this.initConfig.enable_encryption)return t;var e=void 0;if("sm"===this.initConfig.encryption_type){var i=(r=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+Qt.doEncrypt(r,s,a)),n=d(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},e.prototype.destoryInstance=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(M.TokenComplete))},e.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(M.TokenComplete))},e.plugins=[],e}(),ie="__rangers_ab_style__";!function(t){t[t.Var=0]="Var",t[t.All=1]="All"}(te||(te={}));var ne=2592e6,oe=function(){function e(){this.fetchStatus="no",this.refreshFetchStatus="complete",this.versions=[],this.extVersions=[],this.mulilinkVersions=[],this.enable_multilink=!1,this.enable_ab_visual=!1,this.editMode=!1,this.callbacks=[],this.data=null,this.changeListener=new Map,this.readyStatus=!1,this.exposureCache=[]}return e.prototype.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,s=e.ab_cross,a=e.ab_cookie_domain,h=e.disable_ab_reset,u=o||c(O[e.channel||"cn"]);this.cacheStorgae=new C,this.enable_multilink=n,this.enable_ab_visual=r,this.abKey="__tea_sdk_ab_version_"+e.app_id,this.ab_cross=s,this.ab_cookie_domain=a||"",this.fetchUrl=u+"/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 l=this.collect.Types;this.types=l,this.collect.on(l.TokenChange,function(t){h||"uuid"===t.type&&i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(l.TokenReset,function(){h||i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(l.AbVar,function(t){var e=t.name,n=t.defaultValue,o=t.callback;i.getVar(e,n,o)}),this.collect.on(l.AbAllVars,function(t){i.getAllVars(t)}),this.collect.on(l.AbConfig,function(t){var e=t.params,n=t.callback;i.getABconfig(e,n)}),this.collect.on(l.AbExternalVersion,function(t){i.setExternalAbVersion(t)}),this.collect.on(l.AbOpenLayer,function(){i.openOverlayer()}),this.collect.on(l.AbCloseLayer,function(){i.closeOverlayer()}),this.collect.on(l.AbVersionChangeOn,function(t){i.changeListener.set(t,t)}),this.collect.on(l.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(l.AbReady)}},e.prototype.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)}},e.prototype.loadMode=function(){},e.prototype.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(","))},e.prototype.checkFromUrl=function(){var t=p(window.location.href);return t&&t.vid?t.vid:""},e.prototype.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)})},e.prototype.configVersions=function(t){this.collect.configManager.setAbVersion(t)},e.prototype.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)},e.prototype.getRealVar=function(t,e){var i=t.name,n=t.defaultValue,o=t.callback,s=this.data;if(s){if(r(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,n),o(s[i].val),void this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 曝光了实验"+i,level:"info",time:Date.now(),data:s[i]})}this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getVar",level:"info",time:Date.now(),data:n}),o(n)}else o(n)},e.prototype.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)},e.prototype.getRealAllVars=function(t){(0,t.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getAllVars",level:"info",time:Date.now(),data:this.data})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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)},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:[e],code:200,status:"success"})}),this.exposureCache=[]},e.prototype.setExternalAbVersion=function(t){this.extVersions=[t],this.updateVersions()},e.prototype.getABconfig=function(t,e){var i=Object.keys(t);i&&i.length&&this.collect.configManager.set(t),this.fetchAB(e)},e.prototype.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)},e.prototype.set=function(t,e){this.ab_cross?this.cacheStorgae.setCookie(t,e,ne,this.ab_cookie_domain):this.cacheStorgae.setLocalItem(t,e),this.collect.configManager.setAbCache(e)},e.prototype.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>=ne?(this.cacheStorgae.removeLocalItem(this.abKey),null):t?e[t]:e},e.prototype.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)},e.prototype.setAbCache=function(t){var e=this.getABCache();e.data=this.data,e.uuid=t,e.timestamp=Date.now(),this.set(this.abKey,e)},e.prototype.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},e.prototype.openOverlayer=function(t){var e=this;if(function(){if(!document.getElementById(ie)){var t="body { opacity: 0 !important; }",e=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=ie,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)},e.prototype.closeOverlayer=function(){var t;(t=document.getElementById(ie))&&t.parentElement.removeChild(t)},e.prototype.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.destroyInstance)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.destroyInstance){var t=""+s;t=-1===t.indexOf("http")?"https://"+t:t;var e=l(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=[]},e.prototype.fetchAB=function(e){var i=this,n=this.collect.configManager.get(),o=n.header,r=n.user;this.config.enable_anonymousid&&delete r.web_id;var s=r.user_unique_id,a={header:t({aid:this.config.app_id},r||{},o||{},{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})},c=this.collect.cryptoData(a);this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:a,infoType:"sdk"}),this.collect.requestManager.useRequest({url:this.fetchUrl,data:c,success:function(t){i.fetchStatus="complete",i.refreshFetchStatus="complete";var n=t.data;"success"===t.message?(i.fetchComplete(n,s),e&&e(n)):(i.fetchComplete(null,s),e&&e(null)),i.collect.emit(i.types.AbComplete,n),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:n,infoType:"sdk"})},fail:function(){i.fetchStatus="complete",i.refreshFetchStatus="complete",i.fetchComplete(null,s),e&&e(null),i.collect.emit(i.types.AbTimeout),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})},e.prototype.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}(),re=function(){function e(t,e){this.maxDuration=432e5,this.aliveDTime=6e4,this.options={aliveName:"predefine_page_alive",params:{}},this.collect=t,this.config=e,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,r(e.enable_stay_duration)&&(this.options=Object.assign(this.options,e.enable_stay_duration))}return e.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},e.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},e.prototype.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},e.prototype.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},e.prototype.sendEvent=function(e,i){void 0===i&&(i=!1);var n=i?this.aliveDTime:Date.now()-this.sessionStartTime;n<0||n>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:n,is_support_visibility_change:u(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:e},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},e.prototype.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}},e.prototype.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval(function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)},1e3)},e.prototype.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},e.prototype.beforeunload=function(){document.hidden||this.sendEvent(!0)},e.prototype.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}(),se=function(){function e(t,e){var i=this;this.maxDuration=432e5,this.aliveDTime=6e4,this.options={closeName:"predefine_page_close",params:{}},this.visibilitychange=function(){"hidden"===document.visibilityState?i.activeEndTime=Date.now():"visible"===document.visibilityState&&(i.activeEndTime&&(i.totalTime+=i.activeEndTime-i.activeStartTime,i.activeTimes+=1),i.activeEndTime=void 0,i.activeStartTime=Date.now())},this.beforeunload=function(){if(i.totalTime+=(i.activeEndTime||Date.now())-i.activeStartTime,i.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:i.totalTime,page_title:document.title||location.pathname}))}catch(t){}}i.sendEventPageClose()},this.collect=t,this.config=e,this.maxDuration=e.maxDuration||864e5,this.pageStartTime=Date.now(),r(e.enable_stay_duration)&&(this.options=Object.assign(this.options,e.enable_stay_duration)),this.resetData()}return e.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},e.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},e.prototype.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()},e.prototype.disable=function(){this.disableCallback()},e.prototype.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)},e.prototype.sendEventPageClose=function(){var e=Date.now()-this.pageStartTime;this.totalTime<0||e<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:e,is_support_visibility_change:u()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},e.prototype.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}},e.prototype.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}(),ae=function(){function t(){}return t.prototype.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 re(t,e),this.pageClose=new se(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)}},t.prototype.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)}},t.prototype.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},t.prototype.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t.prototype.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},t.prototype.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t}(),ce=function(){function e(){}return e.prototype.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 R(t,e),this.cache={},this.collect.on(M.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(M.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(M.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(M.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(M.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(M.ProfileClear,function(){i.cache={}}),this.ready(M.Profile)},e.prototype.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)}},e.prototype.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(M.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:r}):i.collect.emit(M.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:r})},fail:function(t,e,n){i.collect.emit(M.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,endTime:Date.now()})}}),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"})}catch(t){this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.setProfile=function(e){var i=this.formatParams(e);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set",t({},i,{profile:!0})))},e.prototype.setOnceProfile=function(e){var i=this.formatParams(e,!0);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set_once",t({},i,{profile:!0})))},e.prototype.incrementProfile=function(e){e?this.report("__profile_increment",t({},e,{profile:!0})):console.warn("please check the params, must be object!!!")},e.prototype.unsetProfile=function(e){if(e){var i={};i[e]="1",this.report("__profile_unset",t({},i,{profile:!0}))}else console.warn("please check the key, must be string!!!")},e.prototype.appendProfile=function(e){if(e){var i={};for(var n in e)"string"==typeof e[n]||"Array"===Object.prototype.toString.call(e[n]).slice(8,-1)?i[n]=e[n]:console.warn("please check the value of param: "+n+", must be string or array !!!");Object.keys(i).length&&this.report("__profile_append",t({},i,{profile:!0}))}else console.warn("please check the params, must be object!!!")},e.prototype.pushCache=function(t){var e=this;Object.keys(t).forEach(function(i){e.cache[i]={val:e.clone(t[i]),timestamp:Date.now()}})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("error")}},e.prototype.compare=function(t,e){try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){return this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),!1}},e.prototype.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},e.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},e}(),he=function(){function t(){var t=this;this.setInterval=function(){t.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(){t.isSessionhasEvent&&t.endCurrentSession()},t.sessionInterval)},this.clearInterval=function(){t.clearIntervalFunc&&t.clearIntervalFunc()}}return t.prototype.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()})}},t.prototype.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},t.prototype.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())},t}();function ue(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&&ge(t,"ss"))return!0}return!1}var le=function(t,e){return!!ge(t,e)};function pe(t){for(var e=t;e&&!ue(e,"container");){if("HTML"===e.nodeName||"BODY"===e.nodeName)return t;e=e.parentElement}return e||t}function fe(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 de=function(t,e){return t.hasAttribute?t.hasAttribute(e):t.attributes?!(!t.attributes[e]||!t.attributes[e].specified):void 0},ge=function(t,e){if("string"==typeof e)return de(t,e);if(s(e)){for(var i=!1,n=0;n<e.length;n++){if(de(t,e[n])){i=!0;break}}return i}},me=function(t,e){var i={};if("string"==typeof e)de(t,e)&&(i[e]=t.getAttribute(e));else if(s(e))for(var n=0;n<e.length;n++){de(t,e[n])&&(i[e[n]]=t.getAttribute(e[n]))}return i};var ye=function(){function e(e,i,n){var o=this;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&&(ue(i,"container")||e.track_attr&&le(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)},this.changeEvent=function(t){o.eventHandel({eventType:"dom",eventName:"change"},t)},this.submitEvent=function(t){o.eventHandel({eventType:"dom",eventName:"submit"},t)},this.getPageViewEvent=function(e,i){i&&"pushState"===i&&o.eventHandel({eventType:"dom",eventName:"beat"},t({beat_type:0},e)),o.eventHandel({eventType:"dom",eventName:"page_view"},e)},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}return e.prototype.init=function(t){this.eventHandel=t;var e=this.config.mode;this.addListener(e)},e.prototype.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)}}},e.prototype.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},e.prototype.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)),h(function(){e.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),e.beatTime&&clearInterval(i)})}catch(t){}},e}(),ve={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},_e=function(){function t(t,e){this.config=t,this.config.eventConfig=Object.assign(this.config.eventConfig,e)}return t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){return this.config=t},t}();function be(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(),ue(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 Ee(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.clientX,n=t.clientY,o=e.left,r=e.top,s=i-o>=0?i-o:0,a=n-r>=0?n-r:0;return{touch_x:Math.floor(s),touch_y:Math.floor(a)}}(t,r),a=r.element_width,c=r.element_height,h=s.touch_x,u=s.touch_y,l=be(e),p=l.element_path,f=l.positions,d=function(t){var e=pe(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,y=f.map(function(t){return""+t}),v=null;if(window.TEAVisualEditor&&window.TEAVisualEditor.getOriginXpath&&(v=window.TEAVisualEditor.getOriginXpath({xpath:p,positions:y})),o.element_path=v&&v.xpath||p,o.positions=v&&v.positions||y,n&&!n.text&&(o.texts=d,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=u,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&&le(e,i.track_attr)){var _=me(e,i.track_attr);for(var b in _)o[b]=_[b]}if(i.custom_attr)try{if(le(e,i.custom_attr)){_=me(e,i.custom_attr),b=decodeURIComponent(_[i.custom_attr]);var E=JSON.parse(b);if(Object.keys(E))for(var S in E)o[S]=E[S]}}catch(t){console.log("custom attr error")}var w=pe(e);return"A"===w.tagName&&(o.href=w.getAttribute("href")),!1!==i.src&&("IMG"!==e.tagName||e.getAttribute("src").includes("base64")||(o.src=e.getAttribute("src"))),o}var Se,we=function(e,i,n,o,r){return t({event:e},Ee(i,n,o,r),{is_html:1,page_key:window.location.href,page_title:document.title})},Te=function(){function e(t,e){this.ignore={text:!1},this.initConfig=t,this.options=e,this.eventName=e&&"tea"===e.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"},e&&!1===e.text&&(this.ignore.text=!0),e&&e.exposure&&e.exposure.eventName&&(this.eventName.exposure=e.exposure.eventName)}return e.prototype.handleEvent=function(e,i){try{if(fe(e.target))return null;var n="bav2b_click";switch(i){case"click":return n=this.eventName.click,we(n,e,e.target,this.options,this.ignore);case"exposure":return n=this.eventName.exposure,we(n,e,e.target,this.options,this.ignore);case"change":return t({},we(n="bav2b_change",e,e.target,this.options),function(t,e){try{if("bav2b_change"===t)return e.hasAttribute("data-tea-track")?{value:e.value}:{}}catch(t){return{}}}(n,e.target));case"submit":return we(n="bav2b_submit",e,e.target,this.options)}}catch(t){return console.error(t),null}},e.prototype.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},e.prototype.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},e.prototype.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},e.prototype.handleExposureEvent=function(t,e){if(fe(e.target))return null;var i=we(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},e.prototype.handleScrollEvent=function(t,e){var i=we(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}(),ke=function(){function t(t){this.collect=t}return t.prototype.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)},t.prototype.get=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"GET"},e);fetch(t,i)},t.prototype.post=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"POST"},e);fetch(t,i)},t}(),De=function(){function t(t,e){this._instance=null,this._intersection=t,this.config=e,this._intersection&&this.init()}return t.prototype.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")},t.prototype.attributeChangeObserve=function(t){t.target.hasAttribute("data-exposure")?this.exposureAdd(t,"mutation"):this.exposureRemove(t)},t.prototype.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))})},t.prototype.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)})},t.prototype.exposureAdd=function(t,e){try{this._intersection&&this._intersection.exposureAdd(t,e)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},t.prototype.exposureRemove=function(t){try{this._intersection&&this._intersection.exposureRemove(t)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},t._exposure_observer=null,t}();!function(t){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"}(Se||(Se={}));var Ae,Ce=function(){function t(e,i,n){var o=this;this.backStatus=!1,this.instance=this.buildObserver(),this.collect=e,this.observeMap=t._observer_map,i.autotrack.exposure.ratio?this.ratio=i.autotrack.exposure.ratio:0===i.autotrack.exposure.ratio?this.ratio=0:this.ratio=.5,this.timeLimit=i.autotrack.exposure.stay||0,this.exposureType=Se.NOT_EXPOSURE,this.eventHandle=n,this.hashMap=new Map,this.backStatus=!1,this.lastState=null,this.collect.on("re-start-sdk",function(){o.visibilitychange()}),this.addListen()}return t.prototype.buildObserver=function(){var e=this;if(t._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{t._observer_instance=new IntersectionObserver(function(t){t.forEach(function(t){var i=t.target.observeId,n=e.observeMap.get(i),o=(t.target,t.isIntersecting,t.intersectionRatio);if(n.intersectionRatio=o,o<=.1&&(t.target.backStatus=!1),e.observeMap.set(i,n),o<e.ratio)return n.isIntersecting=!1,n.added=!1,n.exposured=!1,n.startTime=Date.now(),void e.observeMap.set(i,n);if(!n.added){if(n.startTime=Date.now(),n.added=!0,n.isIntersecting=!0,e.timeLimit){var r=setTimeout(function(){try{if(n.isIntersecting&&!n.exposured&&e.observeMap.get(i)){var o=e.observeMap.get(i).intersectionRatio;e.exposureEvent(t,o,i,n)}}catch(t){console.log("IntersectionObserver setTimeout error,msg: "+JSON.stringify(t))}},e.timeLimit);n.wait=r}e.observeMap.set(i,n)}Date.now()-n.startTime>=e.timeLimit&&!n.exposured&&e.exposureEvent(t,o,i,n)})},{threshold:i})}catch(t){console.log("IntersectionObserver error,msg: "+JSON.stringify(t))}return t._observer_instance}return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null},t.prototype.exposureAdd=function(t,e){var i="mutation"===e?t.target:t,n=i.observeId,o=V();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)},t.prototype.exposureRemove=function(t){this.observeMap.has(t.observeId)&&(this.observeMap.delete(t.observeId),this.unobserve(t),t.observeId="",t.visible=!1)},t.prototype.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)},t.prototype.observe=function(t){this.instance&&this.instance.observe(t)},t.prototype.unobserve=function(t){this.instance&&this.instance.unobserve(t)},t.prototype.getExposureDomToExposure=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t.handleBoundingExposure(e)})},t.prototype.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)},t.prototype.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||Se.RESUME_FORM_BACK},t)}},t.prototype.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},t.prototype.getExposureType=function(t){return t.visible?!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Se.RESUME_FORM_PAGE:this.exposureType=Se.LIFECYCLE_SHOW_NEW:(t.hasExposure,!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Se.RESUME_FORM_PAGE:this.exposureType=Se.EXPOSURE_ONCE),this.exposureType},t.prototype.addListen=function(){var t=this;this.collect.on("set-exposure-type",function(e){t.customType=e});var e,n,o,r,s=this.visibilitychange.bind(this);if(e=document,n="visibilitychange",o=s,r=!1,e.addEventListener?e.addEventListener(n,o,r):e.attachEven?e.attachEven("on"+n,o):e["on"+n]=o,window.addEventListener("hashchange",function(e){var i=t.hashMap.get(e.oldURL);i&&location.href===i.prev?(t.backStatus=!0,t.exposureType=Se.RESUME_FORM_PAGE):(t.backStatus=!1,t.hashMap.set(location.href,{current:e.newURL,prev:e.oldURL}))}),this.collect.bridgeReport){var a=window.history.pushState;history.pushState=function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"function"==typeof history.onpushstate&&history.onpushstate({state:e});var r=a.call.apply(a,i([history,e],n));return t.lastState=e,r};var c=history.replaceState;history.replaceState=function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});var r=c.call.apply(c,i([history,e],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=Se.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",s,!1)}},t._observer_instance=null,t._observer_map=new Map,t}(),Ie=function(){function t(t,e,i){e.autotrack&&e.autotrack.exposure&&(this._intersection=new Ce(t,e,i),this._observer=new De(this._intersection,e),this._intersection&&this._observer?this.initObserver():console.log("your browser version cannot support exposure event, please update~"))}return t.prototype.initObserver=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t._intersection.exposureAdd(e,"intersect")})},t}();!function(t){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"}(Ae||(Ae={}));var xe=function(){function t(t,e){this.distance=30,t.autotrack&&t.autotrack.scroll&&(t.autotrack.scroll.distance&&(this.distance=t.autotrack.scroll.distance),this.eventHandle=e,this.addLinstenr(),this.mutation())}return t.prototype.addLinstenr=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-scroll]"),function(e){t.scrollHandle(e)})},t.prototype.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")},t.prototype.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))})},t.prototype.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)})},t.prototype.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,l=t.scrollLeft,p=e.target&&e.target.getAttribute("data-scroll-event")||"";1===u||2===u?r===c&&(a=c-n,Math.abs(a)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:p,params:{$direction:u,$offsetY:a,$offsetX:s}},e)):3!==u&&4!==u||l===h&&(s=h-o,Math.abs(s)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:p,params:{$direction:u,$offsetY:a,$offsetX:s}},e)),n=c,o=h},100);var c=t.scrollTop,h=t.scrollLeft,u=Ae.NOT_SCROLL;c>n?u=Ae.SCROLL_DOWN:c<n?u=Ae.SCROLL_UP:h>o?u=Ae.SCROLL_LEFT:h<o&&(u=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))}},t}(),Oe={hashTag:!1,impr:!1},Re=function(){function t(){}return t.prototype.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)}},t.prototype.ready=function(t){this.collect.set(t);var e=this.config.autotrack;e="object"==typeof e?e:{},e=Object.assign(Oe,e),this.destroyed=!1,this.options=e,this.Config=new _e(ve,this.options),this.Exposure=new Ie(this.collect,this.config,this.handle.bind(this)),this.Scroll=new xe(this.config,this.handle.bind(this)),this.Listener=new ye(e,this.collect,this.Config),this.EventHandle=new Te(this.config,e),this.Request=new ke(this.collect),this.autoTrackStart=!0,this.init()},t.prototype.init=function(){this.Listener.init(this.handle.bind(this))},t.prototype.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)},t.prototype.handleDom=function(t,e){try{var i=t.eventName;if("click"===i||"change"===i||"submit"===i)(s=this.EventHandle.handleEvent(e,i))&&this.Request.send({eventType:"custom"},s);else if("page_view"===i||"page_statistics"===i){var n=void 0;(n="page_view"===i?this.EventHandle.handleViewEvent(e):this.EventHandle.handleStatisticsEvent(e))&&this.Request.send({eventType:"custom"},n)}else if("beat"===i){var o=this.EventHandle.handleBeadtEvent(e),r=t.eventSend;o&&this.Request.send({eventType:"custom",eventSend:r},o)}else if("exposure"===i){(s=this.EventHandle.handleExposureEvent(t,e))&&this.Request.send({eventType:"custom"},s)}else if("scroll"===i){var s;(s=this.EventHandle.handleScrollEvent(t,e))&&this.Request.send({eventType:"custom"},s)}}catch(t){console.log("handel dom event error "+JSON.stringify(t))}},t.prototype.destroy=function(){if(!this.autoTrackStart)return console.warn("engine is undefined, make sure you have called autoTrack.start()");this.autoTrackStart=!1,this.Listener.removeListener()},t}(),Me=function(){function t(){this.autotrack=!1,this.spa=!1,this.cache={},this.allowHash=!1}return t.prototype.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)}},t.prototype.setKey=function(){this.storage=new C,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)},t.prototype.hack=function(){var t=this,e=window.history.pushState;history.pushState=function(n){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];"function"==typeof history.onpushstate&&history.onpushstate({state:n});var s=e.call.apply(e,i([history,n],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 n=history.replaceState;history.replaceState=function(e){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});var s=n.call.apply(n,i([history,e],o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a),s}}},t.prototype.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},t.prototype.getLocation=function(){return this.lastLocation},t.prototype.init=function(){var t=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:t,init:!0})},t.prototype.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))})},t.prototype.getPopStateChangeEventData=function(){var t=this.pageConfig();return t.is_back=0,t},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),{}}},t.prototype.sendPv=function(t,e){this.collect.emit("route-change",{config:t,init:!1})},t.prototype.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},t.prototype.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)},t}(),Be=500,Ge=5005;var Pe=function(){function t(){this.verifyReady=!1,this.cleanStatus=!1}return t.prototype.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()},t.prototype.checkUrl=function(){var t=window.location.href,e=p(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")},t.prototype.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},t.prototype.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)},t.prototype.eventStore=function(t){this.cleanStatus||(this.verifyReady?this.postVerify(t):this.eventStorage.push(t))},t.prototype.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},t.prototype.postVerify=function(t){var e=this;try{var i=JSON.parse(JSON.stringify(t));s(t)?i.forEach(function(t){e.fetchLog(t)}):this.fetchLog(i)}catch(t){console.log("web verify post error ~")}},t.prototype.fetchLog=function(t){!function(t,e,i,n,o,r,s,a,c,h){try{var u=new XMLHttpRequest,l=a||"POST";u.open(l,""+t,!0),c&&h?u.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):u.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&u.setRequestHeader("X-MCS-AppKey",""+s),n&&(u.withCredentials=!0),i&&(u.timeout=i,u.ontimeout=function(){r&&r(e,Ge)}),u.onload=function(){if(o){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}o(t,e)}}},u.onerror=function(){u.abort(),r&&r(e,Be)},c?u.send(e):u.send(JSON.stringify(e))}catch(t){}}(this.domain+"/simulator/h5/log?connection_key="+this.key,t,2e4,!1)},t.prototype.leave=function(){var t=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.cleanVerify()}),h(function(){t.cleanVerify()})},t}(),Le=function(){function t(){this.retryWaitTime=3e3,this.retryStatus=!1,this.retryCacheStatus=!1}return t.prototype.apply=function(t,e){var i=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroyInstance)){var n=t.Types,o=t.adapters.storage;this.storage=new o(!1),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()})}},t.prototype.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)}},t.prototype.storeData=function(t){var e=this.storage.getItem(this.eventKey),i=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=i,this.storage.setItem(this.eventKey,e))},t.prototype.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getItem(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.setItem(t.eventKey,i)},function(){},!1)};for(var o in e)n(o)},function(){},!0)}catch(t){console.warn("error check storage")}},t.prototype.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":""})},t}(),Ne=function(){function t(){}return t.prototype.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)},t.prototype.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)}},t.prototype.trackStart=function(t){this.TrackMap.set(t,{startTime:Date.now(),isPause:!1,pauseTime:0,resumeTime:0})},t.prototype.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)}},t.prototype.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))}},t.prototype.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))}},t.prototype.cleanTrack=function(t){this.TrackMap.delete(t)},t}();ee.usePlugin(oe,"ab"),ee.usePlugin(ae,"stay"),ee.usePlugin(Le,"store"),ee.usePlugin(Re,"autotrack"),ee.usePlugin(Ne,"trackDuration"),ee.usePlugin(Pe,"verify"),ee.usePlugin(ce,"profile"),ee.usePlugin(he,"heartbeat"),ee.usePlugin(Me,"route");var Fe=new ee("default"),Ue=ee;exports.Collector=Ue,exports.default=Fe;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){return t=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,o,r=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=r.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return s}function i(){for(var t=[],i=0;i<arguments.length;i++)t=t.concat(e(arguments[i]));return t}var n,o=function(){function t(){this._hooks={},this._cache=[],this._hooksCache={}}return t.prototype.on=function(t,e){t&&e&&"function"==typeof e&&(this._hooks[t]||(this._hooks[t]=[]),this._hooks[t].push(e))},t.prototype.once=function(t,e){var i=this;if(t&&e&&"function"==typeof e){this.on(t,function n(o){e(o),i.off(t,n)})}},t.prototype.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]=[]},t.prototype.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)},t.prototype._emit=function(t,e){t&&this._hooks[t]&&this._hooks[t].length&&i(this._hooks[t]).forEach(function(t){try{t(e)}catch(t){}})},t.prototype.set=function(t){t&&-1===this._cache.indexOf(t)&&this._cache.push(t)},t}(),r=function(t){return null!=t&&"[object Object]"==Object.prototype.toString.call(t)},s=function(t){return Array.isArray(t)},a=(n=+Date.now()+Number((""+Math.random()).slice(2,8)),function(){return n+=1}),c=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)},h=function(t){!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)?window.addEventListener("pagehide",t,!1):window.addEventListener("beforeunload",t,!1)},u=function(){var t=0;return["hidden","msHidden","webkitHidden"].forEach(function(e){void 0!==document[e]&&(t=1)}),t},l=function(t){var e=document.createElement("a");return e.href=t,e},p=function(t){var e={};try{var i=l(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},f=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 d=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},g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t,e){return t(e={exports:{}},e.exports),e.exports}var y=m(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 t(){this.cache={}}return t.prototype.setItem=function(t,e){this.cache[t]=e},t.prototype.getItem=function(t){return this.cache[t]},t.prototype.removeItem=function(t){this.cache[t]=void 0},t.prototype.getCookie=function(t){this.getItem(t)},t.prototype.setCookie=function(t,e){this.setItem(t,e)},t}();var _,b,E={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{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{localStorage.removeItem(t)}catch(t){}},getCookie:function(t,e){try{return y.get(t)}catch(t){return""}},setCookie:function(t,e,i,n){try{var o=n||document.domain,r=+new Date+i;y.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},isSupportLS:function(){try{return localStorage.setItem("_ranger-test-key","hi"),localStorage.getItem("_ranger-test-key"),localStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},S={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{}},setItem:function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},removeItem:function(t){try{sessionStorage.removeItem(t)}catch(t){}},getCookie:function(t){this.getItem(t)},setCookie:function(t,e){this.setItem(t,e)},isSupportSession:function(){try{return sessionStorage.setItem("_ranger-test-key","hi"),sessionStorage.getItem("_ranger-test-key"),sessionStorage.removeItem("_ranger-test-key"),!0}catch(t){return!1}}()},w=function(){function t(t,e){this._storage=e&&"session"===e?S:!t&&E.isSupportLS?E:new v}return t.prototype.getItem=function(t){return this._storage.getItem(t)},t.prototype.setItem=function(t,e){this._storage.setItem(t,e)},t.prototype.getCookie=function(t,e){return this._storage.getCookie(t,e)},t.prototype.setCookie=function(t,e,i,n){this._storage.setCookie(t,e,i,n)},t.prototype.removeItem=function(t){this._storage.removeItem(t)},t}(),T=function(){function t(t,e,i){this.appid=t,this.domain=e,this.userAgent=window.navigator.userAgent,this.appVersion=window.navigator.appVersion,this.cookie_expire=i}return t.prototype.init=function(){var t=window.navigator.userAgent,e=window.navigator.language,i=document.referrer,n=i?l(i).hostname:"",o=p(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 w(!1),r=new w(!1,"session"),s=t?"_tea_utm_cache_"+t:"_tea_utm_cache",a=t?"_$utm_from_url_"+t:"_$utm_from_url",c={},h=["tr_shareuser","tr_admaster","tr_param1","tr_param2","tr_param3","tr_param4","$utm_from_url"],u={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 p in u)u[p]&&(-1!==h.indexOf(p)?(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data[p]=u[p]):c[p]=u[p],l=!0);if(l)r.setItem(a,"1"),o.setCookie(s,JSON.stringify(c),n,i);else{var f=o.getCookie(s,i);f&&(c=JSON.parse(f))}r.getItem(a)&&(c.hasOwnProperty("tracer_data")||(c.tracer_data={}),c.tracer_data.$utm_from_url=1)}catch(t){return u}return c}(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)}},t.prototype.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=p(t);a.keyword&&(o=a.keyword)}return{$latest_referrer:i,$latest_referrer_host:n,$latest_search_keyword:o,isLast:s}},t.prototype.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}},t.prototype.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}},t.prototype.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()},t.prototype.isNewIpad=function(){return void 0!==this.userAgent&&"MacIntel"===navigator.platform&&"number"==typeof navigator.maxTouchPoints&&navigator.maxTouchPoints>1},t}(),k=function(){function t(){this.cache={}}return t.prototype.setItem=function(t,e){this.cache[t]=e},t.prototype.getItem=function(t){return this.cache[t]},t.prototype.removeItem=function(t){this.cache[t]=void 0},t}(),D=function(){function t(){this.support=this.isSupportLS()}return t.prototype.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}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);localStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{localStorage.removeItem(t)}catch(t){}},t}(),A=function(){function t(){this.support=this.isSupportSession()}return t.prototype.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}},t.prototype.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{}},t.prototype.setItem=function(t,e){try{var i="string"==typeof e?e:JSON.stringify(e);sessionStorage.setItem(t,i)}catch(t){}},t.prototype.removeItem=function(t){try{sessionStorage.removeItem(t)}catch(t){}},t}(),C=function(){function t(){this.defaultExpireTime=6048e5,this.local=new D,this.session=new A,this.cache=new k}return t.prototype.getLocalItem=function(t){return this.local.getItem(t)},t.prototype.setLocalItem=function(t,e){this.local.setItem(t,e)},t.prototype.removeLocalItem=function(t){this.local.removeItem(t)},t.prototype.getSessionItem=function(t){return this.session.getItem(t)},t.prototype.setSessionItem=function(t,e){this.session.setItem(t,e)},t.prototype.removeSessionItem=function(t){this.session.removeItem(t)},t.prototype.getCacheItem=function(t){return this.cache.getItem(t)},t.prototype.setCacheItem=function(t,e){this.cache.setItem(t,e)},t.prototype.removeCacheItem=function(t){this.cache.removeItem(t)},t.prototype.getCookie=function(t,e){try{return y.get(t)}catch(t){return""}},t.prototype.setCookie=function(t,e,i,n){void 0===i&&(i=this.defaultExpireTime);try{var o=n||document.domain,r=+new Date+i;y.set(t,e,{expires:new Date(r),path:"/",domain:o})}catch(t){}},t.prototype.removeCookie=function(t,e){try{y.remove(t,{path:"/",domain:e||""})}catch(t){}},t}(),I={cn:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},x="0.1.2",O={cn:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",va:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k",sg:"1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k"},R=function(){function t(t,e){this.collector=t,this.config=e,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}$")}return t.prototype.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},t.prototype.checkEventName=function(t){return!!t&&this.calculate(t,"event")},t.prototype.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},t.prototype.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))},t}();!function(t){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"}(_||(_={})),function(t){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"}(b||(b={}));var M=_,B=void 0,G=(new Date).getTimezoneOffset(),P=parseInt(""+-G/60,10),L=60*G,N=function(){function e(t,e){this.is_first_time=!0,this.configPersist=!1,this.enableClientTransport=!1,this.initConfig=e,this.collect=t;var i=new T(e.app_id,e.cookie_domain||"",e.cookie_expire||7776e6).init();this.eventCheck=new R(t,e);var n="__tea_cache_first_"+e.app_id;this.configKey="__tea_cache_config_"+e.app_id,this.storage=new C,e.configPersist&&(this.configPersist=!0,this.storage=1===e.configPersist?this.sessionStorage:this.localStorage);var o=this.storage.getLocalItem(n);o&&1==o?this.is_first_time=!1:(this.is_first_time=!0,this.storage.setLocalItem(n,"1")),this.envInfo={user:{user_unique_id:B,user_type:B,user_id:B,user_is_auth:B,user_is_login:B,device_id:B,web_id:B,ip_addr_id:B,user_unique_id_type:B,anonymous_id:B},header:{app_id:B,app_name:B,app_install_id:B,install_id:B,app_package:B,app_channel:B,app_version:B,ab_version:B,os_name:i.os_name,os_version:i.os_version,device_model:i.device_model,ab_client:B,traffic_type:B,client_ip:B,device_brand:B,os_api:B,access:B,language:i.language,region:B,app_language:B,app_region:B,creative_id:i.utm.creative_id,ad_id:i.utm.ad_id,campaign_id:i.utm.campaign_id,log_type:B,rnd:B,platform:i.platform,sdk_version:x,sdk_lib:"js",province:B,city:B,timezone:P,tz_offset:L,tz_name:B,sim_region:B,carrier:B,resolution:i.screen_width+"x"+i.screen_height,browser:i.browser,browser_version:i.browser_version,referrer:i.referrer,referrer_host:i.referrer_host,width:i.screen_width,height:i.screen_height,screen_width:i.screen_width,screen_height:i.screen_height,utm_term:i.utm.utm_term,utm_content:i.utm.utm_content,utm_source:i.utm.utm_source,utm_medium:i.utm.utm_medium,utm_campaign:i.utm.utm_campaign,tracer_data:JSON.stringify(i.utm.tracer_data),custom:{},wechat_unionid:B,wechat_openid:B}},this.ab_version="",this.evtParams={},this.reportErrorCallback=function(){},this.isLast=!1,this.setCustom(i),this.initDomain(),this.initABData(),this.setEnableClientTransport(!!this.initConfig.transport)}return e.prototype.initDomain=function(){var t=this.initConfig.channel_domain;if(t)this.domain=t;else{var e=this.initConfig.channel;this.domain=c(I[e])}},e.prototype.setDomain=function(t){this.domain=t},e.prototype.getDomain=function(){return this.domain},e.prototype.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)},e.prototype.setAbCache=function(t){this.ab_cache=t},e.prototype.getAbCache=function(){return this.ab_cache},e.prototype.clearAbCache=function(){this.ab_cache={},this.ab_version=""},e.prototype.setAbVersion=function(t){this.ab_version=t},e.prototype.getAbVersion=function(){return this.ab_version},e.prototype.setEnableClientTransport=function(t){this.enableClientTransport=t},e.prototype.getEnableClientTransport=function(){return this.enableClientTransport},e.prototype.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.2&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},e.prototype.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]},e.prototype.set=function(e){var i=this;Object.keys(e).forEach(function(n){void 0!==e[n]&&null!==e[n]||i.delete(n);try{i.eventCheck.calculate(n,"config")}catch(t){}if("traffic_type"===n&&i.isLast&&(i.envInfo.header.custom.$latest_traffic_source_type=e[n]),"evtParams"===n)i.evtParams=t({},i.evtParams||{},e.evtParams||{});else if("_staging_flag"===n)i.evtParams=t({},i.evtParams||{},{_staging_flag:e._staging_flag});else if("reportErrorCallback"===n&&"function"==typeof e[n])i.reportErrorCallback=e[n];else{var o="",r="";if(n.indexOf(".")>-1){var s=n.split(".");o=s[0],r=s[1]}o?"user"===o||"header"===o?i.envInfo[o][r]=e[n]:i.envInfo.header.custom[r]=e[n]:Object.hasOwnProperty.call(i.envInfo.user,n)?["user_type","ip_addr_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?Number(e[n]):e[n]:["user_id","web_id","user_unique_id","user_unique_id_type","anonymous_id"].indexOf(n)>-1?i.envInfo.user[n]=e[n]?String(e[n]):e[n]:["user_is_auth","user_is_login"].indexOf(n)>-1?i.envInfo.user[n]=Boolean(e[n]):"device_id"===n&&(i.envInfo.user[n]=e[n]):Object.hasOwnProperty.call(i.envInfo.header,n)?i.envInfo.header[n]=e[n]:i.envInfo.header.custom[n]=e[n]}})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.getItem=function(t){return this.initConfig&&1===this.initConfig.configPersist?this.storage.getSessionItem(t):this.storage.getLocalItem(t)},e.prototype.setItem=function(t,e){this.initConfig&&1===this.initConfig.configPersist?this.storage.setSessionItem(t,e):this.storage.setLocalItem(t,e)},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),null}},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e}(),F=function(){function t(t,e){this.isLog=e||!1,this.name=t||""}return t.prototype.info=function(t){this.isLog&&console.log("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.warn=function(t){this.isLog&&console.warn("%c %s","color: yellow; background-color: black;","[instance: "+this.name+"] "+t)},t.prototype.error=function(t){this.isLog&&console.error("[instance: "+this.name+"] "+t)},t.prototype.throw=function(t){throw this.error(this.name),new Error(t)},t}(),U=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}(),q=function(){function e(){this.eventLimit=50,this.eventCache=[],this.beconEventCache=[]}return e.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=t.configManager,this.storgae=new C,this.eventCheck=new R(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(M.Ready,function(){i.reportAll(!1)}),this.collect.on(M.ConfigDomain,function(){i.reportUrl=i.configManager.getUrl("event")}),this.collect.on(M.Event,function(t){i.event(t)}),this.collect.on(M.BeconEvent,function(t){i.beconEvent(t)}),this.collect.on(M.CleanEvents,function(){i.reportAll(!1)}),this.linster()},e.prototype.linster=function(){var t=this;window.addEventListener("unload",function(){t.reportAll(!0)},!1),h(function(){t.reportAll(!0)}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.reportAll(!0)},!1)},e.prototype.reportAll=function(t){this.report(t),this.reportBecon()},e.prototype.event=function(t){var e=this;try{var n=i(t,this.storgae.getCacheItem(this.eventKey)||[]);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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.beconEvent=function(t){var e=i(t,this.storgae.getCacheItem(this.beconKey)||[]);this.storgae.setCacheItem(this.beconKey,e),this.collect.destroyInstance||this.collect.tokenManager.getReady()&&this.collect.sdkReady&&(this.storgae.removeCacheItem(this.beconKey),this.send(this.split(this.merge(e)),!0))},e.prototype.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))},e.prototype.report=function(t){if(!this.collect.destroyInstance&&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))}},e.prototype.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{o=this.split(this.merge(t));this.send(o,e)}},e.prototype.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},e.prototype.merge=function(e,i){var n=this,o=this.configManager.get(),r=o.header,s=o.user;r.referrer=this.handleRefer(),r.custom=JSON.stringify(r.custom);var a=this.configManager.get("evtParams"),c=this.configManager.get("user_unique_id_type"),h=e.map(function(e){try{if(Object.keys(a).length&&!i&&(e.params=t({},e.params,a)),n.collect.dynamicParamsFilter){var o=n.collect.dynamicParamsFilter();Object.keys(o).length&&(e.params=t({},e.params,o))}c&&(e.params.$user_unique_id_type=c);var r=n.configManager.getAbCache(),h=n.configManager.getAbVersion();return h&&r&&(n.config.disable_ab_reset||r.uuid===s.user_unique_id)&&(e.ab_sdk_version=h),e.session_id=n.collect.sessionManager.getSessionId(),e.params=JSON.stringify(e.params),e}catch(t){return n.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),e}}),u=[];if(!Object.keys(s).length)return console.warn("user info error,cant report"),u;this.config.enable_anonymousid&&delete s.web_id;var l=JSON.parse(JSON.stringify({events:h,user:s,header:r}));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,u.push(l),u},e.prototype.split=function(t){return t=t.map(function(t){var e=[];return e.push(t),e})},e.prototype.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(M.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(M.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报失败",time:Date.now(),data:r,code:t.e,failType:"数据异常失败",status:"fail"})):(i.collect.emit(M.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:s}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,errorMessage:o,endTime:Date.now()}),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.SubmitVerifyH,o),i.collect.emit(M.SubmitAfter,o)}catch(t){console.warn("something error, "+JSON.stringify(t.stack)),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}})},e}(),z=function t(e){return e?(e^16*Math.random()>>e/4).toString(10):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t)},V=function(){return z().replace(/-/g,"").slice(0,19)},H=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)})},K=function(){function t(){}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.storage=new C,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(M.SessionReset,function(){i.resetSessionId()}),this.collect.on(M.SessionResetTime,function(){i.updateSessionIdTime()}))},t.prototype.updateSessionIdTime=function(){var t=this.storage.getSessionItem(this.sessionKey);if(t&&t.sessionId){var e=t.timestamp;Date.now()-e>this.expireTime?t={sessionId:H(),timestamp:Date.now()}:t.timestamp=Date.now(),this.storage.setSessionItem(this.sessionKey,t),this.resetExpTime()}},t.prototype.setSessionId=function(){var t=this,e=this.storage.getSessionItem(this.sessionKey);e&&e.sessionId?e.timestamp=Date.now():e={sessionId:H(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,e),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime)},t.prototype.getSessionId=function(){var t=this.storage.getSessionItem(this.sessionKey);return this.disableSession?"":t&&t.sessionId?t.sessionId:""},t.prototype.resetExpTime=function(){var t=this;this.sessionExp&&(clearInterval(this.sessionExp),this.sessionExp=setInterval(function(){t.checkEXp()},this.expireTime))},t.prototype.resetSessionId=function(){var t={sessionId:H(),timestamp:Date.now()};this.storage.setItem(this.sessionKey,t)},t.prototype.checkEXp=function(){var t=this.storage.getSessionItem(this.sessionKey);t&&t.sessionId&&(Date.now()-t.timestamp+30>=this.expireTime&&(t={sessionId:H(),timestamp:Date.now()},this.storage.setSessionItem(this.sessionKey,t)))},t}(),j=function(){function t(){this.cacheToken={},this.enableCookie=!1,this.enableTTwebid=!1,this.enableCustomWebid=!1,this.enableAnonymousid=!1}return t.prototype.apply=function(t,e){var i=this;this.collect=t,this.config=e,this.configManager=this.collect.configManager,this.storage=new C,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(M.AnonymousId,function(t){i.setAnonymousId(t)}),this.collect.on(M.ConfigUuid,function(t){i.setUuid(t)}),this.collect.on(M.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()},t.prototype.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(M.CustomWebId,function(){t.tokenReady=!0,t.collect.emit(M.TokenComplete)}):this.checkEnv()||(this.enableTTwebid?this.completeTtWid(this.cacheToken):this.check()):this.remoteWebid()},t.prototype.check=function(){this.cacheToken&&this.cacheToken.web_id?this.complete(this.cacheToken):this.config.disable_webid?this.complete({web_id:V(),user_unique_id:this.configManager.get("user_unique_id")||V()}):this.remoteWebid()},t.prototype.checkEnv=function(){var t=window.navigator.userAgent;if(-1!==t.indexOf("miniProgram")||-1!==t.indexOf("MiniProgram")){var e=p(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},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.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(b.DEBUGGER_MESSAGE,{type:b.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(M.TokenError),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.TokenError),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})},t.prototype.getLocalId=function(){for(var t=V(),e=0;0===t.indexOf("0")||0===t.indexOf("9");){if(e>=10){t=t.replace(/^(0|9)/,"");break}t=V(),e++}return t},t.prototype.complete=function(t){var e=t.web_id,i=t.user_unique_id;if(!e&&!i)return this.collect.emit(M.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(M.TokenComplete)},t.prototype.completeAnonymous=function(t){var e=t.anonymous_id||H(),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(M.TokenComplete)},t.prototype.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(M.TokenComplete)},t.prototype.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(M.TokenChange,{type:"uuid",id:t}),this.collect.emit(M.SessionReset)}else this.clearUuid()},t.prototype.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(M.TokenReset))}},t.prototype.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(M.TokenChange,{type:"uuid",id:t})),this.configManager.set({anonymous_id:t}),this.cacheToken.anonymous_id=t,this.collect.emit(M.TokenChange,{type:"anonymous_id",id:t}),this.setStorage(this.cacheToken))}},t.prototype.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(M.TokenChange,{type:"uuid",id:t})),e!==t&&(this.configManager.set({web_id:t}),this.cacheToken.web_id=t,this.collect.emit(M.TokenChange,{type:"webid",id:t})),this.cacheToken.timestamp=Date.now(),this.setStorage(this.cacheToken)}},t.prototype.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},t.prototype.getReady=function(){return this.tokenReady},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"GetToken请求成功",logType:"fetch",level:"info",time:Date.now(),data:i,infoType:"sdk"})):(e(""),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"GetToken请求失败",logType:"fetch",level:"error",time:Date.now(),data:i,infoType:"sdk"}))},fail:function(){e(""),t.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})})},t}(),J=function(){function t(t,e){var i=this;this.collector=t,this.config=e,this.requestType=e.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=e.custom_request_header||{},this.collector.on(M.CustomHeader,function(t){i.setRequestHeader(t)})}return t.prototype.setRequestHeader=function(t){this.customHeader=Object.assign(this.customHeader,t)},t.prototype.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,u=t.encryption,l=t.encryption_header,p=t.withCredentials;if(window.fetch&&"undefined"!=typeof Request){var f={method:o||"POST"};if(h){if(!("keepalive"in Request.prototype))return void this.useSendBeacon(t);var d=this.collector.configManager.get("browser"),g=this.collector.configManager.get("browser_version");if(g=g.split("."),"Chrome"===d&&g.length&&g[0]&&Number(g[0])<82)return void this.useSendBeacon(t);f.keepalive=!0}var m=JSON.stringify(n),y={"Content-Type":"application/json; charset=utf-8"};u&&l&&(y["Content-Type"]="application/octet-stream;tt-data="+l),p&&(f.credentials="include"),f.body=m,f.headers=y;var v=null;v="undefined"!=typeof AbortController?new AbortController:{signal:null,abort:function(){}};var _=setTimeout(function(){v.abort()},c);if(Object.keys(this.customHeader).length)for(var E in this.customHeader)y[E]=this.customHeader[E];f.signal=v.signal;var S=Date.now();try{fetch(i,f).then(function(t){return t.ok||s&&s(n,t.status,S,t.statusText||e.errorMessage.FETCH_RESPONSE_ERROR),t.json()}).then(function(t){clearTimeout(_),r&&r(t,n,a,S,200)}).catch(function(t){clearTimeout(_),s&&s(n,e.errorCode.FETCH_ERROR,S,t.message||e.errorMessage.FETCH_ERROR)})}catch(e){this.useXhr(t),this.collector.emit(b.DEBUGGER_MESSAGE,{type:b.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")},t.prototype.useSendBeacon=function(t){if(this.supportBeacon){var e=t.url,i=t.data,n=t.status,o=t.success,r=t.fail,s=Date.now();window.navigator.sendBeacon(e,JSON.stringify(i))?o&&o({e:0},i,n,s,200):r&&r(i,this.errorCode.BEACON_FALSE,s,this.errorMessage.BEACON_FALSE)}else this.useXhr(t)},t.prototype.useXhr=function(t){var e=this,i=t.url,n=t.data,o=t.method,r=t.success,s=t.fail,a=t.timeout,c=t.withCredentials,h=t.encryption,u=t.encryption_header,l=t.status;try{var p=new XMLHttpRequest;p.open(o||"POST",i,!0);var f=Date.now();if(p.setRequestHeader("Content-Type","application/json; charset=utf-8"),h&&u?p.setRequestHeader("Content-Type","application/octet-stream;tt-data="+u):p.setRequestHeader("Content-Type","application/json; charset=utf-8"),Object.keys(this.customHeader).length)for(var d in this.customHeader)p.setRequestHeader(d,this.customHeader[d]);c&&(p.withCredentials=!0),a&&(p.timeout=a,p.ontimeout=function(){s&&s(n,e.errorCode.TIMEOUT,f,e.errorMessage.TIMEOUT)}),p.onload=function(){if(r){var t=null;if(p.responseText){try{t=JSON.parse(p.responseText)}catch(e){t={}}r(t,n,l,f,p.status)}else s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR)}},p.onerror=function(){s&&s(n,e.errorCode.XHR_ERROR,f,e.errorMessage.XHR_ERROR),p.abort()},p.send(JSON.stringify(n))}catch(t){this.collector.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK useXhr 发送请求发生了一些问题",level:"error",time:Date.now(),data:t.message,infoType:"sdk"})}},t.prototype.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)},t.prototype.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)}},t}(),W=m(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,u=a*c+h*s;o=((c=s*c+((32767&u)<<15)+i[n]+(1073741823&o))>>>30)+(u>>>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,u=a*c+h*s;o=((c=s*c+((16383&u)<<14)+i[n]+o)>>28)+(u>>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 u(t){var e=n();return e.fromInt(t),e}function l(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 p(t){this.m=t}function f(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 d(t,e){return t&e}function g(t,e){return t|e}function m(t,e){return t^e}function y(t,e){return t&~e}function v(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 _(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}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},f.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},f.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},f.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)},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)},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,u=this.DB-l(r[r.t-1]);u>0?(r.lShiftTo(u,a),s.lShiftTo(u,o)):(r.copyTo(a),s.copyTo(o));var p=a.t,f=a[p-1];if(0!=f){var d=f*(1<<this.F1)+(p>1?a[p-2]>>this.F2:0),g=this.FV/d,m=(1<<this.F1)/d,y=1<<this.F2,v=o.t,_=v-p,b=null==e?n():e;for(a.dlShiftTo(_,b),o.compareTo(b)>=0&&(o[o.t++]=1,o.subTo(b,o)),i.ONE.dlShiftTo(p,b),b.subTo(a,a);a.t<p;)a[a.t++]=0;for(;--_>=0;){var E=o[--v]==f?this.DM:Math.floor(o[v]*g+(o[v-1]+y)*m);if((o[v]+=a.am(0,E,o,_,0,p))<E)for(a.dlShiftTo(_,b),o.subTo(b,o);o[v]<--E;)o.subTo(b,o)}null!=e&&(o.drShiftTo(p,e),c!=h&&i.ZERO.subTo(e,e)),o.t=p,o.clamp(),u>0&&o.rShiftTo(u,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=l(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)+l(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 p(e):new f(e),this.exp(t,i)},i.ZERO=u(0),i.ONE=u(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 C(){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=u(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 u=h(t,c);u<0?"-"==t.charAt(c)&&0==this.signum()&&(r=!0):(a=e*a+u,++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,d,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,y,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+v(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+=_(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,y)},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=u(1);if(r<=0)return s;i=r<18?1:r<48?3:r<144?4:r<768?5:6,o=r<8?new p(e):e.isEven()?new S(e):new f(e);var a=new Array,c=3,h=i-1,d=(1<<i)-1;if(a[1]=o.convert(this),i>1){var g=n();for(o.sqrTo(a[1],g);c<=d;)a[c]=n(),o.mulTo(g,a[c-2],a[c]),c+=2}var m,y,v=t.t-1,_=!0,b=n();for(r=l(t[v])-1;v>=0;){for(r>=h?m=t[v]>>r-h&d:(m=(t[v]&(1<<r+1)-1)<<h-r,v>0&&(m|=t[v-1]>>this.DB+r-h)),c=i;!(1&m);)m>>=1,--c;if((r-=c)<0&&(r+=this.DB,--v),_)a[m].copyTo(s),_=!1;else{for(;c>1;)o.sqrTo(s,b),o.sqrTo(b,s),c-=2;c>0?o.sqrTo(s,b):(y=s,s=b,b=y),o.mulTo(b,a[m],s)}for(;v>=0&&!(t[v]&1<<r);)o.sqrTo(s,b),y=s,s=b,b=y,--r<0&&(r=this.DB-1,--v)}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=u(1),s=u(0),a=u(0),c=u(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 I;if(T=new Array,k=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var x=new Uint8Array(32);for(window.crypto.getRandomValues(x),I=0;I<32;++I)T[k++]=x[I]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var O=window.crypto.random(32);for(I=0;I<O.length;++I)T[k++]=255&O.charCodeAt(I)}for(;k<G;)I=Math.floor(65536*Math.random()),T[k++]=I>>>8,T[k++]=255&I;k=0,C()}function R(){if(null==w){for(C(),(w=new B).init(T),k=0;k<T.length;++k)T[k]=0;k=0}return w.next()}function M(){}function B(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=R()},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:M}}).call(g)});W.BigInteger,W.SecureRandom;const{BigInteger:X}=W;class ${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 Z extends ${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 X(n,16),e=n.xor(t).add(X.ONE),e=e.toString(16).replace(/^-/,"")}return e}(t))}getValue(){return this.v}}class Y extends ${constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map(t=>t.getEncodedHex()).join(""),this.v}}function Q(t,e){return+t[e+2]<8?1:128&+t.substr(e+2,2)}function tt(t,e){const i=Q(t,e),n=t.substr(e+2,2*i);if(!n)return-1;return(+n[0]<8?new X(n,16):new X(n.substr(2),16)).intValue()}function et(t,e){return e+2*(Q(t,e)+1)}var it={encodeDer(t,e){const i=new Z(t),n=new Z(e);return new Y([i,n]).getEncodedHex()},decodeDer(t){const e=et(t,0),i=et(t,e),n=tt(t,e),o=t.substr(i,2*n),r=i+o.length,s=et(t,r),a=tt(t,r),c=t.substr(s,2*a);return{r:new X(o,16),s:new X(c,16)}}};const{BigInteger:nt}=W,ot=new nt("2"),rt=new nt("3");class st{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 st(this.q,this.x.negate().mod(this.q))}add(t){return new st(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new st(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new st(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new st(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new st(this.q,this.x.square().mod(this.q))}}class at{constructor(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?nt.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(nt.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(nt.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(nt.ZERO)&&!this.y.toBigInteger().equals(nt.ZERO)}negate(){return new at(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),u=c.subtract(h),l=i.multiply(s).mod(a),p=r.multiply(n).mod(a),f=l.subtract(p);if(nt.ZERO.equals(u))return nt.ZERO.equals(f)?this.twice():this.curve.infinity;const d=c.add(h),g=n.multiply(s).mod(a),m=u.square().mod(a),y=u.multiply(m).mod(a),v=g.multiply(f.square()).subtract(d.multiply(m)).mod(a),_=u.multiply(v).mod(a),b=f.multiply(m.multiply(c).subtract(v)).subtract(l.multiply(y)).mod(a),E=y.multiply(g).mod(a);return new at(this.curve,this.curve.fromBigInteger(_),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(rt).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),u=r.square().subtract(c.shiftLeft(3)).mod(n),l=s.multiply(u).mod(n),p=r.multiply(c.shiftLeft(2).subtract(u)).subtract(h.shiftLeft(1).multiply(a)).mod(n),f=s.multiply(h).mod(n);return new at(this.curve,this.curve.fromBigInteger(l),this.curve.fromBigInteger(p),f)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const e=t.multiply(rt),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 ct={ECPointFp:at,ECCurveFp:class{constructor(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new at(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 st(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 nt(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 nt("4")).add(nt.ONE),this.q));return i.toBigInteger().mod(ot).equals(new nt(t.substr(0,2),16).subtract(ot))||(i=i.negate()),new at(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 at(this,this.fromBigInteger(new nt(o,16)),this.fromBigInteger(new nt(r,16)));default:return null}}}};const{BigInteger:ht,SecureRandom:ut}=W,{ECCurveFp:lt}=ct,pt=new ut,{curve:ft,G:dt,n:gt}=mt();function mt(){const t=new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),e=new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new ht("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new lt(t,e,i),o=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:o,n:new ht("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function yt(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t}var vt={getGlobalCurve:function(){return ft},generateEcparam:mt,generateKeyPairHex:function(t,e,i){const n=(t?new ht(t,e,i):new ht(gt.bitLength(),pt)).mod(gt.subtract(ht.ONE)).add(ht.ONE),o=yt(n.toString(16),64),r=dt.multiply(n);return{privateKey:o,publicKey:"04"+yt(r.getX().toBigInteger().toString(16),64)+yt(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 ht(t.substr(e+2,e),16).mod(new ht("2")).equals(ht.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:yt,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=yt(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=ft.decodePointHex(t);if(!e)return!1;const i=e.getX();return e.getY().square().equals(i.multiply(i.square()).add(i.multiply(ft.a)).add(ft.b))},comparePublicKeyHex:function(t,e){const i=ft.decodePointHex(t);if(!i)return!1;const n=ft.decodePointHex(e);return!!n&&i.equals(n)}};const _t=new Uint32Array(68),bt=new Uint32Array(64);function Et(t,e){const i=31&e;return t<<i|t>>>32-i}function St(t,e){const i=[];for(let n=t.length-1;n>=0;n--)i[n]=255&(t[n]^e[n]);return i}function wt(t){return t^Et(t,9)^Et(t,17)}function Tt(t){return t^Et(t,15)^Et(t,23)}function kt(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++){_t.fill(0),bt.fill(0);const e=16*t;for(let t=0;t<16;t++)_t[t]=s.getUint32(4*(e+t),!1);for(let t=16;t<68;t++)_t[t]=Tt(_t[t-16]^_t[t-9]^Et(_t[t-3],15))^Et(_t[t-13],7)^_t[t-6];for(let t=0;t<64;t++)bt[t]=_t[t]^_t[t+4];const i=2043430169,n=2055708042;let o,r,a,h,u,l=c[0],p=c[1],f=c[2],d=c[3],g=c[4],m=c[5],y=c[6],v=c[7];for(let t=0;t<64;t++)u=t>=0&&t<=15?i:n,o=Et(Et(l,12)+g+Et(u,t),7),r=o^Et(l,12),a=(t>=0&&t<=15?l^p^f:l&p|l&f|p&f)+d+r+bt[t],h=(t>=0&&t<=15?g^m^y:g&m|~g&y)+v+o+_t[t],d=f,f=Et(p,9),p=l,l=a,v=y,y=Et(m,19),m=g,g=wt(h);c[0]^=l,c[1]^=p,c[2]^=f,c[3]^=d,c[4]^=g,c[5]^=m,c[6]^=y,c[7]^=v}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 Dt=new Uint8Array(64),At=new Uint8Array(64);for(let t=0;t<64;t++)Dt[t]=54,At[t]=92;var Ct={sm3:kt,hmac:function(t,e){for(e.length>64&&(e=kt(e));e.length<64;)e.push(0);const i=St(e,Dt),n=St(e,At),o=kt([...i,...t]);return kt([...n,...o])}};const{BigInteger:It}=W,{encodeDer:xt,decodeDer:Ot}=it,Rt=Ct.sm3,{G:Mt,curve:Bt,n:Gt}=vt.generateEcparam();function Pt(t,e,i="1234567812345678"){i=vt.utf8ToHex(i);const n=vt.leftPad(Mt.curve.a.toBigInteger().toRadix(16),64),o=vt.leftPad(Mt.curve.b.toBigInteger().toRadix(16),64),r=vt.leftPad(Mt.getX().toBigInteger().toRadix(16),64),s=vt.leftPad(Mt.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=Mt.curve.decodePointHex(e);a=vt.leftPad(t.getX().toBigInteger().toRadix(16),64),c=vt.leftPad(t.getY().toBigInteger().toRadix(16),64)}const h=vt.hexToArray(i+n+o+r+s+a+c),u=4*i.length;h.unshift(255&u),h.unshift(u>>8&255);const l=Rt(h);return vt.arrayToHex(Rt(l.concat(vt.hexToArray(t))))}function Lt(){const t=vt.generateKeyPairHex(),e=Bt.decodePointHex(t.publicKey);return t.k=new It(t.privateKey,16),t.x1=e.getX().toBigInteger(),t}var Nt={generateKeyPairHex:vt.generateKeyPairHex,compressPublicKeyHex:vt.compressPublicKeyHex,comparePublicKeyHex:vt.comparePublicKeyHex,doEncrypt:function(t,e,i=1){t="string"==typeof t?vt.hexToArray(vt.utf8ToHex(t)):Array.prototype.slice.call(t),e=vt.getGlobalCurve().decodePointHex(e);const n=vt.generateKeyPairHex(),o=new It(n.privateKey,16);let r=n.publicKey;r.length>128&&(r=r.substr(r.length-128));const s=e.multiply(o),a=vt.hexToArray(vt.leftPad(s.getX().toBigInteger().toRadix(16),64)),c=vt.hexToArray(vt.leftPad(s.getY().toBigInteger().toRadix(16),64)),h=vt.arrayToHex(Rt([].concat(a,t,c)));let u=1,l=0,p=[];const f=[].concat(a,c),d=()=>{p=Rt([...f,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,l=0};d();for(let e=0,i=t.length;e<i;e++)l===p.length&&d(),t[e]^=255&p[l++];const g=vt.arrayToHex(t);return 0===i?r+g+h:r+h+g},doDecrypt:function(t,e,i=1,{output:n="string"}={}){e=new It(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=vt.hexToArray(r),a=vt.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(e),c=vt.hexToArray(vt.leftPad(a.getX().toBigInteger().toRadix(16),64)),h=vt.hexToArray(vt.leftPad(a.getY().toBigInteger().toRadix(16),64));let u=1,l=0,p=[];const f=[].concat(c,h),d=()=>{p=Rt([...f,u>>24&255,u>>16&255,u>>8&255,255&u]),u++,l=0};d();for(let t=0,e=s.length;t<e;t++)l===p.length&&d(),s[t]^=255&p[l++];return vt.arrayToHex(Rt([].concat(c,s,h)))===o.toLowerCase()?"array"===n?s:vt.arrayToUtf8(s):"array"===n?[]:""},doSignature:function(t,e,{pointPool:i,der:n,hash:o,publicKey:r,userId:s}={}){let a="string"==typeof t?vt.utf8ToHex(t):vt.arrayToHex(t);o&&(r=r||function(t){const e=Mt.multiply(new It(t,16)),i=vt.leftPad(e.getX().toBigInteger().toString(16),64),n=vt.leftPad(e.getY().toBigInteger().toString(16),64);return"04"+i+n}(e),a=Pt(a,r,s));const c=new It(e,16),h=new It(a,16);let u=null,l=null,p=null;do{do{let t;t=i&&i.length?i.pop():Lt(),u=t.k,l=h.add(t.x1).mod(Gt)}while(l.equals(It.ZERO)||l.add(u).equals(Gt));p=c.add(It.ONE).modInverse(Gt).multiply(u.subtract(l.multiply(c))).mod(Gt)}while(p.equals(It.ZERO));return n?xt(l,p):vt.leftPad(l.toString(16),64)+vt.leftPad(p.toString(16),64)},doVerifySignature:function(t,e,i,{der:n,hash:o,userId:r}={}){let s,a,c="string"==typeof t?vt.utf8ToHex(t):vt.arrayToHex(t);if(o&&(c=Pt(c,i,r)),n){const t=Ot(e);s=t.r,a=t.s}else s=new It(e.substring(0,64),16),a=new It(e.substring(64),16);const h=Bt.decodePointHex(i),u=new It(c,16),l=s.add(a).mod(Gt);if(l.equals(It.ZERO))return!1;const p=Mt.multiply(a).add(h.multiply(l)),f=u.add(p.getX().toBigInteger()).mod(Gt);return s.equals(f)},getPoint:Lt,verifyPublicKey:vt.verifyPublicKey};const{sm3:Ft,hmac:Ut}=Ct;function qt(t){return t.map(t=>1===(t=t.toString(16)).length?"0"+t:t).join("")}function zt(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 Vt=16,Ht=[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],Kt=[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 jt(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 Jt(t,e){return t<<e|t>>>32-e}function Wt(t){return(255&Ht[t>>>24&255])<<24|(255&Ht[t>>>16&255])<<16|(255&Ht[t>>>8&255])<<8|255&Ht[255&t]}function Xt(t){return t^Jt(t,2)^Jt(t,10)^Jt(t,18)^Jt(t,24)}function $t(t){return t^Jt(t,13)^Jt(t,23)}function Zt(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]^=Xt(Wt(t)),t=n[2]^n[3]^n[0]^i[e+1],n[1]^=Xt(Wt(t)),t=n[3]^n[0]^n[1]^i[e+2],n[2]^=Xt(Wt(t)),t=n[0]^n[1]^n[2]^i[e+3],n[3]^=Xt(Wt(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 Yt(t,e,i,{padding:n="pkcs#7",mode:o,iv:r=[],output:s="string"}={}){if("cbc"===o&&("string"==typeof r&&(r=jt(r)),16!==r.length))throw new Error("iv is invalid");if("string"==typeof e&&(e=jt(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):jt(t):[...t],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const e=Vt-t.length%Vt;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]^Kt[i+0],e[i+0]=n[0]^=$t(Wt(t)),t=n[2]^n[3]^n[0]^Kt[i+1],e[i+1]=n[1]^=$t(Wt(t)),t=n[3]^n[0]^n[1]^Kt[i+2],e[i+2]=n[2]^=$t(Wt(t)),t=n[0]^n[1]^n[2]^Kt[i+3],e[i+3]=n[3]^=$t(Wt(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,u=t.length,l=0;for(;u>=Vt;){const e=t.slice(l,l+16),n=new Array(16);if("cbc"===o)for(let t=0;t<Vt;t++)0!==i&&(e[t]^=h[t]);Zt(e,n,a);for(let t=0;t<Vt;t++)"cbc"===o&&0===i&&(n[t]^=h[t]),c[l+t]=n[t];"cbc"===o&&(h=0!==i?n:e),u-=Vt,l+=Vt}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 Qt={sm2:Nt,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?zt(i):Array.prototype.slice.call(i),qt(Ut(t,i))}return qt(Ft(t))},sm4:{encrypt:(t,e,i)=>Yt(t,e,1,i),decrypt:(t,e,i)=>Yt(t,e,0,i)}}.sm2;var te,ee=function(){function e(t){this.disableAutoPageView=!1,this.bridgeReport=!1,this.staging=!1,this.pluginInstances=[],this.sended=!1,this.started=!1,this.destroyInstance=!1,this.adapters={},this.sdkReady=!1,this.name=t,this.hook=new o,this.logger=new F(t),this.remotePlugin=new Map,this.Types=M}return 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})},e.prototype.init=function(t){var i,n=this;this.inited?console.log("init can be call only one time"):t&&r(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 F(this.name,t.log),this.configManager=new N(this,t),this.appBridge=new U(t,this.configManager),this.bridgeReport=this.appBridge.bridgeInject(),this.requestManager=new J(this,t),this.initConfig=t,this.env=t.channel_domain?"self":"public",this.emit(b.DEBUGGER_MESSAGE,{type:b.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(M.Init)):(t.enable_encryption&&"sm"===t.encryption_type&&this.initCrypto(),this.configManager.set({app_id:t.app_id}),this.eventManager=new q,this.tokenManager=new j,this.sessionManager=new K,Promise.all([new Promise(function(t){n.once(M.TokenComplete,function(){t(!0)})}),new Promise(function(t){n.once(M.Start,function(){t(!0)})})]).then(function(){try{e.plugins.reduce(function(t,e){var i=e.plugin,o=e.options,r=Object.assign(n.initConfig,o),s=new i;return s.apply(n,r),t.push(s),t},n.pluginInstances)}catch(t){console.log("load plugin error, "+t.message),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.sdkReady=!0,n.emit(M.Ready),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 初始化完成",time:Date.now(),level:"info",data:n.configManager.get("user")}),n.logger.info("appid: "+t.app_id+", userInfo:"+JSON.stringify(n.configManager.get("user"))),n.logger.info("appid: "+t.app_id+", sdk is ready, version is "+x+", you can report now !!!");try{(window.opener||window.parent).postMessage("[tea-sdk]ready","*")}catch(t){n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}n.pageView(),n.on(M.TokenChange,function(e){"webid"!==e.type&&"anonymous_id"!==e.type||n.pageView(),n.logger.info("appid: "+t.app_id+" token change, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 设置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})}),n.on(M.TokenReset,function(){n.logger.info("appid: "+t.app_id+" token reset, new userInfo:"+JSON.stringify(n.configManager.get("user"))),n.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 重置了用户信息",time:Date.now(),secType:"USER",level:"info",data:n.configManager.get("user")})}),n.on(M.RouteChange,function(e){e.init||t.disable_route_report||n.pageView()})}),this.tokenManager.apply(this,t),this.eventManager.apply(this,t),this.sessionManager.apply(this,t),this.inited=!0,this.emit(M.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")},e.prototype.config=function(e){if(this.inited)if(e&&r(e))if(this.bridgeReport)this.appBridge.setConfig(e);else{e._staging_flag&&1===e._staging_flag&&(this.staging=!0),e.disable_auto_pv&&(this.disableAutoPageView=!0,delete e.disable_auto_pv);var i=t({},e);if(this.initConfig&&this.initConfig.configPersist){var n=this.configManager.getStore();n&&(i=Object.assign(n,e)),this.configManager.setStore(e)}i.web_id,i.user_unique_id;var o=function(t,e){var i={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(i[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(i[n[o]]=t[n[o]])}return i}(i,["web_id","user_unique_id"]);i.hasOwnProperty("web_id")&&this.emit(M.ConfigWebId,i.web_id),i.hasOwnProperty("user_unique_id")&&this.emit(M.ConfigUuid,i.user_unique_id),this.configManager.set(o),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行CONFIG",level:"info",time:Date.now(),data:i})}else this.logger.warn("config params is error, please check");else this.logger.warn("config must be use after function init")},e.prototype.setDomain=function(t){this.configManager&&this.configManager.setDomain(t),this.emit(M.ConfigDomain)},e.prototype.getConfig=function(t){return this.configManager.get(t)},e.prototype.send=function(){this.start()},e.prototype.start=function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(M.Start),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行START",level:"info",time:Date.now()}),this.bridgeReport&&(this.pageView(),this.emit(M.Ready)))},e.prototype.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(M.Event,n),this.emit(M.SessionResetTime))}catch(t){this.logger.warn("something error, please check"),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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(M.BeconEvent,i),this.emit(M.SessionResetTime)))}},e.prototype.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=e;"object"!=typeof n&&(n={}),n.profile?delete n.profile:n.event_index=a();var o=void 0;return n.local_ms?(o=n.local_ms,delete n.local_ms):o=+new Date,{event:i,params:n,local_time_ms:o,is_bav:this.initConfig&&this.initConfig.autotrack?1:0}}catch(i){return this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:i.message}),{event:t,params:e}}},e.prototype.dynamicParams=function(t){this.dynamicParamsFilter=t},e.prototype.filterEvent=function(t){this.eventFilter=t},e.prototype.on=function(t,e){this.hook.on(t,e)},e.prototype.once=function(t,e){this.hook.once(t,e)},e.prototype.off=function(t,e){this.hook.off(t,e)},e.prototype.emit=function(t,e,i){this.hook.emit(t,e,i)},e.prototype.set=function(t){this.hook.set(t)},e.prototype.pageView=function(){this.disableAutoPageView||this.predefinePageView()},e.prototype.predefinePageView=function(e){if(void 0===e&&(e={}),this.inited){var i={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)},n=t({},i,e);this.event("predefine_pageview",n)}else console.warn("predefinePageView should call after init")},e.prototype.clearEventCache=function(){this.emit(M.CleanEvents)},e.prototype.setWebIDviaUnionID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_unionid:t}),this.emit(M.CustomWebId)}},e.prototype.setWebIDviaOpenID=function(t){if(t){var e=f(t);this.config({web_id:""+e,wechat_openid:t}),this.emit(M.CustomWebId)}},e.prototype.setAnonymousId=function(t){this.emit(M.AnonymousId,t)},e.prototype.setNativeAppId=function(t){this.bridgeReport&&this.appBridge.setNativeAppId(t)},e.prototype.enableTransPort=function(){this.configManager.setEnableClientTransport(!0)},e.prototype.disableTransPort=function(){this.configManager.setEnableClientTransport(!1)},e.prototype.resetStayDuration=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(M.ResetStay,{url_path:t,title:e,url:i},M.Stay)},e.prototype.resetStayParams=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=""),this.emit(M.SetStay,{url_path:t,title:e,url:i},M.Stay)},e.prototype.getToken=function(e,i){var n=this;if(this.inited){var o=!1,r=function(i){if(!o){o=!0;var r=n.configManager.get().user;return i&&(r.tobid=i,r["diss".split("").reverse().join("")]=i),e(t({},r))}},s=function(){n.tokenManager.getTobId().then(function(t){r(t)})};this.sdkReady?s():(i&&setTimeout(function(){r()},i),this.on(M.Ready,function(){s()}))}else this.logger.warn("getToken must be use after function init")},e.prototype.startTrackEvent=function(t){t&&this.emit(M.TrackDurationStart,t,M.TrackDuration)},e.prototype.endTrackEvent=function(t,e){void 0===e&&(e={}),t&&this.emit(M.TrackDurationEnd,{eventName:t,params:e},M.TrackDuration)},e.prototype.pauseTrackEvent=function(t){t&&this.emit(M.TrackDurationPause,t,M.TrackDuration)},e.prototype.resumeTrackEvent=function(t){t&&this.emit(M.TrackDurationResume,t,M.TrackDuration)},e.prototype.profileSet=function(t){this.bridgeReport?this.appBridge.profileSet(JSON.stringify(t)):this.emit(M.ProfileSet,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSet",level:"info",time:Date.now(),data:t})},e.prototype.profileSetOnce=function(t){this.bridgeReport?this.appBridge.profileSetOnce(JSON.stringify(t)):this.emit(M.ProfileSetOnce,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileSetOnce",level:"info",time:Date.now(),data:t})},e.prototype.profileIncrement=function(t){this.bridgeReport?this.appBridge.profileIncrement(JSON.stringify(t)):this.emit(M.ProfileIncrement,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileIncrement",level:"info",time:Date.now(),data:t})},e.prototype.profileUnset=function(t){this.bridgeReport?this.appBridge.profileUnset(t):this.emit(M.ProfileUnset,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileUnset",level:"info",time:Date.now(),data:t})},e.prototype.profileAppend=function(t){this.bridgeReport?this.appBridge.profileAppend(JSON.stringify(t)):this.emit(M.ProfileAppend,t,M.Profile),this.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行profileAppend",level:"info",time:Date.now(),data:t})},e.prototype.setExternalAbVersion=function(t){this.bridgeReport?this.appBridge.setExternalAbVersion(t):this.emit(M.AbExternalVersion,"string"==typeof t&&t?(""+t).trim():null,M.Ab)},e.prototype.getVar=function(t,e,i){this.bridgeReport?this.appBridge.getVar(t,e,i):this.emit(M.AbVar,{name:t,defaultValue:e,callback:i},M.Ab)},e.prototype.getAllVars=function(t){this.bridgeReport?this.appBridge.getAllVars(t):this.emit(M.AbAllVars,t,M.Ab)},e.prototype.getABconfig=function(t,e){this.emit(M.AbConfig,{params:t,callback:e},M.Ab)},e.prototype.getAbSdkVersion=function(t){if(!this.bridgeReport||!t)return this.configManager.getAbVersion()||"";this.appBridge.getAbSdkVersion(t)},e.prototype.onAbSdkVersionChange=function(t){var e=this;return this.emit(M.AbVersionChangeOn,t,M.Ab),function(){e.emit(M.AbVersionChangeOff,t,M.Ab)}},e.prototype.offAbSdkVersionChange=function(t){this.emit(M.AbVersionChangeOff,t,M.Ab)},e.prototype.openOverlayer=function(){this.emit(M.AbOpenLayer,"",M.Ab)},e.prototype.closeOverlayer=function(){this.emit(M.AbCloseLayer,"",M.Ab)},e.prototype.initCrypto=function(){this.publicKey=this.initConfig.crypto_publicKey||"04BA9E229380DC0E41E10839B0C52A4763D3EDFE8903F3B8E81395523381E03AA995D295BD4A4088792E4785B224F7837EB4D2C7C05973C7AE8687A35ACAE470A0"},e.prototype.cryptoData=function(t){try{if(!this.initConfig.enable_encryption)return t;var e=void 0;if("sm"===this.initConfig.encryption_type){var i=(r=JSON.stringify(t),s=this.publicKey,void 0===(a=1)&&(a=1),"04"+Qt.doEncrypt(r,s,a)),n=d(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},e.prototype.destoryInstance=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(M.TokenComplete))},e.prototype.destoryInstace=function(){this.destroyInstance||(this.destroyInstance=!0,this.off(M.TokenComplete))},e.plugins=[],e}(),ie="__rangers_ab_style__";!function(t){t[t.Var=0]="Var",t[t.All=1]="All"}(te||(te={}));var ne=2592e6,oe=function(){function e(){this.fetchStatus="no",this.refreshFetchStatus="complete",this.versions=[],this.extVersions=[],this.mulilinkVersions=[],this.enable_multilink=!1,this.enable_ab_visual=!1,this.editMode=!1,this.callbacks=[],this.data=null,this.changeListener=new Map,this.readyStatus=!1,this.exposureCache=[]}return e.prototype.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,s=e.ab_cross,a=e.ab_cookie_domain,h=e.disable_ab_reset,u=o||c(O[e.channel||"cn"]);this.cacheStorgae=new C,this.enable_multilink=n,this.enable_ab_visual=r,this.abKey="__tea_sdk_ab_version_"+e.app_id,this.ab_cross=s,this.ab_cookie_domain=a||"",this.fetchUrl=u+"/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 l=this.collect.Types;this.types=l,this.collect.on(l.TokenChange,function(t){h||"uuid"===t.type&&i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(l.TokenReset,function(){h||i.readyStatus&&(i.clearCache(),i.fetchAB())}),this.collect.on(l.AbVar,function(t){var e=t.name,n=t.defaultValue,o=t.callback;i.getVar(e,n,o)}),this.collect.on(l.AbAllVars,function(t){i.getAllVars(t)}),this.collect.on(l.AbConfig,function(t){var e=t.params,n=t.callback;i.getABconfig(e,n)}),this.collect.on(l.AbExternalVersion,function(t){i.setExternalAbVersion(t)}),this.collect.on(l.AbOpenLayer,function(){i.openOverlayer()}),this.collect.on(l.AbCloseLayer,function(){i.closeOverlayer()}),this.collect.on(l.AbVersionChangeOn,function(t){i.changeListener.set(t,t)}),this.collect.on(l.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(l.AbReady)}},e.prototype.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)}},e.prototype.loadMode=function(){},e.prototype.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(","))},e.prototype.checkFromUrl=function(){var t=p(window.location.href);return t&&t.vid?t.vid:""},e.prototype.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)})},e.prototype.configVersions=function(t){this.collect.configManager.setAbVersion(t)},e.prototype.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)},e.prototype.getRealVar=function(t,e){var i=t.name,n=t.defaultValue,o=t.callback,s=this.data;if(s){if(r(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,n),o(s[i].val),void this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 曝光了实验"+i,level:"info",time:Date.now(),data:s[i]})}this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getVar",level:"info",time:Date.now(),data:n}),o(n)}else o(n)},e.prototype.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)},e.prototype.getRealAllVars=function(t){(0,t.callback)(this.data?JSON.parse(JSON.stringify(this.data)):{}),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"SDK 调用getAllVars",level:"info",time:Date.now(),data:this.data})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.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)},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:[e],code:200,status:"success"})}),this.exposureCache=[]},e.prototype.setExternalAbVersion=function(t){this.extVersions=[t],this.updateVersions()},e.prototype.getABconfig=function(t,e){var i=Object.keys(t);i&&i.length&&this.collect.configManager.set(t),this.fetchAB(e)},e.prototype.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)},e.prototype.set=function(t,e){this.ab_cross?this.cacheStorgae.setCookie(t,e,ne,this.ab_cookie_domain):this.cacheStorgae.setLocalItem(t,e),this.collect.configManager.setAbCache(e)},e.prototype.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>=ne?(this.cacheStorgae.removeLocalItem(this.abKey),null):t?e[t]:e},e.prototype.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)},e.prototype.setAbCache=function(t){var e=this.getABCache();e.data=this.data,e.uuid=t,e.timestamp=Date.now(),this.set(this.abKey,e)},e.prototype.clearCache=function(){this.refreshFetchStatus="ing",this.data={},this.extVersions=[],this.mulilinkVersions=[],this.versions=[],this.collect.configManager.clearAbCache()},e.prototype.openOverlayer=function(t){var e=this;if(function(){if(!document.getElementById(ie)){var t="body { opacity: 0 !important; }",e=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=ie,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)},e.prototype.closeOverlayer=function(){var t;(t=document.getElementById(ie))&&t.parentElement.removeChild(t)},e.prototype.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.destroyInstance)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.destroyInstance){var t=""+s;t=-1===t.indexOf("http")?"https://"+t:t;var e=l(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=[]},e.prototype.fetchAB=function(e){var i=this,n=this.collect.configManager.get(),o=n.header,r=n.user;this.config.enable_anonymousid&&delete r.web_id;var s=r.user_unique_id,a={header:t({aid:this.config.app_id},r||{},o||{},{ab_sdk_version:this.collect.configManager.getAbVersion(),ab_url:window.location.href})},c=this.collect.cryptoData(a);this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 发起AB实验请求",level:"info",logType:"fetch",time:Date.now(),data:a,infoType:"sdk"}),this.collect.requestManager.useRequest({url:this.fetchUrl,data:c,success:function(t){i.fetchStatus="complete",i.refreshFetchStatus="complete";var n=t.data;"success"===t.message?(i.fetchComplete(n,s),e&&e(n)):(i.fetchComplete(null,s),e&&e(null)),i.collect.emit(i.types.AbComplete,n),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,secType:"AB",info:"AB实验请求成功",level:"info",logType:"fetch",time:Date.now(),data:n,infoType:"sdk"})},fail:function(){i.fetchStatus="complete",i.refreshFetchStatus="complete",i.fetchComplete(null,s),e&&e(null),i.collect.emit(i.types.AbTimeout),i.collect.emit(b.DEBUGGER_MESSAGE,{type:b.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})},e.prototype.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}(),re=function(){function e(t,e){this.maxDuration=432e5,this.aliveDTime=6e4,this.options={aliveName:"predefine_page_alive",params:{}},this.collect=t,this.config=e,this.pageStartTime=Date.now(),this.sessionStartTime=this.pageStartTime,this.timerHandler=null,r(e.enable_stay_duration)&&(this.options=Object.assign(this.options,e.enable_stay_duration))}return e.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},e.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},e.prototype.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},e.prototype.disable=function(){this.disableCallback(),this.pageStartTime=Date.now()},e.prototype.sendEvent=function(e,i){void 0===i&&(i=!1);var n=i?this.aliveDTime:Date.now()-this.sessionStartTime;n<0||n>this.aliveDTime||Date.now()-this.pageStartTime>this.maxDuration||(this.collect.beconEvent(this.options.aliveName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),duration:n,is_support_visibility_change:u(),startTime:this.sessionStartTime,hidden:document.visibilityState,leave:e},this.customParmas)),this.sessionStartTime=Date.now(),this.resetParams(location.pathname,document.title,location.href))},e.prototype.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}},e.prototype.setUpTimer=function(){var t=this;return this.timerHandler&&clearInterval(this.timerHandler),setInterval(function(){Date.now()-t.sessionStartTime>t.aliveDTime&&t.sendEvent(!1,!0)},1e3)},e.prototype.visibilitychange=function(){"hidden"===document.visibilityState?this.timerHandler&&(clearInterval(this.timerHandler),this.sendEvent(!1)):"visible"===document.visibilityState&&(this.sessionStartTime=Date.now(),this.timerHandler=this.setUpTimer())},e.prototype.beforeunload=function(){document.hidden||this.sendEvent(!0)},e.prototype.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}(),se=function(){function e(t,e){var i=this;this.maxDuration=432e5,this.aliveDTime=6e4,this.options={closeName:"predefine_page_close",params:{}},this.visibilitychange=function(){"hidden"===document.visibilityState?i.activeEndTime=Date.now():"visible"===document.visibilityState&&(i.activeEndTime&&(i.totalTime+=i.activeEndTime-i.activeStartTime,i.activeTimes+=1),i.activeEndTime=void 0,i.activeStartTime=Date.now())},this.beforeunload=function(){if(i.totalTime+=(i.activeEndTime||Date.now())-i.activeStartTime,i.config.autotrack){try{window.sessionStorage.setItem("_tea_cache_duration",JSON.stringify({duration:i.totalTime,page_title:document.title||location.pathname}))}catch(t){}}i.sendEventPageClose()},this.collect=t,this.config=e,this.maxDuration=e.maxDuration||864e5,this.pageStartTime=Date.now(),r(e.enable_stay_duration)&&(this.options=Object.assign(this.options,e.enable_stay_duration)),this.resetData()}return e.prototype.setParams=function(t,e,i){this.set_path=t,this.set_url=i,this.set_title=e},e.prototype.resetParams=function(t,e,i){this.url_path=t,this.url=i,this.title=e},e.prototype.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()},e.prototype.disable=function(){this.disableCallback()},e.prototype.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)},e.prototype.sendEventPageClose=function(){var e=Date.now()-this.pageStartTime;this.totalTime<0||e<0||this.totalTime>=this.maxDuration||(this.collect.beconEvent(this.options.closeName,t({url_path:this.getParams("url_path"),title:this.getParams("title"),url:this.getParams("url"),active_times:this.activeTimes,duration:this.totalTime,total_duration:e,is_support_visibility_change:u()},this.customParmas)),this.pageStartTime=Date.now(),this.resetData())},e.prototype.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}},e.prototype.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}(),ae=function(){function t(){}return t.prototype.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 re(t,e),this.pageClose=new se(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)}},t.prototype.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)}},t.prototype.enable=function(t,e,i){this.pageAlive.enable(t,e,i),this.pageClose.enable(t,e,i)},t.prototype.disable=function(){this.pageAlive.disable(),this.pageClose.disable()},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayParams",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t.prototype.reset=function(t,e,i){this.disable(),this.enable(t,e,i)},t.prototype.resetStayDuration=function(t,e,i){this.reset(t,e,i),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"SDK 执行 resetStayDuration",level:"info",time:Date.now(),data:{url_path:t,title:e,url:i}})},t}(),ce=function(){function e(){}return e.prototype.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 R(t,e),this.cache={},this.collect.on(M.ProfileSet,function(t){i.setProfile(t)}),this.collect.on(M.ProfileSetOnce,function(t){i.setOnceProfile(t)}),this.collect.on(M.ProfileUnset,function(t){i.unsetProfile(t)}),this.collect.on(M.ProfileIncrement,function(t){i.incrementProfile(t)}),this.collect.on(M.ProfileAppend,function(t){i.appendProfile(t)}),this.collect.on(M.ProfileClear,function(){i.cache={}}),this.ready(M.Profile)},e.prototype.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)}},e.prototype.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(M.SubmitError,{type:"f_data",eventData:e,errorCode:t.e,response:t,startTime:o,endTime:Date.now(),status:r}):i.collect.emit(M.SubmitSuccess,{eventData:e,res:t,response:t,startTime:o,endTime:Date.now(),status:r})},fail:function(t,e,n){i.collect.emit(M.SubmitError,{type:"f_net",eventData:t,errorCode:e,startTime:n,endTime:Date.now()})}}),this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_EVENT,info:"埋点上报成功",time:Date.now(),data:o,code:200,status:"success"})}catch(t){this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message})}},e.prototype.setProfile=function(e){var i=this.formatParams(e);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set",t({},i,{profile:!0})))},e.prototype.setOnceProfile=function(e){var i=this.formatParams(e,!0);i&&Object.keys(i).length&&(this.pushCache(i),this.report("__profile_set_once",t({},i,{profile:!0})))},e.prototype.incrementProfile=function(e){e?this.report("__profile_increment",t({},e,{profile:!0})):console.warn("please check the params, must be object!!!")},e.prototype.unsetProfile=function(e){if(e){var i={};i[e]="1",this.report("__profile_unset",t({},i,{profile:!0}))}else console.warn("please check the key, must be string!!!")},e.prototype.appendProfile=function(e){if(e){var i={};for(var n in e)"string"==typeof e[n]||"Array"===Object.prototype.toString.call(e[n]).slice(8,-1)?i[n]=e[n]:console.warn("please check the value of param: "+n+", must be string or array !!!");Object.keys(i).length&&this.report("__profile_append",t({},i,{profile:!0}))}else console.warn("please check the params, must be object!!!")},e.prototype.pushCache=function(t){var e=this;Object.keys(t).forEach(function(i){e.cache[i]={val:e.clone(t[i]),timestamp:Date.now()}})},e.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),console.log("error")}},e.prototype.compare=function(t,e){try{return JSON.stringify(t)===JSON.stringify(e)}catch(t){return this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),!1}},e.prototype.clone=function(t){try{return JSON.parse(JSON.stringify(t))}catch(e){return this.collect.emit(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:e.message}),t}},e.prototype.unReady=function(){console.warn("sdk is not ready, please use this api after start")},e}(),he=function(){function t(){var t=this;this.setInterval=function(){t.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(){t.isSessionhasEvent&&t.endCurrentSession()},t.sessionInterval)},this.clearInterval=function(){t.clearIntervalFunc&&t.clearIntervalFunc()}}return t.prototype.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()})}},t.prototype.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},t.prototype.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())},t}();function ue(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&&ge(t,"ss"))return!0}return!1}var le=function(t,e){return!!ge(t,e)};function pe(t){for(var e=t;e&&!ue(e,"container");){if("HTML"===e.nodeName||"BODY"===e.nodeName)return t;e=e.parentElement}return e||t}function fe(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 de=function(t,e){return t.hasAttribute?t.hasAttribute(e):t.attributes?!(!t.attributes[e]||!t.attributes[e].specified):void 0},ge=function(t,e){if("string"==typeof e)return de(t,e);if(s(e)){for(var i=!1,n=0;n<e.length;n++){if(de(t,e[n])){i=!0;break}}return i}},me=function(t,e){var i={};if("string"==typeof e)de(t,e)&&(i[e]=t.getAttribute(e));else if(s(e))for(var n=0;n<e.length;n++){de(t,e[n])&&(i[e[n]]=t.getAttribute(e[n]))}return i};var ye=function(){function e(e,i,n){var o=this;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&&(ue(i,"container")||e.track_attr&&le(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)},this.changeEvent=function(t){o.eventHandel({eventType:"dom",eventName:"change"},t)},this.submitEvent=function(t){o.eventHandel({eventType:"dom",eventName:"submit"},t)},this.getPageViewEvent=function(e,i){i&&"pushState"===i&&o.eventHandel({eventType:"dom",eventName:"beat"},t({beat_type:0},e)),o.eventHandel({eventType:"dom",eventName:"page_view"},e)},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}return e.prototype.init=function(t){this.eventHandel=t;var e=this.config.mode;this.addListener(e)},e.prototype.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)}}},e.prototype.removeListener=function(){window.document.removeEventListener("click",this.clickEvent,!0),window.document.removeEventListener("change",this.changeEvent,!0),window.document.removeEventListener("submit",this.submitEvent,!0)},e.prototype.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)),h(function(){e.eventHandel({eventType:"dom",eventName:"beat",eventSend:"becon"},{beat_type:0}),e.beatTime&&clearInterval(i)})}catch(t){}},e}(),ve={eventConfig:{mode:"proxy-capturing",submit:!1,click:!0,change:!1,pv:!0,beat:!0,hashTag:!1,impr:!1},scoutConfig:{mode:"xpath"}},_e=function(){function t(t,e){this.config=t,this.config.eventConfig=Object.assign(this.config.eventConfig,e)}return t.prototype.getConfig=function(){return this.config},t.prototype.setConfig=function(t){return this.config=t},t}();function be(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(),ue(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 Ee(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.clientX,n=t.clientY,o=e.left,r=e.top,s=i-o>=0?i-o:0,a=n-r>=0?n-r:0;return{touch_x:Math.floor(s),touch_y:Math.floor(a)}}(t,r),a=r.element_width,c=r.element_height,h=s.touch_x,u=s.touch_y,l=be(e),p=l.element_path,f=l.positions,d=function(t){var e=pe(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,y=f.map(function(t){return""+t}),v=null;if(window.TEAVisualEditor&&window.TEAVisualEditor.getOriginXpath&&(v=window.TEAVisualEditor.getOriginXpath({xpath:p,positions:y})),o.element_path=v&&v.xpath||p,o.positions=v&&v.positions||y,n&&!n.text&&(o.texts=d,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=u,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&&le(e,i.track_attr)){var _=me(e,i.track_attr);for(var b in _)o[b]=_[b]}if(i.custom_attr)try{if(le(e,i.custom_attr)){_=me(e,i.custom_attr),b=decodeURIComponent(_[i.custom_attr]);var E=JSON.parse(b);if(Object.keys(E))for(var S in E)o[S]=E[S]}}catch(t){console.log("custom attr error")}var w=pe(e);return"A"===w.tagName&&(o.href=w.getAttribute("href")),!1!==i.src&&("IMG"!==e.tagName||e.getAttribute("src").includes("base64")||(o.src=e.getAttribute("src"))),o}var Se,we=function(e,i,n,o,r){return t({event:e},Ee(i,n,o,r),{is_html:1,page_key:window.location.href,page_title:document.title})},Te=function(){function e(t,e){this.ignore={text:!1},this.initConfig=t,this.options=e,this.eventName=e&&"tea"===e.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"},e&&!1===e.text&&(this.ignore.text=!0),e&&e.exposure&&e.exposure.eventName&&(this.eventName.exposure=e.exposure.eventName)}return e.prototype.handleEvent=function(e,i){try{if(fe(e.target))return null;var n="bav2b_click";switch(i){case"click":return n=this.eventName.click,we(n,e,e.target,this.options,this.ignore);case"exposure":return n=this.eventName.exposure,we(n,e,e.target,this.options,this.ignore);case"change":return t({},we(n="bav2b_change",e,e.target,this.options),function(t,e){try{if("bav2b_change"===t)return e.hasAttribute("data-tea-track")?{value:e.value}:{}}catch(t){return{}}}(n,e.target));case"submit":return we(n="bav2b_submit",e,e.target,this.options)}}catch(t){return console.error(t),null}},e.prototype.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},e.prototype.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},e.prototype.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},e.prototype.handleExposureEvent=function(t,e){if(fe(e.target))return null;var i=we(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},e.prototype.handleScrollEvent=function(t,e){var i=we(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}(),ke=function(){function t(t){this.collect=t}return t.prototype.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)},t.prototype.get=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"GET"},e);fetch(t,i)},t.prototype.post=function(t,e){var i=Object.assign({headers:{"content-type":"application/json"},method:"POST"},e);fetch(t,i)},t}(),De=function(){function t(t,e){this._instance=null,this._intersection=t,this.config=e,this._intersection&&this.init()}return t.prototype.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")},t.prototype.attributeChangeObserve=function(t){t.target.hasAttribute("data-exposure")?this.exposureAdd(t,"mutation"):this.exposureRemove(t)},t.prototype.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))})},t.prototype.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)})},t.prototype.exposureAdd=function(t,e){try{this._intersection&&this._intersection.exposureAdd(t,e)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},t.prototype.exposureRemove=function(t){try{this._intersection&&this._intersection.exposureRemove(t)}catch(t){console.log("intersection error",JSON.stringify(t.message))}},t._exposure_observer=null,t}();!function(t){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"}(Se||(Se={}));var Ae,Ce=function(){function t(e,i,n){var o=this;this.backStatus=!1,this.instance=this.buildObserver(),this.collect=e,this.observeMap=t._observer_map,i.autotrack.exposure.ratio?this.ratio=i.autotrack.exposure.ratio:0===i.autotrack.exposure.ratio?this.ratio=0:this.ratio=.5,this.timeLimit=i.autotrack.exposure.stay||0,this.exposureType=Se.NOT_EXPOSURE,this.eventHandle=n,this.hashMap=new Map,this.backStatus=!1,this.lastState=null,this.collect.on("re-start-sdk",function(){o.visibilitychange()}),this.addListen()}return t.prototype.buildObserver=function(){var e=this;if(t._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{t._observer_instance=new IntersectionObserver(function(t){t.forEach(function(t){var i=t.target.observeId,n=e.observeMap.get(i),o=(t.target,t.isIntersecting,t.intersectionRatio);if(n.intersectionRatio=o,o<=.1&&(t.target.backStatus=!1),e.observeMap.set(i,n),o<e.ratio)return n.isIntersecting=!1,n.added=!1,n.exposured=!1,n.startTime=Date.now(),void e.observeMap.set(i,n);if(!n.added){if(n.startTime=Date.now(),n.added=!0,n.isIntersecting=!0,e.timeLimit){var r=setTimeout(function(){try{if(n.isIntersecting&&!n.exposured&&e.observeMap.get(i)){var o=e.observeMap.get(i).intersectionRatio;e.exposureEvent(t,o,i,n)}}catch(t){console.log("IntersectionObserver setTimeout error,msg: "+JSON.stringify(t))}},e.timeLimit);n.wait=r}e.observeMap.set(i,n)}Date.now()-n.startTime>=e.timeLimit&&!n.exposured&&e.exposureEvent(t,o,i,n)})},{threshold:i})}catch(t){console.log("IntersectionObserver error,msg: "+JSON.stringify(t))}return t._observer_instance}return console.log("your browser cannot support IntersectionObserver, so cannot report exposure event, please update"),null},t.prototype.exposureAdd=function(t,e){var i="mutation"===e?t.target:t,n=i.observeId,o=V();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)},t.prototype.exposureRemove=function(t){this.observeMap.has(t.observeId)&&(this.observeMap.delete(t.observeId),this.unobserve(t),t.observeId="",t.visible=!1)},t.prototype.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)},t.prototype.observe=function(t){this.instance&&this.instance.observe(t)},t.prototype.unobserve=function(t){this.instance&&this.instance.unobserve(t)},t.prototype.getExposureDomToExposure=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t.handleBoundingExposure(e)})},t.prototype.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)},t.prototype.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||Se.RESUME_FORM_BACK},t)}},t.prototype.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},t.prototype.getExposureType=function(t){return t.visible?!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Se.RESUME_FORM_PAGE:this.exposureType=Se.LIFECYCLE_SHOW_NEW:(t.hasExposure,!1!==t.backStatus&&(this.backStatus||this.customType||2===window.performance.navigation.type)?this.exposureType=Se.RESUME_FORM_PAGE:this.exposureType=Se.EXPOSURE_ONCE),this.exposureType},t.prototype.addListen=function(){var t=this;this.collect.on("set-exposure-type",function(e){t.customType=e});var e,n,o,r,s=this.visibilitychange.bind(this);if(e=document,n="visibilitychange",o=s,r=!1,e.addEventListener?e.addEventListener(n,o,r):e.attachEven?e.attachEven("on"+n,o):e["on"+n]=o,window.addEventListener("hashchange",function(e){var i=t.hashMap.get(e.oldURL);i&&location.href===i.prev?(t.backStatus=!0,t.exposureType=Se.RESUME_FORM_PAGE):(t.backStatus=!1,t.hashMap.set(location.href,{current:e.newURL,prev:e.oldURL}))}),this.collect.bridgeReport){var a=window.history.pushState;history.pushState=function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"function"==typeof history.onpushstate&&history.onpushstate({state:e});var r=a.call.apply(a,i([history,e],n));return t.lastState=e,r};var c=history.replaceState;history.replaceState=function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});var r=c.call.apply(c,i([history,e],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=Se.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",s,!1)}},t._observer_instance=null,t._observer_map=new Map,t}(),Ie=function(){function t(t,e,i){e.autotrack&&e.autotrack.exposure&&(this._intersection=new Ce(t,e,i),this._observer=new De(this._intersection,e),this._intersection&&this._observer?this.initObserver():console.log("your browser version cannot support exposure event, please update~"))}return t.prototype.initObserver=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-exposure]"),function(e){t._intersection.exposureAdd(e,"intersect")})},t}();!function(t){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"}(Ae||(Ae={}));var xe=function(){function t(t,e){this.distance=30,t.autotrack&&t.autotrack.scroll&&(t.autotrack.scroll.distance&&(this.distance=t.autotrack.scroll.distance),this.eventHandle=e,this.addLinstenr(),this.mutation())}return t.prototype.addLinstenr=function(){var t=this;Array.prototype.forEach.call(document.querySelectorAll("[data-scroll]"),function(e){t.scrollHandle(e)})},t.prototype.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")},t.prototype.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))})},t.prototype.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)})},t.prototype.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,l=t.scrollLeft,p=e.target&&e.target.getAttribute("data-scroll-event")||"";1===u||2===u?r===c&&(a=c-n,Math.abs(a)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:p,params:{$direction:u,$offsetY:a,$offsetX:s}},e)):3!==u&&4!==u||l===h&&(s=h-o,Math.abs(s)>=i.distance&&i.distance&&i.eventHandle({eventType:"dom",eventName:"scroll",event:p,params:{$direction:u,$offsetY:a,$offsetX:s}},e)),n=c,o=h},100);var c=t.scrollTop,h=t.scrollLeft,u=Ae.NOT_SCROLL;c>n?u=Ae.SCROLL_DOWN:c<n?u=Ae.SCROLL_UP:h>o?u=Ae.SCROLL_LEFT:h<o&&(u=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))}},t}(),Oe={hashTag:!1,impr:!1},Re=function(){function t(){}return t.prototype.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)}},t.prototype.ready=function(t){this.collect.set(t);var e=this.config.autotrack;e="object"==typeof e?e:{},e=Object.assign(Oe,e),this.destroyed=!1,this.options=e,this.Config=new _e(ve,this.options),this.Exposure=new Ie(this.collect,this.config,this.handle.bind(this)),this.Scroll=new xe(this.config,this.handle.bind(this)),this.Listener=new ye(e,this.collect,this.Config),this.EventHandle=new Te(this.config,e),this.Request=new ke(this.collect),this.autoTrackStart=!0,this.init()},t.prototype.init=function(){this.Listener.init(this.handle.bind(this))},t.prototype.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)},t.prototype.handleDom=function(t,e){try{var i=t.eventName;if("click"===i||"change"===i||"submit"===i)(s=this.EventHandle.handleEvent(e,i))&&this.Request.send({eventType:"custom"},s);else if("page_view"===i||"page_statistics"===i){var n=void 0;(n="page_view"===i?this.EventHandle.handleViewEvent(e):this.EventHandle.handleStatisticsEvent(e))&&this.Request.send({eventType:"custom"},n)}else if("beat"===i){var o=this.EventHandle.handleBeadtEvent(e),r=t.eventSend;o&&this.Request.send({eventType:"custom",eventSend:r},o)}else if("exposure"===i){(s=this.EventHandle.handleExposureEvent(t,e))&&this.Request.send({eventType:"custom"},s)}else if("scroll"===i){var s;(s=this.EventHandle.handleScrollEvent(t,e))&&this.Request.send({eventType:"custom"},s)}}catch(t){console.log("handel dom event error "+JSON.stringify(t))}},t.prototype.destroy=function(){if(!this.autoTrackStart)return console.warn("engine is undefined, make sure you have called autoTrack.start()");this.autoTrackStart=!1,this.Listener.removeListener()},t}(),Me=function(){function t(){this.autotrack=!1,this.spa=!1,this.cache={},this.allowHash=!1}return t.prototype.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)}},t.prototype.setKey=function(){this.storage=new C,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)},t.prototype.hack=function(){var t=this,e=window.history.pushState;history.pushState=function(n){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];"function"==typeof history.onpushstate&&history.onpushstate({state:n});var s=e.call.apply(e,i([history,n],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 n=history.replaceState;history.replaceState=function(e){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];"function"==typeof history.onreplacestate&&history.onreplacestate({state:e});var s=n.call.apply(n,i([history,e],o));if(t.lastLocation!==location.href){var a=t.getPopStateChangeEventData();return t.setReferCache(t.lastLocation),t.lastLocation=location.href,t.sendPv(a),s}}},t.prototype.setLocation=function(){"undefined"!=typeof window&&(this.lastLocation=window.location.href)},t.prototype.getLocation=function(){return this.lastLocation},t.prototype.init=function(){var t=this.getPopStateChangeEventData();this.collect.emit("route-change",{config:t,init:!0})},t.prototype.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))})},t.prototype.getPopStateChangeEventData=function(){var t=this.pageConfig();return t.is_back=0,t},t.prototype.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(b.DEBUGGER_MESSAGE,{type:b.DEBUGGER_MESSAGE_SDK,info:"发生了异常",level:"error",time:Date.now(),data:t.message}),{}}},t.prototype.sendPv=function(t,e){this.collect.emit("route-change",{config:t,init:!1})},t.prototype.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},t.prototype.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)},t}(),Be=500,Ge=5005;var Pe=function(){function t(){this.verifyReady=!1,this.cleanStatus=!1}return t.prototype.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()},t.prototype.checkUrl=function(){var t=window.location.href,e=p(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")},t.prototype.checkCache=function(){this.eventStorage.length&&this.postVerify(this.eventStorage)},t.prototype.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)},t.prototype.eventStore=function(t){this.cleanStatus||(this.verifyReady?this.postVerify(t):this.eventStorage.push(t))},t.prototype.cleanVerify=function(){this.cleanStatus=!0,this.eventStorage=[],clearInterval(this.heart)},t.prototype.postVerify=function(t){var e=this;try{var i=JSON.parse(JSON.stringify(t));s(t)?i.forEach(function(t){e.fetchLog(t)}):this.fetchLog(i)}catch(t){console.log("web verify post error ~")}},t.prototype.fetchLog=function(t){!function(t,e,i,n,o,r,s,a,c,h){try{var u=new XMLHttpRequest,l=a||"POST";u.open(l,""+t,!0),c&&h?u.setRequestHeader("Content-Type","application/octet-stream;tt-data="+h):u.setRequestHeader("Content-Type","application/json; charset=utf-8"),s&&u.setRequestHeader("X-MCS-AppKey",""+s),n&&(u.withCredentials=!0),i&&(u.timeout=i,u.ontimeout=function(){r&&r(e,Ge)}),u.onload=function(){if(o){var t=null;if(u.responseText){try{t=JSON.parse(u.responseText)}catch(e){t={}}o(t,e)}}},u.onerror=function(){u.abort(),r&&r(e,Be)},c?u.send(e):u.send(JSON.stringify(e))}catch(t){}}(this.domain+"/simulator/h5/log?connection_key="+this.key,t,2e4,!1)},t.prototype.leave=function(){var t=this;document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&t.cleanVerify()}),h(function(){t.cleanVerify()})},t}(),Le=function(){function t(){this.retryWaitTime=3e3,this.retryStatus=!1,this.retryCacheStatus=!1}return t.prototype.apply=function(t,e){var i=this;if(e.enable_storage&&!e.disable_storage&&(this.collect=t,this.config=e,!this.collect.destroyInstance)){var n=t.Types,o=t.adapters.storage;this.storage=new o(!1),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()})}},t.prototype.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)}},t.prototype.storeData=function(t){var e=this.storage.getItem(this.eventKey),i=t.eventData;Object.keys(e).length!==this.storageNum&&(e[Date.now()]=i,this.storage.setItem(this.eventKey,e))},t.prototype.checkStorage=function(){var t=this;try{if(!window.navigator.onLine)return;var e=this.storage.getItem(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.setItem(t.eventKey,i)},function(){},!1)};for(var o in e)n(o)},function(){},!0)}catch(t){console.warn("error check storage")}},t.prototype.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":""})},t}(),Ne=function(){function t(){}return t.prototype.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)},t.prototype.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)}},t.prototype.trackStart=function(t){this.TrackMap.set(t,{startTime:Date.now(),isPause:!1,pauseTime:0,resumeTime:0})},t.prototype.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)}},t.prototype.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))}},t.prototype.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))}},t.prototype.cleanTrack=function(t){this.TrackMap.delete(t)},t}();ee.usePlugin(oe,"ab"),ee.usePlugin(ae,"stay"),ee.usePlugin(Le,"store"),ee.usePlugin(Re,"autotrack"),ee.usePlugin(Ne,"trackDuration"),ee.usePlugin(Pe,"verify"),ee.usePlugin(ce,"profile"),ee.usePlugin(he,"heartbeat"),ee.usePlugin(Me,"route");var Fe=new ee("default"),Ue=ee;exports.Collector=Ue,exports.default=Fe;